/* ====================================================================
   SAM — SECURITY ALERTS MONITORING · Ricart Labs
   Splash de bienvenida obligatorio (~2.5s) · Todas las páginas
   Patrón táctico HUD (referencia visual: osirisai.live) adaptado a
   la firma monocroma de SAM con cian táctico en el radar/progress.
   El DOM lo inyecta js/lib/splash.js como primer hijo de <body>
   (sin FOUC). Cargar en <head> después de tokens.css.
   ==================================================================== */

/* === Variables locales del splash === */
.sam-splash {
  --splash-cyan: #00e5ff;
  --splash-cyan-strong: rgba(0, 229, 255, 0.55);
  --splash-cyan-soft: rgba(0, 229, 255, 0.35);
  --splash-cyan-dim: rgba(0, 229, 255, 0.16);
  --splash-white-soft: rgba(255, 255, 255, 0.25);

  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  background: radial-gradient(ellipse at center, #0c141a 0%, var(--color-base, #0a0a0a) 70%);
  transition: opacity 0.4s ease, transform 0.4s ease, filter 0.4s ease;
}

/* Salida: fade + leve zoom + blur sobre el contenido ya bootando */
.sam-splash.sam-splash-exit {
  opacity: 0;
  transform: scale(1.03);
  filter: blur(6px);
  pointer-events: none;
}

/* === Capas ambientales === */
.sam-splash-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px);
  background-size: 60px 60px;
}
.sam-splash-run .sam-splash-grid { animation: splash-fade-in 1.2s ease 0.15s both; }

.sam-splash-scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background-image: repeating-linear-gradient(
    0deg,
    transparent, transparent 2px,
    rgba(255, 255, 255, 0.02) 2px, rgba(255, 255, 255, 0.02) 4px
  );
}
.sam-splash-run .sam-splash-scanlines {
  animation: splash-fade-in 1s ease 0.1s both, splash-scan-drift 8s linear infinite;
}

/* Brackets de esquina — visor táctico */
.sam-splash-bracket {
  position: absolute;
  width: 28px;
  height: 28px;
  opacity: 0;
  border: 0 solid rgba(255, 255, 255, 0.28);
}
.sam-splash-bracket-tl { top: 18px; left: 18px; border-top-width: 2px; border-left-width: 2px; }
.sam-splash-bracket-tr { top: 18px; right: 18px; border-top-width: 2px; border-right-width: 2px; }
.sam-splash-bracket-bl { bottom: 18px; left: 18px; border-bottom-width: 2px; border-left-width: 2px; }
.sam-splash-bracket-br { bottom: 18px; right: 18px; border-bottom-width: 2px; border-right-width: 2px; }
.sam-splash-run .sam-splash-bracket { animation: splash-bracket-in 0.5s ease 0.35s both; }

