/* The digital wallet with the cards to flick: the wallet of Vela, an invented payment app, on a dark page with a
   soft light from above and a fine grain. Four cards in a stack (brushed metal, a boarding pass, a concert ticket,
   a gym membership). Every card is two layers: .card is moved by the script (spring, drag, flight), its children
   are styled here. The card's height grows when it opens and the details below its face come in. */
:root {
  --page: #0b0b0d;          /* the page */
  --glow: #24252b;          /* the light above the wallet */
  --ink: #f2f2f4;           /* the words on the page */
  --muted: #85858f;         /* the small words on the page */
  --metal-a: #2c2d32;       /* the metal card, dark side */
  --metal-b: #4a4c53;       /* the metal card, light side */
  --paper: #f3efe6;         /* the boarding pass */
  --paper-ink: #17191e;     /* the words on the pass */
  --blue: #2f5bff;          /* the ink of the pass */
  --dusk-a: #2a1240;        /* the concert ticket, top */
  --dusk-b: #ff5b3a;        /* the concert ticket, bottom */
  --gym: #11241d;           /* the gym membership */
  --lime: #c9f26a;          /* its lime */
}

* {
  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 {
  position: relative;
  min-height: 100svh;
  height: 100svh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
  background:
    radial-gradient(60% 46% at 50% 18%, var(--glow), transparent 70%),
    radial-gradient(40% 30% at 50% 78%, rgba(60, 62, 72, 0.18), transparent 70%),
    var(--page);
  -webkit-user-select: none;
  user-select: none;
}

/* the grain over everything */
.stage::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.07;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* ------------------------------------------------------------------ the wallet */
.wallet {
  --w: 300px;
  --h: 189px;
  --oh: 325px;
  --u: 1;
  position: relative;
  width: var(--w);
  font-size: calc(16px * var(--u));
  opacity: 0;
}

.wallet__head {
  display: flex;
  align-items: center;
  gap: 0.75em;
  margin-bottom: 1.1em;
}

.wallet__title {
  display: flex;
  flex-direction: column;
  gap: 0.1em;
}

.wallet__word {
  font-size: 1.32em;
  font-weight: 640;
  font-variation-settings: 'wdth' 104;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.wallet__count {
  font-size: 0.72em;
  color: var(--muted);
}

/* the name of the card on top, rolling when it changes */
.wallet__names {
  position: relative;
  margin-left: auto;
  height: 1.3em;
  min-width: 7.5em;
  overflow: hidden;
  font-size: 0.78em;
  color: var(--muted);
  text-align: right;
}

.wallet__name {
  position: absolute;
  right: 0;
  top: 0;
  white-space: nowrap;
  line-height: 1.3em;
}

.wallet__add {
  flex: none;
  width: 2em;
  height: 2em;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.3s;
}

.wallet__add svg {
  width: 0.9em;
  height: 0.9em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

@media (hover: hover) {
  .wallet__add:hover {
    transform: rotate(90deg) scale(1.06);
    background: rgba(255, 255, 255, 0.1);
  }
}

.wallet__add:active {
  transform: scale(0.92);
}

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

/* ------------------------------------------------------------------ the deck and the cards */
.deck {
  position: relative;
  width: var(--w);
  touch-action: none;
}

.card {
  --lx: 30%;              /* where the light is on the card */
  --ly: 20%;
  --sh: 0.35;             /* how strong it is */
  --lift: 0;              /* 0 resting, 1 lifted (dragged) */
  --dim: 0;               /* how far back in the stack */
  --notch: 0px;           /* the bites of the perforation, open */
  position: absolute;
  left: 0;
  width: var(--w);
  height: var(--h);
  cursor: grab;
  will-change: transform;
}

.card:active {
  cursor: grabbing;
}

/* the shadow: a resting one and a deeper one when the card is lifted */
.card__shade {
  position: absolute;
  inset: 0;
  border-radius: 0.95em;
  box-shadow: 0 1.1em 2.2em -1.1em rgba(0, 0, 0, 0.85), 0 0.25em 0.6em -0.2em rgba(0, 0, 0, 0.5);
}

.card__shade::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 2.4em 3.6em -1.4em rgba(0, 0, 0, 0.9);
  opacity: var(--lift);
}

.card__body {
  position: absolute;
  inset: 0;
  border-radius: 0.95em;
  overflow: hidden;
  isolation: isolate;
}

/* the edge that catches the light, on top of everything inside */
.card__body::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  z-index: 6;
}

.card__face {
  position: relative;
  z-index: 2;
  height: var(--h);
  padding: 1.05em 1.2em 1em;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.card__more {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  top: var(--h);
  height: calc(var(--oh) - var(--h));
  padding: 0.95em 1.2em 1em;
  display: flex;
  justify-content: space-between;
  gap: 1em;
}

/* the line between the face and the details */
.card__more::before {
  content: '';
  position: absolute;
  left: 1.2em;
  right: 1.2em;
  top: 0;
  height: 1px;
  background: currentColor;
  opacity: 0.14;
}

/* the light that slides on the material, following the pointer */
.card__sheen {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: var(--sh);
  mix-blend-mode: soft-light;
  background: radial-gradient(22em 15em at var(--lx) var(--ly), rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.18) 40%, transparent 70%);
}

/* deeper in the stack, darker */
.card__dim {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background: #050506;
  opacity: var(--dim);
}

.face__row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1em;
}

