/* SizzlinShred: design tokens + shared components.
   Light by default, dark via prefers-color-scheme, manual override via html[data-theme]. */

:root {
  --bg: #f7f3ec;
  --surface: #fffdf8;
  --surface-2: #efe8dc;
  --ink: #1d1a16;
  --ink-2: #463f36;
  --ink-3: #635b50;
  --line: #d9cfbe;
  --line-strong: #b9ad99;

  --ember: #b93d0b;      /* Guitar */
  --ember-soft: #fbe3d4;
  --lapis: #1f4f96;      /* Academy */
  --lapis-soft: #dfe8f7;
  --teal: #0b6b62;       /* Science, the bridge */
  --teal-soft: #d6efeb;
  --gold: #855f12;
  --on-accent: #fff;

  --ok: #1d6b34;
  --warn: #8a5300;
  --bad: #a3221b;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;

  --r: 10px;
  --r-sm: 6px;
  --shadow: 0 1px 2px rgb(40 30 15 / .06), 0 4px 16px rgb(40 30 15 / .06);
  --wrap: 72rem;
  --gutter: clamp(1rem, 4vw, 2rem);
  --accent: var(--ember);
  --accent-soft: var(--ember-soft);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131110;
    --surface: #1c1916;
    --surface-2: #26221d;
    --ink: #efe9de;
    --ink-2: #cfc6b7;
    --ink-3: #a59b8b;
    --line: #3a342c;
    --line-strong: #574e42;
    --ember: #ff8f52;
    --ember-soft: #3b2216;
    --lapis: #93b6ff;
    --lapis-soft: #1b2741;
    --teal: #5fd0c2;
    --teal-soft: #13302c;
    --gold: #e6bd60;
    --on-accent: #1a1209;
    --ok: #6fd08c;
    --warn: #f0b860;
    --bad: #ff8a80;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 6px 20px rgb(0 0 0 / .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131110;
  --surface: #1c1916;
  --surface-2: #26221d;
  --ink: #efe9de;
  --ink-2: #cfc6b7;
  --ink-3: #a59b8b;
  --line: #3a342c;
  --line-strong: #574e42;
  --ember: #ff8f52;
  --ember-soft: #3b2216;
  --lapis: #93b6ff;
  --lapis-soft: #1b2741;
  --teal: #5fd0c2;
  --teal-soft: #13302c;
  --gold: #e6bd60;
  --on-accent: #1a1209;
  --ok: #6fd08c;
  --warn: #f0b860;
  --bad: #ff8a80;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 6px 20px rgb(0 0 0 / .25);
  color-scheme: dark;
}

/* Section accents: set on <body> */
.is-guitar  { --accent: var(--ember); --accent-soft: var(--ember-soft); }
.is-academy { --accent: var(--lapis); --accent-soft: var(--lapis-soft); }
.is-science { --accent: var(--teal);  --accent-soft: var(--teal-soft); }

/* ── Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 5rem; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1.0625rem/1.65 var(--sans);
  text-rendering: optimizeLegibility;
}
img, svg, canvas { max-width: 100%; }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; line-height: 1.15; margin: 0 0 .5em; color: var(--ink); text-wrap: balance; }
h1 { font-size: clamp(2.3rem, 6vw, 4rem); letter-spacing: -.01em; }
h2 { font-size: clamp(1.7rem, 3.6vw, 2.5rem); }
h3 { font-size: 1.3rem; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
strong { font-weight: 650; }
code, kbd, pre, .mono { font-family: var(--mono); font-size: .92em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
::selection { background: var(--accent); color: var(--on-accent); }

.skip {
  position: absolute; left: 1rem; top: -4rem; z-index: 100;
  background: var(--ink); color: var(--bg); padding: .6rem 1rem; border-radius: var(--r-sm);
}
.skip:focus { top: 1rem; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.wrap { width: min(var(--wrap), 100% - 2 * var(--gutter)); margin-inline: auto; }
.narrow { max-width: 44rem; }
.section { padding-block: clamp(3rem, 8vw, 5.5rem); }
.section + .section { border-top: 1px solid var(--line); }
.section.alt { background: var(--surface-2); }
.kicker {
  display: inline-block; font: 600 .78rem/1.2 var(--sans); letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); margin-bottom: .75rem;
}
.lede { font-size: 1.2rem; color: var(--ink-2); max-width: 40rem; }
.muted { color: var(--ink-3); }
.small { font-size: .9rem; }

/* ── Header ───────────────────────────────────────── */
.site-header {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 50;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; gap: 1rem; min-height: 4rem; }
.brand {
  display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--ink);
  font: 700 1.25rem/1 var(--serif); letter-spacing: .01em; margin-right: auto;
}
.brand svg { width: 1.75rem; height: 1.75rem; flex: none; }
.brand b { color: var(--ember); font-weight: 700; }
.nav { display: flex; gap: .25rem; }
.nav a {
  color: var(--ink-2); text-decoration: none; font-weight: 550; font-size: .97rem;
  padding: .45rem .7rem; border-radius: 999px;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--ink); color: var(--bg); }
