/* ===========================================================================
   Design tokens
   ---------------------------------------------------------------------------
   The whole site uses THREE colours: ink, paper, accent.
   Everything else is one of those three at a different opacity.
   Change these three values and the entire site re-skins itself.
   ========================================================================= */

:root {
  /* 1 — ink: text and dark surfaces */
  --ink: #15181c;
  /* 2 — paper: page background and light surfaces */
  --paper: #faf8f4;
  /* 3 — accent: links, highlights, calls to action */
  --accent: #14635c;

  /* Derived (same three colours, different opacity — no new hues) */
  --ink-90: color-mix(in srgb, var(--ink) 90%, transparent);
  --ink-70: color-mix(in srgb, var(--ink) 70%, transparent);
  --ink-64: color-mix(in srgb, var(--ink) 64%, transparent);
  --ink-22: color-mix(in srgb, var(--ink) 22%, transparent);
  --ink-14: color-mix(in srgb, var(--ink) 14%, transparent);
  --ink-10: color-mix(in srgb, var(--ink) 10%, transparent);
  --ink-08: color-mix(in srgb, var(--ink) 8%, transparent);
  --ink-04: color-mix(in srgb, var(--ink) 4%, transparent);
  --accent-12: color-mix(in srgb, var(--accent) 12%, transparent);
  --accent-30: color-mix(in srgb, var(--accent) 30%, transparent);
  --on-accent: var(--paper);

  /* Type */
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  /* Fluid type scale */
  --step--1: clamp(0.83rem, 0.79rem + 0.18vw, 0.92rem);
  --step-0: clamp(1rem, 0.96rem + 0.2vw, 1.09rem);
  --step-1: clamp(1.2rem, 1.12rem + 0.38vw, 1.42rem);
  --step-2: clamp(1.44rem, 1.3rem + 0.7vw, 1.9rem);
  --step-3: clamp(1.73rem, 1.48rem + 1.2vw, 2.55rem);
  --step-4: clamp(2.07rem, 1.66rem + 2vw, 3.4rem);

  /* Space & shape */
  --measure: 68ch;
  --gutter: clamp(1.15rem, 0.7rem + 2.2vw, 2.5rem);
  --section-y: clamp(3.5rem, 2rem + 6vw, 7rem);
  --radius: 4px;
  --radius-lg: 8px;
  --border: 1px solid var(--ink-14);
  --shadow: 0 1px 2px color-mix(in srgb, var(--ink) 5%, transparent),
            0 12px 28px -18px color-mix(in srgb, var(--ink) 30%, transparent);
}

/* Dark mode: the same three colours, with ink and paper swapping roles. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #f1efe9;
    --paper: #14171b;
    --accent: #219ec4;
    --on-accent: #0a2d38;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 28px -18px rgba(0, 0, 0, 0.8);
  }
}

:root[data-theme="dark"] {
  --ink: #f1efe9;
  --paper: #14171b;
  --accent: #219ec4;
  --on-accent: #0a2d38;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 28px -18px rgba(0, 0, 0, 0.8);
}

/* ===========================================================================
   Reset & base
   ========================================================================= */

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

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 6rem;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

img, svg, video { display: block; max-width: 100%; height: auto; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-3); }
h3 { font-size: var(--step-1); }
h4 { font-size: var(--step-0); }

p, li { text-wrap: pretty; }

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
}

a:hover { text-decoration-thickness: 2px; }

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

::selection { background: var(--accent-30); }

/* Text for screen readers only. */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

hr {
  border: 0;
  border-top: var(--border);
  margin: 2.5rem 0;
}

code, kbd, samp {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--ink-08);
  padding: 0.1em 0.35em;
  border-radius: 3px;
}

/* ===========================================================================
   Layout helpers
   ========================================================================= */

.wrap {
  width: min(100% - (var(--gutter) * 2), 1140px);
  margin-inline: auto;
}

.wrap--narrow { width: min(100% - (var(--gutter) * 2), 780px); }
.wrap--wide { width: min(100% - (var(--gutter) * 2), 1280px); }

.section { padding-block: var(--section-y); }
.section--tight { padding-block: clamp(2.5rem, 1.5rem + 4vw, 4.5rem); }
.section--alt { background: var(--ink-04); border-block: var(--border); }

.stack > * + * { margin-top: 1.1rem; }
.stack-lg > * + * { margin-top: 2rem; }

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -4rem;
  z-index: 100;
  background: var(--accent);
  color: var(--on-accent);
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  transition: top 0.15s ease;
}
.skip-link:focus { top: 0.5rem; }

main { flex: 1; }

