/* ------------------------------------------------------------------
   Home Food Register — visual system.

   What this replaces was a technical blueprint: steel blue on graph
   paper, square corners, hairline rules, desaturated photos. Precise,
   and completely wrong for food — it read as an ERP screen.

   What food apps actually do, and what this now does:
     · a warm off-white ground, never pure white and never near-black
     · leafy green as the resting colour, terracotta for the one thing
       you should press
     · freshness as a traffic light — green, amber, red — carried by a
       small pill or a stripe, never a whole card washed red
     · generous radii and soft shadows instead of borders
     · photographs in full colour, big enough to recognise across a
       kitchen
     · every category tinted, so a wall of pantry items still has shape
   ------------------------------------------------------------------ */

@font-face {
  font-family: 'Nunito';
  src: url('fonts/nunito.woff2') format('woff2-variations');
  font-weight: 300 900; font-style: normal; font-display: swap;
}
/* Israeli barcodes come back from Open Food Facts in Hebrew, so the
   stack has to carry Hebrew without falling back to something that
   clashes. Heebo sits beside Nunito without a visible seam. */
@font-face {
  font-family: 'Heebo';
  src: url('fonts/heebo-hebrew.woff2') format('woff2-variations');
  font-weight: 300 900; font-style: normal; font-display: swap;
  unicode-range: U+0590-05FF, U+FB1D-FB4F, U+200F, U+20AA;
}

:root {
  /* ground and ink */
  --bg:        #f7f3ec;   /* warm paper, the app's resting colour */
  --bg-sunk:   #efe9df;   /* wells and inset areas */
  --surface:   #ffffff;
  --ink:       #23201c;   /* warm near-black, never #000 */
  --ink-2:     #5f584f;   /* secondary text */
  --ink-3:     #8c8378;   /* metadata, hints */
  --line:      #e6ded1;   /* the only border colour, used sparingly */
  --line-2:    #d8cebd;

  /* the produce aisle */
  --green-50:  #eef5ee;
  --green-100: #d9e9db;
  --green-300: #8cbe95;
  --green:     #4a8759;   /* primary */
  --green-800: #2c5238;

  /* the warm one — used for the single most important action */
  --clay-50:   #fdf1ea;
  --clay-100:  #f8dcca;
  --clay:      #c4633a;
  --clay-700:  #a44f2b;

  /* freshness traffic light */
  --fresh:     #4a8759;
  --fresh-bg:  #e7f1e8;
  --soon:      #b5761b;
  --soon-bg:   #fbf0dc;
  --gone:      #bf4230;
  --gone-bg:   #fbe6e2;

  --sans: 'Nunito', 'Heebo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --r-lg: 20px;   /* cards, panels */
  --r:    14px;   /* controls */
  --r-sm: 10px;
  --pill: 999px;

  /* one soft shadow, two depths — no hard drop shadows anywhere */
  --lift:   0 1px 2px rgba(60,45,25,.05), 0 6px 18px rgba(60,45,25,.06);
  --lift-2: 0 2px 4px rgba(60,45,25,.06), 0 16px 34px rgba(60,45,25,.10);

  --tap: 52px;
  --tap-lg: 64px;   /* the kitchen tablet gets fat targets */
}

* { box-sizing: border-box; }
::selection { background: var(--green-100); }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: var(--sans); font-size: 16px; line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
  -webkit-font-smoothing: antialiased;
}
body { display: flex; flex-direction: column; }

h1, h2, h3 { font-weight: 800; letter-spacing: -.015em; margin: 0; line-height: 1.15; }
h2 { font-size: 26px; }
h3 { font-size: 19px; }
p  { margin: 0; }

/* A quiet label. It used to be uppercase steel blue everywhere, which
   made every screen shout; now it whispers. */
.kicker {
  font-size: 12.5px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--ink-3); margin: 0;
}
.kicker.accent { color: var(--green); }
.muted { color: var(--ink-3); }
.mono  { font-family: var(--mono); font-size: .92em; }

/* ---------------- chrome ---------------- */