.face__row--end {
  align-items: flex-end;
}

.more__col {
  display: flex;
  flex-direction: column;
  gap: 0.3em;
  min-width: 0;
}

.more__col--end {
  align-items: flex-end;
  text-align: right;
}

.more__label {
  font-size: 0.66em;
  letter-spacing: 0.02em;
  opacity: 0.6;
}

.more__value {
  font-size: 1em;
  font-weight: 600;
}

.more__small {
  font-size: 0.66em;
  opacity: 0.6;
}

.more__tx {
  display: flex;
  justify-content: space-between;
  gap: 1.2em;
  font-size: 0.7em;
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

.more__tx span + span::before {
  content: '\2212';
}

.more__pair {
  display: flex;
  gap: 1.1em;
  margin-top: 0.2em;
}

.more__pair span {
  display: flex;
  flex-direction: column;
  gap: 0.1em;
}

.more__pair small,
.face__fields small,
.gym__member small,
.gym__since small {
  display: block;
  font-size: 0.62em;
  opacity: 0.6;
  font-weight: 450;
}

.more__pair b {
  font-size: 1.25em;
  font-weight: 650;
  font-variation-settings: 'wdth' 92;
  line-height: 1.05;
}

.qr {
  flex: none;
  width: calc((var(--oh) - var(--h)) - 2.3em);
  height: calc((var(--oh) - var(--h)) - 2.3em);
  padding: 0.25em;
  border-radius: 0.45em;
  background: #ffffff;
  fill: #15161a;
}

/* ---- the metal payment card */
.card--metal {
  color: rgba(240, 240, 244, 0.86);
}

.card--metal .card__body {
  background:
    linear-gradient(112deg, var(--metal-a) 0%, var(--metal-b) 34%, #33353b 52%, var(--metal-a) 72%, #3e4047 100%);
}

/* the brushed lines: a texture the script draws once, plus a band of light that runs across them */
.card__brush {
  position: absolute;
  inset: 0;
  z-index: 1;
  background-image: var(--brush, none);
  background-size: 100% 100%;
  opacity: 0.9;
  mix-blend-mode: overlay;
}

.card__brush::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent calc(var(--lx) - 28%), rgba(255, 255, 255, 0.22) var(--lx), transparent calc(var(--lx) + 28%));
  mix-blend-mode: screen;
  opacity: calc(var(--sh) * 1.2);
}

.metal__brand {
  font-size: 1.35em;
  font-weight: 700;
  font-variation-settings: 'wdth' 118;
  letter-spacing: -0.02em;
  line-height: 1;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.55), 0 1px 0 rgba(255, 255, 255, 0.1);
}

.metal__wave {
  width: 1.3em;
  height: 1.3em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  opacity: 0.8;
}

