/* ═══════════════════════════════════════════════════════
   DENTÉ FLIPBOOK — Rebranded to site tokens
   Poppins throughout · white/silver/black palette
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,200;0,300;0,400;0,500;0,600;0,700&display=swap');

/* ── Reset & tokens ───────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #090909;
  --bg2:          #101010;
  --bg3:          #181818;
  --surface:      #1e1e1e;
  --surface2:     #272727;
  --border:       rgba(255,255,255,0.07);
  --border-mid:   rgba(255,255,255,0.13);
  --border-hi:    rgba(255,255,255,0.25);
  --white:        #ffffff;
  --off-white:    #f0ede8;
  --muted:        rgba(255,255,255,0.44);
  --dim:          rgba(255,255,255,0.22);
  --faint:        rgba(255,255,255,0.09);
  --silver:       #c6c2bc;
  --silver-dim:   rgba(198,194,188,0.35);
  --accent:       #ffffff;
  --accent-border:rgba(255,255,255,0.25);
  --ease:         0.22s ease;
  --font:         'Poppins', sans-serif;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--white);
  font-weight: 300;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: var(--font); }

/* ══════════════════════════════════════════════
   LIBRARY PAGE
   ══════════════════════════════════════════════ */

.library-page { min-height: 100vh; display: flex; flex-direction: column; }

/* ── Nav ── */
.lib-nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(9,9,9,0.97);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 64px; height: 60px;
}
.lib-nav-logo {
  font-size: 13px; font-weight: 700;
  letter-spacing: 0.28em; text-transform: uppercase;
  color: var(--white);
}
.lib-nav-back {
  font-size: 9px; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--muted);
  transition: color var(--ease);
  display: flex; align-items: center; gap: 8px;
}
.lib-nav-back:hover { color: var(--white); }
.lib-nav-back svg { width: 14px; height: 14px; }

/* ── Hero ── */
.lib-hero {
  padding: 80px 64px 64px;
  border-bottom: 1px solid var(--border);
}
.lib-hero-kicker {
  font-size: 9px; font-weight: 500;
  letter-spacing: 0.32em; text-transform: uppercase;
  color: var(--silver); margin-bottom: 16px;
  display: flex; align-items: center; gap: 12px;
}
.lib-hero-kicker::before {
  content: ''; width: 24px; height: 1px;
  background: var(--silver); flex-shrink: 0;
}
.lib-hero h1 {
  font-weight: 700; font-size: clamp(40px, 5vw, 72px);
  letter-spacing: 0.03em; text-transform: uppercase;
  line-height: 0.95; margin-bottom: 16px;
}
.lib-hero p {
  font-size: 13px; line-height: 1.85;
  color: var(--muted); max-width: 480px; font-weight: 300;
}

/* ── Issue grid ── */
.lib-main { padding: 56px 64px; flex: 1; }

.issue-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2px;
}

