/* ==========================================================================
   MAGES EDITS — HIGH-PERFORMANCE CINEMATIC BOOTLOADER (v=quad-v3785)
   - Inverted Sketch Background with Canvas Tile-Stamp Reveal Engine
   - 3D Tumble/Flip Spiral Path of Marcus's 4-Part Brand Yellow Emblem
   - Le Murmure Percentage Counter & Wireframe Gerüst Morph into Corner Fly-Out
   - Session-Cache Check for Instant Subsequent Loads
   ========================================================================== */

#bootloader-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 100000;
  background-color: #000000;
  overflow: hidden;
  pointer-events: all;
  user-select: none;
  opacity: 1;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#bootloader-overlay.is-complete {
  opacity: 0;
  pointer-events: none;
}

/* Layer 1: Normal White Sketch Base (1:1 Deckungsgleich mit .hero-bg-layer.phase-0 des Anfangs-Intros) */
#bootloader-base-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background-image: url('../assets/hero-bg-phase0.jpg');
  background-repeat: no-repeat;
  background-size: cover;
  background-position: 30% center;
  transform: scale(1.05);
  transform-origin: center center;
  pointer-events: none;
  z-index: 1;
}

@media (min-aspect-ratio: 1/1) {
  #bootloader-base-bg {
    background-size: 110% auto;
    background-position: 10% center;
  }
}

/* Layer 1.5: Intro Vignette Darkening (exact 1:1 match to .hero-overlay from Anfangs-Intro) */
#bootloader-vignette {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(
    circle at center,
    rgba(0, 0, 0, 0.2) 0%,
    rgba(0, 0, 0, 0.4) 40%,
    rgba(0, 0, 0, 0.6) 100%
  );
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity calc(1.47s / var(--boot-speed, 1)) ease-out;
}

#bootloader-overlay.is-exploding #bootloader-vignette {
  opacity: 1;
}

/* Layer 2: Inverted Dark Canvas (tiles cleared in 60fps rAF loop) */
#bootloader-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 2;
}

/* Layer 2.5: Transient Gold Dust Sparks (cleared every frame, zero residue) */
#bootloader-dust-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 3;
  pointer-events: none;
}

/* Layer 3: Dead Center Percentage Indicator in Le Murmure */
#bootloader-counter {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: var(--boot-cell-w, 214px);
  height: var(--boot-cell-h, 216px);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 4;
  pointer-events: none;
  font-family: var(--font-murmure, 'Le Murmure', sans-serif);
  font-size: clamp(2.2rem, 3.8vw, 4.0rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.05em;
  color: #ffd900;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.95);
  transition: opacity 0.12s ease;
}

#bootloader-counter.is-hidden {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
}

/* Layer 4: 3D Tumbling Logo Container */
#bootloader-logo-wrap {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--boot-cell-w, 214px);
  height: var(--boot-cell-h, 216px);
  z-index: 5;
  pointer-events: none;
  perspective: 1400px;
  -webkit-perspective: 1400px;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  will-change: transform;
}

#bootloader-logo-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  will-change: transform;
}

.bootloader-card-face {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bootloader-card-front {
  transform: none;
}

.bootloader-card-back {
  display: none !important;
}

#bootloader-logo-inner svg {
  width: 100%;
  height: 100%;
  overflow: visible;
  display: block;
  filter: drop-shadow(0 2px 14px rgba(0, 0, 0, 0.85));
}

#bootloader-logo-inner path {
  fill: #ffd900;
  stroke: transparent;
  stroke-width: 0px;
  transition: fill calc(0.65s / var(--boot-speed, 1)) cubic-bezier(0.16, 1, 0.3, 1),
              stroke calc(0.65s / var(--boot-speed, 1)) cubic-bezier(0.16, 1, 0.3, 1),
              stroke-width calc(0.65s / var(--boot-speed, 1)) cubic-bezier(0.16, 1, 0.3, 1);
}

/* Wireframe Gerüst Mode: Exact match to the Anfangs-Intro Skizzen-Phase (6px fine black stroke, no drop-shadow) */
#bootloader-logo-inner.is-wireframe svg {
  filter: none !important;
}

