/* Niwaki — a hand-tinted engraving. Warm paper ground (the plates' own paper; their web copies are re-toned to it
   exactly), the engraving's ink for everything that carries meaning, and three pale washes on the chart bars. */

:root {
  color-scheme: light;
  --paper: #F7EEE3;
  --ink: #231F1A;
  --ink-soft: #5E564B;      /* secondary text, 6.3:1 on paper */
  --ink-dim: #746B5D;       /* a dimmed link that still works, 4.6:1 on paper */
  --rule: #D9CDBB;          /* hairlines */

  /* bar washes — deliberately pale; identity never rests on them alone (texture, ink outline, labels, legend) */
  --tint-release: #A7C2A0;  /* pine */
  --tint-earlier: #E9D3A2;  /* ochre */
  --tint-unpruned: #C3D3DB; /* mist */

  --display: "Cormorant Garamond", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --text: "EB Garamond", "Iowan Old Style", "Palatino Linotype", Palatino, "Hiragino Mincho ProN", "Yu Mincho", Georgia, serif;

  --measure: 56rem;
  --gutter: clamp(1rem, 4vw, 2rem);
}

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

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--text);
  font-size: 1.1875rem;
  line-height: 1.55;
  font-variant-numeric: lining-nums;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 1px; }

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

/* ---------- navigation: stays at the top while the page scrolls ---------- */
.top { position: sticky; top: 0; z-index: 10; background: var(--paper); border-bottom: 1px solid var(--rule); }
.nav {
  display: flex; align-items: center; justify-content: space-between; gap: 1.5rem;
  padding-block: 0.6rem;
}
.nav .mark {
  font-family: var(--display); font-style: italic; font-weight: 500; font-size: 1.6rem; line-height: 1;
  text-decoration: none; display: inline-flex; align-items: center; gap: 0.55rem;
}
.nav .mark img { height: 2.1rem; width: 2.1rem; display: block; }
.nav ul { display: flex; flex-wrap: wrap; gap: 0.35rem 1.4rem; list-style: none; margin: 0; padding: 0; }
.nav li a {
  font-variant-caps: all-small-caps; letter-spacing: 0.09em; font-size: 1.02rem; text-decoration: none;
  border-bottom: 1px solid transparent; padding-bottom: 0.1em;
}
.nav li a:hover, .nav li a[aria-current="page"] { border-bottom-color: var(--ink); }
.nav li.soon a { color: var(--ink-dim); }   /* not ready yet */

/* ---------- a full-width plate (the Saikei page); its file is re-toned to the page's paper, the edges fade ---------- */
.plate { margin: 0 auto; max-width: 75rem; }
.plate img {
  display: block; width: 100%; height: auto; aspect-ratio: 2 / 1;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 3%, #000 97%, transparent), linear-gradient(to bottom, transparent, #000 5%, #000 94%, transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to right, transparent, #000 3%, #000 97%, transparent), linear-gradient(to bottom, transparent, #000 5%, #000 94%, transparent);
  mask-composite: intersect;
}
.lead.solo { padding-block: clamp(1.25rem, 3vw, 2rem) clamp(2.5rem, 6vw, 3.75rem); }
.lead.solo p { max-width: 40ch; }
.lead.solo p + p { max-width: 58ch; }
.lead h1 { margin-bottom: 0.9rem; }

