/* Shop page. Sits on the donate page's light ground (.donatepage) and borrows
   its centred title; what's here is the shelf, the product sheet and the bag. */

/* The shop is on plain white (the donate page's light tokens, its grey
   swapped out), so the grid, the product sheet and the bag follow */
.shoppage { --bg: #FFFFFF; background: #FFFFFF; }
html:has(.shoppage) { --ground: #FFFFFF; background: #FFFFFF; }
.item, .bag { box-shadow: inset 0 0 0 1px color-mix(in srgb, #130F0C 8%, transparent); }

/* the reveal footer tucks 140px up under main, which has no wash of its own,
   so the last row of the grid has to finish clear of that */
.shoppage .donate--c.section { padding-bottom: calc(140px + var(--s-14)); }
/* no last section to be the sheet, so main is: the page's white, its rounded
   foot lifting off the footer as on every other page */
.shoppage main { background: var(--bg); border-radius: 0 0 48px 48px; }
@media (min-width: 1024px) { .shoppage main { border-radius: 0 0 64px 64px; } }

/* ── bag disc in the bar ─────────────────────────────────────────────────── */

/* a second disc must not claim the menu disc's view-transition name, or the
   cross-page morph has two elements to pick from and skips */
.shopbag { position: relative; view-transition-name: none; margin-right: var(--s-2); }
.shopbag__mark { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
.shopbag__n {
  position: absolute; top: -2px; right: -2px;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--r-pill);
  background: var(--fg); color: var(--bg);
  font-size: 11px; line-height: 18px; text-align: center;
}

/* ── shelves ─────────────────────────────────────────────────────────────── */

.shop__shelves {
  display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s-2);
  margin-top: var(--s-12);
}
.shop__shelves button {
  min-height: 40px; padding: var(--s-2) var(--s-5);
  border: 1px solid var(--rule-strong); border-radius: var(--r-pill);
  background: transparent; color: var(--fg); font: inherit; cursor: pointer;
  transition: background-color .18s var(--ease), color .18s var(--ease), border-color .18s var(--ease);
}
.shop__shelves button:hover { border-color: var(--fg); }
.shop__shelves button[aria-selected="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }

/* ── grid ────────────────────────────────────────────────────────────────── */

.shop__grid {
  list-style: none; margin: var(--s-8) 0 0; padding: 0;
  display: grid; gap: var(--s-8) var(--s-4);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  text-align: left;
}
@media (min-width: 900px) { .shop__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-12) var(--s-6); } }
@media (min-width: 1280px) { .shop__grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.tile a { display: grid; gap: var(--s-1); }
.tile a:hover { opacity: 1; }
.tile__pic {
  position: relative; display: block; overflow: hidden;
  aspect-ratio: 2 / 3; margin-bottom: var(--s-3);
  border-radius: 24px; corner-shape: var(--r-md-shape);
  background: color-mix(in srgb, var(--fg) 6%, transparent);
}
.tile__pic img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain;
  transition: transform .6s var(--ease), opacity .4s var(--ease);
}
/* the second photo crossfades in on hover, where there is hover */
.tile__alt { opacity: 0; }
@media (hover: hover) {
  .tile a:hover .tile__pic img { transform: scale(1.03); }
  .tile a:hover .tile__alt { opacity: 1; }
}
.tile__name { font-size: 17px; line-height: 1.3; letter-spacing: -0.01em; }
.tile__price { color: var(--fg-60); }
.tile.is-out .tile__pic img { opacity: .55; }

/* ── dialogs (product sheet and bag) ─────────────────────────────────────── */

.item, .bag {
  padding: 0; border: 0; color: var(--fg); background: var(--bg);
  max-width: none; max-height: none;
}
.item::backdrop, .bag::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.item[open], .bag[open] { animation: shopIn .45s var(--ease); }
@keyframes shopIn { from { opacity: 0; transform: translateY(16px); } }
@media (prefers-reduced-motion: reduce) { .item[open], .bag[open] { animation: none; } }

.item__x {
  display: inline-grid; place-items: center; flex: none;
  width: 40px; height: 40px; padding: 0; border: 0; border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--fg) 8%, transparent); color: var(--fg); cursor: pointer;
}
.item__x svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.item__x:hover { background: color-mix(in srgb, var(--fg) 14%, transparent); }

/* Product: full-screen on a phone, a wide card on desktop with the gallery
   on the left and the buying column on the right. */
.item { width: 100vw; height: 100dvh; margin: 0; }
.item__in { position: relative; height: 100%; overflow-y: auto; overscroll-behavior: contain; }
.item__in > .item__x { position: absolute; top: var(--s-4); right: var(--s-4); z-index: 1; background: color-mix(in srgb, var(--bg) 80%, transparent); }
/* Gallery: one photo at a time, never cropped. The frame takes the shape of
   the product's first photo (--ratio, set by shop.js), so photos of that
   shape fill it edge to edge; one of another shape sits whole over a blurred
   wash of itself instead of on grey bars. */
