/* The scratch card: a yellow ticket on a white page under silver foil. */
:root {
  --page: #ffffff;          /* the page */
  --ink: #1f1b10;
  --muted: #8a8476;
  --ticket: #ffd84a;        /* the ticket */
  --ticket-deep: #f5c518;
  --accent: #e5482c;        /* the gift */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Chivo Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.gift {
  display: grid;
  justify-items: center;
  width: min(420px, 100%);
}

.gift__title {
  margin: 0 0 16px;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

/* ---------------------------------------------------------------- the ticket */
.ticket {
  position: relative;
  width: 100%;
  height: 210px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* the paper with its notches and its shadow, a layer of its own: Safari clips a drop-shadow on an element whose
   children move (the foil, as it comes off) */
.ticket::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 22px;
  background:
    radial-gradient(circle at 0 50%, transparent 15px, transparent 15.5px, var(--ticket) 16px) left / 51% 100% no-repeat,
    radial-gradient(circle at 100% 50%, transparent 15px, transparent 15.5px, var(--ticket) 16px) right / 51% 100% no-repeat;
  filter: drop-shadow(0 16px 18px rgba(80, 60, 0, 0.22));
}

.ticket__prize {
  position: absolute;
  inset: 18px 30px;
  display: grid;
  align-content: center;
  justify-items: center;
  border: 2px dashed rgba(31, 27, 16, 0.25);
  border-radius: 14px;
  text-align: center;
}

.ticket__big {
  margin: 0;
  color: var(--accent);
  font-size: 54px;
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -0.03em;
  text-transform: uppercase;
}

.ticket__small {
  margin: 6px 0 0;
  font-size: 15px;
  font-weight: 600;
}

.ticket__code {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
}

.ticket__chip {
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.ticket__copy {
  padding: 7px 12px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  font: 700 13px 'Chivo Variable', system-ui, sans-serif;
  cursor: pointer;
  opacity: 0;
  transition: transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.ticket__copy:active {
  transform: scale(0.94);
}

/* the foil, drawn by the script, over the gift */
.ticket__foil {
  position: absolute;
  inset: 18px 30px;
  width: calc(100% - 60px);
  height: calc(100% - 36px);
  border-radius: 14px;
  cursor: none;
}

@media (hover: none), (pointer: coarse) {
  .ticket__foil {
    cursor: auto;
  }
}

/* the coin that follows the mouse over the foil */
.ticket__coin {
  position: absolute;
  top: 0;
  left: 0;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff3c4, #e7b53a 55%, #b8841b);
  box-shadow: inset 0 0 0 3px rgba(150, 100, 10, 0.35), 0 4px 10px -2px rgba(80, 55, 0, 0.45);
  opacity: 0;
  pointer-events: none;
}

.gift__reveal {
  margin-top: 16px;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font: 600 14px 'Chivo Variable', system-ui, sans-serif;
  cursor: pointer;
  transition: color 0.2s, background-color 0.2s;
}

@media (hover: hover) {
  .gift__reveal:hover {
    color: var(--ink);
    background: #f4f2ed;
  }
}

.gift__reveal:focus-visible,
.ticket__copy:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

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

/* gone after the reveal, but keeping its room so the ticket does not move */
.gift__reveal.is-gone {
  visibility: hidden;
}

/* the flakes of foil fall over the whole page */
.flakes {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
