/* Mesial · pantalla de apertura.
   Coreografía de la marca, "todo converge aquí":
   1. Los dos incisivos llegan desde los lados y convergen en la línea media para formar la M.
   2. El punto coral cae sobre la línea media y suelta un destello.
   3. La palabra sale desde detrás de la M mientras el logo se centra, y se enciende el punto de la «i».
   4. Al terminar de cargar, la web se abre desde el punto de la «i» como un diafragma.
   Se carga antes que el resto de las hojas y solo anima transform y opacity, para que corra fluida en el celular.
   Si el JavaScript falla, la pantalla se retira sola a los 8 s. El cierre lo hace public/js/splash.js. */

@property --sp-r {
  syntax: '<length>';
  inherits: false;
  initial-value: 0px;
}

body.booting { overflow: hidden; }
body.booting .site-footer,
body.booting .mobile-nav { visibility: hidden; animation: sp-unhide 0s 8s forwards; }
@keyframes sp-unhide { to { visibility: visible; } }

.splash {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
  background: #12304a;
  color: #f6f4f0;
  animation: sp-failsafe 0.5s ease 8s forwards;
  -webkit-mask: radial-gradient(circle at var(--sp-x, 50%) var(--sp-y, 50%), transparent var(--sp-r), #000 calc(var(--sp-r) + 1px));
  mask: radial-gradient(circle at var(--sp-x, 50%) var(--sp-y, 50%), transparent var(--sp-r), #000 calc(var(--sp-r) + 1px));
}
@keyframes sp-failsafe { to { opacity: 0; visibility: hidden; } }

.splash__logo {
  width: min(58vw, 320px);
  height: auto;
  overflow: visible;
  /* Arranca con la M en el centro de la pantalla; luego se corre para centrar la palabra. */
  animation: sp-center 0.6s cubic-bezier(0.65, 0, 0.35, 1) 0.98s both;
}
@keyframes sp-center {
  from { transform: translateX(37.23%); }
  to { transform: none; }
}

.splash__logo .sp-inc,
.splash__logo .sp-word { fill: #f6f4f0; }
.splash__logo .sp-dot { fill: #ef6c4e; }
.splash__logo g,
.splash__logo circle { transform-box: fill-box; }

/* 1. Convergencia de los incisivos */
.sp-inc { transform-origin: 50% 100%; }
.sp-inc-l { animation: sp-in-l 0.74s cubic-bezier(0.16, 1, 0.3, 1) 0.08s both; }
.sp-inc-r { animation: sp-in-r 0.74s cubic-bezier(0.16, 1, 0.3, 1) 0.08s both; }
@keyframes sp-in-l {
  from { transform: translateX(-640px) rotate(-11deg); opacity: 0; }
  60% { opacity: 1; }
  to { transform: none; opacity: 1; }
}
@keyframes sp-in-r {
  from { transform: translateX(640px) rotate(11deg); opacity: 0; }
  60% { opacity: 1; }
  to { transform: none; opacity: 1; }
}

/* 2. El punto cae sobre la línea media y suelta el destello */
.sp-dot { transform-origin: 50% 50%; }
.sp-dot-m { animation: sp-drop 0.52s cubic-bezier(0.34, 1.4, 0.64, 1) 0.6s both; }
@keyframes sp-drop {
  from { transform: translateY(-900px) scale(0.55); opacity: 0; }
  35% { opacity: 1; }
  to { transform: none; opacity: 1; }
}

.sp-glow {
  fill: #f6f4f0;
  opacity: 0;
  transform-origin: 50% 50%;
  animation: sp-glow 0.62s cubic-bezier(0.2, 0.7, 0.2, 1) 0.98s forwards;
}
@keyframes sp-glow {
  0% { transform: scale(1); opacity: 0; }
  18% { opacity: 0.55; }
  100% { transform: scale(3.2); opacity: 0; }
}

.sp-ring {
  fill: none;
  stroke: #ef6c4e;
  stroke-width: 2px;
  vector-effect: non-scaling-stroke;
  opacity: 0;
  transform-origin: 50% 50%;
}
.sp-ring-m { animation: sp-ring 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) 1s forwards; }
.sp-ring-m2 { animation: sp-ring-wide 1s cubic-bezier(0.2, 0.7, 0.2, 1) 1.12s forwards; }
.sp-ring-i { animation: sp-ring 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) 1.66s forwards; }
/* Mientras la web termina de cargar, el punto de la «i» respira con un anillo. */
.sp-ring-wait { animation: sp-ring 1.4s cubic-bezier(0.2, 0.7, 0.2, 1) 2.5s infinite; }
@keyframes sp-ring {
  0% { transform: scale(1); opacity: 0.95; }
  100% { transform: scale(4.6); opacity: 0; }
}
@keyframes sp-ring-wide {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(8); opacity: 0; }
}

/* 3. La palabra sale de detrás de la M y se enciende el punto de la «i» */
.sp-word { animation: sp-word 0.62s cubic-bezier(0.16, 1, 0.3, 1) 1.2s both; }
@keyframes sp-word {
  from { transform: translateX(-420px); opacity: 0; }
  40% { opacity: 1; }
  to { transform: none; opacity: 1; }
}
.sp-dot-i { animation: sp-pop 0.5s cubic-bezier(0.34, 1.6, 0.64, 1) 1.5s both; }
@keyframes sp-pop {
  from { transform: scale(0); }
  to { transform: none; }
}

.splash__tag {
  margin: 0;
  font-family: 'Outfit', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: clamp(0.95rem, 0.9rem + 0.3vw, 1.1rem);
  font-weight: 400;
  letter-spacing: 0.01em;
  color: rgba(246, 244, 240, 0.72);
  animation: sp-tag 0.6s cubic-bezier(0.16, 1, 0.3, 1) 1.55s both;
}
@keyframes sp-tag {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* 4. Apertura: la web se abre desde el punto de la «i» */
.splash.splash--out {
  pointer-events: none;
  animation: sp-open 0.78s cubic-bezier(0.7, 0, 0.2, 1) 0.12s forwards, sp-fade 0.32s ease 0.62s forwards;
}
.splash--out .splash__logo,
.splash--out .splash__tag {
  transition: transform 0.45s cubic-bezier(0.7, 0, 0.84, 0), opacity 0.35s ease;
  transform: scale(1.08);
  opacity: 0;
}
.splash--out .sp-dot-i { animation: sp-ignite 0.3s ease-out forwards; }
@keyframes sp-ignite { to { transform: scale(1.5); } }
@keyframes sp-open { to { --sp-r: 150vmax; } }
@keyframes sp-fade { to { opacity: 0; visibility: hidden; } }

/* La página entra con un leve acercamiento mientras se abre el diafragma. */
body.sp-reveal #app-main,
body.sp-reveal .site-header {
  animation: sp-page 0.9s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes sp-page {
  from { transform: scale(0.985); opacity: 0.4; }
  to { transform: none; opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .splash__logo,
  .splash__logo *,
  .splash__tag,
  .sp-ring-wait { animation: none !important; }
  .sp-ring,
  .sp-glow { display: none; }
  .splash.splash--out { animation: sp-fade 0.3s ease forwards; }
  .splash--out .splash__logo,
  .splash--out .splash__tag { transition: opacity 0.2s ease; transform: none; }
  body.sp-reveal #app-main,
  body.sp-reveal .site-header { animation: none; }
}