header.app {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
header.app .mark {
  width: 40px; height: 40px; flex: none;
  border-radius: 12px; background: var(--green);
  display: grid; place-items: center; color: #fff;
}
header.app h1 { font-size: 19px; }
header.app .title { flex: 1; min-width: 0; }
header.app .title p { margin-top: 1px; }

footer.app {
  display: flex; gap: 12px; justify-content: space-between;
  padding: 10px 16px; border-top: 1px solid var(--line);
  background: var(--surface); color: var(--ink-3);
}

/* who is using it — pills, not filing-cabinet tabs */
nav.users {
  display: flex; gap: 8px; padding: 10px 16px; overflow-x: auto;
  background: var(--surface); border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
nav.users::-webkit-scrollbar { display: none; }
nav.users button {
  flex: none; min-height: 42px; padding: 0 16px;
  border-radius: var(--pill); border: 1.5px solid var(--line-2);
  background: var(--surface); color: var(--ink-2);
  font: inherit; font-weight: 700; font-size: 15px; cursor: pointer;
}
nav.users button[aria-pressed="true"] {
  background: var(--green); border-color: var(--green); color: #fff;
}

main { flex: 1; padding: 18px 16px 40px; }
.screen { display: flex; flex-direction: column; gap: 20px; max-width: 1180px; margin: 0 auto; }

/* ---------------- surfaces ---------------- */

/* `bp` was a blueprint panel with registration marks at the corners.
   Same hook, no drafting-table costume. */
.bp {
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--lift); position: relative;
}
.bp.accent { background: var(--green-50); box-shadow: none; border: 1px solid var(--green-100); }
.bp .corner { display: none; }   /* the + registration marks are gone */

.row  { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.col  { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }

/* ---------------- controls ---------------- */

.btn {
  min-height: var(--tap); padding: 0 18px;
  border-radius: var(--r); border: 1.5px solid var(--line-2);
  background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 700; font-size: 16px;
  cursor: pointer; display: inline-flex; align-items: center;
  justify-content: center; gap: 8px; text-decoration: none;
  transition: transform .08s ease, box-shadow .12s ease, background .12s ease;
}
.btn:hover { background: var(--bg-sunk); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.grow  { flex: 1; }

/* The one button that matters on a screen. Terracotta, because in a
   green room the warm thing is the thing you reach for. */
.btn.primary {
  background: var(--clay); border-color: var(--clay); color: #fff;
  box-shadow: 0 2px 0 var(--clay-700);
}
.btn.primary:hover { background: var(--clay-700); }
.btn.primary:active { box-shadow: none; transform: translateY(2px); }

.btn.ghost { border-color: transparent; background: transparent; color: var(--green); }
.btn.ghost:hover { background: var(--green-50); }
.btn.sel { background: var(--green); border-color: var(--green); color: #fff; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 700; color: var(--ink-2); }
input, select, textarea {
  min-height: var(--tap); padding: 0 14px; width: 100%;
  border-radius: var(--r); border: 1.5px solid var(--line-2);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 16px;
}
input:focus, select:focus, .btn:focus-visible, .tile:focus-visible, .card:focus-visible {
  outline: 3px solid var(--green-300); outline-offset: 2px; border-color: var(--green);
}
select { appearance: none; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235f584f' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px;
}

/* quantity stepper */
.qty { display: flex; align-items: center; gap: 14px; }
.qty button {
  width: var(--tap-lg); height: var(--tap-lg); border-radius: 50%;
  border: none; background: var(--green-50); color: var(--green-800);
  font-size: 30px; font-weight: 700; cursor: pointer; line-height: 1;
}
.qty button:hover { background: var(--green-100); }
.qty .n { font-size: 34px; font-weight: 800; min-width: 56px; text-align: center; }

/* ---------------- tiles (home, shelves, categories) ---------------- */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 12px; }

.tile {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  min-height: 116px; padding: 18px;
  border-radius: var(--r-lg); border: none;
  background: var(--surface); box-shadow: var(--lift);
  color: var(--ink); font: inherit; text-align: left; cursor: pointer;
  transition: transform .1s ease, box-shadow .15s ease;
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--lift-2); }
.tile:active { transform: translateY(0); }
.tile .num { display: none; }                    /* the 01–08 numbering is gone */
.tile .label { font-size: 19px; font-weight: 800; letter-spacing: -.01em; }
.tile .sub { font-size: 13.5px; color: var(--ink-3); line-height: 1.35; }
.tile svg {
  width: 28px; height: 28px; margin-bottom: 10px;
  stroke: var(--green); fill: none; stroke-width: 1.9;
}

/* The two things you do twenty times a day get to be bigger and
   coloured; the other six are supporting cast. */
/* the hero pushes its label to the floor, so the tile reads as a
   deliberate poster rather than a box with a gap in it */
.tile.hero { background: var(--green); color: #fff; min-height: 148px; justify-content: space-between; }
.tile.hero svg { margin-bottom: 0; }
.tile.hero .sub { color: #ffffffcc; }
.tile.hero svg { stroke: #fff; width: 36px; height: 36px; }
.tile.hero .label { font-size: 24px; }
@media (min-width: 700px) { .tile.hero { grid-column: span 2; } }

/* ---------------- pills and status ---------------- */

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: var(--pill);
  background: var(--bg-sunk); color: var(--ink-2);
  font-size: 12.5px; font-weight: 700; white-space: nowrap;
}
.tag.accent { background: var(--green-50); color: var(--green-800); }
.tag.warn   { background: var(--soon-bg);  color: var(--soon); }
.tag.fresh  { background: var(--fresh-bg); color: var(--fresh); }
.tag.gone   { background: var(--gone-bg);  color: var(--gone); }

/* freshness dot, for use inline next to a date */
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--fresh); }
.dot.soon { background: var(--soon); }
.dot.gone { background: var(--gone); }

.bar { height: 8px; border-radius: var(--pill); background: var(--bg-sunk); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: var(--pill); background: var(--green-300); }
.bar > span.urgent { background: var(--gone); }
.bar > span.soon { background: var(--soon); }

/* ---------------- product cards ---------------- */

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 14px; }

.card {
  display: flex; flex-direction: column; overflow: hidden;
  border-radius: var(--r-lg); border: none; background: var(--surface);
  box-shadow: var(--lift); cursor: pointer; padding: 0;
  color: var(--ink); font: inherit; text-align: left;
  transition: transform .1s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--lift-2); }

