/* Drakemere — one stylesheet for the whole site.
   Tokens are three layers: primitive → semantic → component. Rules below the token
   block read semantic or component tokens only; hex lives in the primitive block. */

@font-face {
  font-family: "EB Garamond";
  src: url(../fonts/eb-garamond.woff2) format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "EB Garamond";
  src: url(../fonts/eb-garamond-italic.woff2) format("woff2");
  font-style: italic;
  font-weight: 400 600;
  font-display: swap;
}

/* ---------- 1. Primitive ---------- */
:root {
  --paper-50: #fbf8f0;
  --paper-100: #f5efe1;
  --paper-200: #ece4d2;
  --ink-900: #1c2039;
  --ink-600: #4f536c;
  --ink-400: #b3adc0;
  --night-900: #15172a;
  --night-800: #1d2036;
  --studio-red-600: #9e3324;
  --studio-red-300: #ec8f78;

  /* Dumpster Raccoon world (Codex riso art) */
  --rc-night: #2b2f52;
  --rc-night-deep: #22253f;
  --rc-cream: #f3ead8;
  --rc-coral-600: #b8472d;
  --rc-coral-400: #e8735a;

  /* UnivDesk world (univ-desk/docs/art-direction.md) */
  --ud-navy: #071730;
  --ud-navy-2: #0c2142;
  --ud-mist: #e9eef7;
  --ud-mist-2: #a9b4c8;
  --ud-emerald-500: #0dba74;
  --ud-emerald-700: #0a7a4d;

  --black-a12: rgb(28 32 57 / 0.16);
  --cream-a16: rgb(236 228 210 / 0.18);
}

/* ---------- 2. Semantic (light) ---------- */
:root {
  color-scheme: light dark;
  --surface: var(--paper-100);
  --surface-raised: var(--paper-50);
  --text: var(--ink-900);
  --text-muted: var(--ink-600);
  --rule: var(--black-a12);
  --link: var(--studio-red-600);
  --accent: var(--studio-red-600);
  --focus: var(--studio-red-600);
  --band-surface: var(--ink-900);
  --band-text: var(--paper-100);
  --band-muted: var(--ink-400);
  --band-accent: var(--studio-red-300);

  --font: "EB Garamond", "Iowan Old Style", Palatino, Georgia, serif;
  --step--1: 0.9375rem;
  --step-0: clamp(1.125rem, 1.06rem + 0.3vw, 1.25rem);
  --step-1: clamp(1.3rem, 1.2rem + 0.5vw, 1.6rem);
  --step-2: clamp(1.7rem, 1.45rem + 1.1vw, 2.4rem);
  --step-3: clamp(2.2rem, 1.7rem + 2.4vw, 3.6rem);
  --step-hw: clamp(4rem, 2rem + 10vw, 10.5rem);

  --gutter: clamp(1rem, 0.5rem + 3vw, 4rem);
  --wide: 70rem;
  --measure: 38rem;
  --space-s: 0.75rem;
  --space-m: 1.5rem;
  --space-l: clamp(2.5rem, 2rem + 3vw, 5rem);
  --space-xl: clamp(3.5rem, 2.5rem + 5vw, 7.5rem);

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --dur-press: 120ms;
  --dur-hover: 240ms;
  --dur-enter: 420ms;
}