/* Loading state */
.loading-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 40vh; gap: 20px;
  color: var(--muted); font-size: 12px;
  letter-spacing: 0.14em;
}
.loading-spinner {
  width: 28px; height: 28px;
  border: 1.5px solid var(--border-mid);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Issue card (rendered by library.js) ── */
.issue-card {
  position: relative; overflow: hidden;
  background: var(--bg2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color var(--ease), background var(--ease);
  display: flex; flex-direction: column;
}
.issue-card:hover { border-color: var(--border-mid); background: var(--surface); }

.issue-card-cover {
  aspect-ratio: 3/4; overflow: hidden;
  background: var(--bg3);
  display: flex; align-items: center; justify-content: center;
}
.issue-card-cover canvas { width: 100%; display: block; }
.issue-card-cover-ph {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.issue-card-cover-ph span {
  font-size: 8px; letter-spacing: 0.28em;
  text-transform: uppercase; color: var(--dim);
}

.issue-card-body { padding: 24px; border-top: 1px solid var(--border); }

.issue-card-num {
  font-size: 8px; font-weight: 500;
  letter-spacing: 0.32em; text-transform: uppercase;
  color: var(--silver); margin-bottom: 8px; display: block;
}
.issue-card-title {
  font-weight: 700; font-size: 15px;
  letter-spacing: 0.04em; text-transform: uppercase;
  line-height: 1.1; margin-bottom: 8px;
}
.issue-card-desc {
  font-size: 12px; line-height: 1.8;
  color: var(--muted); font-weight: 300;
  margin-bottom: 20px;
}
.issue-card-tags {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 20px;
}
.issue-tag {
  font-size: 8px; letter-spacing: 0.18em;
  text-transform: uppercase;
  border: 1px solid var(--border-mid);
  padding: 3px 10px;
  color: var(--muted);
}
.issue-card-cta {
  display: inline-block;
  font-size: 9px; font-weight: 600;
  letter-spacing: 0.22em; text-transform: uppercase;
  background: var(--white); color: #000;
  padding: 11px 24px;
  transition: background var(--ease);
  border: none; width: 100%; text-align: center;
}
.issue-card-cta:hover { background: var(--silver); }

/* ── Lib footer ── */
.lib-footer {
  border-top: 1px solid var(--border);
  padding: 32px 64px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 9px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--dim);
}
.lib-footer-logo {
  font-weight: 700; font-size: 11px;
  letter-spacing: 0.28em; color: var(--white);
}


/* ══════════════════════════════════════════════
   READER PAGE
   ══════════════════════════════════════════════ */

.reader-page {
  background: var(--bg);
  display: flex; flex-direction: column;
  height: 100vh; overflow: hidden;
  font-family: var(--font);
}

/* ── Loading overlay ── */
.reader-loading {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 24px; transition: opacity 0.4s ease;
}
.reader-loading.hidden { opacity: 0; pointer-events: none; }

.loading-logo {
  font-size: 14px; font-weight: 700;
  letter-spacing: 0.32em; text-transform: uppercase;
  color: var(--white);
}
.loading-bar-wrap {
  width: 200px; height: 1px;
  background: var(--border-mid);
}
.loading-bar {
  height: 100%; width: 0%;
  background: var(--white);
  transition: width 0.3s ease;
  position: relative;
}
/* Subtle shimmer on loading bar */
.loading-bar::after {
  content: '';
  position: absolute; top: 0; right: 0; bottom: 0;
  width: 60px;
  background: linear-gradient(to right, transparent, rgba(255,255,255,0.6), transparent);
  animation: bar-shimmer 1s ease infinite;
}
@keyframes bar-shimmer {
  0%   { transform: translateX(-60px); opacity: 0; }
  50%  { opacity: 1; }
  100% { transform: translateX(40px);  opacity: 0; }
}
.loading-status {
  font-size: 10px; font-weight: 300;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--muted);
}

/* ── Cover modal ── */
.cover-modal {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(0,0,0,0.92);
  backdrop-filter: blur(20px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.4s ease;
}
.cover-modal.visible  { opacity: 1; pointer-events: auto; }
.cover-modal.hidden   { display: none; }

.cover-modal-inner {
  display: flex; align-items: center;
  gap: 60px; max-width: 920px;
  padding: 56px; width: 100%;
}

.cover-preview {
  flex-shrink: 0; width: 260px;
  box-shadow: 0 40px 100px rgba(0,0,0,0.9);
  overflow: hidden;
}
.cover-preview canvas { width: 100%; display: block; }

.cover-modal-info { flex: 1; }

.cover-modal-label {
  font-size: 9px; font-weight: 500;
  letter-spacing: 0.32em; text-transform: uppercase;
  color: var(--silver); margin-bottom: 12px;
}
.cover-modal-title {
  font-weight: 700; font-size: 38px;
  letter-spacing: 0.03em; text-transform: uppercase;
  color: var(--white); line-height: 1;
  margin-bottom: 14px;
}
.cover-modal-desc {
  font-size: 13px; font-weight: 300;
  color: var(--muted); line-height: 1.85;
  margin-bottom: 20px;
}
.cover-modal-meta {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 32px;
}
.cover-tag {
  font-size: 8px; letter-spacing: 0.2em;
  text-transform: uppercase;
  border: 1px solid var(--border-mid);
  padding: 3px 10px;
  color: var(--muted);
}

/* Buttons inside modal */
.btn-read {
  display: inline-block;
  font-size: 9px; font-weight: 600;
  letter-spacing: 0.22em; text-transform: uppercase;
  color: #000; background: var(--white);
  border: none; padding: 13px 28px;
  transition: background var(--ease);
  margin-right: 12px; cursor: pointer;
}
.btn-read:hover { background: var(--silver); }

.btn-download {
  display: inline-block;
  font-size: 9px; font-weight: 500;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--border-mid);
  padding: 12px 20px;
  transition: color var(--ease), border-color var(--ease);
}
.btn-download:hover { color: var(--white); border-color: var(--border-hi); }

.cover-modal-close {
  position: absolute; top: 24px; right: 28px;
  background: none; border: none;
  color: var(--muted); font-size: 18px;
  cursor: pointer; transition: color var(--ease);
  font-family: var(--font);
}
.cover-modal-close:hover { color: var(--white); }

/* ── Top bar ── */
.reader-topbar {
  position: relative; z-index: 100;
  background: rgba(9,9,9,0.98);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 24px; height: 52px;
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease; flex-shrink: 0;
}
.reader-topbar.visible { opacity: 1; pointer-events: auto; }

.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-logo {
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.28em; text-transform: uppercase;
  color: var(--white);
}
.topbar-divider { color: var(--border-mid); font-size: 14px; }
.topbar-issue-name {
  font-size: 10px; font-weight: 300;
  letter-spacing: 0.14em; color: var(--muted);
}
.topbar-center { flex: 1; display: flex; justify-content: center; }
.page-counter {
  font-size: 10px; font-weight: 300;
  letter-spacing: 0.2em; color: var(--muted);
}
.topbar-right { display: flex; align-items: center; gap: 4px; }

/* Toolbar buttons */
.tb-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted); font-size: 13px;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  transition: color var(--ease), border-color var(--ease), background var(--ease);
  font-family: var(--font);
}
.tb-btn:hover { color: var(--white); border-color: var(--border-hi); background: var(--surface); }
.tb-btn:disabled { opacity: 0.2; cursor: default; }

