@font-face {
  font-family: "Bricolage Grotesque";
  src: url("fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "Patrick Hand";
  src: url("fonts/patrick-hand-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
:root {
  --bg: #EEF5F0;
  --ink: #1E2B4A;
  --ink-soft: #56627D;
  --hint: #8B94A8;
  --paper: #FFFFFF;
  --rule: #D3E2EE;
  --margin: #E05A4E;
  --magnet: #F2B544;
  --error-ink: #9B2C22;
  --error-bg: #FDECEA;
  --line: 52px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif;
}
button, input { font: inherit; color: inherit; }
a { color: inherit; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--magnet); outline-offset: 2px; }

/* ---------- category colours ---------- */
.c-fruit  { --tint: #DDF4E4; --deep: #187A46; --mid: #2FB36A; }
.c-bakery { --tint: #FFEDD2; --deep: #9A5A00; --mid: #F0A12E; }
.c-dairy  { --tint: #E1EEFF; --deep: #1F57AD; --mid: #4C8DF0; }
.c-meat   { --tint: #FFE2DE; --deep: #A8322A; --mid: #EC6A5E; }
.c-pantry { --tint: #EFE5FF; --deep: #5E35A8; --mid: #9D6CF0; }
.c-drinks { --tint: #D8F5F8; --deep: #0B6F7E; --mid: #22B3C7; }
.c-other  { --tint: #EDEFF3; --deep: #4A556E; --mid: #8B94A8; }

/* ---------- page layout ---------- */
.top { max-width: 1180px; margin: 0 auto; padding: 32px 20px 8px; }
.brand {
  margin: 0;
  font-size: clamp(2.4rem, 7vw, 4.2rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: .95;
}
.brand-mark { display: inline-block; transform: rotate(-8deg); margin-right: .15em; }
.tagline { margin: .6rem 0 0; color: var(--ink-soft); max-width: 46ch; font-size: 1.05rem; }
.layout {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 20px 96px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 400px;
  gap: 28px;
  align-items: start;
}

/* ---------- aisle chips ---------- */
.aisles { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 6px; padding: 0; list-style: none; }
.aisles a {
  display: inline-flex; align-items: center; gap: .4em;
  padding: .4rem .85rem;
  border-radius: 999px;
  background: var(--tint);
  color: var(--deep);
  font-weight: 600;
  text-decoration: none;
  font-size: .95rem;
}
.aisles a:hover { background: var(--mid); color: #fff; }

/* ---------- shelves ---------- */
.aisle { margin-top: 26px; scroll-margin-top: 16px; }
.aisle h2 {
  display: flex; align-items: center; gap: .5rem;
  margin: 0 0 12px;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--deep);
}
.aisle h2::after { content: ""; flex: 1; height: 3px; border-radius: 3px; background: var(--tint); }
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 0; padding: 0; list-style: none; }
.shelf form { margin: 0; height: 100%; }
.tile {
  position: relative;
  width: 100%; height: 100%;
  display: flex; flex-direction: column; align-items: flex-start;
  padding: 14px 14px 12px;
  border: 0;
  border-radius: 18px;
  background: var(--tint);
  text-align: left;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.tile:hover { transform: translateY(-2px); box-shadow: 0 10px 18px -12px var(--deep); }
.tile:active { transform: translateY(0) scale(.98); }
.tile .emoji { font-size: 2.7rem; line-height: 1; margin-bottom: 10px; }
.tile .pname { font-weight: 700; font-size: 1.05rem; line-height: 1.2; }
.tile .unit { color: var(--deep); opacity: .8; font-size: .85rem; }
.tile .price {
  margin-top: auto;
  padding-top: 10px;
  font-weight: 800;
  color: var(--deep);
}
.tile .plus {
  position: absolute; right: 12px; bottom: 12px;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--deep); color: #fff;
  font-weight: 800; font-size: 1.15rem; line-height: 1;
}
.tile .on-list {
  position: absolute; top: 10px; right: 10px;
  padding: .1rem .55rem;
  border-radius: 999px;
  background: var(--paper);
  color: var(--deep);
  font-size: .8rem; font-weight: 700;
}
@media (prefers-reduced-motion: reduce) { .tile { transition: none; } .tile:hover { transform: none; } }

/* ---------- the list: a notepad pinned to the fridge ---------- */
.pad {
  position: sticky; top: 20px;
  background: var(--paper);
  border-radius: 4px 4px 14px 14px;
  box-shadow: 0 1px 0 #cfdcd5, 0 24px 48px -30px rgba(30, 43, 74, .5);
  padding: 30px 20px 18px 54px;
  scroll-margin-top: 20px;
}
.pad::before { content: ""; position: absolute; top: 0; bottom: 0; left: 40px; width: 2px; background: var(--margin); opacity: .5; }
.pad::after {
  content: ""; position: absolute; top: -14px; left: 50%;
  width: 28px; height: 28px; margin-left: -14px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffe2a3 0 18%, var(--magnet) 45%);
  box-shadow: 0 3px 6px rgba(30, 43, 74, .25);
}
.pad h2 { margin: 0; font-size: 1.7rem; font-weight: 800; letter-spacing: -0.03em; }
.pad .count { color: var(--ink-soft); font-size: .95rem; }
.pad-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
.lines { list-style: none; margin: 10px 0 0; padding: 0; }
.line {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  grid-template-areas: "tick name remove" ". meta meta";
  column-gap: 10px;
  row-gap: 2px;
  align-items: center;
  padding: 10px 0 8px;
  border-bottom: 1px solid var(--rule);
}
.line form { margin: 0; }
.tick {
  grid-area: tick;
  width: 26px; height: 26px;
  border: 2px solid var(--ink); border-radius: 50%;
  background: var(--paper); cursor: pointer; padding: 0;
  display: grid; place-items: center; font-size: .9rem; font-weight: 800; color: var(--paper);
}
.line .tick-form { grid-area: tick; }
.line.bought .tick { background: #2FB36A; border-color: #2FB36A; }
.lname-wrap { grid-area: name; display: flex; align-items: center; gap: 8px; min-width: 0; }
.line .lemoji { font-size: 1.35rem; flex: none; }
.line .lname { min-width: 0; font: 1.5rem/1.15 "Patrick Hand", cursive; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line.bought .lname { text-decoration: line-through; text-decoration-color: var(--margin); text-decoration-thickness: 2px; color: var(--hint); }
.line .remove-form { grid-area: remove; }
.lmeta { grid-area: meta; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.qty { display: inline-flex; align-items: center; gap: 2px; }
.qty form { display: inline; }
.qty button, .remove {
  width: 28px; height: 28px; border: 0; border-radius: 50%;
  background: #EEF1F6; cursor: pointer; font-weight: 800; line-height: 1; padding: 0;
}
.qty button:hover, .remove:hover { background: #DDE3EE; }
.qty output { min-width: 1.8em; text-align: center; font-weight: 700; }
.lprice { font-weight: 700; font-size: .95rem; color: var(--ink-soft); }
.remove { color: var(--hint); }
.line.bought .lmeta { opacity: .45; }
.basket-title { margin: 18px 0 0; font-size: .95rem; color: var(--ink-soft); font-weight: 700; }
.empty { min-height: var(--line); padding: 10px 0; border-bottom: 1px solid var(--rule); display: flex; align-items: center; color: var(--hint); font: 1.3rem/1.2 "Patrick Hand", cursive; }
.totals { margin-top: 14px; padding-top: 12px; border-top: 2px dashed var(--rule); display: grid; gap: 2px; }
.totals .to-buy { display: flex; justify-content: space-between; font-weight: 800; font-size: 1.25rem; }
.totals .spent { display: flex; justify-content: space-between; color: var(--ink-soft); font-size: .9rem; }
.other { display: flex; gap: 8px; margin-top: 14px; }
.other input {
  flex: 1; min-width: 0; border: 0; border-bottom: 2px solid var(--ink); background: transparent;
  font: 1.3rem/1.3 "Patrick Hand", cursive; padding: .15rem 0;
}
.other input::placeholder { color: var(--hint); }
.other input:focus { outline: none; border-bottom-color: var(--margin); }
.other button, .btn {
  border: 0; border-radius: 999px; background: var(--ink); color: #fff;
  font-weight: 700; padding: .55rem 1.05rem; cursor: pointer;
}
.notice { margin: 10px 0 0; padding: .55rem .8rem; border-radius: 10px; font-size: .95rem; }
.notice.ok { background: #DDF4E4; color: #187A46; }
.notice.error { background: var(--error-bg); color: var(--error-ink); }
.notice:empty { display: none; }
.flash { animation: flash 1.4s ease-out; }
@keyframes flash { from { background: #FFF3C4; } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .flash { animation: none; } }
.foot { max-width: 1180px; margin: 0 auto; padding: 0 20px 28px; color: var(--ink-soft); font-size: .85rem; }

/* ---------- phone: one column + a bottom bar to jump to the list ---------- */
.jump { display: none; }
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .pad { position: relative; top: 0; margin-top: 18px; }
  .jump {
    display: flex; justify-content: space-between; align-items: center;
    position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 5;
    padding: .8rem 1.1rem; border-radius: 16px;
    background: var(--ink); color: #fff; text-decoration: none; font-weight: 700;
    box-shadow: 0 10px 24px -10px rgba(30, 43, 74, .7);
  }
  .shelf { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}
.toast {
  position: fixed; left: 50%; bottom: 88px; z-index: 6;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: .7rem 1.2rem; border-radius: 999px;
  background: var(--ink); color: #fff; font-weight: 600;
  box-shadow: 0 12px 28px -12px rgba(30, 43, 74, .7);
  animation: toast 3.2s ease forwards;
}
.toast.error { background: var(--error-ink); }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 10px); } 8%, 80% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }
@media (min-width: 861px) { .toast { bottom: 28px; } }
.toast {
  position: fixed; left: 50%; bottom: 88px; z-index: 6;
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  padding: .7rem 1.2rem; border-radius: 999px;
  background: var(--ink); color: #fff; font-weight: 600;
  box-shadow: 0 12px 28px -12px rgba(30, 43, 74, .7);
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.toast.show { opacity: 1; }
.toast.error { background: var(--error-ink); }
@media (min-width: 861px) { .toast { bottom: 28px; } }
.line button:disabled, .tile:disabled { opacity: .55; cursor: progress; }
