/* Label Rebel: neo-brutalist. Cream ground, black ink, 3px borders, hard shadows,
   flat pink / lime / yellow blocks. Light only: the look depends on the cream ground. */
:root {
  --bg: #FFF4E0;
  --surface: #ffffff;
  --text: #111111;
  --muted: #4a463f;
  --ink: #111111;
  --pink: #FF5CA8;
  --lime: #C6F36B;
  --yellow: #FFD84D;
  --lilac: #C9B6FF;
  --stone: #E6E0D4;
  --focus: #1a5fb4;

  --border: 3px solid var(--ink);
  --shadow: 6px 6px 0 var(--ink);
  --shadow-sm: 4px 4px 0 var(--ink);
  --display: "Archivo Black", "Arial Black", system-ui, sans-serif;

  font-family: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.5;
  color-scheme: light;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--ink); text-decoration-thickness: 2px; text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
img { max-width: 100%; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* Header */
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-top: 20px; padding-bottom: 8px; }
.logo { display: block; line-height: 0; padding: 6px 0 10px; }
.logo img { display: block; height: 40px; width: auto; }
.site-header nav { display: flex; gap: 10px; flex-wrap: wrap; }
.site-header nav a {
  font-weight: 700; text-decoration: none; white-space: nowrap; padding: 8px 12px;
  border: var(--border); background: var(--surface); transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.site-header nav a:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-sm); }
.site-header nav a.nav-cta { background: var(--lime); box-shadow: var(--shadow-sm); }
.menu-toggle { display: none; }

main { padding-top: 28px; padding-bottom: 56px; }
h1, h2 { font-family: var(--display); font-weight: 400; text-transform: uppercase; letter-spacing: -0.01em; }
h1 { font-size: clamp(2rem, 5vw, 3.4rem); line-height: 0.98; margin: 0 0 14px; }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); line-height: 1.05; margin: 36px 0 12px; }
.breadcrumb { color: var(--muted); font-size: 0.92rem; margin: 0 0 14px; font-weight: 500; }
.fine-print { color: var(--muted); font-size: 0.88rem; }
.lede { max-width: 62ch; margin-top: 0; font-size: 1.08rem; }

/* Home hero */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(300px, 1fr);
  gap: 32px 48px; align-items: center; margin-bottom: 32px;
}
.hero-text { display: flex; flex-direction: column; gap: 18px; }

/* Example ingredients label beside the hero title. */
.label-card {
  position: relative; margin: 0; padding: 26px 22px 18px; background: var(--surface);
  border: var(--border); box-shadow: 10px 10px 0 var(--ink); transform: rotate(2deg);
}
.label-kicker {
  position: absolute; top: -14px; left: 16px; margin: 0; padding: 3px 10px;
  background: var(--yellow); border: 2px solid var(--ink); font-weight: 700; font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.04em; transform: rotate(-3deg);
}
.label-title { margin: 0 0 8px; font-family: var(--display); font-size: 1.15rem; text-transform: uppercase; }
.label-ingredients { margin: 0; font-size: 0.95rem; line-height: 1.6; }
.label-card mark { color: var(--ink); padding: 1px 4px; border: 2px solid var(--ink); font-weight: 700; }
.label-card .hl-folic { background: var(--pink); }
.label-card .hl-other { background: var(--yellow); }
.label-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 14px; padding-top: 12px; border-top: 2px dashed var(--ink); font-size: 0.82rem; font-weight: 700; }
.key { display: inline-flex; align-items: center; gap: 6px; }
.key::before { content: ""; width: 14px; height: 14px; border: 2px solid var(--ink); }
.key-folic::before { background: var(--pink); }
.key-other::before { background: var(--yellow); }
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; }
  .label-card { transform: rotate(1deg); max-width: 520px; }
}
.hero h1 { font-size: clamp(2.6rem, 8.5vw, 6.2rem); line-height: 0.92; letter-spacing: -0.02em; margin: 0; max-width: 14ch; }
.hero p { margin: 0; font-size: clamp(1.05rem, 2vw, 1.3rem); line-height: 1.45; max-width: 46ch; }
.search-card { background: var(--lime); border: var(--border); box-shadow: 10px 10px 0 var(--ink); padding: 20px; margin-bottom: 28px; }
.search-card .filters { margin: 0; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: var(--border); background: var(--surface); margin: 8px 0 12px; }
.stat { padding: 18px 22px; border-right: var(--border); }
.stat:last-child { border-right: 0; background: var(--pink); }
.stat-number { margin: 0; font-family: var(--display); font-size: clamp(1.8rem, 4vw, 2.9rem); line-height: 1.05; }
.stat-label { margin: 4px 0 0; font-weight: 700; }
@media (max-width: 640px) {
  .stats { grid-template-columns: 1fr; }
  .stat { border-right: 0; border-bottom: var(--border); }
  .stat:last-child { border-bottom: 0; }
}

