/* =================================================================
   Clu:Kennwort - splash.css
   Animationen fuer den Startbildschirm (Splash) und das Logo.

   GRUNDREGELN:
   - Komplett offline: keine @import von aussen, keine Remote-Fonts,
     keine externen Bilder oder CDN-Referenzen.
   - Saemtliche Laufzeiten leiten sich aus --splash-duration ab.
     Wird diese eine Variable geaendert (z. B. per inline style auf
     .splash-screen), skaliert die komplette Choreografie mit.
   - In Keyframes werden ausschliesslich GPU-freundliche
     Eigenschaften animiert: transform, opacity, stroke-dashoffset,
     filter und (nur beim Shimmer-Overlay) background-position.
     Niemals width/height/top/left.
   - Die BREITE des Ladebalkens setzt ausschliesslich JavaScript.
     Hier gibt es dafuer weder eine Animation noch eine Transition.
   ================================================================= */


/* -----------------------------------------------------------------
   1) Zeitbasis und daraus abgeleitete Laufzeiten
   ----------------------------------------------------------------- */
.splash-screen {
  /* Der Ladebalken laeuft in exakt dieser Zeit von 0% auf 100%. */
  --splash-duration: 10s;

  /* Abgeleitete Laufzeiten - nichts fest verdrahtet. */
  --splash-ring-outer-dur:  calc(var(--splash-duration) * 1);     /* 10.0s */
  --splash-ring-inner-dur:  calc(var(--splash-duration) * 0.7);   /*  7.0s */
  --splash-dash-outer-dur:  calc(var(--splash-duration) * 0.4);   /*  4.0s */
  --splash-dash-inner-dur:  calc(var(--splash-duration) * 0.25);  /*  2.5s */
  --splash-shield-draw-dur: calc(var(--splash-duration) * 0.25);  /*  2.5s */
  --splash-shield-fill-dur: calc(var(--splash-duration) * 0.09);  /*  0.9s */
  --splash-cross-in-dur:    calc(var(--splash-duration) * 0.09);  /*  0.9s */
  --splash-cross-pulse-dur: calc(var(--splash-duration) * 0.35);  /*  3.5s */
  --splash-glow-dur:        calc(var(--splash-duration) * 0.3);   /*  3.0s */
  --splash-spark-dur:       calc(var(--splash-duration) * 0.35);  /*  3.5s */
  --splash-lock-dur:        calc(var(--splash-duration) * 0.2);   /*  2.0s */
  --splash-shimmer-dur:     calc(var(--splash-duration) * 0.18);  /*  1.8s */
  --splash-bar-glow-dur:    calc(var(--splash-duration) * 0.14);  /*  1.4s */
  --splash-bg-dur:          calc(var(--splash-duration) * 1.8);   /* 18.0s */
  --splash-skip-in-dur:     calc(var(--splash-duration) * 0.05);  /*  0.5s */
  --splash-fade-out-dur:    calc(var(--splash-duration) * 0.06);  /*  0.6s */

  /* Einsatzzeitpunkte der Choreografie. */
  --splash-shield-fill-delay: calc(var(--splash-duration) * 0.25); /* 2.5s */
  --splash-cross-delay:       calc(var(--splash-duration) * 0.2);  /* 2.0s */
  --splash-cross-pulse-delay: calc(var(--splash-duration) * 0.29); /* 2.9s */
  --splash-lock-delay:        calc(var(--splash-duration) * 0.8);  /* 8.0s */
  --splash-skip-delay:        calc(var(--splash-duration) * 0.15); /* 1.5s */
}


/* -----------------------------------------------------------------
   2) Splash-Buehne: Fade-Out ueber .hidden, animierter Hintergrund
   ----------------------------------------------------------------- */
.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bg-primary, #0a0a1a);
  opacity: 1;
  transform: scale(1);
  transform-origin: 50% 50%;
  will-change: opacity, transform;
  transition:
    opacity    var(--splash-fade-out-dur) cubic-bezier(0.4, 0, 0.2, 1),
    transform  var(--splash-fade-out-dur) cubic-bezier(0.4, 0, 0.2, 1),
    visibility var(--splash-fade-out-dur) cubic-bezier(0.4, 0, 0.2, 1);
}

