/* The gift card field that reveals the balance: the gift card step of a checkout on a soft warm page with a fine
   grain. Above, the card: dark glass with three slow lights inside (the aurora), a grain of its own, a light band that
   travels across it as the code fills, and a one pixel edge brighter at the top. Below, a white panel with the field:
   sixteen slots in four groups, a caret that slides on a spring, the Redeem button, the message and the store credit.
   GSAP moves the outer elements (.gift, the slots' characters), CSS styles their children. */
:root {
  --page: #ecebe6;            /* the page */
  --page-light: #f8f7f3;      /* the soft light on the page */
  --card: #18161d;            /* the glass of the card */
  --card-low: #0e0d11;        /* the glass of the card, bottom */
  --glow-a: #ff8a4c;          /* the first light inside the card: apricot */
  --glow-b: #a58bff;          /* the second light: lilac */
  --card-ink: #f5f3ee;        /* the words on the card */
  --panel: #ffffff;           /* the panel of the field */
  --box: #f6f5f2;             /* the field */
  --ink: #17151c;             /* the words */
  --muted: #8a8791;           /* the small words */
  --line: rgba(23, 21, 28, 0.09); /* the thin lines */
  --accent: #ff7a3d;          /* the focus: apricot */
  --ok: #129a5c;              /* redeemed */
  --err: #e0473f;             /* the error */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background:
    radial-gradient(60% 50% at 50% 38%, var(--page-light), transparent 72%),
    var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* the grain over the page */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.08;
  mix-blend-mode: multiply;
  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.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

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

.redeem {
  --w: min(88vw, 360px, calc((100vh - 196px) * 1.7));
  position: relative;
  width: var(--w);
  display: grid;
  gap: clamp(10px, 2.2vh, 16px);
  opacity: 0;
}

/* ---------------------------------------------------------------- the card */
.gift {
  position: relative;
  width: 86%;
  justify-self: center;
  z-index: 2;
}

/* the coloured shadow under the card, under the black one */
.gift::before {
  content: '';
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: -8%;
  height: 40%;
  border-radius: 50%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--glow-a) 45%, transparent), transparent);
  filter: blur(18px);
  opacity: var(--halo, 0.5);
  pointer-events: none;
}

.gift__body {
  --sx: -40%;
  --lit: 0.35;
  position: relative;
  aspect-ratio: 1.586;
  border-radius: clamp(12px, 3.6vw, 16px);
  overflow: hidden;
  color: var(--card-ink);
  background: linear-gradient(160deg, var(--card), var(--card-low));
  box-shadow:
    0 1px 1px rgba(16, 14, 20, 0.18),
    0 4px 8px -2px rgba(16, 14, 20, 0.22),
    0 18px 30px -12px rgba(16, 14, 20, 0.45),
    0 40px 60px -30px rgba(16, 14, 20, 0.55);
  padding: clamp(12px, 3.6vw, 18px) clamp(14px, 4.2vw, 20px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  isolation: isolate;
}

.gift__aurora {
  position: absolute;
  inset: 0;
  z-index: -3;
  filter: blur(min(28px, 7vw));
  opacity: 0.62;
}

.gift__blob {
  position: absolute;
  border-radius: 50%;
}

.gift__blob--a {
  width: 72%;
  height: 92%;
  left: -18%;
  top: 30%;
  background: radial-gradient(closest-side, var(--glow-a), transparent);
}

.gift__blob--b {
  width: 70%;
  height: 90%;
  right: -16%;
  top: -34%;
  background: radial-gradient(closest-side, var(--glow-b), transparent);
}

.gift__blob--c {
  width: 40%;
  height: 50%;
  left: 40%;
  top: 46%;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--glow-a) 50%, var(--glow-b)), transparent);
  opacity: 0.6;
}

