/* Speed Disc Golf — shared styles. System fonts, no external requests.
   Type, spacing, and line-height sit on a golden-ratio scale (PHI = 1.61803398875).
   Every font-size, margin, padding, gap, and line-height below uses a token. */
:root {
  --bg: #f6f4ee;
  --surface: #ffffff;
  --surface-2: #eeebe2;
  --ink: #13221b;
  --muted: #4a5a52;
  --line: #d8d3c6;
  --accent: #e4572e;        /* disc orange: fills, never small text */
  --accent-ink: #a93a12;    /* orange for text on light surfaces */
  --green: #1d6b46;
  --green-soft: #e3efe7;
  --amber-soft: #fbeedd;
  --focus: #1a5fd0;
  --night: #0f2a1f;
  --night-2: #17402f;
  --on-night: #f3f6f1;
  --on-night-muted: #b9cbbf;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(19 34 27 / 0.06), 0 8px 24px rgb(19 34 27 / 0.06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --wrap: 72rem;

  /* Spacers: s_n = 1.5 * PHI^(n-6) rem. Whole steps for margins, gaps, and
     horizontal padding; half/double steps (calc) only for vertical padding. */
  --s1: 0.135255rem;
  --s2: 0.218847rem;
  --s3: 0.354102rem;
  --s4: 0.572949rem;
  --s5: 0.927051rem;
  --s6: 1.5rem;
  --s7: 2.427051rem;
  --s8: 3.927051rem;
  --s9: 6.354102rem;
  --s10: 10.281153rem;
  --s11: 16.635255rem;

  /* Type: 16px * PHI^n. t-1 (9.9px) is below the 11-12px floor, so nothing uses it. */
  --t-1: 0.618034rem;
  --t0: 1rem;
  --t1: 1.618034rem;
  --t2: 2.618034rem;
  --t3: 4.236068rem;

  /* Line-heights: the only four allowed (plus 1 on fixed numeral boxes). */
  --lh-tight: 1.145898;  /* display, hero */
  --lh-snug: 1.236064;   /* titles, UI, buttons */
  --lh-read: 1.381966;   /* leads, captions */
  --lh-loose: 1.618034;  /* body */

  /* Spring: a damped spring (stiffness 260, damping 18, mass 1; ~12% overshoot)
     sampled every 15 ms into a linear() easing. Used by the calculator reveal and press. */
  --spring: linear(0, 0.029, 0.1, 0.201, 0.319, 0.444, 0.567, 0.684, 0.789, 0.879, 0.955, 1.014, 1.059, 1.09, 1.109, 1.118, 1.119, 1.113, 1.103, 1.09, 1.075, 1.061, 1.046, 1.033, 1.021, 1.011, 1.002, 0.996, 0.991, 0.988, 0.986, 0.986, 0.986, 0.987, 0.988, 0.99, 0.992, 0.993, 0.995, 0.997, 1);
  --spring-dur: 600ms;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1712;
    --surface: #14231b;
    --surface-2: #1b2e24;
    --ink: #edf2ec;
    --muted: #a8b9ae;
    --line: #2b3e33;
    --accent-ink: #ff9a6c;
    --green: #6fd6a3;
    --green-soft: #173527;
    --amber-soft: #33271a;
    --focus: #8ab4ff;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 8px 24px rgb(0 0 0 / 0.25);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: var(--s8); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 var(--t0)/var(--lh-loose) var(--font);
  text-rendering: optimizeLegibility;
}
img, svg { max-width: 100%; }
a { color: var(--accent-ink); text-underline-offset: 0.18em; text-decoration-thickness: 0.08em; }
a:hover { text-decoration-thickness: 0.14em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
h1, h2, h3 { line-height: var(--lh-snug); letter-spacing: -0.02em; margin: 0 0 var(--s4); text-wrap: balance; }
h1 { font-size: clamp(var(--t2), 7vw, var(--t3)); line-height: var(--lh-tight); margin-bottom: var(--s6); font-weight: 850; letter-spacing: -0.035em; }
h2 { font-size: clamp(var(--t1), 4vw, var(--t2)); margin-bottom: var(--s5); font-weight: 800; }
h3 { font-size: var(--t0); font-weight: 750; }
p, ul, ol { margin: 0 0 var(--s5); }
p, li, dd { text-wrap: pretty; }
li + li { margin-top: var(--s3); }
.num { font-variant-numeric: tabular-nums; }

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--s5); }
@media (min-width: 48rem) { .wrap { padding-inline: var(--s6); } }

