/**
 * THE APP MACHINE — cabinet, glass, controls.
 *
 * Structural rule that drives this whole file: the glass pane is a SIBLING of
 * the 3D cabinet, never a child. `backdrop-filter` is silently flattened inside
 * a `preserve-3d` subtree in both Chromium and WebKit, so the pane is absolutely
 * positioned over the cabinet instead of living in it.
 */

* {
  box-sizing: border-box;
}

html {
  background: var(--room-bg);
  scroll-behavior: auto;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--room-bg);
  color: #e8e9ea;
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  /* `clip` not `hidden`: overflow-x:hidden makes body a scroll container and
     silently breaks position:sticky on the machine viewport. */
  overflow-x: clip;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ====================================================================== */
/* ROOM                                                                    */
/* ====================================================================== */

.room {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(80% 55% at 50% 8%, rgba(150, 170, 190, 0.09), transparent 70%),
    radial-gradient(60% 40% at 50% 100%, rgba(120, 140, 165, 0.06), transparent 72%),
    linear-gradient(180deg, var(--room-wall) 0%, var(--room-bg) 62%, var(--room-floor) 100%);
}

.room::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.5;
  mix-blend-mode: overlay;
  background-image: var(--grain-fine);
  background-size: 180px 180px;
}

/* ====================================================================== */
/* SCROLL SCAFFOLD                                                         */
/* The page is the scroller (native momentum). The machine sticks; the      */
/* shelf column translates inside the window, so the cabinet reads as       */
/* impossibly deep rather than as stacked page sections.                    */
/* ====================================================================== */

.stage {
  position: relative;
  z-index: 1;
  /* --travel is written by scroll.js from the real shelf overflow */
  height: calc(100dvh + var(--travel, 0px));
}

.viewport {
  position: sticky;
  top: 0;
  display: grid;
  place-items: center;
  height: 100dvh;
  padding: clamp(10px, 2vh, 26px);
}

/* ====================================================================== */
/* MACHINE SHELL                                                           */
/* ====================================================================== */

.machine {
  --machine-h: min(calc(100dvh - clamp(20px, 4vh, 52px)), 1040px);
  --machine-w: min(calc(var(--machine-h) / 1.5), 94vw);

  position: relative;
  display: grid;
  grid-template-rows: var(--marque-h) 1fr var(--base-h);
  width: var(--machine-w);
  height: var(--machine-h);
  border-radius: var(--radius-body);
  perspective: 1400px;
  perspective-origin: 50% 42%;
  /* near-black matte powder-coat: almost no specular, so the lit cabinet
     carries every bit of contrast in the frame */
  background:
    linear-gradient(
      180deg,
      var(--metal-mid) 0%,
      var(--metal-body) 9%,
      var(--metal-dark) 62%,
      #0c0e10 100%
    ),
    var(--metal-body);
  box-shadow:
    inset 0 1px 0 var(--metal-edge-hi),
    inset 0 -1px 0 var(--metal-edge-lo),
    inset 1px 0 0 rgba(255, 255, 255, 0.045),
    inset -1px 0 0 rgba(0, 0, 0, 0.5),
    0 50px 110px -24px rgba(0, 0, 0, 0.95),
    0 8px 24px rgba(0, 0, 0, 0.7);
}

/* Light pooling on the floor in front of the machine, plus a soft reflection
   of the lit cabinet in the polished concrete. */
.machine__pool {
  position: absolute;
  bottom: -8%;
  left: -12%;
  width: 124%;
  height: 16%;
  z-index: -1;
  pointer-events: none;
  background: radial-gradient(
    ellipse 50% 100% at 50% 0%,
    rgba(200, 224, 245, 0.16),
    rgba(160, 190, 220, 0.05) 42%,
    transparent 72%
  );
  filter: blur(10px);
}

/* Body grain + the floor contact shadow that anchors it in the room. */
.machine::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0.14;
  mix-blend-mode: overlay;
  background-image: var(--grain-fine);
  background-size: 120px 120px;
  pointer-events: none;
}

.machine::after {
  content: "";
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: -26px;
  height: 30px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.75), transparent 72%);
  filter: blur(9px);
  pointer-events: none;
}

/* ====================================================================== */
/* MARQUE — backlit translucent header panel                              */
/* ====================================================================== */

