/* Monochrome design system — matches the pattern used across Mike's other
   projects (see CarSearchBuddy's Theme.kt): pure white surfaces, pure black
   content, no gray anywhere. Small text is bumped to a heavier weight so it
   never reads as faded — thin black-on-white at small sizes looks gray even
   though it isn't. High-resolution photography carries the visual interest
   instead of color.

   One deliberate exception: a red/yellow/green severity system on results,
   so a shopper can tell a real regulatory finding (red) from a "worth
   knowing" note (yellow) from actual good news (green) at a glance, without
   reading paragraphs. Reserved for severity only — everything else stays
   monochrome. */

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --black: #000000;
  --white: #ffffff;
  --red: #c0272d;
  --yellow: #9a6400;
  --green: #1e7b34;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  background: var(--white);
  color: var(--black);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 500;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-weight: 800; letter-spacing: -0.01em; }
strong { font-weight: 800; }
a { color: var(--black); text-decoration-thickness: 2px; }

button {
  font-family: inherit;
  font-weight: 700;
  border: none;
  cursor: pointer;
  color: inherit;
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + var(--safe-top)) 18px 14px;
  background: var(--white);
  border-bottom: 3px solid var(--black);
}

.wordmark { font-size: 1.05rem; font-weight: 700; }
.wordmark strong { font-weight: 900; }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid var(--black);
  background: var(--white);
  font-weight: 800;
  font-size: 1rem;
}
.icon-btn:active { background: var(--black); color: var(--white); }

/* ---------- Views ---------- */

.view { min-height: calc(100dvh - 64px); display: flex; flex-direction: column; }
.view[hidden] { display: none; }

/* ---------- Home / hero ---------- */

.hero {
  flex: 1;
  min-height: 78vh;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: flex-end;
  padding: 32px 22px 40px;
}

.hero-content { color: var(--white); max-width: 480px; }

.hero h1 {
  font-size: clamp(2.1rem, 7vw, 2.8rem);
  line-height: 1.05;
  margin-bottom: 14px;
}

.hero-sub {
  font-weight: 600;
  font-size: 1.02rem;
  margin-bottom: 22px;
  max-width: 40ch;
}

.btn-photo {
  display: block;
  width: 100%;
  padding: 20px 24px;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--white);
  background-size: cover;
  background-position: center;
  border-radius: var(--radius);
  border: 3px solid var(--white);
  text-align: center;
}
.btn-photo:active { transform: scale(0.98); }

.disclaimer-line {
  text-align: center;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 12px 16px calc(16px + var(--safe-bottom));
}

/* ---------- Scan / photo / loading shared chrome ---------- */

.scan-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 3px solid var(--black);
}

.back-btn {
  background: none;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 6px 0;
}

.scan-header h2 { font-size: 1.05rem; }

#qr-reader {
  width: 100%;
  aspect-ratio: 3 / 4;
  background: var(--black);
  overflow: hidden;
}
#qr-reader video { object-fit: cover; }

.scan-status {
  text-align: center;
  font-weight: 700;
  padding: 16px;
}

.btn-secondary, .photo-capture-btn {
  display: block;
  width: calc(100% - 36px);
  margin: 16px 18px calc(18px + var(--safe-bottom));
  padding: 16px;
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  background: var(--white);
  color: var(--black);
  border: 3px solid var(--black);
  border-radius: var(--radius);
}
.btn-secondary:active, .photo-capture-btn:active { background: var(--black); color: var(--white); }

.hint {
  padding: 18px 22px 4px;
  font-weight: 600;
  font-size: 0.95rem;
}

.ocr-progress { padding: 20px 22px; }
.ocr-progress-bar {
  height: 10px;
  border: 2px solid var(--black);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 10px;
}
.ocr-progress-fill { height: 100%; background: var(--black); width: 0%; transition: width 0.2s; }
#ocr-progress-label { font-weight: 700; text-align: center; }

/* ---------- Loading ---------- */

#view-loading {
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.loading-spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 5px solid var(--black);
  border-top-color: var(--white);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#loading-label { font-weight: 700; }

/* ---------- Empty / not-found ---------- */

.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; text-align: center; gap: 8px; }
.empty-title { font-size: 1.2rem; font-weight: 800; }

/* ---------- Results ---------- */

#results-content { padding: 18px; padding-bottom: calc(24px + var(--safe-bottom)); }

.product-header { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.product-thumb { width: 64px; height: 64px; object-fit: contain; border: 2px solid var(--black); border-radius: 10px; background: var(--white); }
.product-name { font-size: 1.3rem; line-height: 1.15; }
.product-brand { font-weight: 600; font-size: 0.9rem; }

.card {
  border: 3px solid var(--black);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
}
.card-title { font-weight: 800; font-size: 1rem; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.card p { font-weight: 600; font-size: 0.94rem; }
.card-source { font-size: 0.8rem; font-weight: 600; margin-top: 8px; }
.card-source a { text-decoration-thickness: 1px; }

/* Severity system: colored left edge on the card, a colored badge glyph, and
   a plain-word tag — color is never the only signal (accessibility, and it
   directly answers "is this good or bad?" without reading further). */
.card.severity-red { border-left: 8px solid var(--red); }
.card.severity-yellow { border-left: 8px solid var(--yellow); }
.card.severity-green { border-left: 8px solid var(--green); }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 800;
  flex-shrink: 0;
}
.badge-red { background: var(--red); color: var(--white); }
.badge-yellow { background: var(--yellow); color: var(--white); }
.badge-green { background: var(--green); color: var(--white); }

.tag {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.tag-red { color: var(--red); }
.tag-yellow { color: var(--yellow); }
.tag-green { color: var(--green); }

.additive-item + .additive-item { margin-top: 14px; padding-top: 14px; border-top: 2px solid var(--black); }
.additive-item-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.additive-name { font-weight: 800; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
  border: 2px solid var(--black);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 700;
}

.all-clear { text-align: center; padding: 28px 16px; font-weight: 700; }
.all-clear .badge { width: 40px; height: 40px; font-size: 1.4rem; margin: 0 auto 10px; }

details.full-ingredients { border-top: 3px solid var(--black); padding-top: 14px; margin-top: 4px; }
details.full-ingredients summary { font-weight: 800; cursor: pointer; padding: 6px 0; }
details.full-ingredients p { font-weight: 500; font-size: 0.92rem; margin-top: 10px; }

.results-disclaimer { font-size: 0.78rem; font-weight: 600; margin-top: 18px; text-align: center; }

/* ---------- About ---------- */

.about-content { padding: 20px 22px calc(28px + var(--safe-bottom)); max-width: 640px; }
.about-content h3 { font-size: 1rem; margin: 22px 0 8px; }
.about-content p { font-weight: 600; font-size: 0.95rem; margin-bottom: 6px; }
.about-content ul { padding-left: 20px; font-weight: 600; font-size: 0.95rem; }
.about-content li { margin-bottom: 6px; }