/* ===========================================================================
   Eyebrow / section headings
   ========================================================================= */

.eyebrow {
  font-family: var(--font-body);
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.85rem;
  display: block;
}

.lede {
  font-size: var(--step-1);
  line-height: 1.5;
  color: var(--ink-70);
  max-width: var(--measure);
}

.section-head {
  max-width: var(--measure);
  margin-bottom: clamp(2rem, 1rem + 3vw, 3.25rem);
}

.section-head > p { color: var(--ink-70); margin-top: 0.9rem; }

/* ===========================================================================
   Header & navigation
   ========================================================================= */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: var(--border);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.25rem;
  position: relative;
}

.brand { order: 1; }

.brand {
  font-family: var(--font-display);
  font-size: var(--step-1);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  white-space: nowrap;
}

.brand::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
  transform: translateY(-0.15em);
}

.nav { display: flex; align-items: center; gap: 0.35rem; order: 2; }

/* :not(.btn) matters — a bare `.nav a` selector outranks `.btn--primary` and
   would repaint the call to action with the plain link's colour and padding. */
.nav a:not(.btn) {
  color: var(--ink-70);
  text-decoration: none;
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: 0.01em;
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius);
  white-space: nowrap;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.nav a:not(.btn):hover { color: var(--ink); background: var(--ink-08); }

/* The button already reads as the destination, so it keeps its own styling —
   it still gets aria-current in the markup for screen readers and keyboard users. */
.nav a[aria-current="page"]:not(.btn) {
  color: var(--ink);
  font-weight: 650;
  background: var(--accent-12);
}

.nav .btn { margin-left: 0.4rem; }

/* --- Language switcher ------------------------------------------------- */

.site-header__controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  order: 3;
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 2px;
  border: var(--border);
  border-radius: var(--radius);
  background: var(--ink-04);
}

.lang-switch__link {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  line-height: 1;
  color: var(--ink-64);
  text-decoration: none;
  padding: 0.42rem 0.5rem;
  border-radius: 2px;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.lang-switch__link:hover { color: var(--ink); background: var(--ink-08); }

.lang-switch__link[aria-current="true"] {
  color: var(--on-accent);
  background: var(--accent);
}

/* Phones and tablets: the menu stays in sight as tiles under the name, with
   the same links as on desktop. The tiles share each row and wrap onto a
   second row when the screen is too narrow, so every link is always shown. */
@media (max-width: 860px) {
  .site-header__inner {
    flex-wrap: wrap;
    row-gap: 0;
    min-height: 0;
    padding-block: 0.5rem 0.5rem;
  }

  .brand { font-size: 1.1rem; }

  .nav {
    order: 4;
    flex: 1 0 100%;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-top: 0.45rem;
  }

  .nav a:not(.btn),
  .nav .btn {
    flex: 1 0 auto;
    justify-content: center;
    text-align: center;
    margin: 0;
    padding: 0.4rem 0.55rem;
    font-size: 0.8125rem;
    line-height: 1.2;
  }
  .nav a:not(.btn) { background: var(--ink-04); border: var(--border); }
}

/* ===========================================================================
   Buttons
   ========================================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font: inherit;
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn--primary { background: var(--accent); color: var(--on-accent); }
.btn--primary:hover { background: color-mix(in srgb, var(--accent) 86%, var(--ink)); }

.btn--ghost { border-color: var(--ink-14); color: var(--ink); background: transparent; }
.btn--ghost:hover { border-color: var(--ink); background: var(--ink-04); }

.btn--wide { width: 100%; justify-content: center; }

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.arrow-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  font-size: var(--step--1);
  text-decoration: none;
  border-bottom: 1px solid var(--accent-30);
  padding-bottom: 2px;
}

.arrow-link:hover { border-bottom-color: var(--accent); }

/* The root 404 page answers for every language (see src/pages/en/404.html). */
.notfound-langs {
  display: grid;
  gap: 1.25rem;
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--ink-14);
  text-align: left;
}
.notfound-lang p { margin-bottom: 0.5rem; color: var(--ink-70); }
@media (min-width: 640px) { .notfound-langs { grid-template-columns: 1fr 1fr; gap: 2rem; } }
.arrow-link::after { content: "→"; transition: transform 0.15s ease; }
.arrow-link:hover::after { transform: translateX(3px); }

/* ===========================================================================
   Hero (landing page)
   ========================================================================= */

.hero { padding-block: clamp(3.5rem, 2rem + 8vw, 8rem) clamp(3rem, 2rem + 5vw, 6rem); }

.hero__grid {
  display: grid;
  gap: clamp(2.5rem, 1rem + 5vw, 4.5rem);
  align-items: center;
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .hero__grid { grid-template-columns: 1.15fr 0.85fr; }
}

