/* Lottery ticket: the ticket of Lodestar Six, an invented lottery, alone on white. A dark draw board with six reels
   above a cream security paper ticket (fine guilloche lines, stamp-cut edges, serial number and barcode); Check
   results spins the reels, the matching numbers get circled in pen, the count goes up and the prize rolls in. */
:root {
  --page: #ffffff;          /* the page */
  --ink: #172036;           /* the printing on the ticket */
  --muted: #7d7768;         /* the small printing */
  --paper: #fbf7ee;         /* the ticket paper */
  --paper-deep: #f1e9d8;    /* the paper towards the edges */
  --guilloche: #2d6a63;     /* the fine security lines */
  --pen: #e0442a;           /* the pen that circles the numbers */
  --board: #131a2b;         /* the draw board */
  --board-ink: #f4efe3;     /* the numbers on the reels */
  --button: #172036;        /* the button */
  --button-ink: #fbf7ee;    /* the words on the button */
}

* {
  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;
}

.defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

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

.lotto {
  position: relative;
  width: min(328px, 92vw);
  display: grid;
  gap: clamp(8px, 2.4vh, 14px);
  user-select: none;
  -webkit-user-select: none;
}

/* ---------------------------------------------------------------- the draw board */
.board {
  position: relative;
  padding: clamp(8px, 2.2vh, 12px) 12px clamp(9px, 2.4vh, 12px);
  border-radius: 18px;
  background:
    radial-gradient(120% 90% at 50% -30%, rgba(255, 255, 255, 0.09), transparent 60%),
    linear-gradient(180deg, #19213a, var(--board));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    0 1px 1px rgba(19, 26, 43, 0.12),
    0 10px 22px -10px rgba(19, 26, 43, 0.45),
    0 30px 50px -30px rgba(19, 26, 43, 0.5);
  color: var(--board-ink);
  opacity: 0;
}

.board__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: clamp(6px, 1.6vh, 9px);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-stretch: 112%;
}

.board__label {
  font-weight: 640;
  color: rgba(244, 239, 227, 0.86);
}

