/* Lirio — a calm, colorful learning palette.
   Light: warm paper, soft mint, lavender, peach and rose study accents.
   Dark: deep teal surfaces with muted versions of the same category colors.
   Semantic tokens keep reading, controls and study cards consistent. */
:root,
[data-bs-theme="light"] {
  --bg: #f8f9f3;          /* warm paper */
  --surface: #fffefa;     /* cards, wells */
  --surface-2: #edf3ed;   /* soft chips, covers */
  --ink: #263b3a;         /* body text */
  --ink-soft: #526764;    /* secondary text */
  --line: #dbe5df;        /* borders */

  --accent: #236e68;
  --accent-bg: #deefea;
  --inverse-text: #ffffff;
  --reading-bg: #fac775;  --reading-fg: #412402;

  /* feedback */
  --ok: #0f6e56;   --ok-bg: #e1f5ee;
  --bad: #a32d2d;  --bad-bg: #fcebeb;
  --hint: #633806; --hint-bg: #faeeda;

  --shadow: 0 1px 3px rgb(33 32 29 / 0.06), 0 8px 24px rgb(33 32 29 / 0.05);
  --shadow-pop: 0 4px 12px rgb(33 32 29 / 0.12), 0 12px 32px rgb(33 32 29 / 0.14);

  /* Mint-to-lavender bands frame the library without overpowering it. */
  --band-from: #e1f0e7;  --band-to: #eee7f7;
  --band-ink: #263b3a;   --band-soft: #4e6460;
  --band-accent: #236e68;   /* the accent, lightened to sit on a dark band */

  /* The dark bubble the server-rendered glosses use. */
  --tooltip-bg: #21201d;  --tooltip-ink: #e8e6df;

  /* deprecated aliases — see the note above */
  --gold: var(--accent);
  --gold-bright: var(--accent);
  --gold-soft: var(--accent-bg);
  --navy-900: var(--ink);
  --navy-700: var(--ink);
  --navy-500: var(--ink-soft);
  --navy-200: var(--line);
  --bg-soft: var(--surface-2);

  color-scheme: light;

  /* Highlighted words in the reader — ported from lirio-v2 (DESIGN §6).
     A tint has to read as a distinct swatch against the page, not merely
     differ from it: a dotted underline is invisible until you look for it,
     which defeats the point of marking a word. Each tint has a distinct hue
     and strongly contrasting text. The kinds keep their hue in the dark
     theme and swap roles there — tint goes deep, ink goes light — so a verb
     still reads orange at night. --gloss-bg is the default, used for the
     entries that carry no kind (and for nouns, which share it). */
  --gloss-bg: #e8e1f7;       --gloss-ink: #57427f;
  --gloss-verb-bg: #f8e3d4;  --gloss-verb-ink: #814726;
  --gloss-adj-bg: #dfeef6;   --gloss-adj-ink: #315f79;
  --gloss-expr-bg: #f5e1ea;  --gloss-expr-ink: #853e60;
  --gloss-conn-bg: #dcefe3;  --gloss-conn-ink: #2b6548;

  --bs-body-bg: var(--bg);
  --bs-body-color: var(--ink);
  --bs-border-color: var(--line);
  --bs-tertiary-bg: var(--surface-2);
  --bs-secondary-bg: var(--surface-2);
  --bs-secondary-color: var(--ink-soft);
  --bs-emphasis-color: var(--ink);
  /* Bootstrap builds link colour from a triplet, so --accent cannot be handed
     over as-is; keep these two in step with it. */
  --bs-link-color-rgb: 35, 110, 104;
  --bs-link-hover-color-rgb: 25, 84, 79;
}

/* Evening palette: the same category hues on quiet teal surfaces. */
[data-bs-theme="dark"] {
  --bg: #172725;
  --surface: #203330;
  --surface-2: #29403b;
  --ink: #edf4eb;
  --ink-soft: #b0c5bc;
  --line: #3c544d;

  --accent: #9cd7c8;
  --accent-bg: #2d4c43;
  --inverse-text: #172725;
  --reading-bg: #f2bd5e;  --reading-fg: #2b1802;

  --ok: #82d6b9;   --ok-bg: #12332a;
  --bad: #f39e9e;  --bad-bg: #3a1d1d;
  --hint: #ebcb8d; --hint-bg: #33280f;

  --shadow: 0 1px 3px rgb(0 0 0 / 0.5), 0 8px 24px rgb(0 0 0 / 0.4);
  --shadow-pop: 0 4px 12px rgb(0 0 0 / 0.55), 0 12px 32px rgb(0 0 0 / 0.5);

  --band-from: #223f35;  --band-to: #38334d;
  --band-ink: #edf4eb;   --band-soft: #b8cbc1;
  --band-accent: #9cd7c8;

  --tooltip-bg: #34322c;  --tooltip-ink: #ece9e1;

  --gold: var(--accent);
  --gold-bright: var(--accent);
  --gold-soft: var(--accent-bg);
  --navy-900: var(--ink);
  --navy-700: var(--ink);
  --navy-500: var(--ink-soft);
  --navy-200: var(--line);
  --bg-soft: var(--surface-2);

  color-scheme: dark;

  --gloss-bg: #3b3654;       --gloss-ink: #d6c5f5;
  --gloss-verb-bg: #4d3b30;  --gloss-verb-ink: #efc09b;
  --gloss-adj-bg: #2d424e;   --gloss-adj-ink: #b3d8ed;
  --gloss-expr-bg: #4b3445;  --gloss-expr-ink: #edbad3;
  --gloss-conn-bg: #284a39;  --gloss-conn-ink: #aedaba;

  --bs-body-bg: var(--bg);
  --bs-body-color: var(--ink);
  --bs-border-color: var(--line);
  --bs-tertiary-bg: var(--surface-2);
  --bs-secondary-bg: var(--surface-2);
  --bs-secondary-color: var(--ink-soft);
  --bs-emphasis-color: var(--ink);
  --bs-link-color-rgb: 156, 215, 200;
  --bs-link-hover-color-rgb: 193, 234, 221;
}

