/* =========================================================
   TACKYCHAN — TRANSICIÓN GLOBAL DE NAVEGACIÓN EN SUPERFICIE
   Mantiene visualmente la página anterior hasta que el nuevo
   documento está listo. No convierte el sitio en una SPA.
   ========================================================= */

@view-transition {
  navigation: auto;
}

/* La cabecera es el único elemento extraído del snapshot general:
   la versión anterior permanece visible hasta que termina el cambio. */
.tc-surface-header {
  view-transition-name: tc-surface-header;
}

::view-transition-group(root) {
  z-index: 1;
  animation-duration: 140ms;
}

::view-transition-old(root) {
  animation: none;
}

::view-transition-new(root) {
  animation: tc-surface-page-in 140ms ease-out both;
}

::view-transition-group(tc-surface-header) {
  z-index: 2;
  animation-duration: 140ms;
}

::view-transition-old(tc-surface-header) {
  animation: none;
  opacity: 1;
}

::view-transition-new(tc-surface-header) {
  animation: none;
  opacity: 0;
}

@keyframes tc-surface-page-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Indicador discreto mientras el navegador prepara el siguiente documento. */
.tc-surface-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 3px;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    transparent 34%,
    var(--tc-brand-cyan) 42%,
    var(--tc-brand-lilac) 50%,
    var(--tc-brand-pink) 58%,
    transparent 66%,
    transparent 100%
  );
  background-size: 220% 100%;
  background-position: 100% 0;
}

html.tc-navigation-pending .tc-surface-header::after {
  opacity: .92;
  animation: tc-surface-loading 900ms ease-in-out infinite;
}

@keyframes tc-surface-loading {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(root),
  ::view-transition-group(tc-surface-header),
  ::view-transition-old(root),
  ::view-transition-new(root),
  ::view-transition-old(tc-surface-header),
  ::view-transition-new(tc-surface-header) {
    animation-duration: 1ms !important;
  }

  html.tc-navigation-pending .tc-surface-header::after {
    animation: none;
    background-position: center;
  }
}
