/* Light only: the store is brightly lit, so the screen stays bright, crisp and high-contrast. */
:root {
  --bg: #ffffff; --soft: #f4f5f1; --ink: #121512; --muted: #565c54; --faint: #959b92; --line: #e4e6df;
  --accent: #0d7a50; --accent-ink: #fff; --accent-soft: #e5f3eb;
  --gold: #f2ab00; --gold-ink: #3d2a00; --gold-soft: #fff6d9;
  --frozen: #1d62a6; --frozen-soft: #e6f0fa; --warn: #a05600;
  --radius: 16px; --pad: 16px;
  --focus-color: var(--accent); --focus-gap: #fff;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 400 17px/1.45 Rubik, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent; overflow-x: hidden;
}
button, textarea { font: inherit; color: inherit; }
svg { display: block; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.app { max-width: 560px; margin: 0 auto; min-height: 100dvh; }
.view { min-height: 100dvh; display: flex; flex-direction: column; padding: 0 var(--pad); }
.view.enter { animation: view-in var(--dur-medium) var(--ease-out); }
@keyframes view-in { from { opacity: 0; transform: translateX(calc(var(--rise-sm) * var(--dir) * -1)); } }

.top { padding: calc(env(safe-area-inset-top) + 22px) 0 14px; }
.top h1 { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -.015em; line-height: 1.15; }
.store { margin: 3px 0 0; color: var(--muted); font-size: 14px; }
.draft { color: var(--warn); }
.loading { color: var(--muted); }

/* ---------- composer ---------- */
.composer { background: var(--soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 4px 10px;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out); }
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer textarea {
  display: block; width: 100%; min-height: 8.2em; max-height: 50vh; resize: none; border: 0; outline: none; background: transparent;
  padding: 12px 12px 4px; font-size: 18px; line-height: 1.6; color: var(--ink); field-sizing: content;
}
.composer textarea::placeholder { color: var(--faint); }
.has-list .composer textarea { min-height: 4.2em; }
.composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 8px 0 4px; }
.composer-hint { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.35; }