.hero h1 { margin-bottom: 1.25rem; }
.hero .lede { margin-bottom: 2rem; }

.hero__proof {
  margin-top: 2.75rem;
  padding-top: 1.75rem;
  border-top: var(--border);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1.5rem;
}

.stat__value {
  font-family: var(--font-display);
  font-size: var(--step-2);
  line-height: 1;
  display: block;
  margin-bottom: 0.4rem;
}

.stat__label {
  font-size: var(--step--1);
  color: var(--ink-64);
  line-height: 1.4;
}

.hero__portrait {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: var(--border);
  background: var(--ink-04);
  aspect-ratio: 4 / 5;
}

.hero__portrait img { width: 100%; height: 100%; object-fit: cover; }

/* ===========================================================================
   Cards & grids
   ========================================================================= */

.grid {
  display: grid;
  gap: clamp(1.25rem, 0.8rem + 1.6vw, 2rem);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
}

.grid--2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); }
.grid--half { grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); }

.card {
  background: var(--paper);
  border: var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(1.4rem, 1rem + 1.2vw, 2rem);
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.card--hover:hover {
  border-color: var(--accent-30);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.card__number {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--accent);
  letter-spacing: 0.08em;
  background: none;
  padding: 0;
}

.card p { color: var(--ink-70); }

/* Keep calls to action aligned along the bottom of a row of cards — but leave
   plain text where it falls, so text-only cards do not drift apart. */
.card > a:last-child,
.card > .btn-row:last-child,
.card > p:last-child:has(> a.arrow-link) { margin-top: auto; }

.service-card h3 { display: flex; align-items: baseline; gap: 0.6rem; }

/* ===========================================================================
   About — alternating photo / text rows
   ========================================================================= */

.about-row {
  display: grid;
  gap: clamp(1.75rem, 1rem + 3vw, 3.5rem);
  align-items: center;
  grid-template-columns: 1fr;
  padding-block: clamp(2rem, 1.2rem + 3vw, 3.5rem);
}

.about-row + .about-row { border-top: var(--border); }

@media (min-width: 820px) {
  /* Odd rows: photo left, text right. Even rows: the other way round.
     The column proportions flip too, so the text always gets the wider side. */
  .about-row { grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr); }

  .about-row:nth-child(even) { grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr); }
  .about-row:nth-child(even) .about-row__media { order: 2; }
  .about-row:nth-child(even) .about-row__text { order: 1; }
}

.about-row__text h2 { margin-bottom: 1rem; font-size: var(--step-2); }
.about-row__text p + p { margin-top: 1rem; }
.about-row__text p { color: var(--ink-70); max-width: 60ch; }

figure { margin: 0; }

.photo {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: var(--border);
  background: var(--ink-04);
  aspect-ratio: 4 / 3;
}

.photo img { width: 100%; height: 100%; object-fit: cover; }

/* Visible label on AI-generated images, modelled on the EU icon from the
   Commission's Code of Practice on marking and labelling AI-generated content
   (the acronym "AI" plus "GENERATED", high contrast). Fixed colours on
   purpose: it sits on top of the image in both light and dark mode. Screen
   readers get the full sentence from the hidden text inside. */
