/* The Pay button with the card that slides into its slot. The graphite pill is a real <button> with a groove cut
   into its top edge. The card above it sits in a window whose bottom edge is exactly the groove: whatever part of the
   card goes lower is cut away, so it looks as if it went inside the button. Sizes are in pixels and small enough for
   the phone box (341 by 410); the script reads them again on resize. */
:root {
  --paper: #ffffff;          /* the page */
  --graphite: #15161a;       /* the pill */
  --graphite-top: #2d2f36;   /* the light on top of the pill */
  --ink: #f4f4f2;            /* the words on the pill */
  --muted: #9a9ca6;          /* the amount and the waiting word */
  --accent: #8d9cff;         /* the band of light and the light leaking from the slot */
  --ok: #5fe0a4;             /* the tick */
  --card-1: #4258ff;         /* the card, light corner */
  --card-2: #2433c9;         /* the card, middle */
  --card-3: #121866;         /* the card, dark corner */
  --pill-h: 60px;            /* the height of the button */
  --pill-bottom: 26px;       /* the room under the button */
  --slot-y: 9px;             /* where the slot is, from the top edge of the button */
}

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

html {
  touch-action: manipulation;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

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

.stage {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 12px;
  overflow: hidden;
}

/* the box of the whole piece: the room for the card above, and the button */
.pay {
  position: relative;
  width: min(300px, 92vw);
  height: min(200px, 48vh);
}

/* ---------------------------------------------------------------- the card and its window */
.win {
  position: absolute;
  left: -20px;
  right: -20px;
  top: -40px;
  bottom: calc(var(--pill-bottom) + var(--pill-h) - var(--slot-y));
  overflow: hidden;
  pointer-events: none;
  z-index: 2;
}

.card {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 116px;
  height: 73px;
  opacity: 0;
  will-change: transform;
  transform-origin: 50% 100%;
}

.card__face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 7px;
  background:
    radial-gradient(120% 90% at 12% 0%, rgba(255, 255, 255, 0.28), transparent 55%),
    linear-gradient(135deg, var(--card-1) 0%, var(--card-2) 42%, var(--card-3) 100%);
  box-shadow:
    0 1px 1px rgba(14, 18, 80, 0.25),
    0 6px 14px -4px rgba(18, 24, 110, 0.4);
}

/* very fine brushed lines, so the card reads as a material */
.card__brush {
  position: absolute;
  inset: 0;
  opacity: 0.5;
  background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
}

/* a soft lilac light in the lower corner */
.card__glow {
  position: absolute;
  right: -30%;
  bottom: -60%;
  width: 90%;
  height: 120%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(170, 160, 255, 0.45), transparent);
}

/* the light running across the card while it straightens */
.card__sheen {
  position: absolute;
  top: -20%;
  bottom: -20%;
  left: 0;
  width: 45%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.32) 50%, transparent);
  transform: translateX(-120%) skewX(-12deg);
}

/* the 1px edge that catches the light from above */
.card__edge {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0.08) 45%, rgba(255, 255, 255, 0.02) 80%, rgba(255, 255, 255, 0.14));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}

.card__mark {
  position: absolute;
  top: 8px;
  right: 9px;
  width: 12px;
  height: 12px;
  fill: none;
  stroke: rgba(255, 255, 255, 0.85);
  stroke-width: 1.4;
}

.card__bank {
  position: absolute;
  top: 9px;
  left: 10px;
  font-size: 7px;
  font-weight: 650;
  letter-spacing: 0.2em;
  color: rgba(255, 255, 255, 0.9);
}

.card__chip {
  position: absolute;
  top: 27px;
  left: 10px;
  width: 20px;
  height: 15px;
}

.card__num,
.card__exp {
  position: absolute;
  bottom: 8px;
  font-size: 7.5px;
  font-weight: 560;
  letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
  color: rgba(255, 255, 255, 0.82);
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25);
}

.card__num {
  left: 10px;
}

.card__exp {
  right: 10px;
  color: rgba(255, 255, 255, 0.6);
}

