/* The payment method with the cards that trade places: the payment step of an online shop's checkout on pure black.
   A panel of dark smoked glass with a 1px edge that catches the pointer's light, the three ways to pay as real cards
   in a stack (brushed graphite, copper, the indigo glass of a wallet), a glass pill that slides onto the chosen row
   and the Pay button with its states. Every card is .cc (moved by GSAP in the stack) > .cc__body (tilted by GSAP)
   > .cc__face (drawn by CSS). */
:root {
  --page: #000000;            /* the page */
  --panel: #111114;           /* the panel */
  --panel-deep: #0a0a0c;      /* the bottom of the panel */
  --ink: #ededf0;             /* the words */
  --muted: #85858f;           /* the small words */
  --line: rgba(255, 255, 255, 0.07); /* thin lines and edges */
  --light: #9db8ff;           /* the pointer's light on the edge */
  --graphite: #2c2e34;        /* the graphite card */
  --copper: #c48c5c;          /* the copper card */
  --halo: #5b5cf0;            /* the wallet card */
  --button: #f4f4f5;          /* the Pay button */
  --button-ink: #0b0b0d;      /* the words on the button */
  --ok: #3fcf8e;              /* payment complete */
}

* {
  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 {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
}

/* ---------- the panel ---------- */

.pay {
  --tint: var(--graphite);
  --mx: 50%;
  --my: 30%;
  position: relative;
  width: min(88vw, 340px);
  padding: clamp(12px, 3.4vh, 20px) clamp(12px, 4vw, 18px) clamp(12px, 3.2vh, 18px);
  border-radius: 24px;
  background:
    radial-gradient(120% 70% at 50% 0%, rgba(255, 255, 255, 0.045), transparent 60%),
    linear-gradient(180deg, var(--panel), var(--panel-deep));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.09),
    inset 0 0 0 1px var(--line),
    0 1px 1px rgba(0, 0, 0, 0.6),
    0 12px 24px -10px rgba(0, 0, 0, 0.9),
    0 40px 80px -30px color-mix(in srgb, var(--tint) 30%, transparent);
  overflow: hidden;
  isolation: isolate;
  opacity: 0;
}

/* the edge lights up where the pointer is */
.pay::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: radial-gradient(180px circle at var(--mx) var(--my), color-mix(in srgb, var(--light) 70%, transparent), transparent 70%);
  -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);
  pointer-events: none;
  z-index: 5;
}

/* and a soft wash inside it */
.pay::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(260px circle at var(--mx) var(--my), rgba(255, 255, 255, 0.035), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* the colour of the chosen card, spilled softly under the wallet */
.pay__glow {
  position: absolute;
  left: 50%;
  top: 18%;
  width: 90%;
  height: 46%;
  transform: translate(-50%, -20%);
  background: radial-gradient(closest-side, color-mix(in srgb, var(--tint) 42%, transparent), transparent);
  filter: blur(18px);
  opacity: 0.7;
  pointer-events: none;
  z-index: 0;
}

.pay__grain {
  position: absolute;
  inset: 0;
  opacity: 0.06;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 0;
}

.pay__head {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.pay__title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  font-variation-settings: 'wdth' 106;
  letter-spacing: 0.005em;
}

.pay__total {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.pay__total-label {
  font-size: 12px;
  color: var(--muted);
}

.pay__total-sum {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- the wallet ---------- */

.wallet {
  --ch: clamp(66px, 21vh, 122px);
  --cw: calc(var(--ch) * 1.586);
  --peek: calc(var(--ch) * 0.1);
  position: relative;
  z-index: 1;
  height: calc(var(--ch) + var(--peek) * 2);
  margin: clamp(8px, 2.4vh, 14px) 0 clamp(10px, 2.8vh, 16px);
}

/* the soft shadow the front card casts on the panel */
.wallet__floor {
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: calc(var(--cw) * 0.82);
  height: 14px;
  margin-left: calc(var(--cw) * -0.41);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.85), transparent);
  filter: blur(4px);
}

.cc {
  position: absolute;
  left: calc(50% - var(--cw) / 2);
  top: calc(var(--peek) * 2);
  width: var(--cw);
  height: var(--ch);
  border-radius: calc(var(--ch) * 0.1);
}

.cc__body {
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.cc__dim {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: #050506;
  opacity: 0;
  pointer-events: none;
}

.cc__face {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  overflow: hidden;
  font-size: calc(var(--ch) * 0.105);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.32),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.35),
    0 2px 3px rgba(0, 0, 0, 0.5),
    0 14px 26px -12px rgba(0, 0, 0, 0.9);
}