.board__draw {
  font-weight: 500;
  color: rgba(244, 239, 227, 0.46);
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.reels {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

/* a reel window: an element for GSAP (the settle), the window for the CSS */
.reel {
  position: relative;
  --cell: clamp(32px, 8.6vh, 44px);
}

.reel__win {
  position: relative;
  display: block;
  height: var(--cell);
  border-radius: 9px;
  overflow: hidden;
  background: linear-gradient(180deg, #0b1020, #182039 50%, #0b1020);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    inset 0 2px 5px rgba(0, 0, 0, 0.55),
    0 1px 0 rgba(255, 255, 255, 0.06);
  transition: box-shadow 0.4s ease;
}

/* the glass on the window: shade at the top and bottom like a drum, and a thin highlight */
.reel__win::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(180deg, rgba(5, 8, 18, 0.85), transparent 30%, transparent 70%, rgba(5, 8, 18, 0.85)),
    linear-gradient(180deg, transparent 47%, rgba(255, 255, 255, 0.05) 48%, transparent 52%);
  pointer-events: none;
}

.reel__strip {
  position: absolute;
  inset: 0 0 auto;
  display: block;
  will-change: transform;
}

.reel__cell {
  display: grid;
  place-items: center;
  height: var(--cell);
  font-size: clamp(16px, 4.4vh, 20px);
  font-weight: 640;
  font-stretch: 108%;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  color: var(--board-ink);
}

/* the empty window at rest: a short engraved line */
.reel__cell--blank::before {
  content: '';
  width: 10px;
  height: 2px;
  border-radius: 2px;
  background: rgba(244, 239, 227, 0.18);
}

.reel.is-hit .reel__win {
  box-shadow:
    inset 0 0 0 1px rgba(224, 68, 42, 0.75),
    inset 0 2px 5px rgba(0, 0, 0, 0.55),
    0 0 0 3px rgba(224, 68, 42, 0.14);
}

.reel.is-hit .reel__cell:last-child {
  color: #ff8a70;
}

/* ---------------------------------------------------------------- the ticket */
.ticket-wrap {
  position: relative;
  filter:
    drop-shadow(0 1px 1px rgba(23, 32, 54, 0.1))
    drop-shadow(0 8px 12px rgba(23, 32, 54, 0.08))
    drop-shadow(0 22px 26px rgba(60, 44, 18, 0.12));
  opacity: 0;
}

.ticket {
  --s: 9px;                 /* the distance between two cuts of the stamp edge */
  --r: 3px;                 /* the size of a cut */
  --mx: 30%;
  --my: 0%;
  position: relative;
  padding: clamp(11px, 3vh, 16px) 14px clamp(9px, 2.6vh, 13px);
  background:
    radial-gradient(140% 100% at 50% 0%, var(--paper) 55%, var(--paper-deep));
  overflow: hidden;
  -webkit-mask:
    radial-gradient(circle var(--r) at 50% 0, #0000 calc(var(--r) - 0.5px), #000 var(--r)) 50% 0 / var(--s) 51% repeat-x,
    radial-gradient(circle var(--r) at 50% 100%, #0000 calc(var(--r) - 0.5px), #000 var(--r)) 50% 100% / var(--s) 51% repeat-x;
  mask:
    radial-gradient(circle var(--r) at 50% 0, #0000 calc(var(--r) - 0.5px), #000 var(--r)) 50% 0 / var(--s) 51% repeat-x,
    radial-gradient(circle var(--r) at 50% 100%, #0000 calc(var(--r) - 0.5px), #000 var(--r)) 50% 100% / var(--s) 51% repeat-x;
}

/* a very fine paper grain */
.ticket::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.6'/%3E%3C/svg%3E");
  opacity: 0.06;
  mix-blend-mode: multiply;
  pointer-events: none;
}

.ticket__guilloche {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  -webkit-mask: linear-gradient(90deg, #000, rgba(0, 0, 0, 0.35) 30%, rgba(0, 0, 0, 0.35) 70%, #000);
  mask: linear-gradient(90deg, #000, rgba(0, 0, 0, 0.35) 30%, rgba(0, 0, 0, 0.35) 70%, #000);
}

.ticket__guilloche path {
  fill: none;
  stroke: var(--guilloche);
  stroke-width: 0.45;
  opacity: 0.22;
}

/* the soft light that follows the pointer on the paper */
.ticket__sheen {
  position: absolute;
  inset: 0;
  background: radial-gradient(180px 120px at var(--mx) var(--my), rgba(255, 255, 255, 0.55), transparent 70%);
  mix-blend-mode: soft-light;
  pointer-events: none;
}

/* the thin line of light that runs over the ticket at the result */
.ticket__sweep {
  position: absolute;
  top: -20%;
  bottom: -20%;
  left: 0;
  width: 46px;
  background: linear-gradient(90deg, transparent, rgba(255, 252, 240, 0.0) 20%, rgba(255, 252, 240, 0.9) 50%, rgba(255, 252, 240, 0) 80%, transparent);
  transform: translateX(-80px) rotate(14deg);
  mix-blend-mode: soft-light;
  opacity: 0;
  pointer-events: none;
}

.ticket__head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* the holographic seal: its colours turn with --a */
.seal {
  --a: 20deg;
  position: relative;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background:
    conic-gradient(from var(--a), #d9f0e9, #f4dcc6, #e6d6f3, #cfe6f6, #f2eccb, #d9f0e9);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.7),
    inset 0 -6px 10px rgba(23, 32, 54, 0.08),
    0 1px 2px rgba(23, 32, 54, 0.18);
  overflow: hidden;
}

.seal::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.5) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
}

.seal svg {
  position: absolute;
  inset: 3px;
  width: 24px;
  height: 24px;
}

.seal path {
  fill: var(--ink);
  opacity: 0.82;
}

.seal circle {
  fill: none;
  stroke: var(--ink);
  stroke-width: 0.5;
  opacity: 0.4;
}

.ticket__name {
  flex: 1;
  min-width: 0;
}

.ticket__brand {
  margin: 0;
  font-family: 'Fraunces Variable', Georgia, serif;
  font-size: clamp(18px, 4.8vh, 22px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.01em;
}

.ticket__brand span {
  font-weight: 380;
  color: var(--guilloche);
}

.ticket__sub {
  margin: 3px 0 0;
  font-size: 10.5px;
  color: var(--muted);
  font-stretch: 96%;
}

.ticket__price {
  display: grid;
  justify-items: end;
  font-family: 'Fraunces Variable', Georgia, serif;
  font-size: 18px;
  font-weight: 560;
  line-height: 1;
}

.ticket__price small {
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 3px;
}

.ticket__label {
  position: relative;
  margin: clamp(8px, 2.2vh, 12px) 0 2px;
  font-size: 9.5px;
  font-weight: 620;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-stretch: 112%;
  color: var(--muted);
}

.picks {
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
}

/* a number on the ticket: an element for GSAP (the pen nudge), its number for the CSS */
.pick {
  position: relative;
  display: grid;
  place-items: center;
  height: clamp(34px, 9vh, 46px);
}

.pick__n {
  position: relative;
  font-family: 'Fraunces Variable', Georgia, serif;
  font-size: clamp(20px, 5.4vh, 26px);
  font-weight: 520;
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.pick__ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 44px;
  margin: -22px 0 0 -27px;
  overflow: visible;
  pointer-events: none;
}

.pick__ring path {
  fill: none;
  stroke: var(--pen);
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pick__ring .ink {
  stroke-width: 2.1;
}

.pick__ring .ink2 {
  stroke-width: 0.8;
  opacity: 0.45;
}

/* the perforation between the numbers and the stub, with the microtext along it */
.perf {
  position: relative;
  height: 12px;
  margin: clamp(6px, 1.8vh, 10px) -14px clamp(5px, 1.4vh, 8px);
}

.perf__holes {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: radial-gradient(circle 1.2px, #ffffff 90%, transparent) 50% 0 / 7px 3px repeat-x;
  opacity: 0.95;
}

.perf__micro {
  position: absolute;
  left: 14px;
  right: 14px;
  top: 5px;
  font-family: 'JetBrains Mono Variable', ui-monospace, monospace;
  font-size: 4.6px;
  line-height: 1;
  letter-spacing: 0.18em;
  white-space: nowrap;
  overflow: hidden;
  color: var(--guilloche);
  opacity: 0.6;
}

.stub {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.barcode {
  display: block;
  width: 128px;
  height: clamp(18px, 4.6vh, 24px);
}

.barcode rect {
  fill: var(--ink);
}

.stub__serial {
  margin: 0;
  display: grid;
  justify-items: end;
  font-family: 'JetBrains Mono Variable', ui-monospace, monospace;
  font-size: 10.5px;
  line-height: 1.15;
  color: var(--ink);
}

.stub__serial span {
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.stub__serial b {
  font-weight: 560;
  letter-spacing: 0.04em;
}

/* ---------------------------------------------------------------- the result and the button */
.result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px;
  opacity: 0;
}

.result__text {
  min-width: 0;
}

.result__count {
  margin: 0;
  display: flex;
  align-items: flex-start;
  line-height: 1.2em;
  font-size: 13px;
  font-weight: 600;
  font-stretch: 104%;
  color: var(--ink);
  white-space: nowrap;
}

.digit {
  display: inline-block;
  height: 1.2em;
  line-height: 1.2em;
  overflow: hidden;
  vertical-align: top;
  text-align: center;
}

.digit > span {
  display: block;
}

.digit > span > span {
  display: block;
  height: 1.2em;
}

.result__prize {
  margin: 2px 0 0;
  height: 1.3em;
  font-size: 12px;
  line-height: 1.3em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
}

.result__line {
  display: inline-flex;
  align-items: flex-start;
}

.result__line.is-won {
  color: var(--pen);
  font-weight: 640;
}

.result__line .digit {
  height: 1.3em;
  line-height: 1.3em;
}

.result__line .digit > span > span {
  height: 1.3em;
}

.check {
  flex: none;
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  -webkit-tap-highlight-color: transparent;
  transition: translate 0.25s cubic-bezier(0.3, 1.5, 0.5, 1);
}

.check:focus {
  outline: none;
}

/* the face of the button: an element for GSAP (press, swell), the colours for the CSS */
.check__face {
  position: relative;
  display: grid;
  place-items: center;
  width: 142px;
  height: 46px;
  border-radius: 999px;
  overflow: hidden;
  background: linear-gradient(180deg, #24304d, var(--button));
  color: var(--button-ink);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -1px 0 rgba(0, 0, 0, 0.3),
    0 1px 2px rgba(23, 32, 54, 0.25),
    0 8px 18px -8px rgba(23, 32, 54, 0.55);
  transition: box-shadow 0.25s ease;
}

.check__shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.16) 50%, transparent 65%);
  translate: -110% 0;
  pointer-events: none;
}

.check__label {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 620;
  font-stretch: 106%;
  letter-spacing: 0.005em;
  white-space: nowrap;
}

.check__icon {
  width: 14px;
  height: 14px;
  margin-left: -2px;
  display: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.check.is-again .check__icon {
  display: block;
}

/* the thin line along the bottom of the button that fills as the reels stop */
.check__bar {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 7px;
  height: 2px;
  border-radius: 2px;
  background: rgba(251, 247, 238, 0.12);
  opacity: 0;
  overflow: hidden;
}

.check__bar i {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--pen);
  transform-origin: 0 50%;
  transform: scaleX(0);
}

.check:focus-visible .check__face {
  box-shadow:
    0 0 0 2px var(--page),
    0 0 0 4px var(--pen),
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 8px 18px -8px rgba(23, 32, 54, 0.55);
}

.check[aria-busy='true'] {
  cursor: default;
}

@media (hover: hover) {
  .check:not([aria-busy='true']):hover {
    translate: 0 -1px;
  }

  .check:not([aria-busy='true']):hover .check__face {
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.2),
      inset 0 -1px 0 rgba(0, 0, 0, 0.3),
      0 2px 3px rgba(23, 32, 54, 0.22),
      0 14px 24px -10px rgba(23, 32, 54, 0.6);
  }

  .check:not([aria-busy='true']):hover .check__shine {
    translate: 110% 0;
    transition: translate 0.7s cubic-bezier(0.3, 0.7, 0.3, 1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .check,
  .check__face,
  .check__shine {
    transition: none;
  }
}