.skip {
  position: absolute; left: var(--s5); top: calc(-1 * var(--s8)); z-index: 50;
  background: var(--ink); color: var(--bg); padding: var(--s4) var(--s5); border-radius: 8px; font-weight: 700;
}
.skip:focus { top: var(--s5); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; gap: var(--s5); flex-wrap: wrap; padding-block: var(--s4); }
.brand { display: inline-flex; align-items: center; gap: var(--s4); color: var(--ink); text-decoration: none; font-weight: 850; letter-spacing: -0.02em; line-height: var(--lh-snug); }
.brand svg { width: 2rem; height: 2rem; flex: none; }
.site-nav { margin-left: auto; }
.site-nav ul { display: flex; gap: var(--s1); list-style: none; margin: 0; padding: 0; flex-wrap: wrap; }
.site-nav li + li { margin: 0; }
.site-nav a {
  display: block; padding: calc(var(--s5) / 2) var(--s4); border-radius: 999px;
  color: var(--ink); text-decoration: none; font-weight: 650; line-height: var(--lh-snug);
}
.site-nav a:hover { background: var(--surface-2); }
.site-nav a[aria-current="page"] { background: var(--ink); color: var(--bg); }
@media (max-width: 40rem) {
  .site-header { position: static; }
  .site-nav { margin-left: 0; width: 100%; }
  .site-nav ul { gap: var(--s2); }
  .site-nav a { padding: var(--s3) var(--s4); background: var(--surface-2); }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s4);
  min-height: 2.9rem; padding: calc(var(--s3) * 2) var(--s6); border-radius: 999px; border: 2px solid transparent;
  font: inherit; font-weight: 750; text-decoration: none; cursor: pointer; line-height: var(--lh-snug);
}
.btn-primary { background: var(--accent); color: #1a0d06; }
.btn-primary:hover { background: #f06a3f; }
.btn-ghost { border-color: currentColor; color: inherit; background: transparent; }
.btn-ghost:hover { background: rgb(255 255 255 / 0.08); }
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s5); }
.more { margin: var(--s6) 0 0; }