.icon-btn {
  display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem; flex: none;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink);
  cursor: pointer;
}
.icon-btn:hover { border-color: var(--line-strong); }
.icon-btn svg { width: 1.15rem; height: 1.15rem; }
.menu-btn { display: none; }

@media (max-width: 900px) {
  .menu-btn { display: inline-grid; }
  .nav {
    display: none; position: absolute; left: 0; right: 0; top: 100%;
    flex-direction: column; gap: 0; padding: .5rem var(--gutter) 1rem;
    background: var(--bg); border-bottom: 1px solid var(--line); box-shadow: var(--shadow);
  }
  .nav.open { display: flex; }
  .nav a { padding: .8rem .9rem; border-radius: var(--r-sm); font-size: 1.05rem; }
}

/* ── Footer ───────────────────────────────────────── */
.site-footer { border-top: 1px solid var(--line); padding-block: 3rem calc(3rem + env(safe-area-inset-bottom, 0px)); color: var(--ink-3); font-size: .95rem; }
.site-footer .wrap { display: grid; gap: 2rem; grid-template-columns: 2fr repeat(3, 1fr); }
.site-footer h2 { font-size: 1rem; font-family: var(--sans); color: var(--ink); letter-spacing: .04em; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.site-footer a { color: var(--ink-2); text-decoration: none; }
.site-footer a:hover { color: var(--accent); text-decoration: underline; }
.motto { font-family: var(--serif); font-style: italic; color: var(--ink-2); font-size: 1.1rem; }
@media (max-width: 760px) { .site-footer .wrap { grid-template-columns: 1fr 1fr; } .site-footer .wrap > :first-child { grid-column: 1 / -1; } }

/* ── Buttons, chips, inputs ───────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 2.75rem; padding: .55rem 1.15rem; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: 600 1rem/1.2 var(--sans); text-decoration: none; cursor: pointer;
  transition: background-color .15s, border-color .15s, transform .1s;
}
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn-sm { min-height: 2.25rem; padding: .35rem .85rem; font-size: .92rem; }
.btn[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }

.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip {
  min-height: 2.25rem; padding: .3rem .85rem; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2);
  font: 550 .92rem/1.2 var(--sans);
}
.chip:hover { color: var(--ink); border-color: var(--ink-3); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

label { font-weight: 600; font-size: .95rem; }
input[type="text"], input[type="search"], input[type="number"], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: .55rem .7rem; min-height: 2.75rem;
  width: 100%;
}
textarea { min-height: 6rem; resize: vertical; }
input[type="range"] { width: 100%; accent-color: var(--accent); min-height: 2rem; }
.field { display: grid; gap: .35rem; }
.field-row { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); }

/* ── Cards, grids ─────────────────────────────────── */
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(22rem, 100%), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(17rem, 100%), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(13rem, 100%), 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 1.4rem; box-shadow: var(--shadow);
}
.card > :last-child { margin-bottom: 0; }
.card h3 { margin-bottom: .4rem; }
.card .num { font: 600 .8rem/1 var(--mono); color: var(--accent); letter-spacing: .08em; display: block; margin-bottom: .6rem; }
a.card { display: block; text-decoration: none; color: inherit; transition: border-color .15s, transform .15s; }
a.card:hover { border-color: var(--accent); transform: translateY(-2px); }

/* ── Status + provenance badges ───────────────────── */
.badge {
  display: inline-block; font: 650 .74rem/1 var(--sans); letter-spacing: .06em; text-transform: uppercase;
  padding: .35rem .55rem; border-radius: 999px; border: 1px solid currentColor; vertical-align: middle; white-space: nowrap;
}
.st-demonstrated, .pv-attested { color: var(--ok); }
.st-established, .pv-reported { color: var(--lapis); }
.st-provisional, .pv-paraphrase { color: var(--warn); }
.st-aporetic { color: var(--gold); }
.st-refuted, .pv-doubtful { color: var(--bad); }