.zoom-level {
  font-size: 9px; font-weight: 300;
  letter-spacing: 0.1em; color: var(--muted);
  min-width: 40px; text-align: center;
}
.tb-download { font-size: 9px; font-weight: 500; letter-spacing: 0.12em; padding: 0 10px; width: auto; }

/* ── Thumbnail panel ── */
.thumb-panel {
  position: fixed; top: 52px; right: -280px;
  width: 260px; bottom: 0; z-index: 200;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  transition: right 0.3s ease;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.thumb-panel.open { right: 0; }

.thumb-panel-header {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 9px; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--muted); flex-shrink: 0;
}
.thumb-panel-header button {
  background: none; border: none; color: var(--muted);
  font-size: 16px; cursor: pointer; transition: color var(--ease);
  font-family: var(--font);
}
.thumb-panel-header button:hover { color: var(--white); }

.thumb-grid {
  overflow-y: auto; padding: 12px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  flex: 1;
}
.thumb-item {
  cursor: pointer; overflow: hidden;
  border: 1px solid transparent;
  transition: border-color var(--ease); position: relative;
}
.thumb-item:hover   { border-color: var(--border-hi); }
.thumb-item.active  { border-color: var(--white); }
.thumb-item canvas  { width: 100%; display: block; }
.thumb-item span {
  position: absolute; bottom: 4px; right: 6px;
  font-size: 9px; color: var(--silver);
  background: rgba(0,0,0,0.7);
  padding: 1px 5px;
}

/* ── Main reader area ── */
.reader-main {
  flex: 1; position: relative;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}

/* ── Flipbook stage ── */
.flipbook-stage {
  display: none;
  align-items: center; justify-content: center;
  width: 100%; height: 100%;
  position: relative;
}
.flipbook-stage.visible { display: flex; }

/* Nav arrows */
.nav-arrow {
  position: absolute; z-index: 10;
  background: rgba(9,9,9,0.75);
  border: 1px solid var(--border);
  color: var(--muted); border-radius: 50%;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  transition: color var(--ease), background var(--ease), border-color var(--ease);
  flex-shrink: 0;
}
.nav-arrow:hover   { color: var(--white); background: var(--surface); border-color: var(--border-hi); }
.nav-arrow:disabled { opacity: 0.15; cursor: default; }
.nav-arrow svg     { width: 18px; height: 18px; }
.nav-arrow-left    { left: 20px; }
.nav-arrow-right   { right: 20px; }

