/*
  Fonts: Helvetica Neue (text and titles) and ITC Avant Garde Gothic, the
  fonts of the posters the page follows, used as installed on the reader's
  device (every Apple device has Helvetica Neue). Where they are missing, the
  page falls back to TeX Gyre Heros and TeX Gyre Adventor, free clones with
  the same design, served from static/fonts. TeX Gyre Heros has no Medium,
  so the Medium served with it (Heros Web Medium) is derived from its
  Regular by scripts/release_assets/make_heros_medium.py, with the stems of
  Helvetica Neue Medium. Cover titles and result subheadings use Helvetica
  Neue (--font-display); to set them in Avant Garde instead, point
  --font-display at var(--font-geometric).

  The title, the subtitle, the authors, the affiliations and the section
  headings are in ITC Avant Garde Gothic (--font-title), Bold and Book, the
  face of 1970s posters and of some of the reference covers
  ("Psycho-Cybernetics"). Few devices have it, so most
  readers see TeX Gyre Adventor, its free clone, served from static/fonts.
*/

@font-face {
  font-family: "TeX Gyre Heros";
  src: local("TeX Gyre Heros"), url("../fonts/TeXGyreHeros-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "TeX Gyre Heros";
  src: url("../fonts/HerosWeb-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "TeX Gyre Heros";
  src: local("TeX Gyre Heros"), url("../fonts/TeXGyreHeros-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "TeX Gyre Adventor";
  src: local("TeX Gyre Adventor"), url("../fonts/TeXGyreAdventor-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "TeX Gyre Adventor";
  src: local("TeX Gyre Adventor"), url("../fonts/TeXGyreAdventor-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  /* Cream poster paper (the page) and black ink. */
  /* The page is dark: a worn black board (backgrounds.css) with cream text.
     --ink is the colour of text and rules on the board, so it is cream. */
  --page: #171513;
  --ink: #ece4d2;
  --muted: #a89f8f;
  --hairline: rgba(236, 228, 210, 0.2);
  /* A slightly lighter board for the code block. */
  --paper-deep: #24211d;
  /* One accent: the blue of the Pelican reference covers, sampled from "The
     Psychology of Perception" (#2B8FB3) and made a step darker (OKLCH
     lightness -0.015), so the author names, which have no underline, stand
     3.1:1 against the cream commas and numbers of their line while keeping
     4.6:1 on the board. It colours the author names, link underlines, focus
     outlines and the hover fill of the BibTeX and Copy buttons, with
     board-coloured text (4.6:1); never body text. It replaced vermilion,
     which read as the orange of the diffusion data. */
  --pelican-blue: #258aae;
  --accent: var(--pelican-blue);
  --link: var(--pelican-blue);
  /* The colours of the sites the hero buttons lead to, only for their hover
     fill: the red of arXiv and the green of the Code button on GitHub. */
  --arxiv: #b31b1b;
  --github: #1f883d;
  /* Cream paper with black ink: the book covers of the findings and the
     sheets under the paper figures. */
  --paper: #ece4d2;
  --paper-ink: #1c1a17;
  --paper-muted: #5c554a;
  /* Data colours: diffusion and autoregressive, the orange and the violet of
     the paper's own figures (#F19065 and #8569AC); the orange is one step
     darker so the pair passes the palette checks on the board and on the
     plates of the covers. Never for text. */
  --diffusion: #de6a3a;
  --autoregressive: #8569ac;
  --font-body: "Helvetica Neue", "TeX Gyre Heros", Helvetica, Arial, sans-serif;
  --font-display: "Helvetica Neue", "TeX Gyre Heros", Helvetica, Arial, sans-serif;
  --font-geometric: "ITC Avant Garde Gothic", "ITC Avant Garde Gothic Std", "ITC Avant Garde Gothic Pro", "TeX Gyre Adventor", sans-serif;
  --font-title: var(--font-geometric);
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}


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

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

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

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--ink);
  background: var(--page);
  overflow-wrap: break-word;
}

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

a {
  color: var(--ink);
  text-decoration-line: underline;
  text-decoration-color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--ink);
  text-decoration-thickness: 2px;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -100px;
  z-index: 10;
  padding: 8px 14px;
  border-radius: 0;
  background: var(--page);
  color: var(--ink);
  border: 1px solid var(--hairline);
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

h1,
h2,
h3 {
  font-family: var(--font-body);
  color: inherit;
}

h1 {
  font-size: clamp(2.1rem, 4.6vw, 3.6rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.08;
  margin: 0;
  text-wrap: balance;
}

h2 {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
}

h3 {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0;
}

/* Section headings: Avant Garde Bold in cream, like the title, with a 3 px
   rule under the text column. Avant Garde is for the hero (title, subtitle,
   authors, affiliations) and the section headings only; everything that is
   read (text, captions, tables, buttons, cover titles) is Helvetica Neue. */
main h2 {
  display: block;
  font-family: var(--font-title);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
  padding-bottom: 8px;
  border-bottom: 3px solid var(--ink);
  color: var(--ink);
}

main h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--ink);
}

strong,
b {
  font-weight: 700;
}

p {
  margin: 0;
}

sup {
  font-size: 0.8em;
  line-height: 0;
}

sub {
  font-size: 0.8em;
  line-height: 0;
}

code,
pre {
  font-family: var(--font-mono);
}

code {
  font-size: 0.9em;
  overflow-wrap: anywhere;
}

/* Model names and pseudonyms never break at their hyphens, where they would
   read as hyphenated words; a marker stays with its name. */
.nobr {
  white-space: nowrap;
}

/* ---------- Layout ---------- */

.wrap {
  width: min(1000px, 100% - 40px);
  margin-inline: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  row-gap: 1rem;
}

.wrap > * {
  grid-column: 1;
}

section {
  padding-block: clamp(48px, 6vw, 72px);
  scroll-margin-top: 24px;
}

section + section {
  border-top: 0;
}

.wrap > article {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  row-gap: 1rem;
}

/* Wide layout: text in a 720px column, figures up to 960px. */
@media (min-width: 900px) {
  .wrap {
    grid-template-columns: minmax(0, 1fr) minmax(0, 720px) minmax(0, 1fr);
  }

  .wrap > * {
    grid-column: 2;
  }

  .wrap > .teaser {
    grid-column: 1 / -1;
  }

  .wrap > article {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: subgrid;
    row-gap: 1rem;
  }

  .wrap > article > * {
    grid-column: 2;
  }

  .wrap > article > .fig-narrow {
    grid-column: 2;
  }

  .wrap > article > .fig-wide {
    grid-column: 1 / -1;
  }
}

/* Figure size classes: single-column paper figures are narrow, the three-panel grid is wide. */
.fig-narrow {
  width: min(600px, 100%);
  justify-self: center;
}

.fig-wide {
  width: min(960px, 100%);
  justify-self: center;
}

.teaser {
  width: min(720px, 100%);
  justify-self: center;
  margin: 0;
}

.formula {
  width: min(640px, 100%);
  justify-self: center;
  margin: 0;
}

/* Below 600 px the formula and Figure 3 switch to versions laid out for a
   narrow screen (paradigm-bias-narrow-dark.svg, fig_bias_grid_bars_narrow.svg),
   since the wide ones shrink to unreadable text. Figure 3 then
   carries its marker key inside, so the key of the caption is left to screen
   readers. */
.formula img {
  margin-inline: auto;
}

@media (max-width: 600px) {
  .fig-wide .markers {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }
}

/* Metrics: what A, P, R and J are.
   One row per metric, the name on the left and its definition on the right,
   between hairlines like the tables; the definitions are justified like the
   prose. */
.metrics {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr);
  margin: 0;
  border-bottom: 1px solid var(--hairline);
}

.metrics dt,
.metrics dd {
  margin: 0;
  padding: 14px 0;
  border-top: 1px solid var(--hairline);
}

.metrics dt {
  padding-right: 24px;
  font-weight: 700;
}

.metrics dd {
  text-align: justify;
  -webkit-hyphens: auto;
  hyphens: auto;
}

/* Each metric has its formula under its definition, so the reader does not
   look up and down between a list and one formula block. The
   formulas keep their natural size, the scale of the paradigm-bias formula,
   and are centred in the column of the definitions. */
.metrics .eq {
  margin-top: 14px;
}

.metrics .eq img {
  margin-inline: auto;
}

/* S with a tilde, as in the regression: a combining tilde lands off the
   italic S, so the tilde is drawn over it. */
.tilde {
  position: relative;
  display: inline-block;
}

.tilde::after {
  content: "\02DC";
  position: absolute;
  left: 0.2em;
  top: -0.38em;
  font-style: normal;
  pointer-events: none;
}

/* P and R with a bar: the mean over the nine biases, as in the formula. */
.bar {
  text-decoration: overline;
  text-decoration-thickness: 1px;
}

@media (max-width: 600px) {
  .metrics {
    grid-template-columns: minmax(0, 1fr);
  }

  .metrics dt {
    padding-bottom: 6px;
  }

  .metrics dd {
    padding-top: 0;
    border-top: 0;
  }
}

/* Paper figures sit on cream paper sheets (.surface) on the board. The sheet
   has square corners, no shadow and some padding; the caption stays on the
   board. */
main .surface {
  position: relative;
  padding: clamp(12px, 2vw, 20px);
  background-color: var(--paper);
  background-image: url("../images/bg/specks.webp"), url("../images/bg/paper.webp");
  background-size: 1000px 1000px, 1200px 1200px;
  background-repeat: repeat, repeat;
}

/* Three paper figures carry a white background of their own: multiply prints
   them into the cream sheet under them. */
.surface img {
  width: 100%;
  mix-blend-mode: multiply;
}

figure {
  margin: 0;
}

/* The caption is as wide as its figure, justified like the prose. */
figcaption {
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--muted);
  text-align: justify;
  -webkit-hyphens: auto;
  hyphens: auto;
  width: 100%;
  margin-top: 12px;
}

