/* Hand-written styles. Tokens first; components use only tokens. Reference: /_kitchen-sink.
   Design: docs/design/02-directions/DIRECTION.md (direction), 03-foundations/NOTES.md (tokens). */

/* ---------- Font ---------- */

/* Ysabeau Office (OFL, fonts/OFL.txt): one variable file, wght 400–800, Latin + Cyrillic, with
   the Bulgarian forms (locl BGR, via <html lang="bg">) and tabular digits. A new file gets a new
   name: /static/fonts/ is cached as immutable. Recipe: 03-foundations/NOTES.md. */
@font-face {
  font-family: "Ysabeau Office";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("../fonts/ysabeau-office-2.002.woff2") format("woff2");
}

/* ---------- Tokens ---------- */

:root {
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  /* Type: one face; hierarchy by size and weight only (colour stays text / muted). */
  --font-sans: "Ysabeau Office", system-ui, sans-serif;
  --text-xs: 0.78125rem; /* 12.5: small uppercase labels */
  --text-sm: 0.875rem; /* 14: meta, tabs, hints */
  --text-base: 1rem; /* 16: body, inputs, buttons */
  --text-md: 1.03125rem; /* 16.5: product names */
  --text-lg: 1.1875rem; /* 19: h2, list item names */
  --text-xl: 1.375rem; /* 22: wordmark (navbar) */
  --text-2xl: 1.75rem; /* 28: h1 */
  --text-wordmark-solo: 2.25rem; /* 36: the wordmark on signed-out pages */
  --text-price-whole: 2.125rem; /* 34: the card's new price, euros (cents at half) */
  --text-price-whole-compact: 1.625rem; /* 26: the same in a compact card */
  --text-discount: 1.0625rem; /* 17: the discount mark */
  --line-height: 1.45;
  --line-height-snug: 1.3;
  --line-height-tight: 1.15;
  --line-height-none: 1;
  --weight-text: 400;
  --weight-name: 500; /* product names */
  --weight-strong: 650; /* labels, buttons, tabs, store names */
  --weight-heavy: 800; /* headings, prices, wordmark */
  --tracking-heading: -0.015em;
  --tracking-price: -0.01em;
  --tracking-label: 0.07em;

  /* Shape: rounded where you touch, square where you read. */
  --radius-control: 6px; /* buttons, select, nav tab */
  --radius-bar: 7px; /* the page bar (desktop) */
  --radius-tray: 9px; /* the nav tray: a tab's radius + the tray's 3 px padding */
  --radius-chip: 5px; /* chips, badges */
  --radius-input: 4px;
  --radius-card: 3px; /* cards, rows, panels */
  --radius-cover: 2px; /* leaflet covers, page images, the store square */
  --radius-sheet: 12px; /* the bottom sheet's top corners */
  --radius-round: 50%; /* ♥, ✕ */

  --target: 44px; /* minimum touch target */
  --target-sm: 36px; /* chips */
  --target-heart: 40px; /* the drawn ♥ button (its target is --target) */
  --container: 64rem;

  /* Store brand colours: the same in both themes. */
  --store-kaufland: #e10915;
  --store-lidl: #0050aa;
  --store-fantastico: #c2410c;
  --store-metro: #002d72;
  --store-hitmax: #e21e26;
  --store-billa: #1e4d2b;

  /* The deal (discount, "в промоция"): yellow with ink on it, in both themes. Nothing else is
     yellow. */
  --color-deal: #ffd400;
  --color-on-deal: #1b1a17;

  /* Palette "Stone": light-dark(light, dark). One place for both themes: the value follows the
     color-scheme of the element that uses it (the OS, or a [data-theme] panel). */
  color-scheme: light dark;
  --color-bg: light-dark(#eeede9, #1c1b19); /* the page */
  --color-surface: light-dark(#ffffff, #262523); /* cards, rows, panels */
  --color-surface-2: light-dark(#e4e2dd, #141312); /* trays (nav, page bar), a card's press */
  --color-text: light-dark(#1b1a17, #f2f0eb); /* ink: text, brand, the primary action */
  --color-muted: light-dark(#524f49, #c1bdb4); /* secondary text: brand, meta, old price */
  --color-faint: light-dark(#625e57, #a39f95); /* placeholders, field icons */
  --color-border: light-dark(#dcd9d2, #383633); /* around a card */
  --color-rule: light-dark(#d6d3cc, #383633); /* hairlines between rows / groups */
  --color-primary: var(--color-text);
  --color-on-primary: light-dark(#ffffff, #1b1a17);
  --color-focus: var(--color-text);
  --color-store-ring: light-dark(transparent, #8a7f6d);
  --color-heart: var(--color-text);

  /* Semantic: quiet and warm; fg on bg and fg on the page / a card pass AA. */
  --color-info-bg: light-dark(#e3e7ea, #252c32);
  --color-info-fg: light-dark(#2c4a66, #a9c4dd);
  --color-success-bg: light-dark(#e4ebdc, #242e20);
  --color-success-fg: light-dark(#3d6428, #a6cc8e);
  --color-warning-bg: light-dark(#f1e5d3, #33281a);
  --color-warning-fg: light-dark(#7a4a0c, #e6b77a);
  --color-danger-bg: light-dark(#f4e2dc, #3a2420);
  --color-danger-fg: light-dark(#9e2f1c, #f0957c);
  --color-backdrop: light-dark(#1b1a1799, #000000b3);

  /* Relief, controls only (information is flat). Raised: a small gradient, a darker bottom
     edge, a hard 1 px shadow (no blur). Pressed: flat, inner shadow, 1 px down. Inset: fields,
     darker top edge. */
  --color-raised-top: light-dark(#ffffff, #353331);
  --color-raised-bottom: light-dark(#f5f4f1, #2c2b28);
  --color-raised-edge: light-dark(#cbc7be, #4a4844);
  --color-raised-edge-bottom: light-dark(#a9a499, #0d0c0b);
  --color-pressed: light-dark(#e6e4df, #191817);
  --color-primary-top: light-dark(#2b2925, #ffffff);
  --color-primary-bottom: light-dark(#1b1a17, #e9e6df);
  --color-primary-edge: light-dark(#000000, #a8a397);
  --color-primary-pressed: light-dark(#0c0b0a, #d4d0c7);
  /* The danger button is the same red with white text in both themes (a light salmon in dark
     was loud). */
  --color-danger-top: #b23a22;
  --color-danger-bottom: #9e2f1c;
  --color-danger-edge: light-dark(#5e1a0e, #0d0c0b);
  --color-danger-pressed: #86271a;
  --color-on-danger: #ffffff;
  /* A field's edge is its only boundary on a white card: 3:1 against the card and the page. */
  --color-inset: light-dark(#ffffff, #161514);
  --color-inset-edge: light-dark(#8f8a80, #77736b);
  --color-inset-edge-top: light-dark(#6f6b63, #0a0a09);

  --shadow-raised:
    inset 0 1px 0 light-dark(#ffffffe6, #fff5e117), 0 1px 0 light-dark(#281e0f21, #000000b3);
  --shadow-pressed: inset 0 1px 2px light-dark(#281e0f38, #000000b3);
  --shadow-primary:
    inset 0 1px 0 light-dark(#ffffff24, #ffffff), 0 1px 0 light-dark(#0000004d, #000000b3);
  --shadow-primary-pressed: inset 0 1px 2px light-dark(#000000b3, #00000066);
  /* The primary's in dark has a white top line for a white button; red keeps the light one. */
  --shadow-danger: inset 0 1px 0 #ffffff24, 0 1px 0 light-dark(#0000004d, #000000b3);
  --shadow-inset: inset 0 1px 1px light-dark(#281e0f1a, #00000080);
  /* A focused field sinks in a little further (with an ink edge on its own border, no ring). */
  --shadow-inset-sunk: inset 0 2px 4px light-dark(#281e0f2e, #000000cc);
  /* Overlays only (menu, sheet, the sticky page bar): the one blurred shadow. */
  --shadow-overlay: 0 2px 10px light-dark(#281e0f29, #000000a6);
  --shadow-overlay-up: 0 -2px 10px light-dark(#281e0f1f, #00000080);
  --gradient-raised: linear-gradient(180deg, var(--color-raised-top), var(--color-raised-bottom));
  --gradient-primary: linear-gradient(
    180deg,
    var(--color-primary-top),
    var(--color-primary-bottom)
  );
  --gradient-danger: linear-gradient(180deg, var(--color-danger-top), var(--color-danger-bottom));
  /* Hover (pointer devices): the same gradient a step lighter. */
  --gradient-primary-hover: linear-gradient(
    180deg,
    light-dark(#3b3833, #ffffff),
    light-dark(#2b2925, #f4f2ed)
  );
  --gradient-danger-hover: linear-gradient(180deg, #c4462c, #b23a22);
  --icon-stroke: 1.6px; /* every icon, whatever its size */
}
[data-theme="light"] {
  color-scheme: light;
}
[data-theme="dark"] {
  color-scheme: dark;
}

/* ---------- Base ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--line-height);
  font-weight: var(--weight-text);
  background: var(--color-bg);
  color: var(--color-text);
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: var(--weight-heavy);
  line-height: var(--line-height-tight);
  letter-spacing: var(--tracking-heading);
  text-wrap: balance;
  /* A long product or store word must not push the page sideways (lang="bg" hyphenates). */
  overflow-wrap: anywhere;
  hyphens: auto;
}
h1 {
  font-size: var(--text-2xl);
}
h2 {
  font-size: var(--text-lg);
}
h3 {
  font-size: var(--text-base);
  font-weight: var(--weight-strong);
  letter-spacing: normal;
}
p {
  margin: 0;
}
strong,
b {
  font-weight: var(--weight-strong);
}

/* Links are ink, told apart by the underline. */
a {
  color: var(--color-primary);
  text-decoration-color: var(--color-faint);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
@media (hover: hover) {
  a:hover {
    text-decoration-color: currentColor;
  }
}

::selection {
  background: var(--color-text);
  color: var(--color-surface);
}

/* One ring for everything: 2 px ink, 2 px clear of the element. */
:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

/* Outline icons (components.tsx ICON_PATHS), drawn in the text colour. */
.icon {
  width: 1em;
  height: 1em;
  flex: none;
  vertical-align: -0.125em;
  fill: none;
  stroke: currentColor;
  stroke-width: var(--icon-stroke);
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* One drawn stroke at every size (the paths are on a 24 grid; a 14 px icon would get thinner). */
.icon path {
  vector-effect: non-scaling-stroke;
}

.muted {
  color: var(--color-muted);
}
.small {
  font-size: var(--text-sm);
}
/* Read by screen readers, not shown (e.g. a label the placeholder already says). */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- Layout ---------- */

.container {
  max-width: var(--container);
  margin-inline: auto;
  /* viewport-fit=cover: keep clear of a landscape notch. */
  padding-inline: max(var(--space-4), env(safe-area-inset-left))
    max(var(--space-4), env(safe-area-inset-right));
}
.main {
  padding-block: var(--space-5) var(--space-7);
}
/* A page's groups (head, controls, results, footnote) sit further apart than the parts inside them. */
.page {
  gap: var(--space-5);
}
/* One-column pages read better narrow on desktop (the list; docs/tasks/desktop-list-layout.md). */
.page-narrow {
  max-width: 40rem;
}
.narrow {
  max-width: 26rem;
  margin-inline: auto;
  display: grid;
  gap: var(--space-3);
}
.stack {
  display: grid;
  /* One column that never grows past its container because of a wide child. */
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
}
.cluster {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}
.grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
}
.flash {
  margin-bottom: var(--space-4);
}

/* ---------- Wordmark, signed-out pages ---------- */

/* The mark + "Намалено" in live text. The tag fills only a diamond of its square, so it is a
   little taller than the text and sits close to it. */
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.28em;
  font-size: var(--text-xl);
  font-weight: var(--weight-heavy);
  line-height: var(--line-height-none);
  letter-spacing: var(--tracking-price);
  white-space: nowrap;
}
.wordmark img {
  width: 1.2em;
  height: 1.2em;
  flex: none;
}
.wordmark-solo {
  font-size: var(--text-wordmark-solo);
  letter-spacing: var(--tracking-heading);
}

/* Login, set password, errors when signed out: no navbar, the wordmark above one card, high on
   the page (not centred: the phone keyboard would push it around). */
.main-solo {
  padding-top: clamp(var(--space-6), 12vh, 6rem);
}
.main-solo > .flash,
.solo {
  max-width: 24rem;
  margin-inline: auto;
}
.solo {
  display: grid;
  gap: var(--space-4);
}
.solo-brand {
  margin: 0 0 var(--space-3);
  justify-self: center;
}
.solo-card {
  padding: var(--space-5) var(--space-4);
  gap: var(--space-4);
}
.solo-title {
  font-size: var(--text-xl);
  margin: 0;
}
.solo-kicker {
  margin: 0 0 calc(-1 * var(--space-3));
  font-size: var(--text-xs);
  font-weight: var(--weight-strong);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--color-muted);
}
.solo-card > p {
  margin: 0;
}
.solo-footer {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--color-muted);
  text-align: center;
  text-wrap: balance;
}

/* ---------- Nav ---------- */

/* White bar: wordmark, the tabs in a tray (the current one raised: "you are here"), the user
   menu. Phones: wordmark and menu on the first row, the tray full width under them. */
.navbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
}
.navbar-inner {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  min-height: 3.5rem;
}
.navbar-brand {
  display: inline-flex;
  min-height: var(--target);
  align-items: center;
  color: var(--color-text);
  text-decoration: none;
}
.navbar-links {
  display: flex;
  gap: 2px;
  list-style: none;
  margin: 0;
  padding: 3px;
  background: var(--color-surface-2);
  border-radius: var(--radius-tray);
}
.navbar-links a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  min-height: 2.375rem;
  padding: 0 var(--space-3);
  white-space: nowrap;
  font-weight: var(--weight-strong);
  color: var(--color-muted);
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
}
@media (hover: hover) {
  .navbar-links a:hover {
    color: var(--color-text);
  }
}
.navbar-links a:active:not([aria-current="page"]) {
  background: var(--color-pressed);
  box-shadow: var(--shadow-pressed);
}
.navbar-links a[aria-current="page"] {
  color: var(--color-text);
  background: var(--gradient-raised);
  border-color: var(--color-raised-edge);
  border-bottom-color: var(--color-raised-edge-bottom);
  box-shadow: var(--shadow-raised);
}
.navbar-links .icon {
  width: 1.15em;
  height: 1.15em;
}

@media (max-width: 40rem) {
  .navbar-inner {
    flex-wrap: wrap;
    gap: 0 var(--space-4);
    padding-top: var(--space-1);
  }
  .navbar-links {
    order: 3;
    flex-basis: 100%;
    min-width: 0;
    margin-bottom: var(--space-2);
  }
  .navbar-links li {
    flex: 1;
    min-width: 0;
  }
  .navbar-links a {
    min-height: var(--target);
    padding: 0 var(--space-1);
    font-size: var(--text-sm);
  }
}

/* The account: a quiet control (person, email, chevron); the panel holds "Изход". */
.user-menu {
  position: relative;
  min-width: 0;
  margin-left: auto;
}
.user-menu-toggle {
  display: flex;
  align-items: center;
  gap: 0.4em;
  min-height: var(--target);
  margin-right: calc(-1 * var(--space-2));
  padding: 0 var(--space-2);
  border-radius: var(--radius-control);
  font-size: var(--text-sm);
  color: var(--color-muted);
  list-style: none;
  cursor: pointer;
}
.user-menu-toggle::-webkit-details-marker {
  display: none;
}
@media (hover: hover) {
  .user-menu-toggle:hover {
    color: var(--color-text);
    background: var(--color-surface-2);
  }
}
[open] > .user-menu-toggle {
  color: var(--color-text);
  background: var(--color-surface-2);
}
.user-menu-email {
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Small phones (320px): wordmark and a shortened email still share the first row; the tabs drop
   their icons to fit. */
@media (max-width: 22.5rem) {
  .user-menu-email {
    max-width: 5.5rem;
  }
  .navbar-links .icon {
    display: none;
  }
}
.user-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + var(--space-1));
  z-index: 10;
  min-width: 11rem;
  padding: var(--space-1);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-overlay);
}
.user-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-height: var(--target);
  padding: 0 var(--space-3);
  font: inherit;
  font-weight: var(--weight-strong);
  color: var(--color-text);
  background: transparent;
  border: 0;
  border-radius: var(--radius-control);
  cursor: pointer;
}
@media (hover: hover) {
  .user-menu-item:hover {
    background: var(--color-surface-2);
  }
}

/* ---------- Card ---------- */

/* Information is flat: no shadow. */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: var(--space-4);
  display: grid;
  gap: var(--space-3);
}
.card-body {
  display: grid;
  gap: var(--space-3);
}
.card-footer {
  border-top: 1px solid var(--color-rule);
  padding-top: var(--space-3);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  font: inherit;
  font-weight: var(--weight-strong);
  text-decoration: none;
  cursor: pointer;
  line-height: 1.25;
}
/* Pressed: pushed in (flat fill, inner shadow, 1 px down). */
.btn:active:not(:disabled) {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-sm {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
}
.btn-primary {
  background: var(--gradient-primary);
  border-color: var(--color-primary-edge);
  box-shadow: var(--shadow-primary);
  color: var(--color-on-primary);
}
@media (hover: hover) {
  .btn-primary:hover:not(:disabled) {
    background: var(--gradient-primary-hover);
    color: var(--color-on-primary);
  }
}
.btn-primary:active:not(:disabled) {
  background: var(--color-primary-pressed);
  box-shadow: var(--shadow-primary-pressed);
}
.btn-secondary {
  background: var(--gradient-raised);
  border-color: var(--color-raised-edge);
  border-bottom-color: var(--color-raised-edge-bottom);
  box-shadow: var(--shadow-raised);
  color: var(--color-text);
}
@media (hover: hover) {
  .btn-secondary:hover:not(:disabled) {
    border-color: var(--color-raised-edge-bottom);
    color: var(--color-text);
  }
}
.btn-secondary:active:not(:disabled) {
  background: var(--color-pressed);
  border-top-color: var(--color-raised-edge-bottom);
  box-shadow: var(--shadow-pressed);
}
/* The primary's relief in red. */
.btn-danger {
  background: var(--gradient-danger);
  border-color: var(--color-danger-edge);
  box-shadow: var(--shadow-danger);
  color: var(--color-on-danger);
}
@media (hover: hover) {
  .btn-danger:hover:not(:disabled) {
    background: var(--gradient-danger-hover);
    color: var(--color-on-danger);
  }
}
.btn-danger:active:not(:disabled) {
  background: var(--color-danger-pressed);
  box-shadow: var(--shadow-primary-pressed);
}
.btn-ghost {
  background: transparent;
  color: var(--color-text);
}
@media (hover: hover) {
  .btn-ghost:hover:not(:disabled) {
    background: var(--color-surface-2);
  }
}

/* ---------- Badges ---------- */

/* "ново" / "3 нови": the one badge left (the store, validity and discount have their own marks). */
.badge {
  display: inline-block;
  padding: 0.1rem var(--space-2);
  border-radius: var(--radius-chip);
  font-size: var(--text-sm);
  font-weight: var(--weight-strong);
  white-space: nowrap;
}
.badge-new {
  background: var(--color-primary);
  color: var(--color-on-primary);
  text-transform: uppercase;
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-label);
}

/* ---------- Alerts ---------- */

/* Information: flat and tinted, no side bar. */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-card);
  display: grid;
  gap: var(--space-1);
}
.alert-title {
  font-weight: var(--weight-strong);
}
.alert-info {
  background: var(--color-info-bg);
  color: var(--color-info-fg);
}
.alert-success {
  background: var(--color-success-bg);
  color: var(--color-success-fg);
}
.alert-warning {
  background: var(--color-warning-bg);
  color: var(--color-warning-fg);
}
.alert-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger-fg);
}

/* ---------- Forms ---------- */

.field {
  display: grid;
  gap: var(--space-1);
}
.field label {
  font-weight: var(--weight-strong);
  font-size: var(--text-sm);
}
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
select,
textarea {
  font: inherit;
  color: var(--color-text);
  background: var(--color-inset);
  border: 1px solid var(--color-inset-edge);
  border-top-color: var(--color-inset-edge-top);
  border-radius: var(--radius-input);
  box-shadow: var(--shadow-inset);
  padding: var(--space-2) var(--space-3);
  width: 100%;
}
/* A select is a control you press, not a field: raised. */
select {
  background: var(--gradient-raised);
  border-color: var(--color-raised-edge);
  border-bottom-color: var(--color-raised-edge-bottom);
  border-radius: var(--radius-control);
  box-shadow: var(--shadow-raised);
}
/* Focused fields: no ring around them; the border turns ink, 2 px, and the field sinks in. */
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--color-focus);
  box-shadow:
    inset 0 0 0 1px var(--color-focus),
    var(--shadow-inset-sunk);
}
::placeholder {
  color: var(--color-faint);
  opacity: 1;
}
/* The base rule's :not()s outweigh input:disabled, so they are repeated here. */
input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):disabled,
select:disabled,
textarea:disabled {
  background: var(--color-surface-2);
  border-color: var(--color-border);
  box-shadow: none;
  color: var(--color-muted);
}
.field-invalid input:not([type="checkbox"]):not([type="radio"]),
.field-invalid select {
  border-color: var(--color-danger-fg);
}
.field-invalid input:not([type="checkbox"]):not([type="radio"]):focus-visible {
  box-shadow:
    inset 0 0 0 1px var(--color-danger-fg),
    var(--shadow-inset-sunk);
}
.field-mark {
  color: var(--color-danger-fg);
  font-weight: var(--weight-heavy);
}
.field-hint {
  font-size: var(--text-sm);
  color: var(--color-muted);
}
.field-error {
  font-size: var(--text-sm);
  color: var(--color-danger-fg);
}
.checkbox {
  display: inline-flex;
  gap: var(--space-2);
  align-items: center;
}
input[type="checkbox"] {
  accent-color: var(--color-primary);
  width: 1.1rem;
  height: 1.1rem;
}

/* ---------- Table ---------- */

.table-wrap {
  overflow-x: auto;
}
.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-surface);
}
.table th,
.table td {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-rule);
}
.table th {
  font-size: var(--text-sm);
  font-weight: var(--weight-strong);
  color: var(--color-muted);
}
.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---------- Disclosure / empty ---------- */

.disclosure summary {
  cursor: pointer;
  font-weight: var(--weight-strong);
}
/* Nothing to show: a heading and a hint on the page, no frame. */
.empty {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  display: grid;
  gap: var(--space-2);
  justify-items: center;
  color: var(--color-muted);
  text-wrap: balance;
}
.empty-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-heavy);
  color: var(--color-text);
}

/* ---------- Coverage strip ---------- */

/* A footnote under a hairline: which leaflets the page is built from. Only an expired one is red. */
.coverage {
  display: grid;
  gap: var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-rule);
  font-size: var(--text-sm);
  color: var(--color-muted);
  font-variant-numeric: tabular-nums;
}
.coverage-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-4);
  list-style: none;
  margin: 0;
  padding: 0;
}
.coverage-expired {
  color: var(--color-danger-fg);
  font-weight: var(--weight-strong);
}

/* ---------- Search + offers ---------- */

/* The words field is the page's hero (big, a search icon inside); store and category under it
   side by side on a phone, in one row with it on desktop. The labels are read, not shown. */
.search-form {
  display: grid;
  gap: var(--space-2);
  grid-template-columns: 2fr 1fr 1fr;
  align-items: end;
}
.search-q {
  position: relative;
}
.search-q .icon {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  translate: 0 -50%;
  width: 1.25rem;
  height: 1.25rem;
  color: var(--color-faint);
  pointer-events: none;
}
/* The id: the base input rule's :not()s outweigh a class. */
#f-q {
  min-height: 3rem;
  padding-left: 2.6rem;
  font-size: var(--text-lg);
}
.search-form select {
  min-height: 3rem;
}
@media (max-width: 40rem) {
  .search-form {
    grid-template-columns: 1fr 1fr;
  }
  .search-q {
    grid-column: 1 / -1;
  }
}
/* The field's ✕: an ink-grey cross instead of the browser's blue one. */
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  width: 1.25rem;
  height: 1.25rem;
  background-color: var(--color-muted);
  -webkit-mask:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E")
    center / contain no-repeat;
  mask:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E")
    center / contain no-repeat;
  cursor: pointer;
}

.offer-list {
  list-style: none;
  margin: var(--space-2) 0 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}
/* Search results from tablet width: cards in columns (3 at the full container, 2 on a tablet).
   The name grows, so price rows and foot lines line up across a row. */
@media (min-width: 48rem) {
  .offer-grid {
    grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
    gap: 10px;
  }
  .offer-grid > .offer-card {
    grid-template-rows: 1fr auto auto;
  }
}

/*
 * The offer card, flat: name (with ♥), the price row, a quiet foot line (store, validity, page).
 * The name's link covers the card. Design: docs/design/04-offer-card/NOTES.md.
 */
.offer-card {
  position: relative;
  display: grid;
  gap: var(--space-2);
  padding: 10px var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  scroll-margin-top: var(--space-4);
}
@media (hover: hover) {
  .offer-card-linked:hover {
    border-color: var(--color-muted);
  }
}
.offer-card-linked:active {
  background: var(--color-surface-2);
}
.offer-card-linked:has(.offer-card-name a:focus-visible) {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}
/* The offer the page view was opened from. */
.offer-card-highlight {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 1px var(--color-primary);
}
.offer-card-top {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
}
.offer-card-info {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: var(--space-1);
  align-content: start;
}
.offer-card-name {
  font-size: var(--text-md);
  font-weight: var(--weight-name);
  line-height: var(--line-height-snug);
  overflow-wrap: anywhere;
}
.offer-card-name a {
  color: inherit;
  text-decoration: none;
}
@media (hover: hover) {
  .offer-card-name a:hover {
    text-decoration: underline;
  }
}
.offer-card-name a:focus-visible {
  outline: none;
}
/* Stretched link: the name's link covers the card. */
.offer-card-name a::after {
  content: "";
  position: absolute;
  inset: 0;
}
.offer-card-brand {
  font-weight: var(--weight-text);
  color: var(--color-muted);
}
/* Size, then the conditions that change what you pay (ink, with their icon). */
.offer-card-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-3);
  font-size: var(--text-sm);
}
.offer-card-size {
  color: var(--color-muted);
}
.offer-card-conditions {
  display: contents;
  list-style: none;
  font-weight: var(--weight-strong);
}
.offer-card-conditions li {
  white-space: nowrap;
}
/* The price row: new price, the discount right after it, old / unit price at the right end. */
.offer-card-price {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-1) 10px;
  font-variant-numeric: tabular-nums;
}
/* The largest, heaviest thing on the card: big euros, small raised cents, "€" under them. */
.price-new {
  display: inline-flex;
  align-items: flex-start;
  font-size: var(--text-price-whole);
  font-weight: var(--weight-heavy);
  line-height: 0.82;
  letter-spacing: var(--tracking-price);
  white-space: nowrap;
}
.price-frac {
  display: grid;
  justify-items: start;
  margin-left: 2px;
  font-size: 0.5em;
  line-height: 1;
}
.price-cents {
  padding-top: 1px;
}
.price-eur {
  margin-top: 2px;
  font-size: 0.76em;
  font-weight: var(--weight-strong);
}
/* Ink on a square yellow highlighter, the one yellow thing on the card. */
.discount {
  align-self: center;
  background: var(--color-deal);
  color: var(--color-on-deal);
  font-size: var(--text-discount);
  font-weight: var(--weight-heavy);
  line-height: var(--line-height-none);
  padding: 0.3em 0.35em 0.24em;
  white-space: nowrap;
}
.price-was {
  display: grid;
  gap: 2px;
  margin-left: auto;
  text-align: right;
  line-height: var(--line-height-tight);
  white-space: nowrap;
}
.price-old {
  color: var(--color-muted);
  font-size: var(--text-sm);
}
.price-unit {
  color: var(--color-muted);
  font-size: var(--text-sm);
}
.price-unit-best {
  color: var(--color-text);
  font-weight: var(--weight-strong);
}
.best-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  font-size: var(--text-sm);
  font-weight: var(--weight-strong);
  color: var(--color-success-fg);
}
.best-tag .icon {
  fill: currentColor;
}
/* Where and until when: quiet, under a hairline. */
.offer-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 var(--space-2);
  padding-top: 6px;
  border-top: 1px solid var(--color-rule);
  font-size: var(--text-sm);
  color: var(--color-muted);
}
.offer-card-page {
  white-space: nowrap;
}
/* The highlighted card's fine print (page view): the raw conditions. */
.offer-card-details {
  position: relative;
  z-index: 1;
  display: grid;
  gap: var(--space-1);
  margin: 0;
  padding-top: var(--space-2);
  border-top: 1px dashed var(--color-border);
  font-size: var(--text-sm);
}
.offer-card-details dt {
  color: var(--color-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-strong);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}
.offer-card-details dd {
  margin: 0 0 var(--space-1);
}
/* Compact (list rows): smaller name and price. */
.offer-card-compact .offer-card-name {
  font-size: var(--text-sm);
}
.offer-card-compact .price-new {
  font-size: var(--text-price-whole-compact);
}
.offer-card-compact .discount {
  font-size: var(--text-sm);
}

/* ---------- Store mark, validity ---------- */

/* The store's colour once, as a small square; the name carries the meaning. */
.store-mark {
  --store-mark: var(--color-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: var(--text-sm);
  font-weight: var(--weight-strong);
  color: var(--color-text);
  white-space: nowrap;
}
.store-mark-square {
  flex: none;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: var(--radius-cover);
  background: var(--store-mark);
  box-shadow: 0 0 0 1px var(--color-store-ring);
}
.store-mark-kaufland {
  --store-mark: var(--store-kaufland);
}
.store-mark-lidl {
  --store-mark: var(--store-lidl);
}
.store-mark-fantastico {
  --store-mark: var(--store-fantastico);
}
.store-mark-metro {
  --store-mark: var(--store-metro);
}
.store-mark-hitmax {
  --store-mark: var(--store-hitmax);
}
.store-mark-billa {
  --store-mark: var(--store-billa);
}

/* Text only: muted normally, bold for the exceptions; the wording carries the meaning. */
.validity {
  font-size: var(--text-sm);
  white-space: nowrap;
  color: var(--color-muted);
}
.validity-ending-soon,
.validity-last-day,
.validity-upcoming {
  color: var(--color-text);
  font-weight: var(--weight-strong);
}
.validity-expired {
  color: var(--color-danger-fg);
  font-weight: var(--weight-strong);
}

.results-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

/* ---------- Page head, form rows, confirm ---------- */

.confirm {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
}

/* ---------- Filter chips ---------- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  list-style: none;
  margin: 0;
  padding: 0;
}
.chip {
  padding: 0 var(--space-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-chip);
  font-size: var(--text-sm);
  color: var(--color-muted);
  background: var(--color-surface-2);
}

/* ---------- The list ---------- */

/* The add field: input + button in one row, the live preview under it. */
.list-add {
  display: grid;
  gap: var(--space-2);
}
.list-add-row {
  display: flex;
  gap: var(--space-2);
}
.list-add-row input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
}
/* A tray under the field (not a card), so the example cards in it are not cards in a card. */
.add-preview {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--color-surface-2);
  border-radius: var(--radius-card);
}
.add-preview-group {
  display: grid;
  gap: var(--space-2);
}
.add-preview-choice {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.add-preview-choice legend {
  padding: 0;
  margin-bottom: var(--space-2);
}
.section-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-strong);
  color: var(--color-muted);
}
.divider {
  border: 0;
  border-top: 1px solid var(--color-rule);
  margin: 0;
}
/* A one-tap choice (aria-pressed); `chip-on` is the picked one. Raised like a secondary
   button; a press pushes in. */
.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: var(--target-sm);
  padding: 0 var(--space-3);
  font: inherit;
  font-size: var(--text-sm);
  color: var(--color-text);
  background: var(--gradient-raised);
  border: 1px solid var(--color-raised-edge);
  border-bottom-color: var(--color-raised-edge-bottom);
  border-radius: var(--radius-chip);
  box-shadow: var(--shadow-raised);
  cursor: pointer;
}
@media (hover: hover) {
  .chip-btn:hover {
    border-color: var(--color-raised-edge-bottom);
  }
}
.chip-btn:active {
  background: var(--color-pressed);
  border-top-color: var(--color-raised-edge-bottom);
  box-shadow: var(--shadow-pressed);
  transform: translateY(1px);
}
/* Picked: ink like the primary button, with its relief (an action state, not a deal). */
.chip-on {
  font-weight: var(--weight-strong);
  color: var(--color-on-primary);
  background: var(--gradient-primary);
  border-color: var(--color-primary-edge);
  box-shadow: var(--shadow-primary);
}
@media (hover: hover) {
  .chip-on:hover {
    border-color: var(--color-primary-edge);
  }
}
.chip-on:active {
  background: var(--color-primary-pressed);
  box-shadow: var(--shadow-primary-pressed);
}
.chip-count {
  font-weight: var(--weight-text);
  font-variant-numeric: tabular-nums;
  color: var(--color-muted);
}
.chip-on .chip-count {
  color: inherit;
}
/* An on / off chip: a checkbox (submitted with the form) drawn as a chip; ✓ when on. The same
   states as above, keyed on the checkbox. */
.chip-toggle {
  position: relative;
}
.chip-toggle input {
  position: absolute;
  opacity: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
/* The ✓ shows on the picked chip only. :where() keeps this at (0,2,0), under the later icon rules. */
.chip-toggle :where(input:not(:checked) + .chip-btn) .icon {
  display: none;
}
@media (hover: hover) {
  .chip-toggle:hover .chip-btn {
    border-color: var(--color-raised-edge-bottom);
  }
}
.chip-toggle input:active + .chip-btn {
  background: var(--color-pressed);
  border-top-color: var(--color-raised-edge-bottom);
  box-shadow: var(--shadow-pressed);
  transform: translateY(1px);
}
.chip-toggle input:focus-visible + .chip-btn {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}
.chip-toggle input:checked + .chip-btn {
  font-weight: var(--weight-strong);
  color: var(--color-on-primary);
  background: var(--gradient-primary);
  border-color: var(--color-primary-edge);
  box-shadow: var(--shadow-primary);
  transform: none;
}
.chip-toggle input:checked:active + .chip-btn {
  background: var(--color-primary-pressed);
  box-shadow: var(--shadow-primary-pressed);
  transform: translateY(1px);
}

/* ♥ at the top right of a card: a 40 px round raised button with a 44 px target, kept from
   making the name's row taller. */
.heart-form {
  position: relative;
  z-index: 1;
  flex: none;
  margin: -4px -4px -4px 0;
}
.heart {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--target-heart);
  height: var(--target-heart);
  padding: 0;
  font-size: var(--text-lg);
  color: var(--color-heart);
  background: var(--gradient-raised);
  border: 1px solid var(--color-raised-edge);
  border-bottom-color: var(--color-raised-edge-bottom);
  border-radius: var(--radius-round);
  box-shadow: var(--shadow-raised);
  cursor: pointer;
}
.heart::before {
  content: "";
  position: absolute;
  inset: calc((var(--target-heart) - var(--target)) / 2);
}
@media (hover: hover) {
  .heart:hover {
    border-color: var(--color-raised-edge-bottom);
  }
}
.heart:active {
  background: var(--color-pressed);
  border-top-color: var(--color-raised-edge-bottom);
  box-shadow: var(--shadow-pressed);
  transform: translateY(1px);
}
.heart-on .icon {
  fill: currentColor;
}
.heart:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

/* The add-from-offer sheet: a bottom sheet on phones, a centred dialog on wider screens. */
.sheet {
  width: 100%;
  max-width: 32rem;
  max-height: 90dvh;
  margin: auto auto 0;
  padding: 0;
  color: var(--color-text);
  background: var(--color-surface);
  border: 0;
  border-radius: var(--radius-sheet) var(--radius-sheet) 0 0;
  box-shadow: var(--shadow-overlay);
}
.sheet::backdrop {
  background: var(--color-backdrop);
}
@media (min-width: 40rem) {
  .sheet {
    margin: auto;
    border-radius: var(--radius-card);
  }
}
.sheet-form {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-4);
}
.sheet-page .sheet-form {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
}
.sheet-head {
  display: grid;
  gap: var(--space-1);
}
.sheet-group {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.sheet-group legend {
  padding: 0;
  margin-bottom: var(--space-2);
}
.sheet-count {
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-2);
  border-radius: var(--radius-card);
}
.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2);
}

.list-head {
  display: grid;
  gap: var(--space-1);
}
.list-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}
/* One item: head (title + status), filter chips, the best offer as a compact card, "още N". */
.list-row {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
}
/* No matches: a quiet line without a frame, so the item stays in its place in the list. */
.list-row-quiet {
  background: transparent;
  border-color: transparent;
  padding-block: var(--space-2);
}
.list-row-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-1) var(--space-2);
}
.list-row-title a {
  color: inherit;
  text-decoration: none;
}
@media (hover: hover) {
  .list-row-title a:hover {
    text-decoration: underline;
  }
}
/* The row's status: a small uppercase label; "в промоция" with the deal's yellow square. */
.status {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  font-size: var(--text-xs);
  font-weight: var(--weight-strong);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  white-space: nowrap;
}
.status-deal::before {
  content: "";
  width: 0.6rem;
  height: 0.6rem;
  background: var(--color-deal);
}
/* The row is the card: its offer sits in it without a frame of its own. */
.list-row .offer-card-compact {
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}
.list-row-more {
  justify-self: start;
  font-size: var(--text-sm);
  font-weight: var(--weight-strong);
}

/* The item page: title, chips (or the edit form), summary line; remove at the bottom. */
.back-link {
  justify-self: start;
}
.item-head {
  display: grid;
  gap: var(--space-2);
}
a.chip-btn {
  text-decoration: none;
}
/* On the page like the list's add field (no card), so its preview tray is not a tray in a card. */
.item-edit {
  display: grid;
  gap: var(--space-3);
  margin-block: var(--space-2) var(--space-3);
}
/* A ghost button whose text lines up with the column (its padding and border hang out left). */
.item-remove {
  justify-self: start;
  margin-inline-start: calc(-1 * var(--space-4) - 1px);
  color: var(--color-danger-fg);
}

/* The empty list: what it is for, starter chips (one POST form each), the ♥ hint. */
.list-empty {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
}
.list-empty .chips {
  justify-content: center;
}

/* ---------- Leaflet page view ---------- */

.leaflet-page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}
/* The page view: the image starts high, so less air above and between the parts. */
.main:has(> .leaflet-page) {
  padding-top: var(--space-3);
  padding-bottom: 0;
}
.leaflet-page {
  gap: var(--space-3);
}
.leaflet-page > h2 {
  margin: var(--space-2) 0 0;
  scroll-margin-top: var(--space-3);
}
/* One line: store mark, label (cut with "…"), validity. */
.leaflet-page-head-line {
  flex-wrap: nowrap;
  gap: var(--space-2);
  min-width: 0;
}
.leaflet-page-head-line .leaflet-page-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.leaflet-page-head-line > :not(.leaflet-page-label) {
  flex-shrink: 0;
}
.leaflet-page-from {
  margin: 0;
}
.leaflet-page-figure {
  margin: 0;
  display: grid;
  gap: var(--space-1);
}
.leaflet-page-figure figcaption {
  justify-self: end;
}

/* The bottom bar: a tray (like the nav) with raised round arrows; edge to edge on a phone, above
   the home indicator; a centred pill when wide. Every target at least 44 px. Last in the page
   view, so at the end it sits below the last card; the ♥ sheet is a modal <dialog> (top layer),
   always above it. */
.page-bar {
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-inline: calc(-1 * var(--space-4));
  padding: var(--space-1) var(--space-3) calc(var(--space-1) + env(safe-area-inset-bottom));
  background: var(--color-surface-2);
  border-top: 1px solid var(--color-border);
  box-shadow: var(--shadow-overlay-up);
}
.page-bar > * {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  text-decoration: none;
  white-space: nowrap;
}
.page-bar-arrow {
  flex: none;
  width: 44px;
  height: 44px;
  color: var(--color-text);
  background: var(--gradient-raised);
  border: 1px solid var(--color-raised-edge);
  border-bottom-color: var(--color-raised-edge-bottom);
  border-radius: var(--radius-round);
  box-shadow: var(--shadow-raised);
}
.page-bar-arrow .icon {
  width: 1.4em;
  height: 1.4em;
}
@media (hover: hover) {
  a.page-bar-arrow:hover {
    border-color: var(--color-raised-edge-bottom);
  }
}
a.page-bar-arrow:active {
  background: var(--color-pressed);
  border-top-color: var(--color-raised-edge-bottom);
  box-shadow: var(--shadow-pressed);
  transform: translateY(1px);
}
/* First / last page: the button's place, flat and muted (nothing to tap). */
.page-bar-off {
  color: var(--color-muted);
  background: transparent;
  border: 1px solid var(--color-border);
  box-shadow: none;
  opacity: 0.6;
}
.page-bar-count {
  flex: 1;
  font-weight: var(--weight-heavy);
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
}
.page-bar-offers {
  flex: 1;
  gap: var(--space-1);
  font-size: var(--text-sm);
  font-weight: var(--weight-strong);
  color: var(--color-text);
}
@media (min-width: 40rem) {
  .page-bar {
    bottom: var(--space-3);
    justify-self: center;
    width: 26rem;
    margin: 0 0 var(--space-3);
    padding: var(--space-1);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-bar);
    box-shadow: var(--shadow-overlay);
  }
}
/* Kitchen sink: the bar's states in place, not sticky. */
.page-bar-samples {
  display: grid;
  gap: var(--space-2);
}
.page-bar-samples .page-bar {
  position: static;
}

/* Full width; width/height from pages.json keep the aspect ratio, so nothing jumps. */
.leaflet-page-image {
  display: block;
  width: 100%;
  height: auto;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-cover);
}

