/* ============================================================
   UNIVERSAL PREMIUM RACE LOADER  —  one loader for the whole site.
   Dark grid → official SMSP circuit draws → race cars → dissolve.
   Standalone (no build) — linked on every page. Brand-neutral
   red→orange; the motion itself is the brand (no text / % / bar).
   ============================================================ */
.rloader {
  position: fixed;
  inset: 0;
  z-index: 100000; /* above masthead (800) + megamenu (900) + switch (640) */
  display: grid;
  place-items: center;
  background: #07080c;
  overflow: hidden;
  opacity: 1;
  transition: opacity 0.65s ease;
}
.rloader.is-hidden {
  opacity: 0;
  pointer-events: none;
}

/* Stage 1 — dark intro: blueprint grid + breathing ambient glow */
.rloader__grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: radial-gradient(120% 120% at 50% 50%, #000 28%, transparent 78%);
  mask-image: radial-gradient(120% 120% at 50% 50%, #000 28%, transparent 78%);
  opacity: 0.55;
}
.rloader__glow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 82vw;
  max-width: 1100px;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(var(--brand-rgb, 0, 55, 230), 0.2), transparent 60%);
  filter: blur(42px);
  opacity: 0.5;
  animation: rl-breathe 5s ease-in-out infinite;
}
.rloader.is-finish .rloader__glow {
  opacity: 0.92;
}

/* the circuit */
/* centred column: compact circuit + progress readout below it */
.rloader__stage {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(1.1rem, 3vh, 1.7rem);
  transition: opacity 0.45s ease;
}
.rloader.is-exit .rloader__stage {
  opacity: 0; /* page-transition cover shows only the dark environment */
}
.rloader__svg {
  width: 230px; /* compact emblem (height follows the 2513:1388 ratio ≈ 127px) */
  height: auto;
  overflow: visible;
}

/* progress bar + common "Loading…" / % readout */
.rloader__hud {
  width: 240px;
  max-width: 72vw;
}
.rloader__bar {
  position: relative;
  height: 2px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.13);
  overflow: hidden;
}
.rloader__bar-fill {
  display: block;
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left;
  background: linear-gradient(90deg, var(--color-brand, #0037e6), var(--color-brand-bright, #5a73ff));
  box-shadow: 0 0 10px rgba(var(--brand-rgb, 0, 55, 230), 0.7);
}
.rloader__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.8rem;
  font-family: var(--font-mono, "JetBrains Mono", ui-monospace, monospace);
  font-size: 0.6rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.42);
}
.rloader__pct {
  color: rgba(255, 255, 255, 0.85);
  font-variant-numeric: tabular-nums;
}

.rloader__halo,
.rloader__edge,
.rloader__path,
.rloader__core {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1; /* hidden until the draw */
}
.rloader__halo {
  stroke: rgba(var(--brand-rgb, 0, 55, 230), 0.5);
  stroke-width: 90;
  filter: blur(24px);
  opacity: 0.6;
}
.rloader__edge {
  stroke: #08090d;
  stroke-width: 64;
}
.rloader__path {
  stroke: var(--color-brand-bright, #5a73ff);
  stroke-width: 42;
  filter: drop-shadow(0 0 17px rgba(var(--brand-rgb, 0, 55, 230), 0.6));
  transition: filter 0.6s ease;
}
.rloader.is-finish .rloader__path {
  filter: drop-shadow(0 0 32px rgba(var(--brand-rgb, 0, 55, 230), 0.92));
}
.rloader__core {
  stroke: #fff;
  stroke-width: 4; /* thin, faint highlight — the line stays solid blue, never "turns light" */
  opacity: 0.35;
  transition: opacity 0.6s ease;
}
.rloader.is-drawn .rloader__core {
  opacity: 0.35; /* constant: no bright-white reveal after the draw */
}

/* race cars (top-down, headlight + taillight + motion-blur trail) */
.rl-car {
  opacity: 0;
  transition: opacity 0.5s ease;
}
.rloader.is-racing .rl-car {
  opacity: 1;
}
.rl-car__trail {
  fill: var(--car-col, #ff5a2a);
  opacity: 0.22;
  filter: blur(3px);
}
.rl-car__shadow {
  fill: #000;
  opacity: 0.32;
}
.rl-car__body {
  fill: #14171f;
  stroke: rgba(255, 255, 255, 0.16);
  stroke-width: 1.5;
}
.rl-car__accent {
  fill: var(--car-col, #ff5a1e);
}
.rl-car__glass {
  fill: rgba(150, 200, 255, 0.42);
}
.rl-car__head {
  fill: #fff;
  opacity: 0.92;
  filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.8));
}
.rl-car__tail {
  fill: #ff6a2e;
  filter: drop-shadow(0 0 7px rgba(255, 100, 40, 0.95));
}

/* SMSP red tuning — its --color-brand-bright (#f15d5d) is a pale salmon that
   reads "washed out" as neon; give the red theme a vivid, saturated stroke +
   bar so it has the same punch as the blue. (ARDC/index blue is unchanged.) */
[data-theme="smp"] .rloader__path {
  stroke: #ff2e2e;
}
[data-theme="smp"] .rloader__bar-fill {
  background: linear-gradient(90deg, #d80d0d, #ff2e2e);
}

@keyframes rl-breathe {
  0%, 100% { opacity: 0.38; }
  50% { opacity: 0.66; }
}

@media (prefers-reduced-motion: reduce) {
  .rloader { transition: opacity 0.4s ease; }
  .rloader__glow { animation: none; }
  .rloader__halo,
  .rloader__edge,
  .rloader__path,
  .rloader__core { stroke-dashoffset: 0; }
  .rloader__core { opacity: 0.35; }
  .rl-car { display: none; }
  .rloader__bar-fill { transform: scaleX(1); }
}