/* A separate raised sign box mounted on the machine, inset from the body
   sides, with its own bezel and a step down to the door below. */
.marque {
  position: relative;
  display: grid;
  place-items: center;
  margin: 2.4% 4.5% 1.6%;
  border-radius: 3px;
  overflow: hidden;
  background: linear-gradient(180deg, #131517, #0b0d0e);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.09),
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 3px 10px -2px rgba(0, 0, 0, 0.9),
    0 0 34px -6px rgba(220, 236, 255, 0.16);
}

.marque__plate {
  display: grid;
  justify-items: center;
  gap: 0.28em;
  padding: 0 6%;
  text-align: center;
}

/* Blown-out illuminated lettering: the brightest thing on the machine's face. */
.marque__title {
  margin: 0;
  font-family: var(--font-marque);
  font-size: clamp(0.85rem, calc(var(--machine-w) * 0.076), 3.1rem);
  font-weight: 900;
  letter-spacing: -0.01em;
  line-height: 0.95;
  white-space: nowrap;
  color: #fff;
  text-shadow:
    0 0 6px rgba(255, 255, 255, 0.9),
    0 0 20px rgba(214, 236, 255, 0.7),
    0 0 46px rgba(190, 220, 255, 0.4);
}

/* The maker mark: a serial inscription, never a subtitle. */
.marque__maker {
  font-family: var(--font-mono);
  font-size: clamp(0.4rem, calc(var(--machine-w) * 0.0132), 0.6rem);
  font-weight: 400;
  letter-spacing: 0.34em;
  text-indent: 0.34em;
  color: rgba(233, 228, 218, 0.44);
  text-transform: uppercase;
}

/* Header light bar visible through the diffuser at the very top edge. */
.marque::after {
  content: "";
  position: absolute;
  top: 0;
  left: 8%;
  right: 8%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 250, 235, 0.5), transparent);
  filter: blur(1px);
}

/* ====================================================================== */
/* BODY — window + control column                                          */
/* ====================================================================== */

.body {
  position: relative;
  display: grid;
  grid-template-columns: 1fr var(--control-w);
  gap: 1.1%;
  min-height: 0;
  padding: 1.2% var(--bezel-side);
}

/* ---------------------------------------------------------------------- */
/* WINDOW — the glass-front opening                                        */
/* ---------------------------------------------------------------------- */

.window {
  position: relative;
  min-height: 0;
  border-radius: var(--radius-inner);
  /* the door extrusion wraps the glass, which sits inset behind the face */
  box-shadow:
    inset 0 0 0 2px #16181a,
    inset 0 0 0 3px rgba(255, 255, 255, 0.07),
    0 0 0 1px rgba(0, 0, 0, 0.6);
}

/* Full-height door handle on the latch side. Where hands land, brushed metal
   goes shinier rather than duller. */
.handle {
  position: absolute;
  top: 12%;
  right: -1.1%;
  bottom: 12%;
  z-index: 8;
  width: 6px;
  border-radius: 3px;
  pointer-events: none;
  background: linear-gradient(90deg, #3b4146 0%, #9aa3aa 34%, #cdd4d9 50%, #767e85 70%, #2a2f33 100%);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.6),
    0 2px 8px rgba(0, 0, 0, 0.8);
}

/* Rubber door gasket around the full perimeter. */
.window::before {
  content: "";
  position: absolute;
  inset: -4px;
  z-index: 6;
  border-radius: 9px;
  pointer-events: none;
  border: 4px solid #101214;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.8);
}

/* --- Cabinet: the only preserve-3d subtree ---------------------------- */

.cabinet {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: var(--radius-inner);
  transform-style: preserve-3d;
  background:
    linear-gradient(180deg, var(--cabinet-back-lit), var(--cabinet-back) 55%, #141619);
}

/* Back wall: faint horizontal ribbing, lit to ~35% of the front plane. */
.cabinet__back {
  position: absolute;
  inset: -6%;
  transform: translateZ(-40px);
  background:
    repeating-linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.014) 0 1px,
      transparent 1px 9px
    ),
    radial-gradient(90% 60% at 50% 30%, rgba(var(--led-warm), 0.11), transparent 72%),
    var(--cabinet-back);
}

/* Vertical LED pillars mounted inside the door frame, facing inward —
   this is what produces the side rim-light on every product. */
