/* Fairground wheel engine (sv-wh-). Uses the site tokens from style.css. */

.sv-wh {
  container-type: inline-size;
  width: 100%;
  max-width: 980px;
}

.sv-wh-in {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sv-s4);
  align-items: center;
  justify-items: center;
}

.sv-wh-stage {
  position: relative;
  width: min(100%, 500px);
}

.sv-wh-svg {
  width: 100%;
  height: auto;
  overflow: visible;
  filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.45));
}

.sv-wh-stand { fill: #3b2410; stroke: #ffcf5a; stroke-width: 3; stroke-linejoin: round; }
.sv-wh-halo { fill: none; stroke: rgba(255, 207, 90, 0.18); stroke-width: 10; }
.sv-wh-well { fill: #2a1a08; }
.sv-wh-seg { stroke: none; }
.sv-wh-rib { stroke: rgba(255, 236, 190, 0.55); stroke-width: 1.6; }
.sv-wh-peg { fill: #fff3c4; stroke: #8a5a16; stroke-width: 1.4; }

.sv-wh-label {
  font-family: var(--sv-font-display);
  font-size: 25px;
  font-weight: 900;
  letter-spacing: -0.02em;
  text-anchor: middle;
  dominant-baseline: central;
  paint-order: stroke;
  stroke: rgba(0, 0, 0, 0.18);
  stroke-width: 2px;
}

.sv-wh-label.is-zero { font-size: 21px; font-weight: 800; stroke: none; }

/* Bulbs: a slow twinkle at rest, a quick chase while turning, a flash on a hit */
.sv-wh-bulb {
  fill: #fff3c4;
  stroke: rgba(255, 207, 90, 0.45);
  stroke-width: 4;
  animation: sv-wh-twinkle 1.8s ease-in-out infinite alternate;
}

.sv-wh-bulb.is-b { animation-delay: -0.9s; }
.sv-wh.is-spinning .sv-wh-bulb { animation-duration: 0.22s; }
.sv-wh.is-hit .sv-wh-bulb { animation: sv-wh-flash 0.18s linear 8 alternate; }

@keyframes sv-wh-twinkle {
  from { opacity: 0.35; }
  to { opacity: 1; }
}

@keyframes sv-wh-flash {
  from { opacity: 1; }
  to { opacity: 0.2; }
}

/* The landing segment */
.sv-wh-glow {
  fill: #fffbe8;
  opacity: 0;
  stroke: #ffcf5a;
  stroke-width: 0;
  pointer-events: none;
}

.sv-wh.is-hit .sv-wh-glow {
  stroke-width: 5;
  animation: sv-wh-pulse 0.9s var(--sv-ease-out) 3 alternate both;
}

.sv-wh.is-miss .sv-wh-glow { opacity: 0.14; stroke-width: 3; stroke: rgba(255, 255, 255, 0.4); }

@keyframes sv-wh-pulse {
  from { opacity: 0.1; }
  to { opacity: 0.42; }
}

/* Hub */
.sv-wh-hubring { fill: #2a1a08; stroke: #ffcf5a; stroke-width: 4; }
.sv-wh-hub { stroke: rgba(255, 255, 255, 0.35); stroke-width: 2; }
.sv-wh-hub.is-pop { animation: sv-wh-pop 420ms var(--sv-ease-out); }

@keyframes sv-wh-pop {
  0% { transform: scale(0.94); }
  45% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.sv-wh-hubtext,
.sv-wh-hubsub {
  font-family: var(--sv-font-display);
  text-anchor: middle;
  dominant-baseline: central;
  fill: var(--sv-on-coral);
  pointer-events: none;
}

.sv-wh-hubtext { font-size: 30px; font-weight: 900; letter-spacing: -0.01em; }
.sv-wh-hubsub { font-size: 15px; font-weight: 800; fill: #3b2606; }
.sv-wh.is-hit .sv-wh-hubtext { transform: translateY(-8px); }

/* Pointer */
.sv-wh-flap { stroke: #8a5a16; stroke-width: 2; stroke-linejoin: round; }
.sv-wh-cap { fill: #ffbe5c; stroke: #fff1c4; stroke-width: 3; }
.sv-wh-spark { pointer-events: none; }

/* Legend */
.sv-wh-legend {
  width: min(100%, 560px);
  padding: var(--sv-s3) var(--sv-s4);
  border-radius: var(--sv-r);
  background: rgba(6, 7, 25, 0.72);
  border: 1px solid var(--sv-line-2);
  backdrop-filter: blur(6px);
}

.sv-wh-legend__title {
  margin: 0 0 var(--sv-s2);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sv-faint);
}

.sv-wh-legend__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--sv-s2);
}

.sv-wh-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 3px;
  border-radius: var(--sv-r-pill);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid transparent;
  font-size: 13px;
  color: var(--sv-muted);
  transition: transform var(--sv-fast) var(--sv-ease-out), border-color var(--sv-fast) var(--sv-ease-out),
    background-color var(--sv-fast) var(--sv-ease-out);
}

.sv-wh-legend__item.is-lit {
  border-color: var(--sv-gold);
  background: rgba(255, 207, 90, 0.12);
  color: var(--sv-ink);
  transform: scale(1.04);
}

.sv-wh-chip {
  display: inline-grid;
  place-items: center;
  min-width: 46px;
  height: 26px;
  padding: 0 8px;
  border-radius: var(--sv-r-pill);
  background: var(--chip);
  color: var(--chip-ink);
  font-family: var(--sv-font-display);
  font-weight: 900;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.sv-wh-legend__item.is-none .sv-wh-chip { box-shadow: inset 0 0 0 1px var(--sv-line-2); }

.sv-wh-legend__note {
  margin: var(--sv-s2) 0 0;
  font-size: 12.5px;
  color: var(--sv-faint);
}

/* Wide stages: the legend sits beside the wheel as a column */
@container (min-width: 760px) {
  .sv-wh-in {
    grid-template-columns: minmax(0, 1fr) 230px;
    justify-items: stretch;
    gap: var(--sv-s6);
  }
  .sv-wh-stage { justify-self: end; }
  .sv-wh-legend { position: static; width: 100%; }
  .sv-wh-legend__list { flex-direction: column; }
  .sv-wh-legend__item { padding-right: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .sv-wh-bulb,
  .sv-wh.is-spinning .sv-wh-bulb,
  .sv-wh.is-hit .sv-wh-bulb { animation: none; opacity: 0.9; }
  .sv-wh.is-hit .sv-wh-glow { animation: none; opacity: 0.32; }
  .sv-wh-hub.is-pop { animation: none; }
}

/* Narrow stages: a compact legend so the wheel keeps the room */
@container (max-width: 520px) {
  .sv-wh-legend { padding: var(--sv-s2) var(--sv-s3); }
  .sv-wh-legend__title { font-size: 11px; margin-bottom: 6px; }
  .sv-wh-legend__list { gap: 6px; }
  .sv-wh-legend__item { font-size: 12px; padding: 2px 8px 2px 2px; gap: 4px; }
  .sv-wh-chip { min-width: 38px; height: 22px; font-size: 12.5px; padding: 0 6px; }
  .sv-wh-legend__note { font-size: 11.5px; margin-top: 6px; }
}

