/* The Pay button you tap with the card on a contactless terminal. The graphite pill is a real <button>: its size is
   set in pixels by the script (rest, terminal, rest again) and everything inside is clipped by its rounded edge. The
   terminal face is laid out at its full size from the start and only uncovered as the pill grows, so nothing reflows
   while it moves. The card sits above it, a layer of its own, with its contact shadow underneath. */
:root {
  --paper: #ffffff;       /* the page */
  --graphite: #17181b;    /* the pill and the terminal */
  --graphite-top: #2b2d32; /* the light on top of the terminal */
  --ink: #f2f2f0;         /* the words on the pill */
  --muted: #8d8f96;       /* the small words on the terminal */
  --accent: #3ee08f;      /* the waves, the tick, the approval */
  --steel-1: #eceef1;     /* the brushed metal of the card, light */
  --steel-2: #b7bbc3;     /* the brushed metal of the card, shade */
  --steel-ink: #565b65;   /* the engraved words on the card */
}

* {
  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: as big as the terminal will be */
.pay {
  position: relative;
  width: min(300px, 86vw);
  height: min(200px, 46vh);
}

/* ---------------------------------------------------------------- the pill */
.pill {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 232px;
  height: 60px;
  padding: 0;
  border: 0;
  border-radius: 30px;
  overflow: hidden;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  background:
    radial-gradient(120% 90% at 50% 0%, var(--graphite-top) 0%, var(--graphite) 58%, #111214 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.13),
    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;
}

/* 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 soft green light that floods the face for an instant when the card is read */
.pill__wash {
  opacity: 0;
  background: radial-gradient(70% 70% at 50% 50%, color-mix(in srgb, var(--accent) 34%, transparent), transparent 70%);
}

/* the 1px edge that catches the light from above */
.pill__edge {
  padding: 1px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), 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);
}

/* ---------------------------------------------------------------- rest and done */
.rest,
.done {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  white-space: nowrap;
  pointer-events: none;
}

.rest__waves {
  width: 20px;
  height: 20px;
  margin-right: 2px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  overflow: visible;
}

.rest__waves path {
  opacity: 0.55;
}

.rest__label,
.done__label {
  font-size: 16px;
  font-weight: 620;
  letter-spacing: 0.005em;
  font-variation-settings: 'wdth' 100;
}

.rest__amount,
.done__amount {
  font-size: 16px;
  font-weight: 480;
  color: rgba(242, 242, 240, 0.62);
  font-variation-settings: 'wdth' 96;
  letter-spacing: -0.005em;
}

/* the hairline between the label and the amount */
.rest__amount::before {
  content: '';
  display: inline-block;
  width: 1px;
  height: 16px;
  margin-right: 10px;
  vertical-align: -2px;
  background: rgba(255, 255, 255, 0.14);
}

.roll {
  display: inline-flex;
  align-items: baseline;
}

.ch {
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
  padding: 0.08em 0;
  margin: -0.08em 0;
}

.ch__in {
  display: inline-block;
}

.done {
  visibility: hidden;
}

.done__tick {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible;
}

.done__tick circle {
  stroke-width: 1.3;
  opacity: 0.5;
}

.done__tick [pathLength] {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

/* ---------------------------------------------------------------- the terminal face */
.term {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--tw, 300px);
  height: var(--th, 200px);
  transform: translate(-50%, -50%);
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  padding: clamp(12px, 3.4vh, 16px) 18px clamp(10px, 3vh, 15px);
  visibility: hidden;
  pointer-events: none;
}

.term__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12.5px;
}

.term__shop {
  font-weight: 600;
  font-variation-settings: 'wdth' 108;
  letter-spacing: 0.01em;
  color: var(--ink);
}

.term__sum {
  color: var(--muted);
  font-weight: 500;
}

.term__rule {
  display: block;
  height: 1px;
  margin-top: clamp(8px, 2.4vh, 11px);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.1) 20%, rgba(255, 255, 255, 0.1) 80%, rgba(255, 255, 255, 0));
}

.term__mark {
  position: relative;
  display: grid;
  align-items: center;
  justify-items: start;
}

/* the mark sits left of the middle, where the card's corner comes to touch it */
.term__spot {
  position: relative;
  display: grid;
  place-items: center;
  margin-left: calc(33% - clamp(18px, 7.5vh, 30px));
}

.term__waves {
  position: relative;
  width: clamp(36px, 15vh, 60px);
  height: clamp(36px, 15vh, 60px);
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  overflow: visible;
}

.term__dim {
  stroke: rgba(255, 255, 255, 0.16);
}

.term__lit {
  stroke: var(--accent);
  filter: drop-shadow(0 0 3px color-mix(in srgb, var(--accent) 60%, transparent));
}

