/* ===== MANUALS PAGE — Premium 3D Book Shelf =================== */

/* ── Hero ── */
.manuals-hero {
  background: linear-gradient(135deg, #0f1923 0%, #1a2a3a 60%, #0d2137 100%);
  color: #fff;
  padding: 5rem 0 4rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.manuals-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, rgba(32,168,224,.18) 0%, transparent 65%);
  pointer-events: none;
}
.manuals-hero .hero-eyebrow {
  display: inline-block;
  background: rgba(32,168,224,.15);
  border: 1px solid rgba(32,168,224,.35);
  color: #20a8e0;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: .35em 1em;
  border-radius: 100px;
  margin-bottom: 1.25rem;
}
.manuals-hero h1 {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 700;
  margin: 0 0 1rem;
  color: #fff;
}
.manuals-hero .page-hero-lead {
  color: rgba(255,255,255,.72);
  font-size: 1.05rem;
  line-height: 1.7;
  max-width: 580px;
  margin: 0 auto 2.5rem;
}
.manuals-stats {
  display: flex;
  justify-content: center;
  gap: 3rem;
  flex-wrap: wrap;
}
.mstat { display: flex; flex-direction: column; align-items: center; gap: .25rem; }
.mstat-num {
  font-size: 2.4rem;
  font-weight: 700;
  color: #20a8e0;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.mstat-num::after { content: "+"; font-size: 1.4rem; }
.mstat-label { font-size: .8rem; color: rgba(255,255,255,.55); text-transform: uppercase; letter-spacing: .08em; }

/* ── Filter / Search Bar ── */
.manuals-filter-bar {
  position: sticky;
  top: 60px;
  z-index: 90;
  background: rgba(255,255,255,.97);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0,0,0,.08);
  padding: .9rem 0;
  box-shadow: 0 2px 12px rgba(0,0,0,.07);
}
.mfb-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.mfb-search-wrap { position: relative; flex: 1; min-width: 200px; }
.mfb-search-icon {
  position: absolute;
  left: .8rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: .9rem;
  pointer-events: none;
}
#manuals-search {
  width: 100%;
  padding: .55rem 1rem .55rem 2.3rem;
  border: 1.5px solid #d8dde5;
  border-radius: 100px;
  font-family: 'Kanit', sans-serif;
  font-size: .9rem;
  background: #f8f9fa;
  transition: border-color .2s, box-shadow .2s;
  box-sizing: border-box;
}
#manuals-search:focus {
  outline: none;
  border-color: #20a8e0;
  box-shadow: 0 0 0 3px rgba(32,168,224,.15);
  background: #fff;
}
.mfb-tabs { display: flex; gap: .4rem; flex-wrap: wrap; }
.mfb-tab {
  padding: .42rem .9rem;
  border: 1.5px solid #d8dde5;
  border-radius: 100px;
  background: transparent;
  font-family: 'Kanit', sans-serif;
  font-size: .82rem;
  cursor: pointer;
  color: #555;
  transition: all .18s;
  white-space: nowrap;
}
/* #20a8e0 คือฟ้าน้ำทะเลประจำหน้าคู่มือ อ่านออกดีบนพื้นเข้ม แต่บนพื้นขาวได้แค่ 2.71:1
   จึงใช้เฉดเข้มกว่า (--cyan-ink) เมื่อวางบนพื้นสว่าง */
