/* ═══════════════════════════════════════════════════════════════════════
   claude-resets.com

   Three themes: light, dark, claude (Claude's warm cream + coral).

   --series-* are DATA MARK colors. Each set is validated against the
   surface its theme actually renders on (lightness band, chroma floor,
   protan/deutan separation, normal-vision floor, contrast). Do not
   hand-edit them without re-running the palette validator.

   --accent is CHROME ONLY (wordmark, hero digit, tags, rules). Claude's
   brand coral #d97757 lives here because it measures 2.96:1 on cream and
   sits outside the dark lightness band (L 0.672) — fine for decoration and
   large text, not legal for data marks. That split is deliberate.
   ═══════════════════════════════════════════════════════════════════════ */

/* Light — Claude's warm cream plane and coral accent. Surface #faf9f5;
   the light series steps are validated against it (all six checks pass). */
:root {
  color-scheme: light;

  --plane:          #f0eee6;
  --surface:        #faf9f5;
  --surface-sunken: #eae7dc;
  --ink:            #1f1e1d;
  --ink-2:          #575653;
  --ink-muted:      #85837c;
  --grid:           #e0ddd1;
  --axis:           #ccc9bb;
  --hairline:       rgba(31, 30, 29, 0.12);

  --accent:         #d97757;
  --accent-soft:    rgba(217, 119, 87, 0.16);

  --series-claude:  #eb6834;
  --series-codex:   #2a78d6;
  --series-claude-soft: rgba(235, 104, 52, 0.13);
  --series-codex-soft:  rgba(42, 120, 214, 0.13);

  --radius: 14px;
  --radius-sm: 8px;
  --wrap: 1080px;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* Light is the default and <html> always carries a data-theme, so there is
   deliberately no prefers-color-scheme block — the OS setting does not pick
   the theme. Dark is opt-in via the switcher and persists in localStorage. */

/* Dark — surface #1a1a19 */
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane:          #0d0d0d;
  --surface:        #1a1a19;
  --surface-sunken: #131312;
  --ink:            #ffffff;
  --ink-2:          #c3c2b7;
  --ink-muted:      #898781;
  --grid:           #2c2c2a;
  --axis:           #383835;
  --hairline:       rgba(255, 255, 255, 0.10);
  --accent:         #d95926;
  --accent-soft:    rgba(217, 89, 38, 0.18);
  --series-claude:  #d95926;
  --series-codex:   #3987e5;
  --series-claude-soft: rgba(217, 89, 38, 0.18);
  --series-codex-soft:  rgba(57, 135, 229, 0.18);
}

/* Explicit light stamp — must beat an OS dark preference. */
:root[data-theme="light"] {
  color-scheme: light;
  --plane:          #f0eee6;
  --surface:        #faf9f5;
  --surface-sunken: #eae7dc;
  --ink:            #1f1e1d;
  --ink-2:          #575653;
  --ink-muted:      #85837c;
  --grid:           #e0ddd1;
  --axis:           #ccc9bb;
  --hairline:       rgba(31, 30, 29, 0.12);
  --accent:         #d97757;
  --accent-soft:    rgba(217, 119, 87, 0.16);
  --series-claude:  #eb6834;
  --series-codex:   #2a78d6;
  --series-claude-soft: rgba(235, 104, 52, 0.13);
  --series-codex-soft:  rgba(42, 120, 214, 0.13);
}

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

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

a { color: inherit; text-decoration-color: var(--axis); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }

:focus-visible {
  outline: 2px solid var(--series-codex);
  outline-offset: 2px;
  border-radius: 4px;
}

.wrap { max-width: var(--wrap); margin-inline: auto; padding-inline: 20px; }

.skip {
  position: absolute; left: -9999px;
  background: var(--surface); padding: 10px 16px; border-radius: var(--radius-sm);
}
.skip:focus { left: 12px; top: 12px; z-index: 20; }

