/* ============================================================
   Galactosemie checker — shared styles
   Used by: index (launcher), ingredienten-check, scanner,
            barcode, flow
   ============================================================ */

:root {
  color-scheme: dark;
  --bg: #101a26;
  --topbar: rgba(16, 26, 38, 0.92);
  --card: #1a2530;
  --card-border: #24313d;
  --divider: #26333f;
  --text: #e8eef4;
  --muted: #8ea4b6;
  --green: #4ade80;
  --green-bg: rgba(74, 222, 128, 0.12);
  --red: #f87171;
  --red-bg: rgba(248, 113, 113, 0.12);
  --accent: #55b1e0;
  --accent-bg: rgba(85, 177, 224, 0.12);
  --yellow: #facc15;
  --yellow-bg: rgba(250, 204, 21, 0.12);
  --orange: #fb923c;
  --orange-bg: rgba(251, 146, 60, 0.12);
  --purple: #c084fc;
  --purple-bg: rgba(192, 132, 252, 0.12);
  --pill: #243240;
  --radius: 18px;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  background-color: var(--bg); /* prevents black bar when overscrolling */
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px 24px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* ---------- Back button ---------- */

.back {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--card-border);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}

.back:active { transform: scale(0.95); }

.back svg { width: 20px; height: 20px; }

/* ---------- Headers ---------- */

header {
  text-align: center;
  padding: 28px 0 24px;
}

/* Header sits inside the sticky top bar on the checker page */
.topbar header {
  padding: 0 0 4px;
}

header .badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 10px;
}

header .badge.beta {
  background: var(--accent-bg);
  color: var(--accent);
  border: 1px solid rgba(85, 177, 224, 0.35);
}

h1 {
  font-size: 1.5rem;
  margin: 0 0 4px;
  line-height: 1.25;
}

header p {
  color: var(--muted);
  margin: 0;
  font-size: 0.9rem;
}

/* ---------- Sticky top bar (ingredient check) ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--topbar);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  margin: 0 -16px;
  padding: 20px 16px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.topbar .back {
  position: absolute;
  left: 10px;
  top: 12px;
}

/* ---------- Search ---------- */

.search-wrap {
  position: relative;
  margin: 14px 0 0;
}

.search-wrap svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}

#search {
  width: 100%;
  padding: 13px 16px 13px 42px;
  font-size: 1rem;
  border: 1px solid #2c3c4a;
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#search::placeholder { color: #6d8397; }

#search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(85, 177, 224, 0.2);
}

#no-results {
  display: none;
  text-align: center;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin: 16px 0;
}

/* ---------- Info note ---------- */

.note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: rgba(85, 177, 224, 0.09);
  border: 1px solid rgba(85, 177, 224, 0.25);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 20px 0;
  font-size: 0.92rem;
  color: #b7d5ea;
}

.note svg {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  color: var(--accent);
}

/* ---------- Ingredient lists ---------- */

section { margin-top: 24px; }

.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 0 2px;
}

.section-head .icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  flex-shrink: 0;
}

.section-head .icon svg { width: 18px; height: 18px; }

.allowed .section-head .icon { background: var(--green-bg); color: var(--green); }
.denied .section-head .icon { background: var(--red-bg); color: var(--red); }

.section-head h2 {
  font-size: 1.1rem;
  margin: 0;
}

.allowed .section-head h2 { color: var(--green); }
.denied .section-head h2 { color: var(--red); }

ul.ingredients {
  list-style: none;
  margin: 0;
  padding: 4px 14px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.allowed ul.ingredients { border-top: 3px solid var(--green); }
.denied ul.ingredients { border-top: 3px solid var(--red); }

ul.ingredients li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 2px;
  font-size: 0.98rem;
}

ul.ingredients li + li { border-top: 1px solid var(--divider); }

ul.ingredients .mark {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 4px;
}

.allowed ul.ingredients .mark { color: var(--green); }
.denied ul.ingredients .mark { color: var(--red); }

ul.ingredients li small {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

/* ---------- Launcher: full-screen 2x2 feature matrix ---------- */

.grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 1fr;
  gap: 12px;
  padding-bottom: 24px;
  min-height: 0;
}

.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center; /* vertical centering */
  align-items: center; /* horizontal centering */
  text-align: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  text-decoration: none;
  color: var(--text);
  transition: transform 0.12s ease, border-color 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}

.tile:active { transform: scale(0.97); }

.tile .icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  flex-shrink: 0;
}

.tile .icon svg { width: 26px; height: 26px; }

.tile .label {
  font-weight: 600;
  font-size: 1.02rem;
  line-height: 1.3;
}