/* ---------- Hero ---------- */
.hero {
  background:
    radial-gradient(ellipse 80% 60% at 75% 10%, rgb(255 209 102 / 0.12), transparent 60%),
    linear-gradient(170deg, var(--night) 0%, var(--night-2) 100%);
  color: var(--on-night);
  overflow: hidden;
}
.hero .wrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s6); padding-block: var(--s7); align-items: center; }
@media (min-width: 60rem) { .hero .wrap { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: var(--s7); padding-block: var(--s8); } }
.eyebrow { text-transform: uppercase; letter-spacing: 0.14em; font-weight: 800; line-height: var(--lh-snug); color: var(--accent-ink); margin-bottom: var(--s4); }
.lead { line-height: var(--lh-read); }
.hero .lead { color: var(--on-night-muted); max-width: 34rem; }
.hero .btn-primary:focus-visible, .hero .btn-ghost:focus-visible, .hero :focus-visible { outline-color: #ffd166; }

.formula {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s3) var(--s4);
  font-weight: 800; line-height: var(--lh-snug); margin: var(--s6) 0;
}
.formula .term { padding: var(--s2) var(--s4); border-radius: 8px; background: rgb(255 255 255 / 0.08); border: 1px solid rgb(255 255 255 / 0.14); }
.formula .op { color: #ffd166; }
.formula .term.total { background: var(--accent); color: #1a0d06; border-color: transparent; }

.hero-art { margin: 0; }
.hero-art svg { display: block; width: 100%; height: auto; }
.scoreboard {
  display: flex; justify-content: center; align-items: baseline; flex-wrap: wrap; gap: var(--s3) var(--s5);
  margin: var(--s2) auto 0; padding: calc(var(--s3) * 2) var(--s5); max-width: 30rem;
  border-radius: 12px; background: rgb(0 0 0 / 0.28); border: 1px solid rgb(255 255 255 / 0.12);
  font-variant-numeric: tabular-nums; font-weight: 700; line-height: var(--lh-snug); color: var(--on-night-muted);
}
.scoreboard b { color: var(--on-night); }
.scoreboard .eq { color: #ffd166; }
.scoreboard .final { color: #ffb38f; font-size: var(--t1); font-weight: 850; }

/* Chains sway briefly when the disc hits (Disc Arc into Chains). */
.chain { transform-box: fill-box; transform-origin: 50% 0; }
.sway .chain { animation: chain-sway 1.15s cubic-bezier(0.25, 0.7, 0.3, 1) var(--d, 0s) both; }
@keyframes chain-sway {
  0% { transform: skewX(0deg); }
  14% { transform: skewX(-7deg); }
  34% { transform: skewX(4.5deg); }
  56% { transform: skewX(-2.5deg); }
  78% { transform: skewX(1deg); }
  100% { transform: skewX(0deg); }
}
@media (prefers-reduced-motion: reduce) {
  .sway .chain { animation: none; }
}

/* ---------- Sections ---------- */
.section { padding-block: calc(var(--s6) * 2); }
.section + .section { border-top: 1px solid var(--line); }
.section-head { max-width: 46rem; margin-bottom: var(--s6); }
.section-head p { color: var(--muted); }
.page-head { padding-block: var(--s7) var(--s6); border-bottom: 1px solid var(--line); }
.page-head .lead { color: var(--muted); max-width: 46rem; }
.page-head .callout h2 { font-size: var(--t0); }
.prose { max-width: 46rem; }
.prose h2 { margin-top: var(--s7); }
.prose h3 { margin-top: var(--s6); }
.prose .grid { margin-bottom: var(--s5); }
.prose .btn-row { margin-top: var(--s7); }
.guide { padding-block: calc(var(--s8) / 2) calc(var(--s6) * 2); }

.grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s5); }
@media (min-width: 44rem) { .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: calc(var(--s7) / 2) var(--s6) calc(var(--s5) / 2); box-shadow: var(--shadow);
}
.card h3 { margin-bottom: var(--s3); }
/* Fixed numeral box: line-height 1, equal padding, centered. */
.card .step {
  display: inline-grid; place-items: center; min-inline-size: calc(1em + 2 * var(--s4)); padding: var(--s4);
  line-height: 1; border-radius: 50%; background: var(--ink); color: var(--bg); font-weight: 800; margin-bottom: var(--s4);
}
.callout {
  border-left: 5px solid var(--accent); background: var(--amber-soft);
  padding: var(--s5) var(--s5) var(--s1); border-radius: 0 var(--radius) var(--radius) 0; margin: var(--s6) 0;
}
.callout.green { border-left-color: var(--green); background: var(--green-soft); }
.callout h2, .callout h3 { margin-top: 0; }
.big-score { font-size: clamp(var(--t2), 9vw, var(--t3)); font-weight: 850; letter-spacing: -0.04em; font-variant-numeric: tabular-nums; line-height: var(--lh-tight); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; line-height: var(--lh-read); }
caption { text-align: left; font-weight: 800; padding: var(--s5) var(--s5) var(--s3); }
th, td { text-align: left; vertical-align: top; padding: var(--s4) var(--s5); border-top: 1px solid var(--line); }
thead th { background: var(--surface-2); border-top: 0; }
td.ref, th.ref { width: 1%; white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 700; }
td a { font-weight: 650; }
.note { margin-top: var(--s4); }
.result + .table-wrap { margin-top: var(--s6); }
.rule + .table-wrap { margin-top: var(--s5); }

/* ---------- Rulebook ---------- */
.rules-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s7); padding-block: calc(var(--s8) / 2) calc(var(--s6) * 2); }
@media (min-width: 64rem) { .rules-layout { grid-template-columns: 15.5rem minmax(0, 1fr); align-items: start; } }
.toc { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: calc(var(--s3) * 2) var(--s5); line-height: var(--lh-snug); }
.toc h2 { font-size: var(--t0); text-transform: uppercase; letter-spacing: 0.12em; margin: 0 0 var(--s3); }
.toc ol { list-style: none; padding: 0; margin: 0; }
@media (min-width: 30rem) and (max-width: 63.99rem) { .toc ol { columns: 2; column-gap: var(--s5); } .toc li { break-inside: avoid; } }
.toc li + li { margin-top: var(--s1); }
.toc a { display: block; padding: var(--s2) var(--s3); border-radius: 6px; color: var(--ink); text-decoration: none; }
.toc a:hover { background: var(--surface-2); }
.toc a span { color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 700; margin-right: var(--s3); }
@media (min-width: 64rem) { .toc { position: sticky; top: var(--s8); max-height: calc(100vh - var(--s9)); overflow-y: auto; } }

