/* ============================================================
   jarrodcrano.com — design tokens
   Light/dark values swap here; everything else uses the roles.
   ============================================================ */
:root {
  --page:           #f9f9f7;
  --surface:        #fcfcfb;
  --ink:            #0b0b0b;
  --ink-2:          #52514e;
  --muted:          #898781;
  --grid:           #e1e0d9;
  --baseline:       #c3c2b7;
  --border:         rgba(11, 11, 11, 0.10);
  --series:         #2a78d6;   /* single-series blue, validated light */
  --series-soft:    rgba(42, 120, 214, 0.12);
  /* year heatmap — sequential blue, low → high (light-mode ordinal ramp) */
  --cell-0:         #f0efec;
  --cell-1:         #86b6ef;
  --cell-2:         #5598e7;
  --cell-3:         #2a78d6;
  --cell-4:         #1c5cab;
  --cell-5:         #104281;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page:         #0d0d0d;
    --surface:      #1a1a19;
    --ink:          #ffffff;
    --ink-2:        #c3c2b7;
    --muted:        #898781;
    --grid:         #2c2c2a;
    --baseline:     #383835;
    --border:       rgba(255, 255, 255, 0.10);
    --series:       #3987e5;   /* validated dark step */
    --series-soft:  rgba(57, 135, 229, 0.18);
    /* dark ramp: near-zero recedes toward the dark surface */
    --cell-0:       #262624;
    --cell-1:       #184f95;
    --cell-2:       #256abf;
    --cell-3:       #3987e5;
    --cell-4:       #6da7ec;
    --cell-5:       #9ec5f4;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 24px;
}

a { color: var(--series); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.2; }

/* ---------------- header ---------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.site-header nav {
  max-width: 880px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.wordmark {
  font-weight: 700;
  font-size: 18px;
  color: var(--ink);
  letter-spacing: 0.02em;
}
.nav-links { display: flex; gap: 20px; }
.nav-links a { color: var(--ink-2); font-size: 15px; }
.nav-links a:hover { color: var(--ink); text-decoration: none; }

/* ---------------- hero ---------------- */
.hero { padding: 88px 0 32px; }
.hero h1 {
  font-size: clamp(36px, 6vw, 56px);
  margin: 0 0 12px;
  letter-spacing: -0.02em;
}
.lede {
  font-size: 20px;
  color: var(--ink-2);
  max-width: 560px;
  margin: 0;
}

/* ---------------- sections ---------------- */
section { padding: 48px 0; }
section h2 { font-size: 28px; margin: 0 0 6px; letter-spacing: -0.01em; }
.section-note { color: var(--muted); margin: 0 0 28px; font-size: 15px; }

/* ---------------- life resume ---------------- */
.resume-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}
.resume-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
}
.resume-card h3 {
  margin: 0 0 10px;
  font-size: 16px;
}
.resume-card ul { margin: 0; padding-left: 18px; }
.resume-card li { margin: 6px 0; font-size: 15px; color: var(--ink-2); }
.resume-card li strong { color: var(--ink); font-weight: 600; }
.resume-card li.todo {
  color: var(--muted);
  list-style: none;
  margin-left: -18px;
  border: 1px dashed var(--baseline);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 13.5px;
}

/* ---------------- stat tiles ---------------- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}
.stat-tile .label { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.stat-tile .value { font-size: 30px; font-weight: 600; letter-spacing: -0.01em; }
.stat-tile .value small { font-size: 15px; font-weight: 500; color: var(--ink-2); }

/* ---------------- chart cards ---------------- */
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px 14px;
  margin-bottom: 20px;
}
.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.chart-title { font-size: 15px; font-weight: 600; }
.range-buttons { display: flex; gap: 4px; }
.range-buttons button {
  font: inherit;
  font-size: 13px;
  padding: 4px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
}
.range-buttons button:hover { background: var(--series-soft); }
.range-buttons button.active {
  background: var(--series-soft);
  color: var(--ink);
  border-color: var(--border);
  font-weight: 600;
}
.chart-holder svg { width: 100%; height: auto; display: block; }

/* bar chart internals (SVG classes) */
.bar { fill: var(--series); }
.hit { fill: transparent; }
.bar.hover { fill: color-mix(in srgb, var(--series) 82%, var(--ink)); }
.gridline { stroke: var(--grid); stroke-width: 1; }
.axis-baseline { stroke: var(--baseline); stroke-width: 1; }
.tick-label, .axis-label { fill: var(--muted); font-size: 11px; font-family: inherit; font-variant-numeric: tabular-nums; }
.cap-label { fill: var(--ink-2); font-size: 11px; font-family: inherit; font-variant-numeric: tabular-nums; }