/* Prose and captions below the header are justified, as in the paper.
   Hyphenation keeps the gaps small in narrow columns. */
main p,
main figcaption {
  text-align: justify;
  -webkit-hyphens: auto;
  hyphens: auto;
}

.fig-num {
  font-weight: 700;
  color: var(--ink);
}

/* The marker key of Figures 3 and 4 is a line of its own, set ragged: each
   marker stays with its name, and justified they left wide gaps. */
.markers {
  display: block;
  text-align: left;
}

.muted {
  color: var(--muted);
  font-size: 0.95rem;
}

/* Space between findings and below the Results heading. */
#results .wrap > h2 {
  margin-bottom: 16px;
}

#results .wrap > article + article {
  margin-top: 48px;
}

/* ---------- Teaser and abstract ---------- */

/* The abstract is the camera-ready's word for word, split into four
   paragraphs as on Nerfies: the problem, what we do, the
   results, the release. No line ends on a single word, and the last
   paragraph, whose URL cannot break, is set ragged so its first line does not
   spread. */
#abstract p {
  text-wrap: pretty;
}

#abstract p:last-child {
  text-align: left;
}

/* The URL stays whole on its own line; only on a phone, where it does not
   fit, it breaks after "epfl-mints/", never at a hyphen of the repository
   name, where it would read as a hyphenated word. */
