/* sweedworks.com — no webfonts, no third-party requests, no tracking. */

:root {
  --bg: #fbfaf8;
  --bg-sunk: #f2efea;
  --panel: #ffffff;
  --ink: #16171b;
  --ink-soft: #4a4d57;
  --ink-faint: #7c8089;
  --rule: #e2ded7;
  --accent: #c02c47;
  --accent-soft: #fbe9ec;
  --link: #9c2338;

  --tok-1: #e8f0fb; --tok-1-b: #7fa8dd;
  --tok-2: #fdeee2; --tok-2-b: #e0a274;
  --tok-3: #e6f5ec; --tok-3-b: #78bd97;
  --tok-4: #f6ebfa; --tok-4-b: #b98ccb;
  --tok-5: #fdf3da; --tok-5-b: #d6b45c;
  --tok-6: #e4f4f6; --tok-6-b: #74b7c0;

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
               Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
               "Liberation Mono", monospace;
  /* One reading column. Figures bleed slightly wider than the text, which is
     the only intentional width difference on the page. */
  --measure: 44rem;
  --bleed: 54rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0f13;
    --bg-sunk: #16181e;
    --panel: #14161b;
    --ink: #e8e6e3;
    --ink-soft: #a8adb8;
    --ink-faint: #767b86;
    --rule: #262932;
    --accent: #ff6b85;
    --accent-soft: #2a1720;
    --link: #ff8298;

    --tok-1: #1b2738; --tok-1-b: #5b82b8;
    --tok-2: #33231a; --tok-2-b: #b5794c;
    --tok-3: #172b20; --tok-3-b: #4e9270;
    --tok-4: #281c30; --tok-4-b: #9169a6;
    --tok-5: #302713; --tok-5-b: #ab8b3a;
    --tok-6: #142a2e; --tok-6-b: #4d8f99;
  }
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

/* ---------- layout ---------- */

.wrap { max-width: var(--measure); margin: 0 auto; padding: 0 1.5rem; }

.col { max-width: var(--measure); }

.masthead {
  border-bottom: 1px solid var(--rule);
  padding: 1.1rem 0;
  margin-bottom: 3.5rem;
}
.masthead .wrap {
  display: flex; align-items: baseline; gap: 1.5rem; flex-wrap: wrap;
}
.masthead a.brand {
  font-weight: 620; letter-spacing: -0.015em; color: var(--ink);
  text-decoration: none; font-size: 1rem;
}
.masthead nav { margin-left: auto; display: flex; gap: 1.25rem; }
.masthead nav a {
  color: var(--ink-faint); text-decoration: none; font-size: 0.9rem;
}
.masthead nav a:hover, .masthead a.brand:hover { color: var(--accent); }

footer.site {
  margin-top: 6rem;
  border-top: 1px solid var(--rule);
  padding: 2rem 0 4rem;
  color: var(--ink-faint);
  font-size: 0.875rem;
}
footer.site a { color: var(--ink-soft); }
footer.site .wrap > p { max-width: var(--measure); }

/* ---------- type ---------- */

