/* The card field: the card fields of a checkout on a white page, with the card above them. The fields are soft
   grey and turn white with an ink ring; the card takes the material of its network: brushed graphite, ink blue,
   verdigris or garnet, and pale unprinted plastic until the first figures say which. */
:root {
  --page: #ffffff;          /* the page */
  --ink: #16171b;           /* the words, the ring of the field being typed in, the button */
  --muted: #6c6e77;         /* the labels and the line under the fields */
  --field: #f4f3f1;         /* a field at rest */
  --line: #e2e0db;          /* the edge of a field */
  --wrong: #d3443b;         /* an error */
  --right: #1e9a55;         /* a number that adds up, and a payment approved */
  --blank-a: #eeede9;       /* the card before the network is known */
  --blank-b: #d6d3cb;
  --orbit-a: #3a3d44;       /* Orbit: brushed graphite */
  --orbit-b: #191a1e;
  --strata-a: #2a4fb0;      /* Strata: ink blue */
  --strata-b: #0f1f58;
  --atrium-a: #4b8571;      /* Atrium: verdigris */
  --atrium-b: #1c3f33;
  --kite-a: #8f2d52;        /* Kite: garnet */
  --kite-b: #3a0c22;
  --silver: #e3e6eb;        /* the foil on the embossed figures of Orbit and Atrium */
  --gold: #ecca7e;          /* and of Strata and Kite */
  --graphite: #45484f;      /* and of the card before the network is known */
  --print: rgba(255, 255, 255, 0.62); /* what is printed on a dark card */
}

* {
  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: 'Hubot Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 36px 16px;
}

.pay {
  width: min(400px, 100%);
  margin: 0;
}

/* ---------------------------------------------------------------- the card */
.pay__card {
  position: relative;
  margin: 0 0 30px;
  perspective: 1300px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* its shadow on the page: the script moves it away from the lamp */
.card__shadow {
  position: absolute;
  left: 7%;
  right: 7%;
  bottom: 2%;
  height: 26%;
  border-radius: 50%;
  background: rgba(22, 23, 27, 0.5);
  filter: blur(18px);
  opacity: 0.75;
  pointer-events: none;
}

.card {
  position: relative;
  width: 100%;
  aspect-ratio: 428 / 270;
  transform-style: preserve-3d;
  will-change: transform;
}

.card__face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 3.9% / 6.2%;
  background: var(--blank-b);
  box-shadow: 0 1px 1px rgba(22, 23, 27, 0.1), 0 0 0 0.5px rgba(22, 23, 27, 0.12);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  isolation: isolate;
}

.card__face--back {
  transform: rotateY(180deg);
}

/* the materials, one layer each: the script uncovers the new one behind a band of light */
.card__mats,
.mat {
  position: absolute;
  inset: 0;
}

.mat {
  opacity: 0;
}

.mat.is-on {
  opacity: 1;
}

.mat canvas,
.mat svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.mat--blank {
  background:
    radial-gradient(120% 90% at 20% 0%, rgba(255, 255, 255, 0.7), transparent 60%),
    linear-gradient(135deg, var(--blank-a), var(--blank-b));
}

.mat--orbit {
  background: linear-gradient(135deg, var(--orbit-a), var(--orbit-b));
}

.mat--orbit canvas {
  mix-blend-mode: overlay;
}

.mat--strata {
  background:
    radial-gradient(90% 120% at 100% 100%, rgba(120, 170, 255, 0.28), transparent 60%),
    linear-gradient(135deg, var(--strata-a), var(--strata-b));
}

.mat--atrium {
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.055) 0 1px, transparent 1px 7px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.055) 0 1px, transparent 1px 7px),
    radial-gradient(100% 120% at 0% 0%, rgba(190, 255, 225, 0.22), transparent 60%),
    linear-gradient(135deg, var(--atrium-a), var(--atrium-b));
}