/* ---------- Leaflet index and page grid ---------- */

/* The index: horizontal cards (cover left, text right), one column on a phone, a grid when wide. */
.leaflet-cards {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-3);
  list-style: none;
  margin: 0;
  padding: 0;
}
@media (min-width: 48rem) {
  .leaflet-cards {
    grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr));
  }
}
.leaflet-card-body {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  height: 100%;
  padding: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  color: var(--color-text);
  text-decoration: none;
}
@media (hover: hover) {
  a.leaflet-card-body:hover {
    border-color: var(--color-primary);
  }
}
/* One box for every cover, so the cards line up; landscape spreads are letterboxed. */
.leaflet-card-cover {
  flex: none;
  display: block;
  width: 5.5rem;
  aspect-ratio: 3 / 4;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-cover);
  overflow: hidden;
}
.leaflet-card-cover img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.leaflet-card-text {
  display: grid;
  justify-items: start;
  gap: var(--space-1);
  min-width: 0;
}
/* The store is the card's title; the dates and the validity are the line under it. */
.leaflet-card-label {
  font-size: var(--text-lg);
  font-weight: var(--weight-strong);
  line-height: var(--line-height-tight);
}
/* As a title the store mark is inline text (on the heading's baseline), the square sized to it. */
.leaflet-card-label .store-mark,
.leaflet-grid-title .store-mark {
  display: inline;
  font-size: inherit;
  font-weight: inherit;
  white-space: normal;
}
.leaflet-card-label .store-mark-square,
.leaflet-grid-title .store-mark-square {
  display: inline-block;
  width: 0.6em;
  height: 0.6em;
  margin-right: 0.3em;
}
.leaflet-card-dates {
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-2);
  font-weight: var(--weight-name);
}
.leaflet-index-missing {
  margin: 0;
}