/* The dominant feature of the whole design: two blown-out vertical LED
   pillars running the full cabinet height, mounted just inside the door. */
.cabinet__lamp {
  position: absolute;
  top: 1.5%;
  bottom: 1.5%;
  width: 9px;
  z-index: 6;
  border-radius: 3px;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(var(--led-cool), 0.5) 0%,
    #fff 3%,
    #fff 97%,
    rgba(var(--led-cool), 0.5) 100%
  );
  box-shadow:
    0 0 6px 1px #fff,
    0 0 18px 5px rgba(var(--led-cool), 0.9),
    0 0 44px 14px rgba(var(--led-cool), 0.5),
    0 0 90px 30px rgba(var(--led-cool), 0.22);
}

.cabinet__lamp--left {
  left: 6px;
}

.cabinet__lamp--right {
  right: 6px;
}

/* Spill from the two pillars + vignette toward the cabinet floor. */
.cabinet__spill {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  mix-blend-mode: screen;
  background:
    linear-gradient(90deg, rgba(var(--led-cool), 0.16), transparent 18%),
    linear-gradient(270deg, rgba(var(--led-cool), 0.16), transparent 18%);
}

/* Vignette toward the cabinet floor, kept separate from the lamp spill so it
   darkens without also greying the lit areas. */
.cabinet__spill::after {
  content: "";
  position: absolute;
  inset: 0;
  mix-blend-mode: multiply;
  background: radial-gradient(120% 80% at 50% 12%, transparent 42%, rgba(0, 0, 0, 0.55) 100%);
}

/* Dust in the bottom interior corners — 1-2px warm line, barely there. */
.cabinet__dust {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 2px;
  z-index: 4;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(190, 175, 150, 0.16), transparent 18%, transparent 82%, rgba(190, 175, 150, 0.16));
}

/* ====================================================================== */
/* SHELVES                                                                 */
/* ====================================================================== */

.shelves {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 2;
  /* clear of the door-pillar LEDs so the lit strips read uninterrupted */
  padding: 12px 22px 0;
  transform: translate3d(0, calc(var(--shelf-offset, 0px) * -1), 0);
  will-change: transform;
}

.shelf {
  position: relative;
  margin-bottom: 14px;
  content-visibility: auto;
  contain-intrinsic-size: auto 150px;
}

/* Products stand on the tray, set back from the front edge. */
/* --deckh is the shelf's usable interior height. Every package is sized as a
   fraction of it, so a row reads as stocked goods of varying real heights
   rather than eleven components each choosing their own scale. */
.shelf__deck {
  /* Raised from the original 74-116px band: at typical viewport heights the
     old floor left short archetypes (tin/module/cassette) with ~0px of
     panel after the label reserved its space — the art window was
     collapsing invisibly. Bigger stock, and it's the fix, not just polish. */
  --deckh: clamp(108px, 16vh, 168px);
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr));
  align-items: end;
  gap: 2px;
  /* rows size to their tallest package: real headroom is 15-25% of product
     height, so a fixed deck height just manufactures dead space */
  min-height: calc(var(--deckh) * 0.5);
  padding: 0 4px 3px;
}

/* Folded-down front lip, hit hardest by the under-shelf LED. This bright
   horizontal band is the strongest line in the whole interior. */
/* Under-shelf LED washes the folded lip into a bright white band — the
   strongest horizontal line in the interior, and what makes it read "lit
   cabinet" rather than "dark box with shapes in it". */
.shelf__lip {
  position: relative;
  height: 19px;
  border-radius: 1px;
  background: linear-gradient(
    180deg,
    #ffffff 0%,
    #f4f8fa 42%,
    #cfd8dd 74%,
    #8d979d 100%
  );
  box-shadow:
    0 0 12px 2px rgba(var(--led-cool), 0.5),
    0 8px 18px -6px rgba(0, 0, 0, 0.85),
    inset 0 -1px 0 rgba(0, 0, 0, 0.25);
}

/* Clear C-channel snapped over the lit lip, holding the selection cards. */
.shelf__channel {
  position: absolute;
  inset: 3px 5px 3px;
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr));
  gap: 3px;
}

/* Printed card: dark code chip, then the product name, both reading as ink
   on the already-white lit band. */