.mat--kite {
  background:
    conic-gradient(from 200deg at 70% 30%, rgba(255, 200, 220, 0.16), rgba(160, 200, 255, 0.12), rgba(255, 230, 190, 0.16), rgba(255, 200, 220, 0.16)),
    radial-gradient(80% 100% at 85% 10%, rgba(255, 180, 210, 0.3), transparent 60%),
    linear-gradient(135deg, var(--kite-a), var(--kite-b));
}

/* the pool of the lamp on the material, and the band of light that changes the material */
.card__lamp,
.card__glint {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.card__lamp {
  --lx: 20%;
  --ly: 8%;
  --pool: 0.5;
  background: radial-gradient(var(--pw, 46%) var(--ph, 70%) at var(--lx) var(--ly), rgba(255, 255, 255, calc(var(--pool) * 0.5)), rgba(255, 255, 255, 0) 100%);
  mix-blend-mode: soft-light;
}

/* the unprinted plastic is pearly: where the lamp shines it turns through soft colours */
.card[data-net='blank'] .card__lamp {
  background:
    radial-gradient(var(--pw, 46%) var(--ph, 70%) at var(--lx) var(--ly), rgba(255, 255, 255, calc(var(--pool) * 0.55)), rgba(255, 255, 255, 0) 100%),
    conic-gradient(from 40deg at var(--lx) var(--ly), #ffd9ea, #d4f1ff, #e4dbff, #fff0c4, #d9ffe9, #ffd9ea);
  -webkit-mask-image: radial-gradient(calc(var(--pw, 46%) * 1.3) calc(var(--ph, 70%) * 1.2) at var(--lx) var(--ly), rgba(0, 0, 0, 0.8), transparent 100%);
  mask-image: radial-gradient(calc(var(--pw, 46%) * 1.3) calc(var(--ph, 70%) * 1.2) at var(--lx) var(--ly), rgba(0, 0, 0, 0.8), transparent 100%);
  mix-blend-mode: multiply;
  opacity: 0.8;
}

/* brushed metal throws the lamp back as a streak across its grain */
.card[data-net='orbit'] .card__lamp {
  background:
    radial-gradient(6% 100% at var(--lx) var(--ly), rgba(255, 255, 255, calc(var(--pool) * 0.2)), rgba(255, 255, 255, 0) 100%),
    radial-gradient(var(--pw, 46%) var(--ph, 70%) at var(--lx) var(--ly), rgba(255, 255, 255, calc(var(--pool) * 0.3)), rgba(255, 255, 255, 0) 100%);
  mix-blend-mode: screen;
}

.card__glint {
  --gx: -40%;
  background: linear-gradient(105deg, transparent calc(var(--gx) - 16%), rgba(255, 255, 255, 0.42) var(--gx), transparent calc(var(--gx) + 16%));
  mix-blend-mode: overlay;
  opacity: 0;
}

/* the plastic's edge catches the light: a bevel over everything */
.card__face::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), inset 0 -1px 0 rgba(0, 0, 0, 0.18), inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  pointer-events: none;
}

.card.is-blank .card__face::after {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), inset 0 -1px 0 rgba(22, 23, 27, 0.08);
}

.card__art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* the chip */
.chip__lines {
  fill: none;
  stroke: rgba(92, 64, 20, 0.55);
  stroke-width: 1.1;
}

/* what is printed, not embossed (the words of the date show with the date) */
.card__print {
  opacity: 0;
}

.card__print text {
  fill: var(--print);
  font: 650 6.4px 'Hubot Sans Variable', sans-serif;
  letter-spacing: 0.06em;
}

.card.is-blank .card__print text {
  fill: rgba(22, 23, 27, 0.45);
}

.card__frontcode {
  fill: var(--print);
  font: 500 11px 'Martian Mono Variable', monospace;
  letter-spacing: 0.08em;
}

/* the embossed figures and letters: Martian Mono, struck one by one by the script (which also narrows them) */
.card__relief {
  fill: var(--graphite);
  font-family: 'Martian Mono Variable', monospace;
  font-weight: 480;
}

.card__number {
  font-size: 26px;
}

.card__exp,
.card__name {
  font-size: 15.5px;
}

/* the network marks: an emblem and a word */
.card__marks text {
  font: 700 15px 'Hubot Sans Variable', sans-serif;
  font-stretch: 118%;
  letter-spacing: 0.01em;
}

