:root {
  color-scheme: dark;
}

/* ============================================
   POLYPHONIC LOADING SCREEN - Monochromatic
   ============================================ */

#app-splash {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: #000;
  color: #f8fafc;
}

#app-splash.app-splash--hidden {
  opacity: 0;
  visibility: hidden;
}

/* Canvas background */
#splash-ascii-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  will-change: contents;
}

/* Gradient overlay for contrast */
.gradient-overlay {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: 
    radial-gradient(
      ellipse 55% 45% at center,
      rgba(0, 0, 0, 0.88) 0%,
      rgba(0, 0, 0, 0.75) 25%,
      rgba(0, 0, 0, 0.5) 50%,
      rgba(0, 0, 0, 0.2) 75%,
      transparent 100%
    ),
    radial-gradient(
      ellipse 100% 100% at center,
      transparent 30%,
      rgba(0, 0, 0, 0.4) 100%
    );
  transition: opacity 1s ease;
}

/* Loading wrapper - contains overlay, corners, content */
.loading-wrapper {
  position: fixed;
  inset: 0;
  z-index: 3;
  transition: opacity 500ms ease-in-out;
}

.loading-wrapper.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-wrapper.hidden .gradient-overlay {
  opacity: 0;
}

.loading-wrapper.hidden .loading-content {
  opacity: 0;
  transform: scale(0.97);
}

/* Corner accent brackets */
.corner-accent {
  position: fixed;
  width: 48px;
  height: 48px;
  z-index: 2;
  opacity: 0.12;
  transition: opacity 0.3s ease;
}

.corner-accent.top-left {
  top: 28px;
  left: 28px;
  border-top: 1px solid rgba(200, 230, 217, 0.6);
  border-left: 1px solid rgba(200, 230, 217, 0.6);
}

.corner-accent.top-right {
  top: 28px;
  right: 28px;
  border-top: 1px solid rgba(200, 230, 217, 0.6);
  border-right: 1px solid rgba(200, 230, 217, 0.6);
}

.corner-accent.bottom-left {
  bottom: 28px;
  left: 28px;
  border-bottom: 1px solid rgba(200, 230, 217, 0.6);
  border-left: 1px solid rgba(200, 230, 217, 0.6);
}

.corner-accent.bottom-right {
  bottom: 28px;
  right: 28px;
  border-bottom: 1px solid rgba(200, 230, 217, 0.6);
  border-right: 1px solid rgba(200, 230, 217, 0.6);
}

/* Loading content - centered */
.loading-content {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  transition: opacity 1s ease, transform 1s ease;
}

/* Rotating triangle symbol */
.loading-logo {
  font-size: 56px;
  color: rgba(230, 230, 230, 0.95);
  animation: logoSpin 2.5s ease-in-out infinite;
  text-shadow: 
    0 0 40px rgba(200, 230, 217, 0.25),
    0 0 80px rgba(200, 230, 217, 0.1);
  margin-bottom: 8px;
  will-change: transform, opacity;
}

@keyframes logoSpin {
  0%, 100% { 
    transform: rotate(0deg) scale(1); 
    opacity: 0.9;
  }
  50% { 
    transform: rotate(180deg) scale(1.08); 
    opacity: 1;
  }
}

/* Alias for polyphonic consistency */
@keyframes polyphonic-spin {
  0%, 100% { 
    transform: rotate(0deg) scale(1); 
    opacity: 0.9;
  }
  50% { 
    transform: rotate(180deg) scale(1.08); 
    opacity: 1;
  }
}

/* Pulsing status text */
.loading-text {
  font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Geist Mono', monospace;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: rgba(230, 230, 230, 0.6);
  animation: textPulse 2s ease-in-out infinite;
}

@keyframes textPulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.85; }
}

/* Progress bar container */
.loading-progress {
  width: 280px;
  height: 1px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 1px;
  overflow: hidden;
  position: relative;
  margin-top: 12px;
}

/* Sweeping progress bar */
.loading-bar {
  position: absolute;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(200, 230, 217, 0.3) 30%,
    rgba(200, 230, 217, 0.7) 50%,
    rgba(200, 230, 217, 0.3) 70%,
    transparent 100%
  );
  animation: barSlide 2.8s ease-in-out infinite;
  will-change: left;
}

@keyframes barSlide {
  0% { left: -100%; }
  100% { left: 100%; }
}

/* Track pulse effect */
.loading-progress::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(200, 230, 217, 0.08);
  animation: trackPulse 2.8s ease-in-out infinite;
}

@keyframes trackPulse {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

/* Version/status text at bottom */
.status-text {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', 'Geist Mono', monospace;
  font-size: 9px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(230, 230, 230, 0.2);
}

/* ============================================
   LEGACY KEYFRAMES (for backwards compat)
   ============================================ */

@keyframes loadingSpin {
  0%, 100% { 
    transform: rotate(0deg) scale(1); 
  }
  50% { 
    transform: rotate(180deg) scale(1.1); 
  }
}

@keyframes loadingPulse {
  0%, 100% { 
    opacity: 0.3; 
  }
  50% { 
    opacity: 1; 
  }
}

@keyframes loadingSlide {
  0% { 
    left: -100%; 
  }
  100% { 
    left: 100%; 
  }
}

@keyframes loadingFadeOut {
  to {
    opacity: 0;
    visibility: hidden;
  }
}
