:root {
  --fondo: #ffffff;
  --testo: #0f0f10;
  --grigio: #71717a;
  --linea: rgba(15, 15, 16, 0.1);
  --campo: #fafafa;
  --accento: #4f46e5;
  --errore: #dc2626;
  --carta-1: #1d1b2e;
  --carta-2: #2f2a52;
  --carta-3: #121117;
  --carta-testo: #f4f3fb;
  --chip: #d9c58f;
  --pulsante: #0f0f10;
  --pagato: #15803d;
  --w: min(380px, 88vw);
  --cw: min(340px, 80vw, calc(36vh * 1.586));
}

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

html, body { height: 100%; }

body {
  background: var(--fondo);
  color: var(--testo);
  font-family: "Mona Sans Variable", "Mona Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.stage {
  position: relative;
  min-height: 100vh;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: min(3vh, 20px) 16px;
}

.pay {
  width: var(--w);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: min(3.4vh, 22px);
}

/* ---------- the card ---------- */

.scene {
  position: relative;
  width: var(--cw);
  aspect-ratio: 1.586;
  perspective: 1100px;
}

.card {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  will-change: transform;
}

.face {
  position: absolute;
  inset: 0;
  border-radius: calc(var(--cw) * 0.055);
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  color: var(--carta-testo);
  background:
    radial-gradient(120% 90% at 85% 0%, rgba(124, 116, 255, 0.45), transparent 60%),
    radial-gradient(90% 80% at 0% 100%, rgba(255, 255, 255, 0.07), transparent 70%),
    linear-gradient(135deg, var(--carta-2), var(--carta-1) 55%, var(--carta-3));
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.09),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.face--front {
  padding: calc(var(--cw) * 0.065) calc(var(--cw) * 0.07);
  display: flex;
  flex-direction: column;
}

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

.glare {
  position: absolute;
  inset: -40%;
  background: radial-gradient(closest-side, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0) 70%);
  transform: translate(var(--gx, 30%), var(--gy, -20%));
  pointer-events: none;
  mix-blend-mode: screen;
}

.front__top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.bank {
  font-size: calc(var(--cw) * 0.052);
  font-weight: 640;
  font-stretch: 112%;
  letter-spacing: 0.02em;
}

.wave {
  width: calc(var(--cw) * 0.07);
  height: calc(var(--cw) * 0.07);
  fill: none;
  stroke: rgba(244, 243, 251, 0.7);
  stroke-width: 1.6;
  stroke-linecap: round;
}

