/* Comparesame — one centred column, Inter (self-hosted, SIL OFL: fonts/OFL.txt) over the system stack,
   one accent (#0f6b4f) used only on primary buttons, links, the wordmark and the saving figure.
   Light + dark. Every text/background pair is AA or better (ratios listed in reports/round-f.md). */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/Inter-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("fonts/Inter-SemiBold.woff2") format("woff2");
}

:root {
  --accent: #0f6b4f;          /* primary button fill: white text on it 6.49:1 */
  --accent-hover: #0b5a42;    /* white on it 8.22:1 */
  --accent-ink: #0f6b4f;      /* links, wordmark, saving figure on --bg: 6.49:1 */
  --on-accent: #ffffff;
  --bg: #ffffff;
  --surface: #f5f5f5;         /* hover fill of secondary buttons only */
  --ink: #111111;             /* 18.88:1 */
  --ink-2: #444444;           /* 9.74:1 */
  --muted: #6b6b6b;           /* 5.33:1 */
  --line: #e2e2e2;            /* decorative hairlines (cards, sections) */
  --field: #8a8a8a;           /* input and secondary-button borders: 3.45:1 (WCAG 1.4.11) */
  --warn-bg: #fff4e5;
  --warn-ink: #7a3e00;        /* 7.68:1 on --warn-bg, 8.34:1 on --bg */
  --focus: #1a73e8;
  --radius: 8px;
  /* spacing scale: every margin, padding and gap uses one of these */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  /* type scale, four steps: small · body · title · the saving figure */
  --fs-1: 0.875rem;
  --fs-2: 1rem;
  --fs-3: 1.5rem;
  --fs-4: 2.25rem;
  /* text column: 42rem for text and forms; the results state widens it to 48rem (below) */
  --col: 42rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #0f6b4f;
    --accent-hover: #0b5a42;
    --accent-ink: #7fd6b3;    /* 10.60:1 on --bg */
    --on-accent: #ffffff;
    --bg: #111614;
    --surface: #1a211e;
    --ink: #e8eeeb;           /* 15.55:1 */
    --ink-2: #c3cdc8;         /* 11.22:1 */
    --muted: #a9b6b0;         /* 8.71:1 */
    --line: #34403a;
    --field: #7d8a84;         /* 5.08:1 */
    --warn-bg: #3a2a12;
    --warn-ink: #ffd8a8;
    --focus: #8ab4f8;
    color-scheme: dark;
  }
}
@media (min-width: 40rem) {
  :root {
    --fs-2: 1.0625rem;
    --fs-3: 1.75rem;
    --fs-4: 3rem;
  }
}
body:has(#s-results:not([hidden])) { --col: 48rem; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  font-size: var(--fs-2);
  line-height: 1.55;
  /* Chrome on Linux rounds hinted glyph advances to whole pixels, which spaces Inter unevenly
     ("t ext"); this keeps glyph positions exact there and changes nothing visible elsewhere */
  text-rendering: geometricPrecision;
  overflow-wrap: anywhere;
}
.wrap { width: 100%; max-width: calc(var(--col) + 2 * var(--s-4)); margin: 0 auto; padding: 0 var(--s-4); }
a { color: var(--accent-ink); text-underline-offset: 0.15em; }
h1, h2, h3 { font-weight: 600; line-height: 1.15; }
h1 { font-size: var(--fs-3); letter-spacing: -0.015em; margin: var(--s-6) 0 var(--s-3); }
h2 { font-size: var(--fs-2); margin: var(--s-6) 0 var(--s-2); }
h3 { font-size: var(--fs-2); margin: var(--s-4) 0 var(--s-1); }
p { margin: var(--s-2) 0; }
strong, b { font-weight: 600; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1:focus, main:focus { outline: none; }

.skip { position: absolute; left: -999px; top: 0; background: var(--bg); padding: var(--s-2) var(--s-3); z-index: 10; }
.skip:focus { left: var(--s-2); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* small uppercase labels: confirm fields, section eyebrows */
.card > label, .card > legend, .pair label, .summary h2, .how h2 {
  font-size: var(--fs-1);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-2);
}

/* header / footer */
.site-header { border-bottom: 1px solid var(--line); padding: var(--s-3) 0; }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.brand { font-weight: 600; font-size: var(--fs-2); letter-spacing: -0.01em; color: var(--accent-ink); text-decoration: none; }
.tagline { color: var(--muted); margin: 0 auto; font-size: var(--fs-1); }
.site-footer { border-top: 1px solid var(--line); margin-top: var(--s-6); padding: var(--s-4) 0 var(--s-6); color: var(--muted); font-size: var(--fs-1); }
.site-footer nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--s-2); }
.site-footer a { display: inline-block; padding: var(--s-3) 0; }
/* the language switch has a row of its own, so it never wraps alone after the page links (RO on a phone) */
.footer-lang { margin: 0; }