/* Category chips */
.categories { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0; }
.categories a {
  padding: 6px 12px; border: var(--border); text-decoration: none; background: var(--surface);
  font-weight: 700; font-size: 0.92rem; transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.categories a:hover { transform: translate(-2px, -2px); box-shadow: var(--shadow-sm); }
.categories a[aria-current] { background: var(--ink); color: var(--bg); }
.chip-count { font-size: 0.82em; margin-left: 3px; opacity: 0.75; }
.shop-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: -4px 0 18px; }
.shop-chips-label { font-weight: 700; margin-right: 2px; }

/* Supermarket buttons: brand colours from per-retailer variables in base.html. */
.shop-badge {
  display: inline-flex; flex-direction: column; justify-content: center; gap: 1px;
  background: var(--shop-bg); color: var(--shop-fg); text-decoration: none;
  border: var(--border); box-shadow: inset 0 -4px 0 var(--shop-accent), var(--shadow-sm);
  line-height: 1.15; transition: transform 0.08s ease, box-shadow 0.08s ease;
}
a.shop-badge:hover { transform: translate(-2px, -2px); box-shadow: inset 0 -4px 0 var(--shop-accent), var(--shadow); }
a.shop-badge[aria-current] { outline: 3px solid var(--ink); outline-offset: 3px; }
.shop-wordmark { font-family: var(--display); font-weight: 400; letter-spacing: 0; white-space: nowrap; }
.shop-logo { display: block; max-height: 28px; max-width: 100%; }
.shop-count { font-size: 0.78em; font-weight: 700; opacity: 0.9; }
.shop-badge--xs { padding: 1px 6px 3px; border-width: 2px; font-size: 0.7rem; box-shadow: inset 0 -2px 0 var(--shop-accent); }
.shop-badge--xs .shop-logo { max-height: 14px; }
.shop-badge--sm { flex-direction: row; align-items: center; gap: 6px; padding: 4px 10px 6px; font-size: 0.86rem; }
.shop-badge--md { padding: 8px 14px 11px; font-size: 1rem; }
.shop-badge--lg { padding: 14px 16px 16px; min-height: 76px; font-size: 1.15rem; }
.shop-badge--lg .shop-logo { max-height: 32px; }
.shop-tiles { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.shop-tiles .shop-badge { width: 100%; }
.card-text .shop-list-inline { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.shop-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 12px; }
.shop-head h1 { margin: 0; }

/* Home entry points */
.entry-points { display: grid; gap: 8px 40px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); margin-top: 12px; }
.entry-points h2 { margin-bottom: 4px; }