/* the three materials, also used by the small thumbnails in the rows */
.cc--graphite {
  color: #e9e9ee;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.022) 0 1px, transparent 1px 3px),
    radial-gradient(120% 90% at 0% 0%, rgba(255, 255, 255, 0.12), transparent 55%),
    linear-gradient(135deg, color-mix(in srgb, var(--graphite) 80%, #ffffff), var(--graphite) 45%, color-mix(in srgb, var(--graphite) 55%, #000000));
}

.cc--copper {
  color: #2a170c;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 3px),
    radial-gradient(120% 90% at 0% 0%, rgba(255, 244, 228, 0.55), transparent 55%),
    linear-gradient(135deg, color-mix(in srgb, var(--copper) 55%, #ffffff), var(--copper) 45%, color-mix(in srgb, var(--copper) 55%, #000000));
}

.cc--halo {
  color: #f1f0ff;
  background:
    radial-gradient(80% 120% at 100% 0%, rgba(160, 230, 255, 0.45), transparent 55%),
    radial-gradient(90% 90% at 0% 100%, rgba(255, 140, 220, 0.35), transparent 60%),
    linear-gradient(140deg, color-mix(in srgb, var(--halo) 80%, #ffffff), var(--halo) 40%, color-mix(in srgb, var(--halo) 30%, #000000));
}

.cc__brand {
  position: absolute;
  left: 8%;
  top: 11%;
  font-weight: 640;
  font-variation-settings: 'wdth' 112;
  letter-spacing: 0.02em;
}

.cc__mark {
  position: absolute;
  right: 7%;
  top: 10%;
  width: 15%;
  fill: currentColor;
  opacity: 0.85;
}

.cc__chip {
  position: absolute;
  left: 8%;
  top: 38%;
  width: 15%;
  fill: none;
  stroke: rgba(70, 48, 10, 0.5);
  stroke-width: 1;
}

.cc__chip rect {
  fill: #d9b46a;
}

.cc--copper .cc__chip rect {
  fill: #e9cf9b;
}

.cc--halo .cc__chip {
  display: none;
}

.cc__face-id {
  position: absolute;
  left: 8%;
  top: 36%;
  width: 14%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.9;
}

.cc__waves {
  position: absolute;
  left: 27%;
  top: 40%;
  width: 7%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.cc__waves path {
  opacity: 0.45;
}

.cc__holder {
  position: absolute;
  left: 8%;
  bottom: 11%;
  font-size: 0.82em;
  font-weight: 500;
  letter-spacing: 0.04em;
  opacity: 0.8;
}

.cc__digits {
  position: absolute;
  right: 7%;
  bottom: 10%;
  font-size: 1.05em;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}

.cc__digits--word {
  font-size: 0.86em;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* the light on the metal: a soft band whose place (--sx, in %) follows the pointer */
.cc__sheen {
  --sx: 30;
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent calc(var(--sx) * 1% - 34%), rgba(255, 255, 255, 0.5) calc(var(--sx) * 1%), transparent calc(var(--sx) * 1% + 34%));
  mix-blend-mode: soft-light;
  opacity: 0.6;
  pointer-events: none;
}

/* ---------- the rows ---------- */

.methods {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 2px;
}

.methods__pill {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 0;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.025)),
    color-mix(in srgb, var(--tint) 14%, transparent);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 0 0 1px color-mix(in srgb, var(--tint) 45%, rgba(255, 255, 255, 0.08)),
    0 6px 16px -8px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

.method {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  height: clamp(36px, 10vh, 50px);
  padding: 0 10px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.method:focus-visible {
  outline: 2px solid var(--light);
  outline-offset: 1px;
}

.method__thumb {
  flex: none;
  width: 30px;
  height: 20px;
  border-radius: 4px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 2px 4px rgba(0, 0, 0, 0.5);
}

.method__text {
  display: grid;
  gap: 1px;
  min-width: 0;
  flex: 1;
}

.method__name {
  font-size: 13.5px;
  font-weight: 560;
  white-space: nowrap;
}

.method__sub {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.method__tick {
  flex: none;
  width: 18px;
  height: 18px;
}

.method__tick svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.tick__ring {
  fill: none;
  stroke: rgba(255, 255, 255, 0.2);
  stroke-width: 1.2;
}

.tick__fill {
  fill: var(--ink);
}

.tick__check {
  fill: none;
  stroke: var(--button-ink);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

@media (hover: hover) {
  .method:hover .tick__ring {
    stroke: rgba(255, 255, 255, 0.4);
  }
}

/* ---------- the Pay button ---------- */

.paybtn {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: clamp(40px, 11vh, 48px);
  margin-top: clamp(10px, 2.8vh, 16px);
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.paybtn:focus-visible {
  outline: 2px solid var(--light);
  outline-offset: 3px;
}

/* a beam of light running round the button while it works: a conic gradient turned by --a */
.paybtn__beam {
  --a: 0deg;
  position: absolute;
  inset: -1.5px;
  border-radius: 15.5px;
  background: conic-gradient(from var(--a), transparent 0deg, transparent 250deg, color-mix(in srgb, var(--light) 80%, #ffffff) 330deg, #ffffff 352deg, transparent 360deg);
  opacity: 0;
}

.paybtn__face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffffff, var(--button));
  color: var(--button-ink);
  box-shadow:
    inset 0 1px 0 #ffffff,
    inset 0 -1px 0 rgba(0, 0, 0, 0.12),
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 10px 24px -10px color-mix(in srgb, var(--tint) 70%, transparent);
  overflow: hidden;
}

.paybtn__label {
  grid-area: 1 / 1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 600;
  font-variation-settings: 'wdth' 104;
  font-variant-numeric: tabular-nums;
}

.paybtn__label[data-label='busy'],
.paybtn__label[data-label='done'] {
  opacity: 0;
}

.paybtn__icon {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.paybtn__icon--done path {
  stroke-width: 2;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

/* the word shimmers while it waits */
.paybtn__shimmer {
  background: linear-gradient(90deg, var(--button-ink) 0%, var(--button-ink) 40%, #9a9aa3 50%, var(--button-ink) 60%, var(--button-ink) 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 1.3s linear infinite;
}

@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: -150% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .paybtn__shimmer {
    animation: none;
    color: var(--button-ink);
  }
}
