/* Trove — design tokens
   ────────────────────── */

:root {
  color-scheme: light;
  /* Brand */
  --navy-950: #0F1A30;
  --navy-900: #15233F;
  --navy-800: #1F2D4D;
  --navy-700: #2A3D63;
  --navy-600: #3A4F7A;
  --navy-500: #5A6E94;

  /* Gold variants — set via [data-accent] */
  --gold:        #C9A44E;  /* warm gold (default) */
  --gold-soft:   #DDC288;
  --gold-deep:   #A68238;

  /* Neutral paper / cream */
  --paper-50:  #FCFAF5;
  --paper-100: #F7F3EA;
  --paper-200: #EFE9DB;
  --paper-300: #E2DBC9;
  --paper-400: #C9C0AB;

  /* Ink */
  --ink-900: #14213D;
  --ink-700: #354766;
  --ink-500: #5D6B85;
  --ink-400: #8492A8;
  --ink-300: #B4BECE;

  /* Cool neutrals — light theme surfaces */
  --cool-50:  #FAFBFD;
  --cool-100: #F1F4F9;
  --cool-200: #E4E9F2;
  --cool-300: #CFD6E4;

  /* Semantic — light theme defaults */
  --bg:         #FFFFFF;
  --bg-elev:    #FFFFFF;
  --bg-sunken:  var(--cool-100);
  --surface:    var(--cool-50);
  --border:     var(--cool-200);
  --border-strong: var(--cool-300);
  --fg:         var(--navy-900);
  --fg-muted:   #47566F;
  --fg-subtle:  #5F6E86;
  --brand:      var(--navy-900);
  --brand-fg:   #FFFFFF;
  --accent:     var(--gold);
  --accent-fg:  var(--navy-900);
  --ring:       color-mix(in oklab, var(--accent) 50%, transparent);
  --shadow-sm: 0 1px 2px rgba(20,33,61,.05), 0 1px 0 rgba(20,33,61,.03);
  --shadow-md: 0 4px 12px -2px rgba(20,33,61,.08), 0 2px 4px -2px rgba(20,33,61,.05);
  --shadow-lg: 0 24px 48px -16px rgba(20,33,61,.18), 0 8px 16px -8px rgba(20,33,61,.08);
  --shadow-xl: 0 40px 80px -20px rgba(20,33,61,.25);

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --radius-xl: 22px;

  --font-sans: 'Mulish', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-serif: 'Mulish', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'Mulish', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
}

/* Dark navy chrome (header + footer) — overrides semantic tokens locally so children adapt */
.chrome-dark {
  background: #0F1A30;
  --bg: #0F1A30;
  --bg-elev: var(--navy-900);
  --bg-sunken: var(--navy-900);
  --surface: rgba(255,255,255,.07);
  --border: rgba(255,255,255,.13);
  --border-strong: rgba(255,255,255,.24);
  --fg: #FFFFFF;
  --fg-muted: rgba(255,255,255,.72);
  --fg-subtle: rgba(255,255,255,.52);
  --gold-deep: var(--gold-soft);
}

/* Dark mode */
[data-theme="dark"] {
  color-scheme: dark;
  --bg:         #0E1729;
  --bg-elev:    #15223C;
  --bg-sunken:  #0A1322;
  --surface:    #15223C;
  --border:     #243558;
  --border-strong: #324874;
  --fg:         #EDE7D4;
  --fg-muted:   #9AA8C2;
  --fg-subtle:  #6E7E9C;
  --brand:      #EDE7D4;
  --brand-fg:   var(--navy-900);
  --accent-fg:  var(--navy-900);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow-md: 0 6px 18px rgba(0,0,0,.45);
  --shadow-lg: 0 24px 48px -16px rgba(0,0,0,.55);
  --shadow-xl: 0 40px 80px -20px rgba(0,0,0,.65);
}

