/* Shared design tokens + small components used by the book AND the site pages.
   Two themes: light "botanical editorial" (cream paper, ink, deep green, amber) and dark "night botanical"
   ([data-theme="dark"], set before first paint by the head script; toggled by app/site.js). */
/* ============ tokens ============ */
:root {
  --W: 420px; --H: 583px; --u: 4.2px; --fs: 2.8; --tilt: 15deg; --shift: 0px;
  --f-serif: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --f-label: "Bahnschrift", "DIN Alternate", "DIN Next", "Roboto Condensed", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --f-sans: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --noise: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 .55 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");

  --bg: #f4f1e8;
  --paper: #fbfaf6; --paper2: #f3efe4;
  --ink: #16241a; --ink2: #3c4a3e; --muted: #4a5547; --muted-off: #7a8576;
  --green: #3f7a2e; --green-d: #1f3d24; --amber: #c7782a;
  --acc: #c7782a;
  --line: rgba(63, 122, 46, .42); --line2: rgba(63, 122, 46, .15);
  --tag-bg: rgba(63, 122, 46, .05);
  --edge0: #f6f2e7; --edge1: #d9d1bd; --board: #1f3d24;
  --cover-a: #2c5130; --cover-b: #1f3d24; --cover-c: #142a18;
  --gold: #d9b26a; --gold-l: #f3dfa8;
  --ui-bg: rgba(255, 255, 255, .6); --ui-br: rgba(22, 36, 26, .13); --ui-ink: #16241a;
  --menu-bg: #fbfaf6;
  --head-bg: rgba(248, 246, 239, .86);
  --card-sh: 0 1px 0 rgba(255, 255, 255, .8) inset, 0 12px 30px rgba(31, 61, 36, .09);
  scrollbar-color: rgba(63, 122, 46, .45) transparent;
  color-scheme: light;

  /* derived tokens (the light values reproduce the original hard-coded colours) */
  --fill: #1f3d24; --fill-h: #2a5230; --fill-ink: #f6f1e2;          /* filled buttons / chips / tooltip / toast */
  --green-t: #1f3d24;                                                /* deep green used as text */
  --sh: 31, 52, 28;                                                  /* shadow colour (r, g, b) */
  --gate-bg: rgba(240, 237, 226, .84); --gate-ring: rgba(63, 122, 46, .3);
  --amber-line: rgba(199, 120, 42, .45); --amber-hover: rgba(199, 120, 42, .08);
  --focus-ring: rgba(63, 122, 46, .12);
  --card-sh-h: 0 1px 0 rgba(255, 255, 255, .8) inset, 0 18px 40px rgba(31, 61, 36, .14);
  --glow-hi: rgba(255, 255, 255, .95); --glow-hi2: rgba(255, 255, 255, .9);
  --glow-lo: rgba(170, 205, 140, .3); --glow-lo2: rgba(170, 205, 140, .28); --glow-rgb: 150, 190, 130;
  --bgname: rgba(63, 122, 46, .24);
  --thumb-sh: rgba(22, 36, 26, .25);
  --faux1: rgba(22, 36, 26, .14); --faux2: rgba(22, 36, 26, .3); --faux-bud: rgba(63, 122, 46, .35);
  --amb-0: #fdfcf8; --amb-1: #f3f0e6; --amb-2: #e6e5d6;
  --amb-g1: rgba(236, 214, 170, .45); --amb-g2: rgba(150, 190, 130, .34);
  --grain-op: .07; --grain-blend: multiply;
}