.term__lit path {
  opacity: 0;
}

.term__rings {
  position: absolute;
  left: 50%;
  top: 50%;
  width: clamp(80px, 32vh, 130px);
  height: clamp(80px, 32vh, 130px);
  transform: translate(-50%, -50%);
  overflow: visible;
  fill: none;
  stroke: var(--accent);
  stroke-width: 0.8;
}

.term__rings circle {
  opacity: 0;
}

.term__foot {
  display: grid;
  gap: 8px;
  justify-items: center;
}

.term__status {
  position: relative;
  display: grid;
  font-size: 12px;
  font-weight: 520;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.term__status span {
  grid-area: 1 / 1;
  text-align: center;
  white-space: nowrap;
}

.term__status span + span {
  opacity: 0;
}

.term__status span:last-child {
  color: var(--accent);
}

.term__bar {
  position: relative;
  display: block;
  width: 64px;
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 1px;
  overflow: hidden;
}

.term__bar i {
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: 0 50%;
}

/* ---------------------------------------------------------------- the card */
.pay__shadow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--cw, 168px) * 0.92);
  height: calc(var(--cw, 168px) * 0.5);
  margin: calc(var(--cw, 168px) * -0.25) 0 0 calc(var(--cw, 168px) * -0.46);
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.75);
  opacity: 0;
  z-index: 2;
  pointer-events: none;
  will-change: transform, opacity, filter;
}

.card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--cw, 168px);
  aspect-ratio: 1.586;
  z-index: 3;
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
}

.card__face {
  position: absolute;
  inset: 0;
  border-radius: calc(var(--cw, 168px) * 0.055);
  overflow: hidden;
  border: 1px solid rgba(70, 75, 85, 0.5);
  background:
    linear-gradient(118deg, var(--steel-1) 0%, #fafbfc 18%, var(--steel-2) 44%, #e3e5e9 62%, #c8ccd2 80%, #a4a9b2 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    inset 0 -1px 0 rgba(40, 44, 52, 0.25),
    0 1px 1px rgba(14, 15, 17, 0.14),
    0 6px 12px -6px rgba(14, 15, 17, 0.28),
    0 20px 34px -18px rgba(14, 15, 17, 0.4);
}

/* the brushed grain: noise stretched along the card, laid over the gradient */
.card__brush {
  position: absolute;
  inset: 0;
  opacity: 0.55;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='240'%3E%3Cfilter id='b'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.004 0.9' numOctaves='3' seed='7' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0.8 0.8 0.8 0 -0.7 0.8 0.8 0.8 0 -0.7 0.8 0.8 0.8 0 -0.7 0 0 0 0 1'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23b)'/%3E%3C/svg%3E");
  background-size: 100% 100%;
}

/* the reflection that slides across the metal as the card tilts */
.card__sheen {
  position: absolute;
  top: -30%;
  bottom: -30%;
  left: -20%;
  width: 70%;
  background: linear-gradient(100deg, rgba(255, 255, 255, 0) 20%, rgba(255, 255, 255, 0.65) 46%, rgba(255, 255, 255, 0.9) 50%, rgba(255, 255, 255, 0) 74%);
  mix-blend-mode: soft-light;
  will-change: transform;
}

.card__name,
.card__kind,
.card__num {
  position: absolute;
  color: var(--steel-ink);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.75), 0 -0.5px 0 rgba(30, 33, 40, 0.25);
}

.card__name {
  left: 8.5%;
  top: 11%;
  font-size: calc(var(--cw, 168px) * 0.064);
  font-weight: 640;
  letter-spacing: 0.22em;
  font-variation-settings: 'wdth' 118;
}

.card__nfc {
  position: absolute;
  right: 8%;
  top: 9%;
  width: 9%;
  fill: none;
  stroke: var(--steel-ink);
  stroke-width: 1.8;
  stroke-linecap: round;
  opacity: 0.7;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.7));
}

.card__chip {
  position: absolute;
  left: 9%;
  top: 38%;
  width: 17%;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.6)) drop-shadow(0 -0.5px 0 rgba(40, 30, 10, 0.3));
}

.card__kind {
  left: 8.5%;
  bottom: 10%;
  font-size: calc(var(--cw, 168px) * 0.046);
  font-weight: 600;
  letter-spacing: 0.16em;
}

.card__num {
  right: 8%;
  bottom: 9%;
  font-size: calc(var(--cw, 168px) * 0.076);
  font-weight: 560;
  letter-spacing: 0.12em;
  font-variation-settings: 'wdth' 110;
}

.rest__waves path {
  transition: stroke 0.3s ease;
}

.pill.is-hover .rest__waves path {
  stroke: var(--accent);
}
