/* theme-jp
   One column, one family, one accent. Hierarchy comes from size and weight,
   not from caps or color. */

/* ---- Fonts (self-hosted, latin subset) ---------------------------------- */
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/ibm-plex-sans-400.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/ibm-plex-sans-400-italic.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/ibm-plex-sans-600.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/ibm-plex-mono-400.woff2") format("woff2");
}

/* ---- Tokens -------------------------------------------------------------- */
:root {
  --bg: #fbfbfa;
  --fg: #191b1e;
  --muted: #6a7075;
  --faint: #868c91;
  --rule: #dfe3e1;
  --accent: #3547a8;
  --code-bg: #f0f1ef;
  --chart-line: #3547a8;
  --chart-2: #008a6e;

  --font-text: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-code: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --measure: 38rem;          /* ~72 characters at the body size */
  --gutter: 1rem;

  --text-0: 1rem;            /* body, h3 */
  --text-1: 1.235rem;        /* h2 */
  --text-2: 1.647rem;        /* h1 */
  --text-small: 0.882rem;    /* dates, footer, code */
  --text-xsmall: 0.8rem;     /* author names */
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141617;
    --fg: #e8e9e9;
    --muted: #9aa0a4;
    --faint: #7c8286;
    --rule: #2b3032;
    --accent: #93a4f4;
    --code-bg: #1d2022;
    --chart-line: #7389e8;
    --chart-2: #2fa487;
  }
}

:root[data-theme="dark"] {
  --bg: #141617;
  --fg: #e8e9e9;
  --muted: #9aa0a4;
  --faint: #7c8286;
  --rule: #2b3032;
  --accent: #93a4f4;
  --code-bg: #1d2022;
  --chart-line: #7389e8;
  --chart-2: #2fa487;
}

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

html {
  font-size: 106.25%;        /* 17px */
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--fg);
  font-family: var(--font-text);
  font-size: var(--text-0);
  line-height: 1.6;
  font-feature-settings: "kern", "liga";
}

.page {
  max-width: calc(var(--measure) + 2 * var(--gutter));
  margin: 0 auto;
  padding: 0 var(--gutter);
}

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

::selection {
  background: var(--accent);
  color: var(--bg);
}

/* ---- Navigation ---------------------------------------------------------- */
.navbar {
  padding: 1.75rem 0 0.75rem;
  border-bottom: 1px solid var(--rule);
}

.nav-items {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-toggle {
  margin-left: auto;
}

.nav-home {
  color: var(--fg);
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.nav-home:hover {
  color: var(--accent);
}

.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-size: var(--text-small);
}

.nav-link:hover {
  color: var(--fg);
}

.nav-link[aria-current="page"] {
  color: var(--accent);
}

.theme-toggle-btn {
  display: flex;
  align-items: center;
  padding: 0.25rem;
  margin: -0.25rem;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
}

.theme-toggle-btn:hover {
  color: var(--fg);
}

.icon-sun { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}

:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }

/* ---- Typography ---------------------------------------------------------- */
h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--fg);
}

h1 {
  font-size: var(--text-2);
  margin: 2rem 0 1rem;
}

h2 {
  font-size: var(--text-1);
  margin: 2.25rem 0 0.5rem;
}

h3 {
  font-size: var(--text-0);
  margin: 1.5rem 0 0.25rem;
}

h4 {
  font-size: var(--text-0);
  font-weight: 400;
  font-style: italic;
  margin: 1.25rem 0 0.25rem;
}

p {
  margin: 0.75rem 0;
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
}

a:hover {
  color: var(--accent);
  text-decoration-color: currentColor;
}

strong {
  font-weight: 600;
  color: var(--accent);
}

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

/* ---- Prose (rendered markdown) ------------------------------------------- */
.prose p,
.prose li {
  text-align: justify;
  -webkit-hyphens: auto;
  hyphens: auto;
}

.prose ul,
.prose ol {
  margin: 0.75rem 0;
  padding-left: 1.5rem;
}

.prose li {
  margin: 0.35rem 0;
}

.prose li > p {
  margin: 0.35rem 0;
}

.prose img {
  max-width: 100%;
  height: auto;
  margin: 1rem 0;
}