.mfb-tab:hover { border-color: var(--cyan-ink); color: var(--cyan-ink); }
.mfb-tab.is-active { background: var(--cyan-ink); border-color: var(--cyan-ink); color: #fff; font-weight: 600; }
.mfb-count { font-size: .8rem; color: var(--text-soft); white-space: nowrap; min-width: 70px; text-align: right; }

/* ── Section ── */
.manuals-section { padding: 3.5rem 0 5rem; }

/* ── Book Shelf ── */
.book-shelf {
  display: flex;
  flex-wrap: wrap;
  gap: 3.5rem 2.8rem;
  perspective: 1600px;
}

/* ══════════════════════════════════════════
   📖 PREMIUM REALISTIC 3D BOOK
══════════════════════════════════════════ */
.book-item {
  opacity: 0;
  transform: translateY(50px) rotateX(8deg);
  transition: opacity .55s ease, transform .55s ease;
}
.book-item.is-visible {
  opacity: 1;
  transform: translateY(0) rotateX(0);
}

/* The 3D wrapper — bigger than before */
.book-3d {
  width: 162px;
  height: 230px;
  position: relative;
  transform-style: preserve-3d;
  transform: rotateY(-22deg);
  transition: transform .45s cubic-bezier(.25,.46,.45,.94), filter .45s ease;
  cursor: pointer;
  filter: drop-shadow(8px 14px 22px rgba(0,0,0,.38));
}
.book-3d:hover {
  transform: rotateY(-4deg) translateY(-10px) scale(1.04);
  filter: drop-shadow(16px 24px 34px rgba(0,0,0,.44));
}

/* ── Front Cover ── */
.book-cover {
  position: absolute;
  top: 0;
  left: 18px;
  width: 144px;
  height: 230px;
  border-radius: 1px 5px 5px 1px;
  overflow: hidden;
  backface-visibility: hidden;
}

/* Cover image */
.book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── Placeholder cover — premium book design ── */
.book-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  position: relative;
  overflow: hidden;
}

/* Watermark "R" monogram — big translucent letter */
.book-placeholder::before {
  content: "R";
  position: absolute;
  right: -12px;
  bottom: 30px;
  font-size: 9rem;
  font-weight: 900;
  font-family: 'Kanit', sans-serif;
  color: rgba(255,255,255,.05);
  line-height: 1;
  pointer-events: none;
  user-select: none;
}

/* Bottom publisher band */
.book-placeholder::after {
  content: "ROPEMAN LIBRARY";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 28px;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .46rem;
  font-weight: 700;
  letter-spacing: .18em;
  color: rgba(255,255,255,.65);
  font-family: 'Kanit', sans-serif;
  text-align: center;
  line-height: 28px;
}

/* Top header band — category color stripe */
.book-header-band {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 44px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 6px;
  background: rgba(0,0,0,.3);
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.book-cat-label {
  font-size: .48rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(255,255,255,.75);
  font-family: 'Kanit', sans-serif;
  flex: 1;
}

.book-cat-icon {
  font-size: 1.3rem;
  line-height: 1;
  opacity: .9;
}

/* Decorative divider below header */
.book-divider {
  position: absolute;
  top: 44px;
  left: 10px; right: 10px;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(255,255,255,.25), transparent);
}

/* Title area — centered in the middle zone */
.book-title-text {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 56px;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.5;
  color: #fff;
  font-family: 'Kanit', sans-serif;
  text-shadow:
    0 1px 6px rgba(0,0,0,.5),
    0 0 20px rgba(0,0,0,.2);
  /* Slight emboss: light above, dark below */
  -webkit-text-stroke: 0.3px rgba(255,255,255,.2);
}

/* Horizontal rules framing the title */
.book-rule-top {
  position: absolute;
  left: 10px; right: 10px;
  top: 52px;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(255,255,255,.3), transparent);
}
.book-rule-bottom {
  position: absolute;
  left: 10px; right: 10px;
  bottom: 38px;
  height: 1px;
  background: linear-gradient(to right, transparent, rgba(255,255,255,.2), transparent);
}

/* Cover gloss/sheen overlay */
.book-cover::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    linear-gradient(110deg, rgba(255,255,255,.13) 0%, rgba(255,255,255,.04) 30%, transparent 55%),
    linear-gradient(to bottom, rgba(255,255,255,.06) 0%, transparent 30%),
    linear-gradient(to right, rgba(0,0,0,.18) 0%, transparent 25%);
  pointer-events: none;
  z-index: 3;
}