.gal { display: flex; flex-direction: column; gap: var(--s-3); }
.gal__stage { position: relative; width: min(100%, calc(72dvh * var(--ratio, .8))); aspect-ratio: var(--ratio, .8); margin-inline: auto; overflow: hidden; background: color-mix(in srgb, var(--fg) 6%, transparent); }
.gal__track { display: flex; height: 100%; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain; }
.gal__track::-webkit-scrollbar { display: none; }
.gal__track:focus-visible { outline: 2px solid var(--accent-cool); outline-offset: -2px; }
.gal__slide { position: relative; flex: none; width: 100%; height: 100%; margin: 0; overflow: hidden; scroll-snap-align: start; scroll-snap-stop: always; }
.gal__slide::before { content: ""; position: absolute; inset: -40px; background: var(--wash) center / cover; filter: blur(28px) saturate(1.1); opacity: .55; }
.gal__slide img { position: relative; width: 100%; height: 100%; object-fit: contain; }
.gal__arrow {
  position: absolute; top: 50%; translate: 0 -50%;
  display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0;
  border: 0; border-radius: var(--r-pill); cursor: pointer; color: var(--fg);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 2px 12px rgba(19, 15, 12, .12);
  transition: opacity .2s var(--ease), transform .18s var(--ease);
}
.gal__arrow svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.gal__arrow:hover { transform: scale(1.06); }
.gal__arrow:active { transform: scale(.94); }
.gal__arrow:disabled { opacity: 0; pointer-events: none; }
.gal__arrow--prev { left: var(--s-3); }
.gal__arrow--next { right: var(--s-3); }
.gal__count {
  position: absolute; left: 50%; bottom: var(--s-3); translate: -50% 0;
  padding: 2px 10px; border-radius: var(--r-pill); font-size: 13px; font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, var(--bg) 82%, transparent); color: var(--fg);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.gal__thumbs { display: flex; gap: var(--s-2); overflow-x: auto; scrollbar-width: none; padding: 2px var(--pad); }
.gal__thumbs::-webkit-scrollbar { display: none; }
.gal__thumbs button {
  flex: none; width: 48px; height: 64px; padding: 0; border: 0; border-radius: 10px; overflow: hidden; cursor: pointer;
  background: color-mix(in srgb, var(--fg) 6%, transparent);
  opacity: .55; transition: opacity .18s var(--ease), box-shadow .18s var(--ease);
}
.gal__thumbs button:hover { opacity: .85; }
.gal__thumbs button[aria-current="true"] { opacity: 1; box-shadow: 0 0 0 2px var(--fg); }
.gal__thumbs img { width: 100%; height: 100%; object-fit: contain; }
.gal[data-single] .gal__arrow, .gal[data-single] .gal__count, .gal[data-single] .gal__thumbs { display: none; }
.item__body { padding: var(--s-6) var(--pad) var(--s-12); }
.item__title { margin: 0; font-weight: 400; font-size: clamp(28px, 3vw, 38px); line-height: 1.05; letter-spacing: -0.04em; text-wrap: balance; }
.item__price { margin-top: var(--s-2); font-size: 20px; color: var(--fg-60); }
.item__add { width: 100%; margin-top: var(--s-6); }
.item__add:disabled { opacity: .4; cursor: default; }
.item__text { margin-top: var(--s-8); color: var(--fg-60); line-height: 1.55; }
.item__text p + p { margin-top: var(--s-3); }

.opt { margin: var(--s-6) 0 0; padding: 0; border: 0; display: flex; flex-wrap: wrap; gap: var(--s-2); }
.opt legend { width: 100%; padding: 0; margin-bottom: var(--s-2); color: var(--fg-60); font-size: 14px; }
.opt button {
  min-width: 52px; min-height: 40px; padding: var(--s-2) var(--s-4);
  border: 1px solid var(--rule-strong); border-radius: var(--r-pill);
  background: transparent; color: var(--fg); font: inherit; cursor: pointer;
}
.opt button[aria-pressed="true"] { border-color: var(--fg); box-shadow: inset 0 0 0 1px var(--fg); }
.opt button.is-out { color: var(--fg-35); text-decoration: line-through; }

@media (min-width: 900px) {
  .item {
    width: min(1120px, calc(100vw - 2 * var(--pad))); height: min(760px, calc(100dvh - 2 * var(--s-12)));
    margin: auto; border-radius: var(--r-md); corner-shape: var(--r-md-shape); overflow: hidden;
  }
  .item__in { display: grid; overflow: hidden; }
  /* the photo column is exactly as wide as a full-height frame of that shape
     needs (dialog height less the thumbnail row), and the buying column
     takes the rest */
  .item { --gal-h: calc(min(760px, 100dvh - 2 * var(--s-12)) - 64px - var(--s-3) - var(--s-4) - 4px); }
  .item__in { grid-template-columns: auto minmax(340px, 1fr); }
  .gal { padding-bottom: var(--s-4); }
  .gal__stage { height: var(--gal-h); width: calc(var(--gal-h) * var(--ratio, .8)); max-width: 62vw; margin: 0; }
  .gal__thumbs { padding-inline: var(--s-4); max-width: calc(var(--gal-h) * var(--ratio, .8)); }
  .item__body { overflow-y: auto; padding: var(--s-14) var(--s-12) var(--s-12); }
}