.chip {
  position: relative;
  margin-top: calc(var(--cw) * 0.07);
  width: calc(var(--cw) * 0.13);
  aspect-ratio: 1.3;
  border-radius: calc(var(--cw) * 0.016);
  background: linear-gradient(135deg, #efe2b5, var(--chip) 45%, #b39b5c);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
  overflow: hidden;
}
.chip i {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: rgba(70, 55, 20, 0.35);
}
.chip i:nth-child(1) { top: 33%; }
.chip i:nth-child(2) { top: 66%; }
.chip i:nth-child(3) { top: 0; bottom: 0; left: 50%; right: auto; width: 1px; height: auto; }

.num {
  margin-top: auto;
  display: flex;
  gap: calc(var(--cw) * 0.045);
  font-size: calc(var(--cw) * 0.074);
  font-weight: 520;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  line-height: 1;
}

.grp { display: flex; }

.slot {
  position: relative;
  display: inline-block;
  width: 0.64em;
  height: 1.15em;
  overflow: hidden;
}

.slot b,
.slot s {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: inherit;
  text-decoration: none;
}

.slot s { color: rgba(244, 243, 251, 0.24); }

.front__bottom {
  margin-top: calc(var(--cw) * 0.06);
  display: flex;
  align-items: flex-end;
  gap: calc(var(--cw) * 0.07);
}

.field-on-card { display: flex; flex-direction: column; gap: calc(var(--cw) * 0.012); min-width: 0; }
.field-on-card[data-on="name"] { flex: 1; }

.tiny {
  font-size: calc(var(--cw) * 0.03);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(244, 243, 251, 0.55);
}

.holder,
.exp {
  font-size: calc(var(--cw) * 0.046);
  font-weight: 560;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  font-variant-numeric: tabular-nums;
  height: 1.2em;
  display: flex;
}

.holder.is-empty { color: rgba(244, 243, 251, 0.34); }

.exp .slot { width: 0.62em; height: 1.2em; }
.exp .sep { opacity: 0.6; padding: 0 0.04em; }

.ch { display: inline-block; white-space: pre; }

.mark {
  width: calc(var(--cw) * 0.12);
  height: auto;
  fill: rgba(244, 243, 251, 0.82);
  flex: none;
}

.band {
  position: absolute;
  left: 0;
  right: 0;
  top: 13%;
  height: 20%;
  background: linear-gradient(180deg, #08080b, #19181f);
}

.sign {
  position: absolute;
  left: 7%;
  right: 7%;
  top: 44%;
  height: 16%;
  display: flex;
  align-items: center;
  gap: 4%;
}

.sign__strip {
  flex: 1;
  height: 100%;
  border-radius: 4px;
  background: repeating-linear-gradient(135deg, #f4f1e6 0 6px, #e7e2d0 6px 12px);
}

.cvc {
  min-width: 22%;
  height: 100%;
  border-radius: 4px;
  background: #ffffff;
  color: #18181b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(var(--cw) * 0.05);
  font-weight: 620;
  font-style: italic;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
}

.cvc .slot { width: 0.66em; }
.cvc .slot s { color: rgba(24, 24, 27, 0.22); }

.back__note {
  position: absolute;
  left: 7%;
  right: 7%;
  bottom: 9%;
  font-size: calc(var(--cw) * 0.028);
  line-height: 1.45;
  color: rgba(244, 243, 251, 0.5);
}

.focusbox {
  position: absolute;
  left: 0;
  top: 0;
  width: 10px;
  height: 10px;
  border-radius: 8px;
  border: 1.5px solid rgba(190, 186, 255, 0.85);
  box-shadow: 0 0 0 4px rgba(124, 116, 255, 0.14);
  opacity: 0;
  pointer-events: none;
  transform: translateZ(1px);
}

.shadow {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -9%;
  height: 22%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(30, 27, 60, 0.32), rgba(30, 27, 60, 0));
  filter: blur(6px);
  z-index: -1;
  pointer-events: none;
}

/* ---------- the form ---------- */

.form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: min(1.4vh, 9px);
}

.row { display: flex; gap: min(1.4vh, 9px); }

.in {
  position: relative;
  display: block;
  flex: 1;
  min-width: 0;
  height: clamp(40px, 9.4vh, 50px);
  border-radius: 12px;
  background: var(--campo);
  box-shadow: inset 0 0 0 1px var(--linea);
  transition: box-shadow 0.2s, background-color 0.2s;
  cursor: text;
}

.in--wide { flex: none; }

.in--cvc { flex: 0.8; }

.in.is-focus {
  background: #ffffff;
  box-shadow: inset 0 0 0 1.5px var(--accento), 0 0 0 4px rgba(79, 70, 229, 0.12);
}

.in.is-bad {
  box-shadow: inset 0 0 0 1.5px var(--errore), 0 0 0 4px rgba(220, 38, 38, 0.1);
}

.in.is-good:not(.is-focus) { box-shadow: inset 0 0 0 1px rgba(15, 15, 16, 0.16); }

.in__label {
  position: absolute;
  left: 12px;
  top: 7px;
  font-size: 10.5px;
  font-weight: 560;
  letter-spacing: 0.02em;
  color: var(--grigio);
  pointer-events: none;
  white-space: nowrap;
}

.in.is-bad .in__label { color: var(--errore); }

.in input {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  padding: 18px 12px 0;
  font: inherit;
  font-size: clamp(13px, 3.4vh, 15px);
  font-weight: 520;
  color: var(--testo);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.in input::placeholder { color: rgba(15, 15, 16, 0.28); }

.paybtn {
  position: relative;
  flex: 0.9;
  min-width: 0;
  height: clamp(40px, 9.4vh, 50px);
  border: 0;
  border-radius: 12px;
  background: #e4e4e7;
  color: #a1a1aa;
  font: inherit;
  font-size: 14px;
  font-weight: 640;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: not-allowed;
  isolation: isolate;
}

.paybtn__fill {
  position: absolute;
  inset: 0;
  background: var(--pulsante);
  transform-origin: 0 50%;
  transform: scaleX(0);
  z-index: -1;
}

.paybtn.is-on { color: #ffffff; cursor: pointer; }

.paybtn__ring,
.paybtn__check {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: #ffffff;
  stroke-width: 2;
  stroke-linecap: round;
  display: none;
}

.paybtn__ring circle { stroke-dasharray: 30 50; }

.paybtn__check path { stroke-dasharray: 1; stroke-dashoffset: 1; stroke-linejoin: round; }

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

/* the fake pointer of the autopilot */
.ghost {
  position: absolute;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  fill: #111;
  stroke: #fff;
  stroke-width: 1.4;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.25));
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}

@media (max-height: 520px) {
  .in__label { top: 4px; font-size: 9.5px; }
  .in input { padding-top: 13px; }
}