#abstract p:last-child a,
#abstract .nobr {
  white-space: nowrap;
}

@media (max-width: 600px) {
  #abstract p:last-child a {
    white-space: normal;
  }

  /* A zero-width space as generated content: a place to break that exists
     only on a phone and is not copied with the text. */
  #abstract .url-break::after {
    content: "\200B";
  }
}

.teaser-section {
  padding-top: clamp(32px, 5vw, 56px);
}

/* ---------- Tables ---------- */

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

caption {
  text-align: left;
  color: var(--muted);
  padding-bottom: 8px;
}

th,
td {
  text-align: left;
  vertical-align: top;
  padding: 10px 16px 10px 0;
  border-bottom: 1px solid var(--hairline);
}

th {
  font-weight: 700;
}

thead th {
  padding: 10px 12px 8px 0;
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--muted);
  border-bottom: 1px solid var(--hairline);
}

th.num,
td.num {
  text-align: right;
  white-space: nowrap;
}

td a {
  text-decoration-color: var(--link);
}

td code {
  overflow-wrap: normal;
  word-break: normal;
}

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 8px;
  vertical-align: 0;
}

.swatch-diff {
  background: var(--diffusion);
}

.swatch-ar {
  background: var(--autoregressive);
}

/* Tables 2 and 3 of the paper (judge profile, Gemma pair). Judges and
   metrics in the first column, numbers right-aligned; the stars of a
   significant difference hang to the right of the number, so the digits
   stay in line. */
