/* Endpapers — shared design tokens & base elements.
 * Palette "Raven's Wing & Dragon Gold" (from docs/research/gazetteer.json → theme): cover-sampled
 * night violet and foil gold, lilac and mirror-white from the cover raven, Dragon limestone and
 * sea-green slate from the imperial palace, Bodyguard red, blackened larch, endpaper parchment.
 * Book pages may override --book-* tokens at runtime from book.theme. */
@import url('https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@700&family=Cinzel:wght@500;600&family=Cormorant+Garamond:ital,wght@0,500;0,600;1,500&family=EB+Garamond:ital,wght@0,400;0,500;1,400&family=IM+Fell+English+SC&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  color-scheme: dark;
  /* night & surfaces */
  --bg: #140f1e;          /* Raven's Wing night (cover corner, deepened) */
  --bg-2: #1b1425;
  --surface: #2e2140;     /* amethyst dusk (cover edge) */
  --surface-2: #3a2a52;
  --surface-3: #4e3463;   /* cover violet (sampled) */
  --glass: rgba(27, 20, 37, 0.78);
  --glass-strong: rgba(20, 15, 30, 0.92);
  --line: rgba(230, 211, 163, 0.14);
  --line-strong: rgba(230, 211, 163, 0.32);
  /* ink */
  --ink: #f6f1fa;          /* mirror-glass white (cover raven) */
  --ink-2: #e4d8ec;
  --muted: #cdb6d8;        /* lilac plume (author line) */
  --faint: #8c7a9e;
  /* gilt */
  --gold: #ba9658;         /* foil gold (cover rules) */
  --gold-2: #e6d3a3;       /* Dragon limestone */
  --gold-deep: #8a6b37;
  /* cover violet */
  --violet: #6b4a8c;
  --violet-2: #a58bc4;
  --violet-deep: #2e2140;
  /* cool accents from the island */
  --slate: #4e9384;        /* sea-green slate (Dragon roofs) */
  --slate-2: #8cc5b7;
  --sea: #627f86;          /* Armas Channel grey-green */
  --sea-deep: #2b4a52;
  /* warm accents */
  --apricot: #efb48a;      /* canal-bridge roses */
  --parchment: #ece5d2;    /* endpaper parchment */
  --larch: #27201c;        /* blackened larch */
  --cream: #f6e6cc;
  --crimson: #b3261e;      /* Bodyguard red (Bear) */
  --raven: #0a0a11;

  /* book-level overrides (set from book.theme) */
  --book-accent: var(--gold);
  --book-accent-2: var(--violet-2);
  --book-ink: var(--ink);
  --book-bg: var(--bg);

  /* type */
  --font-display: 'Cinzel Decorative', 'Cinzel', 'Trajan Pro', serif;   /* hero & book titles */
  --font-caps: 'Cinzel', 'Trajan Pro', 'Times New Roman', serif;            /* UI headings, banners */
  --font-body: 'EB Garamond', Garamond, Georgia, serif;                   /* reading */
  --font-label: 'Cormorant Garamond', 'EB Garamond', Georgia, serif;       /* map labels, small caps */
  --font-engraved: 'IM Fell English SC', 'Cormorant Garamond', serif;      /* world regions & seas */
  --font-ui: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --fs-xs: 0.72rem; --fs-sm: 0.84rem; --fs-md: 1rem; --fs-lg: 1.2rem; --fs-xl: 1.6rem; --fs-2xl: 2.2rem; --fs-3xl: clamp(2.2rem, 5vw, 4rem);

  /* shape & depth */
  --r-sm: 6px; --r: 10px; --r-lg: 16px; --r-xl: 22px; --r-pill: 999px;
  --shadow-1: 0 1px 2px rgba(0,0,0,.35), 0 4px 14px rgba(0,0,0,.25);
  --shadow-2: 0 10px 40px rgba(5, 2, 14, .55), 0 2px 8px rgba(0,0,0,.35);
  --glow-gold: 0 0 0 1px rgba(230, 211, 163, .4), 0 0 24px rgba(186, 150, 88, .32);
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 72px;

  /* layers */
  --z-map: 0; --z-labels: 10; --z-ui: 20; --z-card: 30; --z-modal: 40; --z-loader: 50;

  /* motion */
  --ease: cubic-bezier(.2, .7, .2, 1);
  --dur-1: 120ms; --dur-2: 220ms; --dur-3: 420ms;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-ui); font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
img, svg, canvas { display: block; max-width: 100%; }
a { color: var(--gold-2); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
::selection { background: rgba(186, 150, 88, .4); color: var(--ink); }
:focus-visible { outline: 2px solid var(--gold-2); outline-offset: 2px; border-radius: 4px; }
h1, h2, h3 { font-family: var(--font-caps); font-weight: 600; letter-spacing: .04em; line-height: 1.15; margin: 0; }
p { margin: 0; }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.mono { font-family: var(--font-mono); letter-spacing: .12em; text-transform: uppercase; }
.serif { font-family: var(--font-body); }

/* buttons & chips */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 40px; padding: 0 var(--s-4); border-radius: var(--r-pill);
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink);
  font: 500 var(--fs-sm)/1 var(--font-ui); cursor: pointer;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.btn:hover { background: var(--surface-3); border-color: var(--gold); }
.btn:active { transform: translateY(1px); }
.btn--gold { background: linear-gradient(180deg, var(--gold-2), var(--gold)); color: #1a1206; border-color: transparent; font-weight: 600; }
.btn--gold:hover { background: linear-gradient(180deg, #f3e6c4, var(--gold-2)); }
.btn--ghost { background: transparent; }
.btn--icon { width: 40px; padding: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px;
  border-radius: var(--r-pill); border: 1px solid var(--line); background: rgba(255,255,255,.02);
  color: var(--ink-2); font: 500 var(--fs-sm)/1 var(--font-ui); cursor: pointer; white-space: nowrap;
  transition: all var(--dur-1) var(--ease);
}
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip[aria-pressed="true"], .chip.is-active { background: rgba(186,150,88,.16); border-color: var(--gold); color: var(--gold-2); }

/* ad slots — reserved, labelled, never over content */
.ad-slot {
  position: relative; display: grid; place-items: center; overflow: hidden;
  border: 1px dashed var(--line-strong); border-radius: var(--r);
  background: repeating-linear-gradient(135deg, rgba(255,255,255,.015) 0 10px, transparent 10px 20px), var(--bg-2);
  color: var(--faint); font: 500 var(--fs-xs)/1.2 var(--font-mono); letter-spacing: .14em; text-transform: uppercase;
}
.ad-slot::before { content: 'Advertisement'; position: absolute; top: 6px; left: 10px; font-size: 10px; opacity: .8; }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 8px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