.metal__chip {
  width: 2.5em;
  height: 1.9em;
  fill: none;
  stroke: rgba(70, 58, 34, 0.55);
  stroke-width: 0.9;
  border-radius: 0.35em;
  background: linear-gradient(135deg, #e3cf9f, #b49a63 45%, #d9c48f 70%, #9f8655);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25), 0 1px 1px rgba(0, 0, 0, 0.4);
}

.metal__chip rect {
  fill: none;
  stroke: none;
}

.metal__chip path {
  fill: none;
}

.metal__num {
  font-size: 0.88em;
  letter-spacing: 0.14em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.55), 0 1px 0 rgba(255, 255, 255, 0.1);
}

.metal__mask {
  letter-spacing: 0.08em;
  opacity: 0.7;
}

.metal__kind {
  font-size: 0.62em;
  text-align: right;
  line-height: 1.3;
  opacity: 0.7;
}

.metal__kind b {
  font-size: 1.25em;
  font-weight: 650;
  opacity: 1;
  color: #f5f5f7;
}

.metal__balance {
  font-size: 1.6em;
  font-weight: 650;
  font-variation-settings: 'wdth' 94;
  letter-spacing: -0.02em;
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
  color: #fafafa;
  margin-bottom: 0.2em;
}

.metal__spark {
  width: 4.6em;
  height: 2em;
  overflow: visible;
}

.metal__spark-area {
  fill: rgba(255, 255, 255, 0.07);
}

.metal__spark-line {
  fill: none;
  stroke: #e9e9ee;
  stroke-width: 1.4;
  stroke-linejoin: round;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  vector-effect: non-scaling-stroke;
}

/* ---- the boarding pass */
.card--pass {
  color: var(--paper-ink);
}