body {
  overflow-x: hidden;
  background-image: radial-gradient(ellipse at 0 0, color-mix(in srgb, var(--accent-bg) 50%, transparent), transparent 50rem);
}
::selection { background: var(--gloss-bg); color: var(--gloss-ink); }

/* Theme toggle (navbar) */
.theme-toggle {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  width: 2.1rem;
  height: 2.1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.theme-toggle:hover { border-color: var(--gold); }

/* ---- Reading typography: calm, book-like measure ---- */
.reading {
  font-family: Charter, "Iowan Old Style", Georgia, "Times New Roman", serif;
  font-size: 1.07rem;
  line-height: 1.75;
  max-width: 44rem;
}
.reading p { margin-bottom: 1.05rem; }
.reading h2, .reading h3 {
  font-family: Georgia, serif;
  color: var(--navy-900);
  margin-top: 2.2rem;
}
.reading blockquote {
  border-left: 3px solid var(--gold);
  background: var(--surface);
  padding: 0.8rem 1.1rem;
  border-radius: 0 0.5rem 0.5rem 0;
  color: var(--ink-soft);
}
.serif { font-family: Georgia, "Times New Roman", serif; }
.navbar-brand { font-family: Georgia, serif; }

/* ---- Full-bleed helper (breaks out of the .container) ---- */
.fullbleed { width: 100vw; position: relative; left: 50%; margin-left: -50vw; }

/* ---- Hero ---- */
.hero {
  background: linear-gradient(135deg, var(--band-from) 0%, var(--band-to) 100%);
  color: var(--band-ink);
  padding: 4rem 0 4.5rem;
  margin-bottom: 2.5rem;
}
/* keep the navbar above full-bleed sections */
.navbar { position: relative; z-index: 10; background: var(--bg); }
.hero h1 {
  font-family: Georgia, serif;
  font-weight: 700;
  font-size: clamp(2.1rem, 4vw, 3.1rem);
  letter-spacing: -0.5px;
}
.hero .lead { color: var(--band-soft); max-width: 42rem; }
.hero .accent { color: var(--band-accent); }
.hero .stat {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 0.4rem 0.95rem;
  font-size: 0.85rem;
}
.hero .stat b { color: var(--band-ink); }
.hero .continue {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--band-accent);
  color: var(--inverse-text);
  border-radius: 999px;
  padding: 0.5rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.hero .continue:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  color: var(--inverse-text);
}

/* ---- How-it-works strip ---- */
.hiw .item { padding: 0.5rem 0; }
.hiw .emoji { font-size: 1.7rem; line-height: 1; }
.hiw .t { font-weight: 600; color: var(--navy-900); }
.hiw .d { color: var(--navy-500); font-size: 0.9rem; }