.prose blockquote {
  margin: 1.25rem 0;
  padding-left: 1rem;
  border-left: 2px solid var(--rule);
  color: var(--muted);
}

.prose blockquote p {
  margin: 0.5rem 0;
}

code,
kbd,
pre {
  font-family: var(--font-code);
  font-size: var(--text-small);
}

code,
kbd {
  padding: 0.1em 0.3em;
  border-radius: 3px;
  background: var(--code-bg);
}

pre {
  margin: 1.25rem 0;
  padding: 1rem;
  border-radius: 4px;
  background: var(--code-bg);
  line-height: 1.5;
  overflow-x: auto;
}

pre code {
  padding: 0;
  background: none;
}

/* Code names must never be hyphenated by the justified prose around them. */
code,
kbd {
  -webkit-hyphens: manual;
  hyphens: manual;
}

/* Tables span the column so consecutive tables line up; on phones they
   scroll inside their own box instead of widening the page. */
.prose table {
  width: 100%;
  margin: 1.5rem 0;
  border-collapse: collapse;
  font-size: var(--text-small);
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
}

.prose th,
.prose td {
  padding: 0.45rem 0.75rem;
  text-align: left;
  vertical-align: top;
}

.prose th:first-child,
.prose td:first-child {
  padding-left: 0;
}

.prose th:last-child,
.prose td:last-child {
  padding-right: 0;
}

.prose th {
  font-weight: 600;
  border-bottom: 1px solid var(--fg);
}

.prose td {
  border-bottom: 1px solid var(--rule);
}

/* Bold cells mark the row to look at; tint the whole row instead of
   coloring every value. */
.prose tr:has(td strong) td {
  background: color-mix(in srgb, var(--chart-line) 8%, transparent);
}

.prose td strong {
  color: inherit;
}

@media (max-width: 480px) {
  .prose table {
    display: block;
    overflow-x: auto;
  }
}

/* Key/value facts, e.g. a model's configuration. */
.prose dl.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  margin: 1.5rem 0;
  font-size: var(--text-small);
  line-height: 1.45;
  border-top: 1px solid var(--fg);
}

.prose dl.facts dt,
.prose dl.facts dd {
  margin: 0;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--rule);
}

.prose dl.facts dt {
  padding-right: 1.5rem;
  color: var(--muted);
}

@media (max-width: 480px) {
  .prose dl.facts {
    grid-template-columns: 1fr;
  }

  .prose dl.facts dt {
    padding-bottom: 0;
    border-bottom: 0;
  }

  .prose dl.facts dd {
    padding-top: 0.1rem;
  }
}

/* ---- Figures and charts ------------------------------------------------- */
.prose figure {
  margin: 2rem 0;
}

/* A wide figure breaks out of the text column on large screens. */
.prose figure.wide {
  --wide: min(48rem, 100vw - 2 * var(--gutter));
  width: var(--wide);
  margin-left: calc((100% - var(--wide)) / 2);
}

.prose figure.wide figcaption {
  max-width: var(--measure);
  margin-inline: auto;
}

/* On phones a chart keeps a readable size and scrolls sideways instead of
   shrinking its labels to nothing. */
.chart-scroll {
  overflow-x: auto;
}

@media (max-width: 480px) {
  .chart-scroll .chart {
    min-width: 640px;
  }
}

.prose figcaption {
  margin-top: 0.5rem;
  color: var(--muted);
  font-size: var(--text-small);
}

.chart {
  display: block;
  width: 100%;
  height: auto;
  font-family: var(--font-text);
}