/* ---------- 2b. Semantic (dark) ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --surface: var(--night-900);
    --surface-raised: var(--night-800);
    --text: var(--paper-200);
    --text-muted: var(--ink-400);
    --rule: var(--cream-a16);
    --link: var(--studio-red-300);
    --accent: var(--studio-red-300);
    --focus: var(--studio-red-300);
    --band-surface: var(--night-800);
  }
}

/* Product worlds rebind accent, link and band only. */
[data-world="raccoon"] {
  --link: var(--rc-coral-600);
  --accent: var(--rc-coral-600);
  --focus: var(--rc-coral-600);
  --band-surface: var(--rc-night);
  --band-text: var(--rc-cream);
  --band-muted: var(--rc-cream);
  --band-accent: var(--rc-coral-400);
}
[data-world="univdesk"] {
  --link: var(--ud-emerald-700);
  --accent: var(--ud-emerald-700);
  --focus: var(--ud-emerald-700);
  --band-surface: var(--ud-navy);
  --band-text: var(--ud-mist);
  --band-muted: var(--ud-mist-2);
  --band-accent: var(--ud-emerald-500);
}
@media (prefers-color-scheme: dark) {
  [data-world="raccoon"] {
    --link: var(--rc-coral-400);
    --accent: var(--rc-coral-400);
    --focus: var(--rc-coral-400);
    --surface: var(--rc-night-deep);
  }
  [data-world="univdesk"] {
    --link: var(--ud-emerald-500);
    --accent: var(--ud-emerald-500);
    --focus: var(--ud-emerald-500);
    --surface: var(--ud-navy);
    --surface-raised: var(--ud-navy-2);
  }
}

/* ---------- 3. Component ---------- */
:root {
  --plate-frame: var(--text);
  --plate-mat: var(--surface-raised);
  --sense-number: var(--accent);
  --chip-border: var(--rule);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--surface);
  color: var(--text);
  font: 400 var(--step-0)/1.55 var(--font);
  font-variant-numeric: oldstyle-nums proportional-nums;
  text-rendering: optimizeLegibility;
}
img { display: block; max-width: 100%; height: auto; }
h1, h2, h3, p, ol, ul, dl, dd, figure { margin: 0; }
a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 0.18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 2px; }
::selection { background: var(--accent); color: var(--surface); }

.skip {
  position: absolute; left: var(--gutter); top: -100px;
  background: var(--surface-raised); color: var(--text);
  padding: 0.6rem 1rem; z-index: 10;
}
.skip:focus { top: 0.75rem; }