/* Sanfter Fade-Out: Deckkraft plus leichte Vergroesserung. */
.splash-screen.hidden {
  opacity: 0;
  transform: scale(1.06);
  visibility: hidden;
  pointer-events: none;
}

/*
   Subtil animierter Farbverlauf-Hintergrund.
   Statt background-position wandern hier zwei weiche Farbwolken per
   transform/opacity - das bleibt vollstaendig auf dem Compositor.
*/
.splash-screen::before {
  content: "";
  position: absolute;
  inset: -25%;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(circle at 30% 32%, var(--accent-glow, rgba(108, 92, 231, 0.30)), transparent 55%),
    radial-gradient(circle at 72% 68%, var(--swiss-red-glow, rgba(231, 76, 60, 0.18)), transparent 55%);
  will-change: transform, opacity;
  animation: splash-bg-drift var(--splash-bg-dur) ease-in-out infinite alternate;
}

@keyframes splash-bg-drift {
  0%   { transform: translate3d(-2%, -1.5%, 0) scale(1);    opacity: 0.75; }
  50%  { transform: translate3d( 1.5%, 2%,  0) scale(1.08); opacity: 1;    }
  100% { transform: translate3d( 2.5%, -2%, 0) scale(1.04); opacity: 0.8;  }
}

/* Inhalt liegt ueber der Farbwolke. */
.splash-content {
  position: relative;
  z-index: 1;
  text-align: center;
}


/* -----------------------------------------------------------------
   3) Logo-Grundlage
   ----------------------------------------------------------------- */
.splash-logo {
  display: block;
  width: 132px;
  height: 132px;
  margin: 0 auto 22px;
  overflow: visible;
}

/* Rings und Wappen drehen/skalieren um den viewBox-Mittelpunkt. */
.splash-ring-outer,
.splash-ring-inner {
  transform-box: view-box;
  transform-origin: 50% 50%;
  will-change: transform, stroke-dashoffset;
}


/* -----------------------------------------------------------------
   4) Ringe: Drehung plus umlaufendes Strichmuster
   Beide Kreise tragen pathLength="600", die dasharray-Werte teilen
   600 restlos - dadurch laeuft das Muster nahtlos um.
   ----------------------------------------------------------------- */
.splash-ring-outer {
  /* 600 / 50 = 12 gleiche Segmente */
  stroke-dasharray: 36 14;
  stroke-dashoffset: 0;
  animation:
    splash-ring-spin-cw  var(--splash-ring-outer-dur) linear infinite,
    splash-dash-outer    var(--splash-dash-outer-dur) linear infinite;
}

.splash-ring-inner {
  /* 600 / 20 = 30 gleiche Segmente, gegenlaeufig und schneller */
  stroke-dasharray: 8 12;
  stroke-dashoffset: 0;
  animation:
    splash-ring-spin-ccw var(--splash-ring-inner-dur) linear infinite,
    splash-dash-inner    var(--splash-dash-inner-dur) linear infinite;
}

