/* Unwrapped Food.
 *
 * One stylesheet, self hosted, no external origins at all. The page renders
 * with no third party connection, which is good for speed and removes a whole
 * class of supply chain risk.
 *
 * Two rules run through the design:
 *
 * 1. Severity is shown with colour. Evidence strength is shown with a dot
 *    meter. Keeping them in different visual languages is what stops a reader
 *    collapsing the two axes into one impression of danger.
 * 2. Colour is never the only signal. Every severity carries a word, every
 *    nutrient band carries its band name, and the dot meter carries a label,
 *    so the page works in greyscale and to a screen reader.
 */

:root {
  color-scheme: light;

  --bg: #eaefee;
  --surface: #ffffff;
  --surface-2: #f4f7f6;
  --ink: #122320;
  --ink-soft: #4a5b57;
  --line: #d5ddda;
  --primary: #0f5f56;
  --primary-deep: #093f39;
  --primary-tint: #e2efec;
  /* Text on a primary-coloured fill. */
  --on-primary: #ffffff;
  --chip-line: #cfe4df;

  /* Functional only. Never used as decoration. */
  --safe: #1f8a52;
  --low: #b78a1f;
  --moderate: #d1731f;
  --high: #bd3a2c;
  --safe-bg: #edf7f0;
  --low-bg: #fbf4e3;
  --moderate-bg: #fdf0e6;
  --high-bg: #fbecea;

  /* Severity as text is a different colour from severity as a fill. A fill
   * only has to be seen, at 3:1; a word has to be read, at 4.5:1, and the
   * fills are nowhere near that on white. These are the reading colours,
   * dark enough for the palest ground they can land on. */
  --safe-text: #136b3d;
  --low-text: #8a6410;
  --moderate-text: #ad4d14;
  --high-text: #8f2b1f;
  --safe-line: #c4e3ce;
  --low-line: #ecd9a6;
  --high-line: #eecac4;

  /* NOVA group identity. Fixed mid tones carrying white numerals, kept
   * off the severity ramp: a processing group is not a severity, and
   * DECISIONS.md is explicit that it must never read as one. */
  --nova-1: #1f8a52;
  --nova-2: #7f8f24;
  --nova-3: #d1731f;
  --nova-4: #bd3a2c;
  --on-nova: #ffffff;

  /* Product photographs are mostly shot on white and cut out badly, so
   * their plate stays light whatever the theme. */
  --photo-plate: #ffffff;
  /* The surface colour at zero alpha: fading to plain transparent goes
   * through grey. */
  --surface-fade: rgba(255, 255, 255, 0);

  --radius: 14px;
  --shadow: 0 1px 2px rgba(9, 40, 36, 0.04), 0 8px 30px rgba(9, 40, 36, 0.06);

  /* System font stacks rather than a web font. A downloaded display face
   * costs a render-blocking round trip and a third party origin, and the
   * whole site is text, so the text should appear immediately. */
  --display: ui-sans-serif, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --body: ui-sans-serif, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

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

/* A later display rule must never win against the hidden attribute. */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 940px; margin: 0 auto; padding: 0 20px; }

a { color: var(--primary); }
a:hover { color: var(--primary-deep); }

h1, h2, h3, h4 { font-family: var(--display); letter-spacing: -0.01em; line-height: 1.2; }
h1 { font-size: 30px; margin: 0 0 12px; }
h2 { font-size: 23px; margin: 34px 0 8px; }
h3 { font-size: 18px; margin: 24px 0 8px; }

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

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

.skip-link {
  position: absolute; left: -9999px; top: 0; background: var(--primary);
  color: var(--on-primary); padding: 10px 16px; z-index: 10;
}
.skip-link:focus { left: 0; }

/* --- Header and footer -------------------------------------------------- */

.site-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; padding: 14px 20px;
}
.brand {
  font-family: var(--display); font-weight: 700; font-size: 22px;
  color: var(--primary-deep); text-decoration: none;
  display: flex; align-items: center; gap: 10px;
}
.brand .dot {
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--primary); box-shadow: 0 0 0 4px var(--primary-tint);
}
.brand picture { display: block; }
.brand img { display: block; height: 64px; width: auto; }
.pack-note { color: var(--ink-soft); font-size: 13px; }
.nav { list-style: none; display: flex; gap: 18px; margin: 0; padding: 0; flex-wrap: wrap; }
.nav a { text-decoration: none; font-weight: 500; }
.nav a:hover { text-decoration: underline; }

/* The theme control. Hidden until theme.js reveals it, so it is never a
 * button that does nothing, and it shows the theme it will switch to rather
 * than the one you are already looking at. */
.theme-toggle {
  flex: none; width: 40px; height: 40px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; color: var(--ink-soft); cursor: pointer;
  border: 1px solid var(--line); border-radius: 10px;
}
.theme-toggle:hover { color: var(--primary); border-color: var(--primary); }
.theme-icon {
  width: 20px; height: 20px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.theme-toggle[data-resolved="dark"] .theme-icon-moon,
.theme-toggle[data-resolved="light"] .theme-icon-sun { display: none; }

.header-tools { display: flex; align-items: center; gap: 18px; min-width: 0; }

main { padding-bottom: 40px; }

.site-footer {
  border-top: 1px solid var(--line); background: var(--surface);
  color: var(--ink-soft); font-size: 14px; padding: 26px 0 50px;
}
/* The trading disclosure and copyright. Set apart from the sources note
 * above it, and quieter, because it is a legal requirement rather than
 * something anyone came here to read. */
.colophon {
  margin: 16px 0 0; padding-top: 14px;
  border-top: 1px solid var(--line); font-size: 13px;
}
.disclaimer {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 16px 18px; margin-bottom: 16px;
}
.footer-links { list-style: none; display: flex; gap: 18px; flex-wrap: wrap; padding: 0; }

/* --- Blocks ------------------------------------------------------------- */

.hero { padding: 30px 0 6px; }
.lede { font-size: 19px; line-height: 1.5; max-width: 62ch; }
.lede strong { color: var(--primary-deep); font-weight: 600; }
.sub { color: var(--ink-soft); max-width: 64ch; }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; margin: 20px 0;
}
.panel > :first-child { margin-top: 0; }

/* --- Search ------------------------------------------------------------- */