.wrap { width: min(100% - 2 * var(--gutter), var(--wide)); margin-inline: auto; }
.visually-num { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.sc { font-variant: small-caps; letter-spacing: 0.06em; }
.muted { color: var(--text-muted); }

/* ---------- Header / footer ---------- */
.site-header { border-bottom: 1px solid var(--rule); }
.site-header .wrap {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0.25rem 1.5rem; min-height: 4rem; padding-block: 0.5rem;
}
.wordmark {
  color: var(--text); text-decoration: none;
  font-variant: small-caps; letter-spacing: 0.08em; font-size: var(--step-1);
  display: inline-flex; align-items: center; min-height: 44px;
}
.site-nav ul { list-style: none; padding: 0; display: flex; gap: 0.25rem 1.25rem; flex-wrap: wrap; }
.site-nav a {
  color: var(--text); text-decoration: none; font-variant: small-caps; letter-spacing: 0.06em;
  display: inline-flex; align-items: center; min-height: 44px; padding-inline: 0.15rem;
}
.site-nav a:hover { text-decoration: underline; }
.site-nav a[aria-current="page"] { text-decoration: underline; text-decoration-color: var(--accent); }

.site-footer { border-top: 1px solid var(--rule); margin-top: var(--space-xl); }
.site-footer .wrap {
  display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; justify-content: space-between;
  padding-block: 1.5rem 2rem; color: var(--text-muted); font-size: var(--step--1);
}
.site-footer ul { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0 1.25rem; }
.site-footer a { color: var(--text-muted); display: inline-flex; align-items: center; min-height: 44px; }

/* ---------- Home: the dictionary entry ---------- */
.entry { padding-block: var(--space-l) var(--space-m); }
.headword {
  font-size: var(--step-hw); font-weight: 500; line-height: 0.86; letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
.pron { margin-top: 1rem; font-size: var(--step-1); color: var(--text-muted); max-width: 44rem; }
.pron .pos { color: var(--accent); font-style: italic; margin-inline: 0.35em; }
.etym { margin-top: 1rem; max-width: var(--measure); color: var(--text-muted); }
.etym b { color: var(--text); font-weight: 600; }

.senses {
  list-style: none; padding: 1.75rem 0 0; margin-top: var(--space-m);
  border-top: 1px solid var(--rule);
  display: grid; gap: 2rem;
}
@media (min-width: 48rem) { .senses { grid-template-columns: 1fr 1fr; gap: 2rem 3rem; } }
.senses li { display: grid; grid-template-columns: 2.25rem 1fr; }
.senses .n { color: var(--sense-number); font-weight: 700; font-size: var(--step-2); line-height: 1; }
.senses h2 { font-size: var(--step-2); font-weight: 500; font-style: italic; line-height: 1.05; }
.senses .gloss { grid-column: 2; margin-top: 0.5rem; max-width: 30rem; }
.senses .see { grid-column: 2; margin-top: 0.5rem; font-size: var(--step--1); }
.senses .see a { display: inline-flex; align-items: center; min-height: 44px; }

/* ---------- Plates (works) ---------- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.section-head h2 { font-size: var(--step-2); font-weight: 500; }
.works { padding-top: var(--space-l); }
.plates { display: grid; gap: var(--space-l); margin-top: var(--space-m); }

.plate {
  position: relative;
  border: 1px solid var(--plate-frame);
  background: var(--plate-mat);
  padding: clamp(0.5rem, 0.3rem + 0.8vw, 0.875rem);
  animation: plate-in var(--dur-enter) var(--ease-out) both;
}
.plate:nth-child(2) { animation-delay: 80ms; }
.plate .art { overflow: hidden; background: var(--band-surface); }
.plate .art img { width: 100%; transition: transform var(--dur-hover) var(--ease-out); }
.plate figcaption {
  display: grid; gap: 0.35rem 1.5rem; padding: 0.9rem 0.25rem 0.25rem;
}
@media (min-width: 48rem) {
  .plate figcaption { grid-template-columns: 1fr auto; align-items: baseline; }
}
.plate .no { font-variant: small-caps; letter-spacing: 0.08em; color: var(--text-muted); font-size: var(--step--1); }
.plate h3 { font-size: var(--step-1); font-weight: 600; line-height: 1.2; }
.plate h3 a { color: var(--text); text-decoration: none; }
.plate h3 a::after { content: ""; position: absolute; inset: 0; }
.plate h3 a:focus-visible { outline: none; }
.plate:has(h3 a:focus-visible) { outline: 3px solid var(--focus); outline-offset: 4px; }
.plate .what { max-width: 36rem; color: var(--text-muted); }
.plate .status { font-variant: small-caps; letter-spacing: 0.06em; font-size: var(--step--1); }
@media (min-width: 48rem) { .plate .status { white-space: nowrap; } }
.plate .status .dot { color: var(--accent); }
@media (hover: hover) {
  .plate:hover .art img { transform: scale(1.015); }
  .plate:hover h3 a { text-decoration: underline; text-decoration-color: var(--accent); }
}

@keyframes plate-in {
  from { opacity: 0; transform: translateY(10px); }
}

/* ---------- Prose blocks ---------- */
.block { padding-top: var(--space-l); }
.block h2 { font-size: var(--step-2); font-weight: 500; line-height: 1.1; }
.block > .wrap > * + * { margin-top: 1rem; }
.prose { max-width: var(--measure); }
.prose > * + * { margin-top: 1rem; }
.prose h2 { font-size: var(--step-2); font-weight: 500; line-height: 1.1; margin-top: var(--space-l); }
.prose h3 { font-size: var(--step-1); font-weight: 600; line-height: 1.2; margin-top: 2rem; }
.prose ul { padding-left: 1.25rem; }
.prose li + li { margin-top: 0.5rem; }
.prose code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.85em; overflow-wrap: anywhere; }
.lede { font-size: var(--step-1); line-height: 1.4; max-width: 40rem; }

.two-col { display: grid; gap: var(--space-m); }
@media (min-width: 48rem) { .two-col { grid-template-columns: 1fr 1fr; gap: 3rem; } }

.mail {
  display: inline-flex; align-items: center; min-height: 48px;
  padding: 0.5rem 1.25rem; border: 1px solid var(--text); color: var(--text);
  text-decoration: none; font-size: var(--step-1);
  transition: transform var(--dur-press) var(--ease-out);
}
.mail:hover { text-decoration: underline; text-decoration-color: var(--accent); }
.mail:active { transform: translateY(1px) scale(0.985); }

/* ---------- Product band ---------- */
.band { background: var(--band-surface); color: var(--band-text); }
.band .crumb { padding-top: 1.25rem; font-size: var(--step--1); color: var(--band-muted); }
.band .crumb a { color: var(--band-text); display: inline-flex; align-items: center; min-height: 44px; }
.band-art { margin-top: 0.75rem; }
.band-art img { width: 100%; }
.band-copy { padding-block: var(--space-m) var(--space-l); display: grid; gap: 1rem; }
.band h1 { font-size: var(--step-3); font-weight: 500; line-height: 1.02; }
.band h1 .sub { display: block; font-size: var(--step-1); font-style: italic; color: var(--band-muted); margin-top: 0.4rem; }
.band .lede { color: var(--band-text); }
.band .logo { width: min(100%, 30rem); }
.band :focus-visible { outline-color: var(--band-accent); }

.facts {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; margin-top: 0.5rem;
  border-top: 1px solid var(--band-muted);
}
@media (min-width: 48rem) { .facts { grid-template-columns: repeat(4, 1fr); gap: 0; } }
.facts div { padding: 0.75rem 0; border-bottom: 1px solid var(--band-muted); }
@media (min-width: 48rem) { .facts div { padding-right: 1rem; } }
.facts dt { font-variant: small-caps; letter-spacing: 0.08em; font-size: var(--step--1); color: var(--band-muted); }
.facts dd { font-size: var(--step-0); }
.facts .accent { color: var(--band-accent); }
[data-world="raccoon"] .facts .accent { color: var(--band-text); text-decoration: underline; text-decoration-color: var(--band-accent); text-decoration-thickness: 2px; text-underline-offset: 0.2em; }

/* ---------- Gallery ---------- */
.gallery { list-style: none; padding: 0; display: grid; gap: var(--space-m); margin-top: var(--space-m); }
@media (min-width: 48rem) { .gallery { grid-template-columns: 1fr 1fr; } }
.gallery figure { border: 1px solid var(--rule); background: var(--surface-raised); padding: 0.5rem; }
.gallery img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.gallery figcaption { padding: 0.6rem 0.25rem 0.15rem; font-size: var(--step--1); color: var(--text-muted); }

.spots { list-style: none; padding: 0; display: grid; gap: var(--space-m); margin-top: var(--space-m); }
@media (min-width: 40rem) { .spots { grid-template-columns: 1fr 1fr; } }
@media (min-width: 64rem) { .spots { grid-template-columns: repeat(4, 1fr); } }
.spots li { display: grid; gap: 0.6rem; align-content: start; }
.spots img { width: 100%; max-width: 14rem; aspect-ratio: 1; object-fit: cover; border-radius: 4px; }
.spots h3 { font-size: var(--step-1); font-weight: 600; line-height: 1.2; }
.spots p { color: var(--text-muted); }

.callout {
  border-block: 1px solid var(--rule); padding-block: 1rem; max-width: var(--measure);
  font-size: var(--step-1); line-height: 1.4;
}

.notfound { padding-block: var(--space-xl); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important; animation-delay: 0ms !important;
    transition-duration: 1ms !important;
  }
  .plate:hover .art img { transform: none; }
}

@media print {
  .site-nav, .skip { display: none; }
  .band { background: none; color: inherit; }
}

/* ---------- Plain pages ---------- */
.page-title { font-size: var(--step-3); font-weight: 500; line-height: 1.02; }
.notfound .headword { margin-top: 0.5rem; }
.notfound .prose { margin-top: var(--space-m); }