/* controls */
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
label, legend { display: block; font-weight: 600; margin: 0 0 var(--s-2); }
input[type="text"], input[type="url"], select, textarea {
  width: 100%;
  min-height: 44px;
  font: inherit;
  text-rendering: inherit; /* form controls reset it to auto in the browser's own stylesheet */
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--field);
  border-radius: var(--radius);
  padding: var(--s-2) var(--s-3);
}
textarea { resize: vertical; line-height: 1.5; }
::placeholder { color: var(--muted); opacity: 1; }
button, .button {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: var(--s-2) var(--s-4);
  font: inherit; font-weight: 600; line-height: 1.2; text-align: center; text-decoration: none; text-rendering: inherit;
  border: 1px solid transparent; border-radius: var(--radius); cursor: pointer;
}
.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.secondary { background: var(--bg); color: var(--ink); border-color: var(--field); }
.secondary:hover:not(:disabled) { background: var(--surface); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.lang-toggle { background: transparent; color: var(--ink); border-color: var(--field); padding: var(--s-1) var(--s-3); font-size: var(--fs-1); }
.lang-toggle:hover { background: var(--surface); }
.lang-toggle.link { border: 0; padding: var(--s-3) 0; background: none; color: var(--accent-ink); text-decoration: underline; text-underline-offset: 0.15em; font-weight: 400; font-size: inherit; }

/* content blocks */
.muted { color: var(--muted); }
.small { font-size: var(--fs-1); }
.honesty { color: var(--muted); font-size: var(--fs-1); margin-top: var(--s-4); }
.steps { padding-left: var(--s-5); }
.steps li { margin: var(--s-1) 0; }
.progress { color: var(--muted); font-size: var(--fs-1); font-variant-numeric: tabular-nums; }
.alert { background: var(--warn-bg); color: var(--warn-ink); border-radius: var(--radius); padding: var(--s-3) var(--s-4); margin: var(--s-4) 0; }
.alert p { margin: 0; }
.alert .secondary { margin-top: var(--s-3); background: transparent; color: var(--warn-ink); border-color: var(--warn-ink); }

/* 1. home */
#paste-form > label { font-size: var(--fs-2); }
/* the input selector, then the field(s) it shows: the product link and/or the page text */
.field { margin-top: var(--s-4); }
#paste-url, #paste-text { padding: var(--s-3) var(--s-4); }
/* a native select cannot wrap its closed text; the longest option (Romanian, on a phone) ends in an ellipsis and the open list shows it whole */
#input-mode { text-overflow: ellipsis; }
.help { color: var(--muted); font-size: var(--fs-1); margin: var(--s-2) 0 0; }
.paste-row { display: grid; gap: var(--s-3); margin-top: var(--s-5); }
#paste-submit { width: 100%; }
.how { border-top: 1px solid var(--line); margin-top: var(--s-6); padding-top: var(--s-4); }
.how h2 { margin: 0 0 var(--s-3); }
.how ol { display: grid; gap: var(--s-3); margin: 0; padding: 0; list-style-position: inside; }
.how li { color: var(--ink-2); font-size: var(--fs-1); }
.how li::marker { color: var(--muted); font-weight: 600; }

/* 2. confirm */
#read-from, #f-class { font-size: var(--fs-1); }
.card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s-4); margin: var(--s-3) 0; min-width: 0; }
.card > :first-child { margin-top: 0; }
fieldset.card legend { float: left; width: 100%; padding: 0; }
fieldset.card legend + * { clear: both; }
.evidence { color: var(--muted); font-size: var(--fs-1); margin: var(--s-2) 0 0; padding-left: var(--s-3); border-left: 2px solid var(--line); }
.evidence q { font-style: normal; }
.missing { color: var(--warn-ink); font-size: var(--fs-1); margin: var(--s-2) 0 0; padding-left: var(--s-3); border-left: 2px solid var(--warn-ink); }
.pair { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s-3); }
.kind { display: flex; flex-wrap: wrap; gap: 0 var(--s-4); align-items: center; }
.kind .small { width: 100%; color: var(--ink-2); }
label.radio { display: flex; align-items: center; gap: var(--s-2); min-height: 44px; margin: 0; font-weight: 400; }
label.radio input { width: 20px; height: 20px; margin: 0; accent-color: var(--ink); }
.rows { list-style: none; padding: 0; margin: var(--s-3) 0 var(--s-2); }
.row { display: grid; grid-template-columns: minmax(0, 1fr) 6.5rem; gap: var(--s-2); margin-bottom: var(--s-2); align-items: center; }
.row .remove { grid-column: 1 / -1; justify-self: start; }
.pct-wrap { display: flex; align-items: center; gap: var(--s-1); color: var(--ink-2); }
.pct-wrap input { text-align: right; font-variant-numeric: tabular-nums; }
#comp-sum { color: var(--ink-2); }
/* the page text's value where it differs from the link's: same chip as "Use this block" */
.alt .chip { margin-bottom: 0; }
#comp-ingr label { margin-top: var(--s-3); }
.chips { list-style: none; padding: 0; margin: 0 0 var(--s-2); }
.chip { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-3); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s-2) var(--s-3); margin: var(--s-2) 0; }
.in-use { font-weight: 600; }
.confirm-bar { margin-top: var(--s-4); padding: var(--s-3) 0; }
.why { font-weight: 600; margin: 0 0 var(--s-3); }
.why.blocked { color: var(--warn-ink); }
.confirm-bar .progress { margin: 0 0 var(--s-3); }
#confirm-submit { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-top: var(--s-4); }
.actions > * { flex: 1 1 12rem; }