/* Browse panels: plain headings on desktop, tap-to-open bars on phones (see the phone section). */
.browse > summary { list-style: none; cursor: default; }
.browse > summary::-webkit-details-marker { display: none; }
.browse-sub { display: none; }
.section-note { color: var(--muted); font-size: 0.92rem; margin: 0 0 16px; }
.tiles {
  list-style: none; padding: 0; margin: 0; display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); grid-auto-rows: 1fr;
}
/* Every tile in a row is the same height: name at the top, count at the bottom. */
.tiles li { display: flex; }
.tile {
  display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
  width: 100%; min-height: 96px; padding: 14px 16px;
  background: var(--surface); border: var(--border); box-shadow: var(--shadow);
  text-decoration: none; transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.tile:hover { transform: translate(-2px, -2px); box-shadow: 8px 8px 0 var(--ink); }
.tile-name { font-family: var(--display); font-size: 1.12rem; line-height: 1.1; text-transform: uppercase; }
.tile-count { font-weight: 700; font-size: 0.9rem; }

/* Search and filters */
.filters { margin: 8px 0 18px; }
/* Home page: filters only matter once you've typed a search. */
.filters-landing:has(#q:placeholder-shown) .status-filter,
.filters-landing:has(#q:placeholder-shown) .retailer-filter { display: none; }
.search-row { display: flex; gap: 10px; }
.search-row input {
  flex: 1; min-width: 0; font: inherit; font-size: 1.05rem; padding: 12px 14px;
  border: var(--border); border-radius: 0; background: var(--surface); color: var(--text);
}
button {
  font-family: var(--display); font-size: 1rem; text-transform: uppercase; padding: 12px 20px;
  border: var(--border); border-radius: 0; background: var(--ink); color: var(--lime); cursor: pointer;
}
button:hover { box-shadow: var(--shadow-sm); transform: translate(-2px, -2px); }
.status-filter { border: 0; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.status-filter legend { float: left; margin-right: 4px; font-weight: 700; font-size: 0.92rem; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  font-size: 0.88rem; font-weight: 700; cursor: pointer; border: 2px solid var(--ink); opacity: 0.6;
}
.chip:has(input:checked) { opacity: 1; box-shadow: 3px 3px 0 var(--ink); }
.chip input { margin: 0; accent-color: var(--ink); }
.retailer-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; font-size: 0.92rem; font-weight: 700; }
.retailer-filter select { font: inherit; padding: 6px 10px; border: 2px solid var(--ink); border-radius: 0; background: var(--surface); color: var(--text); }
.retailer-filter a { font-weight: 500; font-size: 0.86rem; }

/* Status colours: all dark ink on a flat light block. */
.status-unfortified         { background: var(--lime); color: var(--ink); }
.status-folic_acid_free     { background: var(--yellow); color: var(--ink); }
.status-likely_fortified    { background: var(--pink); color: var(--ink); }
.status-contains_folic_acid { background: var(--lilac); color: var(--ink); }
.status-unknown             { background: var(--stone); color: var(--ink); }

/* Product tiles: as many columns as fit at 160px, never more than 5. */
.result-count { font-size: 0.92rem; font-weight: 700; margin: 0 0 12px; }
.htmx-request #results, #results.htmx-request { opacity: 0.6; transition: opacity 0.2s; }
.product-list {
  --gap: 18px;
  list-style: none; padding: 0; margin: 0; display: grid; gap: var(--gap);
  grid-template-columns: repeat(auto-fill, minmax(max(160px, calc((100% - 4 * var(--gap)) / 5)), 1fr));
}
.product-list li { display: flex; }
.product-card {
  position: relative; display: flex; flex-direction: column; width: 100%;
  background: var(--surface); border: var(--border); box-shadow: var(--shadow);
  text-decoration: none; transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.product-card:hover { transform: translate(-2px, -2px); box-shadow: 8px 8px 0 var(--ink); }
.card-image { position: relative; display: block; aspect-ratio: 1; overflow: hidden; background: #fff; border-bottom: var(--border); }
.card-image img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 10px; }
.no-image { display: block; width: 100%; height: 100%; background: var(--stone); }

/* Skeleton: a shimmer while a product photo loads, then the photo fades in.
   Only with JS, which marks each image loaded; without it photos just show. */
/* The highlight is a pseudo-element sliding from fully off the left edge to fully off the
   right, so each loop restarts out of sight: no visible jump. */
.js .skeleton { background: var(--stone); }
.js .skeleton::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: linear-gradient(100deg, transparent 0%, rgb(255 255 255 / 0.7) 50%, transparent 100%);
  transform: translateX(-100%);
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}
.js .skeleton img { z-index: 1; opacity: 0; transition: opacity 0.25s ease; }
.js .skeleton:has(img.is-loaded) { background: #fff; }
.js .skeleton:has(img.is-loaded)::before,
.skeleton.is-broken::before { content: none; }
.js .skeleton img.is-loaded { opacity: 1; }
/* A photo that fails or times out: a plain block instead of a broken-image icon. */
.skeleton.is-broken { background: var(--stone); }
.skeleton.is-broken img { display: none; }
.skeleton.is-broken::after {
  content: "No photo"; position: absolute; inset: 0; display: grid; place-items: center;
  font-weight: 700; font-size: 0.85rem; color: var(--muted);
}
@keyframes skeleton-shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .js .skeleton::before { animation: none; content: none; } }
/* The status as a slapped-on sticker. */
.product-card .badge {
  position: absolute; top: -10px; right: -8px; z-index: 1;
  border: 2px solid var(--ink); border-radius: 0; text-transform: uppercase; font-size: 0.72rem;
  transform: rotate(3deg);
}
.product-list li:nth-child(even) .product-card .badge { transform: rotate(-3deg); }
.card-text { min-width: 0; display: grid; gap: 2px; padding: 10px 12px 12px; align-content: start; }
.card-text .name {
  font-weight: 700; font-size: 0.95rem; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-text .brand { color: var(--muted); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-text .shops { font-size: 0.82rem; font-weight: 700; }
.badge { padding: 3px 10px; font-size: 0.8rem; font-weight: 700; white-space: nowrap; border: 2px solid var(--ink); }
.empty { padding: 24px 0; font-weight: 500; }
.pager { display: flex; gap: 16px; justify-content: center; align-items: center; margin-top: 28px; font-weight: 700; }
.pager a { border: var(--border); background: var(--surface); padding: 6px 14px; text-decoration: none; box-shadow: var(--shadow-sm); }

/* Product page */
.product-head { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.product-image {
  position: relative; display: block; width: 180px; aspect-ratio: 1; overflow: hidden;
  background: #fff; border: var(--border); box-shadow: var(--shadow);
}
.product-image img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.product .brand { margin: 0; font-weight: 700; }
.barcode { color: var(--muted); font-size: 0.86rem; font-variant-numeric: tabular-nums; }
.verdict { margin-top: 24px; padding: 18px 22px; border: var(--border); box-shadow: var(--shadow); }
.verdict h2 { margin-top: 0; }
.verdict p { margin: 0 0 6px; }
.verdict .as-of { font-size: 0.9rem; font-weight: 700; margin-top: 10px; }
.matches { padding-left: 20px; }
.matches .kind, .matches .context { color: var(--muted); }
.ingredients { background: var(--surface); border: var(--border); padding: 14px 16px; }
mark { background: #FFC2DD; color: inherit; padding: 0 2px; }
.shop-list { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 10px; }
.shop-list li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.shop-source { color: var(--muted); }
.source { color: var(--muted); font-size: 0.92rem; }

/* Text pages */
.prose { max-width: 68ch; }
.prose h2 { font-size: 1.5rem; }
.status-defs dt { margin-top: 14px; }
.status-defs dd { margin: 6px 0 0; }
.summary { border-collapse: collapse; border: var(--border); background: var(--surface); }
.summary th, .summary td { text-align: left; padding: 8px 16px; border-bottom: 2px solid var(--ink); }
.summary td:last-child { text-align: right; font-variant-numeric: tabular-nums; }

.site-footer { border-top: var(--border); font-size: 0.88rem; padding: 18px 0 36px; }
.data-link { font-weight: 700; }

/* "Data availability" pop-up */
.data-dialog {
  max-width: min(520px, calc(100vw - 32px)); padding: 22px 24px 20px;
  background: var(--surface); color: var(--text); border: var(--border); box-shadow: 10px 10px 0 var(--ink);
}
.data-dialog::backdrop { background: rgb(17 17 17 / 0.45); }
.data-dialog h2 { margin: 0 0 10px; font-size: 1.5rem; }
.data-dialog p { margin: 0 0 12px; font-size: 0.98rem; }
.data-dialog form { margin: 16px 0 0; }

/* ---------- Phones: less chrome, more products ----------
   The desktop look stays; this trims borders, shadows and spacing, folds the menu,
   and turns long chip lists into single rows that scroll sideways. */
@media (max-width: 640px) {
  :root { --shadow: 4px 4px 0 var(--ink); --shadow-sm: 3px 3px 0 var(--ink); }
  .wrap { padding: 0 16px; }
  main { padding-top: 16px; padding-bottom: 40px; }
  h2 { margin: 28px 0 10px; }

  /* Header: logo and a Menu button; links unfold below. Without JS they stay visible. */
  .site-header .wrap { flex-wrap: wrap; padding-top: 14px; padding-bottom: 4px; gap: 10px; }
  .logo img { height: 32px; }
  .js .menu-toggle {
    display: inline-flex; font-size: 0.9rem; padding: 7px 14px; background: var(--surface);
    color: var(--ink); border: var(--border);
  }
  .js .menu-toggle:hover { box-shadow: none; transform: none; }
  .js .site-header nav { display: none; }
  .js .site-header.nav-open nav { display: grid; }
  .site-header nav { width: 100%; grid-template-columns: 1fr 1fr; gap: 8px; padding-bottom: 6px; }
  .site-header nav a { text-align: center; padding: 8px 6px; font-size: 0.9rem; }

  /* Home: headline, one line of intro, then straight to search. */
  .hero { gap: 12px; margin-bottom: 18px; }
  .hero h1 { font-size: clamp(2.3rem, 11vw, 2.9rem); }
  .hero p { font-size: 1rem; }
  .label-card { display: none; }
  .search-card { padding: 12px; box-shadow: 6px 6px 0 var(--ink); margin-bottom: 18px; }
  .search-row input { font-size: 1rem; padding: 10px 12px; }
  .search-row button { padding: 10px 14px; font-size: 0.9rem; }

  /* Stats: one compact row instead of three tall boxes. */
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat { padding: 10px 10px 12px; border-right: var(--border); border-bottom: 0; }
  .stat:last-child { border-right: 0; }
  .stat-number { font-size: 1.35rem; }
  .stat-label { font-size: 0.72rem; line-height: 1.25; }

  /* Browse panels: a bold bar with a chevron; tap to open. */
  .entry-points { gap: 14px; margin-top: 20px; }
  .browse > summary {
    display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 12px;
    padding: 14px 16px; background: var(--surface); border: var(--border); box-shadow: var(--shadow);
    cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .browse > summary h2 { margin: 0; font-size: 1.15rem; }
  .browse-sub { display: block; grid-column: 1; font-size: 0.85rem; font-weight: 700; color: var(--muted); }
  .browse > summary::after {
    content: ""; grid-column: 2; grid-row: 1 / span 2; width: 12px; height: 12px;
    border-right: 3px solid var(--ink); border-bottom: 3px solid var(--ink);
    transform: rotate(45deg) translate(-3px, -3px); transition: transform 0.15s ease;
  }
  .browse[open] > summary { background: var(--lime); }
  .browse[open] > summary::after { transform: rotate(-135deg) translate(-3px, -3px); }
  .browse .section-note { margin: 14px 0 12px; }

  .tiles { gap: 10px; }
  .tile { min-height: 78px; padding: 12px; }
  .tile-name { font-size: 0.98rem; }
  .tile-count { font-size: 0.82rem; }
  .shop-badge--lg { min-height: 62px; padding: 10px 12px 12px; font-size: 1rem; }

  /* Long chip lists: one row each, swipe sideways. */
  .categories, .shop-chips, .status-filter {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    margin-inline: -16px; padding: 4px 16px 8px; min-width: 0;
  }
  .categories::-webkit-scrollbar, .shop-chips::-webkit-scrollbar, .status-filter::-webkit-scrollbar { display: none; }
  .categories a, .shop-chips > *, .status-filter .chip { flex: 0 0 auto; }
  .categories { margin-top: 10px; margin-bottom: 8px; }
  .shop-chips { margin-top: 0; margin-bottom: 10px; }
  .status-filter legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .status-filter { margin-top: 10px; }
  .filters { margin-bottom: 10px; }

  /* Product grid: two columns, lighter cards. */
  .product-list { --gap: 12px; }
  .card-text { padding: 8px 10px 10px; }
  .product-card .badge { font-size: 0.66rem; padding: 2px 6px; }
}
