/* Synthlit player: tokens, chapter list, book cards and the paywall
   notice. The app shell, transport bar and themes are in player-app.css.
   Tokens mirror site/assets/site.css -- change both together. */

:root {
  --paper: #f4eee1;
  --paper-2: #ebe3d1;
  --paper-3: #e0d5bd;
  --card: #fbf7ec;
  --ink: #1f1d1a;
  --ink-soft: #5d574c;
  --cloth: #23392f;
  --cloth-ink: #efe6cf;
  --accent: #8c2f2b;
  --accent-dark: #6f2421;
  --accent-soft: #c8a45a;
  --gold: #c8a45a;
  --gold-soft: #dcc48c;
  --rule: rgba(31, 29, 26, 0.14);
  --shadow: 0 1px 2px rgba(31, 29, 26, 0.07), 0 10px 28px rgba(31, 29, 26, 0.12);
  --display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --text: 'Literata', 'Iowan Old Style', Georgia, serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .serif { font-family: var(--display); font-weight: 500; letter-spacing: -0.01em; }
a { color: var(--accent); }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 1.5rem; }

/* ── book header ───────────────────────────────────────────────────────── */

.book-hero { display: flex; gap: 1.6rem; align-items: flex-end; padding: 0.5rem 0 1.4rem; }
.book-hero .jacket { flex: none; }
.book-head h1 { font-size: clamp(1.9rem, 4vw, 2.8rem); margin: 0 0 0.2rem; line-height: 1.1; }
.book-head .byline { color: var(--ink-soft); font-size: 1.08rem; font-style: italic; margin: 0 0 0.8rem; }
.book-head .meta {
  display: flex; flex-wrap: wrap; gap: 0.4rem 1rem;
  color: var(--ink-soft); font-size: 0.88rem;
}
.book-head .meta .dot { color: var(--accent-soft); }
.book-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.1rem; }

/* ── chapter list ──────────────────────────────────────────────────────── */

