/* ÎNTRE LUMI — audiobook + ebook PWA
   Design system. Tokens + semantic classes; no inline styles.
   Aesthetic: warm literary (KindAid DNA) — cream paper, deep mulberry, coral, gold.
   Signature: the "seam" — a vertical thread that fills with audio progress,
   binding the read text to the heard voice ("între lumi" = between worlds). */

/* ---------- tokens ---------- */
:root {
  --paper:    #fcf8ec;   /* warm cream — the page */
  --paper-2:  #f7f1e1;   /* deeper cream surface */
  --beige:    #f0e8d1;   /* inset / card beige */
  --white:    #fffdf8;   /* elevated card */
  --ink:      #620035;   /* deep mulberry — dark surfaces, headings, chrome */
  --ink-2:    #4a0028;   /* darker mulberry */
  --mauve:    #9a5b7c;   /* soft mulberry — secondary icons/text on dark */
  --coral:    #ff4121;   /* primary CTA / play / active */
  --coral-2:  #e0331a;   /* pressed */
  --gold:     #ffca24;   /* seam + seek fill + progress */
  --text:     #2c1b24;   /* reading prose on cream */
  --muted:    #8a7a72;   /* warm grey — meta/captions */
  --line:     #e7dcc6;   /* warm hairline on cream */
  --line-ink: rgba(252,248,236,.16); /* hairline on mulberry */

  --ff-display: 'Libre Baskerville', Georgia, 'Times New Roman', serif;
  --ff-ui:      'Montserrat', system-ui, -apple-system, sans-serif;
  --ff-mono:    'IBM Plex Mono', ui-monospace, 'SFMono-Regular', monospace;

  --step--1: .8125rem;
  --step-0:  1rem;
  --step-1:  1.1875rem;
  --step-2:  1.5rem;
  --step-3:  clamp(1.9rem, 6vw, 2.6rem);

  --radius:   14px;
  --radius-s: 9px;
  --pill:     999px;
  --shadow:   0 6px 22px -12px rgba(74,0,40,.34);
  --shadow-up:0 -8px 24px -16px rgba(74,0,40,.5);
  --gap:      1rem;
  --pad:      1.15rem;
  --player-h: 76px;
  --ease:     cubic-bezier(.22,.61,.36,1);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--ff-ui);
  color: var(--text);
  background: var(--paper);
  line-height: 1.5;
  font-size: var(--step-0);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, .display { font-family: var(--ff-display); font-weight: 700; color: var(--ink); line-height: 1.18; margin: 0; }
a { color: inherit; }
img { max-width: 100%; display: block; }
:focus-visible { outline: 3px solid var(--coral); outline-offset: 2px; border-radius: 4px; }

/* ---------- shell ---------- */
.app { max-width: 560px; margin-inline: auto; min-height: 100vh; position: relative; }
.screen { padding: 0 var(--pad) calc(var(--player-h) + 2rem); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .85rem var(--pad);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-family: var(--ff-display); font-size: 1.1rem; letter-spacing: .14em; color: var(--ink); text-transform: uppercase; }
.brand b { color: var(--coral); font-weight: 700; }
.topbar__act { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--pill);
  background: var(--beige); color: var(--ink); border: 0; font-size: 1.1rem; cursor: pointer; }

/* ---------- type helpers ---------- */
.eyebrow { font-family: var(--ff-ui); font-size: .68rem; font-weight: 600; letter-spacing: .22em;
  text-transform: uppercase; color: var(--coral); }
.code { font-family: var(--ff-mono); font-size: var(--step--1); color: var(--mauve); letter-spacing: .02em; }
.meta { font-family: var(--ff-ui); font-size: .78rem; color: var(--muted); }
.muted { color: var(--muted); }

/* ---------- buttons ---------- */
.btn { font-family: var(--ff-ui); font-weight: 600; font-size: .95rem; border: 0; cursor: pointer;
  padding: .9rem 1.3rem; border-radius: var(--pill); transition: transform .12s var(--ease), background .15s; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--coral); color: var(--white); box-shadow: var(--shadow); }