h1 {
  font-size: clamp(2.1rem, 5.5vw, 3.1rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
  font-weight: 660;
  margin: 0 0 1rem;
  max-width: 18ch;
}
h2 {
  font-size: clamp(1.35rem, 3vw, 1.7rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 640;
  margin: 4rem 0 1rem;
  max-width: 24ch;
}
h3 {
  font-size: 1.0625rem; font-weight: 640; letter-spacing: -0.01em;
  margin: 2.25rem 0 0.6rem;
}
p { margin: 0 0 1.15rem; max-width: var(--measure); }
a { color: var(--link); text-underline-offset: 0.15em; }

.standfirst {
  font-size: 1.2rem; line-height: 1.55; color: var(--ink-soft);
  max-width: 38rem; margin-bottom: 2rem;
}
.dek { color: var(--ink-faint); font-size: 0.875rem; margin-bottom: 2.5rem; }
.lede::first-letter { /* no drop cap; kept for future use */ }

small, .small { font-size: 0.875rem; }
.muted { color: var(--ink-faint); }

code, kbd, samp { font-family: var(--font-mono); font-size: 0.925em; }
p code, li code, td code {
  background: var(--bg-sunk); padding: 0.1em 0.34em; border-radius: 4px;
}

ul.plain { list-style: none; padding: 0; }

/* ---------- token chips ---------- */

.tokens {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  line-height: 2.35;
  word-break: break-word;
  margin: 0;
}
.tok {
  padding: 0.2em 0.02em;
  border-radius: 3px;
  border-bottom: 2px solid transparent;
  white-space: pre-wrap;
}
.tok-1 { background: var(--tok-1); border-bottom-color: var(--tok-1-b); }
.tok-2 { background: var(--tok-2); border-bottom-color: var(--tok-2-b); }
.tok-3 { background: var(--tok-3); border-bottom-color: var(--tok-3-b); }
.tok-4 { background: var(--tok-4); border-bottom-color: var(--tok-4-b); }
.tok-5 { background: var(--tok-5); border-bottom-color: var(--tok-5-b); }
.tok-6 { background: var(--tok-6); border-bottom-color: var(--tok-6-b); }

/* visible whitespace markers */
.tok .ws { color: var(--ink-faint); opacity: 0.55; }

.tokens.spaced .tok { margin-right: 2px; }

.tok-id {
  display: inline-block; font-size: 0.68em; color: var(--ink-faint);
  vertical-align: super; margin-left: 1px;
}

/* ---------- figures ---------- */

figure.demo {
  margin: 1.75rem 0 2rem;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 1.25rem 1.35rem;
  /* Bleed wider than the text column, centred on it. Tables and long token
     runs need the room; prose does not. */
  width: min(var(--bleed), calc(100vw - 3rem));
  margin-left: 50%;
  transform: translateX(-50%);
}

@media (max-width: 56rem) {
  figure.demo { width: auto; margin-left: 0; transform: none; }
}
figure.demo figcaption {
  margin-top: 0.9rem; padding-top: 0.8rem; border-top: 1px solid var(--rule);
  color: var(--ink-faint); font-size: 0.85rem; line-height: 1.5;
}
figure.demo.plain { background: none; border: none; padding: 0; }

.readout {
  display: flex; gap: 1.75rem; flex-wrap: wrap;
  font-size: 0.8rem; color: var(--ink-faint);
  margin-top: 0.9rem; padding-top: 0.8rem; border-top: 1px solid var(--rule);
}
.readout b {
  display: block; font-size: 1.5rem; font-weight: 620; color: var(--ink);
  font-variant-numeric: tabular-nums; line-height: 1.15;
}

/* ---------- tables ---------- */

/* Horizontal scroll with edge shadows that appear only when there is more
   table to reach — otherwise a cut-off column on a phone looks like a bug. */
.scroll-x {
  overflow-x: auto;
  margin: 1.5rem 0 1rem;
  background:
    linear-gradient(to right, var(--panel) 30%, rgba(0, 0, 0, 0)) left center / 2.5rem 100% no-repeat,
    linear-gradient(to left, var(--panel) 30%, rgba(0, 0, 0, 0)) right center / 2.5rem 100% no-repeat,
    radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, 0.16), rgba(0, 0, 0, 0)) left center / 1rem 100% no-repeat,
    radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.16), rgba(0, 0, 0, 0)) right center / 1rem 100% no-repeat;
  background-attachment: local, local, scroll, scroll;
}
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
th, td {
  text-align: right; padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--rule); white-space: nowrap;
}
th:first-child, td:first-child { text-align: left; }
thead th {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-faint); font-weight: 600; border-bottom-color: var(--ink-faint);
}
td { font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--bg-sunk); }
.bar {
  display: inline-block; height: 0.62em; border-radius: 2px;
  background: var(--accent); opacity: 0.75; vertical-align: baseline;
  min-width: 1px;
}
td.barcell { width: 40%; text-align: left; }