/* Badge de versión */
.sam-splash-badge {
  position: absolute;
  top: 22px;
  left: 24px;
  padding: 4px 9px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.3em;
  color: var(--color-text-muted, #888);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.03);
  opacity: 0;
}
.sam-splash-run .sam-splash-badge { animation: splash-fade-in 0.6s ease 0.55s both; }

/* === Emblema radar === */
.sam-splash-emblem {
  position: relative;
  width: 160px;
  height: 160px;
  margin-bottom: 30px;
  flex-shrink: 0;
}

.sam-splash-ring {
  position: absolute;
  border-radius: 50%;
  opacity: 0;
}
.sam-splash-ring-outer { inset: 0; border: 1px solid rgba(255, 255, 255, 0.14); transform: scale(0.6); --ring-from: 0.6; }
.sam-splash-ring-cyan { inset: 18px; border: 1px solid var(--splash-cyan-dim); transform: scale(0.4); --ring-from: 0.4; }
.sam-splash-ring-inner { inset: 40px; border: 1px solid rgba(255, 255, 255, 0.22); transform: scale(0.2); --ring-from: 0.2; }

.sam-splash-run .sam-splash-ring-outer { animation: splash-ring-in 0.55s cubic-bezier(0.16, 1, 0.3, 1) 0.42s both; }
.sam-splash-run .sam-splash-ring-cyan { animation: splash-ring-in 0.55s cubic-bezier(0.16, 1, 0.3, 1) 0.30s both; }
.sam-splash-run .sam-splash-ring-inner { animation: splash-ring-in 0.55s cubic-bezier(0.16, 1, 0.3, 1) 0.18s both; }

/* Órbitas: rotan los puntos luminosos sobre cada anillo */
.sam-splash-orbit { position: absolute; inset: 0; }
.sam-splash-run .sam-splash-orbit-a { animation: splash-spin 14s linear 0.6s infinite; }
.sam-splash-run .sam-splash-orbit-b { animation: splash-spin-rev 10s linear 0.6s infinite; }
.sam-splash-run .sam-splash-orbit-c { animation: splash-spin 7s linear 0.6s infinite; }

.sam-splash-dot {
  position: absolute;
  border-radius: 50%;
  background: #ffffff;
}
.sam-splash-dot-lg {
  width: 8px; height: 8px;
  top: -4px; left: 50%; margin-left: -4px;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.9), 0 0 24px rgba(255, 255, 255, 0.35);
}
.sam-splash-dot-sm {
  width: 4px; height: 4px;
  bottom: -2px; left: 50%; margin-left: -2px;
  background: var(--splash-cyan);
  box-shadow: 0 0 8px var(--splash-cyan-soft);
}
.sam-splash-dot-cyan {
  width: 6px; height: 6px;
  top: 50%; right: -3px; margin-top: -3px;
  background: var(--splash-cyan);
  box-shadow: 0 0 10px var(--splash-cyan-soft), 0 0 20px var(--splash-cyan-dim);
}
.sam-splash-dot-inner {
  width: 6px; height: 6px;
  top: -3px; left: 50%; margin-left: -3px;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
}
.sam-splash-run .sam-splash-dot { animation: splash-dot-pulse 2.4s ease-in-out infinite; }

/* Barrido cónico de radar */
.sam-splash-sweep {
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  opacity: 0;
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    var(--splash-cyan-dim) 40deg,
    transparent 80deg
  );
}
.sam-splash-run .sam-splash-sweep {
  animation: splash-fade-in 0.5s ease 0.55s both, splash-spin 3s linear 0.55s infinite;
}

/* Núcleo con cruz de mira */
.sam-splash-nucleus {
  position: absolute;
  inset: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--color-accent, #ffffff);
  border-radius: 50%;
  box-shadow: 0 0 18px rgba(255, 255, 255, 0.35), inset 0 0 12px rgba(255, 255, 255, 0.15);
  opacity: 0;
  transform: scale(0);
}
.sam-splash-run .sam-splash-nucleus { animation: splash-core-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.08s both; }

.sam-splash-nucleus-disc {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.9) 0%, var(--splash-cyan-dim) 60%, transparent 75%);
  box-shadow: 0 0 10px var(--splash-cyan-soft);
}
.sam-splash-cross-h {
  position: absolute;
  left: 8px; right: 8px; top: 50%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
}
.sam-splash-cross-v {
  position: absolute;
  top: 8px; bottom: 8px; left: 50%; width: 1px;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.55), transparent);
}