.btn--primary:hover { background: var(--coral-2); }
.btn--block { display: block; width: 100%; text-align: center; }
.btn--ghost { background: transparent; color: var(--ink); border: 1.5px solid var(--ink); }

/* ---------- the SEAM (signature) ---------- */
/* a thin vertical thread; --seam-progress (0..1) fills it gold-over-mulberry */
.seam { position: relative; padding-left: 1.4rem; }
.seam::before { content: ""; position: absolute; left: .5rem; top: .2em; bottom: .2em; width: 2px;
  border-radius: 2px; background: linear-gradient(var(--gold) calc(var(--seam-progress,0)*100%),
  color-mix(in srgb, var(--ink) 20%, transparent) 0); }

/* ---------- cuprins / table of contents ---------- */
.lede { padding: 1.4rem 0 .4rem; }
.lede h1 { font-size: var(--step-3); }
.lede p { color: var(--muted); margin: .5rem 0 0; max-width: 34ch; }

.part { margin-top: 1.6rem; }
.part__head { display: flex; align-items: baseline; gap: .7rem; padding-bottom: .55rem; border-bottom: 1.5px solid var(--ink); }
.part__num { font-family: var(--ff-display); font-size: 1.5rem; color: var(--coral); min-width: 1.8ch; }
.part__title { font-family: var(--ff-display); font-size: 1.18rem; color: var(--ink); }
.part__count { margin-left: auto; }

.movement { margin: 1.1rem 0 .4rem; display: flex; align-items: center; gap: .6rem; }
.movement__label { font-family: var(--ff-mono); font-size: .72rem; letter-spacing: .26em; text-transform: uppercase; color: var(--mauve); }
.movement::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.chapter { display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto;
  align-items: center; column-gap: .85rem; row-gap: .12rem; padding: .7rem .35rem;
  border-radius: var(--radius-s); border: 0; width: 100%; text-align: left; background: transparent;
  cursor: pointer; transition: background .15s; }
.chapter:hover { background: var(--paper-2); }
.chapter__code { grid-column: 1; grid-row: 1 / span 2; align-self: center; font-family: var(--ff-mono);
  font-size: .72rem; color: var(--mauve); width: 2.6rem; height: 2.6rem; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 50%; }
.chapter__title { grid-column: 2; grid-row: 1; align-self: end; font-family: var(--ff-display);
  font-size: 1rem; color: var(--ink); line-height: 1.28; }
.chapter__meta { grid-column: 2; grid-row: 2; align-self: start; font-family: var(--ff-ui); font-size: .72rem; color: var(--muted); }
.chapter .dl { grid-column: 3; grid-row: 1 / span 2; align-self: center; }

.chapter.is-playing { background: var(--beige); }
.chapter.is-playing .chapter__code { background: var(--coral); color: var(--white); border-color: var(--coral); }
.chapter.is-playing .chapter__title { color: var(--coral-2); }

/* download affordance — states via class */
.dl { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; border: 0;
  background: transparent; color: var(--mauve); cursor: pointer; font-size: 1rem; }
