/* The spin-the-wheel page (/spin/) and its confirmation page. Builds on
   mm.css: same yellow canvas, ink, paper and thick square borders, with a
   hard ink shadow under the two things you touch, the wheel and the card. */

.spin-page { display: flex; flex-direction: column; }

/* Top bar */
.spin-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; max-width: 1180px; margin: 0 auto; padding: 14px 16px 0; }
.spin-brand { font-size: 22px; text-decoration: none; white-space: nowrap; }
.spin-sound { display: inline-flex; align-items: center; gap: 6px; border: 2px solid var(--ink); background: transparent; padding: 6px 10px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; cursor: pointer; border-radius: 0; }
.spin-sound:hover { background: rgba(34, 34, 34, .08); }
.spin-sound svg { width: 18px; height: 18px; }
.spin-sound .spin-sound-cross, .spin-sound[aria-pressed="false"] .spin-sound-waves { display: none; }
.spin-sound[aria-pressed="false"] .spin-sound-cross { display: inline; }

/* Layout: one column on a phone (title, wheel, card); on a wide screen the
   words and the card sit beside the wheel. The box is as wide as the screen
   and its padding keeps the content to 1180px, because overflow-x is
   clipped here: a square turned on its corner (the wheel, mid-spin) is
   wider than itself and the fire reaches well past the wheel, and neither
   may make the page scroll sideways or stop short of the screen's edge. */
.spin-main { flex: 1; width: 100%; padding: 18px max(16px, (100% - 1148px) / 2) 56px; overflow-x: clip; display: grid; gap: 22px; grid-template-columns: minmax(0, 1fr); justify-items: center; }
.spin-hero { width: 100%; max-width: 520px; }
.spin-title { font-size: clamp(60px, 19vw, 104px); line-height: .86; margin-top: 8px; }
.spin-tag { margin-top: 14px; font-size: clamp(19px, 5.2vw, 24px); font-style: italic; font-weight: 500; line-height: 1.2; }

/* The wheel */
.spin-stage { position: relative; width: min(100%, 430px, 52vh); width: min(100%, 430px, 52dvh); min-width: 240px; aspect-ratio: 1; margin: 6px 0 10px; }
.spin-wheel { position: absolute; inset: 0; }
.spin-wheel > svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; overflow: visible; }
.spin-wheel > .spin-shadow { transform: translate(2.2%, 2.8%); }
.spin-disc { transform-origin: 50% 50%; }
.spin-wheel.is-spinning .spin-disc { will-change: transform; }
.spin-mark { font-family: var(--display); font-size: 58px; }
.spin-bulb { fill: var(--paper); }
.spin-bulb-b { fill: var(--canvas); }
.spin-wheel > .spin-pointer { inset: -4.5% auto auto 50%; width: 11.5%; height: auto; margin-left: -5.75%; transform-origin: 50% 32%; z-index: 2; filter: drop-shadow(2px 3px 0 rgba(34, 34, 34, .35)); }

/* The fire (fire.js): two canvases that reach past the wheel on every side,
   flames behind it, embers and sparks in front; and a glow under it all
   that follows --heat (0 to 1), which spin.js sets while the wheel turns. */
