/* =========================================================
   ════════  V5.4 — ZÜNDUNG (Loader)  ════════
   Ein Zeichen, ein Ring, eine Zeile:
   - EF zeichnet sich Strich für Strich (Verlaufs-Stroke)
   - ein Elektron umkreist es auf der Orbit-Ellipse; die Bahn
     hinter ihm ist der Fortschritt
   - Exit: Inhalt blendet aus, ein Plasma-Ring schiesst aus der
     Mitte (nur transform/opacity), Fläche fadet, das Fluid
     zündet an derselben Stelle (main.js)
   Ersetzt den v4-Vorhang; alte .loader-*-Regeln bleiben
   ungenutzt in styles.css.
   ========================================================= */

.loader.ign {
    --ign-bg: #0A0E27;
    --ign-ink: #E9E6FF;
    --ign-soft: #8F8AB8;
    --ign-track: rgba(167, 139, 250, 0.16);
    --ign-s1: #6366F1;
    --ign-s2: #8B5CF6;
    --ign-s3: #EC4899;
    --ign-glow: rgba(139, 92, 246, 0.55);
    background: none;
    transition: none;
    /* Notbremse: läuft main.js nie (Fehler/Blocker), gibt die Seite
       nach 8 s trotzdem frei */
    animation: ignFailsafe 0.01s linear 8s forwards;
}
[data-theme="light"] .loader.ign {
    --ign-bg: #F6F4FD;
    --ign-ink: #1E1645;
    --ign-soft: #5A5482;
    --ign-track: rgba(79, 53, 201, 0.16);
    --ign-s1: #4F46E5;
    --ign-s2: #7C3AED;
    --ign-s3: #DB2777;
    --ign-glow: rgba(109, 79, 216, 0.35);
}
@keyframes ignFailsafe { to { visibility: hidden; pointer-events: none; opacity: 0; } }
.loader.ign::before, .loader.ign::after { content: none; }

.ign-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    background: var(--ign-bg);                    /* Fallback ohne color-mix */
    background:
        radial-gradient(48% 42% at 50% 50%, color-mix(in srgb, var(--ign-s2) 13%, transparent), transparent 70%),
        var(--ign-bg);
}

/* ---------- HUD: Crop-Marks + Etiketten ---------- */
.ign-hud { position: absolute; inset: clamp(14px, 3vw, 28px); z-index: 1; pointer-events: none; }
.ign-crop { position: absolute; width: 16px; height: 16px; border: 0 solid var(--ign-soft); opacity: 0; animation: ignIn 0.5s ease 0.1s forwards; }
.ign-crop.c1 { top: 0; left: 0; border-top-width: 1px; border-left-width: 1px; }
.ign-crop.c2 { top: 0; right: 0; border-top-width: 1px; border-right-width: 1px; }
.ign-crop.c3 { bottom: 0; left: 0; border-bottom-width: 1px; border-left-width: 1px; }
.ign-crop.c4 { bottom: 0; right: 0; border-bottom-width: 1px; border-right-width: 1px; }
.ign-tag {
    position: absolute;
    font: 500 0.7rem var(--font-mono);
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ign-soft);
    opacity: 0;
    animation: ignIn 0.5s ease 0.2s forwards;
}
.ign-tag.t1 { top: 2px; left: 26px; }
.ign-tag.t2 { bottom: 2px; right: 26px; }