.ai-label {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  display: inline-flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem;
  border-radius: 0.4rem;
  background: rgb(21 24 28 / 0.86);
  box-shadow: 0 0 0 1px rgb(250 248 244 / 0.35); /* stays visible on dark photos */
  color: #faf8f4;
  font: 700 0.68rem/1 var(--font-body);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.ai-label b { font-size: 0.95rem; letter-spacing: 0.04em; }
@media (max-width: 640px) {
  .ai-label { top: 0.5rem; left: 0.5rem; padding: 0.28rem 0.45rem; font-size: 0.6rem; }
  .ai-label b { font-size: 0.8rem; }
}

.photo--portrait { aspect-ratio: 3 / 4; }
.photo--square { aspect-ratio: 1 / 1; }

/* The italic caption under every photo. */
figcaption {
  font-style: italic;
  font-size: var(--step--1);
  line-height: 1.5;
  color: var(--ink-64);
  margin-top: 0.7rem;
  padding-left: 0.85rem;
  border-left: 2px solid var(--accent-30);
}

/* ===========================================================================
   About — fact tiles: title on the face, detail revealed in place
   ========================================================================= */

.facts {
  display: grid;
  gap: clamp(1rem, 0.6rem + 1.4vw, 1.75rem);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}

.fact {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 10rem;
  padding: 1.75rem 2rem;
  text-align: center;
  background: var(--paper);
  border: 2px solid var(--ink-14);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: default;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Both faces sit in the same grid cell, so the tile is always as tall as the
   larger of the two — swapping them can never change its size. */
.fact > * {
  grid-area: 1 / 1;
  margin: 0;
  transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.fact__title { font-size: var(--step-2); }

.fact__body {
  color: var(--ink-70);
  max-width: 30ch;
  opacity: 0;
  transform: translateY(0.75rem);
}

/* A small "+" says the tile has more to show; it turns into an "x" when open. */
.fact::after {
  content: "+";
  position: absolute;
  top: 0.6rem;
  right: 0.9rem;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--accent);
  transition: transform 0.3s ease;
}

.fact:is(:focus-visible, .is-open) { border-color: var(--accent); box-shadow: var(--shadow); }
.fact:is(:focus-visible, .is-open) .fact__title { opacity: 0; transform: translateY(-0.75rem); }
.fact:is(:focus-visible, .is-open) .fact__body { opacity: 1; transform: none; }
.fact:is(:focus-visible, .is-open)::after { transform: rotate(45deg); }

/* Hover only where a real pointer exists: on touch screens hover "sticks"
   after a tap, so phones and tablets toggle .is-open from site.js instead. */
@media (hover: hover) {
  .fact:hover { border-color: var(--accent); box-shadow: var(--shadow); }
  .fact:hover .fact__title { opacity: 0; transform: translateY(-0.75rem); }
  .fact:hover .fact__body { opacity: 1; transform: none; }
  .fact:hover::after { transform: rotate(45deg); }
}

.facts-hint--touch { display: none; }

@media (hover: none) {
  .facts-hint--pointer { display: none; }
  .facts-hint--touch { display: inline; }
  .fact { cursor: pointer; }
}

/* ===========================================================================
   Prose (articles)
   ========================================================================= */

.prose { max-width: var(--measure); }
.prose > * + * { margin-top: 1.15rem; }

.prose h2 {
  font-size: var(--step-2);
  margin-top: 3rem;
  padding-top: 0.5rem;
  scroll-margin-top: 6rem;
}

.prose h3 {
  font-size: var(--step-1);
  margin-top: 2.25rem;
  scroll-margin-top: 6rem;
}

/* On phones the header has a second row (the menu), so jumps to a heading
   stop lower, clear of it. */
@media (max-width: 860px) {
  .prose :is(h2, h3) { scroll-margin-top: 8rem; }
}

.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li + li { margin-top: 0.5rem; }
.prose li::marker { color: var(--accent); }

.prose strong { font-weight: 650; }

.prose blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1.25rem;
  font-style: italic;
  color: var(--ink-70);
}

.prose figure { margin-block: 2rem; }

/* One line under the article meta: what the text takes into account. */
.article-note {
  margin-top: 0.85rem;
  font-size: var(--step--1);
  line-height: 1.55;
  color: var(--ink-64);
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  font-size: var(--step--1);
  color: var(--ink-64);
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: var(--border);
}

/* Table of contents */
.toc {
  border: var(--border);
  border-radius: var(--radius-lg);
  padding: 1.35rem 1.5rem;
  background: var(--ink-04);
}

.toc h2 {
  font-size: var(--step--1);
  font-family: var(--font-body);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-64);
  margin: 0 0 0.85rem;
  padding: 0;
}

.toc ol { margin: 0; padding-left: 1.1rem; }
.toc li + li { margin-top: 0.35rem; }
.toc a { font-size: var(--step--1); text-decoration: none; }
.toc a:hover { text-decoration: underline; }

/* Wide screens: the table of contents moves into a sticky rail beside the
   article and marks the section being read (site.js). The rail keeps its own
   strip of the page: tables start at the text's left edge and grow to the
   right only, so nothing ever slides underneath it.
   The rail, the text column and the reach of the widest tables are centred
   together as one block, so the space left of the rail matches the space
   right of the widest table. The page title moves with the text, and the rail
   is only as wide as its longest entry. */