.scores tbody th {
  font-weight: 500;
}

.scores th,
.scores td {
  padding-right: 16px;
}

.scores .sig {
  display: inline-block;
  width: 1.6em;
  font-size: 0.75em;
  text-align: left;
  vertical-align: super;
  line-height: 1;
}

@media (max-width: 600px) {
  .scores {
    font-size: 0.86rem;
  }

  .scores th,
  .scores td {
    padding-right: 10px;
  }

  .scores .swatch {
    margin-right: 6px;
  }

  /* Table 3 does not fit a phone with the two names in its head: there it
     shows DG, G4 and Δ, as in the head of the paper's table, and the full
     names stay for screen readers. */
  .scores .th-long {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .scores .th-short {
    display: inline;
  }
}

.th-short {
  display: none;
}

/* Phones: prose, captions and definitions are set ragged. In a column this
   narrow, justified lines around a long model name, which never breaks, left
   wide gaps between the words (as on the tagline). */
@media (max-width: 600px) {
  main p,
  main figcaption,
  .metrics dd {
    text-align: left;
  }
}

/* The panel table: one pair per row; each judge has the logo of its vendor in the ink of the
   page, then its vendor and its weights and size (Table 1 of the paper) in
   muted text.
   Markup from scripts/release_assets/make_judges_table.py. */
.judges thead th {
  width: 50%;
}

.judges th,
.judges td {
  padding-right: 24px;
}

.judges td {
  padding-top: 14px;
  padding-bottom: 14px;
}

.judges .judge {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.05rem;
  font-weight: 500;
}

.judges .vendor-logo {
  flex: none;
  width: 22px;
  height: 22px;
}

.judges .meta {
  display: block;
  margin-top: 3px;
  padding-left: 32px;
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--muted);
}

@media (max-width: 600px) {
  .judges th,
  .judges td {
    padding-right: 12px;
  }

  .judges .judge {
    gap: 7px;
    font-size: 0.92rem;
  }

  /* "Gemma-4-26B-A4B" would break at a hyphen. */
  .judges .name {
    white-space: nowrap;
  }

  .judges .vendor-logo {
    width: 18px;
    height: 18px;
  }

  .judges .meta {
    padding-left: 0;
  }
}

/* ---------- Code ---------- */

/* BibTeX is a printed slip: a darker board block with a 1 px cream border and
   cream text. The Copy button sits in the top right corner. The long fields
   are broken by hand in index.html, each second line under the opening brace,
   so the entry is never wrapped: on a desktop it fits, on a phone it scrolls
   sideways, and the first line starts below the button. */
.bib {
  position: relative;
  width: 100%;
  background: var(--paper-deep);
  border: 1px solid var(--ink);
}

pre {
  margin: 0;
  padding: 16px;
  border-radius: 0;
  background: transparent;
  font-size: 0.85rem;
  line-height: 1.55;
  overflow-x: auto;
  color: var(--ink);
}

.bib pre {
  padding: 20px 24px;
  color: var(--ink);
}

pre code {
  font-size: inherit;
  white-space: pre;
  overflow-wrap: normal;
}

