/* ============================================================
   author.thinks — Premium Reader
   Calm paper, guided turns, soft motion
   ============================================================ */

body.reader-body {
  background: var(--bg, #F7F4EF);
  height: 100svh;
  overflow: hidden;
  --reader-size: 18px;
}

.reader-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 45% at 50% 20%, rgba(233, 222, 210, 0.55), transparent 70%),
    radial-gradient(ellipse 50% 40% at 80% 80%, rgba(255, 255, 255, 0.4), transparent 65%);
}

.reader-shell {
  position: relative;
  z-index: 1;
  height: 100svh;
  display: flex;
  flex-direction: column;
}

/* ---------- Chrome ---------- */
.reader-topbar,
.reader-bottombar {
  transition: transform 0.55s var(--ease-soft), opacity 0.45s var(--ease-soft);
}

.reader-body.chrome-hidden .reader-topbar {
  transform: translate(-50%, calc(-100% - 24px));
  opacity: 0;
  pointer-events: none;
}
.reader-body.chrome-hidden .reader-bottombar {
  transform: translate(-50%, calc(100% + 24px));
  opacity: 0;
  pointer-events: none;
}

.reader-topbar {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(720px, calc(100% - 28px));
  z-index: 40;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 10px;
  border-radius: 22px;
  box-sizing: border-box;
}

.rt-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 40px;
  height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  border: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  transition: background 0.3s var(--ease), transform 0.3s var(--ease);
}
.rt-btn:hover { background: rgba(255, 255, 255, 0.9); }
.rt-btn:active { transform: scale(0.96); }

.rt-center {
  min-width: 0;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rt-studio {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}
.rt-title {
  font-family: var(--display);
  font-size: 14px;
  font-style: italic;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rt-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.fontpop-wrap { position: relative; }
.fontpop {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 210px;
  border-radius: 22px;
  padding: 16px;
  z-index: 45;
  box-shadow: var(--shadow);
}
.fontpop[hidden] { display: none !important; }
.fontpop .label {
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.font-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.font-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.7);
  font-family: var(--display);
  color: var(--ink);
  display: grid;
  place-items: center;
}
.font-btn.small { font-size: 13px; }
.font-btn.large { font-size: 19px; }
.font-size-dots { display: flex; gap: 6px; }
.font-size-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line-strong);
  transition: background 0.25s, transform 0.25s;
}
.font-size-dots span.active {
  background: var(--accent);
  transform: scale(1.2);
}
.font-hint {
  margin: 12px 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink-faint);
}

/* ---------- TOC ---------- */
.toc-backdrop {
  position: fixed;
  inset: 0;
  z-index: 48;
  background: rgba(42, 39, 36, 0.22);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s var(--ease-soft);
}
.toc-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.toc-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  width: min(320px, 88vw);
  padding: max(20px, env(safe-area-inset-top)) 22px 28px;
  transform: translateX(105%);
  transition: transform 0.5s var(--ease);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.toc-panel.open { transform: translateX(0); }
.toc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.toc-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
  overflow-y: auto;
}
.toc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  background: transparent;
  border: none;
  text-align: left;
  font-family: var(--body);
  color: var(--ink);
  cursor: pointer;
  transition: background 0.3s;
}
.toc-item:hover,
.toc-item.is-current { background: var(--bg); }
.toc-item strong {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 500;
}
.toc-item span {
  font-size: 12px;
  color: var(--ink-faint);
}
.toc-item.is-locked { opacity: 0.55; }
.toc-note {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink-faint);
}

/* ---------- Page stage ---------- */
.page-viewport {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 96px 16px 110px;
  position: relative;
}

.page-stage {
  width: min(640px, 100%);
  perspective: 1400px;
}

.page-card {
  position: relative;
  width: 100%;
  height: min(72svh, 700px);
  border-radius: 32px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.82);
  box-shadow:
    0 30px 80px rgba(42, 39, 36, 0.1),
    0 8px 24px rgba(42, 39, 36, 0.04);
  transition: transform 0.55s var(--ease-soft), box-shadow 0.55s var(--ease-soft);
}
.page-card.is-turning {
  transform: translateY(-2px) scale(0.995);
  box-shadow:
    0 36px 90px rgba(42, 39, 36, 0.12),
    0 10px 28px rgba(42, 39, 36, 0.05);
}

.page-paper {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.55), transparent 28%),
    linear-gradient(90deg, rgba(42, 39, 36, 0.03), transparent 8%, transparent 92%, rgba(42, 39, 36, 0.03));
  z-index: 1;
}