@media (min-width: 1360px) {
  main:has(.toc-rail) {
    --rail-w: 12rem;     /* typical rail width, used for centring */
    --rail-gap: 2.5rem;  /* rail to text */
    --reach: 24rem;      /* how far the widest tables extend past the text */
    /* Left edge of the text: the block is (rail + gap + 780px column + reach)
       wide, centred, and never closer to the window edge than the gutter. */
    --text-left: calc(max(var(--gutter), (100vw - var(--rail-w) - var(--rail-gap) - 780px - var(--reach)) / 2) + var(--rail-w) + var(--rail-gap));
  }
  main:has(.toc-rail) .page-header > .wrap,
  .prose:has(> .toc-rail) { margin-left: var(--text-left); margin-right: auto; }
  .prose:has(> .toc-rail) { position: relative; }
  .toc-rail {
    position: absolute;
    top: 0;
    bottom: 0;
    right: calc(100% + var(--rail-gap));
    width: max-content;
    max-width: 14.5rem;
  }
  .toc-rail .toc {
    position: sticky;
    top: 6.5rem;
    max-height: calc(100vh - 8.5rem);
    overflow-y: auto;
    padding: 0;
    border: 0;
    background: none;
  }
  .toc-rail .toc ol { list-style: none; padding: 0; border-left: 2px solid var(--ink-14); }
  .toc-rail .toc li + li { margin-top: 0; }
  .toc-rail .toc a {
    display: block;
    margin-left: -2px;
    padding: 0.32rem 0 0.32rem 0.9rem;
    border-left: 2px solid transparent;
    color: var(--ink-70);
    line-height: 1.35;
  }
  .toc-rail .toc a:hover { color: var(--ink); text-decoration: none; border-left-color: var(--ink-22); }
  .toc-rail .toc a.is-current { color: var(--accent); font-weight: 600; border-left-color: var(--accent); }

  /* 100vw - gutter - text-left is the room between the text's left edge and
     the right edge of the window. */
  .prose:has(> .toc-rail) :is(.table-wrap, .table-note--wide) {
    --table-width: min(100% + 14rem, 100vw - var(--gutter) - var(--text-left));
    margin-inline: 0;
  }
  .prose:has(> .toc-rail) :is(.table-wrap--wide, .table-note--wide) {
    --table-width: min(100% + var(--reach), 100vw - var(--gutter) - var(--text-left));
  }
}

/* Between 1360 and 1600 px the rail leaves the widest results table a little
   less room, so its cells get tighter padding instead of a scrollbar. */
@media (min-width: 1360px) and (max-width: 1599px) {
  .prose:has(> .toc-rail) .table--dense :is(th, td) { padding-inline: 0.6rem; }
  .prose:has(> .toc-rail) .table--dense .quote { min-width: 11rem; }
}

/* Callout boxes */
.callout {
  border: var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent-12);
  padding: 1.25rem 1.4rem;
  font-size: var(--step--1);
  line-height: 1.6;
}

.callout--plain { background: var(--ink-04); border-left-color: var(--ink-64); }

.callout__title {
  display: block;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.78rem;
  margin-bottom: 0.5rem;
  color: var(--accent);
}

.callout--plain .callout__title { color: var(--ink-64); }
.callout p + p { margin-top: 0.7rem; }
.callout ul { margin: 0.6rem 0 0; padding-left: 1.15rem; }
.callout li + li { margin-top: 0.35rem; }

/* Collapsible extra detail inside an article, e.g. the full obligations table. */
.details {
  border: var(--border);
  border-radius: var(--radius-lg);
  padding: 0.9rem 1.2rem;
}
.details > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
}
.details > summary:hover { text-decoration: underline; }
.details[open] > summary { margin-bottom: 0.5rem; }
/* A table inside the box stays inside it instead of widening into the margins. */
.prose .details .table-wrap,
.prose:has(> .toc-rail) .details .table-wrap {
  --table-width: 100%;
  width: 100%;
  margin-inline: 0;
  margin-block: 1rem 0.3rem;
}

/* ===========================================================================
   Tables
   ========================================================================= */

.table-wrap {
  overflow-x: auto;
  border: 2px solid var(--ink-14);
  border-radius: var(--radius-lg);
  margin-block: 2rem;
  -webkit-overflow-scrolling: touch;
}

/* Inside an article the reading column is deliberately narrow, but tables need
   room. These widen symmetrically out of the column, up to the viewport. */
.prose .table-wrap {
  --table-width: min(100% + 14rem, 100vw - (var(--gutter) * 2));
  width: var(--table-width);
  margin-inline: calc((100% - var(--table-width)) / 2);
}

/* For matrices with many short columns, such as the image-marking results. */
.prose .table-wrap--wide { --table-width: min(100% + 24rem, 100vw - (var(--gutter) * 2)); }
.table-wrap--wide table { min-width: 50rem; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--step--1);
  min-width: 34rem;
}

caption {
  caption-side: top;
  text-align: left;
  padding: 1.1rem 1.35rem;
  font-size: var(--step--1);
  color: var(--ink-64);
  font-style: italic;
  border-bottom: 1px solid var(--ink-14);
}

th, td {
  padding: 0.9rem 1.35rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--ink-10);
}