/* Book wrapper */
/* ── Book wrapper ── */
.book-wrap {
  perspective: 3000px;
  perspective-origin: 50% 48%;
  display: flex; align-items: center; justify-content: center;
  width: calc(100% - 120px); height: 100%;
  padding: 16px 0;
}

/* ── The book ── */
/* Book is sized by JS to exactly match the PDF page aspect ratio.
   No max-width/max-height here — JS sets width/height inline. */
.book {
  position: relative; display: flex;
  transform-style: preserve-3d;
  filter: drop-shadow(0 28px 56px rgba(0,0,0,0.75))
          drop-shadow(0  4px 12px rgba(0,0,0,0.5));
  /* Default size before JS runs */
  width: 80vh; height: 56vh;
}

/* ── Individual pages — fill their half of the book exactly ── */
.page-left, .page-right {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #f8f7f4;
  /* No centering — canvas fills the full face */
}
.page-left  { border-radius: 2px 0 0 2px; }
.page-right { border-radius: 0 2px 2px 0; }

/* Canvas fills its page face completely — no gaps */
.page-canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  position: absolute;
  top: 0; left: 0;
}

.page-blank { background: var(--bg3); }

/* Spine shadow — left page (shadow at right edge towards spine) */
.page-shadow-left {
  position: absolute; top: 0; right: 0;
  width: 60px; height: 100%; pointer-events: none; z-index: 3;
  background: linear-gradient(to left,
    rgba(0,0,0,0.22) 0%,
    rgba(0,0,0,0.10) 30%,
    transparent 100%);
}
/* Spine shadow — right page (shadow at left edge towards spine) */
.page-shadow-right {
  position: absolute; top: 0; left: 0;
  width: 60px; height: 100%; pointer-events: none; z-index: 3;
  background: linear-gradient(to right,
    rgba(0,0,0,0.22) 0%,
    rgba(0,0,0,0.10) 30%,
    transparent 100%);
}
/* Corner fold */
.page-fold-left {
  position: absolute; bottom: 0; left: 0;
  width: 0; height: 0; border-style: solid;
  border-width: 0 0 20px 20px;
  border-color: transparent transparent rgba(0,0,0,0.06) transparent;
  pointer-events: none; z-index: 4;
}
.page-fold-right {
  position: absolute; bottom: 0; right: 0;
  width: 0; height: 0; border-style: solid;
  border-width: 20px 20px 0 0;
  border-color: rgba(0,0,0,0.06) transparent transparent transparent;
  pointer-events: none; z-index: 4;
}

/* ── 3D PAGE FLIP — Heyzine-style ── */
.page-flip {
  position: absolute;
  top: 0; width: 50%; height: 100%;
  transform-style: preserve-3d;
  display: none; z-index: 20;
}

.page-flip-front, .page-flip-back {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
  background: #f8f7f4;
}
.page-flip-front { border-radius: 0 2px 2px 0; }
.page-flip-back  {
  transform: rotateY(180deg);
  border-radius: 2px 0 0 2px;
}
/* Flip canvases also fill their face */
.page-flip-front .page-canvas,
.page-flip-back  .page-canvas {
  width: 100% !important;
  height: 100% !important;
  position: absolute;
  top: 0; left: 0;
}

/* ── Turning NEXT (right → left) ─────────────────────────
   Flip panel sits over right half, hinges at LEFT edge
   Start:  rotateY(0)    (flat, showing front = current right)
   End:    rotateY(-180) (flipped, showing back = incoming left) */
.page-flip.flip-next-start {
  left: 50%;
  transform-origin: 0% 50%;   /* hinge at LEFT edge of panel */
  transform: rotateY(0deg);
}
.page-flip.flip-next-go {
  transition: transform 0.6s cubic-bezier(0.645, 0.045, 0.355, 1.000);
  transform: rotateY(-180deg);
}

/* ── Turning PREV (left → right) ─────────────────────────
   Flip panel sits over left half, hinges at RIGHT edge
   Start:  rotateY(0)    (flat, showing front = current left)
   End:    rotateY(180)  (flipped, showing back = incoming right) */