/* Bag: a drawer from the right edge, full width on a phone. */
.bag { width: min(440px, 100vw); height: 100dvh; margin: 0 0 0 auto; }
.bag[open] { animation-name: bagIn; }
@keyframes bagIn { from { transform: translateX(40px); opacity: 0; } }
.bag__in { display: flex; flex-direction: column; height: 100%; padding: var(--s-4) var(--s-6) var(--s-6); }
.bag__head { display: flex; align-items: center; justify-content: space-between; padding-bottom: var(--s-4); border-bottom: 1px solid var(--rule); }
.bag__title { margin: 0; font-weight: 400; font-size: 28px; letter-spacing: -0.04em; }
.bag__lines { list-style: none; margin: 0; padding: 0; flex: 1; overflow-y: auto; }
.bag__lines[hidden] { display: none; }
/* Empty: the message sits in the upper middle of the drawer, not adrift in it,
   with two products under it so the drawer is never a dead end. */
.bag__empty {
  flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center;
  padding-top: clamp(var(--s-12), 14vh, 120px); overflow-y: auto;
}
.bag__empty[hidden] { display: none; }
.bag__emptymark {
  width: 64px; height: 64px; padding: 16px; box-sizing: border-box; border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--fg) 7%, transparent);
  fill: none; stroke: currentColor; stroke-width: 1.3; stroke-linejoin: round;
}
.bag__emptyh { margin-top: var(--s-5); font-size: 28px; line-height: 1.1; letter-spacing: -0.04em; }
.bag__emptyp { margin-top: var(--s-2); max-width: 26ch; color: var(--fg-60); line-height: 1.45; text-wrap: balance; }
.bag__browse { margin-top: var(--s-6); }
.bag__picklab { align-self: stretch; margin-top: auto; padding-top: var(--s-12); text-align: left; color: var(--fg-60); font-size: 14px; }
.bag__picks { align-self: stretch; list-style: none; margin: var(--s-3) 0 0; padding: 0; display: grid; gap: var(--s-2); text-align: left; }
.pick {
  display: grid; grid-template-columns: 56px 1fr auto; gap: var(--s-4); align-items: center;
  padding: var(--s-2); padding-right: var(--s-3); border-radius: 22px;
  background: color-mix(in srgb, var(--fg) 5%, transparent);
}
.pick img { width: 56px; height: 56px; object-fit: cover; border-radius: 14px; }
.pick div { display: grid; gap: 2px; min-width: 0; }
.pick b { font-weight: 400; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick small { color: var(--fg-60); font-size: 14px; }
.pick__add {
  min-height: 36px; padding: 0 var(--s-4); border: 0; border-radius: var(--r-pill);
  background: var(--fg); color: var(--bg); font: inherit; font-size: 14px; cursor: pointer;
  transition: opacity .18s var(--ease);
}
.pick__add:hover { background: color-mix(in srgb, var(--fg) 86%, var(--bg)); }
.line { display: grid; grid-template-columns: 72px 1fr auto; gap: var(--s-4); align-items: start; padding: var(--s-4) 0; border-bottom: 1px solid var(--rule); }
.line img { width: 72px; height: 88px; object-fit: cover; border-radius: 14px; }
.line__mid { display: grid; gap: 2px; }
.line__mid small { color: var(--fg-60); font-size: 14px; }
.line__price { font-variant-numeric: tabular-nums; }
.qty { display: inline-flex; align-items: center; gap: var(--s-1); margin-top: var(--s-2); justify-self: start;
  border: 1px solid var(--rule-strong); border-radius: var(--r-pill); }
.qty button { width: 36px; height: 34px; padding: 0; border: 0; background: transparent; color: var(--fg); font: inherit; font-size: 18px; cursor: pointer; border-radius: var(--r-pill); }
.qty button:hover { background: color-mix(in srgb, var(--fg) 8%, transparent); }
.qty output { min-width: 18px; text-align: center; font-variant-numeric: tabular-nums; }
.bag__foot { padding-top: var(--s-4); border-top: 1px solid var(--rule); }
.bag__sum { display: flex; justify-content: space-between; font-size: 18px; }
.bag__sum b { font-weight: 400; font-variant-numeric: tabular-nums; }
.bag__note { margin-top: var(--s-1); color: var(--fg-60); font-size: 14px; }
.bag__go { width: 100%; margin-top: var(--s-4); }
.bag__go:disabled { opacity: .5; }
