/* The parcel summary of a made-up pantry shop on a warm white page. The well in the middle holds a postal scale: the
   pan (moved by the script on its own spring), the coil under it (an SVG path redrawn every frame) and a ruler on the
   left. The item tiles sit in their own layer: each tile is placed by the script (outer element), the inner face is
   left to CSS for the hover lift, so the two transforms never clash. */
:root {
  --page: #efece6;          /* the page */
  --card: #fbfaf7;          /* the card */
  --well: #f2efe8;          /* the well of the scale */
  --ink: #1b1d1a;           /* the words */
  --muted: #7d7a71;         /* the small words */
  --line: rgba(27, 29, 26, 0.09); /* thin lines */
  --accent: #1f5f46;        /* the green of the meter, the button and the oil */
  --steel: #b8b2a6;         /* the spring and the pan */
  --ivory: #fffdf8;         /* tile: stoneware */
  --kraft: #d9c6a3;         /* tile: coffee */
  --char: #2a2b28;          /* tile: cast iron */
  --sand: #ece2d0;          /* tile: linen */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

p {
  margin: 0;
}

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

.page {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: clamp(10px, 2.6vh, 20px) 12px;
  overflow: hidden;
}

.card {
  position: relative;
  width: min(92vw, 380px);
  padding: clamp(12px, 3.2vh, 18px) clamp(13px, 4vw, 18px) clamp(12px, 3.2vh, 18px);
  border-radius: 22px;
  background: var(--card);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 0 0 1px rgba(27, 29, 26, 0.06),
    0 1px 2px rgba(27, 29, 26, 0.05),
    0 8px 18px -8px rgba(27, 29, 26, 0.12),
    0 30px 60px -28px rgba(27, 29, 26, 0.22);
  opacity: 0;
}

.card__grain {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- head ---------- */
.head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.head__who {
  display: flex;
  align-items: center;
  gap: 10px;
}

.head__mark {
  width: 30px;
  height: 30px;
  padding: 6px;
  border-radius: 9px;
  background: var(--accent);
  fill: none;
  stroke: #f3efe4;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 2px 6px -2px rgba(31, 95, 70, 0.5);
}

.head__brand {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.head__title {
  margin: 1px 0 0;
  font-size: 15.5px;
  line-height: 1.15;
  font-weight: 620;
  font-variation-settings: 'wdth' 104;
  letter-spacing: -0.01em;
}

.count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 540;
  color: var(--ink);
  background: #ffffff;
  box-shadow: inset 0 0 0 1px var(--line), 0 1px 2px rgba(27, 29, 26, 0.05);
}

/* ---------- the well and the scale ---------- */
.well {
  position: relative;
  margin-top: clamp(9px, 2.4vh, 14px);
  height: clamp(146px, 40vh, 214px);
  border-radius: 16px;
  background:
    radial-gradient(120% 80% at 50% 0%, #fbf9f4 0%, rgba(251, 249, 244, 0) 70%),
    var(--well);
  box-shadow: inset 0 0 0 1px var(--line), inset 0 10px 24px -18px rgba(27, 29, 26, 0.25);
  overflow: hidden;
  touch-action: none;
}

.well__light {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 30%);
  opacity: 0.6;
}

.ruler {
  position: absolute;
  left: 0;
  top: 0;
  width: 26px;
  height: 100%;
  pointer-events: none;
}

.ruler__tick {
  position: absolute;
  left: 16px;
  width: 5px;
  height: 1px;
  background: rgba(27, 29, 26, 0.18);
}

.ruler__tick.is-major {
  width: 8px;
  left: 14px;
  background: rgba(27, 29, 26, 0.32);
}

.ruler__lbl {
  position: absolute;
  left: 6px;
  font-size: 8.5px;
  line-height: 1;
  color: var(--muted);
  transform: translateY(-50%);
  font-variant-numeric: tabular-nums;
}

/* the needle that rides with the pan */
.ruler__needle {
  position: absolute;
  left: 18px;
  top: 0;
  width: 10px;
  height: 8px;
  margin-top: -4px;
}

.ruler__needle svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: var(--accent);
}

.spring {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.spring path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.spring [data-coil] {
  stroke: var(--steel);
  stroke-width: 2.4;
}

.spring [data-coil-hi] {
  stroke: rgba(255, 255, 255, 0.85);
  stroke-width: 0.8;
}

.base {
  position: absolute;
  left: calc(50% + 12px);
  bottom: 8px;
  width: 34%;
  height: 7px;
  transform: translateX(-50%);
  border-radius: 4px;
  background: linear-gradient(180deg, #d4cec2, #bdb6a9);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 3px 6px -3px rgba(27, 29, 26, 0.35);
}

.pan {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
}

.pan__face {
  position: absolute;
  inset: 0;
  border-radius: 3px 3px 6px 6px;
  background: linear-gradient(180deg, #e3ded4 0%, #c9c2b5 55%, #b6afa1 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    inset 0 -1px 0 rgba(27, 29, 26, 0.12),
    0 6px 12px -6px rgba(27, 29, 26, 0.38);
}

/* the two guide rails at the ends of the pan: they rise to the top of the well and ride with it */
.pan__face::before,
.pan__face::after {
  content: '';
  position: absolute;
  bottom: 3px;
  width: 3px;
  height: calc(var(--rail, 120px) + 3px);
  border-radius: 2px;
  background: linear-gradient(0deg, #c3bcaf 0%, #d9d3c8 40%, rgba(217, 211, 200, 0) 100%);
  box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.7);
}

.pan__face::before {
  left: -1px;
}

.pan__face::after {
  right: -1px;
}

/* ---------- the item tiles ---------- */
.tiles {
  position: absolute;
  inset: 0;
}

.tile {
  position: absolute;
  left: 0;
  top: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  will-change: transform;
  cursor: pointer;
}

.tile__face {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  padding: 0 calc(9px * var(--u, 1));
  border-radius: calc(8px * var(--u, 1));
  background: var(--t-bg);
  color: var(--t-ink);
  box-shadow:
    inset 0 1px 0 var(--t-hi),
    inset 0 0 0 1px var(--t-edge),
    0 1px 1px rgba(27, 29, 26, 0.08),
    0 6px 12px -8px rgba(27, 29, 26, 0.4);
  transition: transform 0.28s cubic-bezier(0.3, 1.6, 0.5, 1), box-shadow 0.28s ease, filter 0.28s ease;
  overflow: hidden;
}

/* a soft sheen on every tile */
.tile__face::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 45%);
  pointer-events: none;
}

.tile__name {
  position: relative;
  font-size: calc(10.5px * var(--u, 1));
  line-height: 1.15;
  font-weight: 600;
  font-variation-settings: 'wdth' 96;
  letter-spacing: -0.005em;
  white-space: nowrap;
}

.tile__meta {
  position: relative;
  font-size: calc(9px * var(--u, 1));
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  opacity: 0.66;
  white-space: nowrap;
}

/* the little remove mark, shown on the tile under the pointer */
.tile__x {
  position: absolute;
  top: calc(5px * var(--u, 1));
  right: calc(5px * var(--u, 1));
  width: calc(14px * var(--u, 1));
  height: calc(14px * var(--u, 1));
  border-radius: 50%;
  background: var(--t-ink);
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.2s ease, transform 0.3s cubic-bezier(0.3, 1.7, 0.5, 1);
}

.tile__x svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: none;
  stroke: var(--t-bg);
  stroke-width: 1.6;
  stroke-linecap: round;
}

.tile.is-hot .tile__face {
  transform: translateY(-2px);
  box-shadow:
    inset 0 1px 0 var(--t-hi),
    inset 0 0 0 1px var(--t-edge),
    0 1px 1px rgba(27, 29, 26, 0.06),
    0 14px 20px -10px rgba(27, 29, 26, 0.45);
}

.tile.is-hot .tile__x {
  opacity: 1;
  transform: scale(1);
}

.tile.is-press .tile__face {
  transform: translateY(0) scale(0.97);
}

.tile.is-dim .tile__face {
  filter: saturate(0.7) brightness(1.04);
}

.tile--ivory { --t-bg: var(--ivory); --t-ink: var(--ink); --t-hi: #ffffff; --t-edge: rgba(27, 29, 26, 0.09); }
.tile--kraft { --t-bg: linear-gradient(180deg, #e0cfae, var(--kraft)); --t-ink: #3a2f1e; --t-hi: rgba(255, 255, 255, 0.55); --t-edge: rgba(58, 47, 30, 0.12); }
.tile--char  { --t-bg: linear-gradient(180deg, #34352f, var(--char)); --t-ink: #f2efe7; --t-hi: rgba(255, 255, 255, 0.16); --t-edge: rgba(0, 0, 0, 0.3); }
.tile--sand  { --t-bg: var(--sand); --t-ink: #3d372c; --t-hi: rgba(255, 255, 255, 0.8); --t-edge: rgba(61, 55, 44, 0.1); }
.tile--green { --t-bg: linear-gradient(180deg, #2b7357, var(--accent)); --t-ink: #eef4ef; --t-hi: rgba(255, 255, 255, 0.22); --t-edge: rgba(0, 0, 0, 0.18); }

/* linen gets a faint weave */
.tile--sand .tile__face {
  background-image: repeating-linear-gradient(90deg, rgba(61, 55, 44, 0.035) 0 1px, transparent 1px 3px), linear-gradient(var(--sand), var(--sand));
}

/* ---------- empty state and toast ---------- */
.empty {
  position: absolute;
  inset: 0 0 32% 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
  opacity: 0;
  visibility: hidden;
}

.empty__btn,
.toast__btn {
  font: inherit;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.empty__btn {
  height: 30px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 560;
  color: var(--ink);
  background: #ffffff;
  box-shadow: inset 0 0 0 1px var(--line), 0 2px 6px -3px rgba(27, 29, 26, 0.25);
}

.toast {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 4px 0 11px;
  border-radius: 999px;
  font-size: 11px;
  color: #f1eee6;
  background: rgba(27, 29, 26, 0.92);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 8px 18px -8px rgba(27, 29, 26, 0.5);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  white-space: nowrap;
  z-index: 3;
}

.toast__btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 9px 0 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink);
  background: #f4f1ea;
}

.toast__btn svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- the readout ---------- */
.read {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-top: clamp(10px, 2.6vh, 14px);
}

.read__label,
.foot__label {
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.read__num {
  display: flex;
  align-items: baseline;
  gap: 4px;
  margin-top: 1px;
  font-size: clamp(24px, min(8vw, 7vh), 30px);
  line-height: 1;
  font-weight: 640;
  font-variation-settings: 'wdth' 94;
  letter-spacing: -0.02em;
}

.read__unit {
  font-size: 13px;
  font-weight: 520;
  color: var(--muted);
  letter-spacing: 0;
}

.read__band {
  text-align: right;
}

.band__name {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 600;
  font-variation-settings: 'wdth' 102;
}

.band__name span {
  display: inline-block;
}

.band__price {
  display: flex;
  justify-content: flex-end;
  align-items: baseline;
  margin-top: 2px;
  font-size: 11px;
  color: var(--muted);
  white-space: pre;
}

.band__price .roll {
  color: var(--ink);
  font-weight: 560;
}

/* ---------- the meter of the shipping bands ---------- */
.meter {
  position: relative;
  height: 24px;
  margin-top: clamp(8px, 2vh, 11px);
}

.meter__track {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 5px;
  border-radius: 3px;
  background: rgba(27, 29, 26, 0.07);
  box-shadow: inset 0 1px 1px rgba(27, 29, 26, 0.08);
  overflow: hidden;
}

.meter__fill {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #2f7a5c, var(--accent));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transform-origin: 0 50%;
  transform: scaleX(0);
}

.meter__tick {
  position: absolute;
  left: var(--at);
  top: -3px;
}

.meter__tick i {
  display: block;
  width: 1px;
  height: 11px;
  margin-left: -0.5px;
  background: rgba(27, 29, 26, 0.28);
}

.meter__tick b,
.meter__end {
  position: absolute;
  top: 14px;
  font-size: 9px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.meter__tick b {
  left: 0;
  transform: translateX(-50%);
}

.meter__end {
  right: 0;
  top: 11px;
}

/* ---------- foot ---------- */
.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: clamp(10px, 2.4vh, 13px);
  border-top: 1px solid var(--line);
}

.foot__num {
  margin-top: 1px;
  font-size: 19px;
  line-height: 1.05;
  font-weight: 640;
  font-variation-settings: 'wdth' 96;
  letter-spacing: -0.015em;
}

.go {
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tile:focus-visible,
.go:focus-visible,
.toast__btn:focus-visible,
.empty__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.go__face {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 100%;
  padding: 0 16px 0 19px;
  border-radius: inherit;
  color: #f2f5f0;
  background: linear-gradient(180deg, #2a7456, var(--accent) 60%, #1a523c);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), inset 0 -1px 0 rgba(0, 0, 0, 0.18), 0 8px 16px -8px rgba(31, 95, 70, 0.7);
  font-size: 13.5px;
  font-weight: 600;
  font-variation-settings: 'wdth' 100;
  transition: font-variation-settings 0.4s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.go__arrow {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.4s cubic-bezier(0.3, 1.6, 0.5, 1);
}

@media (hover: hover) {
  .go:hover .go__face {
    font-variation-settings: 'wdth' 112;
  }

  .go:hover .go__arrow {
    transform: translateX(2px);
  }

  .toast__btn:hover {
    background: #ffffff;
  }

  .empty__btn:hover {
    box-shadow: inset 0 0 0 1px rgba(27, 29, 26, 0.16), 0 4px 10px -4px rgba(27, 29, 26, 0.3);
  }
}

/* ---------- the roller of the numbers ---------- */
.roll {
  display: inline-flex;
  font-variant-numeric: tabular-nums;
}

.roll__c {
  display: inline-block;
  height: 1.1em;
  line-height: 1.1em;
  overflow: hidden;
  vertical-align: bottom;
}

/* the columns fade at top and bottom, like the window of a counter */
.roll__c:has(.roll__s) {
  -webkit-mask-image: linear-gradient(180deg, transparent 0%, #000 16%, #000 84%, transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0%, #000 16%, #000 84%, transparent 100%);
}

.roll__s {
  display: block;
}

.roll__s > span {
  display: block;
  height: 1.1em;
  text-align: center;
}

/* ---------- the drawn pointer of the autopilot ---------- */
.ghost {
  position: fixed;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  pointer-events: none;
  fill: #ffffff;
  stroke: #15161c;
  stroke-width: 1.4;
  stroke-linejoin: round;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.25));
  opacity: 0;
  visibility: hidden;
  z-index: 10;
}