#bootloader-logo-inner.is-wireframe path {
  fill: transparent !important;
  stroke: #000000 !important;
  stroke-width: 6px !important;
  stroke-linejoin: round;
  stroke-linecap: round;
}

/* Eliminate internal stray patch bars in wireframe mode so no extra line sticks into the corner */
#bootloader-logo-inner.is-wireframe .logo-inner-patch {
  display: none !important;
  opacity: 0 !important;
  stroke: none !important;
  visibility: hidden !important;
}

/* Subtle 3-Phase 3D Anticipation Pulse: Hop forward (+Z) -> Dive back (-Z) -> Accelerate to origin -> Split */
#bootloader-logo-inner.is-bouncing {
  animation: bootloaderLogoBounce calc(0.58s / var(--boot-speed, 1)) linear forwards;
}

@keyframes bootloaderLogoBounce {
  0% {
    transform: translateZ(0) scale(1);
    animation-timing-function: cubic-bezier(0.33, 1, 0.68, 1);
  }
  28% {
    transform: translateZ(26px) scale(1.026);
    animation-timing-function: cubic-bezier(0.45, 0, 0.55, 1);
  }
  64% {
    transform: translateZ(-48px) scale(0.942);
    animation-timing-function: cubic-bezier(0.4, 0, 0.7, 1);
  }
  100% {
    transform: translateZ(0) scale(1);
  }
}

/* Corner Fly-Out: 4 quadrants blast along exact screen diagonal vectors completely out of the viewport */
#bootloader-logo-inner .logo-part {
  transform: translate(0px, 0px) scale(1);
  transition: transform calc(1.47s / var(--boot-speed, 1)) ease-out, opacity calc(1.47s / var(--boot-speed, 1)) ease-out;
  transform-origin: 841px 1181px; /* Exact center crosshair of Marcus emblem */
  transform-box: view-box;
}

#bootloader-logo-inner.is-exploding .part-tl {
  transform: translate(var(--fly-tl-x, -12000px), var(--fly-tl-y, -12000px)) scale(1) !important;
  opacity: 1 !important;
}

#bootloader-logo-inner.is-exploding .part-tr {
  transform: translate(var(--fly-tr-x, 12000px), var(--fly-tr-y, -12000px)) scale(1) !important;
  opacity: 1 !important;
}

#bootloader-logo-inner.is-exploding .part-bl {
  transform: translate(var(--fly-bl-x, -12000px), var(--fly-bl-y, 12000px)) scale(1) !important;
  opacity: 1 !important;
}

#bootloader-logo-inner.is-exploding .part-br {
  transform: translate(var(--fly-br-x, 12000px), var(--fly-br-y, 12000px)) scale(1) !important;
  opacity: 1 !important;
}

/* ==========================================================================
   BOOTLOADER SPEED CONTROLLER & ANALYZER HUD
   ========================================================================== */
#bootloader-speed-hud {
  display: none !important;
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100010;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(14, 14, 16, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 217, 0, 0.35);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.85), 0 0 24px rgba(255, 217, 0, 0.12);
  font-family: 'Steps Mono', monospace;
  color: #ffffff;
  user-select: none;
  pointer-events: all;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
  width: 440px;
  max-width: calc(100vw - 32px);
  box-sizing: border-box;
}

#bootloader-speed-hud.is-open {
  display: flex !important;
}

#bootloader-speed-hud.is-minimized {
  transform: translateX(-50%) translateY(calc(100% - 34px));
  opacity: 0.9;
}

.boot-hud-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #ffd900;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 6px;
}

.boot-hud-header-title {
  display: flex;
  align-items: center;
  gap: 6px;
}

.boot-hud-minimize-btn {
  background: none;
  border: none;
  color: #888888;
  cursor: pointer;
  font-size: 13px;
  padding: 0 4px;
  line-height: 1;
}

.boot-hud-minimize-btn:hover {
  color: #ffd900;
}

.boot-hud-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.boot-hud-slider-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.boot-hud-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.boot-hud-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffd900;
  cursor: pointer;
  box-shadow: 0 0 10px rgba(255, 217, 0, 0.9);
  transition: transform 0.1s ease;
}