/* The Copy button is a flat cream block with board-coloured text, like the
   hero buttons (14.4:1). On hover it turns the accent blue and the label stays
   the board colour (4.9:1); cream text on the blue would be 2.9:1. */
.copy-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 1;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.2;
  padding: 7px 14px;
  border-radius: 0;
  border: 0;
  background: var(--ink);
  color: var(--page);
  cursor: pointer;
}

.copy-btn:hover {
  background: var(--accent);
  color: var(--page);
}

@media (prefers-reduced-motion: no-preference) {
  .copy-btn {
    transition: background-color 0.15s ease, color 0.15s ease;
  }
}

/* ---------- Hero links row and top bar (hero.css owns the rest of the hero) ---------- */

.hero .links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

/* The top bar holds only the "More Research" menu, centred. */
.topnav {
  position: relative;
  z-index: 3;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  width: 100%;
  padding: 12px 0;
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 500;
}

.more summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 0;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.more summary:focus-visible,
.more-menu a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.more {
  position: relative;
}

.more summary {
  list-style: none;
}

.more summary::-webkit-details-marker {
  display: none;
}

/* A flat sheet of --paper-deep with a 1 px cream border, no shadow. */
.more-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 32px);
  margin: 0;
  padding: 6px;
  list-style: none;
  text-align: left;
  background: var(--paper-deep);
  border: 1px solid var(--ink);
  border-radius: 0;
  box-shadow: none;
}

/* A strip over the gap between the summary and the sheet, so the pointer
   stays on the menu while it moves down to the links. */
.more-menu::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 10px;
}

.more-menu a {
  display: block;
  padding: 10px 12px;
  border-radius: 0;
  color: var(--ink);
  text-decoration: none;
}

.more-title {
  display: block;
  font-weight: 500;
  line-height: 1.3;
}

.hero .icon {
  flex: none;
}

/* ---------- Footer ---------- */

.site-footer {
  position: relative;
  overflow: hidden;
  padding-block: 56px 64px;
  font-size: 0.92rem;
  color: var(--muted);
}

.site-footer .wrap {
  position: relative;
  z-index: 1;
  row-gap: 1.25rem;
  padding-top: 28px;
}

/* A 3 px ink rule across the top of the text column. */
.site-footer .wrap::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: min(720px, 100%);
  transform: translateX(-50%);
  height: 3px;
  pointer-events: none;
  background: var(--ink);
}

.site-footer a {
  color: var(--ink);
}

/* Footer lines are justified under the centred logos; the last line of each
   paragraph is centred, so no line sits flush left. */
.site-footer p {
  text-align: justify;
  text-align-last: center;
  -webkit-hyphens: auto;
  hyphens: auto;
}

.logos {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 32px 44px;
}

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

/* Logos 60 px high. */
.logos img {
  height: 60px;
  width: auto;
}

/* The licence line stays on one line. */
.site-footer .one-line {
  white-space: nowrap;
}

/* On a phone it may wrap, so that larger text spacing never cuts it. */
@media (max-width: 600px) {
  .site-footer .one-line {
    white-space: normal;
  }
}

/* ---------- Phones ---------- */

@media (max-width: 600px) {
  section {
    padding-block: 44px;
  }

  #results .wrap > article + article {
    margin-top: 28px;
  }

  main h2 {
    font-size: 1.6rem;
  }
}

/* ---------- Review fixes ---------- */
@media (max-width: 600px) {
  .hero .links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: min(340px, 100%);
    margin-inline: auto;
  }
  .hero .btn {
    justify-content: center;
  }
  .copy-btn {
    font-size: 0.9rem;
  }
  pre {
    font-size: 0.78rem;
  }
  .bib pre {
    padding: 56px 16px 16px;
  }
}

/* Phones: the footer logos two by two. */
@media (max-width: 600px) {
  .logos {
    display: grid;
    grid-template-columns: repeat(2, max-content);
    justify-content: center;
  }
}

@media (max-width: 600px) {
  .more {
    position: static;
  }
  .hero h1,
  .title-echo span {
    font-size: 1.8rem;
  }
}
