/*
 * Cargador de inicio (ver src/marca/Arranque.tsx). Archivo aparte para que se vea antes del bundle y sin estilos
 * en línea (CSP style-src 'self'). Ritmo: latido de 0,8 s (75 lpm); el trazo se dibuja en 2 latidos, queda un instante y se borra.
 */
@font-face {
  font-family: 'Archivo';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('/fuentes/archivo-latin.woff2') format('woff2');
}

@font-face {
  font-family: 'Syne';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  /* Solo el nombre del logo. Google Fonts, licencia OFL 1.1 (ver fuentes/Syne-OFL.txt). */
  src: url('/fuentes/syne-latin-700.woff2') format('woff2');
}

.arranque {
  --arranque-papel: light-dark(#ffffff, #141011);
  --arranque-tinta: light-dark(#121212, #f4eeef);
  --arranque-suave: light-dark(#76585d, #dcb9be);
  --arranque-bordo: light-dark(#8c2337, #e8899a);
  --latido: 800ms;

  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 24px;
  padding: 24px max(24px, env(safe-area-inset-right, 0px)) max(24px, env(safe-area-inset-bottom, 0px))
    max(24px, env(safe-area-inset-left, 0px));
  background:
    radial-gradient(60% 45% at 50% 45%, color-mix(in srgb, var(--arranque-bordo) 8%, transparent), transparent 70%),
    var(--arranque-papel);
  color: var(--arranque-tinta);
  font-family: 'Archivo', system-ui, sans-serif;
  transition: opacity 320ms ease-out;
}

/* Dentro de la app (cierre de sesión, recarga de sesión) no tapa nada: ocupa la página */
#raiz .arranque {
  position: relative;
  min-block-size: 100dvh;
  z-index: auto;
}

:root[data-producto='clinica']:not([data-color='grises']) .arranque {
  --arranque-papel: light-dark(#ffffff, #0e1214);
  --arranque-tinta: light-dark(#121212, #ecf1f4);
  --arranque-suave: light-dark(#4b6575, #abc8da);
  --arranque-bordo: light-dark(#0877a8, #7bc8f6);
  --arranque-celda: #0877a8;
}

:root[data-color='grises'] .arranque {
  --arranque-papel: light-dark(#ffffff, #121212);
  --arranque-suave: light-dark(#5f5f5f, #c2c2c2);
  --arranque-bordo: light-dark(#3a3a3a, #d6d6d6);
  --arranque-celda: #8a8a8a;
}

.arranque-sale {
  opacity: 0;
  pointer-events: none;
}

.arranque-marca {
  display: inline-flex;
  align-items: center;
  gap: 14px;
}

.arranque-logo-cuerpo {
  fill: var(--arranque-tinta);
}

.arranque-logo-celda {
  fill: var(--arranque-celda, #8c2337);
}

.arranque-logo-corte {
  stroke: var(--arranque-papel);
}

.arranque-nombre {
  display: inline-block;
  font-family: 'Syne', 'Archivo', system-ui, sans-serif;
  font-size: clamp(1.9rem, 8.4vw, 3.7rem);
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1;
  transform-origin: 50% 60%;
}

.arranque-producto {
  color: var(--arranque-bordo);
  font-size: 0.72em;
}

.arranque-trazo {
  inline-size: min(480px, 84vw);
  block-size: auto;
  overflow: visible;
}

.arranque-trazo path {
  fill: none;
  stroke: var(--arranque-bordo);
  stroke-width: 3.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

/* La punta que dibuja: un punto (trazo de largo casi cero con extremo redondo) que recorre la misma línea */
.arranque-trazo .arranque-punta {
  stroke-width: 11;
  stroke-dasharray: 0.01 400;
  opacity: 0;
}

.arranque-texto {
  font-size: 1rem;
  color: var(--arranque-suave);
}

@media (prefers-reduced-motion: no-preference) {
  .arranque-nombre {
    animation: latir var(--latido) linear infinite;
  }

  /* La línea se dibuja a lo largo de su recorrido (pathLength 200 = 100 por latido). La onda R cae a ~39 % del largo
     de cada latido, así el nombre late justo cuando la punta llega al pico. */
  .arranque-linea {
    stroke-dasharray: 200 400;
    animation: dibujar calc(4 * var(--latido)) linear infinite;
  }

  .arranque-trazo .arranque-punta {
    animation: recorrer calc(4 * var(--latido)) linear infinite;
  }

  .arranque-logo-celda {
    animation: encender var(--latido) linear infinite;
  }
}

/* Con movimiento reducido no hay escala ni barrido: el trazo queda completo y respira suave en opacidad */
@media (prefers-reduced-motion: reduce) {
  .arranque-trazo {
    animation: respirar 3200ms ease-in-out infinite;
  }
}

/* R a ~34 % del latido: «lub» fuerte; fin de la T a ~60 %: «dub» suave */
@keyframes latir {
  0%,
  30% {
    scale: 1;
  }
  38% {
    scale: 1.09;
  }
  50% {
    scale: 1;
  }
  60% {
    scale: 1.04;
  }
  72%,
  100% {
    scale: 1;
  }
}

@keyframes encender {
  0%,
  30%,
  56%,
  100% {
    opacity: 1;
  }
  40% {
    opacity: 0.7;
  }
}

@keyframes dibujar {
  0% {
    stroke-dashoffset: 200;
  }
  50%,
  62% {
    stroke-dashoffset: 0;
  }
  100% {
    stroke-dashoffset: -200;
  }
}

@keyframes recorrer {
  0% {
    stroke-dashoffset: 0;
    opacity: 1;
  }
  50% {
    stroke-dashoffset: -200;
    opacity: 1;
  }
  56%,
  100% {
    stroke-dashoffset: -200;
    opacity: 0;
  }
}

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