.search-form label { display: block; font-size: 14px; color: var(--ink-soft); margin-bottom: 6px; }
.search-row { display: flex; gap: 10px; flex-wrap: wrap; }
.search-row input[type="search"], .search-row input[type="text"] {
  flex: 1; min-width: 220px; font: inherit; color: var(--ink);
  padding: 13px 15px; border: 1.5px solid var(--line);
  border-radius: 10px; background: var(--surface-2);
}
.search-row input:focus { border-color: var(--primary); background: var(--surface); outline: none; }

.button {
  font-family: var(--display); font-weight: 600; font-size: 16px;
  border-radius: 10px; padding: 12px 22px; cursor: pointer;
  text-decoration: none; display: inline-block; border: 1.5px solid transparent;
}
.button.primary { background: var(--primary); color: var(--on-primary); }
.button.primary:hover { background: var(--primary-deep); color: var(--on-primary); }
.button.secondary { background: var(--surface); color: var(--primary-deep); border-color: var(--line); }
.button.secondary:hover { border-color: var(--primary); }

.examples { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--ink-soft); }
.chip {
  font-family: var(--mono); font-size: 12.5px; text-decoration: none;
  background: var(--primary-tint); color: var(--primary-deep);
  border: 1px solid var(--chip-line); border-radius: 20px; padding: 5px 12px;
}

/* --- Notices ------------------------------------------------------------ */

.note { padding: 15px 17px; border-radius: 10px; font-size: 14.5px; margin: 14px 0; }
.note.info { background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-soft); }
.note.warn { background: var(--low-bg); border: 1px solid var(--low-line); color: var(--low-text); }
.note.error { background: var(--high-bg); border: 1px solid var(--high-line); color: var(--high-text); }
.messages { list-style: none; padding: 0; }

/* --- Product ------------------------------------------------------------ */

.product-head { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.product-head img {
  width: 84px; height: 84px; object-fit: contain; background: var(--photo-plate);
  border: 1px solid var(--line); border-radius: 10px;
}

/* Products with no photograph. Shown as a labelled placeholder rather than
 * blank space, because an empty gap reads as a broken image and this is an
 * honest absence: most Open Food Facts entries have no picture. */
.no-photo {
  display: flex; align-items: center; justify-content: center; text-align: center;
  background: var(--surface-2); border: 1px dashed var(--line); border-radius: 10px;
  color: var(--ink-soft); font-size: 10px; line-height: 1.25; padding: 4px;
  flex: none;
}
.no-photo.large { width: 84px; height: 84px; }
.no-photo.small { width: 46px; height: 46px; font-size: 9px; }
.product-sub { color: var(--ink-soft); font-size: 15px; }
.barcode { font-family: var(--mono); font-size: 13px; color: var(--ink-soft); }

.section-label {
  font-family: var(--display); font-weight: 600; font-size: 13px;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-soft);
  margin: 0 0 14px;
}