.chapters { list-style: none; margin: 0; padding: 0; }
.chapters li { margin: 0; border-bottom: 1px solid var(--rule); }
.chapters button {
  display: flex; align-items: center; gap: 0.9rem;
  width: 100%; padding: 0.75rem 0.6rem;
  background: none; border: 0; cursor: pointer; text-align: left;
  color: inherit; font: inherit; font-size: 0.98rem;
}
.chapters button:hover { background: var(--paper-2); }
.chapters button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.chapters .num {
  flex: 0 0 2.2rem; text-align: right;
  font-family: var(--display); font-style: italic;
  color: var(--ink-soft); font-size: 0.95rem;
}
.chapters .title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chapters .dur { flex: 0 0 auto; color: var(--ink-soft); font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.chapters li.current button { background: var(--paper-2); font-weight: 600; }
.chapters li.current .num { color: var(--accent); }
.chapters li.played .title { color: var(--ink-soft); }

.chapters .lock { flex: none; width: 1rem; height: 1rem; fill: var(--ink-soft); opacity: 0.7; }
.chapters li.locked .title, .chapters li.locked .dur { color: var(--ink-soft); }
.chapters li.locked .title { opacity: 0.8; }
.chapters .free-tag {
  flex: none; font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 0.1rem 0.5rem; border-radius: 999px;
  background: rgba(200, 164, 90, 0.18); color: #7b5d1d; border: 1px solid rgba(200, 164, 90, 0.6);
}

/* the "rest of the book" divider shown under the open chapters */
.chapters li.gate-row { border-bottom: 0; }
.gate-inline {
  margin: 0.9rem 0; padding: 1.1rem 1.2rem; border-radius: 10px;
  background: var(--cloth); color: var(--cloth-ink);
  display: flex; flex-wrap: wrap; gap: 0.8rem 1.2rem; align-items: center; justify-content: space-between;
}
.gate-inline p { margin: 0; flex: 1 1 18rem; }
.gate-inline strong { font-family: var(--display); font-weight: 500; font-size: 1.15rem; color: var(--gold-soft); display: block; }

/* ── buttons ───────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.62rem 1.2rem; border-radius: 999px;
  border: 1px solid var(--accent); background: var(--accent); color: #fbf3e6;
  font: inherit; font-size: 0.94rem; font-weight: 500;
  text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.ghost { background: none; color: var(--accent); }
.btn.ghost:hover { background: rgba(140, 47, 43, 0.07); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--cloth); }
.btn.gold:hover { background: var(--gold-soft); border-color: var(--gold-soft); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.note { font-size: 0.82rem; color: var(--ink-soft); margin-top: 0.6rem; }

.scrub { width: 100%; accent-color: var(--accent); cursor: pointer; height: 1.1rem; }

/* ── library: books as cloth-bound volumes ─────────────────────────────── */

.shelf {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 2rem 1.4rem; padding-bottom: 4rem;
}
.shelf-card {
  position: relative; display: flex; flex-direction: column; gap: 0.15rem;
  background: none; border: 0; padding: 0; cursor: pointer; text-align: left;
  font: inherit; color: inherit;
}
.shelf-card .t { font-family: var(--display); font-size: 1.05rem; font-weight: 500; line-height: 1.25; margin-top: 0.7rem; }
.shelf-card .a { color: var(--ink-soft); font-size: 0.86rem; font-style: italic; }
.shelf-card .m { color: var(--ink-soft); font-size: 0.78rem; margin-top: 0.6rem; }
.shelf-card .access {
  align-self: flex-start; margin-top: 0.35rem;
  font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 0.08rem 0.5rem; border-radius: 999px; border: 1px solid var(--rule); color: var(--ink-soft);
}
.shelf-card .access.open { border-color: rgba(200, 164, 90, 0.7); color: #7b5d1d; background: rgba(200, 164, 90, 0.14); }

/* a generated jacket for books without cover art: cloth, foil, bands */
.jacket {
  --c: var(--cloth);
  --foil: var(--gold-soft);
  position: relative; aspect-ratio: 2 / 3; width: 100%;
  border-radius: 3px 6px 6px 3px; overflow: hidden;
  background:
    linear-gradient(90deg, rgba(0,0,0,0.32) 0, rgba(0,0,0,0.05) 7%, rgba(255,255,255,0.08) 9%, transparent 14%),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.03) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(0,0,0,0.05) 0 1px, transparent 1px 3px),
    var(--c);
  box-shadow: 0 1px 1px rgba(0,0,0,0.15), 0 8px 18px rgba(31, 29, 26, 0.22);
  color: var(--foil);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 14% 12% 14% 16%; text-align: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.jacket::before, .jacket::after {
  content: ""; position: absolute; left: 16%; right: 10%; height: 4px;
  border-top: 1px solid currentColor; border-bottom: 1px solid currentColor; opacity: 0.7;
}
.jacket::before { top: 8%; }
.jacket::after { bottom: 8%; }
.jacket .jt { font-family: var(--display); font-size: 1.12rem; line-height: 1.15; font-weight: 500; }
.jacket .jo { margin: 0.6rem 0; font-size: 0.9rem; opacity: 0.8; }
.jacket .ja { font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.85; }
.jacket.small { width: 112px; padding: 12% 10% 12% 15%; }
.jacket.small .jt { font-size: 0.85rem; }
.jacket.small .jo { margin: 0.35rem 0; font-size: 0.7rem; }
.jacket.small .ja { font-size: 0.52rem; }
.shelf-card:hover .jacket, .shelf-card:focus-visible .jacket { transform: translateY(-4px) rotate(-0.6deg); box-shadow: 0 2px 2px rgba(0,0,0,0.15), 0 16px 28px rgba(31, 29, 26, 0.28); }
.shelf-card:focus-visible { outline: none; }
.shelf-card .cover { aspect-ratio: 2 / 3; border-radius: 3px 6px 6px 3px; box-shadow: 0 8px 18px rgba(31,29,26,0.22); }

/* ── the paywall notice ────────────────────────────────────────────────── */

.gate-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(18, 22, 19, 0.55); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; padding: 1.25rem;
}
.gate-card {
  position: relative; width: 100%; max-width: 30rem;
  background: var(--card); color: #1f1d1a; border-radius: 8px;
  padding: 2.4rem 2rem 2rem; text-align: center;
  box-shadow: 0 30px 70px rgba(0,0,0,0.35);
  border-top: 6px solid var(--cloth);
}
.gate-card .ribbon {
  position: absolute; top: -6px; right: 2rem; width: 16px; height: 64px; background: #8c2f2b;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 84%, 0 100%);
}
.gate-card .orn { color: #c8a45a; font-size: 1.5rem; }
.gate-card h2 { font-size: 1.8rem; margin: 0.3rem 0 0.6rem; color: #1f1d1a; }
.gate-card p { color: #5d574c; margin: 0 0 1.4rem; }
.gate-card .actions { display: flex; flex-direction: column; gap: 0.6rem; align-items: stretch; }
.gate-card .btn { padding: 0.8rem 1.2rem; font-size: 1rem; }
.gate-card .btn.ghost { color: #8c2f2b; border-color: #8c2f2b; }
.gate-card .close {
  position: absolute; top: 0.6rem; right: 0.8rem; background: none; border: 0; cursor: pointer;
  font-size: 1.5rem; line-height: 1; color: #5d574c; padding: 0.3rem;
}

/* ── mobile (≤860px) ───────────────────────────────────────────────────────
   Kept in ONE block at the very end: these rules re-target selectors above
   at the same specificity, and source order decides that tie. */
@media (max-width: 860px) {
  .shelf { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 1.6rem 1rem; }
  .jacket .jt { font-size: 0.95rem; }
  .book-hero { gap: 1rem; align-items: flex-start; }
  .jacket.small { width: 84px; }
  .jacket.small .jt { font-size: 0.68rem; }
  .jacket.small .jo, .jacket.small .ja { display: none; }
  .book-head h1 { font-size: 1.5rem; }
  .book-head .byline { font-size: 0.95rem; margin: 0 0 0.4rem; }
  .book-head .meta { font-size: 0.78rem; gap: 0.3rem 0.75rem; }
  .chapters button { padding: 0.65rem 0.3rem; font-size: 0.94rem; }
}

/* The open book's cloth washes faintly down behind its jacket
   (--book-wash is set from the book's colour in player-app.js). */
#view-book .book-hero {
  background: linear-gradient(to bottom, var(--book-wash, transparent), transparent 90%);
  border-radius: 10px; padding: 0.9rem 0.6rem 1.4rem; margin: 0 -0.6rem;
}
