/* loaders.css — per-theme boot loader animations.
 *
 * Each theme can declare a `loader` slug in its manifest.json. The
 * theme-runtime.js writes that slug as a body class (`loader-<id>`).
 * The premium-loader markup (#np-loader) is the same on every page,
 * but the body class swaps in a different animation + colour palette
 * + status text.
 *
 * Every loader keeps the same structural budget: ≤ 3 seconds,
 * monochrome + accent only, no image dependencies (vector / CSS),
 * accessible (respects prefers-reduced-motion).
 *
 * Loader IDs (referenced by manifest.json `loader` field):
 *   generic                  — default fallback
 *   polar-instrument-boot    — Polar Field Lab pilot
 *   naturalist-quill         — Naturalist (TODO Phase 6)
 *   codex-illumination       — Obsidian Codex (TODO Phase 6)
 *   greenhouse-fern-unfurl   — Cretaceous Greenhouse (TODO Phase 6)
 *   glass-shatter            — Volcanic Glass (TODO Phase 6)
 *   vellum-ink-bleed         — Vellum Atlas (TODO Phase 6)
 *   solar-bloom              — Solarpunk (TODO Phase 6)
 *   deep-glow                — Bioluminescent Deep (TODO Phase 6)
 *   foundry-ignition         — Steampunk Foundry (TODO Phase 6)
 *   martian-dust-rise        — Martian Survey (TODO Phase 6)
 */

/* ── Polar Instrument Boot ─────────────────────────────────────────
 * Reads as: instrument self-test on boot. Three status lights
 * flicker on in sequence, an oscilloscope sweep crosses left-to-
 * right, and a status text scrolls "INSTRUMENTS · CALIBRATING".
 * 2.6 s total. Loops.
 */

body.loader-polar-instrument-boot #np-loader {
  background:
    radial-gradient(ellipse at 50% 38%,
      color-mix(in srgb, var(--accent), transparent 88%), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-mono);
}

body.loader-polar-instrument-boot #np-loader::before {
  content: "";
  display: block;
  position: absolute;
  inset: 50% 0 auto 0;
  height: 1px;
  background: color-mix(in srgb, var(--accent), transparent 40%);
  transform: translateY(-50%);
  animation: polar-scope-sweep 2.6s linear infinite;
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent), transparent 60%);
}

body.loader-polar-instrument-boot #np-loader::after {
  content: "INSTRUMENTS · CALIBRATING · "
           "INSTRUMENTS · CALIBRATING · "
           "INSTRUMENTS · CALIBRATING";
  position: absolute;
  bottom: 18%;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--accent), var(--ink-dim) 45%);
  white-space: nowrap;
  overflow: hidden;
  animation: polar-status-blink 1.4s steps(2) infinite;
}

/* Boot lights row, painted via the existing .ld-bar slot */
body.loader-polar-instrument-boot #np-loader .ld-bar {
  display: flex !important;
  gap: 8px;
  justify-content: center;
  align-items: center;
  position: absolute;
  top: 56%;
  left: 50%;
  transform: translateX(-50%);
  width: auto;
  height: auto;
  background: transparent !important;
}
body.loader-polar-instrument-boot #np-loader .ld-bar::before,
body.loader-polar-instrument-boot #np-loader .ld-bar::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent), transparent 50%);
  box-shadow: 0 0 8px color-mix(in srgb, var(--accent), transparent 30%);
  animation: polar-light-flicker 2.6s ease-in-out infinite;
  margin: 0 !important;
}
body.loader-polar-instrument-boot #np-loader .ld-bar::after {
  animation-delay: 0.3s;
}

@keyframes polar-scope-sweep {
  0%   { left: -10%; opacity: 0; width: 12%; }
  10%  { opacity: 1; }
  50%  { left: 50%; width: 18%; }
  90%  { opacity: 1; }
  100% { left: 110%; opacity: 0; width: 12%; }
}
@keyframes polar-status-blink {
  0%, 50% { opacity: 0.78; }
  51%, 100% { opacity: 0.42; }
}
@keyframes polar-light-flicker {
  0%, 30%   { background: color-mix(in srgb, var(--accent), transparent 80%); }
  35%, 100% { background: var(--accent); box-shadow: 0 0 12px var(--accent); }
}

@media (prefers-reduced-motion: reduce) {
  body.loader-polar-instrument-boot #np-loader::before,
  body.loader-polar-instrument-boot #np-loader::after,
  body.loader-polar-instrument-boot #np-loader .ld-bar::before,
  body.loader-polar-instrument-boot #np-loader .ld-bar::after {
    animation: none;
  }
}