/* The page grid: two tiles per row on a phone, more when wide. */
.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(10rem, 40%), 1fr));
  gap: var(--space-3);
  list-style: none;
  margin: 0;
  padding: 0;
}
.leaflet-grid-head {
  display: grid;
  gap: var(--space-1);
}
.leaflet-grid-title {
  margin: 0;
  overflow-wrap: anywhere;
}
.leaflet-grid-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  margin: 0;
  font-size: var(--text-sm);
}
.page-tile-link {
  display: grid;
  gap: var(--space-1);
  color: var(--color-text);
  text-decoration: none;
}
.page-tile-image,
.page-tile-blank {
  display: block;
  width: 100%;
  height: auto;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-cover);
}
@media (hover: hover) {
  .page-tile-link:hover .page-tile-image,
  .page-tile-link:hover .page-tile-blank {
    border-color: var(--color-primary);
  }
}
/* Not backfilled yet: a page-shaped box with the number. */
.page-tile-blank {
  aspect-ratio: 3 / 4;
  display: grid;
  place-items: center;
  font-size: var(--text-2xl);
  font-weight: var(--weight-heavy);
  color: var(--color-muted);
}
.page-tile-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-1);
  font-size: var(--text-sm);
}
.page-tile-offers {
  font-variant-numeric: tabular-nums;
}
.page-tile:target .page-tile-image,
.page-tile:target .page-tile-blank {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ---------- Loading, motion ---------- */

/* An HTMX request in flight (hx-indicator, or the form itself): what will change dims; the ♥
   stays pressed until its sheet opens. */
.results.htmx-request,
.add-preview-slot.htmx-request,
.sheet-form.htmx-request {
  opacity: 0.6;
}
.heart-form.htmx-request .heart {
  background: var(--color-pressed);
  border-top-color: var(--color-raised-edge-bottom);
  box-shadow: var(--shadow-pressed);
}

/* Small and few: press feedback, the sheet coming in, the ♥ press. Nothing moves for people who
   ask for less motion. */
@media (prefers-reduced-motion: no-preference) {
  .btn,
  .chip-btn,
  .heart,
  .page-bar-arrow,
  .navbar-links a {
    transition:
      transform 60ms ease-out,
      box-shadow 80ms ease-out;
  }
  .heart .icon {
    transition: scale 120ms ease-out;
  }
  .heart:active .icon {
    scale: 0.85;
  }
  /* Dims after a short wait, so a fast answer does not flicker. */
  .results,
  .add-preview-slot,
  .sheet-form {
    transition: opacity 150ms 100ms;
  }
  /* The sheet slides up on a phone, fades in on wider screens; the backdrop fades. */
  .sheet[open] {
    transition:
      translate 220ms cubic-bezier(0.2, 0.8, 0.2, 1),
      opacity 160ms ease-out,
      scale 160ms ease-out;
  }
  .sheet[open]::backdrop {
    transition: opacity 220ms ease-out;
  }
  @starting-style {
    .sheet[open] {
      translate: 0 100%;
    }
    .sheet[open]::backdrop {
      opacity: 0;
    }
  }
  @media (min-width: 40rem) {
    @starting-style {
      .sheet[open] {
        translate: none;
        opacity: 0;
        scale: 0.98;
      }
    }
  }
}

/* ---------- Kitchen sink ---------- */

.kitchen-sink {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(min(26rem, 100%), 1fr));
}
.theme-panel {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  padding: var(--space-4);
  min-width: 0;
}
/* A sample wider than a half-width panel (the desktop navbar) scrolls inside it. */
.ks-scroll {
  overflow-x: auto;
}
.theme-panel-label {
  font-weight: var(--weight-strong);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  font-size: var(--text-xs);
  color: var(--color-muted);
  margin-bottom: var(--space-3);
}
/* Foundations: type scale, swatches, radius, elevation. */
.ks-type,
.ks-swatches,
.ks-radii,
.ks-elevation {
  display: grid;
  gap: var(--space-3);
  list-style: none;
  margin: 0;
  padding: 0;
}
.ks-type li {
  display: grid;
  gap: var(--space-1);
}
.ks-type-sample {
  line-height: var(--line-height-tight);
}
.ks-type-label {
  letter-spacing: var(--tracking-label);
}
.ks-token {
  font-size: var(--text-xs);
  color: var(--color-muted);
  overflow-wrap: anywhere;
}
.ks-digits span {
  display: block;
  width: max-content;
  margin-left: auto;
  font-weight: var(--weight-heavy);
  font-variant-numeric: tabular-nums;
}
.ks-identity {
  align-items: end;
}
.ks-identity figure {
  margin: 0;
  display: grid;
  justify-items: center;
  gap: var(--space-1);
}
/* What iOS does to the square icon. */
.ks-app-icon {
  border-radius: 22.5%;
}
.ks-swatches,
.ks-radii,
.ks-elevation {
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
}
.ks-swatches li,
.ks-radii li,
.ks-elevation li {
  display: grid;
  gap: var(--space-1);
  justify-items: start;
}
.ks-swatch,
.ks-radius {
  width: 100%;
  height: 2.5rem;
  border: 1px solid var(--color-rule);
}
.ks-swatch {
  border-radius: var(--radius-input);
}
.ks-radius {
  width: 3rem;
  height: 3rem;
  background: var(--color-surface);
  border-color: var(--color-raised-edge);
}
.ks-elev {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: var(--target);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-control);
  background: var(--color-surface);
  font-weight: var(--weight-strong);
}
.ks-elev-flat {
  border-radius: var(--radius-card);
}
.ks-elev-raised {
  background: var(--gradient-raised);
  border-color: var(--color-raised-edge);
  border-bottom-color: var(--color-raised-edge-bottom);
  box-shadow: var(--shadow-raised);
}
.ks-elev-pressed {
  background: var(--color-pressed);
  border-color: var(--color-raised-edge);
  border-top-color: var(--color-raised-edge-bottom);
  box-shadow: var(--shadow-pressed);
}
.ks-elev-primary {
  background: var(--gradient-primary);
  border-color: var(--color-primary-edge);
  box-shadow: var(--shadow-primary);
  color: var(--color-on-primary);
}
.ks-elev-inset {
  background: var(--color-inset);
  border-color: var(--color-inset-edge);
  border-top-color: var(--color-inset-edge-top);
  border-radius: var(--radius-input);
  box-shadow: var(--shadow-inset);
}
.ks-elev-inset-focus {
  background: var(--color-inset);
  border-color: var(--color-focus);
  border-radius: var(--radius-input);
  box-shadow:
    inset 0 0 0 1px var(--color-focus),
    var(--shadow-inset-sunk);
}
.ks-elev-overlay {
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-overlay);
}