@keyframes splash-ring-spin-cw {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

@keyframes splash-ring-spin-ccw {
  from { transform: rotate(0deg); }
  to   { transform: rotate(-360deg); }
}

@keyframes splash-dash-outer {
  from { stroke-dashoffset: 0; }
  to   { stroke-dashoffset: -50; }
}

@keyframes splash-dash-inner {
  from { stroke-dashoffset: 0; }
  to   { stroke-dashoffset: 20; }
}


/* -----------------------------------------------------------------
   5) Wappen: Kontur zeichnet sich selbst, dann faded die Fuellung ein
   ----------------------------------------------------------------- */
.splash-shield {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  will-change: transform;
  animation: splash-shield-settle var(--splash-shield-draw-dur) cubic-bezier(0.22, 1, 0.36, 1) both;
}

.splash-shield-stroke {
  /* pathLength="100" -> die Kontur ist normiert auf 100 Einheiten. */
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  will-change: stroke-dashoffset, opacity;
  animation:
    splash-shield-draw  var(--splash-shield-draw-dur) cubic-bezier(0.65, 0, 0.35, 1) both,
    splash-shield-hide  var(--splash-shield-fill-dur) ease-out var(--splash-shield-fill-delay) both;
}

.splash-shield-fill {
  opacity: 0;
  will-change: opacity, transform;
  transform-box: fill-box;
  transform-origin: 50% 50%;
  animation: splash-shield-reveal var(--splash-shield-fill-dur) ease-out var(--splash-shield-fill-delay) both;
}

@keyframes splash-shield-draw {
  from { stroke-dashoffset: 100; opacity: 1; }
  to   { stroke-dashoffset: 0;   opacity: 1; }
}

/* Kontur tritt zurueck, sobald die Fuellung da ist. */
@keyframes splash-shield-hide {
  from { opacity: 1; }
  to   { opacity: 0.35; }
}

@keyframes splash-shield-reveal {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes splash-shield-settle {
  from { transform: scale(0.9); }
  to   { transform: scale(1); }
}


/* -----------------------------------------------------------------
   6) Schweizerkreuz: Balken fahren aus der Mitte heraus, danach Puls
   Beide Rechtecke sind um (100|96) zentriert - fill-box + center
   laesst sie exakt aus dem Kreuzmittelpunkt wachsen.
   ----------------------------------------------------------------- */
.splash-cross-v,
.splash-cross-h {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  will-change: transform;
}

.splash-cross-v {
  transform: scaleY(0);
  animation:
    splash-cross-v-in    var(--splash-cross-in-dur)    cubic-bezier(0.34, 1.56, 0.64, 1) var(--splash-cross-delay) both,
    splash-cross-v-pulse var(--splash-cross-pulse-dur) ease-in-out var(--splash-cross-pulse-delay) infinite;
}

.splash-cross-h {
  transform: scaleX(0);
  animation:
    splash-cross-h-in    var(--splash-cross-in-dur)    cubic-bezier(0.34, 1.56, 0.64, 1) var(--splash-cross-delay) both,
    splash-cross-h-pulse var(--splash-cross-pulse-dur) ease-in-out var(--splash-cross-pulse-delay) infinite;
}

@keyframes splash-cross-v-in {
  from { transform: scaleY(0); }
  to   { transform: scaleY(1); }
}

@keyframes splash-cross-h-in {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

/* Dezenter, langsamer Puls im Anschluss. */
@keyframes splash-cross-v-pulse {
  0%, 100% { transform: scaleY(1); }
  50%      { transform: scaleY(1.05); }
}

@keyframes splash-cross-h-pulse {
  0%, 100% { transform: scaleX(1); }
  50%      { transform: scaleX(1.05); }
}


/* -----------------------------------------------------------------
   7) Glow: Atemrhythmus in --swiss-red
   ----------------------------------------------------------------- */
.splash-glow {
  transform-box: fill-box;
  transform-origin: 50% 50%;
  will-change: transform, opacity;
  animation: splash-glow-breathe var(--splash-glow-dur) ease-in-out infinite;
}

@keyframes splash-glow-breathe {
  0%, 100% { transform: scale(0.86); opacity: 0.22; }
  50%      { transform: scale(1.14); opacity: 0.55; }
}


/* -----------------------------------------------------------------
   8) Funken: sechs Partikel steigen versetzt auf und verblassen
   ----------------------------------------------------------------- */
.splash-spark {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: 50% 50%;
  will-change: transform, opacity;
  animation: splash-spark-rise var(--splash-spark-dur) ease-out infinite;
}

.splash-spark:nth-child(1) { animation-delay: calc(var(--splash-duration) * 0);    }
.splash-spark:nth-child(2) { animation-delay: calc(var(--splash-duration) * 0.06); }
.splash-spark:nth-child(3) { animation-delay: calc(var(--splash-duration) * 0.12); }
.splash-spark:nth-child(4) { animation-delay: calc(var(--splash-duration) * 0.18); }
.splash-spark:nth-child(5) { animation-delay: calc(var(--splash-duration) * 0.23); }
.splash-spark:nth-child(6) { animation-delay: calc(var(--splash-duration) * 0.29); }

@keyframes splash-spark-rise {
  0%   { transform: translate3d(0, 0, 0) scale(0.4);           opacity: 0;    }
  15%  { transform: translate3d(0, -8px, 0) scale(1);          opacity: 0.9;  }
  60%  { transform: translate3d(2px, -34px, 0) scale(0.85);    opacity: 0.55; }
  100% { transform: translate3d(-2px, -62px, 0) scale(0.25);   opacity: 0;    }
}


/* -----------------------------------------------------------------
   9) Schloss: erscheint zum Schluss, kurzer Wackler plus Bounce
   ----------------------------------------------------------------- */
.splash-lock {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: 50% 50%;
  will-change: transform, opacity;
  animation: splash-lock-snap var(--splash-lock-dur) cubic-bezier(0.34, 1.56, 0.64, 1) var(--splash-lock-delay) both;
}

@keyframes splash-lock-snap {
  0%   { opacity: 0; transform: translate3d(0, -6px, 0) scale(0.45) rotate(-14deg); }
  35%  { opacity: 1; transform: translate3d(0, 0, 0) scale(1.28) rotate(7deg);      }
  52%  { opacity: 1; transform: translate3d(0, 0, 0) scale(0.9)  rotate(-5deg);     }
  68%  { opacity: 1; transform: translate3d(0, 0, 0) scale(1.1)  rotate(3deg);      }
  82%  { opacity: 1; transform: translate3d(0, 0, 0) scale(0.97) rotate(-1.5deg);   }
  100% { opacity: 1; transform: translate3d(0, 0, 0) scale(1)    rotate(0deg);      }
}


/* -----------------------------------------------------------------
   10) Ladebalken
   ACHTUNG: Die Breite von .loading-bar setzt ausschliesslich JS.
   Hier gibt es bewusst weder animation noch transition auf width.
   ----------------------------------------------------------------- */
.loading-bar-container {
  position: relative;
  width: 300px;
  height: 6px;
  margin: 0 auto 12px;
  border-radius: 999px;
  background: var(--input-bg, rgba(255, 255, 255, 0.07));
  /* sichtbar, damit der mitwandernde Glow nicht abgeschnitten wird */
  overflow: visible;
}

.loading-bar {
  position: relative;
  height: 100%;
  width: 0%;            /* Startwert - ab hier uebernimmt ausschliesslich JS */
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent, #6c5ce7), var(--swiss-red, #e74c3c));
  /*
     Bewusst none: hebt eine evtl. in style.css gesetzte
     "transition: width" auf. Die Breite darf CSS weder
     animieren noch weichzeichnen - das macht allein JS.
  */
  transition: none;
  animation: none;
}

/* Shimmer-Overlay: bewegter Lichtstreifen per background-position. */
.loading-bar::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background-image: linear-gradient(
    100deg,
    rgba(255, 255, 255, 0)    0%,
    rgba(255, 255, 255, 0)   38%,
    rgba(255, 255, 255, 0.7) 50%,
    rgba(255, 255, 255, 0)   62%,
    rgba(255, 255, 255, 0)  100%
  );
  background-size: 240% 100%;
  background-repeat: no-repeat;
  background-position: -140% 0;
  animation: splash-bar-shimmer var(--splash-shimmer-dur) linear infinite;
}

@keyframes splash-bar-shimmer {
  from { background-position: -140% 0; }
  to   { background-position:  240% 0; }
}

/* Mitwandernder Glow: klebt am rechten Balkenende und folgt der Breite. */
.loading-bar::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -9px;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, var(--swiss-red, #e74c3c) 0%, transparent 70%);
  will-change: transform, opacity;
  animation: splash-bar-glow var(--splash-bar-glow-dur) ease-in-out infinite;
}

@keyframes splash-bar-glow {
  0%, 100% { transform: scale(0.75); opacity: 0.5; }
  50%      { transform: scale(1.35); opacity: 1;   }
}

/* Prozentzahl darf beim Hochzaehlen nicht springen. */
.loading-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted, #6060a0);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  letter-spacing: 0.02em;
}


/* -----------------------------------------------------------------
   11) Ueberspringen-Button (nur bei .splash-screen--skippable)
   ----------------------------------------------------------------- */
.splash-skip {
  display: none;
}

.splash-screen--skippable .splash-skip {
  position: absolute;
  right: 20px;
  bottom: 18px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text-muted, #6060a0);
  background: var(--glass-bg, rgba(255, 255, 255, 0.05));
  border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.1));
  border-radius: 999px;
  cursor: pointer;
  opacity: 0;
  will-change: transform, opacity;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  animation: splash-skip-in var(--splash-skip-in-dur) ease-out var(--splash-skip-delay) both;
}

