:root {
  --fondo: #ffffff;
  --card: #ffffff;
  --inchiostro: #151515;
  --grigio: #707070;
  --grigio-chiaro: #a9a9a9;
  --bordo: rgba(21, 21, 21, 0.09);
  --campo: #f4f3f0;
  --foto: #f1eee8;
  --accento: #2f6b52;
  --accento-tenue: #e8f1ec;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--fondo);
  color: var(--inchiostro);
  font-family: "Mona Sans Variable", "Mona Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.stage {
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  padding: 12px;
}

.card {
  position: relative;
  width: min(420px, 100%);
  min-width: 0;
  background: var(--card);
  border: 1px solid var(--bordo);
  border-radius: 20px;
  padding: clamp(12px, 3.4vmin, 18px);
  box-shadow: 0 1px 2px rgba(21, 21, 21, 0.04), 0 18px 46px -20px rgba(21, 21, 21, 0.2);
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 2.6vmin, 14px);
}

/* the head: the shop's mark, its name, how many pieces, and the Sort by pill on the right */
.head { position: relative; z-index: 3; display: flex; align-items: center; gap: 10px; }
.mark {
  flex: none;
  width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--accento-tenue); color: var(--accento);
}
.mark svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.head__text { display: flex; flex-direction: column; line-height: 1.15; flex: 1; min-width: 0; }
.head__name { font-size: 15px; font-weight: 640; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.head__sub { font-size: 12px; color: var(--grigio); white-space: nowrap; }

.sort { position: relative; flex: none; }

/* the pill: «Sort» in grey, the value in a window that rolls, the chevron that turns */
.pill {
  display: flex; align-items: center; gap: 6px;
  height: 36px;
  padding: 0 10px 0 13px;
  border: 1px solid var(--bordo);
  border-radius: 999px;
  background: #fff;
  color: var(--inchiostro);
  font: inherit;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(21, 21, 21, 0.05);
  transition: border-color 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.pill.is-hover, .pill[aria-expanded="true"] { border-color: rgba(21, 21, 21, 0.18); box-shadow: 0 1px 2px rgba(21, 21, 21, 0.06), 0 6px 16px -8px rgba(21, 21, 21, 0.25); }
@media (hover: hover) { .pill:hover { border-color: rgba(21, 21, 21, 0.18); } }
.pill:focus-visible { outline: 2px solid var(--accento); outline-offset: 2px; }
.pill__key { font-size: 12.5px; color: var(--grigio); font-weight: 500; }
.pill__win { position: relative; display: block; height: 18px; overflow: hidden; }
.pill__val { display: block; font-size: 13px; font-weight: 620; line-height: 18px; white-space: nowrap; font-variation-settings: "wdth" 100; }
.pill__chev { width: 16px; height: 16px; fill: none; stroke: var(--grigio); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* the menu: a white sheet under the pill, the highlight that slides under the option, the check on the chosen one */
.menu {
  position: absolute; right: 0; top: calc(100% + 8px);
  width: 212px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--bordo);
  border-radius: 16px;
  box-shadow: 0 2px 4px rgba(21, 21, 21, 0.04), 0 24px 48px -18px rgba(21, 21, 21, 0.32);
  transform-origin: 88% 0;
  visibility: hidden;
  opacity: 0;
  outline: none;
}
.menu__title { display: block; padding: 6px 10px 4px; font-size: 11px; font-weight: 560; color: var(--grigio-chiaro); letter-spacing: 0.02em; }
.menu__hl {
  position: absolute; left: 6px; right: 6px; top: 0;
  height: 36px;
  border-radius: 10px;
  background: var(--campo);
  opacity: 0;
  pointer-events: none;
}
.menu__list { position: relative; display: flex; flex-direction: column; }
.opt {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  height: 36px;
  padding: 0 10px;
  border: 0; border-radius: 10px;
  background: none;
  color: var(--inchiostro);
  font: inherit; font-size: 13px; font-weight: 520;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.opt:focus-visible { outline: 2px solid var(--accento); outline-offset: -2px; }
.opt[aria-selected="true"] { font-weight: 640; }
.opt__icon { display: flex; align-items: center; gap: 9px; }
.opt__glyph { width: 16px; height: 16px; fill: none; stroke: var(--grigio); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.opt[aria-selected="true"] .opt__glyph { stroke: var(--inchiostro); }
.opt__check { width: 16px; height: 16px; fill: none; stroke: var(--accento); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* the grid: six products, each a tile moved by Flip; the inner layer lifts on the way */
.grid { position: relative; z-index: 1; list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(8px, 2.2vmin, 12px); }
.tile { position: relative; min-width: 0; }
.tile__in { position: relative; border-radius: 14px; will-change: transform; }
.thumb {
  position: relative;
  aspect-ratio: 1 / 0.86;
  border-radius: 12px;
  background: var(--foto);
  overflow: hidden;
}
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14); pointer-events: none; }
.tag {
  position: absolute; left: 6px; top: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #fff;
  font-size: 10px; font-weight: 640; letter-spacing: 0.01em;
  color: var(--accento);
  box-shadow: 0 1px 2px rgba(21, 21, 21, 0.08);
}
.meta { padding: 7px 2px 0; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.meta__name { font-size: 12.5px; font-weight: 600; letter-spacing: -0.005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta__row { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.price, .rate { position: relative; font-size: 12px; color: var(--grigio); font-weight: 520; white-space: nowrap; }
.rate { display: flex; align-items: center; gap: 3px; }
.rate svg { width: 11px; height: 11px; fill: currentColor; }
.price.is-key, .rate.is-key { color: var(--inchiostro); font-weight: 640; }

.ghost {
  position: absolute; left: 0; top: 0;
  width: 22px; height: 22px;
  fill: var(--inchiostro); stroke: #fff; stroke-width: 1.4; stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.18));
  pointer-events: none;
  opacity: 0;
  z-index: 9;
}

@media (max-width: 380px) {
  .pill__key { display: none; }
  .menu { width: 196px; }
}
@media (max-height: 460px) {
  .head__sub { display: none; }
  .meta__name { font-size: 11.5px; }
}