thead th {
  background: var(--ink-04);
  font-weight: 650;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-70);
  white-space: nowrap;
  border-bottom: 2px solid var(--ink-22);
}

tbody tr:last-child :is(th, td) { border-bottom: 0; }
tbody tr:hover { background: var(--ink-04); }

td.num, th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Results tables: short values, so every cell is centred on both axes and
   columns get a light rule between them. Prose tables keep left alignment,
   because centred paragraphs are hard to read. */
.table--data :is(th, td),
.table--data :is(th, td).num {
  text-align: center;
  vertical-align: middle;
  padding: 0.95rem 1.1rem;
}

.table--data :is(th, td) + :is(th, td) { border-left: 1px solid var(--ink-10); }
.table--data tbody th { font-weight: 600; }

/* Row groups (one per tested system) are separated by a heavier rule. */
.table--data tbody + tbody { border-top: 2px solid var(--ink-22); }

.table--data .bar { justify-content: center; max-width: 13rem; margin-inline: auto; }

/* Many short columns: headers wrap onto two lines instead of pushing the
   table wider than the page, and the verbatim-quote column gets real room. */
.table--data thead th { white-space: normal; text-wrap: balance; }
.table--data .quote { min-width: 13rem; }
.table--dense :is(th, td) { padding-inline: 0.85rem; }

/* A footnote that explains a mark in the table directly above it. */
.table-note {
  font-size: var(--step--1);
  line-height: 1.55;
  color: var(--ink-70);
  padding-inline: 1.35rem;
}

.prose .table-note { margin-top: -1rem; }

.prose .table-note--wide {
  --table-width: min(100% + 24rem, 100vw - (var(--gutter) * 2));
  width: var(--table-width);
  margin-inline: calc((100% - var(--table-width)) / 2);
}

/* Two-column "item / reason" tables: keep the item column narrow. */
.table--reasons tbody th { width: 34%; }

/* Tables keyed by a date or period: keep "2 Dec 2027" or "Q1 2027" on one line. */
.table--when tbody th { white-space: nowrap; }

/* Grouped results (image marking): one row group per generator, one row per
   check and one column per place, so every cell holds a single result. */
.table--data.table--grouped :is(th, td) { padding: 0.5rem 0.75rem; }
.table--data.table--grouped tbody th { text-align: left; }
.table--data.table--grouped tbody th[scope="row"] { font-weight: 500; color: var(--ink-70); }
.table--data.table--grouped tbody th[scope="rowgroup"] { vertical-align: top; padding-top: 0.7rem; }
.table--grouped .file-id { white-space: normal; }
.matrix__note { display: block; margin-top: 0.3rem; font-weight: 400; font-size: 0.78rem; color: var(--ink-70); }

/* When it scrolls sideways on a phone, both the generator and the check stay
   in view. */
.table-wrap .table--grouped tbody th[scope="rowgroup"] {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 7rem;
  min-width: 7rem;
  background-color: var(--paper);
  box-shadow: inset -1px 0 0 var(--ink-10);
}
.table-wrap .table--grouped thead th:nth-child(2),
.table-wrap .table--grouped tbody th[scope="row"] {
  position: sticky;
  left: 7rem;
  z-index: 1;
  min-width: 0;
  max-width: none;
  background-color: var(--paper);
}
.table-wrap .table--grouped thead th:nth-child(2) { background-image: linear-gradient(var(--ink-04), var(--ink-04)); }
@media (max-width: 640px) {
  .table-wrap .table--grouped tbody th[scope="rowgroup"] { width: 5.75rem; min-width: 5.75rem; }
  .table-wrap .table--grouped :is(thead th:nth-child(2), tbody th[scope="row"]) { left: 5.75rem; max-width: 6.5rem; }
}

/* A table wider than the screen scrolls sideways inside .table-wrap. Its
   first column (what each row is about) and its caption stay in view while
   the rest scrolls, and site.js makes the wrapper focusable so it can be
   scrolled from the keyboard too. On a wide screen nothing scrolls and none
   of this changes anything. */
.table-wrap :is(thead th:first-child, tbody th[scope="row"]) {
  position: sticky;
  left: 0;
  z-index: 1;
  background-color: var(--paper);
  box-shadow: inset -1px 0 0 var(--ink-10);
}
.table-wrap thead th:first-child,
.table-wrap tbody tr:hover th[scope="row"] { background-image: linear-gradient(var(--ink-04), var(--ink-04)); }
.table-wrap caption { position: sticky; left: 0; max-width: var(--table-width, calc(100vw - var(--gutter) * 2)); }

@media (max-width: 640px) {
  .table-wrap tbody th[scope="row"] { min-width: 7rem; max-width: 9.5rem; }
}