/* ---------- playground ---------- */

.pg { margin: 2rem 0 1rem; }
.pg textarea {
  width: 100%; min-height: 8.5rem; resize: vertical;
  font-family: var(--font-mono); font-size: 0.95rem; line-height: 1.6;
  padding: 0.9rem 1rem;
  color: var(--ink); background: var(--panel);
  border: 1px solid var(--rule); border-radius: 10px;
}
.pg textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent;
}
.pg-bar {
  display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center;
  margin: 0.75rem 0;
}
button, .btn {
  font: inherit; font-size: 0.85rem;
  padding: 0.32rem 0.7rem; border-radius: 999px;
  border: 1px solid var(--rule); background: var(--panel); color: var(--ink-soft);
  cursor: pointer;
}
button:hover { border-color: var(--accent); color: var(--accent); }
button[aria-pressed="true"] {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent);
}
.samples { margin-left: auto; display: flex; gap: 0.4rem; flex-wrap: wrap; }

.segmented { display: inline-flex; }
.segmented button { border-radius: 0; margin-left: -1px; }
.segmented button:first-child {
  border-radius: 999px 0 0 999px; margin-left: 0; padding-left: 0.85rem;
}
.segmented button:last-child { border-radius: 0 999px 999px 0; padding-right: 0.85rem; }
.segmented button[aria-pressed="true"] { position: relative; z-index: 1; }
.segmented .muted { font-size: 0.85em; }
.segmented button[aria-pressed="true"] .muted { color: inherit; opacity: 0.75; }

#pg-compare { margin: 0.4rem 0 0; min-height: 1.4em; }

/* ---------- trainer ---------- */

.numfield {
  font: inherit; font-size: 0.85rem; width: 5.5rem;
  padding: 0.3rem 0.5rem; border-radius: 7px;
  border: 1px solid var(--rule); background: var(--panel); color: var(--ink);
}
.numfield:focus, #tr-probe:focus {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
#tr-probe { margin-bottom: 0.75rem; font-size: 0.95rem; }
#tr-probe-out { min-height: 3.5rem; }

.scroll-y {
  max-height: 26rem; overflow-y: auto; overflow-x: auto;
  border: 1px solid var(--rule); border-radius: 10px;
  padding: 0 0.9rem;
}
.scroll-y table { font-size: 0.85rem; }
.scroll-y thead th {
  position: sticky; top: 0; background: var(--bg);
  padding-top: 0.7rem; z-index: 1;
}

/* The merges worth stopping on, marked in the static table. */
tr.hit td { background: var(--accent-soft); }
tr.hit td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

.pg-out {
  background: var(--panel); border: 1px solid var(--rule);
  border-radius: 10px; padding: 1.1rem 1.2rem; min-height: 5rem;
}
.status { color: var(--ink-faint); font-size: 0.85rem; }
.status.err { color: var(--accent); }

#pg-linkwrap { margin: 0.9rem 0 0.4rem; }
#pg-linkwrap label { display: block; margin-bottom: 0.25rem; }
.linkurl {
  width: 100%; font-family: var(--font-mono); font-size: 0.82rem;
  padding: 0.5rem 0.6rem; color: var(--ink-soft); background: var(--bg-sunk);
  border: 1px solid var(--rule); border-radius: 7px;
}
.linkurl:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.noscript-note {
  background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: 8px; padding: 0.8rem 1rem; font-size: 0.9rem;
}

/* ---------- home ---------- */

.piece {
  display: block; text-decoration: none; color: inherit;
  border-top: 1px solid var(--rule); padding: 1.6rem 0;
}
.piece:hover h2 { color: var(--accent); }
.piece h2 { margin: 0 0 0.35rem; font-size: 1.3rem; max-width: none; }
.piece p { color: var(--ink-soft); margin: 0; font-size: 0.975rem; }
.piece .when {
  font-size: 0.78rem; color: var(--ink-faint); letter-spacing: 0.04em;
  text-transform: uppercase; display: block; margin-bottom: 0.4rem;
}

