/* grunners.vip — domain-wide stylesheet
   One file, all pages. Tokens at the top, components below.
   Surface: Operate (tool first) with a Learn section underneath. */

:root {
  color-scheme: dark;

  /* neutrals — warm-leaning, not blue-grey */
  --bg:        oklch(17% 0.012 70);
  --surface:   oklch(21% 0.014 70);
  --surface-2: oklch(25% 0.016 70);
  --border:    oklch(31% 0.016 70);
  --ink:       oklch(93% 0.010 80);
  --ink-dim:   oklch(72% 0.014 78);
  --ink-faint: oklch(58% 0.014 78);

  /* single accent */
  --accent:      oklch(78% 0.150 68);
  --accent-ink:  oklch(22% 0.040 68);
  --accent-dim:  oklch(38% 0.070 68);

  --ok:   oklch(72% 0.140 150);
  --warn: oklch(78% 0.140 85);

  /* type */
  --font-display: "Bricolage Grotesque", ui-serif, Georgia, serif;
  --font-body:    "Public Sans", ui-sans-serif, "Segoe UI", Helvetica, sans-serif;
  --font-mono:    ui-monospace, "JetBrains Mono", "SFMono-Regular", Consolas, monospace;

  /* rhythm */
  --sp: 0.5rem;
  --radius: 10px;
  --radius-lg: 16px;
  --maxw: 44rem;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg:        oklch(97% 0.008 80);
    --surface:   oklch(100% 0 0);
    --surface-2: oklch(95% 0.008 78);
    --border:    oklch(87% 0.010 78);
    --ink:       oklch(24% 0.014 70);
    --ink-dim:   oklch(44% 0.014 76);
    --ink-faint: oklch(58% 0.014 78);
    --accent:      oklch(58% 0.150 55);
    --accent-ink:  oklch(99% 0 0);
    --accent-dim:  oklch(88% 0.070 68);
  }
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  font-size: 1rem;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-underline-offset: 3px; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; text-wrap: balance; font-weight: 600; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* ---------- chrome ---------- */
.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: 1.25rem; }

.site-head {
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: blur(8px);
}
.site-head .wrap { display: flex; align-items: center; gap: 1.25rem; min-height: 3.5rem; flex-wrap: wrap; }
.brand { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; color: var(--ink); text-decoration: none; letter-spacing: -0.02em; }
.brand span { color: var(--accent); }
.site-nav { display: flex; gap: 0.25rem; flex-wrap: wrap; margin-left: auto; }
.site-nav a {
  color: var(--ink-dim); text-decoration: none; font-size: 0.875rem;
  padding: 0.35rem 0.6rem; border-radius: 6px; min-height: 32px; display: inline-flex; align-items: center;
}
.site-nav a:hover { color: var(--ink); background: var(--surface-2); }
.site-nav a[aria-current="page"] { color: var(--accent); background: var(--surface); }

main { flex: 1; padding-block: 2.5rem 4rem; }

.site-foot {
  border-top: 1px solid var(--border); padding-block: 1.5rem;
  color: var(--ink-faint); font-size: 0.8125rem;
}
.site-foot .wrap { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: space-between; }
.site-foot nav { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.site-foot a { color: var(--ink-dim); }

/* ---------- page furniture ---------- */
.eyebrow {
  font-family: var(--font-mono); font-size: 0.6875rem; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-faint); margin-bottom: 0.75rem;
}
.page-title { font-size: clamp(1.75rem, 5vw, 2.5rem); letter-spacing: -0.02em; }
.lede { color: var(--ink-dim); margin-top: 0.75rem; font-size: 1.0625rem; }

/* ---------- the tool (Operate surface) ---------- */
.tool {
  margin-top: 2rem; padding: 1.25rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  display: grid; gap: 1rem;
}
.tool-stage {
  display: grid; place-items: center; gap: 1rem;
  min-height: 9rem; padding: 1rem 0;
}
.result {
  font-family: var(--font-mono); font-weight: 700;
  font-size: clamp(3rem, 18vw, 5.5rem); line-height: 1;
  letter-spacing: -0.03em; text-align: center; word-break: break-word;
}
.result-label { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); }

.controls { display: flex; gap: 0.6rem; flex-wrap: wrap; justify-content: center; }
.control { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; justify-content: center; }

