/* =========================================================
   Lunes — transiciones.css (ws11-t8, 2026-11-20). Fundidos y movimientos cortos (150–300 ms).
   TODO cuelga de <html class="tx"> (lo pone assets/js/transiciones.js) y de prefers-reduced-motion: no-preference.
   Para apagar todo: en config/config.php  'transiciones' => false,  (ya no se cargan ni este CSS ni el JS:
   Lunes queda exactamente como antes). Ver trabajos/20261120-lunes-rediseno/REPORTE-ws11-t8.md
   No reescribe nada de las pantallas: solo agrega animaciones encima de las clases que ya existen.
   ========================================================= */

/* ---------- 2. Cambiar de página: View Transitions entre documentos (Chrome/Edge/Arc 126+, Safari 18.2+) ---------- */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}

@media (prefers-reduced-motion: no-preference) {

  /* El menú de arriba es su propia capa: es igual en las dos páginas, así que no parpadea. */
  html.tx .tope { view-transition-name: tx-tope; }
  /* Cambio de tema: una sola capa (fundido parejo de TODA la pantalla). */
  html.tx-vt-tema .tope { view-transition-name: none; }

  /* Durante la transición los clics pasan directo a la página nueva (no se «congela»). */
  ::view-transition { pointer-events: none; }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: 180ms; animation-timing-function: ease-out; }
  ::view-transition-group(tx-tope) { animation-duration: 180ms; }
  ::view-transition-old(tx-tope), ::view-transition-new(tx-tope) { animation-duration: 180ms; }
  /* 1. Tema oscuro/claro */
  html.tx-vt-tema::view-transition-old(root), html.tx-vt-tema::view-transition-new(root) { animation-duration: 260ms; animation-timing-function: ease-in-out; }

  /* Sin View Transitions entre documentos (Firefox, Safari viejo): fundido de entrada solo del contenido. */
  html.tx.tx-sin-vt .principal > .contenido, html.tx.tx-sin-vt .principal > .subbarra { animation: tx-funde 170ms ease-out; }

  /* ---------- 3. Pestañas: la rayita activa que se desliza ---------- */
  .tx-raya { position: fixed; height: 2px; margin: 0; padding: 0; border: 0; background: var(--rojo-vivo, #E5484D);
    pointer-events: none; z-index: 45; transform-origin: 0 50%; view-transition-name: tx-raya; }
  ::view-transition-group(tx-raya) { animation-duration: 240ms; animation-timing-function: cubic-bezier(.2, .8, .2, 1); }
  html.tx-raya-viaje .pestanas:not(.segmentado) .activo,
  html.tx-raya-viaje .pestanas:not(.segmentado) [aria-current],
  .pestanas.tx-raya-viaje .activo, .pestanas.tx-raya-viaje [aria-selected="true"] { border-bottom-color: transparent; }

  /* ---------- 5. Ventanas y modales: fundido con un ligero crecimiento ---------- */
  html.tx .modal.abierto { animation: tx-funde 160ms ease-out; }
  html.tx .modal.abierto .modal__caja { animation: tx-crece 220ms cubic-bezier(.2, .8, .2, 1); }
  html.tx .modal.tx-saliendo:not(.abierto) { display: flex; pointer-events: none; animation: tx-funde-sale 160ms ease-in forwards; }
  html.tx .modal.tx-saliendo:not(.abierto) .modal__caja { animation: tx-encoge 160ms ease-in forwards; }
  /* vista previa del dictado (llega por fetch dentro de su caja) */
  html.tx .dictado__previa-caja > .dictado-previa { animation: tx-crece 220ms cubic-bezier(.2, .8, .2, 1); }

  /* ---------- 6. Panel lateral de tarea: entra deslizándose desde la derecha ---------- */
  html.tx .panel { transition: transform 260ms cubic-bezier(.2, .8, .2, 1), visibility 0s linear 260ms, box-shadow 260ms; }
  html.tx body.panel-abierto .panel { transition: transform 260ms cubic-bezier(.2, .8, .2, 1), visibility 0s, box-shadow 260ms; }
  html.tx .velo { transition: opacity 220ms ease; }
  html.tx body.panel-abierto [data-panel-contenido] > * { animation: tx-funde 180ms ease-out; }

  /* ---------- 7. Tarjetas que se acomodan al soltar (el FLIP lo hace el JS) ---------- */
  html.tx .tx-asienta { animation: tx-asienta 240ms cubic-bezier(.2, .8, .2, 1); }

  /* ---------- 8. Tarea hecha: se tacha y se desvanece un poco ---------- */
  html.tx .tx-hecha .nombre, html.tx .subtareas li.tx-hecha span { animation: tx-tachar 320ms ease-out; }
  html.tx .tx-hecha { animation: tx-desvanece 320ms ease-out; }

  /* ---------- 9. Avisos (toasts): entran desde abajo y se desvanecen solos ---------- */
  html.tx .aviso { animation: tx-aviso-entra 240ms cubic-bezier(.2, .8, .2, 1); }
  html.tx .aviso.sale { opacity: 0; transform: translateY(.75rem) scale(.98); transition: opacity 200ms ease-in, transform 200ms ease-in; }

  /* ---------- 10. Menú ☰ en celular: baja deslizándose desde el menú de arriba ---------- */
  @media (max-width: 1100px) {
    html.tx body.menu-abierto .tope__nav { animation: tx-menu-baja 220ms cubic-bezier(.2, .8, .2, 1); }
    html.tx body.menu-abierto .velo-menu { animation: tx-funde 200ms ease-out; }
  }

  /* ---------- 12. Resumen: cifras y tarjetas escalonadas, solo al cargar (html.tx-primera dura ~1 s) ---------- */
  html.tx.tx-primera .rg-hero__in,
  html.tx.tx-primera .rg-cifras > li,
  html.tx.tx-primera .rg-bloques > .rg-bloque,
  html.tx.tx-primera .rg-lista > .rg-dia { animation: tx-sube 280ms cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--tx-i, 0) * 35ms); }
  html.tx.tx-primera .rg-cifras > li:nth-child(2) { --tx-i: 1; }
  html.tx.tx-primera .rg-cifras > li:nth-child(3) { --tx-i: 2; }
  html.tx.tx-primera .rg-cifras > li:nth-child(4) { --tx-i: 3; }
  html.tx.tx-primera .rg-cifras > li:nth-child(n+5) { --tx-i: 4; }
  html.tx.tx-primera .rg-bloques > .rg-bloque { --tx-i: 3; }
  html.tx.tx-primera .rg-bloques > .rg-bloque:nth-child(2) { --tx-i: 4; }
  html.tx.tx-primera .rg-bloques > .rg-bloque:nth-child(3) { --tx-i: 5; }
  html.tx.tx-primera .rg-bloques > .rg-bloque:nth-child(n+4) { --tx-i: 6; }
  html.tx.tx-primera .rg-lista > .rg-dia { --tx-i: 6; }
  html.tx.tx-primera .rg-lista > .rg-dia:nth-child(n+4) { --tx-i: 7; }
}