.rulebook > section { padding-top: calc(var(--s7) / 2); margin-bottom: var(--s7); }
.rulebook h2 { display: flex; gap: var(--s4); align-items: baseline; flex-wrap: wrap; border-bottom: 3px solid var(--ink); padding-bottom: var(--s3); }
.sec-no { font-variant-numeric: tabular-nums; color: var(--accent-ink); font-weight: 850; }
.sec-note { color: var(--muted); margin-top: calc(-1 * var(--s2)); }
.rule { padding: var(--s5) 0; border-top: 1px solid var(--line); }
.rulebook h2 + .sec-note + .rule, .rulebook h2 + .rule { border-top: 0; }
.rule h3 { margin: 0 0 var(--s3); }
.rule-no { font-weight: 850; font-variant-numeric: tabular-nums; color: var(--accent-ink); text-decoration: none; margin-right: var(--s3); white-space: nowrap; }
.rule-no:hover { text-decoration: underline; }
.rule > :last-child { margin-bottom: 0; }
.rule ol, .rule ul { padding-left: var(--s6); }
dl.terms { margin: 0; }
dl.terms dt { font-weight: 750; margin-top: var(--s4); }
dl.terms dd { margin: var(--s1) 0 0; color: var(--muted); }
.tags { display: flex; flex-wrap: wrap; gap: var(--s3); margin: var(--s4) 0 0; }
.tag { display: inline-block; font-weight: 750; line-height: var(--lh-snug); padding: var(--s1) var(--s4); border-radius: 999px; border: 1px solid var(--line); color: var(--muted); background: var(--surface); }
.tag.changed { border-color: var(--accent-ink); color: var(--accent-ink); }
.tag.new { border-color: var(--green); color: var(--green); }
.why { color: var(--muted); }
.why::before { content: "Why: "; font-weight: 750; color: var(--ink); }
.key { display: inline-flex; gap: var(--s4); flex-wrap: wrap; color: var(--muted); }

.compare { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s6); }

.sources li { margin-bottom: var(--s4); }
.disclaimer { color: var(--muted); }