.splash-screen--skippable .splash-skip:hover,
.splash-screen--skippable .splash-skip:focus-visible {
  color: var(--text-primary, #ffffff);
  border-color: var(--accent, #6c5ce7);
  background: var(--accent-glow, rgba(108, 92, 231, 0.3));
}

.splash-screen--skippable .splash-skip:focus-visible {
  outline: 2px solid var(--accent, #6c5ce7);
  outline-offset: 2px;
}

@keyframes splash-skip-in {
  from { opacity: 0; transform: translate3d(0, 8px, 0); }
  to   { opacity: 1; transform: translate3d(0, 0, 0);   }
}


/* -----------------------------------------------------------------
   12) Reduzierte Bewegung: ALLE Animationen aus, Logo statisch,
       Ladebalken ohne Shimmer. Zwingend.
   ----------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {

  .splash-screen,
  .splash-screen *,
  .splash-screen *::before,
  .splash-screen *::after,
  .splash-screen::before,
  .splash-screen::after,
  .splash-logo,
  .splash-logo * {
    animation: none !important;
    animation-delay: 0s !important;
    animation-duration: 0s !important;
    transition: none !important;
    will-change: auto !important;
  }

  /* Buehne: nur noch eine kurze, bewegungsfreie Deckkraft-Blende. */
  .splash-screen {
    transform: none !important;
    transition: opacity 0.2s linear !important;
  }

  .splash-screen.hidden {
    opacity: 0;
    transform: none !important;
  }

  .splash-screen::before {
    transform: none !important;
    opacity: 0.85;
  }

  /* Logo im fertigen Endzustand einfrieren. */
  .splash-ring-outer,
  .splash-ring-inner {
    transform: none !important;
    stroke-dasharray: none !important;
    stroke-dashoffset: 0 !important;
  }

  .splash-shield {
    transform: none !important;
  }

  .splash-shield-stroke {
    stroke-dasharray: none !important;
    stroke-dashoffset: 0 !important;
    opacity: 0.35 !important;
  }

  .splash-shield-fill {
    opacity: 1 !important;
    transform: none !important;
  }

  .splash-cross-v,
  .splash-cross-h {
    transform: none !important;
    opacity: 1 !important;
  }

  .splash-glow {
    transform: none !important;
    opacity: 0.35 !important;
  }

  /* Funken sind reine Bewegung - komplett ausblenden. */
  .splash-sparks,
  .splash-spark {
    display: none !important;
  }

  .splash-lock {
    transform: none !important;
    opacity: 1 !important;
  }

  /* Ladebalken ohne Shimmer und ohne pulsierenden Glow. */
  .loading-bar::before,
  .loading-bar::after {
    display: none !important;
  }

  .splash-screen--skippable .splash-skip {
    opacity: 1 !important;
    transform: none !important;
  }
}
