/*
  Styles for the server-rendered pages: /food/..., /list/... and /lists.

  Deliberately not the app's stylesheet. web/index.html carries about six
  hundred lines of CSS for a filter sidebar, a modal, a photo gallery and a
  paging control, none of which exists here. A crawler and a first-time visitor
  arriving from a search result both get a document that is a few kilobytes
  rather than ninety.

  The cost of that choice is a second copy of the design tokens below, and a
  second copy is how two things drift apart -- FOOD_GROUPS drifted from the
  classifier for a whole release behind a comment asking them to agree. So the
  tokens are checked rather than trusted: tests/verify_live.py reads --accent
  out of both files and fails if they differ.
*/

:root {
  --bg: #fbf9f9;
  --panel: #ffffff;
  --ink: #1e1a1b;
  --muted: #6f6668;
  --line: #e8e2e3;
  --accent: #b81f31;
  --accent-soft: #fbecee;
  --on-accent: #ffffff;
  --data: #2c6e7f;
  --shadow: 0 1px 2px rgba(30,26,27,.05), 0 4px 14px rgba(30,26,27,.06);
}

/* Same two-directional rule as the app: the media query paints dark on the
   first frame for a dark-set phone, and the attribute lets a manual choice win.
   These pages have no theme switch of their own, but the app writes
   data-theme onto the document and a visitor who set it there expects the rest
   of the site to have heard. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171416;
    --panel: #201c1e;
    --ink: #f3eeef;
    --muted: #a09699;
    --line: #332c2e;
    --accent: #ff6b78;
    --accent-soft: #2c1a1d;
    --on-accent: #1a1214;
    --data: #6fb8c9;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
  }
}
:root[data-theme="dark"] {
  --bg: #171416;
  --panel: #201c1e;
  --ink: #f3eeef;
  --muted: #a09699;
  --line: #332c2e;
  --accent: #ff6b78;
  --accent-soft: #2c1a1d;
  --on-accent: #1a1214;
  --data: #6fb8c9;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.6 ui-sans-serif, -apple-system, "Segoe UI", system-ui, sans-serif;
}
a { color: var(--accent); }
img { max-width: 100%; height: auto; }

header.site, footer.site {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  padding: 14px 24px; background: var(--panel);
}
header.site { border-bottom: 1px solid var(--line); }
footer.site {
  border-top: 1px solid var(--line); display: block;
  margin-top: 56px; padding: 24px; color: var(--muted); font-size: 14px;
}
footer.site p { margin: 0 0 8px; }
.fineprint { font-size: 13px; max-width: 62ch; }

.wordmark {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  line-height: 1; text-decoration: none; color: var(--ink);
}
.logo { height: 22px; width: auto; display: block; color: var(--ink); }
.wordmark span { font-size: 13px; font-weight: 600; }
.cta {
  margin-left: auto; background: var(--accent); color: var(--on-accent);
  text-decoration: none; border-radius: 8px; padding: 9px 15px;
  font-size: 14px; font-weight: 500;
}
.cta:hover { filter: brightness(1.08); }

main { max-width: 900px; margin: 0 auto; padding: 32px 24px 0; }
h1 { font-size: 27px; line-height: 1.25; margin: 0 0 8px; }
h2 { font-size: 19px; margin: 40px 0 12px; }
.lede { color: var(--muted); margin: 0 0 6px; max-width: 62ch; }

/* One measured figure, presented as a figure. --data is the project's marker
   for a number that was read rather than chosen. */
.count { color: var(--data); font-variant-numeric: tabular-nums; }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 18px 20px; box-shadow: var(--shadow);
}

/* The food page's headline block: photo beside the identifying facts. */
.masthead { display: flex; gap: 22px; flex-wrap: wrap; align-items: flex-start; }
.masthead img {
  width: 190px; border-radius: 10px; background: var(--accent-soft);
}
.masthead .facts { flex: 1; min-width: 240px; }
.brand { color: var(--muted); margin: 0 0 4px; }
.reference {
  color: var(--data); font-size: 14px; margin: 0 0 4px;
}
.credit { color: var(--muted); font-size: 12px; margin: 6px 0 0; }

table.nutrition { border-collapse: collapse; width: 100%; max-width: 460px; }
table.nutrition th, table.nutrition td {
  text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line);
  font-weight: 400;
}
table.nutrition td { text-align: right; font-variant-numeric: tabular-nums; }
table.nutrition caption {
  text-align: left; color: var(--muted); font-size: 14px; padding-bottom: 8px;
}
.unmeasured { color: var(--muted); font-size: 14px; }

/* Chips: allergens cleared, diets matched, the food group. */
ul.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 0; }
ul.chips li {
  border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px; font-size: 14px; background: var(--bg);
}
ul.chips li.clear { border-color: var(--accent); background: var(--accent-soft); }

/* The result list on a landing page, and the related-links lists. */
ul.foods { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
ul.foods li {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 10px; padding: 12px 15px;
}
ul.foods a { font-weight: 500; text-decoration: none; }
ul.foods a:hover { text-decoration: underline; }
.stats {
  color: var(--muted); font-size: 14px; margin: 3px 0 0;
  font-variant-numeric: tabular-nums;
}
.stats b { color: var(--ink); font-weight: 600; }

ul.links { list-style: none; padding: 0; margin: 0;
  display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
ul.links a { text-decoration: none; }
ul.links a:hover { text-decoration: underline; }

/* Wide content must scroll inside itself rather than pushing the page sideways
   on a phone -- the app's grid was checked at 375px and this has to match. */
.scroll-x { overflow-x: auto; }

@media (max-width: 560px) {
  main { padding: 22px 16px 0; }
  h1 { font-size: 23px; }
  .masthead img { width: 100%; max-width: 260px; }

  /* The same audit that fixed the app's tap targets at 375px, applied here.
     These pages were sound on every other count -- nothing scrolled sideways,
     the nutrition tables scrolled inside their .scroll-x boxes -- but a plain
     text link is only as tall as its line box, which measured 21px on the
     /lists index and inside every result list. Height only: these links are
     already wide, so the extra room costs the layout nothing. */
  ul.links a, ul.foods a { display: inline-block; padding: 8px 0; }
  footer.site a { display: inline-block; padding: 6px 0; }
  .cta { padding: 12px 16px; }
}