/* ── Disclosure (details) ─────────────────────────── */
details.item {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  margin-bottom: .75rem;
}
details.item > summary {
  list-style: none; cursor: pointer; padding: 1rem 3rem 1rem 1.25rem; position: relative;
  display: grid; gap: .3rem;
}
details.item > summary::-webkit-details-marker { display: none; }
details.item > summary::after {
  content: ""; position: absolute; right: 1.25rem; top: 1.35rem; width: .6rem; height: .6rem;
  border-right: 2px solid var(--ink-3); border-bottom: 2px solid var(--ink-3); transform: rotate(45deg);
  transition: transform .15s;
}
details.item[open] > summary::after { transform: rotate(225deg); top: 1.6rem; }
details.item > summary:hover { background: var(--surface-2); border-radius: var(--r); }
details.item .summary-title { font: 600 1.15rem/1.3 var(--serif); }
details.item .summary-meta { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; color: var(--ink-3); font-size: .9rem; }
details.item .body { padding: 0 1.25rem 1.25rem; border-top: 1px solid var(--line); padding-top: 1rem; }
details.item .body > :last-child { margin-bottom: 0; }
.body h4 { font: 650 .8rem/1.2 var(--sans); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); margin: 1.25rem 0 .4rem; }
.steps { padding-left: 1.4rem; }
.steps li { margin-bottom: .45rem; }
.qed { border-left: 3px solid var(--accent); padding: .3rem 0 .3rem .9rem; font-style: italic; }

/* ── Tools ────────────────────────────────────────── */
.tool {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: clamp(1.1rem, 3vw, 1.75rem); box-shadow: var(--shadow);
}
.tool-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: .5rem 1rem; margin-bottom: 1rem; }
.tool-head h3 { margin: 0; }
.readouts { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr)); margin: 1rem 0; }
.readout { background: var(--surface-2); border-radius: var(--r-sm); padding: .65rem .8rem; }
.readout dt, .readout .k { font: 600 .75rem/1.2 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.readout dd, .readout .v { margin: .2rem 0 0; font: 600 1.25rem/1.2 var(--mono); color: var(--ink); font-variant-numeric: tabular-nums; }
.big-num { font: 700 clamp(2.5rem, 8vw, 4rem)/1 var(--mono); font-variant-numeric: tabular-nums; }
.canvas-box { position: relative; background: var(--surface-2); border-radius: var(--r-sm); overflow: hidden; }
.canvas-box canvas { display: block; width: 100%; height: auto; touch-action: none; }

/* Tablature */
pre.tab {
  font: .95rem/1.45 var(--mono); background: var(--surface-2); color: var(--ink);
  padding: 1rem 1.1rem; border-radius: var(--r-sm); overflow-x: auto; margin: 0 0 1rem;
}
.tab-wrap { overflow-x: auto; }

/* Notes / callouts */
.note {
  border: 1px solid var(--line); border-left: 4px solid var(--accent); background: var(--accent-soft);
  padding: .9rem 1.1rem; border-radius: var(--r-sm); margin: 1rem 0;
}
.note > :last-child { margin-bottom: 0; }
.note.analogy { border-left-color: var(--gold); background: var(--surface-2); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: .7rem 1.1rem; border-radius: 999px;
  font-weight: 600; box-shadow: var(--shadow); z-index: 90; max-width: calc(100% - 2rem);
}
.toast:empty { padding: 0; box-shadow: none; }

/* ── Page hero ────────────────────────────────────── */
.page-hero { padding-block: clamp(3rem, 9vw, 6rem) clamp(2rem, 6vw, 3.5rem); border-bottom: 1px solid var(--line); }
.page-hero .lede { margin-bottom: 1.5rem; }
.toc { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: 1.5rem; }
.toc a {
  text-decoration: none; color: var(--ink-2); border: 1px solid var(--line-strong); border-radius: 999px;
  padding: .35rem .85rem; font-size: .93rem; font-weight: 550;
}
.toc a:hover { border-color: var(--accent); color: var(--accent); }

/* Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}
@media print {
  .site-header, .site-footer, .btn, .chip, .tool { display: none !important; }
  body { background: #fff; color: #000; }
}

/* Spacing utilities */
.mt-1 { margin-top: 1rem; }
.mt-half { margin-top: .5rem; }