/* ============ dark theme: "night botanical" ============
   deep green-black ground, cream ink, brightened green, amber accents; no pink / purple.
   Contrast (WCAG): ink #efe9dc on #131c16 ≈ 14:1, ink2 ≈ 10:1, muted ≈ 7.8:1, muted-off ≈ 5.1:1, amber/green on paper ≥ 7:1. */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1511;
  --paper: #131c16; --paper2: #18231c;
  --ink: #efe9dc; --ink2: #d2d3c5; --muted: #adb8a8; --muted-off: #869283;
  --green: #7fbf5a; --green-d: #a9d68a; --amber: #e0a15a;
  --acc: #e0a15a;
  --line: rgba(127, 191, 90, .4); --line2: rgba(127, 191, 90, .17);
  --tag-bg: rgba(127, 191, 90, .07);
  --edge0: #1b271f; --edge1: #0f1712; --board: #1a3a20;
  --cover-a: #2a4f2e; --cover-b: #1d3a22; --cover-c: #122916;
  --ui-bg: rgba(22, 33, 26, .72); --ui-br: rgba(239, 233, 220, .15); --ui-ink: #efe9dc;
  --menu-bg: #131c16;
  --head-bg: rgba(14, 21, 17, .86);
  --card-sh: 0 1px 0 rgba(239, 233, 220, .05) inset, 0 14px 34px rgba(0, 0, 0, .42);
  scrollbar-color: rgba(127, 191, 90, .45) transparent;

  --fill: #2c5a2e; --fill-h: #37703a; --fill-ink: #f6f1e2;
  --green-t: #a9d68a;
  --sh: 0, 0, 0;
  --gate-bg: rgba(8, 13, 10, .82); --gate-ring: rgba(127, 191, 90, .3);
  --amber-line: rgba(224, 161, 90, .5); --amber-hover: rgba(224, 161, 90, .12);
  --focus-ring: rgba(127, 191, 90, .22);
  --card-sh-h: 0 1px 0 rgba(239, 233, 220, .06) inset, 0 20px 44px rgba(0, 0, 0, .55), 0 0 36px rgba(127, 191, 90, .07);
  --glow-hi: rgba(224, 161, 90, .2); --glow-hi2: rgba(224, 161, 90, .2);
  --glow-lo: rgba(127, 191, 90, .17); --glow-lo2: rgba(127, 191, 90, .17); --glow-rgb: 127, 191, 90;
  --bgname: rgba(127, 191, 90, .34);
  --thumb-sh: rgba(0, 0, 0, .6);
  --faux1: rgba(239, 233, 220, .16); --faux2: rgba(239, 233, 220, .34); --faux-bud: rgba(127, 191, 90, .4);
  --amb-0: #18241c; --amb-1: #0f1712; --amb-2: #0a100d;
  --amb-g1: rgba(224, 161, 90, .10); --amb-g2: rgba(127, 191, 90, .13);
  --grain-op: .06; --grain-blend: screen;
}
[data-mode="single"] { --fs: 3.1; --tilt: 6deg; }
::selection { background: rgba(199, 120, 42, .25); }

* { box-sizing: border-box; }
button { font: inherit; color: inherit; }

/* letter-spaced Bahnschrift labels (small caps feel) */
.eyebrow, .label, .ratio, .tod em, .meta-row, .pill, .cbd, .gp, .chip, .toc-no, .toc-sub, .gl-in, .colophon, .folio,
.cover-kicker, .cover-foot, .back-foot, .back-names, .pg-label, .hint, .site-nav a, .seg button, .tbtn, .btn, .flbl, .fchip, .cat-count,
.no-badge, .card-sub, .card-more, .crumbs, .s-meta, .s-pill, .s-row .lbl, .s-sec h2, .s-pager small, .terp .alt, .terp h3,
.wallet-net, .foot-nav, .tod-lbl, .toc-foot, .ph-cap b, .info-head .no, .thc-n, .thc-u, .thc-mini, .terp .count, .gate-age, .age, .hero-gen, .book-foot { font-family: var(--f-label); }