/* ---------- frontispiece: the lead beside the tree ---------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr); align-items: center; gap: 1.5rem clamp(1.5rem, 4vw, 3rem);
  padding-block: clamp(2rem, 5vw, 3.5rem) clamp(2.5rem, 6vw, 4rem);
}
.tree { margin: 0; justify-self: end; width: 100%; max-width: 31rem; }
.tree img {
  display: block; width: 100%; height: auto; aspect-ratio: 1221 / 868;
  /* same paper as the page, but grainy: fade the edges so the crop never shows */
  -webkit-mask-image: linear-gradient(to right, transparent, #000 5%, #000 95%, transparent), linear-gradient(to bottom, transparent, #000 4%, #000 94%, transparent);
  -webkit-mask-composite: source-in;
  mask-image: linear-gradient(to right, transparent, #000 5%, #000 95%, transparent), linear-gradient(to bottom, transparent, #000 4%, #000 94%, transparent);
  mask-composite: intersect;
}
.lead p {
  font-family: var(--display); font-style: italic; font-weight: 400;
  font-size: clamp(1.45rem, 2.9vw, 2rem); line-height: 1.32; max-width: 30ch; margin: 0;
  text-wrap: balance;
}
.lead p + p {
  font-family: var(--text); font-style: normal; font-size: 1.1875rem; line-height: 1.55;
  color: var(--ink-soft); max-width: 46ch; margin-top: 1.25rem; text-wrap: pretty;
}

/* ---------- sections ---------- */
section { padding-block: clamp(2.25rem, 6vw, 3.75rem); border-top: 1px solid var(--rule); scroll-margin-top: 3.4rem; }
section.first { border-top: 1px solid var(--ink); }

.eyebrow {
  font-variant-caps: all-small-caps; letter-spacing: 0.1em; font-size: 1.02rem; color: var(--ink-soft); margin: 0 0 0.5rem;
}
h1, h2, h3 { font-family: var(--display); font-style: italic; font-weight: 500; line-height: 1.12; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(2.2rem, 5.2vw, 3.3rem); }
h2 { font-size: clamp(1.9rem, 4.4vw, 2.7rem); }
h3 { font-size: 1.55rem; margin-top: 2.75rem; }
.nb { white-space: nowrap; }
.sub { font-family: var(--text); font-style: normal; font-size: 0.62em; color: var(--ink-soft); white-space: nowrap; }

.summary { max-width: 64ch; margin: 1rem 0 0; text-wrap: pretty; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.84em; }
.note { max-width: 70ch; color: var(--ink-soft); font-size: 1.02rem; line-height: 1.5; margin: 1.1rem 0 0; text-wrap: pretty; }

/* headline figures */
.figures {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0;
  margin: 2.25rem 0 0; padding: 0; list-style: none;
  border-block: 1px solid var(--ink);
}
.figures.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.figures.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.figures li { padding: 1.05rem 1rem 1rem 0; }
.figures li + li { border-left: 1px solid var(--rule); padding-left: 1rem; }
.figures .n {
  display: block; font-family: var(--display); font-style: italic; font-weight: 500;
  font-size: clamp(1.9rem, 4.2vw, 2.7rem); line-height: 1; white-space: nowrap;
}
.figures .n small { font-size: 0.55em; font-style: normal; font-family: var(--text); letter-spacing: 0.02em; }
.figures .c { display: block; margin-top: 0.45rem; font-size: 0.98rem; line-height: 1.35; color: var(--ink-soft); }

/* ---------- charts: engraved bars ---------- */
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2.5rem 3rem; margin-top: 2.5rem; }
.chart { margin: 0; min-width: 0; }
.chart.wide { grid-column: 1 / -1; }
.chart figcaption { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.15rem 1rem; margin-bottom: 0.7rem; }
.chart figcaption b { font-weight: 500; font-size: 1.12rem; }
.chart figcaption i { font-size: 0.95rem; color: var(--ink-soft); }

.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.6rem; }
.bars li { display: grid; gap: 0.12rem; }
.bars .name { font-size: 0.98rem; line-height: 1.25; color: var(--ink-soft); }
.bars li.solid .name { color: var(--ink); font-weight: 500; }
.bars li:hover .name { color: var(--ink); }
.bars .track { display: flex; align-items: center; gap: 0.55rem; min-width: 0; }
.bars .bar {
  flex: none; height: 0.95rem; min-width: 2px;
  width: calc(var(--v) / var(--max) * (100% - 7.5ch));
  border-radius: 0 2px 2px 0;
  box-shadow: inset 0 0 0 1px var(--ink);
  transform-origin: left center;
  animation: draw 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(var(--i, 0) * 70ms);
}
.bars .val { font-variant-numeric: lining-nums tabular-nums; font-size: 1.02rem; white-space: nowrap; }
.bars li.solid .val { font-weight: 500; }

.solid .bar, .key .solid { background: var(--tint-release); }
.hatch .bar, .key .hatch { background: repeating-linear-gradient(135deg, rgb(35 31 26 / 0.5) 0 1px, transparent 1px 3.6px), var(--tint-earlier); }
.open .bar, .key .open { background: radial-gradient(circle at 1.5px 1.5px, rgb(35 31 26 / 0.4) 0.55px, transparent 0.75px) 0 0 / 4px 4px, var(--tint-unpruned); }

/* paired bars: one benchmark, two models (the Dojo page) — the wash class sits on each track; the first track may carry
   its difference from the second */
.bars.pairs { gap: 0.9rem; }
.bars.pairs li { gap: 0.22rem; }
.bars.pairs .bar { width: calc(var(--v) / var(--max) * (100% - 13ch)); }
.bars .track.solid .val { font-weight: 500; }
.bars .delta { font-size: 0.92rem; color: var(--ink-soft); font-variant-numeric: lining-nums tabular-nums; white-space: nowrap; }

/* a range (two evaluation seeds): the bar runs to the lower bound, a whisker to the upper */
.bars .whisker {
  flex: none; height: 0.95rem; margin-left: -0.55rem;
  width: calc((var(--v2) - var(--v)) / var(--max) * (100% - 9.5ch));
  border-right: 1px solid var(--ink);
  background: linear-gradient(var(--ink), var(--ink)) left center / 100% 1px no-repeat;
}
.bars li.range .bar { width: calc(var(--v) / var(--max) * (100% - 9.5ch)); }

.key { display: flex; flex-wrap: wrap; gap: 0.4rem 1.6rem; list-style: none; margin: 2rem 0 0; padding: 0; font-size: 0.98rem; color: var(--ink-soft); }
.key li { display: inline-flex; align-items: center; gap: 0.5rem; }
.key span { width: 1.7rem; height: 0.8rem; box-shadow: inset 0 0 0 1px var(--ink); border-radius: 0 2px 2px 0; }