.chart .grid { stroke: var(--rule); stroke-width: 1; }
.chart .boundary { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 4; }
.chart .line { fill: none; stroke: var(--chart-line); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line-live { stroke-dasharray: 4 3; }
.chart .dot { fill: var(--chart-line); stroke: var(--bg); stroke-width: 2; }
.chart .hit { fill: transparent; }
.chart .hit:hover { fill: color-mix(in srgb, var(--chart-line) 25%, transparent); }
.chart .tick { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .note { fill: var(--muted); font-size: 12px; }
.chart .note-strong { fill: var(--fg); font-size: 12px; font-weight: 600; }
.chart .axis-label { fill: var(--muted); font-size: 12px; }
.chart .debt { fill: color-mix(in srgb, var(--chart-line) 18%, transparent); }
.chart .ref { stroke: var(--chart-line); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .leader { stroke: var(--muted); stroke-width: 1; }
.chart .line-thin { stroke-width: 1.5; }
.chart .line-2 { stroke: var(--chart-2); }
.chart .line-other { stroke: var(--muted); }
.chart .line-gap { stroke-dasharray: 1 4; }
.chart .dot-2 { fill: var(--chart-2); }
.chart .dot-other { fill: var(--muted); }
.chart .value.value-2 { font-weight: 400; }
.chart .chance { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .bar { fill: var(--chart-line); }
.chart .bar-2 { fill: color-mix(in srgb, var(--muted) 45%, transparent); }
.chart .bar:hover, .chart .bar-2:hover { fill: var(--accent); }
.chart .target { stroke: var(--chart-2); stroke-width: 1.5; }
.chart .hit-col { fill: transparent; }
.chart .hit-col:hover { fill: color-mix(in srgb, var(--fg) 12%, transparent); }

/* Gradient-norm heatmap: one hue, from near the page color to full ink. */
.chart .heat-0 { fill: color-mix(in oklab, var(--chart-line) 8%, var(--bg)); }
.chart .heat-1 { fill: color-mix(in oklab, var(--chart-line) 22%, var(--bg)); }
.chart .heat-2 { fill: color-mix(in oklab, var(--chart-line) 36%, var(--bg)); }
.chart .heat-3 { fill: color-mix(in oklab, var(--chart-line) 52%, var(--bg)); }
.chart .heat-4 { fill: color-mix(in oklab, var(--chart-line) 68%, var(--bg)); }
.chart .heat-5 { fill: color-mix(in oklab, var(--chart-line) 84%, var(--bg)); }
.chart .heat-6 { fill: var(--chart-line); }

/* Small multiples: one chart per benchmark, same scales. */
.small-multiples {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.prose .small-multiples li {
  margin: 0;
  text-align: left;
}

.small-multiples h3 {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0 0 0.25rem;
  padding-right: 0.6rem;
  font-size: var(--text-small);
}

.panel-value {
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.chart-small .tick-sm { font-size: 10px; }

@media (max-width: 600px) {
  .small-multiples {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem 1rem;
  }

  .small-multiples h3 {
    padding-right: 0;
  }

  .chart-small .tick-sm { font-size: 14px; }
}

/* Legend: a short sample of each mark, then its name. */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0 0 0.75rem;
  padding: 0;
  list-style: none;
  font-size: var(--text-small);
  color: var(--muted);
}

.prose .legend li {
  margin: 0;
  text-align: left;
}

.legend-key {
  display: inline-block;
  width: 1.25rem;
  height: 0;
  margin-right: 0.4rem;
  vertical-align: middle;
  border-top: 2px solid var(--chart-line);
}

.legend-key.k-2 { border-top-color: var(--chart-2); }
.legend-key.k-other-line { border-top-color: var(--muted); }
.legend-key.k-other { width: 0.5rem; height: 0.5rem; border: 0; border-radius: 50%; background: var(--muted); }
.legend-key.k-chance { border-top: 1px dashed var(--muted); }
.legend-key.k-target { border-top: 1.5px solid var(--chart-2); }

/* The numbers behind a chart, one click away. */
.prose details {
  margin: 0.75rem 0 1.5rem;
  font-size: var(--text-small);
}

.prose summary {
  color: var(--muted);
  cursor: pointer;
}

.prose summary:hover {
  color: var(--fg);
}

.prose details table {
  margin-top: 0.5rem;
}
.chart .value { fill: var(--fg); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---- Contents ------------------------------------------------------------ */
/* On wide screens a post's sections are listed in the right margin and the list
   stays in view while reading. Wide figures then bleed left only, clear of it. */
.toc-rail {
  display: none;
}

.prose h2 {
  scroll-margin-top: 1.5rem;
}

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

@media (min-width: 1200px) {
  .post-grid.has-toc {
    display: grid;
    grid-template-columns: 100% 12rem;
    column-gap: 3rem;
  }

  .has-toc .toc-rail {
    display: block;
  }

  .has-toc .prose figure.wide {
    margin-left: calc(100% - var(--wide));
  }

  .has-toc .prose figure.wide figcaption {
    margin-right: 0;
  }
}

.toc {
  position: sticky;
  top: 2rem;
  max-height: calc(100vh - 4rem);
  margin-top: 2.35rem;
  overflow-y: auto;
}

.toc-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-left: 1px solid var(--rule);
  font-size: var(--text-small);
  line-height: 1.35;
}

.toc-list li {
  margin: 0;
}

.toc a {
  display: block;
  margin-left: -1px;
  padding: 0.3rem 0 0.3rem 0.9rem;
  border-left: 2px solid transparent;
  color: var(--muted);
  text-decoration: none;
}

.toc a:hover {
  color: var(--fg);
}

.toc a[aria-current] {
  border-left-color: var(--accent);
  color: var(--fg);
}

/* ---- Post ---------------------------------------------------------------- */
.post-header {
  margin: 2rem 0 1.5rem;
}

.post-header h1 {
  margin: 0;
}

.post-meta {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: var(--text-small);
}

.post-authors a,
.post-by a {
  text-decoration: none;
}

.post-authors a:hover,
.post-by a:hover {
  text-decoration: underline;
}

.post-dek {
  margin: 0.75rem 0 0;
  color: var(--muted);
}

.post-nav {
  margin-top: 3rem;
  font-size: var(--text-small);
}

.post-nav p {
  margin: 0.35rem 0;
}

.post-nav span {
  display: inline-block;
  min-width: 3.5rem;
  color: var(--muted);
}

/* ---- Post index ---------------------------------------------------------- */
.index-year {
  margin-top: 2rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--rule);
}

.posts {
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
}

.posts li {
  display: grid;
  grid-template-columns: 6.25rem 1fr;  /* fits "2026 Sep 24" */
  gap: 0 1rem;
  padding: 0.3rem 0;
}

.posts time {
  color: var(--muted);
  font-size: var(--text-small);
  font-variant-numeric: tabular-nums;
  padding-top: 0.1em;
}

.posts a {
  text-decoration: none;
}

.posts a:hover {
  text-decoration: underline;
}

.post-by {
  display: block;
  color: var(--faint);
  font-size: var(--text-xsmall);
}

.intro {
  margin: 2rem 0 0;
}

.intro p {
  text-align: left;
  -webkit-hyphens: manual;
  hyphens: manual;
}

.series-dates {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.series-dates li {
  min-width: 4rem;
}

.series-dates time {
  color: var(--fg);
  font-size: var(--text-0);
}

.series-dates a:hover time {
  color: var(--accent);
}

/* ---- Gallery ------------------------------------------------------------- */
.gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.gallery-item {
  margin: 0;
}

.gallery-item.wide {
  grid-column: 1 / -1;
}

.gallery-item a {
  display: block;
  line-height: 0;
}

.gallery-item img {
  width: 100%;
  height: auto;
  border-radius: 3px;
}

/* ---- Footer -------------------------------------------------------------- */
.site-footer {
  margin-top: 4rem;
  padding: 1.25rem 0 3rem;
  border-top: 1px solid var(--rule);
  font-size: var(--text-small);
  color: var(--muted);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.footer-links a {
  text-decoration: none;
}

.footer-links a:hover {
  text-decoration: underline;
}

.footer-copy {
  margin-left: auto;
}

/* ---- Small screens ------------------------------------------------------- */
@media (max-width: 480px) {
  /* Justified text opens wide gaps in a phone-width column. */
  .prose p,
  .prose li {
    text-align: left;
  }

  .navbar {
    padding-top: 1.25rem;
  }

  .nav-items {
    gap: 0.25rem 1.1rem;
  }

  .gallery {
    grid-template-columns: 1fr;
  }

  .footer-copy {
    margin-left: 0;
    flex-basis: 100%;
  }
}

/* ---- Motion -------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  a,
  .nav-home,
  .theme-toggle-btn {
    transition: color 120ms ease, text-decoration-color 120ms ease;
  }
}