.tile .desc {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

.tile .arrow {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
}

/* Coming-soon styling */
.tile.soon {
  pointer-events: none; /* niet clickable zolang de feature niet klaar is */
}

.tile.soon .icon {
  background: var(--card-border);
  color: var(--muted);
}

.tile .betachip {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-bg);
  border: 1px solid rgba(85, 177, 224, 0.35);
  border-radius: 999px;
  padding: 3px 8px;
}

.tile .soonchip {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(142, 164, 182, 0.12);
  border: 1px solid rgba(142, 164, 182, 0.25);
  border-radius: 999px;
  padding: 3px 8px;
}

/* Feature accent colors */
.tile-check .icon { background: var(--green-bg); color: var(--green); }
.tile-scan .icon { background: var(--accent-bg); color: var(--accent); }
.tile-barcode .icon { background: var(--yellow-bg); color: var(--yellow); }
.tile-flow .icon { background: var(--purple-bg); color: var(--purple); }

/* ---------- Coming-soon hero ---------- */

.hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 14px;
  padding: 32px 8px;
}

.hero .icon {
  display: grid;
  place-items: center;
  width: 88px;
  height: 88px;
  border-radius: 24px;
  background: var(--feature-bg);
  color: var(--feature);
}

.hero .icon svg { width: 44px; height: 44px; }

.banner {
  font-size: 1.6rem;
  font-weight: 700;
  background: linear-gradient(90deg, var(--feature), var(--feature-light));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin: 0;
}

.hero h1 { font-size: 1.3rem; margin: 0; }

.hero p {
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 34ch;
  margin: 0;
}

.chip {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(142, 164, 182, 0.12);
  border: 1px solid rgba(142, 164, 182, 0.25);
  border-radius: 999px;
  padding: 4px 12px;
}

/* Feature accents (set --feature variables) */
.a-blue { --feature: var(--accent); --feature-bg: var(--accent-bg); --feature-light: #7dd3fc; }
.a-yellow { --feature: var(--yellow); --feature-bg: var(--yellow-bg); --feature-light: #fde047; }
.a-purple { --feature: var(--purple); --feature-bg: var(--purple-bg); --feature-light: #d8b4fe; }

/* Sub pages: keep the back button off the top edge */
.a-blue .container,
.a-yellow .container,
.a-purple .container {
  padding-top: 16px;
}

/* ---------- Foto scanner (OCR) ---------- */

.capture-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 16px 0;
}

.capture-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 12px;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  text-align: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.capture-btn:active { transform: scale(0.97); }

.capture-btn svg { width: 20px; height: 20px; flex-shrink: 0; }

.capture-btn.accent { border-color: rgba(85, 177, 224, 0.4); }

.preview-wrap { margin: 0 0 16px; }

.preview-wrap img {
  display: block;
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
}

.progress {
  height: 8px;
  background: var(--card-border);
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.2s ease;
}

#status p {
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
  margin: 0;
}

.result-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-top: 16px;
}

.verdict-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.verdict-banner svg { width: 22px; height: 22px; flex-shrink: 0; }

.verdict-banner.bad { background: var(--red-bg); color: var(--red); }
.verdict-banner.good { background: var(--green-bg); color: var(--green); }
.verdict-banner.warn { background: var(--yellow-bg); color: var(--yellow); }
.verdict-banner.caution { background: var(--orange-bg); color: var(--orange); }
.verdict-banner.unknown { background: var(--accent-bg); color: var(--accent); }

.verdict-title { font-size: 1rem; }
.verdict-sub { display: block; font-size: 0.82rem; font-weight: 500; color: var(--muted); margin-top: 2px; }

.verdict-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  font-size: 0.95rem;
}

.verdict-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 0;
}

.verdict-list .mark { width: 16px; height: 16px; margin-top: 4px; flex-shrink: 0; }

.verdict-list.allowed-marks .mark { color: var(--green); }
.verdict-list.denied-marks .mark { color: var(--red); }

.verdict-note {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 8px 0 0;
}

/* Symboolhints (logo-herkenning in de Scan-functie) */
.symbol-hits { margin-top: 4px; }

.symbol-hit {
  display: flex;
  flex-direction: column;
  gap: 2px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 8px;
  font-size: 0.9rem;
}

.symbol-hit .symbol-name { font-weight: 700; }
.symbol-hit .symbol-note { color: var(--muted); font-size: 0.82rem; }

.symbol-hit.good { border-color: var(--green); background: var(--green-bg); }
.symbol-hit.good .symbol-name { color: var(--green); }

.scan-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.scan-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.scan-btn:active { transform: scale(0.97); }

.scan-btn svg { width: 18px; height: 18px; }

details.ocr-text,
details.off-details {
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.85rem;
}

details.ocr-text summary,
details.off-details summary { cursor: pointer; }

details.ocr-text pre,
details.off-details pre {
  white-space: pre-wrap;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 12px;
  max-height: 240px;
  overflow: auto;
  font-size: 0.8rem;
}