.boot-hud-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.boot-hud-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffd900;
  cursor: pointer;
  border: none;
  box-shadow: 0 0 10px rgba(255, 217, 0, 0.9);
}

.boot-hud-value {
  font-size: 12px;
  font-weight: 700;
  color: #ffd900;
  min-width: 90px;
  text-align: right;
  white-space: nowrap;
}

.boot-hud-presets {
  display: flex;
  gap: 5px;
  align-items: center;
  justify-content: space-between;
}

.boot-hud-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cccccc;
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.boot-hud-btn:hover {
  background: rgba(255, 217, 0, 0.18);
  border-color: #ffd900;
  color: #ffd900;
}

.boot-hud-btn.is-active {
  background: #ffd900;
  border-color: #ffd900;
  color: #000000;
  font-weight: 700;
}

.boot-hud-modes {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.boot-hud-section-label {
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #888888;
  text-transform: uppercase;
}

.boot-hud-mode-group {
  display: flex;
  gap: 5px;
}

.boot-hud-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: space-between;
  padding-top: 2px;
}

.boot-hud-action-btn {
  flex: 1;
  background: rgba(255, 217, 0, 0.1);
  border: 1px solid rgba(255, 217, 0, 0.35);
  color: #ffd900;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 700;
  padding: 5px 8px;
  border-radius: 5px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.boot-hud-action-btn:hover {
  background: #ffd900;
  color: #000000;
  box-shadow: 0 0 12px rgba(255, 217, 0, 0.4);
}

.boot-hud-loop-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: #aaaaaa;
  cursor: pointer;
  white-space: nowrap;
  padding-left: 4px;
}

.boot-hud-loop-label input[type="checkbox"] {
  accent-color: #ffd900;
  cursor: pointer;
}

/* Floating Launcher button on the main website after intro (HIDDEN by default) */
.bootloader-floating-launcher {
  display: none !important;
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99990;
  background: rgba(14, 14, 16, 0.9);
  border: 1px solid rgba(255, 217, 0, 0.4);
  color: #ffd900;
  font-family: 'Steps Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 16px rgba(255, 217, 0, 0.15);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: all 0.2s ease;
}

.bootloader-floating-launcher:hover {
  background: #ffd900;
  color: #000000;
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.8), 0 0 20px rgba(255, 217, 0, 0.5);
}

/* ==========================================================================
   21:9 WIDESCREEN CINEMA PILLARBOX LOCK FOR BOOTLOADER
   Constrains bootloader stage layers cleanly within the 16:9 center canvas
   ========================================================================== */
@media (min-aspect-ratio: 19/10) {
  /* Dedicated Cinema Pillarbox Curtains inside #bootloader-overlay */
  #bootloader-overlay::before,
  #bootloader-overlay::after {
    content: "" !important;
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    height: 100vh !important;
    width: calc((100vw - min(2560px, calc(100vh * (16 / 9)))) / 2) !important;
    background-color: #000000 !important;
    z-index: 20 !important; /* In front of base-bg (1), vignette (5), canvas (2,3), and logo (5) */
    pointer-events: none !important;
  }

  #bootloader-overlay::before {
    left: 0 !important;
    border-right: 1px solid rgba(255, 255, 255, 0.06) !important;
  }

  #bootloader-overlay::after {
    right: 0 !important;
    left: auto !important;
    border-left: 1px solid rgba(255, 255, 255, 0.06) !important;
  }

  #bootloader-base-bg {
    width: 100vw !important;
    left: 0 !important;
    right: auto !important;
  }

  #bootloader-vignette {
    width: min(2560px, calc(100vh * (16 / 9))) !important;
    left: calc((100vw - min(2560px, calc(100vh * (16 / 9)))) / 2) !important;
    right: auto !important;
  }

  #bootloader-canvas,
  #bootloader-dust-canvas {
    width: 100vw !important;
    left: 0 !important;
    right: auto !important;
  }

  .bootloader-floating-launcher {
    z-index: 100010 !important;
  }
}