/* the frost and grain of the glass */
.gift__grain {
  position: absolute;
  inset: 0;
  z-index: -2;
  opacity: 0.22;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.1' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* the light band: a soft diagonal streak moved by --sx */
.gift__sheen {
  position: absolute;
  inset: -20% -60%;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(105deg, transparent calc(50% - 14%), rgba(255, 255, 255, 0.04) calc(50% - 7%), rgba(255, 255, 255, 0.16) 50%, rgba(255, 255, 255, 0.04) calc(50% + 7%), transparent calc(50% + 14%));
  transform: translateX(var(--sx));
  mix-blend-mode: screen;
}

/* the one pixel edge: brighter at the top, catching the band where it passes */
.gift__edge {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, calc(var(--lit) * 0.9)), rgba(255, 255, 255, 0.04) 40%, rgba(255, 255, 255, 0.08)),
    linear-gradient(105deg, transparent calc(50% + var(--sx) * 0.62 - 10%), rgba(255, 255, 255, 0.5) calc(50% + var(--sx) * 0.62), transparent calc(50% + var(--sx) * 0.62 + 10%));
  -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);
}

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

.gift__brand {
  font-size: clamp(13px, 3.8vw, 15px);
  font-weight: 640;
  font-variation-settings: 'wdth' 112;
  letter-spacing: 0.01em;
}

.gift__kind {
  font-size: 11px;
  font-weight: 500;
  color: rgba(245, 243, 238, 0.6);
  letter-spacing: 0.02em;
}

.gift__code {
  align-self: center;
  display: flex;
  gap: clamp(9px, 3.2vw, 14px);
  font-family: 'Geist Mono Variable', ui-monospace, monospace;
  font-size: clamp(14px, 4.6vw, 18px);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.cgrp {
  display: flex;
}

.cslot {
  position: relative;
  width: 0.66em;
  height: 1.3em;
  display: grid;
  place-items: center;
}

.cslot__line {
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: 0.12em;
  height: 1px;
  background: rgba(245, 243, 238, 0.26);
}

.cslot__ch {
  display: block;
  line-height: 1;
}

.gift__foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}

.gift__value {
  display: grid;
  gap: 2px;
}

.gift__label {
  font-size: 10.5px;
  font-weight: 500;
  color: rgba(245, 243, 238, 0.55);
  letter-spacing: 0.04em;
}

.gift__amount {
  display: block;
  font-size: clamp(20px, 6.4vw, 26px);
  line-height: 1;
  font-weight: 600;
  font-variation-settings: 'wdth' 100;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  filter: blur(var(--blur, 6px));
  opacity: var(--veil, 0.6);
}

.gift__stamp {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 9px 0 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  color: #e9fff3;
  background: color-mix(in srgb, var(--ok) 42%, transparent);
  box-shadow: inset 0 0 0 1px rgba(160, 255, 200, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  opacity: 0;
}

.gift__stamp svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gift__stamp path {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

/* ---------------------------------------------------------------- the panel */
.panel {
  position: relative;
  margin: 0;
  padding: clamp(12px, 2.6vh, 16px) clamp(12px, 3.6vw, 16px) clamp(10px, 2.2vh, 14px);
  border-radius: 18px;
  background: var(--panel);
  box-shadow:
    0 0 0 1px rgba(23, 21, 28, 0.06),
    0 1px 2px rgba(23, 21, 28, 0.06),
    0 8px 18px -8px rgba(23, 21, 28, 0.14),
    0 28px 50px -28px rgba(23, 21, 28, 0.24);
}

.panel__label {
  display: block;
  font-size: 12.5px;
  font-weight: 560;
  color: var(--ink);
  margin: 0 0 7px 2px;
}

.box {
  --c: var(--accent);
  position: relative;
  height: clamp(44px, 9vh, 50px);
  border-radius: 12px;
  background: var(--box);
  box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 2px rgba(23, 21, 28, 0.05);
  display: flex;
  align-items: center;
  padding: 0 5px 0 clamp(10px, 3vw, 14px);
  cursor: text;
}

/* the focus ring: one pixel of colour and a soft halo, faded in by GSAP */
.box__ring {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px var(--c), 0 0 0 4px color-mix(in srgb, var(--c) 16%, transparent);
  opacity: 0;
}

/* a faint light running along the field while the code is checked */
.box__scan {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  overflow: hidden;
  opacity: 0;
}

.box__scan::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--scan, -30%);
  width: 30%;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 14%, transparent), transparent);
}