.page-slot {
  position: absolute;
  inset: 0;
  padding: clamp(28px, 5vw, 56px) clamp(24px, 5.5vw, 60px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  will-change: transform, opacity, filter;
}
.page-slot.active {
  opacity: 1;
  pointer-events: auto;
  position: relative;
  height: 100%;
}

/* Directional page turns */
.page-slot.from-right {
  animation: pageInRight 0.62s var(--ease-soft) both;
}
.page-slot.from-left {
  animation: pageInLeft 0.62s var(--ease-soft) both;
}
.page-slot.to-left {
  animation: pageOutLeft 0.55s var(--ease-soft) both;
}
.page-slot.to-right {
  animation: pageOutRight 0.55s var(--ease-soft) both;
}

@keyframes pageInRight {
  from {
    opacity: 0;
    transform: translateX(36px) rotateY(-4deg);
    filter: blur(2px);
  }
  to {
    opacity: 1;
    transform: translateX(0) rotateY(0);
    filter: blur(0);
  }
}
@keyframes pageInLeft {
  from {
    opacity: 0;
    transform: translateX(-36px) rotateY(4deg);
    filter: blur(2px);
  }
  to {
    opacity: 1;
    transform: translateX(0) rotateY(0);
    filter: blur(0);
  }
}
@keyframes pageOutLeft {
  from {
    opacity: 1;
    transform: translateX(0);
    filter: blur(0);
  }
  to {
    opacity: 0;
    transform: translateX(-28px) scale(0.985);
    filter: blur(1.5px);
  }
}
@keyframes pageOutRight {
  from {
    opacity: 1;
    transform: translateX(0);
    filter: blur(0);
  }
  to {
    opacity: 0;
    transform: translateX(28px) scale(0.985);
    filter: blur(1.5px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .page-slot.from-right,
  .page-slot.from-left,
  .page-slot.to-left,
  .page-slot.to-right {
    animation: none;
  }
  .page-slot.active { opacity: 1; }
}

.page-eyebrow {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 14px;
}

.page-chapter-title {
  margin: 0 0 18px;
  font-family: var(--display);
  font-size: clamp(26px, 4vw, 34px);
  font-weight: 500;
  line-height: 1.15;
  color: var(--ink);
}

.page-body {
  font-family: var(--display);
  font-size: var(--reader-size);
  line-height: 1.85;
  color: var(--ink);
}
.page-body p {
  color: var(--ink);
  margin: 0 0 16px;
  font-family: var(--display);
  font-size: var(--reader-size);
  line-height: 1.85;
}
.page-body p:last-child { margin-bottom: 0; }
.page-body .italic-line,
.page-body .pull-quote {
  font-style: italic;
  color: var(--ink);
}
.pull-quote {
  font-size: calc(var(--reader-size) + 4px);
  line-height: 1.55;
  text-wrap: balance;
}

.page-foot {
  margin-top: auto;
  padding-top: 24px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  text-align: center;
}
.page-foot.soft { letter-spacing: 0.04em; text-transform: none; font-style: italic; }

.title-page {
  text-align: center;
  align-items: center;
}
.title-page .reader-studio {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 500;
  color: var(--accent);
  margin: 0 0 24px;
}
.title-page h1 {
  font-size: clamp(28px, 5vw, 42px);
  margin: 0 0 14px;
  font-weight: 500;
  line-height: 1.12;
}
.title-page .sub {
  font-size: 15px;
  color: var(--ink-soft);
  max-width: 320px;
  margin: 0 auto;
  line-height: 1.55;
}
.title-page .by {
  margin-top: 24px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.begin-btn {
  margin-top: 32px;
  min-width: 200px;
  position: relative;
  z-index: 8;
}
.begin-hint {
  margin: 14px 0 0;
  font-size: 12.5px;
  color: var(--ink-faint);
}

/* Tap zones — use explicit width (buttons don't stretch with left+right) */
.tap-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 3;
  width: 24%;
  margin: 0;
  padding: 0;
  cursor: pointer;
  background: transparent !important;
  border: 0 !important;
  outline: none !important;
  box-shadow: none !important;
  appearance: none;
  -webkit-appearance: none;
  -webkit-tap-highlight-color: transparent;
  color: transparent;
  font-size: 0;
  line-height: 0;
}
.tap-zone.left { left: 0; }
.tap-zone.right { right: 0; left: auto; }
.tap-zone.center {
  left: 24%;
  width: 52%;
}
.page-card.is-cover .tap-zone,
.page-card.is-locked .tap-zone {
  pointer-events: none;
}
.page-slot .btn {
  position: relative;
  z-index: 8;
}

.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  z-index: 6;
  color: var(--ink);
  border: none;
  transition: opacity 0.3s, background 0.3s, transform 0.3s;
}
.nav-arrow:hover {
  background: rgba(255, 255, 255, 0.95);
  transform: translateY(-50%) scale(1.04);
}
.nav-arrow.prev { left: clamp(4px, 1.5vw, 20px); }
.nav-arrow.next { right: clamp(4px, 1.5vw, 20px); }
.nav-arrow[disabled] {
  opacity: 0.22;
  pointer-events: none;
}
@media (max-width: 760px) {
  .nav-arrow { display: none; }
  .rt-btn span { display: none; }
  .rt-btn { padding: 0; width: 40px; }
}

/* ---------- Guidance ---------- */
.guide-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(42, 39, 36, 0.28);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.guide-overlay[hidden] { display: none !important; }
.guide-card {
  width: min(380px, 100%);
  border-radius: 32px;
  padding: 32px 28px 24px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: guideIn 0.6s var(--ease-soft) both;
}
@keyframes guideIn {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.guide-card h2 {
  margin: 8px 0 22px;
  font-family: var(--display);
  font-size: 30px;
  font-weight: 500;
}
.guide-list {
  list-style: none;
  margin: 0 0 24px;
  padding: 0;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.guide-list li {
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--ink-soft);
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--bg);
}
.guide-key {
  display: inline-block;
  font-weight: 600;
  color: var(--ink);
  margin-right: 4px;
}
.guide-skip {
  margin-top: 12px;
  background: none;
  border: none;
  color: var(--ink-faint);
  font-size: 13px;
  cursor: pointer;
  font-family: var(--body);
}

.edge-hint {
  position: fixed;
  top: 50%;
  right: 18px;
  transform: translateY(-50%);
  z-index: 8;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s var(--ease-soft);
}
.edge-hint.is-visible { opacity: 1; }
.edge-hint span {
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-soft);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  animation: hintPulse 2.4s ease-in-out infinite;
}
@keyframes hintPulse {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(4px); }
}
@media (min-width: 761px) {
  .edge-hint { display: none; }
}