/* ---------- Barcode scanner ---------- */

#reader {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

#reader video { width: 100% !important; display: block; }

.manual-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.manual-input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #2c3c4a;
  background: var(--card);
  color: var(--text);
  font-size: 1rem;
  outline: none;
}

.manual-input::placeholder { color: #6d8397; }

.manual-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(85, 177, 224, 0.2);
}

.product-head {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.product-head img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 10px;
  background: #fff;
  padding: 4px;
  flex-shrink: 0;
}

.product-name { font-weight: 700; font-size: 1.02rem; line-height: 1.3; }

.product-brand {
  color: var(--muted);
  font-size: 0.85rem;
}

.inline-link {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

/* ---------- Log ---------- */

.log-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.log-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 10px 12px;
  font-size: 0.9rem;
}

.log-item .mark { width: 16px; height: 16px; margin-top: 3px; flex-shrink: 0; }

.log-item.allowed-mark .mark { color: var(--green); }
.log-item.denied-mark .mark { color: var(--red); }
.log-item.unknown-mark .mark { color: var(--muted); }

.log-title { font-weight: 600; line-height: 1.35; }

.log-sub {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.log-empty {
  text-align: center;
  color: var(--muted);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 16px;
}

.log-hint {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 12px 0 0;
}

/* ---------- Check flow ---------- */

.flow-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 12px;
  min-height: 40px;
}

.flow-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.flow-back:active { transform: scale(0.97); }

.flow-back[hidden] { display: none; }

#flow-progress {
  color: var(--muted);
  font-size: 0.8rem;
  margin-left: auto;
}

#flow-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
}

#flow-card h2 {
  margin: 0 0 10px;
  font-size: 1.15rem;
  line-height: 1.35;
}

#flow-card p { margin: 0 0 10px; font-size: 0.95rem; }

#flow-card ul { margin: 0 0 10px; padding-left: 20px; font-size: 0.95rem; }

#flow-card .note { margin: 12px 0 0; }

.flow-logos {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 4px 0 2px;
}

#flow-card p.flow-logo-caption {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 14px 0 6px;
}

.flow-compare {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 4px 0 2px;
}

.flow-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#flow-card .flow-col-label {
  display: block;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}

.flow-logo {
  position: relative;
  background: transparent;
  border: 3px solid var(--card-border);
  border-radius: 10px;
  padding: 8px;
  height: 200px;
}

.flow-logo.ok { border-color: var(--green); }
.flow-logo.warn { border-color: var(--red); }

.flow-logo .flow-logo-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #fff;
  border: 2px solid var(--bg);
}

.flow-logo .flow-logo-badge svg { width: 12px; height: 12px; }
.flow-logo.ok .flow-logo-badge { background: var(--green); }
.flow-logo.warn .flow-logo-badge { background: var(--red); }

#flow-card p.flow-legend {
  color: var(--muted);
  font-size: 0.82rem;
  margin: 14px 0 0;
}

#flow-card p.flow-legend strong { color: var(--text); }

.flow-logos img,
.flow-logo img {
  display: block;
  width: 100%;
  object-fit: contain;
}

.flow-logos img {
  height: 200px;
  background: transparent;
  border: 3px solid var(--green);
  border-radius: 10px;
  padding: 8px;
}

/* Fill the fixed-height .flow-logo box without overflowing:
   box-sizing: border-box gives the same 178px inner area as .flow-logos img */
.flow-logo img {
  height: 100%;
}

/* Standalone image inside a flow node, centered */
.flow-img {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
}

/* Icon cards: same card look as .flow-logo, 2 columns */
#flow-card ul.flow-icons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 4px 0 2px;
  padding: 0;
  list-style: none;
}

.flow-icons li {
  display: grid;
  place-items: center;
  height: 200px;
  padding: 8px;
  background: transparent;
  border: 3px solid var(--card-border);
  border-radius: 10px;
}

/* SVG scales to fit the card while keeping its aspect ratio (contain) */
.flow-icons li svg {
  width: 100%;
  height: 100%;
}

.flow-answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.flow-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 12px;
  border-radius: 12px;
  border: 1px solid var(--card-border);
  background: var(--card);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.flow-btn:active { transform: scale(0.97); }

.flow-btn.good {
  background: var(--green-bg);
  border-color: rgba(74, 222, 128, 0.4);
  color: var(--green);
}

.flow-btn.bad {
  background: var(--red-bg);
  border-color: rgba(248, 113, 113, 0.4);
  color: var(--red);
}

.flow-btn.unsure {
  background: var(--yellow-bg);
  border-color: rgba(248, 246, 113, 0.4);
  color: var(--yellow);
}

/* ---------- Footer ---------- */

footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  padding: 0 12px;
}