/* ── Top bar ──────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--plane) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--hairline);
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; min-height: 60px;
}
.wordmark {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 650; letter-spacing: -0.015em; text-decoration: none; font-size: 1.02rem;
}
.wordmark .glyph { color: var(--accent); font-size: 1.25rem; line-height: 1; }
.wordmark .tld { color: var(--ink-muted); font-weight: 500; }
.topnav { display: flex; align-items: center; gap: 4px; }
.topnav a {
  padding: 7px 11px; border-radius: var(--radius-sm);
  font-size: 0.88rem; color: var(--ink-2); text-decoration: none;
}
.topnav a:hover { background: var(--surface); color: var(--ink); }
.topnav .nav-out { color: var(--series-codex); }
.chart-empty {
  margin: 0; padding: 46px 0; text-align: center;
  color: var(--ink-muted); font-size: 0.9rem;
}
.scope-statement {
  margin-top: 10px; padding-left: 12px;
  border-left: 2px solid var(--accent-soft);
  font-size: 0.9rem; color: var(--ink-muted);
}
.theme-switch { margin-left: 6px; }
.theme-switch button { padding: 5px 9px; font-size: 0.8rem; }
.sb-key { margin: -8px 0 22px; }

/* ── Hero ─────────────────────────────────────────────────────────────── */
.hero { padding: 68px 0 44px; text-align: center; }
.eyebrow {
  margin: 0 0 18px; font-size: 0.8rem; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--ink-muted);
}
.counter {
  display: flex; justify-content: center; align-items: baseline;
  flex-wrap: wrap; gap: 0 16px;
}
.counter-loading {
  color: var(--ink-muted); font-weight: 400;
  font-size: clamp(2rem, 8vw, 3rem);
}
/* Deterministic pre-render fallback: JS replaces #counter with the live day
   figure on load, so this shows only to crawlers and for the first paint. It
   states the last reset DATE — a stable fact — rather than a day count that
   would drift from the built HTML and make every rebuild a spurious diff. */
.counter-preview {
  color: var(--ink-2); font-weight: 600;
  font-size: clamp(1.5rem, 5.5vw, 2.4rem);
}
.counter-preview time { color: var(--accent); white-space: nowrap; }
.days-figure {
  font-size: clamp(3.4rem, 12vw, 6.5rem);
  font-weight: 800; letter-spacing: -0.045em; line-height: 0.9;
  color: var(--accent);
  /* proportional figures — tabular-nums makes a display numeral look loose */
}
.days-unit {
  font-size: clamp(1rem, 3vw, 1.6rem);
  font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-2);
}
.hero-sub {
  margin: 26px auto 0; max-width: 46ch;
  color: var(--ink-2); font-size: 1.02rem;
}
.hero-meta { margin: 12px 0 0; font-size: 0.86rem; color: var(--ink-muted); }
.hero-meta .dot { margin-inline: 6px; }

/* ── Bands & sections ─────────────────────────────────────────────────── */
.band { padding: 40px 0; }
.section-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; flex-wrap: wrap; margin-bottom: 22px;
}
.section-head h2 {
  margin: 0 0 8px; font-size: 1.5rem; letter-spacing: -0.02em; font-weight: 650;
}
.lede { margin: 0; max-width: 62ch; color: var(--ink-2); font-size: 0.95rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 20px;
}

/* ── Stat tiles ───────────────────────────────────────────────────────── */
.tiles {
  display: grid; gap: 12px;
  /* min(190px, 100%) so the track can shrink below 190 on a narrow phone
     instead of forcing a column wider than the viewport (horizontal scroll). */
  grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr));
}
.tile {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 18px 18px 16px;
}
.tile dt {
  font-size: 0.78rem; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--ink-muted); margin-bottom: 10px;
}
.tile dd {
  margin: 0; font-size: 2rem; font-weight: 680; letter-spacing: -0.03em;
  line-height: 1.1;
}
.tile dd small {
  font-size: 0.42em; font-weight: 600; color: var(--ink-muted);
  margin-left: 5px; letter-spacing: 0;
}
.tile p { margin: 8px 0 0; font-size: 0.82rem; color: var(--ink-muted); }