@keyframes draw { from { transform: scaleX(0); } }

/* ---------- downloads ---------- */
.get { display: flex; flex-wrap: wrap; gap: 0.6rem 0.9rem; margin: 2.25rem 0 0; padding: 0; list-style: none; }
.get a {
  display: inline-block; text-decoration: none; padding: 0.5rem 1rem 0.55rem;
  box-shadow: inset 0 0 0 1px var(--ink); border-radius: 2px; font-size: 1.05rem; line-height: 1.2;
}
.get a:hover { background: var(--ink); color: var(--paper); }
.get a.primary { background: var(--ink); color: var(--paper); }
.get a.primary:hover { background: transparent; color: var(--ink); }
.get small { display: block; font-size: 0.86rem; opacity: 0.8; margin-top: 0.1rem; }
.get + .get { margin-top: 0.6rem; }        /* a second row of downloads (MLX, then GGUF) */

/* release list (earlier generations) */
.releases { list-style: none; margin: 1.5rem 0 0; padding: 0; border-top: 1px solid var(--rule); }
.releases li {
  display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1.6fr) auto; gap: 0.25rem 1.5rem; align-items: baseline;
  padding-block: 0.8rem; border-bottom: 1px solid var(--rule);
}
.releases .what { font-weight: 500; }
.releases .nums { color: var(--ink-soft); font-size: 1.02rem; font-variant-numeric: lining-nums tabular-nums; }
.releases .links { white-space: nowrap; font-size: 1.02rem; }
.releases.pair li { grid-template-columns: minmax(0, 1fr) minmax(0, 1.9fr); }

/* facts: a labelled list under a project's summary (the Dojo page) */
.facts { margin: 1.75rem 0 0; border-top: 1px solid var(--rule); }
.facts > div {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 3.4fr); gap: 0.15rem 1.5rem; align-items: baseline;
  padding-block: 0.8rem; border-bottom: 1px solid var(--rule);
}
.facts dt { font-variant-caps: all-small-caps; letter-spacing: 0.09em; font-size: 1.02rem; color: var(--ink-soft); }
.facts dd { margin: 0; max-width: 64ch; text-wrap: pretty; }
h3 + .summary { margin-top: 0.6rem; }
h3 + .facts { margin-top: 1.1rem; }

/* ---------- paper page ---------- */
.paper { padding-block: clamp(3rem, 10vw, 7rem) clamp(3rem, 8vw, 5rem); }
.paper h1 { max-width: 18ch; }
.paper p { max-width: 60ch; text-wrap: pretty; }
.paper .big { font-family: var(--display); font-style: italic; font-size: clamp(1.4rem, 3vw, 1.9rem); line-height: 1.35; margin-top: 1.5rem; max-width: 34ch; }
.paper ul { max-width: 60ch; padding-left: 1.2rem; }
.paper li { margin-block: 0.3rem; }

/* ---------- footer ---------- */
footer { border-top: 1px solid var(--ink); padding-block: 1.75rem 3rem; color: var(--ink-soft); font-size: 1.02rem; }
footer .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.75rem 2rem; }
footer p { margin: 0; max-width: 58ch; }
footer .made { flex-basis: 100%; max-width: none; margin-top: 0.4rem; font-family: var(--display); font-style: italic; font-size: 1.2rem; color: var(--ink); }

/* ---------- small screens ---------- */
@media (max-width: 46rem) {
  body { font-size: 1.125rem; }
  .charts { grid-template-columns: minmax(0, 1fr); gap: 2.25rem; }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figures li { padding: 0.9rem 0.75rem 0.85rem 0; }
  .figures li + li { border-left: 0; padding-left: 0; }
  .figures li:nth-child(even) { border-left: 1px solid var(--rule); padding-left: 0.9rem; }
  .figures li:nth-child(n + 3) { border-top: 1px solid var(--rule); }
  .figures.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .releases li { grid-template-columns: minmax(0, 1fr); }
  .releases.pair li, .facts > div { grid-template-columns: minmax(0, 1fr); }
  .hero { grid-template-columns: minmax(0, 1fr); }
  .tree { order: -1; justify-self: center; max-width: 24rem; }
  .nav { gap: 0.1rem 1rem; flex-wrap: wrap; padding-block: 0.5rem; }
  .nav ul { gap: 0.3rem 0.95rem; flex-wrap: wrap; }
  section { scroll-margin-top: 5rem; }
  .nav li a { font-size: 0.98rem; letter-spacing: 0.07em; }
  .nav li.ext { display: none; }            /* the bar stays one line; the link is in the footer too */
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .bars .bar { animation: none; }
}

@media print {
  .bars .bar { animation: none; }
  .top { position: static; }
  .nav ul, .get { display: none; }
}

/* ---------- a 2:1 plate (Saikei, Origami, Nihonga, Dojo) beside the lead, laid out like the Niwaki tree ---------- */
.tree.plate-art { max-width: 36rem; }
.tree.plate-art img { aspect-ratio: 2 / 1; }