/* Phones: results tables marked .table--cards show one card per row instead
   of scrolling. Each cell's column name comes from data-label, which the
   build adds together with explicit table roles, so screen readers still
   hear a table after CSS changes how it is displayed. */
@media (max-width: 640px) {
  .table-wrap .table--cards { min-width: 0; }
  .table--cards,
  .table--cards :is(caption, thead, tbody, tr, th, td) { display: block; }
  .table--cards caption { position: static; max-width: none; }
  .table--cards thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .table--cards tbody tr { padding: 1rem 1.15rem 1.1rem; }
  .table--cards tbody tr + tr { border-top: 2px solid var(--ink-14); }
  .table--cards tbody tr:hover { background: none; }
  /* Specific enough to undo the sticky first column and the centred cells. */
  .table-wrap .table--cards tbody tr :is(th[scope="row"], td),
  .table-wrap .table--cards tbody tr :is(th, td) + :is(th, td) {
    position: static;
    min-width: 0;
    max-width: none;
    padding: 0.3rem 0;
    border: 0;
    box-shadow: none;
    background: none;
    text-align: left;
  }
  .table-wrap .table--cards tbody tr th[scope="row"] { font-size: var(--step-0); padding-bottom: 0.55rem; }
  .table--cards tbody td {
    display: grid;
    grid-template-columns: minmax(6.5rem, 38%) 1fr;
    gap: 0.75rem;
    align-items: baseline;
  }
  .table--cards tbody td::before {
    content: attr(data-label);
    content: attr(data-label) / "";
    font-size: 0.72rem;
    font-weight: 650;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--ink-70);
  }
  .table--cards .quote { min-width: 0; }
}

.file-id {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
}

.score {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* The exact prompt a test used, shown directly above its results. */
.prompt {
  border: 2px solid var(--ink-14);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--ink-04);
  padding: 1.1rem 1.35rem 1.2rem;
  margin: 1.75rem 0 0;
}

.prompt__label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.45rem;
}

.prompt__text {
  font-family: var(--font-display);
  font-size: var(--step-1);
  line-height: 1.45;
  color: var(--ink);
  margin: 0;
  quotes: none;
}

/* The prompt belongs to the table under it, so they sit closer together. */
.prompt + .table-wrap { margin-top: 1rem; }

.tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--ink-14);
  color: var(--ink-70);
  white-space: nowrap;
}

.tag--pass { border-color: var(--accent); color: var(--accent); background: var(--accent-12); }
.tag--fail { border-color: var(--ink-64); color: var(--ink); background: var(--ink-08); }
/* The next date still ahead in a timeline: outlined in the accent, not filled. */
.tag--next { border-color: var(--accent); color: var(--accent); }

/* Simple bar used in results tables — no chart library needed. */
.bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 8rem;
}

.bar__track {
  flex: 1;
  height: 6px;
  background: var(--ink-08);
  border-radius: 999px;
  overflow: hidden;
}

.bar__fill { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

.bar__value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
  color: var(--ink-70);
  min-width: 2.75rem;
  text-align: right;
}

/* ===========================================================================
   Project lists (42 / LLM Harness Eval)
   ========================================================================= */

.project {
  display: grid;
  gap: 0.4rem 1.75rem;
  padding-block: 1.75rem;
  border-top: var(--border);
  grid-template-columns: 1fr;
  align-items: start;
}

@media (min-width: 760px) {
  .project { grid-template-columns: minmax(0, 13rem) minmax(0, 1fr); }
}

.project:last-child { border-bottom: var(--border); }

.project__head { display: flex; flex-direction: column; gap: 0.5rem; }
.project__title { font-size: var(--step-1); margin: 0; }
.project__meta {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  color: var(--ink-64);
  text-transform: uppercase;
}

.project__body > p { color: var(--ink-70); }
.project__body > * + * { margin-top: 0.9rem; }

/* The rest of a project list in brief: name, tag line, one or two sentences. */
.section-head--sub { margin-top: clamp(3rem, 2rem + 3vw, 4.5rem); }
.projects-compact {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
}
.project-mini {
  border: var(--border);
  border-radius: var(--radius-lg);
  padding: 1.15rem 1.3rem 1.25rem;
  background: var(--paper);
}
.project-mini__title { font-size: var(--step-0); margin: 0 0 0.35rem; }
.project-mini p:not(.project__meta) { margin-top: 0.6rem; font-size: var(--step--1); line-height: 1.6; color: var(--ink-70); }

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.chip {
  font-size: 0.74rem;
  font-family: var(--font-mono);
  letter-spacing: 0.03em;
  color: var(--ink-70);
  background: var(--ink-08);
  border-radius: 999px;
  padding: 0.22rem 0.6rem;
}