/* ── Spine ── */
.book-spine {
  position: absolute;
  top: 0;
  left: 0;
  width: 18px;
  height: 230px;
  border-radius: 3px 0 0 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  gap: 0;
}

/* Decorative dots at top & bottom of spine */
.book-spine::before,
.book-spine::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255,255,255,.3);
}
.book-spine::before { top: 8px; }
.book-spine::after  { bottom: 8px; }

.book-spine-text {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  font-size: .46rem;
  font-weight: 700;
  letter-spacing: .1em;
  color: rgba(255,255,255,.8);
  font-family: 'Kanit', sans-serif;
  white-space: nowrap;
  overflow: hidden;
  max-height: 190px;
  text-overflow: ellipsis;
  text-shadow: 0 1px 3px rgba(0,0,0,.5);
  padding: 14px 0;
}

/* Page stack (right side) — thicker, more realistic */
.book-pages {
  position: absolute;
  top: 3px;
  right: -7px;
  width: 7px;
  height: 224px;
  border-radius: 0 3px 3px 0;
  background:
    repeating-linear-gradient(
      to bottom,
      #f5efe3 0px, #f5efe3 1px,
      #ede6d6 1px, #ede6d6 2px,
      #f0ead9 2px, #f0ead9 3px,
      #e8e0cc 3px, #e8e0cc 4px
    );
  box-shadow:
    3px 0 6px rgba(0,0,0,.15),
    inset -1px 0 2px rgba(0,0,0,.08);
}

/* ── Color Palette ── */