/* ---------- Bottom bar ---------- */
.reader-bottombar {
  position: fixed;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(720px, calc(100% - 28px));
  z-index: 40;
  border-radius: 24px;
  padding: 14px 18px 16px;
  display: grid;
  gap: 10px;
  box-sizing: border-box;
}

.progress-copy {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.progress-chapter {
  font-family: var(--display);
  font-size: 15px;
  font-style: italic;
  color: var(--ink);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.progress-label {
  font-size: 12px;
  color: var(--ink-faint);
  white-space: nowrap;
}

.progress-track {
  position: relative;
  height: 6px;
  border-radius: 999px;
  background: rgba(42, 39, 36, 0.08);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-soft), var(--accent));
  transition: width 0.55s var(--ease-soft);
  box-shadow: 0 0 12px rgba(199, 134, 98, 0.35);
}
.progress-segments {
  position: absolute;
  inset: 0;
  display: flex;
  pointer-events: none;
}
.progress-segments i {
  flex: 1;
  border-right: 1px solid rgba(255, 255, 255, 0.55);
}
.progress-segments i:last-child { border-right: none; }

.progress-remain {
  margin: 0;
  font-size: 12px;
  color: var(--ink-faint);
  text-align: center;
}

/* ---------- Resume ---------- */
.resume-toast {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 55;
  width: min(420px, calc(100vw - 28px));
  border-radius: 22px;
  padding: 16px 16px 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  box-shadow: var(--shadow);
  animation: guideIn 0.5s var(--ease-soft) both;
}
.resume-toast[hidden] { display: none !important; }
.resume-toast strong {
  display: block;
  font-size: 14px;
  color: var(--ink);
}
.resume-toast span {
  font-size: 12.5px;
  color: var(--ink-soft);
}
.resume-actions {
  display: flex;
  gap: 8px;
  flex: none;
}

/* ---------- Paywall ---------- */
.paywall-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(150deg, var(--accent), var(--gold, #C4A574));
  display: grid;
  place-items: center;
  margin: 0 auto 20px;
  box-shadow: 0 14px 30px rgba(199, 134, 98, 0.35);
}
.paywall-center { text-align: center; align-items: center; }
.paywall-center h2 {
  margin: 0 0 12px;
  font-family: var(--display);
  font-size: clamp(24px, 4vw, 32px);
  font-weight: 500;
  text-wrap: balance;
}
.paywall-center p {
  max-width: 340px;
  margin: 0 auto 24px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-soft);
}
