/* The loyalty card with tokens that fall into the vault: the rewards card of a made-up coffee roaster on a near black
   page. The vault is a small glass box inside the card; the tokens are absolutely placed discs moved by the physics
   in script.js (an outer element for the position, an inner one for the spin, so the metal's light stays put while
   the stamped mark turns). Glass, sheen and streak sit on top of the tokens. */
:root {
  --page: #0b0b0d;            /* the page */
  --card: #141416;            /* the body of the card */
  --edge: rgba(255, 255, 255, 0.075); /* the edge of the card and of the vault */
  --ink: #f2efe9;             /* the words */
  --muted: #8f8b84;           /* the small words */
  --accent: #eba660;          /* the warm amber of the rewards */
  --metal-hi: #fff0d4;        /* the brightest point of a token */
  --metal: #d99b5c;           /* the copper of a token */
  --metal-lo: #7a4520;        /* the dark rim of a token */
  --button: #f2efe9;          /* the button */
  --button-ink: #121214;      /* the words on the button */
}

* {
  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;
}

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

.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 14px;
  overflow: hidden;
  background:
    radial-gradient(60% 50% at 50% 42%, rgba(235, 166, 96, 0.07), transparent 70%),
    var(--page);
}

/* grain over the page, very faint */
.stage::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  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");
}

.card {
  position: relative;
  width: min(88vw, 340px);
  padding: clamp(14px, 2.4vh, 18px);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 38%),
    var(--card);
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 1px 2px rgba(0, 0, 0, 0.6),
    0 24px 50px -22px rgba(0, 0, 0, 0.95),
    0 60px 90px -50px rgba(235, 166, 96, 0.16);
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 2vh, 14px);
  opacity: 0;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.brand__mark {
  flex: none;
  width: 30px;
  height: 30px;
  padding: 6px;
  border-radius: 9px;
  background: linear-gradient(160deg, #2a2420, #1a1715);
  box-shadow: inset 0 0 0 1px rgba(235, 166, 96, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand__txt {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.brand__name {
  font-size: 14px;
  font-weight: 640;
  font-stretch: 108%;
  letter-spacing: -0.01em;
}

.brand__cat {
  font-size: 11.5px;
  color: var(--muted);
}

.tier {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  height: 24px;
  padding: 0 10px 0 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 560;
  color: #e9c79f;
  background: rgba(235, 166, 96, 0.08);
  box-shadow: inset 0 0 0 1px rgba(235, 166, 96, 0.2);
}

.tier__ring {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  border-right-color: rgba(235, 166, 96, 0.25);
  transform: rotate(-30deg);
}

/* ---- tally ---- */
.tally {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}

.tally__big {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}

.roll {
  position: relative;
  display: inline-block;
  height: 1em;
  min-width: 0.62em;
  overflow: hidden;
  font-size: clamp(34px, 6.6vh, 42px);
  font-weight: 620;
  font-stretch: 92%;
  line-height: 1;
  letter-spacing: -0.04em;
}

.roll__n {
  display: block;
  line-height: 1;
}

.roll__n + .roll__n {
  position: absolute;
  left: 0;
  top: 0;
}

.tally__of {
  font-size: 12.5px;
  color: var(--muted);
}

.tally__note {
  margin: 0 0 4px;
  font-size: 11.5px;
  line-height: 1.3;
  color: var(--muted);
  text-align: right;
  max-width: 13em;
  transition: color 0.4s;
}

.tally__note.is-ready {
  color: #f0c08c;
}

/* ---- vault ---- */
.vault {
  position: relative;
  height: clamp(92px, min(46vw, 33vh), 170px);
  border-radius: 16px;
  overflow: hidden;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(255, 255, 255, 0.04), transparent 60%),
    linear-gradient(180deg, #0c0c0e, #121214 70%, #18171a);
  box-shadow:
    inset 0 0 0 1px var(--edge),
    inset 0 10px 22px -12px rgba(0, 0, 0, 0.9),
    inset 0 -1px 0 rgba(255, 255, 255, 0.04);
  cursor: pointer;
  touch-action: none;
  transition: box-shadow 0.35s;
}

@media (hover: hover) {
  .vault:hover {
    box-shadow:
      inset 0 0 0 1px rgba(235, 166, 96, 0.22),
      inset 0 10px 22px -12px rgba(0, 0, 0, 0.9),
      inset 0 -1px 0 rgba(255, 255, 255, 0.04);
  }
}

.vault.is-stir {
  box-shadow:
    inset 0 0 0 1px rgba(235, 166, 96, 0.22),
    inset 0 10px 22px -12px rgba(0, 0, 0, 0.9),
    inset 0 -1px 0 rgba(255, 255, 255, 0.04);
}

/* the warm light that rises from the floor as the tokens add up */
.vault__glow {
  position: absolute;
  left: -10%;
  right: -10%;
  bottom: -40%;
  height: 100%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(235, 166, 96, 0.5), rgba(235, 166, 96, 0.12) 55%, transparent);
  filter: blur(10px);
  opacity: 0;
  pointer-events: none;
}

/* the slot the tokens come through */
.vault__slot {
  position: absolute;
  left: 50%;
  top: 0;
  width: 34%;
  height: 7px;
  transform: translateX(-50%);
  border-radius: 0 0 6px 6px;
  background: #060607;
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.09), 0 1px 0 rgba(0, 0, 0, 0.5);
  z-index: 3;
}

.vault__lip {
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(235, 166, 96, 0.55), transparent);
  opacity: 0.6;
}

.vault__tokens {
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* the floor: two hatches that slide apart when the reward is redeemed */
.vault__floor {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  z-index: 2;
  pointer-events: none;
}

.vault__hatch {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.03));
}