.card__marks path,
.card__marks circle,
.card__marks rect {
  vector-effect: non-scaling-stroke;
}

.mark {
  opacity: 0;
}

.tint--silver {
  color: var(--silver);
}

.tint--gold {
  color: var(--gold);
}

.tint--graphite {
  color: var(--graphite);
}

/* the back */
.card__codebox {
  fill: #ffffff;
}

.card__code text {
  fill: #1d1e22;
  font: 500 15px 'Martian Mono Variable', monospace;
}

.card__small text {
  fill: var(--print);
  font: 450 7.6px 'Hubot Sans Variable', sans-serif;
  letter-spacing: 0.01em;
}

.card.is-blank .card__small text {
  fill: rgba(22, 23, 27, 0.5);
}

/* ---------------------------------------------------------------- the fields */
.pay__fields {
  display: grid;
  gap: 12px;
}

.pay__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
}

.field {
  position: relative;
  height: 60px;
  border-radius: 16px;
  background: var(--field);
  box-shadow: inset 0 0 0 1px var(--line), 0 0 0 0 rgba(22, 23, 27, 0);
  transition: background-color 0.2s ease, box-shadow 0.25s ease;
}

@media (hover: hover) and (pointer: fine) {
  .field:hover {
    background: #efeeeb;
  }
}

.field.is-on,
.field.is-pretend {
  background: #ffffff;
  box-shadow: inset 0 0 0 1.5px var(--ink), 0 0 0 5px rgba(22, 23, 27, 0.07);
}

.field.is-wrong {
  background: #fdf3f2;
  box-shadow: inset 0 0 0 1.5px var(--wrong), 0 0 0 5px rgba(211, 68, 59, 0.12);
}

.field.is-done {
  background: #f8f8f6;
}

.field__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 23px 16px 0;
  border: 0;
  border-radius: inherit;
  outline: none;
  background: transparent;
  color: var(--ink);
  caret-color: var(--ink);
  font: 520 17px/1.2 'Hubot Sans Variable', system-ui, sans-serif;
  letter-spacing: 0;
  -webkit-tap-highlight-color: transparent;
}

.field__input--mono {
  font: 450 16.5px/1.2 'Martian Mono Variable', ui-monospace, monospace;
  font-stretch: 92%;
  letter-spacing: 0.01em;
}

.field--number .field__input {
  padding-right: 92px;
}

.field--code .field__input {
  padding-right: 54px;
}

.field__input::placeholder {
  color: #a3a5ac;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.field.is-on .field__input::placeholder {
  opacity: 1;
}

/* the browser's autofill paints the field: back to the field's own colours */
.field__input:-webkit-autofill {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 60px #ffffff inset;
  caret-color: var(--ink);
}

/* the label sits in the middle like a placeholder, and floats to the top when the field is in use */
.field__label {
  position: absolute;
  left: 16px;
  top: 11px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 560;
  line-height: 16px;
  white-space: nowrap;
  text-overflow: ellipsis;
  transform-origin: 0 0;
  transform: translateY(11px) scale(1.26);
  pointer-events: none;
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), color 0.2s ease;
}

.field.is-on .field__label,
.field.is-pretend .field__label,
.field.is-filled .field__label {
  transform: none;
}

/* the label never runs under the badge or the hint: bigger in the middle, it gets less room */
.field__label {
  --room: 32px;
  max-width: calc((100% - var(--room)) / 1.26);
}

.field--number .field__label {
  --room: 74px;
}

.field--code .field__label {
  --room: 64px;
}

.field.is-on .field__label,
.field.is-pretend .field__label,
.field.is-filled .field__label {
  max-width: calc(100% - var(--room));
}

.field.is-wrong .field__label {
  color: var(--wrong);
}

/* the tick after a number that adds up */
.field__tick {
  position: absolute;
  right: 62px;
  top: 50%;
  width: 20px;
  height: 20px;
  margin-top: -10px;
  overflow: visible;
  pointer-events: none;
}