/* ── Filter bar ───────────────────────────────────────────────────────── */
.filterbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.filterbar-label {
  font-size: 0.78rem; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--ink-muted);
}
.segmented {
  display: inline-flex; background: var(--surface-sunken);
  border: 1px solid var(--hairline); border-radius: 10px; padding: 3px; gap: 3px;
}
.segmented button {
  font: inherit; font-size: 0.85rem; color: var(--ink-2);
  background: none; border: 0; cursor: pointer;
  padding: 6px 13px; border-radius: 7px;
}
.segmented button:hover { color: var(--ink); }
.segmented button.is-on {
  background: var(--surface); color: var(--ink); font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.14);
}
/* Always its own row. Inline would put the short notes beside the control and
   the long "All time" one underneath, so the layout jumped between tabs. */
.filterbar-note {
  flex-basis: 100%; margin: 0;
  font-size: 0.82rem; color: var(--ink-muted);
}

/* ── Scoreboard ───────────────────────────────────────────────────────── */
.scoreboard {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 22px;
}
.sb-row {
  display: grid; grid-template-columns: 1fr minmax(96px, 0.5fr) minmax(96px, 0.5fr);
  gap: 12px; align-items: center;
  padding: 13px 18px; border-top: 1px solid var(--hairline);
}
.sb-row:first-child { border-top: 0; }
.sb-head {
  background: var(--surface-sunken);
  font-size: 0.78rem; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--ink-muted);
}
.sb-head .sb-val { display: flex; align-items: center; justify-content: flex-end; gap: 7px; }
/* Keyed off data-series rather than an inline style="--c:…". The inline form
   worked, but it forced 'unsafe-inline' into style-src for the whole site to
   colour four small squares — a bad trade. There are exactly two series, so
   they can just be named here. */
.swatch {
  width: 10px; height: 10px; border-radius: 3px; flex: none;
  background: var(--ink-muted);
}
.swatch[data-series="claude"] { background: var(--series-claude); }
.swatch[data-series="codex"] { background: var(--series-codex); }
.sb-label { font-size: 0.92rem; }
.sb-label small { display: block; color: var(--ink-muted); font-size: 0.8rem; }
.sb-val {
  text-align: right; font-size: 1.05rem; font-weight: 620;
  font-variant-numeric: tabular-nums;
}
.sb-val .sb-unit { font-size: 0.72rem; color: var(--ink-muted); font-weight: 500; margin-left: 3px; }
.sb-val.is-lead::after {
  content: "▲"; font-size: 0.6rem; margin-left: 6px;
  color: var(--ink-muted); vertical-align: 2px;
}

/* ── Charts ───────────────────────────────────────────────────────────── */
.chart-grid {
  display: grid; gap: 16px;
  /* min(340px, 100%): two columns where there is room, one that fits the
     viewport where there is not — never a 340px track on a 320px screen. */
  grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr));
}
.chart-card figcaption { margin-bottom: 14px; }
.chart-card h3 { margin: 0 0 5px; font-size: 1.02rem; font-weight: 620; }
.chart-card figcaption p { margin: 0; font-size: 0.84rem; color: var(--ink-muted); }

.legend { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 10px; }
.legend-item {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 0.84rem; color: var(--ink-2);
}

.plot { position: relative; width: 100%; }
.plot svg { display: block; width: 100%; height: auto; overflow: visible; }

.grid-line { stroke: var(--grid); stroke-width: 1; }
.axis-line { stroke: var(--axis); stroke-width: 1; }
.tick-text {
  fill: var(--ink-muted); font-size: 11px;
  font-family: var(--sans); font-variant-numeric: tabular-nums;
}
.series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.endpoint-label { font-size: 12px; font-weight: 620; font-family: var(--sans); }
.bar-mark { rx: 4; }
.lane-label {
  fill: var(--ink-2); font-size: 12px; font-weight: 600; font-family: var(--sans);
}
.lane-rule { stroke: var(--grid); stroke-width: 1; }
.lane-dot { stroke: var(--surface); stroke-width: 2; cursor: pointer; }
.hit { fill: transparent; cursor: pointer; }
.crosshair { stroke: var(--axis); stroke-width: 1; }

.tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--hairline); border-radius: 10px;
  padding: 9px 11px; font-size: 0.82rem; line-height: 1.45;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.24);
  opacity: 0; transition: opacity 0.1s ease; max-width: 240px;
}
.tip[data-show="1"] { opacity: 1; }
.tip b { font-variant-numeric: tabular-nums; }
.tip-row { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.tip-date { color: var(--ink-muted); margin-bottom: 5px; }

/* ── Table view ───────────────────────────────────────────────────────── */
.tableview { margin-top: 18px; }
.tableview summary {
  cursor: pointer; font-size: 0.88rem; color: var(--ink-2);
  padding: 9px 0; list-style-position: inside;
}
.tableview summary:hover { color: var(--ink); }
.tablescroll { overflow-x: auto; margin-top: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 0.86rem; }
caption {
  text-align: left; color: var(--ink-muted); font-size: 0.82rem;
  padding: 10px 0 6px;
}
th, td {
  text-align: right; padding: 8px 12px;
  border-bottom: 1px solid var(--hairline); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
th:first-child, td:first-child { text-align: left; font-variant-numeric: normal; }
thead th { color: var(--ink-muted); font-weight: 600; }

/* ── Archive ──────────────────────────────────────────────────────────── */
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 0.87rem; color: var(--ink-2); cursor: pointer; }
.switch input { accent-color: var(--accent); width: 15px; height: 15px; }

.archive { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.entry {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 16px 18px;
  border-left: 3px solid var(--accent);
}
.entry[data-kind="policy"] { border-left-color: var(--axis); }
.entry-top {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 7px;
}
.entry-date { font-size: 0.88rem; font-weight: 620; font-variant-numeric: tabular-nums; }
.entry-rel { font-size: 0.82rem; color: var(--ink-muted); }
.tag {
  font-size: 0.7rem; letter-spacing: 0.05em; text-transform: uppercase;
  font-weight: 650; padding: 3px 8px; border-radius: 999px;
  border: 1px solid var(--hairline); color: var(--ink-2);
}
.tag[data-kind="reset"] { color: var(--accent); border-color: var(--accent-soft); background: var(--accent-soft); }
.entry-note { margin: 0 0 10px; font-size: 0.93rem; color: var(--ink-2); }
.entry-foot { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.82rem; color: var(--ink-muted); }
.entry-gap { font-variant-numeric: tabular-nums; }

/* ── Footer ───────────────────────────────────────────────────────────── */
.foot {
  border-top: 1px solid var(--hairline);
  margin-top: 30px; padding: 34px 0 56px;
  color: var(--ink-2); font-size: 0.87rem;
}
.foot p { margin: 0 0 12px; max-width: 74ch; }
.foot-caveat { color: var(--ink-muted); font-size: 0.82rem; }
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.92em; background: var(--surface-sunken);
  padding: 1px 5px; border-radius: 5px;
}

@media (max-width: 620px) {
  .hero { padding: 44px 0 32px; }
  .band { padding: 30px 0; }
  .sb-row { grid-template-columns: 1fr 72px 72px; gap: 8px; padding: 12px 14px; }
  .sb-val { font-size: 0.95rem; }
  .section-head h2 { font-size: 1.3rem; }

  /* Stack the bar: wordmark on its own row, then the section links + theme
     toggle below. The wordmark plus the full nav do not fit one row much below
     this width, and the old rule at ≤620 hid every link — stranding phone
     visitors with no way to reach the sections. Here the in-page anchors stay;
     only the two outbound links (codex-resets, Source) drop. The nav wraps, so
     the theme toggle falls to its own line rather than overflowing when the row
     runs out of room (≈340px and below). */
  .topbar-inner { flex-wrap: wrap; row-gap: 8px; min-height: 0; padding: 9px 0; }
  .wordmark { font-size: 0.98rem; }
  .topnav {
    width: 100%; flex-wrap: wrap; gap: 6px 3px; align-items: center;
  }
  .topnav a.nav-ext { display: none; }
  .topnav a { padding: 6px 9px; font-size: 0.85rem; }
  .theme-switch { margin-left: auto; }   /* toggle to the right; wraps if tight */
}

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

@media print {
  .topbar, .tableview summary { display: none; }
  .tableview[open] { display: block; }
}