.repo-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: var(--step--1);
  font-weight: 600;
  text-decoration: none;
  font-family: var(--font-mono);
}

.repo-link:hover { text-decoration: underline; text-underline-offset: 0.25em; }
.repo-link svg { width: 1em; height: 1em; flex: none; }

/* ===========================================================================
   Contact
   ========================================================================= */

.contact-grid {
  display: grid;
  gap: clamp(2rem, 1rem + 4vw, 4rem);
  grid-template-columns: 1fr;
  align-items: start;
}

@media (min-width: 900px) {
  .contact-grid { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); }
}

.contact-details { display: grid; gap: 1.5rem; }

.contact-item { display: grid; gap: 0.2rem; }

.contact-item__label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-64);
}

.contact-item a { font-weight: 500; word-break: break-word; }

.form { display: grid; gap: 1.15rem; }

.field { display: grid; gap: 0.4rem; }

.field label {
  font-size: var(--step--1);
  font-weight: 600;
}

.field .hint { font-size: 0.78rem; color: var(--ink-64); font-weight: 400; }

.field input,
.field select,
.field textarea {
  font: inherit;
  font-size: var(--step-0);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--ink-14);
  border-radius: var(--radius);
  padding: 0.7rem 0.85rem;
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field textarea { min-height: 9rem; resize: vertical; }

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-12);
}

.field input::placeholder,
.field textarea::placeholder { color: var(--ink-64); }

.field--inline {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
}

.field--inline input { width: auto; margin-top: 0.3rem; flex: none; }
.field--inline label { font-weight: 400; font-size: var(--step--1); color: var(--ink-70); }

/* Honeypot — hidden from people, tempting to bots. */
.hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.form__status {
  font-size: var(--step--1);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  border: var(--border);
  background: var(--ink-04);
}

.form__status[hidden] { display: none; }
.form__status[data-state="ok"] { border-color: var(--accent); background: var(--accent-12); color: var(--ink); }
.form__status[data-state="error"] { border-color: var(--ink-64); }

/* ===========================================================================
   CTA band & footer
   ========================================================================= */

.cta-band {
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius-lg);
  padding: clamp(2rem, 1.2rem + 3vw, 3.5rem);
  display: grid;
  gap: 1.75rem;
  align-items: center;
}

@media (min-width: 820px) {
  .cta-band { grid-template-columns: 1.4fr auto; }
}

.cta-band h2 { color: var(--paper); font-size: var(--step-2); }
.cta-band p { color: color-mix(in srgb, var(--paper) 72%, transparent); margin-top: 0.75rem; max-width: 52ch; }
.cta-band .btn--primary { background: var(--paper); color: var(--ink); }
.cta-band .btn--primary:hover { background: color-mix(in srgb, var(--paper) 88%, var(--accent)); }
.cta-band .btn--ghost { color: var(--paper); border-color: color-mix(in srgb, var(--paper) 35%, transparent); }
.cta-band .btn--ghost:hover { background: color-mix(in srgb, var(--paper) 12%, transparent); border-color: var(--paper); }

.site-footer {
  border-top: var(--border);
  padding-block: 2.5rem;
  margin-top: var(--section-y);
  font-size: var(--step--1);
  color: var(--ink-64);
}

.site-footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  align-items: center;
  justify-content: space-between;
}

.site-footer a { color: var(--ink-70); text-decoration: none; }
.site-footer a:hover { color: var(--accent); text-decoration: underline; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 1.25rem; }

/* ===========================================================================
   Page header (inner pages)
   ========================================================================= */

.page-header {
  padding-block: clamp(3rem, 2rem + 4vw, 5.5rem) clamp(2rem, 1.5rem + 2vw, 3rem);
  border-bottom: var(--border);
}

.page-header h1 { margin-bottom: 1.25rem; }
.page-header .lede { margin: 0; }

/* ===========================================================================
   Editing helper — remove this rule to hide the template markers
   ========================================================================= */

.tpl {
  background: var(--accent-12);
  border-bottom: 1px dashed var(--accent-30);
  padding: 0 0.15em;
}

/* When the marker sits on a block element, shrink the highlight to the text
   without turning the element inline — otherwise the next line flows up beside
   it. Never apply this to table cells: it would drop them out of the table. */
.stat__value.tpl,
.card__number.tpl { width: fit-content; }

.tpl-note {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  color: var(--accent);
  border: 1px dashed var(--accent-30);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  margin-block: 1rem;
  display: block;
}
