/* === STORY ARCHIVE — Poster Mode Refined v2 === */

:root {
  --chx-bg: #f9f9f9;
  --chx-bg-hover: #f1f6ff;
  --chx-page-bg: #f7f7f7;
  --chx-border: #e2e2e2;
  --chx-shadow: rgba(0, 0, 0, 0.05);
  --chx-gap: 18px;
  --chx-radius: 12px;
}

/* Container */
.today-story-archive {
  width: 90%;
  max-width: 800px;
  margin: 40px auto;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  color: #222;
}


/* Wrapper flex để h1 + nút nằm cùng hàng */
.archive-header {
  display: flex;
  justify-content: space-between; /* h1 bên trái, nút bên phải */
  align-items: center;           /* canh giữa theo trục dọc */
  margin-bottom: 12px;           /* khoảng cách trước kệ sách */
  position: relative;            /* để vẽ đường gạch ngang */
}

/* Title */
.archive-title {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 20px;
  position: relative;
  padding-bottom: 6px;          /* khoảng cách với gạch ngang */
}

/* Gạch ngang dưới h1 */
.archive-title::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 60px;                  /* chiều dài đường gạch */
  height: 3px;                  /* độ dày đường gạch */
  background-color: #ffab00;    /* màu gạch */
  border-radius: 2px;
}