.pcard {
  display: flex;
  align-items: center;
  gap: 0.34em;
  overflow: hidden;
  min-width: 0;
  padding: 0 2px;
  color: #1c2024;
  font-family: var(--font-mono);
  font-size: clamp(5px, calc(var(--machine-w) * 0.0125), 8.5px);
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
  white-space: nowrap;
  text-transform: uppercase;
}

.pcard__code {
  flex: 0 0 auto;
  padding: 1px 2.5px;
  border-radius: 1px;
  background: #16191c;
  color: #f2f5f7;
  font-weight: 700;
}

.pcard--empty {
  opacity: 0.4;
}

.pcard__name {
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.66;
}

/* Selection LED beside each card. */
.pcard__led {
  flex: 0 0 auto;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  margin-left: auto;
}

.slot.is-selected ~ * .pcard__led,
.pcard.is-active .pcard__led {
  background: var(--status-live);
  box-shadow: 0 0 4px var(--status-live);
}

/* ---------------------------------------------------------------------- */
/* SLOT + coil                                                             */
/* ---------------------------------------------------------------------- */

.slot {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-width: 0;
  height: 100%;
  contain: layout paint;
}

/* Helical coil read end-on: the ellipse at the product base plus the wire
   running back into the cabinet. */
.slot__coil {
  position: absolute;
  right: 12%;
  bottom: 1px;
  left: 12%;
  height: 7px;
  pointer-events: none;
  opacity: 0.5;
  background: repeating-linear-gradient(
    90deg,
    rgba(190, 198, 205, 0.55) 0 1px,
    transparent 1px 7px
  );
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
}

.shelf--empty .slot__coil {
  opacity: 0.72;
}

/* Restocking gap — communicates the machine keeps getting stocked. */
.slot--empty {
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 10px;
}

.slot--empty span {
  font-family: var(--font-mono);
  font-size: 6.5px;
  letter-spacing: 0.22em;
  color: rgba(255, 255, 255, 0.16);
  text-transform: uppercase;
}

/* ====================================================================== */
/* GLASS — sibling overlay, never inside .cabinet                          */
/* ====================================================================== */

.glass {
  position: absolute;
  inset: 0;
  z-index: 5;
  border-radius: var(--radius-inner);
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(190, 215, 235, 0.045),
    rgba(120, 150, 175, 0.012) 45%,
    rgba(200, 225, 245, 0.03)
  );
  /* real display glass is sharp — heavy blur reads as a frosted iOS panel
     and is the most expensive thing that can happen on this page */
  backdrop-filter: blur(0.3px) saturate(1.05);
  /* bright rim + float-glass green on the cut edge + occlusion into frame */
  box-shadow:
    inset 0 0 0 1px var(--glass-rim),
    inset 0 0 0 3px var(--glass-green),
    inset 0 0 14px 5px var(--glass-occlusion),
    inset 0 2px 10px rgba(0, 0, 0, 0.4);
  transition: opacity 240ms ease;
}

/* Room reflections: crisp low-alpha shapes. Edge sharpness is what reads as
   reflection — a soft bright haze just reads as fog and kills legibility. */
.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  mix-blend-mode: screen;
  opacity: 0.7;
  /* crisp, narrow reflected shapes confined to the upper third — sharpness
     is what reads as reflection; a soft wash just reads as fog */
  background:
    linear-gradient(
      107deg,
      transparent 15%,
      rgba(255, 255, 255, 0.06) 15.3%,
      rgba(255, 255, 255, 0.06) 21%,
      transparent 21.3%
    ),
    linear-gradient(
      107deg,
      transparent 26%,
      rgba(255, 255, 255, 0.03) 26.2%,
      rgba(255, 255, 255, 0.03) 29%,
      transparent 29.2%
    );
  mask-image: linear-gradient(180deg, #000 0%, #000 34%, transparent 62%);
}

/* Specular streak tracking the pointer. One elongated radial: no corner
   clipping, no extra transform layer. */
.glass::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  mix-blend-mode: screen;
  background: radial-gradient(
    58% 88% at var(--mx) var(--my),
    rgba(255, 255, 255, 0.17),
    rgba(255, 255, 255, 0.05) 38%,
    transparent 62%
  );
}

/* Highest-value legibility move in the design: the pane backs off whenever
   anything inside the cabinet takes focus. */
.window:focus-within .glass {
  opacity: 0.5;
}

