/* The confetti button: a deep ink button with a gift in it, on a white page. The confetti is drawn by the script on
   two canvases, one behind the button and one in front of it; its colours are the --paper ones below, read at every
   burst. */
:root {
  --page: #ffffff;          /* the page */
  --ink: #1b1828;           /* the words, and the button */
  --gold: #ffc94a;          /* the gift, and the button once the reward is yours */
  --gold-deep: #e7a21c;
  --paper-1: #ff5b4f;       /* the colours of the paper */
  --paper-2: #ffc23d;
  --paper-3: #26c49b;
  --paper-4: #3f9bff;
  --paper-5: #8a6bff;
  --paper-6: #ff7cb9;
  --foil: #d6ad57;          /* the gold foil pieces, which flash in the light */
}

* {
  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(--ink);
  font-family: 'Bricolage Grotesque 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;
}

/* the two layers of paper fill the window: one under the button, one over it */
.paper {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.paper--back {
  z-index: 0;
}

.paper--front {
  z-index: 2;
}

.stage {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 48px 16px;
}

/* ---------------------------------------------------------------- the button */
.claim {
  position: relative;
  display: block;
  width: min(328px, calc(100vw - 32px));
  height: 58px;
  padding: 0;
  border: 0;
  border-radius: 18px;
  overflow: hidden;
  background: var(--ink);
  color: #fff;
  font: inherit;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -2px 0 rgba(0, 0, 0, 0.35),
    0 10px 22px -12px color-mix(in srgb, var(--ink) 80%, transparent);
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color 0.45s ease, color 0.45s ease, box-shadow 0.45s ease;
}

.claim.is-done {
  background: var(--gold);
  color: var(--ink);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -2px 0 color-mix(in srgb, var(--gold-deep) 70%, transparent),
    0 10px 24px -12px color-mix(in srgb, var(--gold-deep) 90%, transparent);
}

.claim.is-busy {
  cursor: progress;
}

/* the light that runs across the button under the pointer */
.claim__shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.16) 46%, rgba(255, 255, 255, 0.04) 54%, transparent 64%);
  opacity: 0;
  pointer-events: none;
}

.claim__face {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 100%;
  pointer-events: none;
}

.claim__gift {
  flex: none;
  width: 26px;
  height: 26px;
  overflow: visible;
}

.gift__box,
.gift__lid {
  fill: var(--gold);
}

.gift__lid {
  fill: color-mix(in srgb, var(--gold) 82%, #fff);
}

.gift__band {
  fill: var(--paper-1);
}

.gift__bow {
  fill: none;
  stroke: var(--paper-1);
  stroke-width: 1.7;
  stroke-linejoin: round;
}

.claim__check {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}

/* the three words of the button sit on top of each other: only one shows at a time */
.claim__labels {
  display: grid;
  min-width: 0;
}

.claim__label {
  grid-area: 1 / 1;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.01em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.claim__label + .claim__label {
  opacity: 0;
}

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

html[data-using='pointer'] .claim:focus-visible {
  outline: none;
}
