/* interactive.css — shared chrome for the interactive pages.
   Tokens mirror the main site so these pages feel like part of it. */

:root {
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --bg: #fcfbf9;
  --surface: #ffffff;
  --ink: #191a1c;
  --muted: #5c6169;
  --faint: #8a9099;
  --rule: #e6e3dd;
  --accent: #1c4e7c;
  --accent-soft: #eef3f8;

  /* sequential ramp — one hue, light→dark, five bands (validated) */
  --t0: #86b6ef; --t1: #5598e7; --t2: #2a78d6; --t3: #1c5cab; --t4: #104281;
  --on-t0: #0b0b0b; --on-t1: #0b0b0b; --on-t2: #ffffff; --on-t3: #ffffff; --on-t4: #ffffff;

  --good: #0ca30c;
  --warn: #b26a00;
  --critical: #d03b3b;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131417; --surface: #1a1c20; --ink: #e9e8e5; --muted: #a3a8af;
    --faint: #7b8189; --rule: #2a2d33; --accent: #8ebbe2; --accent-soft: #1b242e;
    /* anchor flips: the near-surface end becomes the dark one */
    --t0: #184f95; --t1: #256abf; --t2: #3987e5; --t3: #6da7ec; --t4: #b7d3f6;
    --on-t0: #ffffff; --on-t1: #ffffff; --on-t2: #ffffff; --on-t3: #0b0b0b; --on-t4: #0b0b0b;
    --warn: #e0a44a;
  }
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-sans); font-size: 16px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 64rem; margin: 0 auto; padding: 2.5rem 1.5rem 5rem; }

h1 {
  font-family: var(--font-serif); font-size: clamp(1.9rem, 4vw, 2.5rem);
  font-weight: 600; letter-spacing: -0.015em; line-height: 1.15; margin: 0 0 0.75rem;
}
h2 { font-family: var(--font-serif); font-size: 1.25rem; font-weight: 600; margin: 0 0 0.6rem; }
h3 { font-family: var(--font-serif); font-size: 1.05rem; font-weight: 600; margin: 0 0 0.5rem; }

.eyebrow {
  font-size: 0.72rem; font-weight: 650; letter-spacing: 0.11em;
  text-transform: uppercase; color: var(--faint); margin: 0 0 0.5rem;
}
p { margin: 0 0 1rem; max-width: 38rem; }
.lede { font-size: 1.1rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
code, .mono { font-family: var(--font-mono); font-size: 0.9em; }
a { color: var(--accent); text-underline-offset: 2px; }

.backlink { display: inline-block; font-size: 0.9rem; margin-bottom: 1.25rem; }

/* ---- panels & controls ---- */
.panel {
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: 4px; padding: 1rem 1.1rem;
}
.panel + .panel { margin-top: 1rem; }
.panel h3 {
  font-family: var(--font-sans); font-size: 0.72rem; font-weight: 650;
  letter-spacing: 0.11em; text-transform: uppercase; color: var(--faint); margin: 0 0 0.6rem;
}

.controls {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.9rem 1.25rem;
  padding: 1rem 1.1rem; background: var(--surface);
  border: 1px solid var(--rule); border-radius: 4px;
}
.field { display: flex; flex-direction: column; gap: 0.25rem; }
.field label {
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em;
  color: var(--muted); text-transform: uppercase;
}
input[type="number"], select, input[type="text"] {
  font: inherit; font-size: 0.92rem; padding: 0.32rem 0.5rem;
  border: 1px solid var(--rule); border-radius: 3px;
  background: var(--bg); color: var(--ink);
}
input[type="number"] { width: 5rem; }
input[type="range"] { width: 9rem; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 0.45rem; font-size: 0.9rem; color: var(--muted); }
.check input { accent-color: var(--accent); width: 1rem; height: 1rem; }

.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin: 1.25rem 0 0; align-items: center; }
button {
  font: inherit; font-size: 0.92rem; font-weight: 550;
  padding: 0.5rem 1rem; border-radius: 3px; cursor: pointer;
  border: 1px solid var(--accent); color: var(--accent); background: transparent;
  transition: background .15s, color .15s;
}
button:hover:not(:disabled) { background: var(--accent); color: var(--bg); }
button.primary { background: var(--accent); color: var(--bg); }
button.primary:hover:not(:disabled) { opacity: .87; }
button.quiet { border-color: var(--rule); color: var(--muted); }
button.quiet:hover:not(:disabled) { background: var(--rule); color: var(--ink); }
button:disabled { opacity: .4; cursor: not-allowed; }

/* ---- grid ---- */
.gridwrap {
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: 4px; padding: 0.9rem;
}
svg.grid { display: block; width: 100%; height: auto; touch-action: none; }

/* ---- messages ---- */
.note-row { display: flex; align-items: flex-start; gap: 0.6rem; font-size: 0.9rem; padding: 0.3rem 0; }
.note-row .icon { flex: none; font-weight: 700; line-height: 1.45; }
.note-row.err .icon { color: var(--critical); }
.note-row.warn .icon { color: var(--warn); }
.note-row.ok .icon { color: var(--good); }

.result {
  display: none; align-items: flex-start; gap: 0.7rem;
  margin: 1.25rem 0 0; padding: 0.85rem 1.1rem;
  border-radius: 4px; border-left: 3px solid var(--faint);
  background: var(--accent-soft); max-width: 40rem;
}
.result.show { display: flex; }
.result.ok { border-left-color: var(--good); }
.result.bad { border-left-color: var(--critical); }
.result .icon { font-weight: 700; font-size: 1.05rem; line-height: 1.5; flex: none; }
.result.ok .icon { color: var(--good); }
.result.bad .icon { color: var(--critical); }
.result p { margin: 0; }
.result strong { display: block; }

.stat { display: flex; justify-content: space-between; font-size: 0.88rem; padding: 0.15rem 0; }
.stat span:last-child { font-family: var(--font-mono); }

details { margin-top: 1.5rem; border-top: 1px solid var(--rule); padding-top: 1rem; }
summary { cursor: pointer; font-weight: 600; font-size: 0.95rem; }
table { border-collapse: collapse; margin-top: 0.9rem; font-size: 0.88rem; }
th, td { text-align: right; padding: 0.22rem 0.85rem 0.22rem 0; font-family: var(--font-mono); }
th { color: var(--faint); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; }
td:first-child, th:first-child { text-align: left; }
tbody tr:nth-child(odd) { background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }

.notes { margin-top: 2.5rem; border-top: 1px solid var(--rule); padding-top: 1.5rem; }
.notes ul { max-width: 38rem; padding-left: 1.1rem; }
.notes li { margin-bottom: 0.5rem; }

.credit { margin-top: 2.5rem; font-size: 0.82rem; color: var(--faint); max-width: 38rem; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