/* ---------- Calculator ---------- */
.calc-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s6); padding-block: calc(var(--s8) / 2) calc(var(--s6) * 2); }
@media (min-width: 56rem) { .calc-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s6); box-shadow: var(--shadow); }
.field { margin-bottom: var(--s5); }
.field label { display: block; font-weight: 750; margin-bottom: var(--s3); }
.hint { display: block; color: var(--muted); line-height: var(--lh-read); margin-bottom: var(--s3); }
input[type="text"], input:not([type]), input[inputmode], select {
  width: 100%; font: inherit; line-height: var(--lh-snug); font-variant-numeric: tabular-nums;
  padding: var(--s4) var(--s5); border-radius: 10px; border: 2px solid var(--line); background: var(--bg); color: var(--ink);
}
input:focus-visible, select:focus-visible { border-color: var(--focus); outline-offset: 1px; }
input[readonly] { background: var(--surface-2); }
input[aria-invalid="true"] { border-color: #c62828; }
.error { color: #b3261e; font-weight: 650; line-height: var(--lh-read); margin: var(--s3) 0 0; }
@media (prefers-color-scheme: dark) { .error { color: #ff8a80; } input[aria-invalid="true"] { border-color: #ff8a80; } }

/* Press: quick squeeze, then the same spring as the score reveal on release. */
.btn-calc { width: 100%; min-height: 3.25rem; transition: transform var(--spring-dur) var(--spring); }
.btn-calc:active { transform: scale(0.95); transition-duration: 70ms; }
@media (prefers-reduced-motion: reduce) { .btn-calc, .btn-calc:active { transition: none; transform: none; } }

.per-hole { margin: 0 0 var(--s5); border: 1px dashed var(--line); border-radius: 10px; padding: calc(var(--s3) * 2) var(--s5); }
.per-hole summary { cursor: pointer; font-weight: 750; }
.per-hole .row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s5); margin: var(--s5) 0; }
.hole-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(3.4rem, 1fr)); gap: var(--s3); }
.hole label { display: block; font-weight: 750; color: var(--muted); text-align: center; }
.hole input { text-align: center; padding: var(--s3) var(--s2); }
.hole-sum { color: var(--muted); margin: var(--s4) 0 0; }

.result { text-align: center; padding: var(--s6); }
.result-label { text-transform: uppercase; letter-spacing: 0.14em; font-weight: 800; line-height: var(--lh-snug); color: var(--accent-ink); margin: 0; }
/* Fixed numeral box: line-height 1, equal padding, centered, numbers that don't jitter. */
.result-score {
  display: grid; place-items: center; padding: var(--s4); margin: var(--s2) 0 var(--s5);
  font-size: clamp(var(--t2), 14vw, var(--t3)); font-weight: 850; letter-spacing: -0.04em; line-height: 1;
  font-variant-numeric: lining-nums tabular-nums;
}
/* The spring beat: each new Speed Score springs in (overshoot, then settle at scale 1). */
.result-score.pop { animation: score-in var(--spring-dur) var(--spring) backwards; }
@keyframes score-in { from { transform: translateY(0.3em) scale(0.6); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .result-score.pop { animation: none; } }
.result-steps { text-align: left; max-width: 26rem; margin: 0 auto; padding-left: var(--s6); }

/* ---------- Scorecard ---------- */
.scorecard th, .scorecard td { text-align: center; padding: calc(var(--s5) / 2) var(--s3); font-variant-numeric: tabular-nums; }
.scorecard th:first-child, .scorecard td:first-child { text-align: left; white-space: nowrap; }

/* ---------- FAQ ---------- */
.faq { max-width: 50rem; padding-block: var(--s6) calc(var(--s6) * 2); }
.faq details { border-bottom: 1px solid var(--line); }
.faq summary {
  cursor: pointer; list-style: none; padding: var(--s5) var(--s7) var(--s5) 0; position: relative;
  font-weight: 750; line-height: var(--lh-snug); text-wrap: balance;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+"; position: absolute; right: var(--s2); top: var(--s4); font-size: var(--t1); font-weight: 500; color: var(--accent-ink);
}
.faq details[open] summary::after { content: "–"; }
.faq .answer { padding-bottom: var(--s5); }
.faq h2 { margin-top: var(--s7); font-size: var(--t1); }

/* ---------- Footer ---------- */
.site-footer { background: var(--surface-2); border-top: 1px solid var(--line); padding-block: calc(var(--s8) / 2); color: var(--muted); }
.site-footer .wrap { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s5); }
@media (min-width: 48rem) { .site-footer .wrap { grid-template-columns: 2fr 1fr; } }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer a { color: var(--ink); }

/* ---------- Print (rulebook) ---------- */
@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #f2f2f2; --ink: #000; --muted: #333; --line: #bbb; --accent-ink: #000; }
  .site-header, .site-footer, .toc, .skip, .no-print { display: none !important; }
  .rule { break-inside: avoid; }
  a { color: #000; text-decoration: none; }
}
