/*
 * Styling for Buyable's own pages.
 *
 * A tool that measures whether pages work for assistive technology cannot ship a UI
 * that does not. Rules that are load-bearing rather than decorative:
 *
 *  - Every state that uses colour also carries a word. `.pill` has text, the diff has
 *    visually hidden "added" and "removed" labels. Nothing is signalled by hue alone.
 *  - Focus is always visible and is never removed, including on dark backgrounds.
 *  - Body text sits at 4.5:1 or better against its background, and the large headline
 *    figure at 3:1 or better.
 *  - Nothing depends on hover. Every affordance is reachable by keyboard.
 *  - Layout reflows to 320px without horizontal scrolling.
 *  - prefers-reduced-motion is respected, which is easy here because there is none.
 */

/* ---------------------------------------------------------------------------
   Design tokens.

   One scale for space, one for type, one for colour, and everything is built from
   them. The point is not tidiness: it is that a page assembled from a fixed set of
   steps looks deliberate, and a page where every value was chosen in the moment looks
   like what it is.

   Colour carries no meaning on its own anywhere in this product. Every state that
   uses it also carries a word, because a tool measuring whether pages work without
   sight cannot ship one that does not.
   --------------------------------------------------------------------------- */

:root {
  /* Space, on a 4px base. Nothing is allowed a value outside this. */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;
  --s8: 72px;
  --s9: 112px;

  --font-sans: "Inter var", "Inter", system-ui, -apple-system, "Segoe UI", Roboto,
    Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, "Cascadia Mono",
    Consolas, monospace;

  /* Ink. Blue cast rather than neutral grey, which reads as considered next to a
     blue accent where a pure grey reads as unset. */
  --ink: #0d1117;
  --ink-soft: #313b49;
  --muted: #5b6676;
  --line: #e3e8ef;
  --line-strong: #cfd6e0;
  --bg: #ffffff;
  --panel: #f7f9fc;
  --panel-2: #eef2f8;

  --accent: #1d43c8;
  --accent-hover: #16349d;
  --accent-soft: #e8edfd;
  --accent-ink: #ffffff;

  --ok-ink: #0a5c39;
  --ok-bg: #e2f5ec;
  --bad-ink: #9a2320;
  --bad-bg: #fdecea;
  --mixed-ink: #7a4d05;
  --mixed-bg: #fdf3e2;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;

  /* Depth, used sparingly. Two levels is enough for a page with no overlays. */
  --shadow-sm: 0 1px 2px rgba(13, 17, 23, 0.05), 0 1px 3px rgba(13, 17, 23, 0.04);
  --shadow-md: 0 4px 12px rgba(13, 17, 23, 0.06), 0 12px 32px rgba(13, 17, 23, 0.07);

  --measure: 68ch;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #eef2f8;
    --ink-soft: #c3ccd9;
    --muted: #94a1b3;
    --line: #232a35;
    --line-strong: #323b49;
    --bg: #0b0e14;
    --panel: #121721;
    --panel-2: #1a2130;

    --accent: #8fb0ff;
    --accent-hover: #adc4ff;
    --accent-soft: #17203a;
    --accent-ink: #0b0e14;

    --ok-ink: #7fe0ae;
    --ok-bg: #0f2a1e;
    --bad-ink: #ffa8a3;
    --bad-bg: #2d1514;
    --mixed-ink: #f2c777;
    --mixed-bg: #2b2112;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45), 0 12px 32px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "cv05" 1, "ss01" 1;
}

.wrap { max-width: 860px; margin: 0 auto; padding: 0 var(--s5); }
/*
 * Breakout.
 *
 * The run view is the widest thing on the site: three lanes do not fit in a column
 * sized for prose, and squeezing them wrapped the third onto its own row with a gap
 * beside it that read as a broken layout.
 *
 * Widening the whole section was the first attempt and it was worse. Every other
 * section's text starts on the same left edge, and one section starting ninety pixels
 * further left is the sort of thing nobody can name and everybody notices. So the
 * prose keeps the shared column and only the lanes break out of it, centred on the
 * viewport rather than on the parent so the parent's width is irrelevant.
 */
/* Selected through the parent so a later `margin` shorthand on the element itself
   cannot quietly reset the margin-left this depends on, which is what happened the
   first time and left the whole run view hanging off the left of the page. */
.wrap > .breakout {
  width: min(1180px, calc(100vw - 2 * var(--s5)));
  margin-left: 50%;
  transform: translateX(-50%);
}
@media (max-width: 640px) {
  .wrap > .breakout { width: auto; margin-left: 0; transform: none; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 var(--s4); }
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.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;
}

.skip-link {
  position: absolute;
  left: -9999px;
  background: var(--ink);
  color: var(--bg);
  padding: var(--s3) var(--s4);
  border-radius: 0 0 var(--radius-sm) 0;
  font-weight: 600;
  z-index: 20;
}
.skip-link:focus { left: 0; top: 0; }

/* ---------------------------------------------------------------------------
   Header.

   Sticky, because the run view is long and losing the way back to the top of a page
   you are three minutes into is a small, constant annoyance.
   --------------------------------------------------------------------------- */