.btn {
  font-family: var(--font-body); font-size: 1rem; font-weight: 600;
  min-height: 48px; padding: 0.6rem 1.4rem; cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
  border: 1px solid transparent; border-radius: var(--radius);
  transition: filter 120ms ease, transform 80ms ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-secondary { background: var(--surface-2); color: var(--ink); border-color: var(--border); }
.btn-secondary:hover { filter: brightness(1.15); }
.btn-small { min-height: 36px; padding: 0.3rem 0.75rem; font-size: 0.875rem; }

.field { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.875rem; color: var(--ink-dim); }
.field input[type="number"], .field select, .field input[type="text"] {
  font-family: var(--font-mono); font-size: 0.9375rem;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 0.45rem 0.6rem; min-height: 40px; width: 5.5rem;
}
.field select, .field input[type="text"] { width: auto; }
.field input:focus-visible, .field select:focus-visible { outline-offset: 0; }

.meta { font-family: var(--font-mono); font-size: 0.6875rem; color: var(--ink-faint); text-align: center; }

/* ---------- history ---------- */
.history { border-top: 1px solid var(--border); padding-top: 0.75rem; }
.history summary { cursor: pointer; font-size: 0.8125rem; color: var(--ink-dim); font-family: var(--font-mono); }
.history summary:hover { color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.6rem; }
.chip {
  font-family: var(--font-mono); font-size: 0.8125rem;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--ink-dim);
  padding: 0.2rem 0.5rem; border-radius: 6px;
}

/* ---------- Learn section (SEO, below the tool) ---------- */
.learn { margin-top: 3rem; }
.learn h2 { font-size: 1.375rem; margin-top: 2rem; margin-bottom: 0.5rem; letter-spacing: -0.01em; }
.learn h2:first-of-type { margin-top: 0; }
.learn h3 { font-size: 1.0625rem; margin-top: 1.5rem; margin-bottom: 0.35rem; }
.learn p, .learn li { color: var(--ink-dim); }
.learn ul, .learn ol { padding-left: 1.25rem; display: grid; gap: 0.35rem; margin-block: 0.75rem; }
.learn strong { color: var(--ink); font-weight: 600; }
.learn code { font-family: var(--font-mono); font-size: 0.875em; background: var(--surface-2); padding: 0.1em 0.35em; border-radius: 4px; }

/* data table — for chi-square output */
.data { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: 0.8125rem; margin-block: 1rem; }
.data caption { text-align: left; color: var(--ink-faint); font-size: 0.75rem; padding-bottom: 0.5rem; }
.data th, .data td { padding: 0.4rem 0.6rem; text-align: right; border-bottom: 1px solid var(--border); }
.data th:first-child, .data td:first-child { text-align: left; }
.data thead th { color: var(--ink-faint); font-weight: 400; }
.data tbody tr:last-child td { border-bottom: 0; }

/* verdict banner */
.verdict {
  margin-block: 1rem; padding: 0.9rem 1.1rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface-2);
  font-size: 0.9375rem;
}
.verdict[data-tone="ok"]   { border-color: color-mix(in oklab, var(--ok) 45%, var(--border)); }
.verdict[data-tone="warn"] { border-color: color-mix(in oklab, var(--warn) 45%, var(--border)); }
.verdict b { display: block; font-size: 1.05rem; margin-bottom: 0.15rem; }
.verdict[data-tone="ok"] b { color: var(--ok); }
.verdict[data-tone="warn"] b { color: var(--warn); }

.meter-wrap { display: grid; gap: .4rem; justify-items: center; width: 100%; }
/* proportion bar with a 50% tick — shows heads share against a fair coin */
.meter { position: relative; width: 100%; max-width: 22rem; height: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width 200ms ease; }
.meter::after {
  content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px;
  background: var(--ink-faint); opacity: .7;
}

/* ---------- cookie consent ---------- */
/* Anchored bottom-centre, max-width so it stays readable, and never covers
   the whole viewport: the tools must remain usable even if it is ignored. */
.consent-open { overflow: hidden; }

.consent-panel {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: end center;
  padding: 1rem;
  background: color-mix(in oklab, var(--bg) 55%, transparent);
  backdrop-filter: blur(2px);
}
.consent-panel[hidden] { display: none; }

.consent-card {
  width: 100%; max-width: 34rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: 0 -4px 24px rgba(0,0,0,.28);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
}
.consent-title { font-size: 1.125rem; letter-spacing: -0.01em; }
.consent-body { margin-top: .6rem; display: grid; gap: .6rem; }
.consent-body p { font-size: .9375rem; color: var(--ink-dim); }
.consent-note { font-size: .875rem !important; color: var(--ink-faint) !important; }
.consent-actions { margin-top: 1rem; display: flex; gap: .5rem; flex-wrap: wrap; }
.consent-actions .btn { flex: 1 1 auto; min-width: 8rem; }
.consent-settings-link { margin-top: .85rem; font-size: .8125rem; }
.consent-settings-link a { color: var(--ink-faint); }

/* Choice summary shown on /cookie-settings/ and in the footer. */
.consent-status { display: grid; gap: .5rem; margin-block: 1rem; }
.consent-status-row {
  display: flex; gap: .75rem; align-items: baseline; justify-content: space-between;
  padding: .6rem .75rem; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-2); font-size: .9375rem;
}
.consent-status-row strong { font-family: var(--font-mono); font-size: .8125rem; }
@media (min-width: 40rem) { .consent-panel { place-items: end center; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* utility */
.stack { display: grid; gap: 0.75rem; }
.hide { display: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}