.field__tick path {
  fill: none;
  stroke: var(--right);
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}

/* the network, as a small card at the end of the number field */
.field__badge {
  position: absolute;
  right: 14px;
  top: 50%;
  width: 38px;
  height: 25px;
  margin-top: -12.5px;
  pointer-events: none;
}

.badge {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 5px;
  opacity: 0;
}

.badge svg {
  width: 17px;
  height: 17px;
  overflow: visible;
}

.badge--blank {
  box-shadow: inset 0 0 0 1.5px #c9c7c1;
}

.badge--blank svg {
  width: 38px;
  height: 25px;
}

.badge--blank path {
  fill: none;
  stroke: #c9c7c1;
  stroke-width: 1.5;
}

/* the hint of where the security code is: the back of a card, or the front for the cards that print it there */
.field__hint {
  position: absolute;
  right: 14px;
  top: 50%;
  width: 30px;
  height: 20px;
  margin-top: -10px;
  perspective: 120px;
  pointer-events: none;
}

.hint__card {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}

.hint__side {
  position: absolute;
  inset: 0;
  width: 30px;
  height: 20px;
  overflow: visible;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.hint__side--front {
  transform: rotateY(180deg);
}

.hint__side rect:first-child {
  fill: none;
  stroke: #a9abb2;
  stroke-width: 1.5;
}

.hint__stripe {
  fill: #a9abb2;
}

.hint__line {
  fill: none;
  stroke: #c3c5cb;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.hint__box {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.5;
}

.hint__box {
  transition: fill 0.2s ease;
}

.field.is-on .hint__box,
.field.is-pretend .hint__box {
  fill: var(--ink);
}

/* ---------------------------------------------------------------- the line under the fields */
.pay__note {
  position: relative;
  min-height: 20px;
  margin: 14px 4px 0;
  font-size: 14px;
  line-height: 20px;
  color: var(--muted);
}

.note__line {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.note__line.is-going {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  pointer-events: none;
}

.note__line svg {
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.note__line.is-wrong {
  color: var(--wrong);
}

.note__line.is-right {
  color: var(--ink);
}

.note__line.is-right svg {
  color: var(--right);
}

/* ---------------------------------------------------------------- the button: the label widens and the colour
   swells under the pointer, so nothing round it moves */
.go {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
  width: 100%;
  height: 60px;
  margin: 18px 0 0;
  padding: 0 24px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #ffffff;
  font: 640 17px/1 'Hubot Sans Variable', system-ui, sans-serif;
  letter-spacing: 0.005em;
  cursor: pointer;
  isolation: isolate;
  -webkit-tap-highlight-color: transparent;
}

.go > :not(.go__bg) {
  grid-area: 1 / 1;
}

.go__bg {
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 10px 22px -12px rgba(22, 23, 27, 0.6);
  transition: inset 0.6s cubic-bezier(0.3, 1.7, 0.45, 1), transform 0.16s ease-out, background-color 0.35s ease;
}

.go__label {
  display: block;
  font-stretch: 100%;
  white-space: nowrap;
  transition: font-stretch 0.6s cubic-bezier(0.3, 1.7, 0.45, 1);
}

@media (hover: hover) and (pointer: fine) {
  .go:not([aria-disabled='true']):hover .go__bg {
    inset: -2px -7px;
  }

  .go:not([aria-disabled='true']):hover .go__label {
    font-stretch: 125%;
  }
}

.go:not([aria-disabled='true']):active .go__bg {
  transform: scale(0.97);
}

.go[aria-disabled='true'] {
  cursor: default;
}

.go.is-paid .go__bg {
  background: var(--right);
}

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

/* waiting for the bank, and paid */
.go__state {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
  opacity: 0;
}

.go__state svg {
  flex: none;
  width: 22px;
  height: 22px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.go__spin {
  stroke-width: 2.4;
  stroke-dasharray: 34 60;
}

.go__tick {
  stroke-width: 2.6;
}

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

@media (max-width: 440px) {
  .pay__card {
    margin-bottom: 26px;
  }

  .field__input--mono {
    font-size: 16px;
  }
}
