/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; background: var(--leaf); color: #fff;
  padding-top: env(safe-area-inset-top, 0px);
  animation: bar-shadow linear both; animation-timeline: scroll(); animation-range: 0 120px;
}
@keyframes bar-shadow { to { box-shadow: 0 8px 24px -10px rgb(0 0 0 / .45); } }
.topbar-inner {
  max-width: 1320px; margin: 0 auto; padding: 10px clamp(12px, 3vw, 28px);
  display: grid; grid-template-columns: auto 1fr auto; gap: clamp(10px, 2vw, 28px); align-items: center;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand-name { font-family: var(--f-display); font-weight: 800; font-size: 1.45rem; letter-spacing: -.02em; }
.search {
  position: relative; display: flex; align-items: center; max-width: 620px; width: 100%; justify-self: center;
  svg { position: absolute; left: 14px; width: 20px; color: var(--muted); pointer-events: none; }
  input {
    width: 100%; height: 46px; border: 0; border-radius: 999px; padding: 0 44px 0 44px; background: #fff; color: var(--ink);
    &:focus { outline: 3px solid var(--turmeric); outline-offset: 0; }
    &::-webkit-search-cancel-button { cursor: pointer; }
  }
  kbd { position: absolute; right: 14px; font: 600 .75rem var(--f-body); color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; }
  &:focus-within kbd { display: none; }
}
.top-actions { display: flex; align-items: center; gap: 6px; }
.top-link {
  display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; padding: 8px 12px; border-radius: 999px; font-weight: 600;
  svg { width: 22px; height: 22px; }
  &:hover { background: rgb(255 255 255 / .1); }
}
.basket-btn {
  position: relative; display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 16px 0 12px; border: 0; border-radius: 999px;
  background: var(--turmeric); color: var(--ink); font-weight: 700;
  svg { width: 24px; height: 24px; }
  &.bump { animation: bump .45s var(--ease-spring); }
}
.basket-count {
  position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px;
  background: var(--chili); color: #fff; font-size: .75rem; display: grid; place-items: center; border: 2px solid var(--leaf);
}
@keyframes bump { 40% { transform: scale(1.12); } }

@media (max-width: 760px) {
  .topbar-inner { grid-template-columns: auto auto; }
  .search { grid-column: 1 / -1; grid-row: 2; kbd { display: none; } }
  .top-link span, .brand-name { display: none; }
  .brand::after { content: "NexMart"; font: 800 1.3rem var(--f-display); }
}

/* ---------- Hero ---------- */
.hero { background: var(--leaf); color: #fff; overflow: clip; }
.hero-inner {
  max-width: 1320px; margin: 0 auto; padding: clamp(28px, 6vw, 72px) clamp(16px, 3vw, 28px) 0;
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: clamp(24px, 4vw, 56px); align-items: end;
}
.hero-copy { padding-bottom: clamp(28px, 5vw, 64px); }
.hero-kicker { display: flex; align-items: center; gap: 8px; margin: 0 0 18px; font-weight: 600; color: rgb(255 255 255 / .8); font-size: .95rem; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: #5DDB8E; box-shadow: 0 0 0 0 #5DDB8E; animation: pulse 2s infinite; }
.live-dot.closed { background: var(--chili); animation: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px rgb(93 219 142 / 0); } }
.hero-title {
  font-size: clamp(2.5rem, 6.2vw, 5.2rem); font-weight: 800; letter-spacing: -.035em; line-height: .98;
  font-variation-settings: "opsz" 96;
}
.hero-sub { max-width: 34em; font-size: clamp(1rem, 1.4vw, 1.15rem); color: rgb(255 255 255 / .82); margin: 20px 0 28px; }
.hero-sub strong { color: var(--turmeric); }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; }
.btn.on-dark { --fg: #fff; box-shadow: inset 0 0 0 1.5px rgb(255 255 255 / .35); &:hover { background: rgb(255 255 255 / .08); } }
.hero-check { min-height: 1.5em; margin: 16px 0 0; font-weight: 600; color: var(--turmeric); }
.hero-check.bad { color: #FFB4A1; }

/* The shelf: aisles as packs standing on two planks — the one orchestrated load moment */
.shelf {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 0 10px; align-items: end;
  padding: 0 4px; position: relative;
}
.shelf-plank { grid-column: 1 / -1; height: 14px; border-radius: 4px 4px 0 0; background: linear-gradient(#E0A817, #B98100); margin-bottom: 18px; box-shadow: 0 6px 0 rgb(0 0 0 / .18); }
.shelf-plank:last-child { margin-bottom: 0; border-radius: 4px 4px 0 0; }
.pack {
  --h: 150px; --c: #E8D9B0;
  height: var(--h); border: 0; border-radius: 12px 12px 4px 4px; background: var(--c); color: var(--ink);
  display: flex; flex-direction: column; justify-content: space-between; text-align: left; padding: 12px 10px 10px;
  position: relative; overflow: hidden; text-decoration: none;
  box-shadow: inset -10px 0 0 rgb(0 0 0 / .06), inset 0 10px 0 rgb(255 255 255 / .25);
  transform-origin: bottom center;
  animation: pack-up .7s var(--ease-spring) both; animation-delay: calc(var(--i) * 55ms + 150ms);
  transition: transform .25s var(--ease-spring);
  &:hover { transform: translateY(-8px) rotate(-1.5deg); }
  &:focus-visible { outline-color: #fff; }
  .pack-name { font: 800 clamp(.8rem, 1.1vw, .98rem)/1.05 var(--f-display); letter-spacing: -.01em; }
  .pack-count { font-size: .75rem; font-weight: 700; opacity: .7; }
  &::after { content: ""; position: absolute; inset: auto 10px 34px; height: 2px; background: rgb(0 0 0 / .12); border-radius: 2px; }
}
@keyframes pack-up { from { transform: translateY(110%) scaleY(.9); opacity: 0; } }
@media (max-width: 900px) {
  .hero-inner { grid-template-columns: 1fr; }
  .hero-copy { padding-bottom: 0; }
  .shelf { grid-template-columns: repeat(5, 1fr); }
  .pack { --h: 110px !important; }
}
@media (max-width: 520px) { .pack .pack-count { display: none; } .pack { padding: 8px 5px; .pack-name { font-size: .66rem; hyphens: auto; overflow-wrap: anywhere; } } .shelf { gap: 0 6px; } }

/* ---------- Aisle bar ---------- */
.aisle-bar {
  position: sticky; top: var(--topbar-h, 66px); z-index: 20; background: color-mix(in oklab, var(--wash) 88%, transparent);
  backdrop-filter: blur(12px) saturate(1.4); border-bottom: 1px solid var(--line);
}
.aisle-scroll, .group-scroll {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; max-width: 1320px; margin: 0 auto;
  padding: 12px clamp(12px, 3vw, 28px); scroll-snap-type: x proximity;
  &::-webkit-scrollbar { display: none; }
}
.group-scroll { padding-top: 0; }
.chip {
  flex: none; scroll-snap-align: start; border: 1.5px solid var(--line); background: var(--paper); border-radius: 999px;
  padding: 7px 14px; font-weight: 600; font-size: .92rem; display: inline-flex; align-items: center; gap: 8px;
  transition: background-color .2s, border-color .2s, color .2s;
  &:hover { border-color: var(--leaf-2); }
  &[aria-pressed="true"] { background: var(--leaf); border-color: var(--leaf); color: #fff; }
  .swatch { width: 12px; height: 12px; border-radius: 4px; background: var(--c); box-shadow: inset 0 0 0 1px rgb(0 0 0 / .1); }
  small { opacity: .6; font-weight: 600; }
}
.group-scroll .chip { font-size: .85rem; padding: 5px 12px; background: transparent; &[aria-pressed="true"] { background: var(--turmeric); color: var(--ink); border-color: var(--turmeric); } }

/* ---------- Product grid ---------- */
.shop { max-width: 1320px; margin: 0 auto; padding: 28px clamp(12px, 3vw, 28px) 40px; }
.shop-head { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 20px; }
.shop-head h2 { font-size: clamp(1.6rem, 3vw, 2.3rem); font-weight: 800; view-transition-name: result-title; }
.shop-head p { margin: 4px 0 0; }
.sort select { min-height: 42px; border-radius: 999px; padding-inline: 16px 36px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 190px), 1fr)); gap: clamp(10px, 1.5vw, 18px); }
@media (max-width: 520px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.card {
  container-type: inline-size;
  display: flex; flex-direction: column; background: var(--paper); border-radius: var(--r-l); overflow: hidden;
  box-shadow: var(--shadow-1); position: relative;
  &.out { .card-media { filter: grayscale(1); opacity: .6; } }
  &.appear { animation: card-in .45s var(--ease-out) both; animation-delay: calc(var(--i, 0) * 25ms); }
}
@keyframes card-in { from { opacity: 0; transform: translateY(12px); } }
.card-media {
  aspect-ratio: 1; display: grid; place-items: center; border: 0; padding: 0; background: #fff; cursor: zoom-in; position: relative;
  img { width: 100%; height: 100%; object-fit: contain; padding: 10%; transition: transform .4s var(--ease-out); }
  &:hover img { transform: scale(1.05); }
}
.tag { position: absolute; top: 10px; left: 10px; z-index: 1; font-size: .72rem; font-weight: 700; padding: 3px 8px; border-radius: 6px; background: var(--ink); color: #fff; }
.tag.feat { background: var(--turmeric); color: var(--ink); }

/* Generated pack label when there's no photo */
.label-art {
  --c: #E8D9B0;
  width: 100%; height: 100%; display: grid; grid-template-rows: auto 1fr auto; padding: 12% 11% 10%; text-align: left;
  background:
    radial-gradient(circle at 85% 12%, rgb(255 255 255 / .55) 0 18%, transparent 19%),
    repeating-linear-gradient(135deg, transparent 0 14px, rgb(255 255 255 / .12) 14px 15px),
    var(--c);
  color: var(--ink);
  .la-brand { font: 800 clamp(1rem, 13cqi, 1.9rem)/.95 var(--f-display); letter-spacing: -.03em; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .la-name { align-self: center; font-weight: 600; font-size: clamp(.72rem, 7.5cqi, .95rem); line-height: 1.2; opacity: .8; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  .la-pack { justify-self: end; background: var(--leaf); color: #fff; font-weight: 700; font-size: clamp(.68rem, 6.5cqi, .85rem); padding: 4px 10px; border-radius: 999px; }
}

.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card-brand { font-size: .78rem; font-weight: 700; color: var(--muted); }
.card-name {
  font-weight: 650; font-size: .95rem; line-height: 1.3; margin: 0; border: 0; background: none; padding: 0; text-align: left; cursor: pointer;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.6em;
  &:hover { color: var(--leaf-2); }
}
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 8px; }
.price { font: 800 1.12rem/1.1 var(--f-display); letter-spacing: -.01em; white-space: nowrap; display: grid; }
.price small { font: 600 .72rem/1.2 var(--f-body); color: var(--muted); }

.add {
  height: 38px; min-width: 38px; border: 0; border-radius: 999px; background: var(--leaf); color: #fff; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 14px;
  transition: transform .15s, background-color .2s;
  &:hover { background: var(--leaf-2); }
  &:active { transform: scale(.94); }
  svg { width: 18px; height: 18px; }
}
@container (max-width: 200px) { .add .add-label { display: none; } .add { padding: 0; width: 38px; } .price { font-size: 1rem; } }

.stepper {
  display: inline-flex; align-items: center; height: 38px; border-radius: 999px; background: var(--turmeric); overflow: hidden;
  animation: pop .3s var(--ease-spring);
  button { width: 34px; height: 100%; border: 0; background: transparent; font-size: 1.2rem; font-weight: 700; &:hover { background: rgb(0 0 0 / .08); } }
  output { min-width: 30px; text-align: center; font-weight: 800; font-size: .92rem; }
}
@keyframes pop { from { transform: scale(.7); } }

.skeleton { border-radius: var(--r-l); background: linear-gradient(90deg, #E6EBE3 25%, #F3F6F1 50%, #E6EBE3 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; aspect-ratio: .72; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { grid-column: 1 / -1; text-align: center; padding: 60px 20px; h3 { font-size: 1.5rem; margin-bottom: 8px; } }
.grid-foot { display: grid; place-items: center; padding: 28px 0 0; }
#sentinel { height: 1px; width: 100%; }

/* Fly-to-basket dot */
.fly { position: fixed; z-index: 90; width: 22px; height: 22px; border-radius: 50%; background: var(--turmeric); box-shadow: 0 0 0 4px rgb(244 180 26 / .35); pointer-events: none; }

/* ---------- How it works ---------- */
.how { max-width: 1320px; margin: 0 auto; padding: 24px clamp(12px, 3vw, 28px) 64px; }
.how h2 { font-size: clamp(1.5rem, 2.6vw, 2rem); margin-bottom: 20px; }
.how-steps { list-style: none; counter-reset: s; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.how-steps li {
  counter-increment: s; background: var(--paper); border-radius: var(--r-l); padding: 22px; display: grid; gap: 6px; position: relative;
  &::before { content: counter(s); font: 800 2.4rem/1 var(--f-display); color: var(--turmeric); }
  span { color: var(--muted); font-size: .95rem; }
}

.footer {
  background: var(--ink); color: #fff; padding: 36px clamp(16px, 3vw, 28px) calc(36px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 20px;
  strong { font: 800 1.4rem var(--f-display); }
  .muted { color: rgb(255 255 255 / .6); margin: 4px 0 0; }
}
.footer-links { display: flex; flex-wrap: wrap; gap: 20px; align-items: center; a { color: #fff; font-weight: 600; } }

/* ---------- Product dialog ---------- */
.product-dialog {
  width: min(880px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); border-radius: var(--r-l); overflow: auto;
  transform: translateY(24px) scale(.97);
  &[open] { transform: none; }
  .close { position: absolute; top: 10px; right: 10px; z-index: 2; background: #fff; box-shadow: var(--shadow-1); }
}
@starting-style { .product-dialog[open] { transform: translateY(24px) scale(.97); } }
.pd-main { display: grid; grid-template-columns: 1fr 1fr; }
.pd-media { aspect-ratio: 1; background: #fff; display: grid; place-items: center; border-right: 1px solid var(--line); img { width: 100%; height: 100%; object-fit: contain; padding: 8%; } }
.pd-media .label-art { container-type: inline-size; }
.pd-info { padding: 32px 28px; display: flex; flex-direction: column; gap: 12px; }
.pd-info h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); font-weight: 800; }
.pd-meta { display: flex; flex-wrap: wrap; gap: 8px; }
.pd-price { font: 800 2rem var(--f-display); display: block; small { font: 600 .9rem var(--f-body); color: var(--muted); } }
.pd-actions { display: flex; gap: 12px; align-items: center; margin-top: 8px; .stepper, .add { height: 48px; } .add { padding: 0 24px; font-size: 1rem; } }
.pd-related { padding: 20px 28px 28px; border-top: 1px solid var(--line); h3 { font-size: 1.1rem; margin-bottom: 12px; } }
.mini-row { display: grid; grid-auto-flow: column; grid-auto-columns: 150px; gap: 10px; overflow-x: auto; padding-bottom: 6px; }
@media (max-width: 700px) { .pd-main { grid-template-columns: 1fr; } .pd-media { border-right: 0; border-bottom: 1px solid var(--line); aspect-ratio: 4/3; } .pd-info { padding: 22px 20px; } }

/* ---------- Drawer (basket) ---------- */
.drawer, .checkout { margin: 0; max-height: 100dvh; height: 100dvh; max-width: 100vw; }
.drawer {
  width: min(440px, 100vw); margin-left: auto; display: none; flex-direction: column;
  transform: translateX(100%);
  &[open] { display: flex; transform: none; }
}
@starting-style { .drawer[open] { transform: translateX(100%); } }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: calc(16px + env(safe-area-inset-top, 0px)) 20px 16px; border-bottom: 1px solid var(--line); h2 { font-size: 1.5rem; } }
.drawer-body { flex: 1; overflow-y: auto; padding: 8px 20px; }
.drawer-foot { border-top: 1px solid var(--line); padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 12px; background: var(--paper); }
.line .thumb .la-brand { overflow-wrap: normal !important; word-break: normal; font-size: .62rem !important; }
.line {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px dashed var(--line);
  &.leaving { animation: line-out .25s forwards; }
  .thumb { width: 64px; height: 64px; border-radius: 12px; overflow: hidden; background: #fff; box-shadow: inset 0 0 0 1px var(--line); container-type: inline-size; img { width: 100%; height: 100%; object-fit: contain; padding: 6px; } .label-art { padding: 8px; .la-name, .la-pack { display: none; } .la-brand { font-size: .8rem; } } }
  .l-name { font-weight: 600; font-size: .92rem; line-height: 1.25; }
  .l-sub { font-size: .8rem; color: var(--muted); }
  .l-right { display: grid; justify-items: end; gap: 6px; }
  .stepper { height: 32px; button { width: 30px; } }
}
@keyframes line-out { to { opacity: 0; transform: translateX(30px); } }
.progress { display: grid; gap: 6px; font-size: .88rem; font-weight: 600; }
.bar { height: 8px; border-radius: 4px; background: var(--wash); overflow: hidden; }
.bar i { display: block; height: 100%; width: var(--p, 0%); background: var(--turmeric); border-radius: 4px; transition: width .5s var(--ease-out); }
.bar.ok i { background: var(--ok); }
.totals { display: grid; gap: 4px; font-size: .95rem; div { display: flex; justify-content: space-between; } .grand { font: 800 1.25rem var(--f-display); padding-top: 6px; border-top: 1px solid var(--line); margin-top: 4px; } }
.basket-empty { text-align: center; padding: 60px 10px; display: grid; gap: 10px; justify-items: center; svg { width: 88px; color: var(--line); } }

/* ---------- Checkout ---------- */
.checkout { width: 100vw; display: none; flex-direction: column; transform: translateY(30px);
  &[open] { display: flex; transform: none; } }
@starting-style { .checkout[open] { transform: translateY(30px); } }
.co-grid { flex: 1; display: grid; grid-template-columns: 1.2fr 1fr; min-height: 0; }
.co-map-wrap { position: relative; min-height: 320px; }
.co-map { position: absolute; inset: 0; background: #E4E9E1; }
.map-tools { position: absolute; left: 16px; right: 16px; bottom: 16px; z-index: 500; display: grid; justify-items: start; gap: 8px; }
.map-hint { margin: 0; background: #fff; padding: 8px 14px; border-radius: 12px; box-shadow: var(--shadow-1); font-size: .9rem; font-weight: 550; max-width: 100%; }
.map-hint.ok { background: var(--leaf); color: #fff; }
.map-hint.bad { background: var(--chili); color: #fff; }
.co-form { overflow-y: auto; padding: 24px clamp(18px, 3vw, 36px) calc(28px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 16px; align-content: start; background: var(--paper); h3 { font-size: 1.4rem; } }
.pay { border: 0; padding: 0; margin: 0; display: flex; gap: 10px; flex-wrap: wrap;
  legend { font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
  label { flex: 1; min-width: 150px; display: flex; gap: 10px; align-items: center; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: var(--r-m); cursor: pointer; font-weight: 600;
    &:has(input:checked) { border-color: var(--leaf); background: color-mix(in oklab, var(--leaf) 6%, #fff); }
    input { accent-color: var(--leaf); width: 18px; height: 18px; } } }
.summary { background: var(--wash); border-radius: var(--r-m); padding: 16px; }
.place { min-height: 54px; font-size: 1.05rem; }
.form-error { color: var(--chili); font-weight: 600; margin: 0; min-height: 1.2em; }
@media (max-width: 860px) {
  .co-grid { grid-template-columns: 1fr; grid-template-rows: 46vh auto; overflow-y: auto; }
  .co-form { overflow: visible; }
}

/* Leaflet pins */
.pin { width: 38px; height: 38px; }
.pin-me { background: var(--turmeric); border: 3px solid #fff; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); box-shadow: 0 4px 12px rgb(0 0 0 / .35); width: 34px; height: 34px; }
.pin-shop { display: grid; place-items: center; background: var(--leaf); border: 3px solid #fff; border-radius: 10px; box-shadow: 0 4px 12px rgb(0 0 0 / .35); color: #fff; font: 800 12px var(--f-display); width: 38px; height: 38px; }
.leaflet-container { font-family: var(--f-body); }

/* View transitions between aisle filters */
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .25s; }