/* NOVA */
.nova { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.nova-badge {
  font-family: var(--display); font-weight: 700; font-size: 30px;
  width: 58px; height: 58px; flex: none; border-radius: 12px; color: var(--on-nova);
  display: flex; align-items: center; justify-content: center;
}
.nova-1 { background: var(--nova-1); }
.nova-2 { background: var(--nova-2); }
.nova-3 { background: var(--nova-3); }
.nova-4 { background: var(--nova-4); }
.nova-text { flex: 1; min-width: 220px; }

/* A little air above a block that follows other content. Exists as a class
 * because the CSP puts a nonce on style elements and blocks style
 * attributes, so an inline margin would silently not apply. */
.spaced { margin-top: 13px; }

/* --- The processing ladder ----------------------------------------------
 *
 * The one ranking on this site that is honest to draw as a ranking, because
 * NOVA orders its own four groups and we are not inventing the order. The
 * impact is meant to come from scale and proportion: a bar that is genuinely
 * three quarters of the width says more than any amount of red would, and
 * red is reserved for graded signals anyway. The rung colours are the same
 * NOVA colours the product page uses, so a reader learns them once.
 */

.eyebrow {
  font-family: var(--display); font-weight: 700; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.12em; color: var(--primary);
  margin: 0 0 6px;
}

.processing-hero { margin: 8px 0 26px; }
.processing-hero h1 { font-size: clamp(30px, 6vw, 50px); line-height: 1.05; margin: 0 0 14px; }
.hero-figure {
  font-size: 17px; color: var(--ink-soft); margin: 18px 0 0;
  border-left: 4px solid var(--high); padding-left: 16px; max-width: 46ch;
}
.hero-figure strong {
  display: block; font-family: var(--display); font-weight: 700;
  font-size: clamp(38px, 9vw, 64px); line-height: 1; color: var(--ink);
}

.ladder { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }

.rung {
  border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; background: var(--surface-2);
}
.rung-head { display: flex; gap: 14px; align-items: flex-start; }
.rung-title { flex: 1; min-width: 0; }
.rung-title h3 { font-size: 17px; margin: 2px 0 3px; }
.rung-title h3 a { text-decoration: none; }
.rung-title h3 a:hover { text-decoration: underline; }
.rung-detail { font-size: 13.5px; color: var(--ink-soft); margin: 0; max-width: 62ch; }

.rung-figure { margin: 0; text-align: right; flex: none; }
.rung-figure strong {
  display: block; font-family: var(--display); font-weight: 700;
  font-size: clamp(24px, 5vw, 34px); line-height: 1;
}
.rung-figure span { font-size: 12px; color: var(--ink-soft); }

/* The bar is decoration for a number that is already printed beside it, so it
 * is hidden from assistive technology rather than announced twice. */
.rung-bar {
  height: 9px; border-radius: 5px; background: var(--line);
  margin: 12px 0 0; overflow: hidden;
}
.rung-fill { height: 100%; border-radius: 5px; background: var(--ink-soft); }
.nova-band-1 .rung-fill { background: var(--nova-1); }
.nova-band-2 .rung-fill { background: var(--nova-2); }
.nova-band-3 .rung-fill { background: var(--nova-3); }
.nova-band-4 .rung-fill { background: var(--nova-4); }

.rung-examples {
  list-style: none; margin: 14px 0 0; padding: 0;
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
}
.rung-examples a {
  display: flex; flex-direction: column; gap: 5px; height: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px; text-decoration: none; color: inherit; font-size: 13px;
}
.rung-examples a:hover { border-color: var(--primary); }
.rung-examples img {
  width: 52px; height: 52px; object-fit: contain; background: var(--photo-plate);
  border: 1px solid var(--line); border-radius: 8px;
}
.rung-example-name { font-weight: 600; line-height: 1.3; }
.rung-example-brand { font-size: 12px; color: var(--ink-soft); margin-top: auto; }

.nova-badge.small { width: 36px; height: 36px; font-size: 19px; border-radius: 9px; }

.group-glossary { margin: 0; }
.group-glossary > div { padding: 14px 0; border-bottom: 1px solid var(--line); }
.group-glossary > div:last-child { border-bottom: 0; }
.group-glossary dt { display: flex; gap: 12px; align-items: center; font-weight: 600; }
.group-glossary dd { margin: 8px 0 0 48px; color: var(--ink-soft); font-size: 14.5px; }

@media (max-width: 560px) {
  .brand img { height: 40px; }
  .rung-head { flex-wrap: wrap; }
  .rung-figure { text-align: left; width: 100%; }
  .group-glossary dd { margin-left: 0; }
}

/* Traffic lights */
.tl-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.tl {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; text-align: center; background: var(--surface-2);
}
.tl .label { font-size: 12.5px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.05em; }
.tl .value { font-family: var(--mono); font-weight: 700; font-size: 17px; margin: 5px 0 2px; }
.tl .band { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.tl.band-low { background: var(--safe-bg); }
.tl.band-low .band, .tl.band-low .value { color: var(--safe-text); }
.tl.band-medium { background: var(--low-bg); }
.tl.band-medium .band, .tl.band-medium .value { color: var(--low-text); }
.tl.band-high { background: var(--high-bg); }
.tl.band-high .band, .tl.band-high .value { color: var(--high); }
.tl.band-unknown .band, .tl.band-unknown .value { color: var(--ink-soft); }

/* The ingredients list, as printed. Slightly tighter than body copy because
 * it is a dense run-on list rather than prose. */
.ingredients {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; font-size: 14.5px; line-height: 1.5; margin: 0 0 12px;
}

/* --- Additive cards ----------------------------------------------------- */

.additive-list { display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 0; list-style: none; }

.additive { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); }
.additive > summary {
  display: flex; gap: 12px; align-items: center; padding: 13px 15px;
  cursor: pointer; list-style: none;
}
.additive > summary::-webkit-details-marker { display: none; }
.additive > summary:hover { background: var(--surface-2); }
.additive[open] > summary { border-bottom: 1px solid var(--line); }

.severity-tab { width: 6px; align-self: stretch; border-radius: 6px; flex: none; min-height: 38px; }
.severity-safe { background: var(--safe); }
.severity-low { background: var(--low); }
.severity-moderate { background: var(--moderate); }
.severity-high { background: var(--high); }

.additive-code {
  font-family: var(--mono); font-weight: 700; font-size: 13px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 6px; padding: 3px 8px; flex: none;
}
.additive-name { font-weight: 600; }
.additive-function { font-size: 13px; color: var(--ink-soft); }
.additive-meta { margin-left: auto; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

.severity-word { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
/* The word, not the fill: this is the site's most meaning-bearing text and
 * the fills were failing AA on white, worst of them at 2.71:1. */
.severity-word.safe { color: var(--safe-text); }
.severity-word.low { color: var(--low-text); }
.severity-word.moderate { color: var(--moderate-text); }
.severity-word.high { color: var(--high-text); }

/* Evidence is a dot meter, never a colour: that is what keeps it from being
 * read as a second severity. */
.evidence { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.evidence-dots { letter-spacing: 2px; font-size: 11px; color: var(--primary); }
.evidence-dots .off { color: var(--line); }
.evidence-label { font-size: 10.5px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.06em; }

.additive-body { padding: 14px 15px 16px; font-size: 14.5px; }
.additive-body p { margin: 10px 0; }
.additive-body p:first-child { margin-top: 0; }

.reg-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; margin-top: 12px; font-size: 13.5px; }
.reg-row .key { color: var(--ink-soft); }
.reg { font-family: var(--mono); font-size: 11.5px; border: 1px solid var(--line); border-radius: 5px; padding: 2px 7px; }
.reg.ok { background: var(--safe-bg); border-color: var(--safe-line); color: var(--safe-text); }
.reg.warn { background: var(--low-bg); border-color: var(--low-line); color: var(--low-text); }
.reg.ban { background: var(--high-bg); border-color: var(--high-line); color: var(--high); }
.reg-note { color: var(--ink-soft); font-size: 13px; margin-top: 8px; }

/* --- Filters and lists -------------------------------------------------- */

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; padding: 0; list-style: none; }
.filter {
  font-size: 13.5px; text-decoration: none; border: 1.5px solid var(--line);
  background: var(--surface); border-radius: 20px; padding: 7px 14px; color: var(--ink-soft);
}
.filter.active { border-color: var(--primary); color: var(--primary-deep); background: var(--primary-tint); }

.result-list { list-style: none; padding: 0; margin: 8px 0; }
.result {
  display: flex; gap: 14px; align-items: center; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 8px;
}
.result:hover { border-color: var(--primary); }
.result img { width: 46px; height: 46px; object-fit: contain; background: var(--photo-plate); border: 1px solid var(--line); border-radius: 8px; }
.result .name { font-weight: 600; text-decoration: none; }
.result .brand { font-size: 13px; color: var(--ink-soft); }
.result .meta { margin-left: auto; font-family: var(--mono); font-size: 12px; color: var(--ink-soft); text-align: right; }

/* Rows sorted by how many assessed additives a product lists. Deliberately
 * styled exactly like a search result: no rank number, no severity colour and
 * no badge on the product itself, because the count is a fact about the label
 * and not a grade of the food. The severity colours belong to the additive
 * pages the chips link to. */
.concern-list .result { align-items: flex-start; }
.concern-body { display: block; }
.concern-summary { display: block; font-size: 13px; color: var(--ink-soft); margin-top: 6px; }
.concern-codes { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 7px; }
.concern-codes .chip { font-family: inherit; font-size: 12.5px; }

.data-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.data-table th, .data-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.data-table th[scope="row"] { font-weight: 500; }
.data-table td.number { font-family: var(--mono); text-align: right; }

.swatch { width: 13px; height: 13px; border-radius: 4px; display: inline-block; margin-right: 8px; vertical-align: -1px; }
.swatch.safe { background: var(--safe); }
.swatch.low { background: var(--low); }
.swatch.moderate { background: var(--moderate); }
.swatch.high { background: var(--high); }

.legend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.legend-item { display: flex; gap: 10px; align-items: baseline; font-size: 14px; margin: 7px 0; }

/* --- Forms -------------------------------------------------------------- */

.form-field { margin-bottom: 18px; }
.form-field label { display: block; font-weight: 500; margin-bottom: 5px; }
.form-field input[type="text"], .form-field input[type="email"],
.form-field input[type="url"], .form-field textarea, .form-field select {
  width: 100%; font: inherit; padding: 11px 13px;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface-2);
}
.form-field .help { font-size: 13.5px; color: var(--ink-soft); margin-top: 5px; }
.form-field .errors { color: var(--high-text); font-size: 13.5px; list-style: none; padding: 0; margin: 5px 0 0; }
.form-field ul { list-style: none; padding: 0; margin: 0; }
.form-field ul li label { font-weight: 400; display: inline; }

/* The honeypot. Positioned off screen rather than display:none, which some
 * bots check for before deciding whether to fill a field in. */
.honeypot { position: absolute; left: -9999px; top: -9999px; }

/* --- Scan --------------------------------------------------------------- */

#scan-video { width: 100%; max-width: 480px; border-radius: 12px; background: #000; }

/* --- Responsive --------------------------------------------------------- */

@media (max-width: 620px) {
  h1 { font-size: 25px; }
  .tl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .legend-grid { grid-template-columns: 1fr; }
  .additive-meta { width: 100%; margin-left: 0; justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------------------------------------------------------------------------
 * Reading a product at a glance.
 *
 * The page always carried these figures; what it lacked was any way to take
 * them in without assembling them from four panels. They are set large because
 * the striking thing about a product is usually true, so scale can do the work
 * that an alarm colour would otherwise be asked to do.
 *
 * They stay three readings on three scales. The rule against a combined score
 * is a layout rule here as much as a data one: separate columns, separate
 * rules between them, and a note under them saying so.
 * ------------------------------------------------------------------------ */

.product-hero {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px 22px 18px; margin-bottom: 20px;
}
.hero-identity { display: flex; gap: 18px; align-items: flex-start; margin-bottom: 18px; }
.hero-identity img {
  width: 96px; height: 96px; object-fit: cover; flex-shrink: 0;
  border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2);
}
.hero-identity h1 { font-size: 32px; margin: 0 0 4px; letter-spacing: -0.025em; }
.product-hero .product-sub { margin: 0; color: var(--ink-soft); }
.product-hero .barcode { margin: 7px 0 0; font-family: var(--mono); font-size: 12.5px; color: var(--ink-soft); }

.verdict { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.reading { padding: 16px 20px; border-left: 1px solid var(--line); min-width: 0; }
.reading:first-child { border-left: 0; padding-left: 0; }
.reading-label {
  margin: 0; font-size: 10.5px; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-soft);
}
.reading-figure {
  margin: 2px 0 1px; font-size: 52px; font-weight: 700; line-height: 1.06;
  letter-spacing: -0.03em; font-variant-numeric: tabular-nums;
}
.reading-figure .unit { font-size: 21px; font-weight: 600; letter-spacing: 0; }
.reading-name { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.reading-note { margin: 3px 0 0; font-size: 12.5px; color: var(--ink-soft); line-height: 1.4; }
.verdict-note {
  margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--ink-soft);
}

/* Same mapping the badges and traffic lights already use, so a figure and its
 * panel can never disagree about a colour. */
.nova-fig-1 { color: var(--safe); }
.nova-fig-2 { color: var(--nova-2); }
.nova-fig-3 { color: var(--moderate); }
.nova-fig-4 { color: var(--high); }
.band-fig-low { color: var(--safe-text); }
.band-fig-medium { color: var(--low-text); }
.band-fig-high { color: var(--high); }
.unknown-fig { color: var(--ink-soft); }

/* The long additive list earns the width; the reference material sits beside
 * it rather than under it, which is what the old single column wasted. */
.detail-grid { display: grid; gap: 20px; align-items: start; }
.detail-main, .detail-aside { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.detail-main > .panel, .detail-aside > .panel { margin: 0; }

@media (min-width: 900px) {
  .detail-grid { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }

  /* In a column narrower than the old full width, the severity word and the
   * dot meter wrapped past each other. Stacking them keeps the two axes
   * legible and side by side with the name. The reference page puts the
   * library in a column too, now that it shares a page with a contents. */
  .detail-main .additive-meta,
  .doc-body .additive-meta {
    flex-wrap: nowrap; flex-direction: column; align-items: flex-end;
    gap: 3px; flex: none;
  }

  /* The nutrients panel moved into the narrow column, where four across does
   * not fit. */
  .detail-aside .tl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .product-hero { padding: 18px 16px 14px; }
  .hero-identity { gap: 14px; margin-bottom: 14px; }
  .hero-identity img { width: 72px; height: 72px; }
  .hero-identity h1 { font-size: 25px; }
  .verdict { grid-template-columns: 1fr; }
  .reading {
    border-left: 0; border-top: 1px solid var(--line); padding: 13px 0;
    display: grid; grid-template-columns: minmax(84px, auto) minmax(0, 1fr);
    column-gap: 16px; align-items: center;
  }
  .reading:first-child { border-top: 0; }
  .reading-figure {
    grid-column: 1; grid-row: 1 / 4; font-size: 36px; text-align: right;
    margin: 0; white-space: nowrap;
  }
  .reading-figure .unit { font-size: 17px; }
  .reading-label { grid-column: 2; grid-row: 1; }
  .reading-name { grid-column: 2; grid-row: 2; }
  .reading-note { grid-column: 2; grid-row: 3; }
}

/* ---- Home: the search box is the product, so it takes the fold ---------- */
.hero h1 { font-size: 44px; line-height: 1.04; letter-spacing: -0.035em; max-width: 27ch; }
.hero .lede { font-size: 18.5px; max-width: 56ch; margin-bottom: 26px; }
.hero .search-form { background: none; border: 0; box-shadow: none; padding: 0; max-width: 780px; }
.hero .search-row input[type="search"] { min-height: 58px; font-size: 17px; }
.hero .search-row .button { min-height: 58px; font-size: 16.5px; display: inline-flex; align-items: center; }

.scale-strip {
  list-style: none; margin: 34px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line);
}
.scale-strip li { padding: 18px 24px 0; border-left: 1px solid var(--line); }
.scale-strip li:first-child { border-left: 0; padding-left: 0; }
.scale-figure {
  display: block; font-size: 30px; font-weight: 700;
  letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.15;
}
.scale-label { display: block; font-size: 13.5px; color: var(--ink-soft); margin-top: 3px; }

@media (max-width: 620px) {
  .hero { padding: 24px 0 6px; }
  .hero h1 { font-size: 31px; }
  .hero .lede { font-size: 17px; margin-bottom: 20px; }
  /* Sharing a row with the buttons left the field about 140px wide, which is
   * too narrow to read back a barcode you have just typed. */
  .hero .search-row { flex-wrap: wrap; }
  .hero .search-row input[type="search"] { flex: 1 0 100%; }
  .hero .search-row .button { flex: 1 1 auto; justify-content: center; }
  .scale-strip { grid-template-columns: 1fr; margin-top: 26px; }
  .scale-strip li { border-left: 0; border-top: 1px solid var(--line); padding: 12px 0 0; }
  .scale-strip li:first-child { border-top: 0; }
  .scale-figure { font-size: 25px; }
}

/* ---- Header on a phone -----------------------------------------------------
 * The nav used to wrap onto a second row and take the top of the screen with
 * it, on the one device someone is holding in a shop. One row that scrolls
 * sideways keeps every link reachable without a menu, and without script.
 * ------------------------------------------------------------------------ */
@media (max-width: 620px) {
  .header-inner { flex-wrap: nowrap; gap: 12px; padding: 8px 20px; }
  .brand { flex-shrink: 0; }
  .brand img { height: 44px; }
  .site-header nav { min-width: 0; flex: 1 1 auto; }
  .nav {
    flex-wrap: nowrap; overflow-x: auto; gap: 16px;
    scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; font-size: 14.5px; }
}

/* ---- The action someone actually came to take --------------------------- */
.product-actions { display: none; }

@media (max-width: 620px) {
  .product-actions {
    display: flex; gap: 10px; position: sticky; bottom: 0; z-index: 5;
    margin: 20px -20px 0; padding: 10px 20px calc(10px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .product-actions .button { flex-grow: 1; min-height: 48px; display: inline-flex; align-items: center; justify-content: center; }
  .product-actions .button.secondary { flex-grow: 0; padding-inline: 20px; }
}

/* ---- Comparing aisles ------------------------------------------------------
 * The first version of this page was eight tall sections in a row, which meant
 * a page called "compare an aisle" never showed two aisles at once. The chart
 * at the top is the fix: one comparison, drawn on NOVA's ordering rather than
 * ours, with the sections below it compressed enough to scan.
 *
 * No product carries a severity colour or a rank number here. The only colour
 * on a product row is the photograph.
 * ------------------------------------------------------------------------ */

.measure { max-width: 62ch; }
.compare-hero { padding: 30px 0 4px; }

.rank-chart { list-style: none; margin: 18px 0 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.rank-chart li { display: flex; align-items: center; gap: 14px; }
.rank-label { width: 150px; flex: none; font-size: 14.5px; font-weight: 600; text-decoration: none; }
.rank-label:hover { text-decoration: underline; }
.rank-track { flex-grow: 1; height: 14px; border-radius: 7px; background: var(--surface-2); overflow: hidden; }
.rank-fill { display: block; height: 100%; border-radius: 7px; }
.rank-value { width: 46px; text-align: right; font-size: 14.5px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rank-base { width: 84px; text-align: right; font-size: 12.5px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.aisle-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.aisle-head h2 { margin: 0 0 4px; }
.aisle-head .sub { margin: 0; }
.aisle-figure {
  margin: 0; flex: none; font-size: 40px; font-weight: 700; line-height: 1;
  letter-spacing: -0.03em; font-variant-numeric: tabular-nums;
}
.aisle-figure .unit { font-size: 18px; font-weight: 600; }

/* One stacked bar rather than four rows: it reads as a composition, and two
 * aisles can be compared by eye without scrolling between them. */
.aisle-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; margin: 16px 0 10px; background: var(--surface-2); }
.aisle-seg { display: block; height: 100%; }

.aisle-key { margin: 0; font-size: 12.5px; color: var(--ink-soft); display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline; }
.key-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.key-dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.key-gap { flex-basis: 100%; }

.aisle-lists { display: grid; gap: 22px; margin-top: 20px; }
@media (min-width: 820px) { .aisle-lists { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* Sentence case at a readable size: these headings carry a whole sentence
 * now, and letterspaced uppercase is hard work at that length. The eyebrow
 * above them does the labelling job the caps used to do. */
.list-head { margin: 0 0 4px; font-size: 16px; font-weight: 650; letter-spacing: -0.01em; color: var(--ink); }
.list-note { margin: 0 0 10px; font-size: 12.5px; color: var(--ink-soft); line-height: 1.45; }

.mini-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.mini-list li { display: flex; align-items: center; gap: 11px; padding: 7px 8px; border-radius: 9px; }
.mini-list li:hover { background: var(--surface-2); }
.mini-list img, .mini-blank { width: 40px; height: 40px; border-radius: 8px; flex: none; object-fit: cover; background: var(--surface-2); }
.mini-list a { flex-grow: 1; font-size: 14.5px; font-weight: 600; text-decoration: none; min-width: 0; }
.mini-list a:hover { text-decoration: underline; }
.mini-meta { font-size: 12.5px; color: var(--ink-soft); white-space: nowrap; flex: none; }

.aisle-additives { margin-top: 20px; }
.aisle-additives ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.additive-pill {
  display: inline-flex; align-items: baseline; gap: 8px; text-decoration: none;
  border: 1px solid var(--line); border-left-width: 4px; border-radius: 9px;
  padding: 7px 12px; background: var(--surface); color: var(--ink);
}
.additive-pill:hover { background: var(--surface-2); color: var(--ink); }
.pill-code { font-family: var(--mono); font-size: 12px; font-weight: 700; }
.pill-name { font-size: 13.5px; }
.pill-count { font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.severity-edge-safe { border-left-color: var(--safe); }
.severity-edge-low { border-left-color: var(--low); }
.severity-edge-moderate { border-left-color: var(--moderate); }
.severity-edge-high { border-left-color: var(--high); }

@media (max-width: 620px) {
  .rank-chart li { flex-wrap: wrap; gap: 6px 10px; }
  .rank-label { width: auto; flex-grow: 1; }
  .rank-track { flex-basis: 100%; order: 3; }
  .rank-base { display: none; }
  .aisle-head { flex-direction: row; align-items: baseline; }
  .aisle-figure { font-size: 32px; }
  .mini-meta { display: none; }
}

/* ---- Finding a product ----------------------------------------------------
 * Searching and scanning were two pages asking the same question, which made
 * a shopper choose a method before they had asked anything. One field takes a
 * name or a barcode, the camera is one tap below it, and both put their
 * answer in the same place.
 *
 * The camera panel is a details element so it opens with no script at all,
 * and /scan/ renders it already open.
 * ------------------------------------------------------------------------ */

.find { padding: 26px 0 4px; }
.find h1 { font-size: 38px; letter-spacing: -0.03em; margin-bottom: 8px; }
.find .lede { font-size: 17.5px; max-width: 52ch; margin-bottom: 22px; }

.find-form { margin: 0 0 14px; }
.find-row { display: flex; gap: 10px; align-items: stretch; }
.find-field { position: relative; display: flex; flex: 1 1 auto; min-width: 0; }
.find-icon {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  color: var(--ink-soft); pointer-events: none; display: flex;
}
.find-row input[type="search"] {
  flex-grow: 1; min-height: 58px; padding: 0 16px 0 46px; font-size: 17px;
  border: 2px solid var(--ink); border-radius: 12px; background: var(--surface);
  color: var(--ink); font-family: inherit; min-width: 0;
}
.find-row input[type="text"] {
  flex-grow: 1; min-height: 48px; padding: 0 14px; font-size: 16px;
  border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface);
  color: var(--ink); font-family: inherit; min-width: 0;
}
.find-row input:focus-visible { outline: 3px solid var(--primary-tint); border-color: var(--primary); }
.find-row .button { min-height: 58px; display: inline-flex; align-items: center; justify-content: center; font-size: 16.5px; }
.manual-entry .find-row .button { min-height: 48px; font-size: 15px; }
.find-hint { margin: 8px 0 0; min-height: 20px; font-size: 13.5px; color: var(--ink-soft); }

/* The camera, one tap away rather than one page away. */
.scanner {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); overflow: hidden; margin: 0 0 24px;
}
.scanner > summary {
  display: flex; align-items: center; gap: 12px; padding: 15px 18px;
  cursor: pointer; list-style: none; font-size: 15.5px; font-weight: 600;
  min-height: 48px;
}
.scanner > summary::-webkit-details-marker { display: none; }
.scanner > summary:hover { background: var(--surface-2); }
.scanner > summary:focus-visible { outline: 3px solid var(--primary-tint); outline-offset: -3px; }
.scan-icon { color: var(--primary); display: flex; flex: none; }
.scan-summary-text { flex-grow: 1; }
.scan-chevron { color: var(--ink-soft); display: flex; flex: none; transition: transform 0.15s ease; }
.scanner[open] > summary { border-bottom: 1px solid var(--line); }
.scanner[open] .scan-chevron { transform: rotate(180deg); }

.scan-body { padding: 18px; }
.scan-privacy { margin: 0 0 14px; font-size: 13.5px; color: var(--ink-soft); line-height: 1.5; max-width: 60ch; }
.scan-status { margin: 0 0 12px; font-size: 14px; font-weight: 600; }

.scan-stage { position: relative; border-radius: 12px; overflow: hidden; background: var(--surface-2); line-height: 0; }
/* Quagga appends its own working canvas to the stage. It is sized to the
 * raw camera frame, not to the cropped preview, so drawing it over the
 * video would put the locator box in the wrong place. */
.scan-stage canvas { display: none; }
.scan-stage video { width: 100%; max-height: 340px; object-fit: cover; display: block; }
.scan-stage:not(:has(video[srcObject])) { min-height: 0; }

.scan-controls { display: flex; gap: 10px; margin: 14px 0 0; flex-wrap: wrap; }
.scan-controls .button { min-height: 48px; display: inline-flex; align-items: center; }

.manual-entry { margin: 18px 0 0; padding-top: 16px; border-top: 1px solid var(--line); }
.manual-entry label { display: block; font-size: 13.5px; color: var(--ink-soft); margin-bottom: 7px; }

.scan-result:empty { display: none; }
.scan-result { margin-top: 16px; }

@media (prefers-reduced-motion: reduce) {
  .scan-chevron { transition: none; }
}

@media (max-width: 620px) {
  .find h1 { font-size: 29px; }
  .find .lede { font-size: 16px; }
  .find-row { flex-wrap: wrap; }
  .find-field { flex: 1 0 100%; }
  .find-row .button { flex: 1 1 auto; }
  .manual-entry .find-row input[type="text"] { flex: 1 0 100%; }
}

/* htmx indicators. These normally arrive in a stylesheet htmx injects at
 * runtime, which this site's CSP blocks, so they live here instead. Without
 * them every indicator on the site reads as permanently busy. */
.htmx-indicator { opacity: 0; transition: opacity 180ms ease; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .htmx-indicator { transition: none; }
}

/* ---- What kind of additive, and what the unassessed ones are -------------
 * A count of kinds is a fact about the label. It carries no severity colour
 * for that reason: four colours is four colours, not a finding.
 * ------------------------------------------------------------------------ */

.kinds { margin: 0 0 14px; font-size: 14.5px; line-height: 1.55; color: var(--ink); }
.kinds strong { font-weight: 650; }

.unassessed-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.unassessed-list li {
  display: flex; align-items: baseline; gap: 10px; padding: 7px 8px;
  border-radius: 8px; flex-wrap: wrap;
}
.unassessed-list li:nth-child(odd) { background: var(--surface-2); }
.unassessed-name { flex-grow: 1; font-size: 14.5px; }
.unassessed-name.unknown { color: var(--ink-soft); font-style: italic; }
/* A checked finding, not a gap. Carries the words as well as the tint,
 * because the tint alone would be a severity and this is not one. */
.unassessed-list li.flagged { background: var(--high-bg); }
.not-authorised {
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--high-text); white-space: nowrap;
}
.unassessed-class { font-size: 12.5px; color: var(--ink-soft); white-space: nowrap; }

/* ---- Reading measure ------------------------------------------------------
 * The wrap is 940px because tables, ladders and product rows want it. Prose
 * does not: past about 75 characters the eye loses the start of the next line,
 * and body copy was running to 104. Only paragraphs that are direct children
 * of a panel are constrained, so text inside a flex or grid cell keeps the
 * width its cell gives it.
 * ------------------------------------------------------------------------ */

.panel > p,
.panel > .sub,
.panel > ul:not([class]),
.panel > ol:not([class]),
/* Page introductions sit outside the panels, and were the widest prose left. */
.lede,
main > p,
.doc-body > p { max-width: 66ch; }

/* The reference entries read as prose too. */
.additive-body p { max-width: 66ch; }

/* ---- The navigation continues past the edge of a phone ---------------------
 * The row scrolls, which is what stopped it wrapping onto a second line and
 * taking the fold with it. A cut off word on its own reads as broken, so the
 * edge fades to say there is more without pretending to be a control.
 * ------------------------------------------------------------------------ */

@media (max-width: 620px) {
  .site-header nav { position: relative; }
  .site-header nav::after {
    content: ""; position: absolute; right: 0; top: 0; bottom: 0; width: 36px;
    background: linear-gradient(to right, var(--surface-fade), var(--surface));
    pointer-events: none;
  }
  .nav { padding-right: 26px; }
}

/* ---- The reference list on a phone ----------------------------------------
 * A row was 175px tall: the name wrapped to two lines, the function to four
 * and the severity word to two, which makes twenty nine entries a list nobody
 * scans. The name and code share a line, the function takes one line and is
 * cut rather than wrapped, and the two axes sit together underneath. Both
 * still carry their word, so the row survives greyscale.
 * ------------------------------------------------------------------------ */

@media (max-width: 620px) {
  .additive > summary { flex-wrap: wrap; gap: 8px 10px; padding: 12px 14px; align-items: center; }
  .severity-tab { width: 100%; height: 4px; min-height: 0; align-self: auto; order: -1; border-radius: 3px; }
  .additive-code { order: 1; }
  /* The name and function sit in an unclassed wrapper, so the wrapper is what
   * has to be ordered: on its own the name and function cannot be moved out
   * of it. */
  .additive > summary > *:not(.severity-tab):not(.additive-code):not(.additive-meta) {
    /* basis 0 rather than auto, so it shares the line with the code chip
     * instead of claiming its content width and wrapping below it. */
    order: 2; flex: 1 1 0; min-width: 0;
  }
  .additive-name { font-size: 15.5px; }
  .additive-function {
    display: block; min-width: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .additive-meta {
    order: 4; flex-basis: 100%; margin-left: 0;
    display: flex; flex-direction: row; align-items: center;
    justify-content: space-between; gap: 12px; flex-wrap: nowrap;
  }
  .evidence { flex-direction: row; align-items: center; gap: 8px; }
  .severity-word { white-space: nowrap; }
}

/* ---- A long reference document -------------------------------------------
 * Contents beside the text on a wide screen, folded away on a phone. A
 * details element rather than a script, so it works with none.
 * ------------------------------------------------------------------------ */

.doc-grid { display: grid; gap: 20px; align-items: start; }
.doc-body { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.doc-body > .panel { margin: 0; }

.doc-contents {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px;
}
.doc-contents summary {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-soft); cursor: pointer;
  list-style: none; min-height: 24px; display: flex; align-items: center;
}
.doc-contents summary::-webkit-details-marker { display: none; }
.doc-contents summary::after { content: " +"; margin-left: auto; font-size: 14px; }
.doc-contents details[open] summary::after { content: " \2212"; }
.doc-contents ul { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.doc-contents a { font-size: 13.5px; text-decoration: none; display: block; min-height: 24px; }
.doc-contents a:hover { text-decoration: underline; }

/* Landing on an anchor should not tuck the heading under the header. */
.doc-body > .panel { scroll-margin-top: 20px; }

@media (min-width: 900px) {
  .doc-grid { grid-template-columns: 232px minmax(0, 1fr); }
  .doc-contents { position: sticky; top: 20px; }
  .doc-contents summary::after { content: ""; }
}

/* Where an additive turns up, by aisle. Counts of labels, so no severity
 * colour: the additive's own grade is already stated above. */
.aisle-tags { list-style: none; margin: 12px 0 4px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.aisle-tags a {
  display: inline-block; font-size: 13px; text-decoration: none;
  padding: 6px 12px; border-radius: 8px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink);
}
.aisle-tags a:hover { background: var(--primary-tint); color: var(--primary-deep); }

/* ---- Two measures, not two halves of one ---------------------------------
 * Side by side lists invite a reader to take them as a good half and a bad
 * half. Naming the axis above each heading is what stops that, and it is why
 * neither column carries a severity colour: the columns answer different
 * questions and a product can appear in both.
 * ------------------------------------------------------------------------ */

/* Matches .panel > p on specificity, which the plain class did not, so the
 * reading measure does not cut a structural rule short. */
.panel > .lists-intro { max-width: none; }

.lists-intro {
  margin: 22px 0 0; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: 13px; color: var(--ink-soft);
}
.aisle-lists { margin-top: 14px; }
.list-axis {
  margin: 0 0 2px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--primary);
}

/* ---- The reference, as one page -------------------------------------------
 * Three pages that answered one question became one that answers it in order:
 * what we grade, how processed the catalogue is, and the method behind both.
 * It is long by nature, so the parts have to be unmistakable and the contents
 * has to reach all of them.
 * ------------------------------------------------------------------------ */

.reference-hero { padding: 26px 0 4px; }
.ref-section { scroll-margin-top: 16px; }
.ref-section + .ref-section { margin-top: 40px; padding-top: 32px; border-top: 2px solid var(--line); }

.ref-heading {
  font-size: 27px; letter-spacing: -0.025em; margin: 0 0 16px;
}
.ref-section > .panel:first-of-type { margin-top: 0; }

/* Sub-entries in the contents, so an eight entry list still reads as a
 * hierarchy rather than a wall of links. */
.doc-contents .sub-item a {
  padding-left: 12px; border-left: 2px solid var(--line);
  color: var(--ink-soft); font-size: 13px;
}
.doc-contents .sub-item a:hover { border-left-color: var(--primary); color: var(--primary-deep); }

@media (max-width: 620px) {
  .ref-heading { font-size: 22px; }
  .ref-section + .ref-section { margin-top: 30px; padding-top: 24px; }
}

/* ---- The aisles, on the home page -----------------------------------------
 * A compact form of the comparison the full ladder was standing in for. It
 * carries the group 4 colour and nothing else: this is NOVA's ordering of
 * categories, not a judgement of the food in them, and no product is named.
 * ------------------------------------------------------------------------ */

.aisles-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 20px; margin-bottom: 16px;
}
.aisles-head h2 { margin: 2px 0 0; }
.aisles-link { font-size: 13.5px; font-weight: 600; white-space: nowrap; flex: none; }

.home-aisles { list-style: none; margin: 0 0 16px; padding: 0; display: flex; flex-direction: column; gap: 9px; }
.home-aisles li { display: flex; align-items: center; gap: 14px; }
.home-aisle-name { width: 160px; flex: none; font-size: 14.5px; font-weight: 600; text-decoration: none; }
.home-aisle-name:hover { text-decoration: underline; }
.home-aisle-track { flex-grow: 1; height: 12px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.home-aisle-fill { display: block; height: 100%; border-radius: 6px; }
.home-aisle-share {
  width: 44px; text-align: right; font-size: 14px; font-weight: 700;
  font-variant-numeric: tabular-nums; flex: none;
}

@media (max-width: 620px) {
  .aisles-head { flex-direction: column; gap: 8px; }
  .home-aisles li { flex-wrap: wrap; gap: 6px 12px; }
  .home-aisle-name { width: auto; flex-grow: 1; }
  .home-aisle-track { flex-basis: 100%; order: 3; }
}

/* --- Dark ----------------------------------------------------------------
 *
 * The palette and nothing else. Every rule above takes its colour from a
 * token, so dark mode is a redefinition rather than a second stylesheet and
 * the two cannot drift apart. The test suite holds that line.
 *
 * Three things deliberately do not invert:
 *
 *   - NOVA group colours are an identity carrying white numerals, and a mid
 *     tone reads on either background.
 *   - The plate behind a product photograph. Most Open Food Facts pictures
 *     are shot on white and cut out badly, so a dark plate would ring every
 *     pack with a white halo. It dims instead of flipping.
 *   - Severity keeps its hue. Green, amber, orange and red have to mean the
 *     same thing in both themes; only lightness moves, and it moves far
 *     enough that each still clears 4.5:1 on the surface it sits on.
 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg: #0e1615;
    --surface: #16211f;
    --surface-2: #1d2a28;
    --ink: #e6eeeb;
    --ink-soft: #a1b2ad;
    --line: #2b3a37;
    --primary: #5cc7ae;
    --primary-deep: #8adcc8;
    --primary-tint: #14302c;
    --on-primary: #05231f;
    --chip-line: #235049;

    --safe: #43c07c;
    --low: #d6a63c;
    --moderate: #ee8b4c;
    --high: #f0756b;
    --safe-bg: #10261b;
    --low-bg: #262014;
    --moderate-bg: #2b1d14;
    --high-bg: #2c1a18;
    --safe-text: #63d195;
    --low-text: #e6c37a;
    --moderate-text: #ee8b4c;
    --high-text: #f79c92;
    --safe-line: #245640;
    --low-line: #55471f;
    --high-line: #5d312a;

    --photo-plate: #e7ecea;
    --surface-fade: rgba(22, 33, 31, 0);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 30px rgba(0, 0, 0, 0.4);
  }
}

/* An explicit choice outranks the system in both directions. The two
 * palettes are the same list twice because CSS cannot say "this rule, or
 * that media query" in one selector; a test compares them declaration by
 * declaration so they cannot drift. */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0e1615;
  --surface: #16211f;
  --surface-2: #1d2a28;
  --ink: #e6eeeb;
  --ink-soft: #a1b2ad;
  --line: #2b3a37;
  --primary: #5cc7ae;
  --primary-deep: #8adcc8;
  --primary-tint: #14302c;
  --on-primary: #05231f;
  --chip-line: #235049;

  --safe: #43c07c;
  --low: #d6a63c;
  --moderate: #ee8b4c;
  --high: #f0756b;
  --safe-bg: #10261b;
  --low-bg: #262014;
  --moderate-bg: #2b1d14;
  --high-bg: #2c1a18;
  --safe-text: #63d195;
  --low-text: #e6c37a;
  --moderate-text: #ee8b4c;
  --high-text: #f79c92;
  --safe-line: #245640;
  --low-line: #55471f;
  --high-line: #5d312a;

  --photo-plate: #e7ecea;
  --surface-fade: rgba(22, 33, 31, 0);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.5), 0 8px 30px rgba(0, 0, 0, 0.4);
}

/* ---- Brand indexes ---------------------------------------------------------
 * The staircase between the home page and 147,000 product pages, so it is
 * plain links and no cleverness: a crawler and a reader with no JavaScript
 * both have to be able to walk it.
 */
.brand-index {
  list-style: none; margin: 18px 0 0; padding: 0;
  display: grid; gap: 2px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.brand-index li {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 8px 10px; border-radius: 8px;
}
.brand-index li:nth-child(odd) { background: var(--surface-2); }
.brand-count { font-family: var(--mono); font-size: 12.5px; color: var(--ink-soft); }

.crumbs { font-size: 13.5px; color: var(--ink-soft); margin-bottom: 10px; }
.crumbs span { margin: 0 4px; }

.pager { display: flex; align-items: center; gap: 14px; margin: 22px 0 0; flex-wrap: wrap; }
.pager-where { font-size: 13.5px; color: var(--ink-soft); }