/* Cambio de tema: mientras dura, nada se anima por su cuenta (así no hay piezas que cambien tarde).
   Único !important: tiene que ganarle a las transition de cada pantalla, y solo vive ~300 ms. */
html.tx-quieto *, html.tx-quieto *::before, html.tx-quieto *::after { transition: none !important; }

@keyframes tx-funde { from { opacity: 0; } }
@keyframes tx-funde-sale { to { opacity: 0; } }
@keyframes tx-crece { from { opacity: 0; transform: translateY(.375rem) scale(.96); } }
@keyframes tx-encoge { to { opacity: 0; transform: scale(.97); } }
@keyframes tx-sube { from { opacity: 0; transform: translateY(.5rem); } }
@keyframes tx-asienta { from { transform: scale(1.035); box-shadow: var(--sombra-flotante); } }
@keyframes tx-tachar { from { text-decoration-color: transparent; } }
@keyframes tx-desvanece { 0% { opacity: 1; } 45% { opacity: .55; } 100% { opacity: 1; } }
@keyframes tx-aviso-entra { from { opacity: 0; transform: translateY(1rem) scale(.98); } }
@keyframes tx-menu-baja { from { opacity: .4; clip-path: inset(0 0 100% 0); transform: translateY(-.5rem); } to { opacity: 1; clip-path: inset(0 0 0 0); transform: none; } }