/* ---------- misc ---------- */

hr.rule { border: none; border-top: 1px solid var(--rule); margin: 3.5rem 0; }

.callout {
  border-left: 3px solid var(--accent);
  padding: 0.1rem 0 0.1rem 1.1rem;
  margin: 1.75rem 0;
  color: var(--ink-soft);
}

.skip {
  position: absolute; left: -9999px;
  background: var(--panel); padding: 0.6rem 1rem; z-index: 10;
}
.skip:focus { left: 1rem; top: 1rem; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

@media (max-width: 34rem) {
  .masthead { margin-bottom: 2.5rem; }
  .readout { gap: 1.1rem; }
  .readout b { font-size: 1.25rem; }
  .samples { margin-left: 0; }
}

/* Merge tables: the two code columns read left-to-right, headers included. */
table.merges th:nth-child(2), table.merges td:nth-child(2),
table.merges th:nth-child(3), table.merges td:nth-child(3) { text-align: left; }
table.merges td:nth-child(2), table.merges td:nth-child(3) { width: 30%; }

/* ---------- sampling ---------- */

table.dist th:first-child, table.dist td:first-child { text-align: left; }
table.dist tr.cut td { color: var(--ink-faint); }
table.dist tr.cut td code { opacity: 0.55; text-decoration: line-through; }

.minibar {
  display: inline-block; height: 0.6em; background: var(--accent);
  opacity: 0.7; border-radius: 2px; vertical-align: baseline; margin-right: 0.4rem;
}
.minival { font-variant-numeric: tabular-nums; font-size: 0.9em; }

.slider {
  -webkit-appearance: none; appearance: none;
  width: 7rem; height: 3px; border-radius: 2px;
  background: var(--rule); outline: none; vertical-align: middle;
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: none;
}
.slider::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: none;
}
.slider:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.pg-bar label b { font-weight: 620; color: var(--ink); font-variant-numeric: tabular-nums; }
.numfield.wide { width: 11rem; }

.sample {
  font-family: var(--font-mono); font-size: 0.92rem; line-height: 1.75;
  margin: 0.35rem 0 1.1rem; max-width: none; word-break: break-word;
}
.sample .prompt {
  background: var(--accent-soft); color: var(--accent);
  padding: 0.1em 0.3em; border-radius: 4px; margin-right: 0.15em;
}
#sm-out { margin: 0; min-height: 3rem; }
#sm-dist { max-height: 22rem; }

.next {
  border-top: 1px solid var(--rule); padding-top: 1.4rem; margin-top: 2.5rem;
  color: var(--ink-soft);
}
.next a { font-weight: 620; }

pre.code {
  font-family: var(--font-mono); font-size: 0.8rem; line-height: 1.55;
  margin: 0; overflow-x: auto; white-space: pre; tab-size: 4;
  color: var(--ink-soft);
}

.tok.special {
  background: var(--bg-sunk); border-bottom-color: var(--ink-faint);
  color: var(--ink-faint); font-size: 0.85em;
}

.mail { font-family: var(--font-mono); font-size: 0.95em; color: var(--ink); }

/* ---------- learning ---------- */

.spark { width: 100%; height: 90px; color: var(--accent); display: block; }
.sparkbox { min-height: 90px; margin: 0.5rem 0; }
.spark-axis {
  display: flex; justify-content: space-between; margin: 0.2rem 0 0;
}
.bigstat { text-align: center; margin: 0.5rem 0; }
.bigstat b {
  display: block; font-size: clamp(2.4rem, 7vw, 3.4rem); font-weight: 660;
  letter-spacing: -0.03em; color: var(--accent); line-height: 1.05;
}
pre.code.arch { font-size: 0.78rem; line-height: 1.5; color: var(--ink-soft); }
.never { color: var(--accent); }
#nn-probe { margin-bottom: 0.75rem; font-family: var(--font-mono); }
#nn-probe-out { min-height: 4rem; }
#nn-sample { margin: 0; min-height: 3.5rem; }