.vault__hatch--l {
  left: 0;
  border-radius: 0 2px 0 0;
}

.vault__hatch--r {
  right: 0;
  border-radius: 2px 0 0 0;
}

/* the glass front: a soft diagonal sheen and a lit top edge */
.vault__glass {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  border-radius: inherit;
  background:
    linear-gradient(112deg, transparent 18%, rgba(255, 255, 255, 0.05) 26%, transparent 34%),
    linear-gradient(112deg, transparent 40%, rgba(255, 255, 255, 0.025) 44%, transparent 50%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent 22%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* the thin anamorphic streak that crosses the glass when the reward is ready */
.vault__streak {
  position: absolute;
  left: 0;
  top: 52%;
  width: 70%;
  height: 1px;
  z-index: 5;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(255, 214, 160, 0.95) 50%, transparent);
  box-shadow: 0 0 10px 1px rgba(235, 166, 96, 0.55);
  opacity: 0;
}

/* ---- a token ---- */
.token {
  position: absolute;
  left: 0;
  top: 0;
  width: calc(var(--r, 24px) * 2);
  height: calc(var(--r, 24px) * 2);
  border-radius: 50%;
  will-change: transform;
  background:
    repeating-radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 3px),
    radial-gradient(circle at 34% 28%, var(--metal-hi) 0, #f1c88f 16%, var(--metal) 46%, #a8662f 78%, var(--metal-lo) 100%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 236, 205, 0.35),
    inset 0 -3px 6px rgba(60, 26, 6, 0.45),
    inset 0 2px 3px rgba(255, 255, 255, 0.25),
    0 6px 10px -5px rgba(0, 0, 0, 0.85),
    0 2px 3px rgba(0, 0, 0, 0.5);
}

/* the stamped face, the part that spins */
.token__face {
  position: absolute;
  inset: 13%;
  border-radius: 50%;
  box-shadow:
    inset 0 1px 1px rgba(70, 32, 8, 0.55),
    0 1px 0 rgba(255, 240, 215, 0.4);
}

.token__mark {
  position: absolute;
  inset: 22%;
  width: 56%;
  height: 56%;
  fill: none;
  stroke: rgba(92, 46, 14, 0.72);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0.8px 0 rgba(255, 240, 215, 0.5));
}

/* a quick shine that crosses a token as it lands */
.token__shine {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(120deg, transparent 35%, rgba(255, 255, 255, 0.75) 50%, transparent 65%);
  background-size: 300% 100%;
  background-position: 100% 0;
  opacity: 0;
  mix-blend-mode: soft-light;
}

.token.is-gold {
  box-shadow:
    inset 0 0 0 1px rgba(255, 236, 205, 0.5),
    inset 0 -3px 6px rgba(60, 26, 6, 0.45),
    inset 0 2px 3px rgba(255, 255, 255, 0.3),
    0 6px 10px -5px rgba(0, 0, 0, 0.85),
    0 0 18px -4px rgba(235, 166, 96, 0.7);
}

/* the thin ring a landing leaves */
.ping {
  position: absolute;
  left: 0;
  top: 0;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border-radius: 50%;
  border: 1px solid rgba(255, 210, 160, 0.7);
  pointer-events: none;
  z-index: 2;
}

/* ---- the track under the vault ---- */
.track {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 4px;
}

.track__seg {
  position: relative;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.track__fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #c98447, var(--accent) 60%, #ffd4a0);
  transform: scaleX(0);
  transform-origin: left center;
}

/* ---- the button ---- */
.btn {
  position: relative;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.btn__face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: inherit;
  color: var(--button-ink);
  background: linear-gradient(180deg, #ffffff, var(--button));
  box-shadow:
    inset 0 -1px 0 rgba(0, 0, 0, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 10px 20px -12px rgba(255, 255, 255, 0.35);
  transition: background 0.45s, color 0.45s, box-shadow 0.45s;
}

.btn.is-ready .btn__face {
  color: #2a1606;
  background: linear-gradient(180deg, #ffd9a8, var(--accent) 70%, #d88d48);
  box-shadow:
    inset 0 -1px 0 rgba(90, 40, 6, 0.3),
    inset 0 1px 0 rgba(255, 245, 230, 0.8),
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 12px 26px -10px rgba(235, 166, 96, 0.65);
}

.btn.is-busy {
  pointer-events: none;
}

.btn__words {
  font-size: 14px;
  font-weight: 600;
  font-stretch: 104%;
  letter-spacing: -0.005em;
  white-space: nowrap;
}

.btn__icon {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.btn__cup {
  opacity: 0;
}

.btn:focus-visible {
  outline: none;
}

.btn:focus-visible .btn__face {
  box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--accent);
}

/* the drawn pointer of the autopilot */
.cursor {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  margin: -2px 0 0 -4px;
  fill: #fff;
  stroke: #111;
  stroke-width: 1.3;
  stroke-linejoin: round;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.55));
  pointer-events: none;
  opacity: 0;
  z-index: 10;
}