/* ---------------------------------------------------------------- the pill */
.pill {
  position: absolute;
  left: 50%;
  bottom: var(--pill-bottom);
  height: var(--pill-h);
  min-width: min(236px, 76vw);
  padding: 6px 26px 0;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  background:
    radial-gradient(120% 100% at 50% 0%, var(--graphite-top) 0%, var(--graphite) 60%, #0f1013 100%);
  box-shadow:
    inset 0 -1px 0 rgba(0, 0, 0, 0.5),
    0 1px 1px rgba(14, 15, 17, 0.18),
    0 4px 8px -2px rgba(14, 15, 17, 0.18),
    0 14px 28px -12px rgba(14, 15, 17, 0.38),
    0 30px 60px -30px rgba(14, 15, 17, 0.35);
  will-change: transform;
  isolation: isolate;
}

.pill:focus-visible {
  outline: 2px solid var(--graphite);
  outline-offset: 4px;
}

.pill__skin,
.pill__grain,
.pill__wash,
.pill__edge {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

.pill__skin {
  overflow: hidden;
}

/* a very fine grain, so the graphite reads as a material and not a flat colour */
.pill__grain {
  opacity: 0.22;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0.33 0.33 0.33 0 0 0.33 0.33 0.33 0 0 0.33 0.33 0.33 0 0 0 0 0 0 1'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* the green light that floods the pill for an instant when the payment goes through */
.pill__wash {
  opacity: 0;
  background: radial-gradient(70% 120% at 50% 50%, color-mix(in srgb, var(--ok) 30%, transparent), transparent 70%);
}

/* the band of light that sweeps across while it authorises */
.pill__band {
  position: absolute;
  top: -10%;
  bottom: -10%;
  left: 0;
  width: 46%;
  opacity: 0;
  background: linear-gradient(100deg,
      transparent 8%,
      color-mix(in srgb, var(--accent) 45%, transparent) 36%,
      rgba(225, 230, 255, 0.26) 50%,
      color-mix(in srgb, var(--accent) 45%, transparent) 64%,
      transparent 92%);
  mix-blend-mode: screen;
}

/* the 1px edge that catches the light from above */
.pill__edge {
  padding: 1px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.04) 40%, rgba(255, 255, 255, 0) 70%, rgba(255, 255, 255, 0.06));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
}

/* ---------------------------------------------------------------- the slot */
.slot {
  position: absolute;
  left: 50%;
  top: calc(var(--slot-y) - 2px);
  width: 128px;
  height: 4px;
  transform: translateX(-50%);
  pointer-events: none;
}

.slot__groove {
  position: absolute;
  inset: 0;
  border-radius: 2px;
  background: linear-gradient(180deg, #000 0%, #060608 60%, #1b1c21 100%);
  box-shadow: inset 0 1px 1.5px rgba(0, 0, 0, 0.9);
}

/* the lit lip under the groove */
.slot__lip {
  position: absolute;
  left: 3px;
  right: 3px;
  top: 4px;
  height: 1px;
  border-radius: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.22) 20%, rgba(225, 230, 255, 0.26) 50%, rgba(255, 255, 255, 0.22) 80%, transparent);
  opacity: 0.6;
}

/* the light leaking out of the slot while the card is inside */
.slot__leak {
  position: absolute;
  left: 8%;
  right: 8%;
  top: -2px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 70%, transparent), transparent);
  filter: blur(3px);
  opacity: 0;
}

/* ---------------------------------------------------------------- the row of words */
.row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 100%;
  white-space: nowrap;
  pointer-events: none;
}

.tick {
  display: inline-flex;
  width: 0;
  height: 22px;
  margin-right: -12px;
  overflow: visible;
}

.tick svg {
  width: 22px;
  height: 22px;
  flex: none;
  fill: none;
  stroke: var(--ok);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.tick circle,
.tick path {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.tick circle {
  stroke-width: 1.4;
  opacity: 0.55;
}

.words {
  display: inline-grid;
  justify-items: start;
  overflow: hidden;
  padding: 2px 0 4px;
  margin: -2px 0 -4px;
}

.word {
  grid-area: 1 / 1;
  font-size: 17px;
  font-weight: 580;
  font-variation-settings: 'wdth' 100;
  letter-spacing: -0.005em;
  line-height: 1.25;
}

.word--auth,
.word--paid {
  opacity: 0;
}

/* the waiting word has a light running through it, in step with the band */
.word--auth {
  color: transparent;
  background-image: linear-gradient(90deg, var(--muted) 0%, var(--muted) 35%, #ffffff 50%, var(--muted) 65%, var(--muted) 100%);
  background-size: 300% 100%;
  background-position: 100% 0;
  -webkit-background-clip: text;
  background-clip: text;
}

.sep {
  width: 1px;
  height: 16px;
  background: rgba(255, 255, 255, 0.16);
}

.amount {
  font-size: 17px;
  font-weight: 480;
  font-variant-numeric: tabular-nums;
  color: #c9cbd2;
  line-height: 1.25;
}

@media (hover: hover) {
  .pill.is-hover .slot__lip {
    opacity: 1;
  }
}