.card--pass .card__body,
.card--gig .card__body {
  /* the two bites of the perforation, on both sides of the fold */
  -webkit-mask:
    radial-gradient(circle var(--notch) at 0 var(--h), transparent 96%, #000) left / 51% 100% no-repeat,
    radial-gradient(circle var(--notch) at 100% var(--h), transparent 96%, #000) right / 51% 100% no-repeat;
  mask:
    radial-gradient(circle var(--notch) at 0 var(--h), transparent 96%, #000) left / 51% 100% no-repeat,
    radial-gradient(circle var(--notch) at 100% var(--h), transparent 96%, #000) right / 51% 100% no-repeat;
}

.card--pass .card__body {
  background:
    radial-gradient(120% 90% at 0% 0%, #fbf8f1, transparent 60%),
    linear-gradient(160deg, var(--paper), #e9e3d6);
}

.card--pass .card__body::after {
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.card--pass .card__sheen {
  mix-blend-mode: overlay;
  opacity: calc(var(--sh) * 0.55);
}

.card--pass .card__more::before,
.card--gig .card__more::before {
  left: 0.9em;
  right: 0.9em;
  background: repeating-linear-gradient(90deg, currentColor 0 0.32em, transparent 0.32em 0.62em);
  opacity: 0.28;
}

.pass__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  font-size: 0.8em;
  font-weight: 650;
  font-variation-settings: 'wdth' 110;
  letter-spacing: 0.01em;
}

.pass__brand svg {
  width: 1.15em;
  height: 0.8em;
  fill: none;
  stroke: var(--blue);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pass__kind {
  font-size: 0.66em;
  opacity: 0.55;
}

.pass__route {
  display: flex;
  align-items: center;
  gap: 0.6em;
}

.pass__city {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.pass__city b {
  font-size: 2.05em;
  font-weight: 700;
  font-variation-settings: 'wdth' 88;
  letter-spacing: -0.02em;
}

.pass__city small {
  font-size: 0.62em;
  opacity: 0.55;
  margin-top: 0.3em;
}

.pass__city--end {
  text-align: right;
}

.pass__line {
  position: relative;
  flex: 1;
  height: 1em;
  margin-top: -0.9em;
}

.pass__line svg:first-child {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.pass__track {
  fill: none;
  stroke: var(--blue);
  stroke-width: 1.2;
  stroke-dasharray: 2 3;
  vector-effect: non-scaling-stroke;
  opacity: 0.6;
}

.pass__plane {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.2em;
  height: 1.2em;
  margin: -0.6em 0 0 -0.6em;
  fill: var(--blue);
  background: var(--paper);
  border-radius: 50%;
  padding: 0.08em;
}

.face__fields {
  display: flex;
  justify-content: space-between;
  font-size: 0.82em;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.pass__seat {
  color: var(--blue);
}

/* ---- the concert ticket */
.card--gig {
  color: #fff6f0;
}

.card--gig .card__body {
  background:
    radial-gradient(90% 70% at 100% 100%, rgba(255, 140, 80, 0.85), transparent 70%),
    linear-gradient(170deg, var(--dusk-a) 0%, #5a1d55 46%, var(--dusk-b) 120%);
}

/* the foil strip: a band of colour that shifts with the light */
.gig__foil {
  position: absolute;
  z-index: 1;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  opacity: calc(0.25 + var(--sh) * 0.6);
  mix-blend-mode: color-dodge;
  background: linear-gradient(115deg,
      transparent calc(var(--lx) - 40%),
      rgba(120, 200, 255, 0.35) calc(var(--lx) - 16%),
      rgba(255, 120, 220, 0.4) var(--lx),
      rgba(255, 230, 120, 0.35) calc(var(--lx) + 16%),
      transparent calc(var(--lx) + 40%));
}

.card--gig .card__face {
  flex-direction: row;
  padding-right: 0;
}

.gig__main {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
}

.gig__venue {
  font-size: 0.66em;
  letter-spacing: 0.04em;
  opacity: 0.75;
}

.gig__band {
  font-size: 1.75em;
  font-weight: 760;
  font-variation-settings: 'wdth' 78;
  line-height: 0.95;
  letter-spacing: -0.015em;
}

.gig__date {
  font-size: 0.72em;
  font-weight: 550;
  opacity: 0.9;
}

/* the stub, behind its own perforation */
.gig__stub {
  position: relative;
  flex: none;
  width: 2.6em;
  margin: -1.05em 0 -1em 0.9em;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.14);
}

.gig__stub::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.5em;
  bottom: 0.5em;
  width: 1px;
  background: repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.5) 0 0.3em, transparent 0.3em 0.6em);
}

.gig__stub span {
  transform: rotate(-90deg);
  white-space: nowrap;
  font-size: 0.62em;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.85;
}

/* ---- the gym membership */
.card--gym {
  color: var(--lime);
}

.card--gym .card__body {
  background:
    radial-gradient(80% 90% at 100% 0%, #1d3a2f, transparent 70%),
    linear-gradient(160deg, var(--gym), #0b1813);
}

.gym__rings {
  position: absolute;
  z-index: 1;
  right: 0;
  top: 0;
  width: 62%;
  height: auto;
  fill: none;
  stroke: var(--lime);
  stroke-width: 0.6;
  opacity: 0.22;
}

.gym__brand {
  font-size: 1.5em;
  font-weight: 800;
  font-variation-settings: 'wdth' 125;
  letter-spacing: 0.02em;
  line-height: 1;
}

.gym__tier {
  font-size: 0.64em;
  font-weight: 600;
  padding: 0.35em 0.75em;
  border-radius: 999px;
  color: var(--gym);
  background: var(--lime);
}

.gym__member,
.gym__since {
  font-size: 0.86em;
  font-weight: 600;
  color: #eef6df;
}

.gym__since {
  text-align: right;
}

.gym__visits {
  font-size: 1.9em;
  font-weight: 700;
  font-variation-settings: 'wdth' 90;
  line-height: 1;
  color: #eef6df;
}

.gym__week {
  display: flex;
  align-items: flex-end;
  gap: 0.28em;
  height: 1.5em;
}

.gym__week i {
  display: block;
  width: 0.42em;
  height: calc(var(--v) * 100%);
  min-height: 2px;
  border-radius: 2px;
  background: var(--lime);
  opacity: 0.85;
  transform-origin: 50% 100%;
}

.gym__bars {
  width: 5.2em;
  height: 2.6em;
  padding: 0.25em 0.3em;
  border-radius: 0.35em;
  background: #eef6df;
  fill: #0e1d17;
}

/* ------------------------------------------------------------------ the drawn pointer of the walk on its own */
.ghost {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 40;
  width: 22px;
  height: 22px;
  pointer-events: none;
  opacity: 0;
  fill: #ffffff;
  stroke: #0b0b0d;
  stroke-width: 1.3;
  stroke-linejoin: round;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.45));
}

@media (prefers-reduced-motion: reduce) {
  .wallet__add {
    transition: background-color 0.3s;
  }
}