/* ---- Section headers ---- */
.section-title {
  font-family: Georgia, serif;
  font-weight: 700;
  color: var(--navy-900);
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.section-title::after {
  content: "";
  flex: 1;
  height: 2px;
  margin-left: 0.75rem;
  background: linear-gradient(90deg, var(--gold), transparent);
  border-radius: 2px;
}
.section-title .count { color: var(--navy-500); font-size: 1rem; font-weight: 400; }

/* ---- Book cards ---- */
.book-card {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.book-card:hover { transform: translateY(-4px); box-shadow: 0 12px 28px rgba(27, 40, 66, 0.16); }
.book-cover {
  aspect-ratio: 3 / 4;
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
}
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-cover.placeholder { font-family: Georgia, serif; font-size: 2.6rem; color: var(--navy-500); }
.book-card .body { padding: 0.6rem 0.75rem 0.75rem; display: flex; flex-direction: column; flex: 1; }
.book-card .title { font-family: Georgia, serif; font-weight: 700; color: var(--navy-900); font-size: 1.06rem; line-height: 1.25; }
.book-card .author { color: var(--navy-500); font-size: 0.84rem; margin-top: 0.15rem; }
.book-card .meta { margin-top: auto; display: flex; gap: 0.35rem; flex-wrap: wrap; justify-content: center; }
.chip { background: var(--bg-soft); color: var(--navy-700); border-radius: 999px; padding: 0.15rem 0.6rem; font-size: 0.72rem; font-weight: 600; }
.book-card .stretched-link::after { position: absolute; inset: 0; content: ""; }

/* ---- Footer: a soft theme-colored band, like the hero ---- */
.site-footer {
  background: var(--band-from);
  color: var(--band-soft);
  padding: 2rem 0;
  margin-top: 3.5rem;
  font-size: 0.9rem;
}
.site-footer a { color: var(--band-ink); text-decoration: none; }
/* Secondary text uses the band palette in both themes. */
.site-footer .text-secondary,
.site-footer .text-muted { color: var(--band-soft) !important; }

/* ---- Audio read-along (static/js/narration.js) ----
   The spoken word is the one place amber survives: it has to be findable at a
   glance mid-paragraph, which the UI accent — a colour the page uses elsewhere
   — cannot do. The paragraph around it gets the same hue at low strength. */
.reading:not(.no-tap-seek) .narratable { cursor: pointer; }
.narration-tap-toggle { margin: 0.35rem 0 0 0.15rem; user-select: none; }
.reading .narrating {
  background: color-mix(in srgb, var(--reading-bg) 22%, transparent);
  border-radius: 0.3rem;
  box-shadow: 0 0 0 0.35rem color-mix(in srgb, var(--reading-bg) 22%, transparent);
  transition: background 0.3s, box-shadow 0.3s;
}
.reading .nw-active {
  background: var(--reading-bg);
  color: var(--reading-fg);
  border-radius: 0.2rem;
  box-shadow: 0 0 0 2px var(--reading-bg);
}
[data-bs-theme="dark"] .reading .narrating {
  background: color-mix(in srgb, var(--reading-bg) 16%, transparent);
  box-shadow: 0 0 0 0.35rem color-mix(in srgb, var(--reading-bg) 16%, transparent);
}

/* The per-theme card and heading overrides that used to live here are gone:
   the tokens above already carry them. */

/* ---- Bootstrap components, re-tinted to the palette ----
   Bootstrap 5.3 drives each button from its own --bs-btn-* custom properties
   with literal values, so re-pointing --bs-primary would not reach them. Only
   the variants the templates actually use are restated here. */
.btn-outline-secondary {
  --bs-btn-color: var(--ink-soft);
  --bs-btn-border-color: var(--line);
  --bs-btn-hover-color: var(--inverse-text);
  --bs-btn-hover-bg: var(--accent);
  --bs-btn-hover-border-color: var(--accent);
  --bs-btn-active-color: var(--inverse-text);
  --bs-btn-active-bg: var(--accent);
  --bs-btn-active-border-color: var(--accent);
  --bs-btn-disabled-color: var(--ink-soft);
  --bs-btn-disabled-border-color: var(--line);
}
.btn-outline-primary {
  --bs-btn-color: var(--accent);
  --bs-btn-border-color: var(--accent);
  --bs-btn-hover-color: var(--inverse-text);
  --bs-btn-hover-bg: var(--accent);
  --bs-btn-hover-border-color: var(--accent);
  --bs-btn-active-color: var(--inverse-text);
  --bs-btn-active-bg: var(--accent);
  --bs-btn-active-border-color: var(--accent);
  --bs-btn-disabled-color: var(--ink-soft);
  --bs-btn-disabled-border-color: var(--line);
}
.btn-secondary {
  --bs-btn-color: var(--inverse-text);
  --bs-btn-bg: var(--accent);
  --bs-btn-border-color: var(--accent);
  --bs-btn-hover-color: var(--inverse-text);
  --bs-btn-hover-bg: var(--accent);
  --bs-btn-hover-border-color: var(--accent);
  --bs-btn-active-color: var(--inverse-text);
  --bs-btn-active-bg: var(--accent);
  --bs-btn-active-border-color: var(--accent);
}
/* The one amber control: it marks the spoken chapter, so it matches the
   read-along highlight rather than the UI accent. */
.btn-warning {
  --bs-btn-color: var(--reading-fg);
  --bs-btn-bg: var(--reading-bg);
  --bs-btn-border-color: var(--reading-bg);
  --bs-btn-hover-color: var(--reading-fg);
  --bs-btn-hover-bg: var(--reading-bg);
  --bs-btn-hover-border-color: var(--reading-bg);
}
.text-bg-secondary {
  background-color: var(--accent-bg) !important;
  color: var(--accent) !important;
}
.text-muted { color: var(--ink-soft) !important; }
.list-group-item {
  --bs-list-group-bg: var(--surface);
  --bs-list-group-color: var(--ink);
  --bs-list-group-border-color: var(--line);
  --bs-list-group-action-hover-bg: var(--surface-2);
  --bs-list-group-action-hover-color: var(--ink);
  --bs-list-group-active-bg: var(--accent);
  --bs-list-group-active-border-color: var(--accent);
  --bs-list-group-active-color: var(--inverse-text);
}