.spin-fire { position: absolute; left: -45%; top: -45%; width: 190%; height: 190%; pointer-events: none; }
.spin-fire-front { z-index: 2; }
.spin-stage::before { content: ""; position: absolute; inset: -26%; border-radius: 50%; background: radial-gradient(closest-side, rgba(238, 58, 23, .55), rgba(255, 138, 0, .3) 58%, rgba(255, 138, 0, 0)); opacity: var(--heat, 0); pointer-events: none; }
.spin-hub { transition: color .3s, background-color .3s; }
.spin-stage.is-hot .spin-hub[disabled] { background: #ee3a17; color: var(--paper); }

/* The hat (hat.js): on the hub like a cap on a head. hat.js moves it with
   transform; where it rests is set here with translate and rotate. Under
   reduced motion it never leaves, so it steps aside for the slice the
   wheel stopped on. */
.spin-hat { position: absolute; left: 50%; top: 30%; width: 31%; height: auto; translate: -50% -50%; rotate: -7deg; z-index: 5; pointer-events: none; filter: drop-shadow(3px 4px 0 rgba(34, 34, 34, .35)); transition: opacity .3s; }
.spin-hat[hidden] { display: none; }
.spin-wheel.has-landed ~ .spin-hat { opacity: 0; }

/* The slice the wheel stopped on: every other slice goes dim. */
.spin-slice, .spin-mark { transition: opacity .35s; }
.spin-wheel.has-landed .spin-slice:not(.is-landed), .spin-wheel.has-landed .spin-mark:not(.is-landed) { opacity: .3; }
.spin-mark { transform-box: fill-box; transform-origin: center; }
.spin-mark.is-landed { scale: 1.3; }

/* The button on the hub. It is the form's second submit button. */
.spin-hub { position: absolute; inset: 50% auto auto 50%; width: 23.6%; aspect-ratio: 1; transform: translate(-50%, -50%); z-index: 3; display: grid; place-items: center; border: 0; border-radius: 50%; background: var(--ink); color: var(--canvas); font-size: clamp(17px, 5.4vw, 30px); cursor: pointer; padding: 0; transition: color .15s, background-color .15s; }
.spin-hub:hover:not([disabled]) { background: #000; color: #fff; }
.spin-hub[disabled] { cursor: default; }
.mm .spin-hub:focus-visible { outline: 3px solid var(--paper-bright); outline-offset: -7px; }

/* The wording differs between a spin with a code and a round without one
   (data-mode). While spin.js is still asking which it is, the parts that
   differ keep their room but are not shown, so no code field appears and
   then goes away. */
.spin-asking [data-mode] { visibility: hidden; }

/* The prize of the round that is open, above the wheel. It comes from the
   server, so it is empty at first: its room is kept until the answer is
   in, and the wheel does not jump when the words arrive. */
.spin-prize-top { margin-top: 16px; }
.spin-prize-top:empty { min-height: 5.6em; border-left-color: transparent; }

/* The boost: the code is optional in a round anyone can spin in. */
.spin-optional { margin-left: 6px; padding: 1px 7px; border: 2px solid currentColor; border-radius: 99px; font-size: 10px; letter-spacing: .08em; vertical-align: 1px; }
.spin-boost-hint, .spin-confirm-hint { margin-top: 6px; }
.spin-boost { padding: 10px 12px; border: 2px dashed var(--ink); font-size: 15px; line-height: 1.4; }
.spin-boost.is-on { border-style: solid; background: var(--canvas); }

@media (prefers-reduced-motion: no-preference) {
  .spin-ready:not(.spin-asking) [data-mode]:not([hidden]) { animation: spin-mode-in .3s ease-out; }
  /* The rim lights swap once a second while the wheel turns. */
  .spin-wheel.is-spinning .spin-bulb { animation: spin-bulbs 1s steps(1) infinite; }
  .spin-wheel.is-spinning .spin-bulb-b { animation-delay: -.5s; }
  /* Alight: the lights race and the whole wheel shakes on its stand. */
  .spin-stage.is-hot .spin-wheel.is-spinning .spin-bulb { animation-duration: .5s; }
  .spin-stage.is-hot .spin-wheel.is-spinning .spin-bulb-b { animation-delay: -.25s; }
  .spin-stage.is-hot .spin-wheel { animation: spin-rumble .12s linear infinite; }
  .spin-wheel.is-celebrating { animation: spin-pop .8s cubic-bezier(.2, 1.6, .4, 1); }
  .spin-hat.is-dropping { animation: spin-hat-drop .7s cubic-bezier(.3, 1.5, .5, 1) backwards; }
  .spin-mark.is-landed { animation: spin-mark .6s cubic-bezier(.2, 1.8, .4, 1); }
  .spin-hub:active:not([disabled]) { transform: translate(-50%, -50%) scale(.94); }
  .spin-result:not([hidden]) > * { animation: spin-rise .45s cubic-bezier(.2, .9, .3, 1) backwards; }
  .spin-result > :nth-child(2) { animation-delay: .05s; }
  .spin-result > :nth-child(3) { animation-delay: .12s; }
  .spin-result > :nth-child(4) { animation-delay: .19s; }
  .spin-result > :nth-child(n+5) { animation-delay: .26s; }
}
@keyframes spin-bulbs { 0% { fill: var(--paper); } 50% { fill: var(--canvas); } }
@keyframes spin-pop { 0% { scale: 1; } 35% { scale: 1.085; } 100% { scale: 1; } }
@keyframes spin-hat-drop { from { opacity: 0; translate: -50% -330%; rotate: -50deg; } 60% { opacity: 1; } }
@keyframes spin-rumble { 0%, 100% { translate: 0 0; } 25% { translate: 1.5px -1px; } 50% { translate: -1px 1.5px; } 75% { translate: -1.5px -.5px; } }
@keyframes spin-mark { 0% { scale: .7; } }
@keyframes spin-rise { from { opacity: 0; translate: 0 14px; } }

/* The card: the form, then the result */
.spin-panel { width: 100%; max-width: 520px; padding: 20px 18px; box-shadow: 7px 8px 0 var(--ink); }
.spin-panel .mm-field > label { font-size: 13px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--label); }
.spin-code { font-weight: 700; font-size: 20px; letter-spacing: .22em; text-transform: uppercase; }
.spin-code::placeholder { opacity: .35; }
.spin-go { padding: 14px 18px 12px; }
.spin-go > span { font-size: 28px; line-height: 1; }
.spin-go:hover:not([disabled]) { color: #fff; }
.spin-small { font-size: 13px; line-height: 1.45; opacity: .85; }
.spin-small a { font-weight: 600; }
.spin-panel .mm-msg { font-size: 15px; font-weight: 600; }

.spin-result-title { font-size: clamp(44px, 12vw, 64px); }
.spin-result-title:focus { outline: none; }
.spin-result-text { font-size: 17px; line-height: 1.45; overflow-wrap: anywhere; }
.spin-result-actions { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 4px; }
.spin-result-actions > * { flex: 1 1 200px; }

/* The ticket stub: a notch bitten out of each side. */
.spin-ticket { position: relative; display: grid; justify-items: center; gap: 2px; border: var(--border); background: var(--canvas); padding: 14px 18px 12px; text-align: center; }
.spin-ticket::before, .spin-ticket::after { content: ""; position: absolute; top: 50%; width: 22px; height: 22px; margin-top: -11px; border: var(--border); border-radius: 50%; background: var(--paper); }
.spin-ticket::before { left: -14px; clip-path: inset(-4px -4px -4px 11px); }
.spin-ticket::after { right: -14px; clip-path: inset(-4px 11px -4px -4px); }
.spin-ticket-label, .spin-ticket-for { font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.spin-ticket-code { font-family: var(--display); font-size: clamp(34px, 10vw, 46px); line-height: 1; letter-spacing: .02em; user-select: all; }
.spin-prize { border-left: 6px solid var(--ink); padding-left: 12px; font-weight: 600; font-size: 17px; overflow-wrap: anywhere; }
.spin-prize .mm-label { display: block; margin-bottom: 2px; }

.spin-steps { list-style: none; padding: 0; display: grid; gap: 8px; }
.spin-step { display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; font-size: 15px; line-height: 1.4; }
.spin-step-n { display: grid; place-items: center; width: 28px; height: 28px; border: 2px solid var(--ink); font-size: 13px; font-weight: 700; }
.spin-step.is-done .spin-step-n { background: var(--ink); color: var(--canvas); }
.spin-step.is-now .spin-step-n { background: var(--canvas); }
.spin-step.is-next { opacity: .7; }

/* How it works */
.spin-how { width: 100%; max-width: 520px; }
.spin-how ol { list-style: none; padding: 0; margin: 0; display: grid; gap: 0; border: var(--border); }
.spin-how li { display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: center; padding: 14px 16px; font-size: 15px; line-height: 1.4; }
.spin-how li + li { border-top: var(--border); }
.spin-how li > span { font-size: 44px; line-height: .9; text-align: center; }

.spin-confetti { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 900; pointer-events: none; }

/* The confirmation page */
.spin-confirm .mm-main { padding-top: 26px; }
.spin-confirm .spin-panel { max-width: none; }

/* A sticker on the corner of the wheel. */
.spin-sticker { position: absolute; left: -3%; bottom: -1%; z-index: 4; display: grid; place-items: center; width: 27%; aspect-ratio: 1; border: var(--border); border-radius: 50%; background: var(--paper); font-family: var(--display); font-size: clamp(11px, 3.3vw, 17px); line-height: .98; text-align: center; text-transform: uppercase; rotate: -13deg; box-shadow: 3px 4px 0 var(--ink); pointer-events: none; }

@media (min-width: 960px) {
  .spin-top { padding: 20px 28px 0; }
  .spin-main { padding: 20px max(28px, (100% - 1124px) / 2) 72px; grid-template-columns: minmax(0, 500px) minmax(0, 1fr); grid-template-areas: "hero wheel" "panel wheel" "how how"; column-gap: 56px; row-gap: 24px; justify-items: start; align-content: start; }
  .spin-hero { grid-area: hero; align-self: end; max-width: none; }
  .spin-panel { grid-area: panel; align-self: start; max-width: none; padding: 24px; }
  .spin-how { grid-area: how; max-width: none; margin-top: 22px; }
  .spin-how ol { grid-template-columns: repeat(3, 1fr); }
  .spin-how li { align-items: start; padding: 18px; }
  .spin-how li + li { border-top: 0; border-left: var(--border); }
  .spin-stage { grid-area: wheel; align-self: center; justify-self: center; width: min(100%, 600px, 76vh); margin: 0; }
  .spin-title { font-size: clamp(76px, 6.7vw, 100px); }
  .spin-prize-top:empty { min-height: 4.1em; }
  .spin-hub { font-size: clamp(26px, 3vw, 40px); }
  .spin-sticker { font-size: clamp(15px, 1.5vw, 21px); }
}

@keyframes spin-mode-in { from { opacity: 0; } }