/* === Marca === */
.sam-splash-title {
  display: flex;
  justify-content: center;
}
.sam-splash-letter {
  display: inline-block;
  padding: 0 0.25em;
  font-size: clamp(36px, 9vw, 50px);
  font-weight: 700;
  letter-spacing: 0;
  color: var(--color-text, #ffffff);
  text-shadow: 0 0 30px var(--splash-white-soft);
  opacity: 0;
  filter: blur(8px);
  transform: translateY(20px);
}
.sam-splash-run .sam-splash-letter { animation: splash-letter-in 0.55s cubic-bezier(0.16, 1, 0.3, 1) both; }
.sam-splash-run .sam-splash-letter:nth-child(1) { animation-delay: 0.35s; }
.sam-splash-run .sam-splash-letter:nth-child(2) { animation-delay: 0.47s; }
.sam-splash-run .sam-splash-letter:nth-child(3) { animation-delay: 0.59s; }

.sam-splash-word {
  margin-top: 8px;
  padding-left: 0.6em; /* compensa el tracking para centrado óptico */
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.6em;
  color: var(--color-text-secondary, #ccc);
  text-shadow: 0 0 14px rgba(255, 255, 255, 0.15);
  opacity: 0;
  transform: translateY(10px);
}
.sam-splash-run .sam-splash-word { animation: splash-fade-up 0.5s ease 0.8s both; }

/* Typewriter — fantasma invisible que reserva el ancho final */
.sam-splash-type-wrap {
  position: relative;
  display: inline-block;
  margin-top: 20px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.5em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--color-accent, #ffffff);
  opacity: 0;
}
.sam-splash-run .sam-splash-type-wrap { animation: splash-fade-in 0.3s ease 0.95s both; }
.sam-splash-ghost { visibility: hidden; }
.sam-splash-type-abs {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
}
.sam-splash-caret {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 3px;
  background: var(--splash-cyan);
  box-shadow: 0 0 8px var(--splash-cyan-soft);
  animation: splash-caret-blink 0.9s steps(1) infinite;
}

/* === Barra de progreso + mensajes rotativos === */
.sam-splash-progress {
  width: 280px;
  max-width: 70vw;
  margin-top: 28px;
  opacity: 0;
  transform: translateY(3px);
}
.sam-splash-run .sam-splash-progress { animation: splash-fade-up 0.45s ease 0.6s both; }

.sam-splash-track {
  position: relative;
  height: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.10);
  overflow: hidden;
}
.sam-splash-fill {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffffff, var(--splash-cyan), #ffffff);
  box-shadow: 0 0 12px var(--splash-cyan-soft);
}
.sam-splash-run .sam-splash-fill { animation: splash-fill 1.7s cubic-bezier(0.33, 0, 0.2, 1) 0.5s both; }

.sam-splash-msg {
  display: block;
  margin-top: 12px;
  text-align: center;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--color-text-muted, #888);
  animation: splash-msg-pulse 1.4s ease-in-out infinite;
}

/* === Keyframes === */
@keyframes splash-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes splash-fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes splash-ring-in {
  from { opacity: 0; transform: scale(var(--ring-from, 0.2)); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes splash-core-in {
  from { opacity: 0; transform: scale(0); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes splash-letter-in {
  from { opacity: 0; filter: blur(8px); transform: translateY(20px); }
  to { opacity: 1; filter: blur(0); transform: translateY(0); }
}
@keyframes splash-bracket-in {
  from { opacity: 0; transform: scale(1.35); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes splash-spin { to { transform: rotate(360deg); } }
@keyframes splash-spin-rev { to { transform: rotate(-360deg); } }
@keyframes splash-dot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}
@keyframes splash-scan-drift {
  from { background-position: 0 0; }
  to { background-position: 0 64px; }
}
@keyframes splash-fill {
  from { width: 0%; }
  to { width: 100%; }
}
@keyframes splash-caret-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}
@keyframes splash-msg-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* === Responsive === */
@media (max-width: 520px) {
  .sam-splash-emblem { transform: scale(0.75); margin-bottom: 22px; }
  .sam-splash-type-wrap { font-size: 9px; letter-spacing: 0.34em; }
  .sam-splash-progress { width: 220px; }
}

/* === Accesibilidad: movimiento reducido → entradas instantáneas === */
@media (prefers-reduced-motion: reduce) {
  .sam-splash,
  .sam-splash *,
  .sam-splash *::before,
  .sam-splash *::after {
    animation-duration: 0.01s !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01s !important;
  }
}
