/* The food search page (/foods), in the Label look of site.css. It reuses the site's panel,
   tag, button, eyebrow and section-head styles; this file adds what only the search needs.
   Colours: green for what helps, amber for worth knowing, rust for concerns, yellow for the one
   answer. No inline styles anywhere (the page's security policy forbids them): the script sets
   custom properties through the CSSOM instead. */

:root {
  --bad: #8a1c0f;
  --moderate: #b07a00;
}

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font: 13px/18px var(--mono); color: var(--muted); }

/* Heading and search */
.head { display: flex; flex-direction: column; gap: 22px; padding: 44px 0 28px; }
.head h1 { font-size: clamp(44px, 7vw, 84px); line-height: 0.94; letter-spacing: -0.035em; text-wrap: balance; }
.tagline { font-size: 14px; line-height: 20px; color: var(--muted); }
.searchrow { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 24px; }
.search { position: relative; flex: 1 1 520px; max-width: 760px; display: flex; align-items: center; gap: 12px; height: 64px; padding: 0 8px 0 18px; border: 2px solid var(--ink); border-radius: 10px; background: #fff; }
/* Focus turns the box's own border green instead of drawing a second ring around it. */
.search:focus-within { border-color: var(--action); }
.search svg { flex: none; width: 24px; height: 24px; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font: 800 24px/1 var(--sans); letter-spacing: -0.01em; }
.search input::placeholder { color: #6b6b67; font-weight: 600; }
.search input::-webkit-search-cancel-button { display: none; }
.clear { display: none; width: 44px; height: 44px; border: 0; background: transparent; color: inherit; font: inherit; font-size: 30px; line-height: 1; cursor: pointer; }
.search.has-text .clear { display: block; }
/* The loader: a short ink bar sliding along the bottom of the box while a search is pending. */
.search::after { content: ""; position: absolute; left: 14px; bottom: 5px; width: 28%; height: 3px; border-radius: 2px; background: var(--ink); opacity: 0; }
.search.busy::after { opacity: 1; animation: load 1.1s ease-in-out infinite alternate; }
@keyframes load { from { transform: translateX(0); } to { transform: translateX(250%); } }
.region { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; font-size: 14px; line-height: 20px; color: var(--muted); }
.strip { display: flex; border: 2px solid var(--ink); border-radius: 10px; overflow: hidden; }
.strip a { display: flex; align-items: center; min-height: 36px; padding: 0 14px; background: #fff; color: var(--ink); font-size: 14px; font-weight: 700; text-decoration: none; }
.strip a + a { border-left: 2px solid var(--ink); }
.strip a:hover { background: var(--soft); color: var(--ink); }
.strip a[aria-current] { background: var(--ink); color: #fff; }
.status { min-height: 20px; padding-bottom: 14px; display: flex; flex-wrap: wrap; gap: 8px; font-size: 14px; line-height: 20px; color: var(--muted); }
.chip { border: 1.5px solid var(--ink); border-radius: 6px; padding: 0 7px; font: 700 12px/20px var(--sans); letter-spacing: 0.04em; color: var(--ink); }
#view { transition: opacity 0.15s; }
body.loading #view { opacity: 0.4; pointer-events: none; }

/* Score boxes */
.tag.ink { background: var(--ink); color: #fff; padding: 4px 8px; }
.sbox { --s: 44px; flex: none; display: flex; align-items: center; justify-content: center; width: var(--s); height: var(--s); border: 2px solid transparent; border-radius: calc(var(--s) * 0.23); font-size: calc(var(--s) * 0.5); line-height: 1; font-weight: 900; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.sbox.healthy { background: var(--action); color: #fff; }
.sbox.moderate { background: var(--warn-bg); border-color: var(--ink); color: var(--ink); }
.sbox.less { background: var(--bad); color: #fff; }
.sbox.none { background: var(--soft); border-color: var(--ink); color: var(--ink); }
.sbox.big { --s: 112px; }

/* The top match: one card with everything about the food */
.card { border: 2px solid var(--ink); border-radius: 14px; overflow: hidden; background: #fff; scroll-margin-top: 16px; }
.card-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 20px; padding: 14px 28px; border-bottom: 2px solid var(--ink); }
.bar-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.card-body { display: flex; flex-wrap: wrap; }
.col-main { flex: 1 1 560px; min-width: 0; padding: 36px 40px 40px; display: flex; flex-direction: column; gap: 26px; }
.col-side { flex: 1 1 420px; min-width: 0; padding: 36px 40px 40px; display: flex; flex-direction: column; gap: 20px; background: var(--soft); }
.col-side .btn { width: 100%; }
.name h2 { font-size: clamp(38px, 5vw, 60px); line-height: 0.98; letter-spacing: -0.035em; overflow-wrap: anywhere; outline: none; }
.name p { padding-top: 6px; font-size: 16px; line-height: 24px; color: var(--muted); }
.scorerow { display: flex; align-items: center; gap: 22px; }
.verdict { font-size: 40px; line-height: 44px; font-weight: 900; letter-spacing: -0.03em; }
.of { font-size: 16px; line-height: 24px; color: var(--muted); }
.cells { display: flex; gap: 4px; }
.cells i { flex: 1; height: 12px; border-radius: 3px; background: var(--rule); }
.cells i.healthy { background: var(--action); }
.cells i.moderate { background: var(--moderate); }
.cells i.less { background: var(--bad); }
.official { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; }
.nutri { display: flex; align-items: center; gap: 10px; }
.nutri small { font-size: 13px; line-height: 18px; font-weight: 700; }
.grades { display: flex; align-items: center; gap: 3px; }
.grades i { display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 6px; background: var(--c); color: var(--ink); font: 800 13px/1 var(--sans); font-style: normal; }
.grades i[data-g="a"], .grades i[data-g="e"] { color: #fff; }
.grades i.on { width: 34px; height: 34px; border-radius: 8px; font-size: 18px; font-weight: 900; box-shadow: 0 0 0 2px var(--ink); }
.answer-line { max-width: 560px; font-size: 22px; line-height: 35px; text-wrap: pretty; }
.answer-line .answer { padding: 3px 5px; }

.section-title { border-top: 4px solid var(--ink); padding: 10px 0 4px; font-size: 24px; line-height: 28px; font-weight: 900; letter-spacing: -0.025em; }
.findings { list-style: none; margin: 0; padding: 0; }
.findings li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 14px; padding: 12px 0; border-top: 1px solid var(--rule); }
.findings b { display: block; font-size: 18px; line-height: 24px; font-weight: 900; letter-spacing: -0.015em; }
.findings p { font-size: 15px; line-height: 22px; color: var(--muted); }
.mark { display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border: 2px solid transparent; border-radius: 6px; font-size: 18px; font-weight: 900; line-height: 1; }
.bad .mark { background: var(--bad); color: #fff; }
.warn .mark { background: var(--warn-bg); border-color: var(--ink); color: var(--ink); font-size: 16px; }
.good .mark { background: var(--action); color: #fff; }

.compare:empty { display: none; }
.cmp { padding: 10px 0 8px; }
.cmp-sub { padding-bottom: 6px; font-size: 14px; line-height: 20px; color: var(--muted); }
.cmp-top { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; line-height: 20px; padding-bottom: 8px; }
.cmp-top b { font-weight: 700; }
.cmp.bad .cmp-top b { color: var(--bad); }
.cmp.good .cmp-top b { color: var(--link); }
.track { position: relative; height: 12px; border-radius: 6px; background: var(--rule); }
.track i { position: absolute; top: -4px; left: calc(var(--p) * 1%); width: 6px; height: 20px; border-radius: 3px; background: var(--ink); transform: translateX(-3px); }

.datanote { border: 2px solid var(--ink); border-radius: 10px; padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; font-size: 15px; line-height: 22px; }
.datanote .ends { display: flex; justify-content: space-between; font-size: 13px; line-height: 18px; color: var(--muted); }

/* The amount, the nutrition label and the sugar note */
.amount { display: flex; flex-wrap: wrap; gap: 10px; }
.seg, .stepper { display: flex; align-items: stretch; border: 2px solid var(--ink); border-radius: 10px; overflow: hidden; background: #fff; }
.seg button, .stepper button { min-width: 44px; height: 44px; padding: 0 16px; border: 0; background: #fff; font-size: 15px; font-weight: 700; cursor: pointer; }
.seg button + button, .stepper button + span, .stepper span + button { border-left: 2px solid var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.stepper button { font-size: 22px; padding: 0 14px; }
.stepper button:disabled { color: #9a9a96; cursor: default; }
.stepper span { display: flex; align-items: center; justify-content: center; min-width: 96px; padding: 0 10px; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.col-side .label { padding: 20px 22px; }
.col-side .label-big .unit { font-size: 30px; line-height: 40px; }
.col-side .label-big .value { font-size: 72px; line-height: 64px; padding: 0 10px; }
.sugarnote { display: flex; align-items: flex-start; gap: 16px; border-top: 4px solid var(--ink); padding-top: 14px; }
.sugarnote b { display: block; font-size: 16px; line-height: 24px; }
.sugarnote p { font-size: 14px; line-height: 20px; color: var(--muted); }
.cubes { display: flex; flex-wrap: wrap; gap: 6px; max-width: 130px; flex: none; align-items: center; }
.cube { width: 28px; height: 28px; border: 2px solid var(--ink); border-radius: 6px; background: linear-gradient(to right, var(--ink) var(--fill), #fff var(--fill)); }
.cubes em { font-style: normal; font-weight: 800; font-size: 14px; }
.note { font-size: 13px; line-height: 19px; color: var(--muted); }
.how summary { cursor: pointer; font-size: 14px; font-weight: 700; color: var(--link); }
.how ul { margin: 8px 0 0; padding-left: 20px; font-size: 14px; line-height: 21px; color: var(--muted); }

/* The other matches */
.more { margin-top: 56px; }
.section-head span { font-size: 14px; line-height: 20px; color: var(--muted); }
.foods { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(440px, 100%), 1fr)); column-gap: 56px; }
.food { width: 100%; display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 12px 0; border: 0; border-bottom: 1px solid var(--rule); background: transparent; text-align: left; cursor: pointer; }
.food:hover .title { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.food .info { min-width: 0; display: flex; flex-direction: column; }
.food .title { font-size: 18px; line-height: 24px; font-weight: 800; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.food .meta { font-size: 14px; line-height: 20px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.food .cal { display: flex; flex-direction: column; align-items: flex-end; }
.food .cal b { font-size: 24px; line-height: 26px; font-weight: 900; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.food .cal small { font-size: 14px; line-height: 20px; color: var(--muted); }
mark { background: linear-gradient(transparent 62%, var(--answer) 62%); color: inherit; }
.more-btn { display: flex; align-items: center; gap: 8px; padding: 18px 0; border: 0; background: none; color: var(--link); font-weight: 700; font-size: 16px; cursor: pointer; }
.more-btn::after { content: "↓"; }

/* The empty and error states */
.panel { border: 2px solid var(--ink); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.panel.bad { border-color: var(--bad); }
.panel h2 { font-size: 32px; line-height: 1.05; }
.panel p { color: var(--muted); max-width: 560px; }
.examples { display: flex; flex-wrap: wrap; gap: 10px; }
.pill { min-height: 44px; padding: 0 16px; border: 2px solid var(--ink); border-radius: 10px; background: #fff; color: var(--ink); font: 700 15px/1.2 var(--sans); cursor: pointer; }
.pill:hover { background: var(--ink); color: #fff; }
.recent h3 { display: flex; align-items: baseline; gap: 14px; margin-bottom: 10px; font-size: 20px; }
.recent h3 button, .linkbtn { border: 0; background: none; color: var(--link); font: 700 14px/1.2 var(--sans); text-decoration: underline; cursor: pointer; padding: 0; text-align: left; }

/* The developer view (?dev=1 on localhost) */
.dev { border: 2px dashed var(--ink); border-radius: 10px; padding: 12px 14px; background: #fff; font-size: 13px; line-height: 20px; }
.dev summary { cursor: pointer; font-weight: 700; }
.devrow { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 8px 0; }
.dev code { font: 12px var(--mono); }
.scroll { overflow-x: auto; }
.dev table { border-collapse: collapse; width: 100%; font-size: 12px; }
.dev th, .dev td { text-align: left; padding: 3px 8px 3px 0; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.dev .n { text-align: right; font-variant-numeric: tabular-nums; }
.dev tr.shown td { font-weight: 800; }

@media (max-width: 640px) {
  .head { gap: 16px; padding: 28px 0 20px; }
  .search { height: 56px; padding-left: 14px; gap: 10px; }
  .search svg { width: 22px; height: 22px; }
  .search input { font-size: 20px; }
  .card-bar { padding: 12px 16px; }
  .col-main, .col-side { padding: 22px 16px 24px; gap: 22px; }
  .name h2 { font-size: 42px; }
  .scorerow { gap: 16px; }
  .sbox.big { --s: 88px; }
  .verdict { font-size: 34px; line-height: 38px; }
  .answer-line { font-size: 19px; line-height: 30px; }
  .col-side .label { padding: 16px; }
  .col-side .label-title { font-size: 26px; }
  .col-side .label-big .unit { font-size: 28px; }
  .col-side .label-big .value { font-size: 64px; line-height: 58px; padding: 0 8px; }
  .more { margin-top: 36px; }
  .panel { padding: 20px 16px; }
  .panel h2 { font-size: 28px; }
  .findings p { font-size: 14px; line-height: 20px; }
  .findings b { font-size: 17px; line-height: 22px; }
}
@media (prefers-reduced-motion: reduce) { .search.busy::after { animation: none; width: 40%; } #view { transition: none; } }