/* ---------- Zentrum ---------- */
.ign-core {
    position: relative;
    z-index: 2;
    width: min(500px, 86vw);
    transition: opacity 0.2s ease, transform 0.35s cubic-bezier(0.5, 0, 0.75, 0);
}
.ign-plasma {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 46%;
    aspect-ratio: 1;
    margin: -23% 0 0 -23%;
    border-radius: 50%;
    background: conic-gradient(from 0deg, var(--ign-s1), var(--ign-s3), var(--ign-s2), #38BDF8, var(--ign-s1));
    filter: blur(42px);
    opacity: 0.32;
    animation: plasmaSpin 7s linear infinite;
}
[data-theme="light"] .ign-plasma { opacity: 0.22; }
.ign-svg { position: relative; display: block; width: 100%; height: auto; overflow: visible; }
.ign-svg .ig1 { stop-color: var(--ign-s1); }
.ign-svg .ig2 { stop-color: var(--ign-s2); }
.ign-svg .ig3 { stop-color: var(--ign-s3); }
.ign-track, .ign-prog { fill: none; stroke-width: 1.2; }
.ign-track { stroke: var(--ign-track); stroke-dasharray: 2 5; }
.ign-prog { stroke: url(#ignG); stroke-width: 1.6; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; }
.ign-e { fill: #fff; filter: drop-shadow(0 0 6px var(--ign-glow)) drop-shadow(0 0 2px var(--ign-s3)); }
[data-theme="light"] .ign-e { fill: var(--ign-s2); }
.ign-mark { filter: drop-shadow(0 0 14px var(--ign-glow)); }
.ign-mark path {
    fill: none;
    stroke: url(#ignG);
    stroke-width: 9;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    animation: ignDraw 0.26s cubic-bezier(0.65, 0, 0.35, 1) forwards;
    animation-delay: calc(var(--d) * 48ms + 100ms);
}
@keyframes ignDraw { to { stroke-dashoffset: 0; } }

/* Statuszeile: absolut unter dem Zeichen → das EF sitzt exakt mittig */
.ign-status {
    position: absolute;
    left: 50%;
    top: calc(100% + 0.4rem);
    translate: -50% 0;
    display: flex;
    align-items: center;
    gap: 0.7rem;
    white-space: nowrap;
    font: 500 0.74rem var(--font-mono);
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ign-soft);
    opacity: 0;
    animation: ignIn 0.5s ease 0.3s forwards;
}
.ign-status b { min-width: 2.4ch; font-weight: 600; color: var(--ign-ink); font-variant-numeric: tabular-nums; text-align: right; }
.ign-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ign-s3); box-shadow: 0 0 10px var(--ign-s3); animation: ignBlink 1.1s ease-in-out infinite; }
@keyframes ignBlink { 50% { opacity: 0.25; } }
@keyframes ignIn { to { opacity: 1; } }

/* Kurz vor dem Exit: Signal steht → EF leuchtet einmal auf */
.loader.ign.lock .ign-mark { animation: ignLock 0.32s ease-out; }
.loader.ign.lock .ign-dot { animation: none; background: #34D399; box-shadow: 0 0 10px #34D399; }
@keyframes ignLock { 40% { filter: drop-shadow(0 0 26px var(--ign-glow)) brightness(1.25); } }

/* ---------- Exit: Plasma-Impuls ---------- */
.ign-ring {
    position: absolute;
    left: 50%;
    top: 50%;
    z-index: 3;
    width: 200px;
    height: 200px;
    margin: -100px 0 0 -100px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, #6366F1, #EC4899, #8B5CF6, #38BDF8, #6366F1);
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
    opacity: 0;
    pointer-events: none;
}
.loader.ign.hide {
    visibility: hidden;
    pointer-events: none;
    transition: visibility 0s linear 0.95s;
}
.loader.ign.hide .ign-core { opacity: 0; transform: scale(0.9); }
.loader.ign.hide .ign-hud { opacity: 0; transition: opacity 0.2s ease; }
.loader.ign.hide .ign-bg { opacity: 0; transition: opacity 0.42s ease 0.12s; }
.loader.ign.hide .ign-ring { animation: ignRing 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) forwards; }
.loader.ign.hide .ign-ring.r2 { animation-delay: 0.09s; animation-duration: 0.9s; }
@keyframes ignRing {
    0% { opacity: 0; transform: scale(0.35); }
    12% { opacity: 1; }
    100% { opacity: 0; transform: scale(var(--ring-s, 8)); }
}

/* Wiederholter Besuch in derselben Session: alles flotter */
.loader.ign.quick .ign-mark path { animation-duration: 0.16s; animation-delay: calc(var(--d) * 22ms); }
.loader.ign.quick .ign-crop, .loader.ign.quick .ign-tag, .loader.ign.quick .ign-status { animation-delay: 0s; animation-duration: 0.25s; }

/* Reduced Motion: statisches Zeichen, kein Orbit-Lauf, kein Impuls */
.loader.ign.still .ign-mark path { animation: none; stroke-dashoffset: 0; }
.loader.ign.still .ign-plasma, .loader.ign.still .ign-dot { animation: none; }
.loader.ign.still .ign-e { display: none; }
.loader.ign.still .ign-ring { display: none; }
.loader.ign.still.hide .ign-bg { transition-duration: 0.25s; transition-delay: 0s; }
@media (prefers-reduced-motion: reduce) {
    .ign-mark path { animation: none !important; stroke-dashoffset: 0 !important; }
    .ign-plasma, .ign-dot { animation: none !important; }
    .ign-ring, .ign-e { display: none !important; }
}

@media (max-width: 480px) {
    .ign-tag { font-size: 0.62rem; letter-spacing: 0.12em; }
    .ign-tag.t1 { left: 22px; }
    .ign-tag.t2 { right: 22px; }
    .ign-status { font-size: 0.68rem; }
}