.primary {
  border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.primary.small { height: 44px; padding: 0 16px; font-size: 16px; flex: none; white-space: nowrap; }
.primary:disabled { background: var(--line); color: var(--faint); cursor: default; }
.primary .fwd { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.text-btn { border: 0; background: none; color: var(--accent); font-weight: 500; padding: 10px 0; min-height: 44px; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.text-btn.quiet { color: var(--muted); font-size: 14px; }

/* ---------- sorted list ---------- */
.sorted { padding: 22px 0 140px; }
.sorted-head { display: flex; align-items: baseline; justify-content: space-between; }
.sorted-head h2 { margin: 0; font-size: 15px; font-weight: 600; color: var(--muted); }
.areas, .area-items, .stops, .finds { list-style: none; margin: 0; padding: 0; }
.area { display: grid; grid-template-columns: 32px 1fr; column-gap: 12px; padding: 14px 0 8px; border-top: 1px solid var(--line); }
.area:first-child { border-top: 0; }
.area-num { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 14px; margin-top: 1px; }
.area.frozen .area-num { background: var(--frozen-soft); color: var(--frozen); }
.area.unknown .area-num { background: #fdf0de; color: var(--warn); }
.area-title { font-weight: 700; font-size: 18px; line-height: 1.3; }
.area-hint { color: var(--muted); font-size: 13px; }
.area-items { grid-column: 2; margin-top: 4px; }
.row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px; min-height: 48px; }
.row .name { display: block; font-size: 17px; font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; }
.row .prod, .row .guess { display: block; }
.row.done .name { color: var(--faint); text-decoration: line-through; }
.row > div { padding: 6px 0; }
.has-list .composer-hint { display: none; }
.has-list .composer-foot { justify-content: flex-end; }
.qty { display: inline-block; margin-inline-start: 6px; padding: 0 7px; border-radius: 6px; background: var(--soft); color: var(--muted); font-size: 13px; font-weight: 500; vertical-align: 1px; }
.prod { color: var(--muted); font-size: 13px; line-height: 1.3; }
.guess { color: var(--faint); font-size: 13px; }
.remove { width: 44px; height: 44px; border: 0; background: none; cursor: pointer; display: grid; place-items: center; color: var(--faint); border-radius: 50%; }
.remove svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
@media (hover: hover) { .remove:hover { color: var(--ink); background: var(--soft); } }

/* bottom bar */
.bar { position: fixed; inset-inline: 0; bottom: 0; z-index: 6; max-width: 560px; margin: 0 auto;
  padding: 14px var(--pad) calc(env(safe-area-inset-bottom) + 14px); background: linear-gradient(to top, #fff 72%, rgba(255,255,255,0)); }
.go { width: 100%; height: 60px; border-radius: 16px; font-size: 19px; justify-content: space-between; padding: 0 20px; box-shadow: 0 6px 18px rgba(13,122,80,.25); }
.go > span { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.go-sub { font-size: 13px; font-weight: 400; opacity: .85; }

/* ---------- hunt ---------- */
.hunt-top { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 6px; padding: calc(env(safe-area-inset-top) + 14px) 0 10px; }
.back { width: 44px; height: 44px; margin-inline-start: -10px; border: 0; background: none; border-radius: 50%; cursor: pointer; display: grid; place-items: center; }
.back svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.3; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .back:hover { background: var(--soft); } }
.hunt-title h1 { margin: 0; font-size: 24px; font-weight: 800; line-height: 1.1; }
.score { display: grid; grid-template-columns: auto auto; align-items: baseline; justify-content: end; column-gap: 1px; text-align: end; direction: ltr; }
.score b { font-size: 34px; font-weight: 800; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; display: inline-block; }
.score > span { font-size: 18px; font-weight: 600; color: var(--muted); }
.score small { grid-column: 1 / -1; font-size: 12px; color: var(--muted); direction: rtl; }
.score b.bump { animation: bump var(--dur-base) var(--ease-pop); }
@keyframes bump { 40% { transform: scale(1.25); } }
.progress { height: 6px; border-radius: 3px; background: var(--soft); overflow: hidden; margin-bottom: 14px; }
.progress span { display: block; height: 100%; background: var(--accent); transform-origin: right center; transform: scaleX(0);
  transition: transform var(--dur-slow) var(--ease-out); }

.route-body { display: flex; flex-direction: column; gap: 14px; padding-bottom: 48px; }

/* the current stop */
.now-card { border: 2px solid var(--gold); background: var(--gold-soft); border-radius: 18px; padding: 14px 14px 8px; }
.now-card.arrive { animation: arrive var(--dur-medium) var(--ease-out); }
@keyframes arrive { from { opacity: 0; transform: translateY(var(--rise)); } }
.now-label { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600; color: var(--gold-ink); margin-bottom: 2px; }
.now-title { font-size: 26px; font-weight: 800; line-height: 1.15; }
.now-hint { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.now-card.frozen { border-color: var(--frozen); background: var(--frozen-soft); }
.now-card.frozen .now-label { color: var(--frozen); }

.find {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 4px; border: 0; background: none;
  text-align: start; cursor: pointer; border-top: 1px solid rgba(0,0,0,.07); font-size: 18px; font-weight: 500;
}
.finds li:first-child .find { border-top: 0; }
.tick { width: 30px; height: 30px; border-radius: 50%; border: 2.5px solid var(--faint); flex: none; display: grid; place-items: center; background: #fff;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out); }
.tick svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transform: scale(.6);
  transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-base) var(--ease-pop); }
.find[aria-checked="true"] .tick { background: var(--accent); border-color: var(--accent); }
.find[aria-checked="true"] .tick svg { opacity: 1; transform: none; }
.find[aria-checked="true"] .find-text { color: var(--faint); text-decoration: line-through; }
.find:active .tick { transform: scale(var(--press)); }
.find-text { flex: 1; line-height: 1.25; overflow-wrap: anywhere; }
.find-text .prod, .find-text .guess { display: block; font-weight: 400; text-decoration: none; }

/* upcoming and done stops */
.next-title { margin: 6px 0 0; font-size: 15px; font-weight: 600; color: var(--muted); }
.stop { display: grid; grid-template-columns: 32px 1fr; column-gap: 12px; padding: 12px 0 4px; border-top: 1px solid var(--line); }
.stop .area-num { margin-top: 2px; }
.stop.frozen .area-num { background: var(--frozen-soft); color: var(--frozen); }
.stop .finds { grid-column: 2; }
.stop .find { font-size: 16px; min-height: 48px; }
.stop .tick { width: 26px; height: 26px; }
.stop.done { opacity: .7; }
.stop.done .area-num { background: var(--accent); color: #fff; }
.stop details summary { list-style: none; cursor: pointer; min-height: 32px; }
.stop details summary::-webkit-details-marker { display: none; }
.stop details summary .area-hint::after { content: " · להציג"; color: var(--accent); font-weight: 500; }
.stop details[open] summary .area-hint::after { content: " · להסתיר"; }

.finish { border: 2px solid var(--gold); background: var(--gold-soft); border-radius: 18px; padding: 18px 16px 8px; text-align: center; outline: none; }
.finish.arrive { animation: arrive var(--dur-medium) var(--ease-out); }
.finish-title { margin: 0; font-size: 30px; font-weight: 800; color: var(--gold-ink); }
.finish-stats { margin: 4px 0 0; font-size: 17px; font-weight: 600; }
.finish-sub { margin: 2px 0 0; color: var(--muted); }

/* map */
.map { margin: 0; }
#map { width: 100%; height: auto; border-radius: var(--radius); background: #fff; border: 1px solid var(--line); }
.draft-cap { color: var(--warn); font-size: 13px; margin-top: 6px; }
.m-dry { fill: #e7e8e1; } .m-fresh { fill: #cfe9d9; } .m-cold { fill: #d3e4f6; } .m-frozen { fill: #bcd3f0; }
.m-nonfood { fill: #e4e1ea; } .m-checkout { fill: #c9ccc4; }
/* interim fills until the Flow shelf graphics land */
.m-gondola { fill: #e7e8e1; } .m-produce { fill: #cfe9d9; } .m-fridge { fill: #d3e4f6; } .m-freezer { fill: #bcd3f0; }
.m-bread { fill: #f1dfbf; } .m-kiosk { fill: #d6ece6; }
.m-aisle { fill: #8a9087; font: 700 1.6px Rubik, sans-serif; paint-order: stroke; stroke: #fafaf7; stroke-width: .55px; stroke-linejoin: round; }
.m-pin { fill: var(--muted); font: 600 1.6px Rubik, sans-serif; }
.side { display: block; color: var(--muted); font-size: 13px; font-weight: 400; }
.find[aria-checked="true"] .side { text-decoration: none; }
.m-leg { fill: none; stroke-linejoin: round; stroke-linecap: round; }
.m-leg.done { stroke: #c9cdc4; stroke-width: .5; }
.m-leg.todo { stroke: var(--accent); stroke-width: .5; stroke-dasharray: .9 .9; opacity: .55; }
.m-leg.now { stroke: var(--accent); stroke-width: .95; stroke-dasharray: 2 1.2; animation: flow 1.2s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -3.2; } }
.m-stop circle { fill: #fff; stroke: var(--accent); stroke-width: .4; }
.m-stop text { fill: var(--accent); font: 700 1.5px Rubik, sans-serif; }
.m-stop.frozen circle { stroke: var(--frozen); } .m-stop.frozen text { fill: var(--frozen); }
.m-stop.done circle { fill: var(--accent); stroke: var(--accent); } .m-stop.done text { fill: #fff; }
.m-stop.now circle.dot { fill: var(--gold); stroke: var(--gold-ink); stroke-width: .3; }
.m-stop.now text { fill: var(--gold-ink); }
.m-ring { fill: none; stroke: var(--gold); stroke-width: .35; transform-box: fill-box; transform-origin: center; animation: ring 1.6s var(--ease-out) infinite; }
@keyframes ring { from { transform: scale(.7); opacity: .9; } to { transform: scale(1.8); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .m-leg.now, .m-ring { animation: none; } .m-ring { opacity: 0; } }

/* switch */
.switch { display: flex; align-items: center; gap: 10px; min-height: 48px; cursor: pointer; color: var(--muted); font-size: 15px; margin-top: 8px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.track { width: 42px; height: 26px; border-radius: 13px; background: #d9dcd4; position: relative; transition: background var(--dur-fast) var(--ease-out); flex: none; }
.knob { position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform var(--dur-fast) var(--ease-pop); }
.switch input:checked + .track { background: var(--frozen); }
.switch input:checked + .track .knob { transform: translateX(calc(16px * var(--dir))); }
.switch input:focus-visible + .track { box-shadow: var(--focus-ring); }

/* toast */
.toast {
  position: fixed; bottom: calc(env(safe-area-inset-bottom) + 96px); inset-inline: var(--pad); z-index: 20;
  max-width: 528px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--ink); color: #fff; border-radius: 12px; padding: 4px 6px; padding-inline-start: 16px; font-size: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18); animation: toast-in var(--dur-medium) var(--ease-out);
}
.toast.out { animation: toast-out calc(var(--dur-medium) * .65) var(--ease-in) forwards; pointer-events: none; }
.toast button { border: 0; background: none; color: #7fe0b2; font-weight: 600; min-height: 44px; padding: 0 12px; cursor: pointer; }
@keyframes toast-in { from { opacity: 0; transform: translateY(var(--rise)); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(var(--rise-sm)); } }
.view-route-on .toast { bottom: calc(env(safe-area-inset-bottom) + 20px); }

/* desktop: map beside the hunt */
@media (min-width: 900px) {
  .app.wide { max-width: 1120px; }
  .wide .route-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); grid-template-areas: "now map" "next map"; column-gap: 32px; align-items: start; }
  .wide .now-col { grid-area: now; } .wide .next-col { grid-area: next; }
  .wide .map { grid-area: map; position: sticky; top: 16px; }
}

/* ---------- map editor ---------- */
.edit-view { height: 100dvh; min-height: 0; overflow: hidden; }
body.editing .app { max-width: 1200px; }
.ed-top { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 4px; padding: calc(env(safe-area-inset-top) + 10px) 0 6px; }
.ed-title h1 { margin: 0; font-size: 22px; font-weight: 800; }
.icon-btn { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; display: grid; place-items: center; font-size: 20px; color: var(--ink); }
.icon-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:disabled { color: var(--faint); cursor: default; }
.ed-tabs { display: flex; gap: 6px; background: var(--soft); border-radius: 12px; padding: 4px; margin-bottom: 8px; }
.ed-tabs button { flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: none; font-weight: 600; cursor: pointer; color: var(--muted); }
.ed-tabs button[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.ed-stage { position: relative; flex: 1; min-height: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #f3f4ef; }
#ed-map { width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; }
.ed-zoom { position: absolute; inset-inline-start: 8px; top: 8px; display: flex; flex-direction: column; gap: 6px; }
.e-floor { fill: #fafaf7; stroke: #cfd2ca; stroke-width: .25; }
.e-shelf { stroke: #8a9087; stroke-width: .08; }
.e-shelf.live { cursor: grab; }
.e-shelf.on { stroke: var(--accent); stroke-width: .25; }
.e-handle { fill: #fff; stroke: var(--accent); cursor: grab; }
.e-spot circle { fill: #fff; stroke: var(--warn); stroke-width: .25; stroke-dasharray: .45 .3; }
.e-spot.ok circle { stroke: var(--accent); stroke-dasharray: none; }
.e-spot.frozen circle { fill: var(--frozen-soft); }
.e-spot.on circle { fill: var(--gold); stroke: var(--gold-ink); stroke-dasharray: none; }
.e-spot.live { cursor: grab; }
.e-spot.dim { opacity: .45; pointer-events: none; }
.e-spot-label { display: none; }
#ed-map.zoomed .e-spot-label, .e-spot.on .e-spot-label { display: inline; }
#ed-map .e-spot-label.culled { display: none; }
.e-spot-label { font: 600 1.05px Rubik, sans-serif; fill: var(--ink); paint-order: stroke; stroke: #fafaf7; stroke-width: .35px; pointer-events: none; }
.e-pin rect { fill: var(--ink); } .e-pin text { font: 600 1px Rubik, sans-serif; fill: var(--muted); paint-order: stroke; stroke: #fafaf7; stroke-width: .3px; }
.e-pin.live { cursor: grab; }
.ed-panel { max-height: 44dvh; overflow-y: auto; padding: 10px 2px 4px; }
.ed-hint { margin: 0 0 8px; color: var(--muted); font-size: 14px; }
.ed-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.ed-dim { color: var(--muted); font-size: 13px; }
.ed-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { min-height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 19px; background: #fff; font-size: 15px; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.chip[aria-checked="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.has { cursor: default; padding-inline-end: 2px; background: var(--accent-soft); border-color: transparent; }
.chip.has small { color: var(--muted); }
.chip .x { width: 34px; height: 34px; border: 0; background: none; border-radius: 50%; font-size: 20px; cursor: pointer; color: var(--muted); }
.ed-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px; }
.act { min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font-weight: 600; cursor: pointer; }
.act.danger { color: #b3261e; }
.act.primary-act { background: var(--accent); border-color: var(--accent); color: #fff; margin-inline-start: auto; }
.fld { display: block; margin-bottom: 8px; }
.fld span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.fld input { width: 100%; height: 44px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; font: inherit; font-size: 16px; }
.fld input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ed-toggles { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 6px; }
.tg { display: flex; align-items: center; gap: 8px; min-height: 40px; cursor: pointer; }
.tg input { width: 20px; height: 20px; accent-color: var(--accent); }
.ed-sub { font-size: 13px; color: var(--muted); margin: 4px 0; }
.ed-gres { list-style: none; margin: -4px 0 8px; padding: 0; }
.gres { width: 100%; text-align: start; min-height: 48px; border: 0; border-bottom: 1px solid var(--line); background: none; cursor: pointer; display: flex; flex-direction: column; justify-content: center; padding: 6px 4px; }
.gres small { color: var(--muted); }
@media (hover: hover) { .gres:hover { background: var(--accent-soft); } .chip:hover { border-color: var(--accent); } }
.ed-foot { display: flex; justify-content: space-between; padding-bottom: calc(env(safe-area-inset-bottom) + 4px); }
.inline-link { color: var(--accent); font-weight: 500; }
@media (min-width: 900px) {
  .edit-view { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); grid-template-rows: auto auto 1fr auto; column-gap: 20px; }
  .ed-top, .ed-tabs { grid-column: 1 / -1; }
  .ed-tabs { max-width: 360px; }
  .ed-stage { grid-column: 1; grid-row: 3 / 5; margin-bottom: 16px; }
  .ed-panel { grid-column: 2; grid-row: 3; max-height: none; }
  .ed-foot { grid-column: 2; grid-row: 4; }
}
