html,
body {
  min-height: 100%;
  margin: 0;
  background-color: var(--theme-sidebar-bg, #0052CC);
}

html:has(#splash-bootstrap),
body:has(#splash-bootstrap) {
  overflow: hidden;
}

#root {
  min-height: 100vh;
}

.splash-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background-color: var(--theme-sidebar-bg, #0052CC);
}

.splash-backdrop::before {
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom right, rgba(255, 255, 255, 0.1), transparent);
  content: '';
  pointer-events: none;
}

.splash-backdrop__stars {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.splash-backdrop__vignette {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: linear-gradient(
    to top,
    var(--theme-sidebar-bg, #0052CC),
    transparent 55%,
    color-mix(in srgb, var(--theme-sidebar-bg, #0052CC) 70%, transparent)
  );
  pointer-events: none;
}

.splash-model-entrance {
  animation: splash-model-entrance 1.8s cubic-bezier(0.2, 0.75, 0.25, 1) both;
}

@keyframes splash-model-entrance {
  from {
    opacity: 0;
    filter: blur(9px);
    transform: scale(0.78);
  }

  70% {
    opacity: 1;
    filter: blur(0);
    transform: scale(1);
  }

  to {
    opacity: 1;
    filter: blur(0);
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .splash-model-entrance {
    animation-duration: 1ms;
  }
}

#splash-bootstrap {
  z-index: 50;
  /* Duración de fade-out del bootstrap estático.
     onComplete() en React se llama DESPUÉS de que esta transición termina,
     por lo que puede ser más corta sin causar el parpadeo. */
  transition: opacity 1400ms ease-in-out;
}

#splash-bootstrap.splash-bootstrap--active {
  opacity: 1;
}

#splash-bootstrap.splash-bootstrap--handoff {
  opacity: 0;
  pointer-events: none;
}

.splash-over-bootstrap {
  background-color: transparent;
}

.splash-over-bootstrap::before {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  #splash-bootstrap {
    transition-duration: 1ms;
  }
}

/* ─────────────────────────────────────────────────────────────
   LAYOUT PROPORCIONAL DEL SPLASH
   La detección se basa en aspect-ratio (ancho/alto) del viewport,
   no solo en el ancho — esto permite dar soporte correcto a teléfonos
   altos como 1080x2460 (ratio ~9:20) que con breakpoints de ancho
   se clasifican como "tablet" cuando en realidad son portrait móvil.
   ───────────────────────────────────────────────────────────── */

/* 1. Contenedor principal del splash: flex column que aprovecha la altura real */
.splash-content {
  /* Usa svh (Small Viewport Height) para excluir barras de sistema en móvil */
  min-height: calc(100svh - 2rem);
  justify-content: center;
  gap: 0;
}

/* 2. Contenedor del modelo 3D: crece proporcionalmente a la altura disponible */
.splash-model-container {
  /* Valor base: teléfono portrait estándar (ratio ~9:16 a 9:19) */
  height: clamp(240px, 44svh, 480px);
  flex-shrink: 0;
  margin-bottom: clamp(1rem, 3svh, 2.5rem);
}

/* 3. Escala del modelo — base: teléfono portrait estrecho (ancho < alto) */
.splash-model-scale {
  /* Escala conservadora: caben todos los satélites en pantalla estrecha */
  scale: 0.58;
}

/* ── PORTRAIT MUY ALTO: ratio < 9:18 → teléfonos tipo 1080x2160 o más alto ── */
@media (max-aspect-ratio: 9/18) {
  .splash-model-container {
    height: clamp(280px, 50svh, 560px);
    margin-bottom: clamp(1.5rem, 4svh, 3rem);
  }
  .splash-model-scale {
    scale: 0.68;
  }
}

/* ── PORTRAIT ULTRA ALTO: ratio < 9:20 → tipo 1080x2400, 1080x2460 ── */
@media (max-aspect-ratio: 9/20) {
  .splash-model-container {
    height: clamp(320px, 55svh, 620px);
    margin-bottom: clamp(2rem, 5svh, 4rem);
  }
  .splash-model-scale {
    scale: 0.76;
  }
}

/* ── PORTRAIT EXTREMO: ratio < 9:21 → tipo 1080x2520 o pantallas plegables ── */
@media (max-aspect-ratio: 9/21) {
  .splash-model-container {
    height: clamp(360px, 58svh, 680px);
    margin-bottom: clamp(2.5rem, 5.5svh, 4.5rem);
  }
  .splash-model-scale {
    scale: 0.82;
  }
}

/* ── LANDSCAPE o pantallas cuadradas: ratio >= 1:1 ── */
@media (min-aspect-ratio: 1/1) {
  .splash-content {
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    padding: 2rem;
    min-height: 100svh;
  }
  .splash-model-container {
    height: clamp(200px, 80svh, 480px);
    width: clamp(200px, 80svh, 480px);
    flex-shrink: 0;
    margin-bottom: 0;
  }
  .splash-model-scale {
    scale: 0.72;
  }
}

/* ── TABLET PORTRAIT: ratio 2:3 (ej. iPad) ── */
@media (min-aspect-ratio: 2/3) and (max-aspect-ratio: 9/14) and (min-width: 600px) {
  .splash-model-container {
    height: clamp(340px, 48svh, 560px);
  }
  .splash-model-scale {
    scale: 0.80;
  }
}

/* ── ESCRITORIO (wide landscape) ── */
@media (min-aspect-ratio: 4/3) {
  .splash-model-container {
    height: clamp(280px, 72svh, 560px);
    width: clamp(280px, 72svh, 560px);
  }
  .splash-model-scale {
    scale: 0.88;
  }
}
