/* IBM Plex Sans, self-hosted rather than fetched from a font CDN.
   SIL Open Font License 1.1 -- the terms are in fonts/LICENSE.txt.

   Split by script, so a page downloads only the ranges it actually sets:
   Latin1 is the text, Pi carries the arrows in the nav and the example
   links. Those two are all this site uses -- 115KB, against 254KB for the
   complete faces, which also carry Greek and Cyrillic nothing here sets.

   The urls are relative to this stylesheet, so they follow the site to a
   subpath without needing SITE_BASE rewriting. */
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/IBMPlexSans-Regular-Latin1.woff2") format("woff2");
  unicode-range: U+0000, U+000D, U+0020-007E, U+00A0-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2013-2014, U+2018-201A, U+201C-201E, U+2020-2022, U+2026, U+2030, U+2039-203A, U+2044, U+20AC, U+2122, U+2212, U+FB01-FB02;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/IBMPlexSans-Regular-Pi.woff2") format("woff2");
  unicode-range: U+0E3F, U+2000-200D, U+2015, U+2028-2029, U+202F, U+2032-2033, U+2070, U+2074-2079, U+2080-2089, U+2113, U+2116, U+2126, U+212E, U+2150-2151, U+2153-215E, U+2190-2199, U+21A9-21AA, U+21B0-21B3, U+21B6-21B7, U+21BA-21BB, U+21C4, U+21C6, U+2202, U+2206, U+220F, U+2211, U+2215, U+221A, U+221E, U+222B, U+2248, U+2260, U+2264-2265, U+25CA, U+2713, U+274C, U+2B0E-2B11, U+ECE0, U+EFCC, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/IBMPlexSans-SemiBold-Latin1.woff2") format("woff2");
  unicode-range: U+0000, U+000D, U+0020-007E, U+00A0-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2013-2014, U+2018-201A, U+201C-201E, U+2020-2022, U+2026, U+2030, U+2039-203A, U+2044, U+20AC, U+2122, U+2212, U+FB01-FB02;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/IBMPlexSans-SemiBold-Pi.woff2") format("woff2");
  unicode-range: U+0E3F, U+2000-200D, U+2015, U+2028-2029, U+202F, U+2032-2033, U+2070, U+2074-2079, U+2080-2089, U+2113, U+2116, U+2126, U+212E, U+2150-2151, U+2153-215E, U+2190-2199, U+21A9-21AA, U+21B0-21B3, U+21B6-21B7, U+21BA-21BB, U+21C4, U+21C6, U+2202, U+2206, U+220F, U+2211, U+2215, U+221A, U+221E, U+222B, U+2248, U+2260, U+2264-2265, U+25CA, U+2713, U+274C, U+2B0E-2B11, U+ECE0, U+EFCC, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/IBMPlexSans-Bold-Latin1.woff2") format("woff2");
  unicode-range: U+0000, U+000D, U+0020-007E, U+00A0-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2013-2014, U+2018-201A, U+201C-201E, U+2020-2022, U+2026, U+2030, U+2039-203A, U+2044, U+20AC, U+2122, U+2212, U+FB01-FB02;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("fonts/IBMPlexSans-Bold-Pi.woff2") format("woff2");
  unicode-range: U+0E3F, U+2000-200D, U+2015, U+2028-2029, U+202F, U+2032-2033, U+2070, U+2074-2079, U+2080-2089, U+2113, U+2116, U+2126, U+212E, U+2150-2151, U+2153-215E, U+2190-2199, U+21A9-21AA, U+21B0-21B3, U+21B6-21B7, U+21BA-21BB, U+21C4, U+21C6, U+2202, U+2206, U+220F, U+2211, U+2215, U+221A, U+221E, U+222B, U+2248, U+2260, U+2264-2265, U+25CA, U+2713, U+274C, U+2B0E-2B11, U+ECE0, U+EFCC, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/IBMPlexSans-Italic-Latin1.woff2") format("woff2");
  unicode-range: U+0000, U+000D, U+0020-007E, U+00A0-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2013-2014, U+2018-201A, U+201C-201E, U+2020-2022, U+2026, U+2030, U+2039-203A, U+2044, U+20AC, U+2122, U+2212, U+FB01-FB02;
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/IBMPlexSans-Italic-Pi.woff2") format("woff2");
  unicode-range: U+0E3F, U+2000-200D, U+2015, U+2028-2029, U+202F, U+2032-2033, U+2070, U+2074-2079, U+2080-2089, U+2113, U+2116, U+2126, U+212E, U+2150-2151, U+2153-215E, U+2190-2199, U+21A9-21AA, U+21B0-21B3, U+21B6-21B7, U+21BA-21BB, U+21C4, U+21C6, U+2202, U+2206, U+220F, U+2211, U+2215, U+221A, U+221E, U+222B, U+2248, U+2260, U+2264-2265, U+25CA, U+2713, U+274C, U+2B0E-2B11, U+ECE0, U+EFCC, U+FEFF, U+FFFD;
}