/* line chart internals (SVG classes) */
.line-path { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.line-area { fill: var(--series); opacity: 0.1; }
.end-dot { fill: var(--series); }
.end-dot-ring { fill: var(--surface); }
.end-label { fill: var(--ink); font-size: 12px; font-weight: 600; font-family: inherit; }
.crosshair { stroke: var(--baseline); stroke-width: 1; }

/* ---------------- heatmap ---------------- */
.heatmap-scroll { overflow-x: auto; padding-bottom: 4px; }
/* scale to the card width; min-width keeps cells readable on phones (scrolls there) */
.heatmap-scroll svg { display: block; width: 100%; min-width: 640px; height: auto; }
.hm-cell.b0 { fill: var(--cell-0); }
.hm-cell.b1 { fill: var(--cell-1); }
.hm-cell.b2 { fill: var(--cell-2); }
.hm-cell.b3 { fill: var(--cell-3); }
.hm-cell.b4 { fill: var(--cell-4); }
.hm-cell.b5 { fill: var(--cell-5); }
.hm-label { fill: var(--muted); font-size: 10px; font-family: inherit; }
.heatmap-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}
.heatmap-legend .swatch {
  width: 11px; height: 11px; border-radius: 2px; display: inline-block;
}
.swatch.b0 { background: var(--cell-0); }
.swatch.b1 { background: var(--cell-1); }
.swatch.b2 { background: var(--cell-2); }
.swatch.b3 { background: var(--cell-3); }
.swatch.b4 { background: var(--cell-4); }
.swatch.b5 { background: var(--cell-5); }

/* ---------------- racing: states map + PBs ---------------- */
h2.subsection { margin-top: 48px; font-size: 28px; }
#states-map { padding: 4px 0; }
#states-map svg { width: 100%; height: auto; display: block; }
#states-map g.state path,
#states-map circle.dc { fill: var(--cell-0); transition: fill 0.1s ease; }
#states-map g.state path.ran { fill: var(--series); }
#states-map g.state path:hover { fill: color-mix(in srgb, var(--cell-0) 80%, var(--ink)); }
#states-map g.state path.ran:hover { fill: color-mix(in srgb, var(--series) 82%, var(--ink)); }
#states-map g.borders path { stroke: var(--surface); stroke-width: 1; fill: none; pointer-events: none; }
#states-map .separator1 { stroke: var(--baseline); stroke-width: 1; fill: none; }
#states-map circle.dccircle { display: none; }

.pb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.pb-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.pb-dist { font-size: 12.5px; color: var(--muted); }
.pb-time { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; margin: 2px 0; }
.pb-race { font-size: 12px; color: var(--ink-2); }

.race-note { color: var(--muted); font-size: 12.5px; }
.race-pb {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--series);
  border: 1px solid var(--series);
  border-radius: 5px;
  padding: 0 5px;
  margin-left: 6px;
  vertical-align: 1px;
}

/* ---------------- data table ---------------- */
.data-table { margin-top: 4px; }
.data-table summary {
  cursor: pointer;
  color: var(--ink-2);
  font-size: 14px;
}
.data-table table {
  margin-top: 12px;
  border-collapse: collapse;
  min-width: 260px;
}
.data-table th, .data-table td {
  text-align: left;
  padding: 5px 18px 5px 0;
  border-bottom: 1px solid var(--grid);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.data-table th { color: var(--muted); font-weight: 500; }

/* ---------------- tooltip ---------------- */
.tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--ink);
  color: var(--page);
  font-size: 12.5px;
  line-height: 1.35;
  padding: 6px 10px;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.08s ease;
  z-index: 50;
  white-space: nowrap;
}
.tooltip.show { opacity: 1; }
.tooltip .tt-value { font-weight: 600; }

/* ---------------- newsletter ---------------- */
.newsletter-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px;
  text-align: center;
}
.newsletter-card h2 { margin-top: 0; }
.newsletter-card p { color: var(--ink-2); max-width: 460px; margin: 8px auto 20px; }
.newsletter-form {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.newsletter-form input[type="email"] {
  font: inherit;
  font-size: 15px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--baseline);
  background: var(--page);
  color: var(--ink);
  width: min(320px, 100%);
}
.newsletter-form input[type="email"]:focus {
  outline: 2px solid var(--series);
  outline-offset: 1px;
  border-color: transparent;
}
.newsletter-form button {
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 10px 22px;
  border-radius: 10px;
  border: none;
  background: var(--series);
  color: #fff;
  cursor: pointer;
}
.newsletter-form button:hover { filter: brightness(1.08); }
.newsletter-form button:disabled { opacity: 0.6; cursor: default; }
.newsletter-status { min-height: 1.4em; margin: 14px 0 0; font-size: 15px; color: var(--ink); font-weight: 500; }
.newsletter-status.error { color: var(--muted); font-weight: 400; }

/* ---------------- footer ---------------- */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 48px;
  padding: 28px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