.page-flip.flip-prev-start {
  left: 0%;
  transform-origin: 100% 50%;  /* hinge at RIGHT edge of panel */
  transform: rotateY(0deg);
}
.page-flip.flip-prev-go {
  transition: transform 0.6s cubic-bezier(0.645, 0.045, 0.355, 1.000);
  transform: rotateY(180deg);
}

/* Realistic curl shadow on flipping page */
.page-flip-front::after,
.page-flip-back::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
/* Shadow on front during forward flip — grows from left as page turns */
.flip-next-go .page-flip-front::after {
  background: linear-gradient(to left,
    rgba(0,0,0,0.20) 0%,
    rgba(0,0,0,0.05) 50%,
    transparent 100%);
  animation: curl-shadow-fwd 0.6s cubic-bezier(0.645,0.045,0.355,1) forwards;
}
/* Shadow on back during forward flip — fades in as page lands */
.flip-next-go .page-flip-back::after {
  background: linear-gradient(to right,
    rgba(0,0,0,0.18) 0%,
    rgba(0,0,0,0.05) 60%,
    transparent 100%);
  animation: curl-shadow-land 0.6s cubic-bezier(0.645,0.045,0.355,1) forwards;
}
@keyframes curl-shadow-fwd  { 0%{opacity:0} 40%{opacity:1} 100%{opacity:0.6} }
@keyframes curl-shadow-land { 0%{opacity:0} 60%{opacity:1} 100%{opacity:0.4} }

/* Page highlight — simulates paper catching light mid-turn */
.page-flip::before {
  content: ""; position: absolute; inset: 0; z-index: 25;
  pointer-events: none; backface-visibility: hidden;
  background: linear-gradient(to right,
    transparent 0%,
    rgba(255,255,255,0.12) 45%,
    rgba(255,255,255,0.22) 50%,
    rgba(255,255,255,0.12) 55%,
    transparent 100%);
  opacity: 0;
}
.flip-next-go::before, .flip-prev-go::before {
  animation: page-highlight 0.6s ease forwards;
}
@keyframes page-highlight {
  0%   { opacity: 0; }
  35%  { opacity: 1; }
  65%  { opacity: 1; }
  100% { opacity: 0; }
}


/* ── Mobile reader ── */
.mobile-reader {
  display: none; width: 100%; height: 100%;
  align-items: center; justify-content: center; overflow: auto;
}
.mobile-reader.visible { display: flex; }
.mobile-canvas {
  max-width: 100%; max-height: 100%; display: block;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8);
  transition: opacity 0.2s ease;
}

/* ── Bottom bar (mobile) ── */
.reader-bottombar {
  display: none;
  align-items: center; justify-content: space-between;
  padding: 12px 20px;
  background: rgba(9,9,9,0.98);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.reader-bottombar.visible { display: flex; }
.bb-btn {
  background: none; border: 1px solid var(--border);
  color: var(--muted); font-size: 9px;
  letter-spacing: 0.14em; text-transform: uppercase;
  padding: 8px 16px; transition: color var(--ease), border-color var(--ease);
  font-family: var(--font);
}
.bb-btn:hover   { color: var(--white); border-color: var(--border-hi); }
.bb-btn:disabled { opacity: 0.2; cursor: default; }
.bb-page { font-size: 10px; letter-spacing: 0.18em; color: var(--muted); }

/* Fullscreen */
:fullscreen .reader-topbar    { position: fixed; top: 0; left: 0; right: 0; }
:fullscreen .reader-main      { padding-top: 52px; }
:fullscreen .reader-bottombar { position: fixed; bottom: 0; left: 0; right: 0; }

/* Responsive */
@media (max-width: 767px) {
  .flipbook-stage    { display: none !important; }
  .reader-topbar     { height: 48px; padding: 0 16px; }
  .topbar-issue-name { display: none; }
  .nav-arrow         { display: none; }
  .thumb-panel       { width: 220px; right: -220px; }
}
@media (min-width: 768px) {
  .reader-bottombar { display: none !important; }
  .mobile-reader    { display: none !important; }
}

/* Scrollbar */
.thumb-grid::-webkit-scrollbar       { width: 3px; }
.thumb-grid::-webkit-scrollbar-track { background: var(--bg); }
.thumb-grid::-webkit-scrollbar-thumb { background: var(--border-mid); }
.thumb-grid::-webkit-scrollbar-thumb:hover { background: var(--silver); }
