/* Halo ring (js/ring.js): tachometer / power meter around the speed readout.
   Colours follow the shell's theme variables; colour changes animate through the
   transitions on the consuming properties. Only opacity, transform and stroke-dashoffset
   are animated; no filters. */

.ring {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  -webkit-user-select: none;
  user-select: none;
}

/* Rotating dashed ring: a sibling <div> that ring.js inserts just before the svg and sizes
   (inline %) to the r = 160 part of the same box. It is turned by a Web Animation on the
   compositor; keep it on its own layer so pausing and resuming never re-rasterises it. */
.ring-spin-layer {
  position: absolute;
  pointer-events: none;
  will-change: transform;
}
.ring-spin-layer svg { display: block; width: 100%; height: 100%; overflow: visible; }

/* ---- static layers ---- */
.ring-hair { stroke: rgba(255, 255, 255, 0.05); }
.ring-spin { stroke: rgba(255, 255, 255, 0.07); }
.ring-track { stroke: rgba(255, 255, 255, 0.1); }
/* One path per kind (red / regen); ring.js swaps in a fresh path when a kind becomes active,
   so this only animates colour changes between two sounds of the same kind. */
.ring-zone { opacity: 0.75; transition: stroke 0.6s; }
.ring-zone-red { stroke: #ff4d5e; }
.ring-zone-regen { stroke: rgb(var(--regen-rgb, 95, 214, 255)); }

/* ---- value fill + head: accent, regen while regenerating, white on the rev limiter ---- */
.ring-glow,
.ring-fill { stroke: rgb(var(--accent-rgb, 255, 106, 43)); transition: stroke 0.5s; }
.ring-glow { opacity: 0.16; }
.ring-head-glow { fill: rgb(var(--accent-rgb, 255, 106, 43)); opacity: 0.35; transition: fill 0.5s; }
.ring-regen .ring-glow,
.ring-regen .ring-fill { stroke: rgb(var(--regen-rgb, 95, 214, 255)); }
.ring-regen .ring-head-glow { fill: rgb(var(--regen-rgb, 95, 214, 255)); }
/* The limiter flash is instant (a cut lasts ~60 ms) and fades back to the accent. */
.ring-limit .ring-glow,
.ring-limit .ring-fill { stroke: #fff; transition: none; }
.ring-limit .ring-head-glow { fill: #fff; transition: none; }

.ring-comet { stroke: #fff; opacity: 0; }

/* ---- scale ---- */
.ring-tk { transform-box: fill-box; transform-origin: center; }
.ring-tick { stroke: rgba(238, 243, 248, 0.3); transition: stroke 0.5s; }
.ring-tick-major { stroke: rgba(238, 243, 248, 0.75); }
.ring-tick.ring-tick-red { stroke: #ff4d5e; }
.ring-tick.ring-tick-regen { stroke: rgba(var(--regen-rgb, 95, 214, 255), 0.667); }
.ring-label {
  fill: rgba(238, 243, 248, 0.78);
  font-family: 'Sora', 'Segoe UI', system-ui, sans-serif;
  font-size: 19px;
  font-weight: 400;
  transition: fill 0.5s;
}
.ring-label.ring-label-red { fill: #ff7b88; }
.ring-label.ring-label-regen {
  fill: rgb(var(--regen-rgb, 95, 214, 255));
  font-size: 11px;
  letter-spacing: 2px;
}

/* ---- keyframes ---- */
@keyframes ringDraw {
  from { stroke-dashoffset: 1131; }
  to { stroke-dashoffset: 0; }
}
/* Three identical comets: the intro one, and two that alternate to restart on each switch. */
@keyframes ringComet {
  0% { opacity: 1; stroke-dashoffset: 0; }
  85% { opacity: 1; }
  100% { opacity: 0; stroke-dashoffset: -1131; }
}
@keyframes ringComet0 {
  0% { opacity: 1; stroke-dashoffset: 0; }
  85% { opacity: 1; }
  100% { opacity: 0; stroke-dashoffset: -1131; }
}
@keyframes ringComet1 {
  0% { opacity: 1; stroke-dashoffset: 0; }
  85% { opacity: 1; }
  100% { opacity: 0; stroke-dashoffset: -1131; }
}
@keyframes ringFade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes ringPop {
  from { opacity: 0; transform: scale(0.3); }
  to { opacity: 1; transform: none; }
}

/* ---- intro (body.intro): track draws on with the comet, then ticks/labels fade in.
   Each tick/label has an inline animation-delay set by ring.js. The comet and tick rules
   stop for good after the first animated switch (.ring-switched), so they can't restart
   when the switch class goes away while body.intro is still set. ---- */
.intro .ring-track { animation: ringDraw 1.05s 0.15s cubic-bezier(0.65, 0, 0.3, 1) backwards; }
.intro .ring:not(.ring-switched) .ring-comet { animation: ringComet 1.05s 0.15s cubic-bezier(0.65, 0, 0.3, 1) backwards; }
.intro .ring:not(.ring-switched) .ring-tk { animation: ringFade 0.35s backwards; }

/* ---- sound switch: one comet lap, ticks and labels pop in (ticks are rebuilt, so they
   always start fresh). ---- */
.ring-sw0 .ring-comet { animation: ringComet0 0.95s cubic-bezier(0.5, 0, 0.25, 1) backwards; }
.ring-sw1 .ring-comet { animation: ringComet1 0.95s cubic-bezier(0.5, 0, 0.25, 1) backwards; }
.ring-sw0 .ring-tk,
.ring-sw1 .ring-tk { animation: ringPop 0.4s backwards; }

/* ---- driving (body.calm): no comet, short and undelayed changes.
   The comet is only hidden (not animation:none) so it can never replay when calm ends. ---- */
.calm .ring .fx { opacity: 0 !important; visibility: hidden !important; }
.calm .ring .ring-tk { animation-duration: 0.25s !important; animation-delay: 0s !important; }
/* Only shorten the colour transitions declared above: a bare transition-duration on an
   element whose transition-property is the default `all` would start animating cx/cy. */
.calm .ring-zone,
.calm .ring-glow,
.calm .ring-fill,
.calm .ring-head-glow,
.calm .ring-tick,
.calm .ring-label { transition-duration: 0.25s !important; }

@media (prefers-reduced-motion: reduce) {
  .ring,
  .ring * { animation: none !important; transition: none !important; }
  .ring .fx { visibility: hidden; }
  .ring-spin-layer { will-change: auto; }
}