.card .thumb {
  position: relative; aspect-ratio: 4 / 3; width: 100%;
  background: var(--cat-tint, var(--bg-sunk));
  display: grid; place-items: center;
}
/* in full colour, which is the entire point of a photo of food */
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* No photo is the common case in a real pantry, so it has to look
   deliberate: the category's own tint, with its glyph. Never a grey
   box that says NO PHOTO. */
.card .thumb .glyph { font-size: 40px; line-height: 1; opacity: .9; }

/* stock count rides on the photo, so the text column stays for words */
.card .count {
  position: absolute; top: 8px; right: 8px;
  min-width: 30px; height: 30px; padding: 0 9px;
  border-radius: var(--pill); background: #ffffffee;
  box-shadow: 0 1px 3px rgba(0,0,0,.14);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800; color: var(--ink);
}
.card .count.out { background: var(--gone); color: #fff; }

/* the freshness stripe: colour where it is glanceable, not a red card */
.card .stripe { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; background: var(--fresh); }
.card .stripe.warn, .card .stripe.soon { background: var(--soon); }
.card .stripe.gone { background: var(--gone); }

.card .body { padding: 12px 13px 14px; display: flex; flex-direction: column; gap: 6px; }
.card .body strong { font-size: 15.5px; font-weight: 800; line-height: 1.25; letter-spacing: -.01em; }
.card .meta { font-size: 12.5px; color: var(--ink-3); }

/* list rows — find, history, shopping */
.rowcard {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; background: var(--surface);
  border-radius: var(--r); box-shadow: var(--lift);
}
.rowcard .avatar {
  width: 54px; height: 54px; flex: none; border-radius: var(--r-sm);
  background: var(--cat-tint, var(--bg-sunk)); overflow: hidden;
  display: grid; place-items: center; font-size: 27px;
}
.rowcard .avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ---------------- category chips ---------------- */

.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 9px;
  min-height: 46px; padding: 0 16px 0 10px;
  border-radius: var(--pill); border: 1.5px solid var(--line);
  background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 700; font-size: 15px; cursor: pointer;
}
.chip:hover { border-color: var(--line-2); background: var(--bg-sunk); }
.chip .glyph {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--cat-tint, var(--green-50));
  display: grid; place-items: center; font-size: 17px;
}
.chip .n { color: var(--ink-3); font-weight: 700; font-size: 13px; }

/* breadcrumb */
.crumbs { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; font-size: 14.5px; }
.crumbs button { border: none; background: none; font: inherit; font-weight: 700; color: var(--green); cursor: pointer; padding: 6px 6px; border-radius: var(--r-sm); }
.crumbs button:hover { background: var(--green-50); }
.crumbs .sep { color: var(--ink-3); }

/* ---------------- the scanner ---------------- */

.scanner {
  position: relative; overflow: hidden; border-radius: var(--r-lg);
  background: #17150f; aspect-ratio: 4 / 3; max-height: 46vh;
  box-shadow: var(--lift);
}
.scanner video { width: 100%; height: 100%; object-fit: cover; display: block; }

/* dimmed surround with a clear window and four corner brackets — the
   convention every scanning app uses, because it works */
