/* The freeze card button: a warm debit card and its Freeze card button, on a black page. The frost is drawn in a
   canvas laid over both; the words of the card and of the button sit above it. */
:root {
  --page: #000000;          /* the page */
  --card-a: #ff8a4c;        /* the card, warm: its three colours from corner to corner */
  --card-b: #f0466e;
  --card-c: #7b3fe4;
  --card-ink: #fff7f0;      /* the words on the warm card */
  --frozen-ink: #17375c;    /* the words on the frost */
  --button: #1d2430;        /* the button */
  --button-hi: #283142;     /* the button under the pointer */
  --label: #f3f6fb;         /* the words on the button */
  --frost: #c9ddef;         /* the haze of the frost */
  --crystal: #fbfdff;       /* the crystals */
  --glint: #8fcaff;         /* the blue light at the tips of the growing crystals */
  --focus: #9fd2ff;         /* the focus ring */
}

* {
  box-sizing: border-box;
}

/* a tap is a click at once: no wait for a double tap */
html {
  touch-action: manipulation;
}

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

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--label);
  font-family: 'Manrope 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: 32px 16px;
}

/* the card above, the button below: 320 by 276 */
.freeze {
  position: relative;
  width: 320px;
  height: 278px;
}

/* ---------------------------------------------------------------- the card */
.card {
  position: absolute;
  left: 0;
  top: 0;
  width: 320px;
  height: 202px;
  border-radius: 16px;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(255, 255, 255, 0.22), transparent 55%),
    linear-gradient(135deg, var(--card-a) 0%, var(--card-b) 52%, var(--card-c) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 0 0 1px rgba(255, 255, 255, 0.12),
    0 24px 40px -22px rgba(240, 70, 110, 0.55);
  transition: filter 1.1s ease, box-shadow 1.1s ease;
}

/* frozen, the colour drains out of the card under the frost */
.freeze.is-frozen .card {
  filter: saturate(0.25) brightness(1.08) hue-rotate(-20deg);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 0 0 1px rgba(255, 255, 255, 0.12),
    0 24px 40px -22px rgba(120, 180, 240, 0.5);
}

/* two soft bands across the card, the way plastic catches the light */
.card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.12) 42%, transparent 54%);
}

.card__face {
  position: absolute;
  inset: 0;
}

.card__chip {
  position: absolute;
  left: 22px;
  top: 64px;
  width: 42px;
  height: 32px;
  fill: #f2cf86;
  stroke: rgba(120, 82, 20, 0.55);
  stroke-width: 1.2;
}

.card__wave {
  position: absolute;
  left: 74px;
  top: 68px;
  width: 24px;
  height: 24px;
  fill: none;
  stroke: rgba(255, 255, 255, 0.85);
  stroke-width: 1.8;
  stroke-linecap: round;
}

/* the words of the card, over the frost */
.card__words {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 2;
  width: 320px;
  height: 202px;
  color: var(--card-ink);
  pointer-events: none;
  transition: color 0.9s ease;
}

.freeze.is-cold .card__words {
  color: var(--frozen-ink);
}

.card__kind {
  position: absolute;
  left: 22px;
  top: 20px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.card__name {
  position: absolute;
  left: 22px;
  bottom: 20px;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.card__end {
  position: absolute;
  right: 22px;
  bottom: 20px;
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}

.card__end-label {
  margin-right: 3px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  opacity: 0.75;
}

/* ---------------------------------------------------------------- the frost, over the card and the button */
.freeze__frost {
  position: absolute;
  left: -20px;
  top: -20px;
  z-index: 1;
  width: calc(100% + 40px);
  height: calc(100% + 40px);
  pointer-events: none;
}

/* ---------------------------------------------------------------- the button */
.freeze__btn {
  position: absolute;
  left: 0;
  top: 220px;
  width: 320px;
  height: 58px;
  padding: 0;
  border: 0;
  border-radius: 29px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0) 50%),
    var(--button);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  color: var(--label);
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.3s ease;
}

@media (hover: hover) and (pointer: fine) {
  .freeze[data-state='warm'] .freeze__btn:hover {
    background-color: var(--button-hi);
  }
}

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

/* the label sits over the frost, over the button */
.freeze__label {
  position: absolute;
  left: 0;
  top: 220px;
  width: 320px;
  height: 58px;
  pointer-events: none;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--label);
  transition: color 0.6s ease;
}

.freeze.is-btn-cold .freeze__label {
  color: var(--frozen-ink);
}

.freeze__flake {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.6s cubic-bezier(0.3, 1.5, 0.5, 1);
}

@media (hover: hover) and (pointer: fine) {
  .freeze[data-hover] .freeze__flake {
    transform: rotate(30deg);
  }
}

.freeze[data-press] .freeze__flake {
  transform: rotate(30deg);
}

.freeze__words {
  display: grid;
  justify-items: start;
  line-height: 1.15;
}

.freeze__main {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.005em;
  white-space: nowrap;
}

.freeze__sub {
  display: none;
  font-size: 12px;
  font-weight: 600;
  opacity: 0.72;
  white-space: nowrap;
}

.freeze.is-frozen .freeze__sub {
  display: block;
}

@media (max-width: 360px) {
  .freeze {
    transform: scale(0.9);
  }
}

@media (prefers-reduced-motion: reduce) {
  .card,
  .card__words,
  .freeze__label,
  .freeze__flake {
    transition-duration: 0.3s;
  }

  .freeze__flake {
    transition: none;
  }
}