header.site {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  padding: var(--s3) 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
}
header.site .wrap {
  display: flex;
  align-items: center;
  gap: var(--s4);
  flex-wrap: wrap;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-weight: 680;
  font-size: 18px;
  letter-spacing: -0.021em;
  color: var(--ink);
  text-decoration: none;
}
/*
 * The mark.
 *
 * Two customers set out on the same journey. The lower path runs the whole way and
 * arrives; the upper one stops at a barrier it cannot get past. That gap is the
 * product, so it is the mark. `currentColor` on the tile means it inherits the accent
 * and works on either theme without a second file.
 */
.brand .mark { width: 22px; height: 22px; flex: none; color: var(--accent); display: block; }
.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  padding-left: var(--s4);
  border-left: 1px solid var(--line);
}
@media (max-width: 720px) {
  .tagline { display: none; }
}

nav.site-nav { margin-left: auto; display: flex; align-items: center; gap: var(--s5); }
nav.site-nav a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 520;
}
nav.site-nav a:hover { color: var(--accent); text-decoration: underline; }
@media (max-width: 640px) {
  nav.site-nav { gap: var(--s4); width: 100%; }
  nav.site-nav a { font-size: 14px; }
}

main { padding: var(--s7) 0 var(--s9); }

.eyebrow {
  margin: 0 0 var(--s3);
  color: var(--accent);
  font-size: 12px;
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(30px, 4.4vw, 40px);
  line-height: 1.14;
  letter-spacing: -0.032em;
  font-weight: 700;
  margin: 0 0 var(--s5);
}
h2 {
  font-size: clamp(22px, 2.6vw, 26px);
  line-height: 1.25;
  letter-spacing: -0.024em;
  font-weight: 660;
  margin: var(--s8) 0 var(--s4);
}
h3 { font-size: 17.5px; letter-spacing: -0.012em; font-weight: 640; margin: 0 0 var(--s3); }

p { max-width: var(--measure); }

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); text-decoration-thickness: 2px; }

dl.subject, dl.facts { display: grid; grid-template-columns: minmax(140px, auto) 1fr; gap: 6px 20px; margin: 0 0 8px; }
dl.subject dt, dl.facts dt { color: var(--muted); font-size: 14px; }
dl.subject dd, dl.facts dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 520px) {
  dl.subject, dl.facts { grid-template-columns: 1fr; gap: 2px 0; }
  dl.subject dd, dl.facts dd { margin-bottom: 10px; }
}

.headline {
  display: flex;
  align-items: baseline;
  gap: var(--s4);
  flex-wrap: wrap;
  margin: var(--s5) 0 var(--s5);
  padding: var(--s5) var(--s5);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.headline .figure { font-size: clamp(40px, 8vw, 56px); font-weight: 700; letter-spacing: -0.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.headline .label { color: var(--muted); font-size: 15px; }

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 var(--s4);
  font-size: 15px;
}
caption { text-align: left; color: var(--muted); font-size: 14px; padding-bottom: var(--s3); }
th, td {
  text-align: left;
  padding: var(--s3) var(--s3);
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
thead th {
  font-size: 12px;
  color: var(--muted);
  font-weight: 620;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-bottom-color: var(--line-strong);
}
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
th[scope="row"] { font-weight: 620; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.blurb { display: block; font-weight: 400; color: var(--muted); font-size: 13px; margin-top: 2px; }

.pill {
  display: inline-block;
  padding: 3px var(--s3);
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 620;
  white-space: nowrap;
  border: 1px solid transparent;
}
.pill.ok { background: var(--ok-bg); color: var(--ok-ink); }
.pill.bad { background: var(--bad-bg); color: var(--bad-ink); }
.pill.mixed { background: var(--mixed-bg); color: var(--mixed-ink); }

.control-note {
  background: var(--panel);
  border-left: 3px solid var(--accent);
  padding: var(--s4) var(--s5);
  border-radius: 0 var(--radius) var(--radius) 0;
  max-width: var(--measure);
}
.control-note p { margin-top: 0; }
.control-note p:last-child { margin-bottom: 0; }

.finding {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--s5);
  margin-bottom: var(--s4);
  box-shadow: var(--shadow-sm);
}
.finding blockquote { margin: 14px 0 0; padding: 12px 16px; background: var(--panel); border-radius: 8px; }
.finding blockquote p { margin: 0 0 8px; }
.finding blockquote footer { color: var(--muted); font-size: 13px; }
.none { color: var(--muted); }

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--panel-2);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  overflow-wrap: anywhere;
}
.filepath code { background: none; padding: 0; color: var(--muted); }

pre.diff {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s4) var(--s5);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  box-shadow: var(--shadow-sm);
}
pre.diff code { background: none; padding: 0; }
pre.diff .line { display: block; white-space: pre; }
pre.diff .add { background: var(--ok-bg); color: var(--ok-ink); }
pre.diff .del { background: var(--bad-bg); color: var(--bad-ink); }
pre.diff .hunk { color: var(--muted); }

.proof { padding: 14px 18px; border-radius: var(--radius); }
.proof.ok { background: var(--ok-bg); color: var(--ok-ink); }
.proof.bad { background: var(--mixed-bg); color: var(--mixed-ink); }
.proof strong { font-variant-numeric: tabular-nums; }

.fineprint { color: var(--muted); font-size: 13px; }

footer.site {
  border-top: 1px solid var(--line);
  margin-top: var(--s8);
  padding: var(--s6) 0 var(--s8);
  color: var(--muted);
  font-size: 14px;
}

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

/* Announcement transcript. A silent stop is marked with a word, never colour alone. */
tr.silent td { background: var(--bad-bg); }
tr.silent .warn { color: var(--bad-ink); }