.box__slots {
  position: relative;
  flex: 1;
  display: flex;
  gap: clamp(6px, 2.2vw, 10px);
  font-family: 'Geist Mono Variable', ui-monospace, monospace;
  font-size: clamp(14px, 4.2vw, 16.5px);
  font-weight: 520;
  color: var(--ink);
  min-width: 0;
}

.grp {
  position: relative;
  display: flex;
}

/* the line of a finished group: the four short lines fuse into one */
.grp__line {
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: 0.08em;
  height: 1.5px;
  border-radius: 2px;
  background: var(--ink);
  opacity: 0;
  transform-origin: 50% 50%;
}

.slot {
  position: relative;
  width: 0.64em;
  height: 1.5em;
  display: grid;
  place-items: center;
}

.slot__line {
  position: absolute;
  left: 14%;
  right: 14%;
  bottom: 0.08em;
  height: 1px;
  border-radius: 1px;
  background: rgba(23, 21, 28, 0.2);
}

.slot__ch {
  display: block;
  line-height: 1;
}

.box__caret {
  position: absolute;
  left: 0;
  top: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
  opacity: 0;
}

.box__caret-bar {
  position: absolute;
  left: -0.75px;
  top: -10px;
  width: 1.5px;
  height: 20px;
  border-radius: 1px;
  background: var(--accent);
  animation: blink 1.06s steps(1) infinite;
}

.is-typing .box__caret-bar {
  animation: none;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* the real input lies over the slots: it takes the keyboard, the paste and the phone's keyboard, but shows nothing */
.box__input {
  position: absolute;
  inset: 0;
  right: 96px;
  width: auto;
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font-size: 16px;
  opacity: 0.01;
  outline: none;
  cursor: text;
}

.box__btn {
  position: relative;
  flex: none;
  height: calc(100% - 10px);
  min-width: 86px;
  padding: 0 14px;
  border: 0;
  border-radius: 9px;
  font: inherit;
  color: #ffffff;
  background: var(--ink);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 1px 2px rgba(23, 21, 28, 0.25), 0 4px 10px -4px rgba(23, 21, 28, 0.4);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  z-index: 2;
}

.box__btn:disabled {
  cursor: default;
}

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

.box__btn-face {
  position: relative;
  display: grid;
  place-items: center;
  height: 100%;
}

.box__btn-face > * {
  grid-area: 1 / 1;
}

.box__btn-words {
  font-size: 13.5px;
  font-weight: 600;
  font-variation-settings: 'wdth' 100;
  transition: font-variation-settings 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
}

@media (hover: hover) {
  .box__btn:not(:disabled):hover .box__btn-words {
    font-variation-settings: 'wdth' 112;
  }
}

.box__btn-spin,
.box__btn-check {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}

.box__btn-spin {
  stroke-width: 1.8;
}

.box__btn-spin circle {
  stroke-dasharray: 0.28 0.72;
}

.box__btn-check {
  stroke-width: 1.9;
}

.box__btn-check path {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

.msg {
  --c: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0 0 2px;
  min-height: 17px;
  font-size: 12px;
  line-height: 1.3;
  color: var(--c);
}

.msg__icon {
  position: relative;
  flex: none;
  width: 14px;
  height: 14px;
}

.msg__i {
  position: absolute;
  inset: 0;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
}

.msg__i--help {
  opacity: 1;
}

.msg__text {
  display: block;
}

.credit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: clamp(9px, 2vh, 12px);
  padding-top: clamp(9px, 2vh, 12px);
  border-top: 1px solid var(--line);
  font-size: 13px;
}

.credit__label {
  color: var(--muted);
}

.credit__right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.credit__plus {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ok);
  padding: 2px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ok) 10%, transparent);
  font-variant-numeric: tabular-nums;
  opacity: 0;
}

.credit__amount {
  font-weight: 620;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

@media (max-width: 380px) {
  .box__btn {
    min-width: 76px;
    padding: 0 10px;
  }

  .box__input {
    right: 84px;
  }
}
