/* BiteCheck — mobile-first, no inline styles (CSP style-src 'self'). */

:root {
  --bg: #f5f6f4;
  --card: #ffffff;
  --text: #1c1f1d;
  --muted: #4d5450;          /* 7.6:1 on white */
  --border: #c9cec9;
  --primary: #1f5f3a;        /* 7.9:1 with white text */
  --primary-hover: #174a2d;
  --focus: #1a56db;
  --contains-bg: #a3121f;    /* white text 7.2:1 */
  --may-bg: #ffe08a;         /* dark text 13:1 */
  --may-text: #3b2a00;
  --none-bg: #1e6b34;        /* white text 6.4:1 */
  --unknown-bg: #e2e5e3;     /* dark text 13:1 */
  --radius: 12px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}

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

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

.site-header,
main,
.site-footer {
  max-width: 40rem;
  margin: 0 auto;
  padding: 0 1rem;
}

.site-header { padding-top: 1.25rem; }

.site-header h1 {
  margin: 0;
  font-size: 1.75rem;
  color: var(--primary);
}

.tagline { margin: 0 0 1rem; color: var(--muted); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.card h2 { margin: 0 0 0.5rem; font-size: 1.25rem; }

.hint { margin: 0.25rem 0 0.75rem; color: var(--muted); font-size: 0.95rem; }

/* Buttons and chips: at least 44x44 px touch targets (FR-14). */
.button {
  min-height: 44px;
  min-width: 44px;
  padding: 0.6rem 1rem;
  border: 2px solid var(--primary);
  border-radius: 999px;
  background: var(--card);
  color: var(--primary);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.button-primary { background: var(--primary); color: #ffffff; }
.button-primary:hover { background: var(--primary-hover); }
.button:disabled { opacity: 0.6; cursor: not-allowed; }

#scan-button { width: 100%; }

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }

.chip {
  min-height: 44px;
  padding: 0.5rem 0.9rem;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.chip[aria-pressed="true"] {
  border-color: var(--primary);
  background: var(--primary);
  color: #ffffff;
}

.chip[aria-pressed="true"]::before { content: "✓ "; }

.scanner { margin-top: 0.75rem; }
.reader { width: 100%; overflow: hidden; border-radius: var(--radius); background: #000000; }
.reader video { width: 100% !important; display: block; }
#scan-cancel { margin-top: 0.5rem; }

.barcode-form { margin-top: 1rem; }
.barcode-form label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
.input-row { display: flex; gap: 0.5rem; }

.input-row input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0.5rem 0.75rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  font: inherit;
  font-size: 1.1rem;
  letter-spacing: 0.05em;
}

.message {
  margin: 0.75rem 0 0;
  padding: 0.75rem;
  border-radius: 8px;
  background: var(--unknown-bg);
}

.message-error { background: #fde7e9; color: #6b0b14; }

/* Verdict: colour AND icon AND text, never colour alone (FR-13). */
.verdict {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.verdict-icon { font-size: 1.5rem; line-height: 1; }
.verdict-contains { background: var(--contains-bg); color: #ffffff; }
.verdict-may_contain { background: var(--may-bg); color: var(--may-text); }
.verdict-not_listed { background: var(--none-bg); color: #ffffff; }
.verdict-unknown { background: var(--unknown-bg); color: var(--text); }

.product { display: flex; gap: 1rem; align-items: flex-start; }
.product h2 { margin-bottom: 0.25rem; }
.product-image {
  width: 96px;
  height: 96px;
  object-fit: contain;
  border-radius: 8px;
  background: #ffffff;
  flex-shrink: 0;
}
.product-meta { margin: 0; color: var(--muted); }

.nutriscore {
  display: inline-block;
  margin: 0.5rem 0 0;
  padding: 0.2rem 0.6rem;
  border-radius: 6px;
  font-weight: 700;
  background: var(--unknown-bg);
}
.nutriscore-a { background: #038141; color: #ffffff; }
.nutriscore-b { background: #85bb2f; color: #1c1f1d; }
.nutriscore-c { background: #fecb02; color: #1c1f1d; }
.nutriscore-d { background: #ee8100; color: #1c1f1d; }
.nutriscore-e { background: #c62d12; color: #ffffff; }

.result h3 { margin: 1rem 0 0.25rem; font-size: 1rem; }

.allergen-results { list-style: none; padding: 0; margin: 0 0 1rem; }
.allergen-results li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}
.status-contains { color: var(--contains-bg); font-weight: 700; }
.status-may_contain { color: #7a4f00; font-weight: 700; }
.status-not_listed { color: var(--muted); }

details { margin: 0.5rem 0; }
summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; font-weight: 600; }

.attribution { margin: 0.5rem 0; }
.disclaimer {
  margin: 0.5rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer { padding-bottom: 2rem; color: var(--muted); font-size: 0.9rem; text-align: center; }