/* Accent variants */
[data-accent="warm"]   { --gold: #C9A44E; --gold-soft:#E0C684; --gold-deep:#9F7E32; }
[data-accent="muted"]  { --gold: #B7A375; --gold-soft:#D4C49E; --gold-deep:#8E7A4E; }
[data-accent="brass"]  { --gold: #9C7E3F; --gold-soft:#BFA269; --gold-deep:#76612F; }

/* ─── Base reset ─── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
  font-variation-settings: "opsz" 14;
  font-size: 15.5px;
  line-height: 1.6;
  font-weight: 500;
}
a { text-decoration-thickness: 1.5px; text-underline-offset: 2px; }
button { font: inherit; color: inherit; }
input, textarea { font: inherit; }
a:not(.btn) { color: var(--gold-deep); }
a:not(.btn):hover { color: var(--fg); }

/* Selection */
::selection { background: color-mix(in oklab, var(--accent) 50%, transparent); color: var(--fg); }

/* Utility — focus ring */
.focus-ring:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* ── Decorative background marks (subtle) ── */
.deco-marks {
  position: absolute; inset: 0; pointer-events: none; overflow: hidden;
  opacity: .35;
}
[data-theme="dark"] .deco-marks { opacity: .18; }

/* ── Type scale ── */
.t-display {
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: clamp(40px, 5.6vw, 72px);
  letter-spacing: -0.024em;
  line-height: 1.04;
}
.t-h1 { font-size: 32px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.t-h2 { font-size: 22px; font-weight: 700; letter-spacing: -.014em; line-height: 1.2; }
.t-h3 { font-size: 17.5px; font-weight: 700; letter-spacing: -.008em; line-height: 1.25; }
.t-body { font-size: 15.5px; line-height: 1.6; }
.t-small { font-size: 13.75px; line-height: 1.55; font-weight: 500; }
.t-micro { font-size: 11.75px; letter-spacing: .07em; text-transform: uppercase; font-weight: 700; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 10px 16px; border-radius: var(--radius);
  border: 1px solid transparent; background: transparent; color: var(--fg);
  font-weight: 600; font-size: 14.5px; cursor: default; transition: all .15s ease;
  white-space: nowrap;
}
.btn:hover { background: color-mix(in oklab, var(--fg) 6%, transparent); }
.btn-primary {
  background: var(--brand); color: var(--brand-fg); border-color: var(--brand);
}
.btn-primary:hover { background: color-mix(in oklab, var(--brand) 86%, white); color: var(--brand-fg); border-color: color-mix(in oklab, var(--brand) 86%, white); }
.btn-accent {
  background: var(--accent); color: var(--accent-fg); border-color: var(--accent);
  font-weight: 600;
}
.btn-accent:hover { background: var(--gold-deep); color: var(--accent-fg); border-color: var(--gold-deep); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-sunken); border-color: var(--border-strong); }
/* Ghost button sitting on a dark panel — hover stays translucent so white text keeps contrast */
.btn-on-dark { background: transparent; border-color: rgba(255,255,255,.22); color: #FFFFFF; }
.btn-on-dark:hover { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.4); color: #FFFFFF; }
.btn-sm { padding: 7px 12px; font-size: 13.5px; border-radius: 8px; }
.btn-lg { padding: 14px 22px; font-size: 15.5px; border-radius: 12px; }

/* ── Pills / badges ── */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 12.25px; font-weight: 600; line-height: 1.5;
  background: var(--bg-sunken); color: var(--fg-muted);
  border: 1px solid var(--border);
}
.pill-accent { background: color-mix(in oklab, var(--accent) 18%, var(--bg)); color: var(--gold-deep); border-color: color-mix(in oklab, var(--accent) 40%, var(--border)); }
[data-theme="dark"] .pill-accent { color: var(--gold-soft); }
.pill-ks1 { background: #EFF1F8; color: #2A3D63; border-color: #DCE0EE; }
.pill-ks2 { background: #FAF4E4; color: #6B5928; border-color: #EBDFC2; }
[data-theme="dark"] .pill-ks1 { background: rgba(120,140,200,.16); color:#B5C2E0; border-color: rgba(120,140,200,.28); }
[data-theme="dark"] .pill-ks2 { background: rgba(201,164,78,.14); color:#DEC589; border-color: rgba(201,164,78,.28); }

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }

/* Inputs */
.input {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--fg);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.wiki-search-input::placeholder { color: var(--fg-subtle); }
.wiki-search-input:focus { border-color: var(--accent) !important; box-shadow: 0 0 0 4px var(--ring), 0 8px 30px -10px rgba(20,33,61,.18) !important; }

/* Scrollbars (mild) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--cool-300); border-radius: 8px; border: 2px solid var(--bg); background-clip: padding-box; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: var(--border-strong); border-color: var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-300); }

/* Animations */
@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes fade-in-scale { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
@keyframes slide-up { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.fade-in { animation: fade-in .35s ease both; }
.fade-in-scale { animation: fade-in-scale .25s cubic-bezier(.2,.8,.2,1) both; }
.slide-up { animation: slide-up .35s cubic-bezier(.2,.8,.2,1) both; }

/* Print — hide app chrome, flatten cards (used by the Curriculum tracker's Print button) */
@media print {
  header, footer, .no-print, .tweaks-panel { display: none !important; }
  body, .card { background: #fff !important; }
  .card { box-shadow: none !important; break-inside: avoid; }
  main { max-width: none !important; padding: 0 !important; }
}

/* Mobile: tighten page gutters and scale down oversized display type.
   Structural layout changes (nav drawer, sidebar collapse, grid stacking)
   are handled per-component via the useViewport() hook. */
@media (max-width: 640px) {
  main { padding-left: 18px !important; padding-right: 18px !important; }
  .t-display { font-size: clamp(30px, 8.5vw, 40px) !important; line-height: 1.08 !important; }
  .t-h1 { font-size: clamp(22px, 6vw, 28px) !important; }
}

/* Hide native number-input spinners (we handle numeric entry ourselves) */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* Homepage showcase marquee */
.showcase-viewport { position: relative; overflow: hidden; -webkit-mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent); mask-image: linear-gradient(90deg, transparent, #000 5%, #000 95%, transparent); }
.showcase-track { display: flex; gap: 20px; width: max-content; padding: 4px 20px; animation: showcase-scroll 80s linear infinite; }
.showcase-viewport:hover .showcase-track { animation-play-state: paused; }
@keyframes showcase-scroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.showcase-card img { transition: transform .35s ease; }
.showcase-card:hover img { transform: scale(1.04); }
@media (prefers-reduced-motion: reduce) {
  .showcase-track { animation: none; }
  .showcase-viewport { overflow-x: auto; -webkit-mask-image: none; mask-image: none; }
}

/* Countdown solution: left-to-right "pen writing" reveal per line */
@keyframes cd-write { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.cd-write { display: inline-block; animation: cd-write 1.4s cubic-bezier(.6,.02,.4,1) both; }
@media (prefers-reduced-motion: reduce) { .cd-write { animation: none; } }

/* Wiki article "On this page" mobile disclosure */
.wiki-toc-mobile summary::-webkit-details-marker { display: none; }
.wiki-toc-mobile[open] .wiki-toc-chevron { transform: rotate(180deg); }
.wiki-toc-mobile nav a:active { background: var(--bg); }

/* Hide scrollbar utility */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { scrollbar-width: none; }