/* Sauvignon website. Light and dark are both first-class, matching the way the
   diagrams themselves adapt via prefers-color-scheme. The palette nods to the
   name: a bordeaux accent over warm, wine-label neutrals -- cream and parchment
   in the light, a wine-dark near-black in the dark. */

:root {
  --bg: #fffdfb;
  --surface: #f8f4f1;
  --surface-2: #efe7e2;
  --border: #e5dcd5;
  --text: #231b1c;
  --muted: #6e6165;
  --accent: #7c2c43;         /* bordeaux */
  --accent-soft: #f6e7ec;    /* pale rosé */
  --code-bg: #f6f0eb;
  --radius: 10px;
  --wrap: 62rem;
  --font: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #181315;
    --surface: #211a1d;
    --surface-2: #2b2226;
    --border: #3a2e33;
    --text: #ede6e8;
    --muted: #a89aa0;
    --accent: #d98a9e;       /* the bordeaux, lightened to a dusty rosé */
    --accent-soft: #2e1c24;  /* deep wine tint */
    --code-bg: #211a1d;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; }
h1 { font-size: 2.1rem; margin: 0 0 .5rem; letter-spacing: -0.02em; }
h2 { font-size: 1.4rem; margin: 2.5rem 0 .75rem; }
h3 { font-size: 1.1rem; margin: 0 0 .35rem; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 2.5rem 1.25rem 4rem; }
.lede { color: var(--muted); font-size: 1.1rem; margin-top: 0; }

/* --- header / footer ------------------------------------------------------ */

.site-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky; top: 0; z-index: 10;
}
.brand {
  font-weight: 700; font-size: 1.15rem; letter-spacing: -0.02em;
  color: var(--text); text-decoration: none;
}
/* wrap, or the five links overflow a phone viewport and scroll the whole page */
.site-nav { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.site-nav a { text-decoration: none; color: var(--muted); font-size: .95rem; }
.site-nav a:hover { color: var(--accent); }
@media (max-width: 30rem) { .site-nav { gap: .85rem; } .site-nav a { font-size: .9rem; } }

.site-footer {
  border-top: 1px solid var(--border);
  padding: 2rem 1.5rem 3rem;
  color: var(--muted); font-size: .875rem; text-align: center;
}
.site-footer p { margin: .25rem 0; }

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

.hero { padding: 2rem 0 1rem; border-bottom: 1px solid var(--border); margin-bottom: 2rem; }
.hero h1 { font-size: 2.6rem; }
.hero h1 em { color: var(--accent); font-style: normal; }
.tagline { font-size: 1.15rem; color: var(--muted); max-width: 44rem; }
.hero-actions { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1.5rem; }
.button {
  display: inline-block; padding: .6rem 1.1rem; border-radius: var(--radius);
  background: var(--accent); color: #fff; text-decoration: none; font-weight: 600;
  font-size: .95rem; border: 1px solid var(--accent);
}
.button.secondary { background: transparent; color: var(--accent); }
.button:hover { opacity: .9; }
/* the bordeaux carries white text at ~8:1 in light mode; in dark it lightens to
   a rosé where white would fail, so the button flips to the wine-dark bg colour */
@media (prefers-color-scheme: dark) {
  .button { color: #181315; }
  .button.secondary { color: var(--accent); }
}
.more { margin-top: 1.5rem; }

/* the tagline: what the name is a pun on */
.name-note { color: var(--muted); font-size: 1.05rem; margin-top: 1.1rem; letter-spacing: .01em; }

/* --- cards / gallery ------------------------------------------------------- */

.card-grid {
  display: grid; gap: 1.25rem;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
}
.card {
  display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); text-decoration: none; color: inherit;
  overflow: hidden; transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card-figure {
  display: flex; align-items: center; justify-content: center;
  height: 11rem; padding: .75rem; background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.card-figure img { max-width: 100%; max-height: 100%; object-fit: contain; }
/* An inline svg carries its own width/height, so it needs bounding both ways to
   sit in the card. `pointer-events: none` keeps the whole card one link target
   rather than letting a drag select the diagram's label text. */
.card-figure > svg {
  max-width: 100%; max-height: 100%; height: auto; width: auto;
  pointer-events: none;
}
/* A hairline ring so a dark-backed thumbnail -- the timeline's cool slate, whose
   lightness sits within a few percent of the warm card -- keeps a crisp edge
   instead of melting into it. Invisible on a light thumbnail (it blends with the
   pale fill), it only shows where a dark diagram meets the card. Dark scheme
   only: in light mode a dark thumbnail already stands well clear. */
@media (prefers-color-scheme: dark) {
  .card-figure img,
  .card-figure > svg { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12); }
}
.card-body { padding: .9rem 1rem 1.1rem; }
.card-body p {
  margin: 0; color: var(--muted); font-size: .875rem;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.tags { margin-top: .6rem !important; display: flex; flex-wrap: wrap; gap: .3rem; }
.tags code { font-size: .72rem; padding: .1rem .35rem; }

.category h2 { display: flex; align-items: baseline; gap: .6rem; }
.category .count {
  font-size: .8rem; font-weight: 400; color: var(--muted);
  background: var(--surface-2); border-radius: 999px; padding: .1rem .6rem;
}

/* --- code ------------------------------------------------------------------ */

code {
  font-family: var(--mono); font-size: .875em;
  background: var(--surface-2); padding: .12rem .35rem; border-radius: 4px;
}
pre {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; overflow-x: auto;
  font-size: .84rem; line-height: 1.55;
}
pre code { background: none; padding: 0; font-size: inherit; }

/* Syntax highlighting for the .svgn sources, tokenised at build time by
   highlight_xml in site/build.py — there is no script on the page. Every
   colour clears AA against --code-bg in its own scheme; the tag takes the
   site's own accent, since the tag is the thing you read first. */
.tok-tag     { color: #7c2c43; }
.tok-attr    { color: #2f5d8a; }
.tok-string  { color: #3a6b3f; }
.tok-interp  { color: #8a4a1f; font-weight: 600; }
.tok-comment { color: #736669; font-style: italic; }
.tok-punct   { color: #6e6165; }
@media (prefers-color-scheme: dark) {
  .tok-tag     { color: #d98a9e; }
  .tok-attr    { color: #8ab4dd; }
  .tok-string  { color: #9dc79f; }
  .tok-interp  { color: #e0a878; }
  .tok-comment { color: #a89aa0; }
  .tok-punct   { color: #a89aa0; }
}

/* --- tutorial snippets: source beside the diagram it produces -------------- */

/* Source above, result below, rather than side by side. Half the prose column
   was too narrow for the source: 16 of the tutorial's 45 snippets had their
   code clipped, the worst by 283px, so a third of what the page is teaching sat
   behind a horizontal scroll. Stacking gives both the full width — the source
   stops clipping and the wider diagrams stop being scaled down to fit. */
.snippet {
  margin: 1.5rem 0; border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: var(--surface);
}
.snippet .snippet-source {
  margin: 0; border: 0; border-radius: 0; background: var(--code-bg);
  border-bottom: 1px solid var(--border);
}
.snippet-result {
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; background: var(--surface-2); min-height: 8rem;
}
.snippet-result img,
.snippet-result > svg { max-width: 100%; height: auto; }

/* --- prose (tutorial) ------------------------------------------------------ */

.prose { max-width: 52rem; }
/* Two levels, because the tutorial is long enough to need them: h2 is a part,
   h3 a numbered step. The step keeps the hairline rule the page has always had
   between sections; the part gets a heavier one so the groups are findable when
   scrolling. */
.prose h2 {
  font-size: 1.8rem; letter-spacing: -0.02em;
  margin-top: 4rem; padding-top: 1.75rem; border-top: 2px solid var(--accent);
}
/* both levels are link targets from the contents, and must clear the sticky header */
.prose h2, .prose h3 { scroll-margin-top: 5rem; }
.prose h2 + h3 { margin-top: 1.75rem; padding-top: 0; border-top: 0; }
.prose h3 {
  font-size: 1.3rem;
  margin-top: 3rem; padding-top: 1.25rem; border-top: 1px solid var(--border);
}
.prose ul, .prose ol { padding-left: 1.25rem; }
.prose li { margin: .3rem 0; }
.prose blockquote {
  margin: 1.25rem 0; padding: .75rem 1rem; border-left: 3px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 var(--radius) var(--radius) 0;
}
.prose blockquote p { margin: 0; }
.next-steps {
  display: flex; gap: 1.5rem; flex-wrap: wrap;
  margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--border);
}

/* --- algorithms ------------------------------------------------------------ */

.article-list { list-style: none; margin: 2rem 0 0; padding: 0; }
.article-list li { counter-increment: article; margin-bottom: 1rem; }
.article-list a {
  display: block; padding: 1.1rem 1.3rem 1.1rem 3.4rem; position: relative;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); text-decoration: none; color: inherit;
  transition: border-color .15s, transform .15s;
}
.article-list a::before {
  content: counter(article);
  position: absolute; left: 1.2rem; top: 1.15rem;
  font-family: var(--mono); font-size: .9rem; color: var(--muted);
}
.article-list a:hover { border-color: var(--accent); transform: translateY(-1px); }
.article-list h2 { margin: 0 0 .25rem; font-size: 1.15rem; }
.article-list p { margin: 0; color: var(--muted); font-size: .9rem; }
.where { font-size: .82rem; color: var(--muted); }
.where code { font-size: .95em; }
.article .where { margin-top: -.5rem; }

/* --- architecture ---------------------------------------------------------- */

.stats { display: flex; gap: .75rem; flex-wrap: wrap; margin: 1.5rem 0 2rem; }
.stat {
  display: flex; flex-direction: column; align-items: baseline; gap: .1rem;
  padding: .7rem 1.1rem; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); min-width: 8rem;
}
.stat strong { font-size: 1.5rem; line-height: 1; font-variant-numeric: tabular-nums; }
.stat span { font-size: .78rem; color: var(--muted); }
.stat.good strong { color: #2e7d4f; }
.stat.bad strong { color: #c0392b; }
@media (prefers-color-scheme: dark) {
  .stat.good strong { color: #6cc48d; }
  .stat.bad strong { color: #f08a7d; }
}
.violations {
  border: 1px solid #c0392b; background: #fff4f3;
  border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 2rem;
}
@media (prefers-color-scheme: dark) { .violations { background: #2a1a1a; } }

figure.generated {
  margin: 1.5rem 0; padding: 1.25rem; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius); text-align: center;
}
figure.generated img,
figure.generated > svg { max-width: 100%; height: auto; }
figure.generated figcaption {
  margin-top: .8rem; font-size: .8rem; color: var(--muted); font-style: italic;
}

/* --- reference ------------------------------------------------------------- */

/* Shared by the reference and the tutorial: a sticky contents beside the body.
   These pages need a wider wrap than the 62rem the prose pages use, because the
   sidebar comes out of it: at 62rem the body column was left 670px, 160px less
   than it had before the contents existed, which clipped the longer source
   lines. 15rem of nav + 2.5rem of gap + the 52rem the prose caps at, plus
   padding, is what 78rem buys. */
.wrap.wide { max-width: 78rem; }
.toc-layout { display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: 2.5rem; }
.toc { position: sticky; top: 5rem; align-self: start; max-height: 80vh; overflow-y: auto; }
.toc h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 .5rem; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin: .1rem 0; }
.toc a { display: block; padding: .2rem .4rem; border-radius: 5px; text-decoration: none; font-size: .85rem; color: var(--muted); }
.toc a:hover { background: var(--surface-2); color: var(--accent); }
.toc code { background: none; padding: 0; font-size: .85em; }
/* Two levels in the tutorial's contents: a part, and the steps under it. The
   part is the findable thing when scanning, so it carries the weight. */
.toc-l2 a { color: var(--text); font-weight: 600; margin-top: .5rem; }
.toc-l3 a { padding-left: 1rem; }
.toc-l2:first-child a { margin-top: 0; }

.ref-entry { scroll-margin-top: 5rem; padding-bottom: 1rem; }
.ref-entry h2 { margin-top: 2rem; }
.ref-entry h2 .anchor { text-decoration: none; color: var(--text); }
.ref-entry h2 .anchor:hover { color: var(--accent); }
.ref-entry table { border-collapse: collapse; width: 100%; font-size: .9rem; display: block; overflow-x: auto; }
.ref-entry th, .ref-entry td { border: 1px solid var(--border); padding: .4rem .6rem; text-align: left; }
.ref-entry th { background: var(--surface-2); }

/* Two columns only where both fit. Below this the sidebar would be taking its
   15rem out of a body column that has none to spare, so it goes on top instead
   and the body gets the whole width. */
@media (max-width: 78rem) {
  .toc-layout { grid-template-columns: 1fr; }
  /* Stacked above the body, so it is bounded rather than free to run: the
     tutorial's 57 entries would otherwise be a screen and a half of links
     between the lede and step 1. */
  .toc { position: static; max-height: 40vh; }
}

/* --- example page ---------------------------------------------------------- */

.breadcrumb { margin: 0 0 1rem; font-size: .9rem; }
.breadcrumb a { text-decoration: none; }
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; margin: 0 0 1.5rem; }
.pill {
  background: var(--accent-soft); color: var(--accent); font-size: .75rem;
  font-weight: 600; padding: .15rem .6rem; border-radius: 999px;
}
.dims { color: var(--muted); font-size: .8rem; font-family: var(--mono); }
.meta code { font-size: .75rem; }
.result {
  margin: 0; padding: 1.5rem; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; justify-content: center; overflow-x: auto;
}
.result img { max-width: 100%; height: auto; }
/* The example pages inline their diagram rather than linking it, so its text is
   set in the same webfont as the page -- an <img> is its own document and a
   webfont cannot reach inside one. The svg carries width/height, so it needs
   the same climb-down as an img to stay inside a narrow viewport. */
.result > svg { max-width: 100%; height: auto; }
.filename { font-family: var(--mono); font-size: .8rem; font-weight: 400; color: var(--muted); }
.downloads { font-size: .9rem; }
.pager {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--border);
  font-size: .9rem;
}
.pager .next { margin-left: auto; text-align: right; }

/* --- algorithms: families of technique ------------------------------------- */

.algorithms { counter-reset: article; }   /* the numbering runs across the parts */
.algorithms .part { margin-top: 3rem; scroll-margin-top: 5rem; }  /* sticky header */
.algorithms .part-title {
  font-size: 1.35rem; letter-spacing: -0.01em;
  padding-bottom: .5rem; border-bottom: 1px solid var(--border);
}
.algorithms .part-blurb { color: var(--muted); max-width: 46rem; margin-top: .6rem; }
.algorithms .article-list h3 { font-size: 1.05rem; margin: 0; }

/* the rest of each family: name, honest status, gloss */
.field { margin: 1.75rem 0 0; }
.field::before {
  content: "The rest of the family";
  display: block; margin-top: 2.5rem;
  font-size: .8rem; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted);
}
.field dt {
  display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap;
  font-weight: 600; margin-top: 1.1rem;
}
.field dd { margin: .2rem 0 0; color: var(--muted); max-width: 46rem; }
.field dd code { font-size: .8em; }
.status {
  font-size: .7rem; font-weight: 600; letter-spacing: .02em; text-transform: uppercase;
  padding: .12rem .5rem; border-radius: 999px; white-space: nowrap;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--muted);
}
.status-yes { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
