/* =========================================================
   Evolf · Transiciones entre secciones
   Lenguaje "blueprint" del sitio: líneas finas, marcas de esquina,
   bloques que se abren a sangre completa. Nada de ondas ni rebotes.

   1. Cortina  (.tx-curtain): una banda oscura entra como una tarjeta
      alineada con la retícula y se abre a ancho completo al hacer scroll.
   2. Costura  (.tx-seam): entre bandas del mismo tono, una línea de 1px
      con marcas "+" se dibuja de izquierda a derecha.
   3. Revelado (.tx-r): bloques de contenido suben 24px y aparecen en
      cascada (70 ms entre elementos).

   Todo se desactiva con prefers-reduced-motion.
   Lo activa js/evolf-transitions.js (añade .tx-on a <html>).
   ========================================================= */

:root {
  --tx-ease: cubic-bezier(.2, .7, 0, 1);
  --tx-dur: .9s;
  --tx-gutter: max(var(--pad, 40px), calc((100% - var(--max, 1360px)) / 2 + var(--pad, 40px)));
}

/* ---------- 1. Cortina ---------- */
.tx-on .tx-curtain { will-change: clip-path; }

/* Navegadores con scroll-driven animations: ligada al scroll, sin JS */
@supports (animation-timeline: view()) {
  .tx-on.tx-sda .tx-curtain {
    animation: tx-curtain linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 70%;
  }
}
@keyframes tx-curtain {
  from { clip-path: inset(0 var(--tx-gutter) 0 var(--tx-gutter)); }
  to   { clip-path: inset(0 0 0 0); }
}

/* Resto: transición disparada por IntersectionObserver */
.tx-on:not(.tx-sda) .tx-curtain {
  clip-path: inset(0 var(--tx-gutter) 0 var(--tx-gutter));
  transition: clip-path 1.2s var(--tx-ease);
}
.tx-on:not(.tx-sda) .tx-curtain.tx-in { clip-path: inset(0 0 0 0); }

/* Retícula de puntos que aparece con la cortina */
.tx-curtain { position: relative; isolation: isolate; }
.tx-curtain::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image: radial-gradient(rgba(0, 202, 207, .22) 1px, transparent 1.4px);
  background-size: 22px 22px;
  -webkit-mask-image: linear-gradient(180deg, #000 0, transparent 280px);
          mask-image: linear-gradient(180deg, #000 0, transparent 280px);
  opacity: 0; transition: opacity 1.4s var(--tx-ease) .3s;
}
.tx-curtain.tx-in::after { opacity: 1; }

/* ---------- 2. Costura ---------- */
.tx-seamed { position: relative; }
.tx-seam {
  position: absolute; top: 0; left: var(--tx-gutter); right: var(--tx-gutter);
  height: 1px; pointer-events: none; z-index: 1;
}
.tx-seam::before {
  content: ""; position: absolute; inset: 0;
  background: currentColor; opacity: .35;
  transform: scaleX(0); transform-origin: left center;
  transition: transform 1.4s var(--tx-ease);
}
.tx-seam i {
  position: absolute; top: -5px; width: 11px; height: 11px; opacity: 0;
  transition: opacity .5s ease .9s;
}
.tx-seam i::before, .tx-seam i::after { content: ""; position: absolute; background: currentColor; }
.tx-seam i::before { left: 5px; top: 0; width: 1px; height: 100%; }
.tx-seam i::after  { top: 5px; left: 0; height: 1px; width: 100%; }
.tx-seam i:first-child { left: -5px; transition-delay: .1s; }
.tx-seam i:last-child  { right: -5px; }
.tx-seam.tx-in::before { transform: scaleX(1); }
.tx-seam.tx-in i { opacity: .8; }
.tx-seam--light { color: var(--purple, #5B19C4); }
.tx-seam--dark  { color: var(--cyan, #00CACF); }

/* ---------- 3. Revelado ---------- */
.tx-on .tx-r {
  opacity: 0; transform: translate3d(0, 24px, 0);
  transition: opacity var(--tx-dur) var(--tx-ease), transform var(--tx-dur) var(--tx-ease);
  transition-delay: var(--tx-d, 0ms);
}
.tx-on .tx-r.tx-in { opacity: 1; transform: none; }

/* ---------- Scroll suave para anclas ---------- */
html.tx-on { scroll-behavior: smooth; }

/* ---------- Movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
  html.tx-on { scroll-behavior: auto; }
  .tx-on .tx-curtain, .tx-on .tx-r { animation: none !important; transition: none !important; clip-path: none !important; opacity: 1 !important; transform: none !important; }
  .tx-seam::before { transform: scaleX(1); transition: none; }
  .tx-seam i { opacity: .8; transition: none; }
}