/* ====================================================================== */
/* CONTROL COLUMN                                                          */
/* ====================================================================== */

.control {
  position: relative;
  z-index: 7;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto auto auto;
  gap: 3%;
  min-height: 0;
  padding: 4% 6%;
  border-radius: var(--radius-inner);
  /* brushed stainless, grain running vertically on this vertical member */
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255, 255, 255, 0.045) 0 1px,
      transparent 1px 2px,
      rgba(0, 0, 0, 0.04) 2px 3px,
      transparent 3px 4px
    ),
    linear-gradient(90deg, #2b2f33 0%, #454b51 26%, #363b40 55%, #4a5057 78%, #262a2d 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 -1px 0 rgba(0, 0, 0, 0.6),
    inset 0 0 0 1px rgba(0, 0, 0, 0.45);
}

.control::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0.16;
  mix-blend-mode: overlay;
  background-image: var(--grain-metal);
  background-size: 140px 140px;
  pointer-events: none;
}

/* --- Display ---------------------------------------------------------- */

.display {
  position: relative;
  overflow: hidden;
  padding: 7% 8%;
  border-radius: 3px;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(125, 255, 178, 0.07), transparent 70%),
    var(--display-bg);
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.9),
    inset 0 0 0 1px rgba(0, 0, 0, 0.8),
    0 1px 0 rgba(255, 255, 255, 0.12);
  font-family: var(--font-mono);
  min-height: 0;
}

/* Dot-matrix grid over the panel. */
.display::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.5) 0 1px, transparent 1px 2px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.35) 0 1px, transparent 1px 2px);
}

.display__line {
  display: block;
  overflow: hidden;
  color: var(--display-ink);
  font-size: clamp(6px, calc(var(--machine-w) * 0.0205), 12px);
  font-weight: 500;
  letter-spacing: 0.09em;
  line-height: 1.45;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-transform: uppercase;
  text-shadow: 0 0 6px var(--display-glow);
}

.display__line--code {
  color: var(--display-amber);
  text-shadow: 0 0 6px rgba(255, 180, 84, 0.5);
}

.display__line--dim {
  color: var(--display-dim);
  text-shadow: none;
}

.display.is-busy .display__line {
  animation: displayFlicker 340ms steps(2) 2;
}

@keyframes displayFlicker {
  50% {
    opacity: 0.45;
  }
}

/* --- Category selector ------------------------------------------------ */

.selector {
  display: grid;
  gap: 3px;
}

.selector__btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 5px;
  border: 0;
  border-radius: 2px;
  background: linear-gradient(180deg, #4a5057, #2f3439);
  color: rgba(236, 238, 240, 0.66);
  font-family: var(--font-mono);
  font-size: clamp(5px, calc(var(--machine-w) * 0.0132), 8px);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-align: left;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -1px 0 rgba(0, 0, 0, 0.55),
    0 1px 2px rgba(0, 0, 0, 0.55);
  transition: transform var(--dur-release) var(--ease-release), color 160ms ease;
}

.selector__btn::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.7);
  flex: 0 0 auto;
}

.selector__btn:hover {
  color: #fff;
}

.selector__btn:active {
  transform: translateY(1px);
  transition-duration: var(--dur-press);
  transition-timing-function: var(--ease-press);
}

.selector__btn[aria-pressed="true"] {
  color: #fff;
}

.selector__btn[aria-pressed="true"]::before {
  background: var(--status-live);
  box-shadow: 0 0 5px var(--status-live);
}

/* --- Keypad ----------------------------------------------------------- */

.keypad {
  align-self: end;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
}