/* 3. results */
.verdict { border: 1px solid var(--line); border-left: 4px solid var(--muted); border-radius: 0 var(--radius) var(--radius) 0; padding: var(--s-3) var(--s-4); margin: var(--s-4) 0; }
.verdict.cheaper_found { border-left-color: var(--accent-ink); }
.verdict p { margin: var(--s-1) 0 0; }
.verdict .verdict-title { font-weight: 600; margin: 0; }
.summary { border-bottom: 1px solid var(--line); padding: 0 0 var(--s-4); margin: var(--s-5) 0 var(--s-4); }
.summary h2 { margin: 0 0 var(--s-1); }
.summary p { margin: var(--s-1) 0 0; }
.summary .ref-line { font-variant-numeric: tabular-nums; }
.matches { list-style: none; padding: 0; margin: 0; }
.match h3 { margin: 0; overflow-wrap: anywhere; }
.match .name { margin: var(--s-1) 0 0; }
.saving { margin: var(--s-3) 0 var(--s-2); color: var(--ink-2); line-height: 1.15; }
.saving-num { font-size: var(--fs-4); font-weight: 600; letter-spacing: -0.02em; color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.figures { margin: 0; font-variant-numeric: tabular-nums; }
.match .note { margin: var(--s-1) 0 0; }
.safety { list-style: none; padding: var(--s-3) 0 0; margin: var(--s-3) 0 0; border-top: 1px solid var(--line); color: var(--ink-2); }
.safety li { margin: 0 0 var(--s-1); }
.safety .warn { color: var(--warn-ink); }
.match .open { display: flex; justify-content: flex-end; margin: var(--s-3) 0 0; }
#notes { padding-left: var(--s-5); color: var(--ink-2); font-size: var(--fs-1); }
#notes li { margin: var(--s-1) 0; }

/* phones: the confirm screen keeps its reason line and Compare button in view */
@media (width < 40rem) {
  .confirm-bar { position: sticky; bottom: 0; z-index: 1; background: var(--bg); }
  .confirm-bar::before { content: ""; position: absolute; inset: 0 calc(-1 * var(--s-4)); z-index: -1; background: var(--bg); border-top: 1px solid var(--line); }
  html:has(#s-confirm:not([hidden])) { scroll-padding-bottom: 10rem; }
}

@media (min-width: 40rem) {
  .paste-row { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
  .paste-row label { margin-bottom: var(--s-2); }
  #paste-submit, #confirm-submit { width: auto; min-width: 10rem; }
  .how ol { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-5); }
  .row { grid-template-columns: minmax(0, 1fr) 7rem auto; }
  .row .remove { grid-column: auto; }
  .confirm-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3) var(--s-4); border-top: 1px solid var(--line); padding-top: var(--s-4); }
  .confirm-bar .why, .confirm-bar .progress { margin: 0; flex: 1 1 16rem; }
  .actions > * { flex: 0 1 auto; }
}