.dl:hover { background: var(--paper-2); color: var(--ink); }
.dl.is-done { color: var(--ink); }
.dl.is-busy { color: var(--coral); }
.dl.is-busy .dl__ring { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- reader (ebook page) ---------- */
.reader { padding-top: .5rem; }
.reader__head { padding: .6rem 0 1rem; }
.reader__kicker { display: flex; gap: .6rem; align-items: center; }
.reader__title { font-size: var(--step-2); margin-top: .35rem; }
.prose { font-family: var(--ff-display); color: var(--text); font-size: 1.0625rem; line-height: 1.78; }
.prose p { margin: 0 0 1.15rem; }
.prose .drop::first-letter { font-size: 3.1rem; line-height: .8; float: left; padding: .1em .12em 0 0; color: var(--coral); font-weight: 700; }
.prose--letter p { font-style: italic; color: color-mix(in srgb, var(--text) 92%, var(--ink)); }   /* Felix/Ligia letters */
/* the WoW chat-log world: monospace, a different register on the page */
.prose--chat { font-family: var(--ff-mono); font-size: .82rem; line-height: 1.85; color: var(--ink); background: var(--paper-2);
  border-left: 2px solid var(--gold); padding: .9rem 1rem; border-radius: 0 var(--radius-s) var(--radius-s) 0; }
.prose--chat .ts { color: var(--mauve); }
.scene-break { text-align: center; color: var(--coral); margin: 1.4rem 0; letter-spacing: .4em; }

/* ---------- player (transport bar) ---------- */
.player { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 560px;
  background: var(--ink); color: var(--paper); box-shadow: var(--shadow-up); z-index: 30; }
.player__inner { padding: .55rem var(--pad) calc(.55rem + env(safe-area-inset-bottom)); }
.player__row { display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: .8rem; }
.player__art { width: 44px; height: 44px; border-radius: 8px; background: var(--ink-2) center/cover; }
.player__now { min-width: 0; }
.player__chap { font-family: var(--ff-display); font-size: .95rem; color: var(--paper); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.player__part { font-family: var(--ff-mono); font-size: .68rem; letter-spacing: .12em; color: var(--mauve); text-transform: uppercase; }
.player__part, .player__chap { display: block; }

.transport { display: flex; align-items: center; gap: .35rem; }
.ctrl { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 50%;
  background: transparent; color: var(--paper); cursor: pointer; font-size: 1.05rem; transition: background .15s; }
.ctrl:hover { background: var(--line-ink); }
.ctrl--play { width: 52px; height: 52px; background: var(--coral); color: var(--white); font-size: 1.25rem; box-shadow: var(--shadow); }
.ctrl--play:hover { background: var(--coral-2); }

.seekrow { display: flex; align-items: center; gap: .6rem; margin-top: .5rem; }
.seekbar { flex: 1; height: 6px; border-radius: var(--pill); background: var(--line-ink); position: relative; cursor: pointer; }
.seekbar__fill { position: absolute; inset: 0 auto 0 0; width: var(--seek,0%); background: var(--gold); border-radius: var(--pill); }
.seekbar__knob { position: absolute; top: 50%; left: var(--seek,0%); width: 13px; height: 13px; border-radius: 50%;
  background: var(--paper); transform: translate(-50%,-50%); box-shadow: 0 0 0 3px var(--ink); }
.time { font-family: var(--ff-mono); font-size: .72rem; color: var(--mauve); font-variant-numeric: tabular-nums; }

/* full player: controls get their own centered row; the title may wrap (it no longer shares a row) */
.transport--full { justify-content: center; gap: 1.7rem; margin-top: .6rem; }
.player:not(.is-mini) .player__chap { white-space: normal; line-height: 1.28; }

/* mini variant: collapses the seek row, used on the cuprins */
.player.is-mini .seekrow { display: none; }
.player.is-mini .player__inner { padding-block: .5rem; }
.player.is-mini .seekbar--hair { display: block; position: absolute; top: 0; left: 0; right: 0; height: 3px; border-radius: 0; }

/* ---------- progress (donation-bar lineage, reused for "% of book heard") ---------- */
.progress { height: 8px; border-radius: var(--pill); background: var(--beige); overflow: hidden; }
.progress__bar { height: 100%; background: var(--gold); border-radius: var(--pill); }

/* ---------- card / auth ---------- */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.auth { min-height: 100svh; display: grid; place-items: center; padding: var(--pad); }
.auth__card { width: 100%; max-width: 380px; padding: 1.6rem 1.4rem 1.8rem; text-align: center; }
.auth__cover { width: 122px; aspect-ratio: 1200/1775; margin: -3.8rem auto 1rem; border-radius: 10px; box-shadow: var(--shadow);
  background: var(--ink) center/cover; object-fit: cover; border: 4px solid var(--white); }
.auth h1 { font-size: 1.7rem; }
.auth .eyebrow { display: block; margin-bottom: .9rem; }
.field { text-align: left; margin: .9rem 0; }
.field label { font-size: .74rem; font-weight: 600; letter-spacing: .04em; color: var(--ink); }
.input { width: 100%; margin-top: .3rem; padding: .8rem .9rem; font: inherit; color: var(--text);
  background: var(--paper); border: 1.5px solid var(--line); border-radius: var(--radius-s); }
.input:focus { border-color: var(--coral); outline: none; }
.auth__alt { margin-top: 1rem; font-size: .85rem; color: var(--muted); }
.auth__alt a { color: var(--coral); font-weight: 600; text-decoration: none; }

/* ---------- a11y / motion ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .001ms !important; transition-duration: .001ms !important; } }

/* ---------- cover-backed surfaces + demo values (preview) ---------- */
.has-cover { background-image: url('assets/cover-sq.jpg'); background-size: cover; background-position: center 26%; }
.seam.is-demo { --seam-progress: .42; }
.seekbar.is-demo { --seek: 39%; }
.progress--book .progress__bar { width: 18%; }

/* ---------- mockup gallery (preview only; not shipped to Django) ---------- */
.gallery { background: #ece2ce; padding: 2.6rem 1rem 4rem; min-height: 100vh; }
.gallery__intro { max-width: 660px; margin: 0 auto 2.2rem; text-align: center; }
.gallery__intro .eyebrow { display: block; margin-bottom: .4rem; }
.gallery__intro h1 { font-family: var(--ff-display); color: var(--ink); font-size: clamp(1.9rem,5vw,2.6rem); margin: 0 0 .5rem; }
.gallery__intro p { color: var(--muted); margin: 0 auto; max-width: 48ch; }
.frames { display: flex; flex-wrap: wrap; gap: 2.2rem; justify-content: center; align-items: flex-start; }
.frame { width: 384px; max-width: 100%; }
.frame__label { text-align: center; font-family: var(--ff-ui); font-weight: 600; font-size: .76rem;
  letter-spacing: .16em; text-transform: uppercase; color: var(--ink); margin-bottom: .75rem; }
.device { height: min(760px, 80vh); background: var(--paper); border: 8px solid var(--ink); border-radius: 34px;
  overflow: hidden; position: relative; box-shadow: 0 34px 60px -30px rgba(74,0,40,.55); }
.device__scroll { height: 100%; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.device .app { max-width: none; min-height: 100%; }
.device .player { position: sticky; left: auto; bottom: 0; transform: none; max-width: none; }
@media (max-width: 480px) {
  .gallery { padding: 1.1rem .55rem 3rem; }
  .frame { width: 100%; }
  .device { height: 84vh; border-width: 6px; border-radius: 24px; }
}

/* auth error state (the mockup defines none — minimal, tokens only) */
.auth .error { color: var(--coral-2); font-size: .85rem; margin: .2rem 0 0; }

/* show/hide password toggle (auth cards; the mockup defines none — tokens only) */
.field { position: relative; }
.input--toggle { padding-right: 4.6rem; }
.input-toggle { position: absolute; right: .6rem; bottom: .55rem; border: 0; background: none;
  font-family: var(--ff-ui); font-size: .74rem; font-weight: 600; color: var(--mauve); cursor: pointer; }
.input-toggle:hover { color: var(--coral); }

/* ---------- desktop adaptation (additive; every mobile-first rule above is untouched) ----------
   On ≥900px viewports the phone column becomes a book column: a wider reading measure
   (760px ≈ 66ch of the display serif), slightly larger prose, roomier padding. Still ONE
   centered column — the player tracks the same width automatically. */
@media (min-width: 900px) {
  :root { --pad: 2rem; }
  .app, .player { max-width: 760px; }
  .prose { font-size: 1.1875rem; }
  .lede p { max-width: 48ch; }
}