.key {
  aspect-ratio: 1;
  border: 0;
  border-radius: 2px;
  /* keys are slightly domed and polished where thumbs land */
  background:
    radial-gradient(80% 70% at 50% 32%, rgba(255, 255, 255, 0.16), transparent 62%),
    linear-gradient(180deg, #565c63, #33383d);
  color: rgba(240, 242, 244, 0.82);
  font-family: var(--font-mono);
  font-size: clamp(5px, calc(var(--machine-w) * 0.0152), 9px);
  font-weight: 700;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    inset 0 -2px 0 rgba(0, 0, 0, 0.5),
    0 1px 2px rgba(0, 0, 0, 0.6);
  transition: transform var(--dur-release) var(--ease-release);
}

.key:active,
.key.is-pressed {
  transform: translateY(1.5px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -1px 0 rgba(0, 0, 0, 0.5),
    0 0 0 rgba(0, 0, 0, 0.6);
  transition-duration: var(--dur-press);
  transition-timing-function: var(--ease-press);
}

.key--wide {
  grid-column: span 3;
  aspect-ratio: auto;
  padding: 4px 0;
  letter-spacing: 0.14em;
}

/* --- Reader, coin slot, delivery port --------------------------------- */

.reader {
  position: relative;
  height: 14%;
  min-height: 14px;
  border-radius: 3px;
  background: linear-gradient(180deg, #202427, #121517);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    inset 0 -1px 0 rgba(0, 0, 0, 0.7);
}

.reader::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 14%;
  width: 4px;
  height: 4px;
  transform: translateY(-50%);
  border-radius: 50%;
  background: var(--status-live);
  box-shadow: 0 0 6px var(--status-live);
}

.coinslot {
  height: 7%;
  min-height: 7px;
  border-radius: 2px;
  background: linear-gradient(180deg, #0a0c0d 0%, #2c3134 40%, #0a0c0d 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -1px 2px rgba(0, 0, 0, 0.9);
}

/* Lit delivery port at the foot of the control column — the dispense target. */
.port {
  position: relative;
  height: 15%;
  min-height: 20px;
  border-radius: 2px;
  overflow: hidden;
  background: linear-gradient(180deg, #0a0c0d, #16191b);
  box-shadow:
    inset 0 3px 10px rgba(0, 0, 0, 0.95),
    inset 0 0 0 1px rgba(255, 255, 255, 0.07);
}

.port__glow {
  position: absolute;
  inset: 14% 10%;
  border-radius: 2px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(200, 226, 248, 0.55));
  box-shadow: 0 0 12px 3px rgba(var(--led-cool), 0.5);
  transition: opacity 200ms ease, transform var(--dur-drawer) var(--ease-drawer-out);
}

.machine.is-dispensing .port__glow {
  transform: translateY(22%) scaleY(0.6);
  opacity: 0.75;
}

/* --- Utility buttons -------------------------------------------------- */

.utils {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
}

.util {
  display: grid;
  place-items: center;
  padding: 5px 0;
  border: 0;
  border-radius: 2px;
  background: linear-gradient(180deg, #414750, #282d31);
  color: rgba(236, 238, 240, 0.7);
  font-family: var(--font-mono);
  font-size: clamp(4.5px, calc(var(--machine-w) * 0.0118), 7.5px);
  font-weight: 600;
  letter-spacing: 0.14em;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -1px 0 rgba(0, 0, 0, 0.55);
  transition: transform var(--dur-release) var(--ease-release), color 160ms ease;
}

.util:hover {
  color: #fff;
}

.util:active {
  transform: translateY(1px);
  transition-duration: var(--dur-press);
}

.util[aria-pressed="true"] {
  color: var(--status-live);
}

/* ====================================================================== */
/* BASE — delivery bin, kick panel, manufacturer plate                     */
/* ====================================================================== */

/* Shallow plinth: louvered vents on the left, etched plate on the right.
   The glass runs nearly to the floor, as on the reference machine. */
.base {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2%;
  padding: 0.8% var(--bezel-side) 1%;
}

.vents {
  height: 62%;
  min-height: 12px;
  max-width: 46%;
  border-radius: 2px;
  background: repeating-linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.82) 0 2px,
    rgba(255, 255, 255, 0.05) 2px 3px,
    transparent 3px 5px
  );
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

/* Etched manufacturer plate — deliberately near-illegible, like the real thing. */
.plate {
  display: grid;
  gap: 1px;
  padding: 4px 7px;
  border-radius: 2px;
  background: linear-gradient(160deg, #8a9095, #5d6367);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.4),
    inset 0 -1px 0 rgba(0, 0, 0, 0.5),
    0 1px 2px rgba(0, 0, 0, 0.6);
  font-family: var(--font-mono);
  font-size: clamp(4px, calc(var(--machine-w) * 0.0092), 6px);
  line-height: 1.3;
  letter-spacing: 0.06em;
  color: #14171a;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Screws at the corners of the base panel. */
.screw {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #9aa0a5, #4a4f54 60%, #2b2f32);
  box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.6), 0 1px 1px rgba(255, 255, 255, 0.08);
}

.screw::after {
  content: "";
  position: absolute;
  inset: 1.4px;
  background: linear-gradient(90deg, transparent 42%, rgba(0, 0, 0, 0.65) 42% 58%, transparent 58%);
}

.screw--bl {
  bottom: 6px;
  left: 6px;
}

.screw--br {
  bottom: 6px;
  right: 6px;
}

/* ====================================================================== */
/* SCROLL CUE                                                              */
/* ====================================================================== */

.cue {
  position: absolute;
  bottom: calc(var(--base-h) + 6px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  font-family: var(--font-mono);
  font-size: 7px;
  letter-spacing: 0.24em;
  color: rgba(255, 255, 255, 0.3);
  text-transform: uppercase;
  pointer-events: none;
  transition: opacity 300ms ease;
}

.machine.is-scrolled .cue {
  opacity: 0;
}

/* ====================================================================== */
/* RESPONSIVE                                                              */
/* ====================================================================== */

/* Tablet: crop in, drop a column, keep the frame edges visible. */
@media (max-width: 900px) {
  .machine {
    --machine-h: min(calc(100dvh - 20px), 900px);
    --machine-w: min(calc(var(--machine-h) / 1.42), 96vw);
    --control-w: 17%;
  }
}

/* Mobile: stand closer to the glass. The machine fills the width, the
   control column moves under the window, products get bigger. */
@media (max-width: 640px) {
  .machine {
    --machine-h: calc(100dvh - 12px);
    --machine-w: 100%;
    --marque-h: 9%;
    --base-h: 6.5%;
    --bezel-side: 2.4%;
    border-radius: 10px;
  }

  .body {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    gap: 6px;
  }

  /* Standing closer to the glass: the cabinet keeps the height, and the
     controls collapse to just the display, the filters and the two utilities. */
  .control {
    grid-template-rows: auto auto;
    grid-template-columns: 1.5fr 1fr;
    gap: 6px;
    padding: 7px 8px;
    align-items: center;
  }

  /* Coin/card furniture doesn't survive the scale — drop it rather than
     render three unreadable bars. */
  .reader,
  .coinslot,
  .port {
    display: none;
  }

  .utils {
    grid-column: 1 / -1;
    grid-template-columns: 1fr 1fr;
  }

  /* the bloom is sized for a 600px-wide cabinet; at 340px it blows out */
  .cabinet__lamp {
    width: 5px;
    box-shadow:
      0 0 4px 1px rgba(255, 255, 255, 0.9),
      0 0 12px 3px rgba(var(--led-cool), 0.6),
      0 0 30px 9px rgba(var(--led-cool), 0.28);
  }

  .shelves {
    padding: 10px 16px 0;
  }

  .pkg__body {
    min-width: min(100%, 76px);
  }

  /* keypad is a desktop affordance; on touch you press the product */
  .keypad {
    display: none;
  }

  .selector {
    grid-template-columns: repeat(3, 1fr);
    gap: 3px;
  }

  .selector__btn {
    justify-content: center;
    padding: 5px 2px;
    font-size: 6.5px;
    letter-spacing: 0.06em;
  }

  .selector__btn::before {
    display: none;
  }

  .display__line {
    font-size: 8.5px;
  }

  .utils {
    grid-template-columns: 1fr 1fr;
  }

  .shelf__deck {
    min-height: 118px;
  }

  .pcard {
    font-size: 6px;
  }

  /* would land on top of the control column at this size */
  .cue {
    display: none;
  }
}

/* ====================================================================== */
/* LITE MODE + REDUCED MOTION                                              */
/* ====================================================================== */

[data-lite] .glass {
  backdrop-filter: none;
  background: linear-gradient(
    180deg,
    rgba(190, 215, 235, 0.13),
    rgba(120, 150, 175, 0.05)
  );
}

[data-lite] .glass::after,
[data-lite] .room::after,
[data-lite] .machine::before {
  display: none;
}

[data-lite] .parallax {
  transform: none !important;
}

@supports not (backdrop-filter: blur(1px)) {
  .glass {
    background: linear-gradient(
      180deg,
      rgba(190, 215, 235, 0.13),
      rgba(120, 150, 175, 0.05)
    );
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