.scanner .mask { position: absolute; inset: 0; box-shadow: inset 0 0 0 100vmax rgba(10,8,5,.45); }
.scanner .win {
  position: absolute; left: 12%; right: 12%; top: 20%; bottom: 20%;
  border-radius: 16px; box-shadow: 0 0 0 100vmax rgba(10,8,5,.45);
}
.scanner .bracket { position: absolute; width: 32px; height: 32px; border: 4px solid #fff; }
.scanner .bracket.tl { top: 20%; left: 12%; border-right: 0; border-bottom: 0; border-radius: 14px 0 0 0; }
.scanner .bracket.tr { top: 20%; right: 12%; border-left: 0; border-bottom: 0; border-radius: 0 14px 0 0; }
.scanner .bracket.bl { bottom: 20%; left: 12%; border-right: 0; border-top: 0; border-radius: 0 0 0 14px; }
.scanner .bracket.br { bottom: 20%; right: 12%; border-left: 0; border-top: 0; border-radius: 0 0 14px 0; }

.scanner .scanline {
  position: absolute; left: 12%; right: 12%; height: 3px; border-radius: 3px;
  background: linear-gradient(90deg, transparent, #8fe0a4, transparent);
  animation: sweep 2.4s ease-in-out infinite;
}
@keyframes sweep { 0%,100% { top: 23%; } 50% { top: 75%; } }

.scanner .caption {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 16px;
  background: linear-gradient(transparent, rgba(10,8,5,.8));
  color: #fff;
}
.scanner .caption .kicker { color: #ffffffd0; }

/* the reward beat on a good scan */
.scanner.hit .win { box-shadow: 0 0 0 100vmax rgba(10,8,5,.45), inset 0 0 0 4px var(--green-300); }

/* ---------------- stats ---------------- */

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .big { font-size: 34px; font-weight: 800; letter-spacing: -.02em; line-height: 1.05; }
.stat .big.green { color: var(--green); }
.stat .big.clay  { color: var(--clay); }

.statrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 16px; }

/* month bars in the consumption report */
.months { display: flex; align-items: flex-end; gap: 10px; height: 160px; }
.months .m { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; height: 100%; }
.months .m .col2 { border-radius: 8px 8px 0 0; background: var(--green-300); min-height: 3px; }
.months .m .col2.waste { background: var(--gone); opacity: .5; }
.months .m .lbl { font-size: 11.5px; color: var(--ink-3); text-align: center; font-weight: 700; }

/* ---------------- toast ---------------- */

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: var(--ink); color: #fff; padding: 14px 20px; border-radius: var(--pill);
  font-weight: 700; box-shadow: var(--lift-2);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60;
  max-width: min(90vw, 460px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: var(--gone); }

/* ---------------- the kitchen tablet ---------------- */

@media (min-width: 900px) {
  main { padding: 24px 24px 60px; }
  .cards { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; }
  h2 { font-size: 30px; }
  .btn { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------------- shopping list ---------------- */

/* A list you carry round a shop: big rows, one tap to tick, the quantity
   as the loudest thing on the right. Ticks live in this browser only —
   it is a trolley, not a document. */
.rowcard.shop {
  width: 100%; border: none; font: inherit; color: inherit;
  text-align: left; cursor: pointer; gap: 12px;
  transition: opacity .15s ease, background .15s ease;
}
.rowcard.shop .check {
  width: 30px; height: 30px; flex: none; border-radius: 50%;
  border: 2px solid var(--line-2); background: var(--surface);
  display: grid; place-items: center;
  color: #fff; font-size: 17px; font-weight: 800;
}
.rowcard.shop.ticked { opacity: .5; }
.rowcard.shop.ticked .check { background: var(--green); border-color: var(--green); }
.rowcard.shop.ticked strong { text-decoration: line-through; }

.rowcard .buy {
  min-width: 46px; height: 46px; padding: 0 12px; flex: none;
  border-radius: var(--r-sm); background: var(--green-50); color: var(--green-800);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800;
}
.rowcard .buy.out { background: var(--gone-bg); color: var(--gone); }

@media print {
  .noprint, header.app, footer.app, nav.users, .rowcard .check { display: none !important; }
  .rowcard { box-shadow: none; border-bottom: 1px solid var(--line); border-radius: 0; }
  body { background: #fff; }
}

/* ---------------- one product ---------------- */

.hero-item {
  display: flex; gap: 20px; align-items: center; flex-wrap: wrap;
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--lift); padding: 18px;
}
.hero-item .shot {
  width: 190px; height: 150px; flex: none; border-radius: var(--r);
  background: var(--cat-tint, var(--bg-sunk)); overflow: hidden;
  display: grid; place-items: center;
}
.hero-item .shot img { width: 100%; height: 100%; object-fit: cover; }
.hero-item .shot .glyph { font-size: 60px; }

table.hist { width: 100%; border-collapse: collapse; }
table.hist td { padding: 10px 10px; border-bottom: 1px solid var(--line); font-size: 14.5px; }
table.hist tr:last-child td { border-bottom: none; }
table.hist td.nowrap { white-space: nowrap; }
table.hist td.num { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }

.editor > summary {
  cursor: pointer; list-style: none; padding: 14px 16px;
  background: var(--surface); border-radius: var(--r);
  box-shadow: var(--lift); font-weight: 700; color: var(--ink-2);
}
.editor > summary::-webkit-details-marker { display: none; }
.editor > summary::after { content: ' \203a'; }
.editor[open] > summary { border-radius: var(--r) var(--r) 0 0; }