/* Navy */
[data-color="navy"] .book-placeholder {
  background: linear-gradient(155deg, #1e4080 0%, #0c2150 40%, #091840 100%);
}
[data-color="navy"] .book-spine {
  background: linear-gradient(to bottom, #071535 0%, #0d2555 50%, #071535 100%);
}
[data-color="navy"] .book-header-band { background: rgba(10,30,80,.55); }

/* Red */
[data-color="red"] .book-placeholder {
  background: linear-gradient(155deg, #c42020 0%, #8a0f0f 40%, #6e0808 100%);
}
[data-color="red"] .book-spine {
  background: linear-gradient(to bottom, #550808 0%, #8a1010 50%, #550808 100%);
}
[data-color="red"] .book-header-band { background: rgba(80,10,10,.55); }

/* Green */
[data-color="green"] .book-placeholder {
  background: linear-gradient(155deg, #1e6840 0%, #0d4224 40%, #082e18 100%);
}
[data-color="green"] .book-spine {
  background: linear-gradient(to bottom, #061f10 0%, #0d3a1e 50%, #061f10 100%);
}
[data-color="green"] .book-header-band { background: rgba(5,30,15,.55); }

/* Orange */
[data-color="orange"] .book-placeholder {
  background: linear-gradient(155deg, #d86000 0%, #9a4000 40%, #7a3000 100%);
}
[data-color="orange"] .book-spine {
  background: linear-gradient(to bottom, #5c2400 0%, #8a3800 50%, #5c2400 100%);
}
[data-color="orange"] .book-header-band { background: rgba(70,30,0,.55); }

/* Purple */
[data-color="purple"] .book-placeholder {
  background: linear-gradient(155deg, #5e22a0 0%, #35106e 40%, #220858 100%);
}
[data-color="purple"] .book-spine {
  background: linear-gradient(to bottom, #180640 0%, #2d0a5c 50%, #180640 100%);
}
[data-color="purple"] .book-header-band { background: rgba(25,8,55,.55); }

/* Teal */
[data-color="teal"] .book-placeholder {
  background: linear-gradient(155deg, #0e6868 0%, #064040 40%, #042e2e 100%);
}
[data-color="teal"] .book-spine {
  background: linear-gradient(to bottom, #022020 0%, #064040 50%, #022020 100%);
}
[data-color="teal"] .book-header-band { background: rgba(2,20,20,.55); }

/* Gray */
[data-color="gray"] .book-placeholder {
  background: linear-gradient(155deg, #424242 0%, #242424 40%, #151515 100%);
}
[data-color="gray"] .book-spine {
  background: linear-gradient(to bottom, #0d0d0d 0%, #222 50%, #0d0d0d 100%);
}
[data-color="gray"] .book-header-band { background: rgba(10,10,10,.55); }

/* Brown */
[data-color="brown"] .book-placeholder {
  background: linear-gradient(155deg, #6a4020 0%, #3e2010 40%, #2c1408 100%);
}
[data-color="brown"] .book-spine {
  background: linear-gradient(to bottom, #1a0c04 0%, #3a1c0a 50%, #1a0c04 100%);
}
[data-color="brown"] .book-header-band { background: rgba(20,10,4,.55); }

/* ── Book label below cover ── */
.book-label {
  margin-top: .85rem;
  width: 162px;
}
.book-label-title {
  font-size: .73rem;
  font-weight: 600;
  color: var(--color-heading, #111);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.book-label-badge {
  display: inline-block;
  margin-top: .3rem;
  font-size: .6rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  background: rgba(32,168,224,.12);
  color: var(--cyan-ink);
  padding: .2em .6em;
  border-radius: 4px;
}

/* Load more */
.manuals-load-more { text-align: center; padding: 2.5rem 0 1rem; }

/* .btn-secondary ถูกออกแบบมาใช้บนพื้นเข้ม (ตัวอักษรสีขาว) แต่ปุ่มนี้อยู่บนพื้นสว่าง
   ของเดิมจึงได้ contrast แค่ 1.02:1 คือแทบมองไม่เห็น */
.manuals-load-more .btn-secondary {
  background: #fff;
  color: var(--cyan-ink);
  border: 1.5px solid var(--border-soft);
}
.manuals-load-more .btn-secondary:hover { border-color: var(--cyan-ink); }

.book-shelf-empty { color: var(--text-soft); font-size: .95rem; padding: 3rem 0; text-align: center; }

/* Responsive */
@media (max-width: 600px) {
  .book-3d { width: 130px; height: 185px; }
  .book-cover { left: 14px; width: 116px; height: 185px; }
  .book-spine { width: 14px; height: 185px; }
  .book-pages { height: 179px; width: 5px; right: -5px; }
  .book-header-band { height: 36px; }
  .book-title-text { font-size: .65rem; top: 46px; }
  .book-label { width: 130px; }
  .book-shelf { gap: 2.8rem 1.8rem; justify-content: center; }
  .mfb-tabs { gap: .3rem; }
  .mfb-tab { font-size: .75rem; padding: .35rem .7rem; }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .manuals-filter-bar {
    background: rgba(18,24,32,.97);
    border-bottom-color: rgba(255,255,255,.08);
  }
  :root:not([data-theme="light"]) #manuals-search {
    background: #1e2a38; border-color: #2e3f52; color: #e0e8f0;
  }
  :root:not([data-theme="light"]) .mfb-tab { border-color: #2e3f52; color: #aab8cc; }
  :root:not([data-theme="light"]) .mfb-tab:hover { border-color: #20a8e0; color: #20a8e0; }
  :root:not([data-theme="light"]) .book-label-title { color: #e0e8f0; }
}
:root[data-theme="dark"] .manuals-filter-bar { background: rgba(18,24,32,.97); border-bottom-color: rgba(255,255,255,.08); }
:root[data-theme="dark"] #manuals-search { background: #1e2a38; border-color: #2e3f52; color: #e0e8f0; }
:root[data-theme="dark"] .mfb-tab { border-color: #2e3f52; color: #aab8cc; }
:root[data-theme="dark"] .book-label-title { color: #e0e8f0; }
