/* Provender. Readable at arm's length under store lighting, one thumb.
   The one loud element is the aisle sign (section headers); the rest is quiet. */

@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("fonts/atkinson-hyperlegible-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("fonts/atkinson-hyperlegible-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --ink: #1B2430;
  --muted: #5F6873;
  --paper: #FFFFFF;
  --wash: #F2F4F3;
  --rule: #E3E6E8;
  --aisle: #0F6E4F;
  --aisle-ink: #FFFFFF;
  --aisle-soft: #E3F1EB;
  --sticker: #F4C430;
  --sticker-ink: #3D2E00;
  --danger: #A3262A;
  --focus: #1D5FD1;

  --step--1: 0.875rem;
  --step-0: 1.0625rem; /* 17px body: comfortable in the hand */
  --step-1: 1.25rem;
  --step-2: 1.5rem;
  --tap: 44px;
  --gutter: 16px;
  --radius: 10px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #E8ECEF;
    --muted: #A2ABB3;
    --paper: #12171D;
    --wash: #1A2129;
    --rule: #2A333C;
    --aisle: #2E9C73;
    --aisle-ink: #06150F;
    --aisle-soft: #173328;
    --sticker: #F2C94C;
    --sticker-ink: #2A1F00;
    --danger: #F08A8D;
    --focus: #7FB0FF;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--step-0)/1.45 "Atkinson Hyperlegible", system-ui, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

.boot { padding: 40px var(--gutter); color: var(--muted); }

/* ---------------------------------------------------------------- shell */

.shell { display: flex; flex-direction: column; min-height: 100dvh; max-width: 680px; margin: 0 auto; }
.top {
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) var(--gutter) 10px;
  position: sticky; top: 0; z-index: 5; background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.top h1 { font-size: var(--step-1); margin: 0; flex: 1; font-weight: 700; }
.top .back { min-width: var(--tap); min-height: var(--tap); margin-left: -12px; border: 0; background: none; font-size: var(--step-1); cursor: pointer; }
.sync { font-size: var(--step--1); color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.sync::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.sync[data-state="live"]::before { background: var(--aisle); }
.sync[data-state="sending"]::before { background: var(--sticker); }
.sync[data-state="problem"]::before { background: var(--danger); }

main { flex: 1; padding-bottom: 150px; }
.banner { margin: 10px var(--gutter); padding: 12px 14px; border-radius: var(--radius); background: var(--wash); }
.banner.problem { background: color-mix(in srgb, var(--danger) 14%, var(--paper)); }

.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  background: var(--paper); border-top: 1px solid var(--rule);
  padding-bottom: env(safe-area-inset-bottom);
}
.dock-inner { max-width: 680px; margin: 0 auto; }
.tabs { display: flex; }
.tabs button {
  flex: 1; min-height: 52px; border: 0; background: none; cursor: pointer;
  color: var(--muted); font-size: var(--step--1); font-weight: 700;
}
.tabs button[aria-current="page"] { color: var(--aisle); box-shadow: inset 0 3px 0 var(--aisle); }

/* ---------------------------------------------------------------- add bar */

.addbar { position: relative; padding: 8px var(--gutter); }
.addbar input {
  width: 100%; min-height: 48px; padding: 0 14px;
  border: 2px solid var(--rule); border-radius: var(--radius); background: var(--wash);
}
.addbar input:focus { border-color: var(--aisle); background: var(--paper); outline: none; }
.suggest {
  position: absolute; left: var(--gutter); right: var(--gutter); bottom: 100%;
  margin: 0; padding: 4px 0; list-style: none;
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius);
  box-shadow: 0 -6px 24px rgb(0 0 0 / 0.12);
}
.suggest button { width: 100%; text-align: left; min-height: var(--tap); padding: 0 14px; border: 0; background: none; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.suggest button[aria-selected="true"], .suggest button:hover { background: var(--aisle-soft); }
.suggest small { color: var(--muted); }

/* ---------------------------------------------------------------- store picker */

.stores { display: flex; gap: 8px; padding: 12px var(--gutter) 4px; overflow-x: auto; scrollbar-width: none; }
.stores button {
  min-height: 40px; padding: 0 16px; border-radius: 999px; cursor: pointer; white-space: nowrap;
  border: 2px solid var(--rule); background: var(--paper); font-weight: 700;
}
.stores button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ---------------------------------------------------------------- the aisle sign */

.store-name { margin: 22px var(--gutter) 6px; font-size: var(--step-2); font-weight: 700; }
.aisle {
  margin: 14px 0 0; padding: 8px var(--gutter);
  background: var(--aisle); color: var(--aisle-ink);
  font-size: var(--step-1); font-weight: 700; letter-spacing: 0.01em;
  display: flex; justify-content: space-between; align-items: baseline;
}
.aisle small { font-weight: 400; opacity: 0.85; font-size: var(--step--1); }
.aisle.quiet { background: var(--wash); color: var(--muted); font-size: var(--step-0); }
.group { margin: 18px var(--gutter) 0; font-weight: 700; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.group button { font-weight: 700; }

/* ---------------------------------------------------------------- rows */

.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: flex-start; gap: 6px; padding: 6px var(--gutter) 6px 6px; border-bottom: 1px solid var(--rule); }
.check {
  flex: none; width: var(--tap); height: var(--tap); border: 0; background: none; cursor: pointer;
  display: grid; place-items: center;
}
.check::before {
  content: ""; width: 26px; height: 26px; border-radius: 50%;
  border: 2.5px solid var(--muted);
}
.row.done .check::before { background: var(--aisle) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5 10.5l3.2 3.2L15 7' fill='none' stroke='white' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center/18px no-repeat; border-color: var(--aisle); }
.row .body { flex: 1; min-width: 0; padding-top: 10px; cursor: pointer; }
.row .name { font-weight: 700; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.row .hint { font-weight: 400; color: var(--muted); }
.row.done .name { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--muted); }
.row .note { color: var(--muted); font-size: var(--step--1); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.chip { font-size: var(--step--1); padding: 1px 8px; border-radius: 999px; background: var(--wash); color: var(--muted); }
.chip.meal { background: var(--aisle-soft); color: var(--ink); }
.readded { display: inline-block; margin-top: 6px; padding: 4px 9px; border-radius: 6px; background: var(--sticker); color: var(--sticker-ink); font-size: var(--step--1); font-weight: 700; transform: rotate(-1deg); }
.row .aside { flex: none; padding-top: 6px; display: flex; gap: 4px; }

.btn {
  min-height: 40px; padding: 0 14px; border-radius: var(--radius); cursor: pointer;
  border: 2px solid var(--rule); background: var(--paper); font-weight: 700;
}
.btn.small { min-height: 34px; padding: 0 10px; font-size: var(--step--1); }
.btn.primary { background: var(--aisle); border-color: var(--aisle); color: var(--aisle-ink); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: default; }
.link { border: 0; background: none; color: var(--aisle); font-weight: 700; cursor: pointer; padding: 6px 0; min-height: 34px; }

.empty { margin: 28px var(--gutter); color: var(--muted); max-width: 32em; }
.section { padding: 8px var(--gutter); }
.section h2 { font-size: var(--step-1); margin: 22px 0 8px; }
.section h3 { font-size: var(--step-0); margin: 18px 0 6px; }
.muted { color: var(--muted); }
.stack > * + * { margin-top: 10px; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label, .label { font-size: var(--step--1); color: var(--muted); font-weight: 700; }
.field input, .field textarea, .field select {
  min-height: 44px; padding: 8px 12px; border: 2px solid var(--rule); border-radius: var(--radius); background: var(--paper);
}
.field textarea { min-height: 120px; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { display: flex; align-items: center; gap: 8px; min-height: 52px; border-bottom: 1px solid var(--rule); padding: 4px 0; }
.list-plain li .grow { flex: 1; min-width: 0; }
.list-plain button.grow { text-align: left; border: 0; background: none; cursor: pointer; min-height: 44px; padding: 0; }
.seg { display: inline-flex; border: 2px solid var(--rule); border-radius: var(--radius); overflow: hidden; }
.seg button { min-height: 40px; padding: 0 12px; border: 0; background: var(--paper); cursor: pointer; font-weight: 700; }
.seg button + button { border-left: 2px solid var(--rule); }
.seg button[aria-pressed="true"] { background: var(--aisle); color: var(--aisle-ink); }

/* ---------------------------------------------------------------- sheets */

.scrim { position: fixed; inset: 0; z-index: 20; background: rgb(0 0 0 / 0.35); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 680px; max-height: 88dvh; overflow-y: auto;
  background: var(--paper); border-radius: 16px 16px 0 0;
  padding: 8px var(--gutter) calc(20px + env(safe-area-inset-bottom));
  animation: rise 160ms ease-out;
}
@keyframes rise { from { transform: translateY(24px); opacity: 0.6; } }
.sheet h2 { font-size: var(--step-1); margin: 12px 0; }
.sheet .grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--rule); margin: 4px auto 6px; }
.sheet .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.sheet .actions .wide { grid-column: 1 / -1; }

.toast {
  position: fixed; left: 50%; bottom: 140px; transform: translateX(-50%); z-index: 30;
  background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: var(--radius);
  display: flex; gap: 14px; align-items: center; max-width: calc(100% - 32px);
}
.toast button { border: 0; background: none; color: var(--sticker); font-weight: 700; cursor: pointer; min-height: 34px; }

/* ---------------------------------------------------------------- pantry */

.pantry-row { display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 4px var(--gutter); border-bottom: 1px solid var(--rule); }
.pantry-row .grow { flex: 1; }
.pantry-row .by { color: var(--muted); font-size: var(--step--1); }
.progress { height: 6px; background: var(--wash); margin: 0 var(--gutter); border-radius: 3px; overflow: hidden; }
.progress > div { height: 100%; background: var(--aisle); }

@media (min-width: 900px) {
  .shell { max-width: 760px; }
  .dock-inner, .sheet { max-width: 760px; }
}

/* ---------------------------------------------------------------- forms outside fields, notices */

.inline > input:not([type="checkbox"]), .section > input, .sheet input[type="search"], .notice textarea {
  flex: 1; min-width: 0; min-height: 44px; padding: 8px 12px;
  border: 2px solid var(--rule); border-radius: var(--radius); background: var(--paper);
}
.inline > input[size] { flex: 0 0 auto; width: 5.5em; }
.sheet .inline + .muted { margin-top: 6px; }
input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--aisle); flex: none; }
label.inline { gap: 10px; cursor: pointer; }
.notice { padding: 48px var(--gutter); max-width: 34em; }
.notice h1 { font-size: var(--step-2); margin: 0 0 8px; color: var(--aisle); }
.notice textarea { width: 100%; resize: vertical; }
.list-plain .chip { margin-left: 6px; }
.placement { align-items: flex-start !important; padding: 12px 0 !important; }
.placement select, .placement input, .stack > select {
  width: 100%; min-height: 44px; padding: 6px 10px;
  border: 2px solid var(--rule); border-radius: var(--radius); background: var(--paper);
}