.tag { display: inline-flex; align-items: center; gap: .45em; padding: .3em .85em; border-radius: 99px; border: 1px solid var(--line); background: var(--tag-bg); font-size: .86em; color: var(--ink); white-space: nowrap; }
.tag::before { content: ""; width: .42em; height: .42em; border-radius: 50%; background: var(--acc); }
/* strain / title names: Georgia serif */
.sname { display: inline-block; font-family: var(--f-serif); font-weight: 400; line-height: 1.1; white-space: nowrap; color: var(--ink); letter-spacing: -.005em; }
.sname.it { font-style: italic; }
/* ============ ratio bar & time of day ============ */
.ratio { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .9em; font-size: .78em; letter-spacing: .2em; text-transform: uppercase; }
.ratio b { color: var(--ink); }
.ratio span { color: var(--muted); }
.ratio-track { display: flex; gap: 3px; height: .32em; }
.ratio-track i { display: block; height: 100%; border-radius: 99px; }
.ratio-track .ri { background: var(--green); }
.ratio-track .rs { background: var(--amber); }
.ratio.compact { width: 100%; gap: .4em; font-size: .62em; letter-spacing: .1em; }
.ratio.compact .ratio-lbl b { display: none; }
.ico { width: 1.5em; height: 1.5em; fill: none; stroke: currentColor; stroke-width: 1.6; }
.tod { display: inline-flex; gap: .9em; }
.tod > span { display: inline-flex; align-items: center; gap: .35em; color: var(--muted-off); opacity: .85; }
.tod > span em { font-style: normal; font-size: .78em; letter-spacing: .16em; text-transform: uppercase; }
.tod > span.on { color: var(--acc); opacity: 1; }
.tod.mini { gap: .5em; }

/* ============ ambient scene: soft cream / sage studio ============ */
.ambient { position: fixed; inset: 0; overflow: hidden; pointer-events: none;
  background: radial-gradient(80% 70% at 50% 38%, var(--amb-0) 0%, var(--amb-1) 58%, var(--amb-2) 100%); }
.amb-glow { position: absolute; border-radius: 50%; filter: blur(40px); }
.amb-glow.g1 { width: 50vw; height: 50vw; left: -16vw; top: -20vw; background: radial-gradient(circle, var(--amb-g1), transparent 65%); }
.amb-glow.g2 { width: 60vw; height: 60vw; right: -20vw; bottom: -26vw; background: radial-gradient(circle, var(--amb-g2), transparent 65%); }
.grain { position: absolute; inset: 0; background: var(--noise); opacity: var(--grain-op); mix-blend-mode: var(--grain-blend); }
.leaf-mark { fill: none; stroke: currentColor; stroke-width: 1.15; stroke-linecap: round; stroke-linejoin: round; }

/* ============ loupe (app/loupe.js): round optical lens, both themes ============ */
:root { --loupe-ring: #f7f3e6; --loupe-ring-in: rgba(22, 36, 26, .34); --loupe-edge: rgba(22, 36, 26, .22); }
[data-theme="dark"] { --loupe-ring: #cdbf97; --loupe-ring-in: rgba(0, 0, 0, .6); --loupe-edge: rgba(0, 0, 0, .45); }
.loupe { position: fixed; left: 0; top: 0; z-index: 95; width: var(--lp-d, 200px); height: var(--lp-d, 200px); pointer-events: none; opacity: 0; visibility: hidden; transition: opacity .14s ease, visibility 0s .14s; will-change: transform; contain: layout style; }
.loupe.show { opacity: 1; visibility: visible; transition: opacity .14s ease; }
.lp-body { position: absolute; inset: 0; border-radius: 50%; transform: scale(.9); transition: transform .18s cubic-bezier(.2, .9, .3, 1.2);
  box-shadow: 0 18px 38px rgba(var(--sh), .38), 0 4px 10px rgba(var(--sh), .3), 0 0 0 1px var(--loupe-ring-in); }
.loupe.show .lp-body { transform: none; }
.lp-in { position: absolute; inset: 0; border-radius: 50%; overflow: hidden; background: var(--paper); isolation: isolate; }
.lp-in canvas { position: absolute; left: 0; top: 0; display: none; }
.lp-dom { position: absolute; inset: 0; display: none; }
.lp-wrap { position: absolute; left: 0; top: 0; transform-origin: 0 0; pointer-events: none; }
.lp-glass { position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
  box-shadow: inset 0 0 0 4px var(--loupe-ring), inset 0 0 0 5px var(--loupe-ring-in), inset 0 0 22px 8px var(--loupe-edge);
  background: radial-gradient(120% 120% at 28% 20%, rgba(255, 255, 255, .26), rgba(255, 255, 255, 0) 36%), radial-gradient(closest-side, transparent 76%, rgba(0, 0, 0, .16)); }
.loupe-on #gl, .loupe-on .scene { cursor: crosshair; }
@media (prefers-reduced-motion: reduce) { .loupe, .lp-body { transition: none; } }