/* Grid layout */
.story-shelf {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--chx-gap);
  margin-bottom: 30px;
}
@media (max-width: 1024px) { .story-shelf { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px)  { .story-shelf { grid-template-columns: repeat(2, 1fr); gap: 14px; } }

/* Poster card */

.story-book {
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 3px 6px rgba(0,0,0,0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
    background-color: #EEEEEE; 

}

.story-book-inner {
  display: block;
  transform-origin: center center;

  text-decoration: none;
  background: #EEEEEE; 
  color: inherit;
}

/* Ratio box (3:4) */
.poster-ratio {
  position: relative;
  width: 100%;
  padding-top: 115%;
}

.poster-content {
  position: absolute;
  inset: 0;
  background: var(--chx-bg);
  background-color: #EEEEEE; 
  border: 1px solid var(--chx-border);
  border-radius: var(--chx-radius);
  box-shadow: 0 6px 14px var(--chx-shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 14px;
  transition: all 0.25s ease;
}

/* Hover effect */
.story-book:hover .poster-content {
  background: var(--chx-bg-hover);
  transform: translateY(-5px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.1);
  background-color: #D8C493; /* vàng sách */

}

/* ====== Content inside ====== */
.story-info {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  height: 100%;
  text-align: left;
}

/* Title */
.story-title {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
  margin-top: 10px;
  margin-bottom: 12px;
  background: #eee;
  background-color: #E7E7E7; /*#E8E8E8; */
  padding: 8px 10px;
  border-radius: 6px;

  display: -webkit-box;
  -webkit-line-clamp: 3; /* fix: show up to 3 lines */
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;

  border-bottom: 2px solid #D9D8DA; /* màu gạch ngang #ffab00*/
  padding-bottom: 10px; /* để text không sát đường */
}

.story-meta-wrap {
  margin-top: auto; 
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Category */
.story-meta-cat {
  font-size: 13px;
  color: #333;
}

/* Type (pill no round) */
.story-type-pill {
  display: inline-block;
  padding: 2px 8px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 4px;
  color: #fff;
}

/* ====== Type color mapping ====== */
.type-humor .story-type-pill { background: #f9a825; }
.type-inspiration .story-type-pill { background: #1e88e5; }
.type-lesson .story-type-pill { background: #43a047; }
.type-warning .story-type-pill { background: #e53935; }
.type-case .story-type-pill { background: #8e24aa; }
.type-quote .story-type-pill { background: #6d4c41; }
.type-personal .story-type-pill { background: #fb8c00; }
.type-tip .story-type-pill { background: #00acc1; }
.type-strategy .story-type-pill { background: #3949ab; }
.type-thinking .story-type-pill { background: #7cb342; }
.type-default .story-type-pill { background: #999; }

.pagination { margin-top: 20px; text-align: center; }
.story-type-pill {
  opacity: 0.5; /* 0.0–1.0, càng nhỏ càng mờ */
}

/* Mobile fine-tune */
@media (max-width: 480px) {
  .poster-content { padding: 12px; }
  .story-title {
    font-size: 16px;     /* tăng kích thước chữ */
    line-height: 1.1;    /* cho dễ đọc */
    -webkit-line-clamp: 3;
  }
}

/* ===== Mobile grid toggle ===== */
.mobile-grid-toggle {
  display: none; /* ẩn mặc định trên PC */
}

@media (max-width: 768px) {
  .mobile-grid-toggle {
    display: flex;                /* hiển thị flex trên mobile */
    justify-content: flex-end;    /* đẩy sát bên phải */
    margin: 0;                    /* loại bỏ margin thừa */
    gap: 0px;                     /* khoảng cách giữa 2 nút */
  }

  /* Nút to lên */
  .mobile-grid-toggle button {
    font-size: 20px;       /* tăng kích thước chữ */
    padding: 0px 0px;     /* tăng padding để nút bự */
    min-width: 40px;       /* đảm bảo không nhỏ hơn */
    min-height: 10px;
    gap: 0px;              /* khoảng cách giữa 2 nút */
    background-color: #ccc; /* mặc định là xám */
    color: #222;
    border: none;
    border-radius: 6px;
  }


  .mobile-grid-toggle button.active {
    background-color: #f9a825;    /* màu nổi bật nút active */
    color: #fff;
    border-color: #f9a825;
    transform: scale(0.95);
  }

    .mobile-grid-toggle button:not(.active):hover {
        background-color: #f1f1f1;
    }
}


/* ===== Khi chọn 1 story/line ===== */
  .story-shelf.single-line {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .story-shelf.single-line .story-book {
    width: 100%;
  }

  .story-shelf.single-line .poster-content {
    padding: 24px 20px; /* zoom nội dung */
  }

  .story-shelf.single-line .story-title {
    font-size: 32px; /* zoom title */
    padding: 12px 14px;
  }

 .story-shelf.single-line .story-title {
  border-bottom: 2px solid #D9D8DA; /* màu gạch ngang #ffab00*/
  padding-bottom: 15px; /* để text không sát đường */
 }

  .story-shelf.single-line .story-meta-cat,
  .story-shelf.single-line .story-type-pill {
    font-size: 20px; /* tăng font meta */
  }

    .story-meta-wrap {
      margin-bottom: 10px; /* nhích lên từ top của flex container */
      display: flex;
      flex-direction: column;
      gap: 4px;
    }
}

/* === STORY ARCHIVE — Poster Mode Refined v2 === */

:root {
  --chx-bg: #f9f9f9;
  --chx-bg-hover: #f1f6ff;
  --chx-page-bg: #f7f7f7;
  --chx-border: #e2e2e2;
  --chx-shadow: rgba(0, 0, 0, 0.05);
  --chx-gap: 18px;
  --chx-radius: 12px;
}

/* Container */
.today-story-archive {
  width: 90%;
  max-width: 800px;
  margin: 40px auto;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  color: #222;
}


/* Wrapper flex để h1 + nút nằm cùng hàng */
.archive-header {
  display: flex;
  justify-content: space-between; /* h1 bên trái, nút bên phải */
  align-items: center;           /* canh giữa theo trục dọc */
  margin-bottom: 12px;           /* khoảng cách trước kệ sách */
  position: relative;            /* để vẽ đường gạch ngang */
}

/* Title */
.archive-title {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 20px;
  position: relative;
  padding-bottom: 6px;          /* khoảng cách với gạch ngang */
}

/* Gạch ngang dưới h1 */
.archive-title::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 60px;                  /* chiều dài đường gạch */
  height: 3px;                  /* độ dày đường gạch */
  background-color: #ffab00;    /* màu gạch */
  border-radius: 2px;
}


/* Grid layout */
.story-shelf {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--chx-gap);
  margin-bottom: 30px;
}
@media (max-width: 1024px) { .story-shelf { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px)  { .story-shelf { grid-template-columns: repeat(2, 1fr); gap: 14px; } }

/* Poster card */

.story-book {
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 3px 6px rgba(0,0,0,0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
    background-color: #EEEEEE; 

}

.story-book-inner {
  display: block;
  transform-origin: center center;

  text-decoration: none;
  background: #EEEEEE; 
  color: inherit;
}

/* Ratio box (3:4) */
.poster-ratio {
  position: relative;
  width: 100%;
  padding-top: 115%;
}

.poster-content {
  position: absolute;
  inset: 0;
  background: var(--chx-bg);
  background-color: #EEEEEE; 
  border: 1px solid var(--chx-border);
  border-radius: var(--chx-radius);
  box-shadow: 0 6px 14px var(--chx-shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 16px 14px;
  transition: all 0.25s ease;
}

/* Hover effect */
.story-book:hover .poster-content {
  background: var(--chx-bg-hover);
  transform: translateY(-5px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.1);
  background-color: #D8C493; /* vàng sách */

}

/* ====== Content inside ====== */
.story-info {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  height: 100%;
  text-align: left;
}

/* Title */
.story-title {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.35;
  margin-top: 10px;
  margin-bottom: 12px;
  background: #eee;
  background-color: #E7E7E7; /*#E8E8E8; */
  padding: 8px 10px;
  border-radius: 6px;

  display: -webkit-box;
  -webkit-line-clamp: 3; /* fix: show up to 3 lines */
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;

  border-bottom: 2px solid #D9D8DA; /* màu gạch ngang #ffab00*/
  padding-bottom: 10px; /* để text không sát đường */
}

.story-meta-wrap {
  margin-top: auto; 
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Category */
.story-meta-cat {
  font-size: 13px;
  color: #333;
}

/* Type (pill no round) */
.story-type-pill {
  display: inline-block;
  padding: 2px 8px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 4px;
  color: #fff;
}

/* ====== Type color mapping ====== */
.type-humor .story-type-pill { background: #f9a825; }
.type-inspiration .story-type-pill { background: #1e88e5; }
.type-lesson .story-type-pill { background: #43a047; }
.type-warning .story-type-pill { background: #e53935; }
.type-case .story-type-pill { background: #8e24aa; }
.type-quote .story-type-pill { background: #6d4c41; }
.type-personal .story-type-pill { background: #fb8c00; }
.type-tip .story-type-pill { background: #00acc1; }
.type-strategy .story-type-pill { background: #3949ab; }
.type-thinking .story-type-pill { background: #7cb342; }
.type-default .story-type-pill { background: #999; }

.pagination { margin-top: 20px; text-align: center; }
.story-type-pill {
  opacity: 0.5; /* 0.0–1.0, càng nhỏ càng mờ */
}

/* Mobile fine-tune */
@media (max-width: 480px) {
  .poster-content { padding: 12px; }
  .story-title {
    font-size: 16px;     /* tăng kích thước chữ */
    line-height: 1.1;    /* cho dễ đọc */
    -webkit-line-clamp: 3;
  }
}

/* ===== Mobile grid toggle ===== */
.mobile-grid-toggle {
  display: none; /* ẩn mặc định trên PC */
}

@media (max-width: 768px) {
  .mobile-grid-toggle {
    display: flex;                /* hiển thị flex trên mobile */
    justify-content: flex-end;    /* đẩy sát bên phải */
    margin: 0;                    /* loại bỏ margin thừa */
    gap: 0px;                     /* khoảng cách giữa 2 nút */
  }

  /* Nút to lên */
  .mobile-grid-toggle button {
    font-size: 20px;       /* tăng kích thước chữ */
    padding: 0px 0px;     /* tăng padding để nút bự */
    min-width: 40px;       /* đảm bảo không nhỏ hơn */
    min-height: 10px;
    gap: 0px;              /* khoảng cách giữa 2 nút */
    background-color: #ccc; /* mặc định là xám */
    color: #222;
    border: none;
    border-radius: 6px;
  }


  .mobile-grid-toggle button.active {
    background-color: #f9a825;    /* màu nổi bật nút active */
    color: #fff;
    border-color: #f9a825;
    transform: scale(0.95);
  }

    .mobile-grid-toggle button:not(.active):hover {
        background-color: #f1f1f1;
    }
}


/* ===== Khi chọn 1 story/line ===== */
  .story-shelf.single-line {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .story-shelf.single-line .story-book {
    width: 100%;
  }

  .story-shelf.single-line .poster-content {
    padding: 24px 20px; /* zoom nội dung */
  }

  .story-shelf.single-line .story-title {
    font-size: 32px; /* zoom title */
    padding: 12px 14px;
  }

 .story-shelf.single-line .story-title {
  border-bottom: 2px solid #D9D8DA; /* màu gạch ngang #ffab00*/
  padding-bottom: 15px; /* để text không sát đường */
 }

  .story-shelf.single-line .story-meta-cat,
  .story-shelf.single-line .story-type-pill {
    font-size: 20px; /* tăng font meta */
  }

    .story-meta-wrap {
      margin-bottom: 10px; /* nhích lên từ top của flex container */
      display: flex;
      flex-direction: column;
      gap: 4px;
    }
}

/* ========== 1. WRAPPER LAYOUT ========== */
.archive-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 12px 0 20px 0;
}

/* PC: 2 ô chia 50/25/25 */
.search-wrapper {
    flex: 0 0 50%;
}
#story-category-dropdown,
#story-type-dropdown {
    flex: 0 0 25%;
}


/* PC layout */
@media (min-width: 769px) {
    .archive-filters {
        display: flex;
        gap: 10px;
        margin: 12px 0 20px 0;
        flex-wrap: nowrap;
    }
}

/* Mobile: 2 hàng — Search full trên, dropdown 50% dưới */
@media (max-width: 768px) {
    .archive-filters {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
    }
    .search-wrapper {
        flex: 0 0 100%; /* hàng 1: full width */
    }
    #story-category-dropdown,
    #story-type-dropdown {
        flex: 0 0 calc(50% - 3px); /* hàng 2: chia đều */
    }
}


/* ========== 2. SEARCH BOX ========== */
#story-search-input {
    width: 100%;
    padding: 8px 26px 8px 10px; /* chừa chỗ nút clear */
    font-size: 15px;
    border-radius: 6px;
    border: 1px solid #ccc;
    box-sizing: border-box;
}

/* ========== 3. CLEAR BUTTON ( × ) ========== */
.clear-btn {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 16px;
    display: none;
    color: #999;
    background: transparent;
    border: none;
}

.clear-btn:hover {
    color: #333;
}


/* ===== CSS phần footer Archive STory ===== */
.taxonomy-navigation {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
}

.taxonomy-section {
    margin-bottom: 20px;
}

.taxonomy-title {
    font-weight: bold;
    margin-bottom: 8px;
    font-size: 1rem;
    color: #333;
}

.taxonomy-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 10px;
    background-color: #f0f0f0;
    text-decoration: none;
    color: #333;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.chip:hover,
.chip.active {
    background-color: #cce5ff;
    color: #004085;
}

.chip-count {
    font-size: 0.8rem;
    color: #666;
    margin-left: 4px;
}

.hidden {
    display: none;
}

.more-chips {
    cursor: pointer;
    color: #007bff;
    font-size: 0.9rem;
    margin-left: 4px;
}


/* ===== CSS phần selected filter ===== */
#selected-filters {
    margin: 10px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.selected-pill {
    background: #f0f0f0;
    padding: 4px 8px;
    border-radius: 10px;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
}
.selected-pill .remove {
    margin-left: 6px;
    cursor: pointer;
}
.chip.active {
    background: #0073e6;
    color: #fff;
}

/* ===== Go Top Button - Simple WordPress Style ===== */
#go-top {
    display: none;
    position: fixed;
    bottom: 70px;
    right: 5px; /* sát lề phải */
    z-index: 999;
    background: #E7E7E7; /* màu nút WP */
    color: #0073aa;
    border: none;
    padding: 6px 12px; /* size nhỏ vừa phải */
    border-radius: 50px;
    font-size: 13px;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: background 0.2s ease, transform 0.2s ease;
}

#go-top:hover {
    background: #006799;
    transform: translateY(-2px);
}


/* ===== CSS phần footer Archive STory ===== */
.taxonomy-navigation {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
}

.taxonomy-section {
    margin-bottom: 20px;
}

.taxonomy-title {
    font-weight: bold;
    margin-bottom: 8px;
    font-size: 1rem;
    color: #333;
}

.taxonomy-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 10px;
    background-color: #f0f0f0;
    text-decoration: none;
    color: #333;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.chip:hover,
.chip.active {
    background-color: #cce5ff;
    color: #004085;
}

.chip-count {
    font-size: 0.8rem;
    color: #666;
    margin-left: 4px;
}

.hidden {
    display: none;
}

.more-chips {
    cursor: pointer;
    color: #007bff;
    font-size: 0.9rem;
    margin-left: 4px;
}


/* ===== CSS phần selected filter ===== */
#selected-filters {
    margin: 10px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.selected-pill {
    background: #f0f0f0;
    padding: 4px 8px;
    border-radius: 10px;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
}
.selected-pill .remove {
    margin-left: 6px;
    cursor: pointer;
}
.chip.active {
    background: #0073e6;
    color: #fff;
}

/* ===== Go Top Button - Simple WordPress Style ===== */
#go-top {
    display: none;
    position: fixed;
    bottom: 70px;
    right: 5px; /* sát lề phải */
    z-index: 999;
    background: #E7E7E7; /* màu nút WP */
    color: #0073aa;
    border: none;
    padding: 6px 12px; /* size nhỏ vừa phải */
    border-radius: 50px;
    font-size: 13px;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    transition: background 0.2s ease, transform 0.2s ease;
}

#go-top:hover {
    background: #006799;
    transform: translateY(-2px);
}

/* ===== CSS NÚT LOAD MORE +10 ===== */

#story-load-more {
    display: inline-block;
    padding: 5px 20px;
    margin: 10px 5px;
    font-size: 14px;
    font-weight: 600;
    background: linear-gradient(135deg, #0073aa, #00bfff);
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

#story-load-more:hover {
    background: linear-gradient(135deg, #005f80, #0099cc);
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

#story-load-more:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}



/* Hiệu ứng fade + slide cho item mới */
.story-book {
    transition: opacity 0.5s ease, transform 0.5s ease;
}
/* === Animate story cards === */
.story-book.new-item {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

/* Khi JS thêm .show */
.story-book.new-item.show {
  opacity: 1;
  transform: translateY(0);
}

/* === Animate pill type (type-pill) === */
.story-book.new-item .story-type-pill {
  display: inline-block;   /* ensure inline-block for width animation */
  width: 0;                /* start nhỏ */
  opacity: 0;              /* ẩn */
  transition: width 0.4s ease, opacity 0.4s ease;
  white-space: nowrap;     /* tránh wrap khi expand */
  overflow: hidden;
}

.story-book.new-item.show .story-type-pill {
  width: auto;             /* expand tự nhiên */
  opacity: 1;
}

/* Nút Load More khi loading */
#story-load-more.loading {
    background-color: #6FBD86 !important;
    color: #fff;
    cursor: not-allowed;
}


/* === CSS nút Load more đẹp như Pinterest */

.story-book {
  opacity: 1;
  transform: translateY(0);
  transition: all 0.4s ease;
}

.story-book.newly-added {
  opacity: 0;
  transform: translateY(20px);
}
.story-book.loaded {
  opacity: 1;
  transform: translateY(0);
}
/* ========================= */
