/* ===========================================================================
   wheel.css — spinning wheel stage, pointer and result overlay
   Loaded only by pages that render a wheel.
   =========================================================================== */

.wheel-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
}

.wheel-frame {
  position: relative;
  width: 100%;
  max-width: 560px;
  aspect-ratio: 1 / 1;
  margin-inline: auto;
  /* Prevents the browser from treating a drag on the wheel as a page scroll. */
  touch-action: manipulation;
}

.wheel-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 6px 24px rgba(17, 24, 39, .18), inset 0 0 0 6px var(--surface);
}
:root[data-theme='dark'] .wheel-frame canvas {
  box-shadow: 0 6px 24px rgba(0, 0, 0, .55), inset 0 0 0 6px var(--surface);
}

/* Fixed pointer at 12 o'clock. The engine stops the winning segment centre
   exactly underneath this tip — see wheel-engine.js. */
.wheel-pointer {
  position: absolute;
  top: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 34px;
  height: 44px;
  z-index: 3;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .3));
  pointer-events: none;
}
.wheel-pointer svg { width: 100%; height: 100%; display: block; }

.wheel-hub {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 22%;
  max-width: 116px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid var(--border-strong);
  display: grid;
  place-items: center;
  z-index: 2;
  box-shadow: var(--shadow);
  padding: .25rem;
}
.wheel-hub button {
  width: 100%; height: 100%; border-radius: 50%; border: 0;
  background: var(--primary); color: #fff; font: inherit; font-weight: 800;
  font-size: clamp(.75rem, .4rem + 1.6vw, 1.1rem); cursor: pointer;
  text-transform: uppercase; letter-spacing: .04em;
}
:root[data-theme='dark'] .wheel-hub button { color: #0b1220; }
.wheel-hub button:hover:not(:disabled) { background: var(--primary-strong); }
.wheel-hub button:disabled { opacity: .6; cursor: not-allowed; }

.wheel-empty {
  position: absolute; inset: 12%;
  display: grid; place-items: center; text-align: center;
  color: var(--muted); font-size: .95rem; padding: 1rem;
  border-radius: 50%;
}
.wheel-empty[hidden] { display: none; }

.wheel-controls {
  display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; width: 100%;
}

.wheel-legend {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-wrap: wrap; gap: .35rem; justify-content: center;
  max-height: 150px; overflow-y: auto; width: 100%;
}
.wheel-legend li { margin: 0; }
.wheel-legend__item {
  display: inline-flex; align-items: center; gap: .35rem;
  border: 1px solid var(--border); border-radius: 999px;
  padding: .15rem .6rem; font-size: .8rem; background: var(--surface);
  max-width: 220px;
}
.wheel-legend__swatch {
  width: .7rem; height: .7rem; border-radius: 3px; flex: 0 0 auto;
  border: 1px solid rgba(0, 0, 0, .2);
}
.wheel-legend__index { font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 700; }
.wheel-legend__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wheel-legend__item.is-winner { border-color: var(--primary); background: var(--primary-soft); font-weight: 700; }

/* Result overlay — deliberately contains no advertising. */
.wheel-result {
  position: absolute; inset: 0; z-index: 4;
  display: grid; place-items: center; padding: 1rem;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-radius: 50%;
}
.wheel-result[hidden] { display: none; }
.wheel-result__inner {
  background: var(--surface); border: 2px solid var(--primary);
  border-radius: var(--radius-lg); padding: 1rem 1.25rem; text-align: center;
  box-shadow: var(--shadow-lg); max-width: 88%;
  animation: rt-pop .22s ease-out;
}
@keyframes rt-pop { from { transform: scale(.9); opacity: 0; } }
.wheel-result__label { font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.wheel-result__value {
  font-size: clamp(1.3rem, .9rem + 2.4vw, 2.1rem); font-weight: 800;
  overflow-wrap: anywhere; margin: .2rem 0 .6rem; line-height: 1.2;
}
.wheel-result__actions { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; }

/* Confetti canvas sits above the wheel but never blocks clicks. */
.confetti-layer {
  position: fixed; inset: 0; pointer-events: none; z-index: 200;
}

/* Full-screen presentation mode */
body.is-fullscreen .wheel-frame { max-width: min(78vh, 92vw); }
body.is-fullscreen .wheel-legend { max-height: 90px; }

@media (max-width: 420px) {
  .wheel-frame { max-width: 100%; }
  .wheel-legend { max-height: 110px; }
}
