/* =========================================================
   STOA — motion.css
   Revelados, transiciones entre láminas y movimiento reducido
   ========================================================= */

/* ---------- Revelado al hacer scroll ---------- */
.js [data-reveal] {
  opacity: 0;
  transform: translateY(26px);
  transition:
    opacity 1s var(--ease-out),
    transform 1.1s var(--ease-out),
    clip-path 1.2s var(--ease);
  transition-delay: var(--d, 0s);
}
.js [data-reveal="clip"] {
  opacity: 1;
  transform: none;
  clip-path: inset(0 100% 0 0);
}
.js [data-reveal="rise"] {
  opacity: 1;
  transform: none;
  clip-path: inset(100% 0 0 0);
}
.js [data-reveal="fade"] { transform: none; }
.js [data-reveal="rule"] {
  opacity: 1;
  transform: scaleX(0);
  transform-origin: left;
}
.js [data-reveal].is-in {
  opacity: 1;
  transform: none;
}
/* Solo las variantes con máscara la abren al final. En el resto no hay
   clip-path: con line-height 1 recortaría los descendentes (g, p, ¿). */
.js [data-reveal="clip"].is-in,
.js [data-reveal="rise"].is-in {
  clip-path: inset(0 0 0 0);
}

/* Los dibujos se ocultan hasta que JS prepara sus trazos (evita parpadeo) */
.js [data-draw] { visibility: hidden; }

/* Palabras que "se asientan" como tinta */
.ink-word {
  display: inline-block;
  opacity: 0;
  filter: blur(6px);
  transform: translateY(.18em);
  transition: opacity .9s var(--ease-out), filter 1.1s var(--ease-out), transform 1s var(--ease-out);
}
.ink-word.is-in { opacity: 1; filter: blur(0); transform: none; }
.ink-word.is-out { opacity: 0; filter: blur(4px); transform: translateY(-.12em); transition-duration: .35s; }

/* Caret de escritura */
.type-caret::after {
  content: "";
  display: inline-block;
  width: .55em;
  height: 1em;
  margin-left: 2px;
  vertical-align: -.15em;
  background: currentColor;
  animation: caret 1s steps(1) infinite;
}
@keyframes caret { 50% { opacity: 0; } }

/* Respiración lenta (elementos vivos) */
@keyframes breathe {
  0%, 100% { opacity: .55; }
  50% { opacity: 1; }
}
.breathe { animation: breathe 4.2s ease-in-out infinite; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spin-rev { to { transform: rotate(-360deg); } }

@keyframes pulse-ring {
  0% { transform: scale(.6); opacity: .9; }
  100% { transform: scale(2.4); opacity: 0; }
}

/* Indicador de scroll en la portada */
@keyframes scroll-hint {
  0% { transform: scaleY(0); transform-origin: top; }
  45% { transform: scaleY(1); transform-origin: top; }
  55% { transform: scaleY(1); transform-origin: bottom; }
  100% { transform: scaleY(0); transform-origin: bottom; }
}

/* ---------- Transiciones entre láminas (View Transitions) ---------- */
@view-transition { navigation: auto; }

::view-transition-old(root) {
  animation: vt-out .55s var(--ease) both;
}
::view-transition-new(root) {
  animation: vt-in .8s var(--ease) both;
}
::view-transition-group(nav) { animation-duration: .5s; }

@keyframes vt-out {
  to { opacity: 0; transform: translateX(-3%); filter: blur(2px); }
}
@keyframes vt-in {
  from { clip-path: inset(0 0 0 100%); }
  to { clip-path: inset(0 0 0 0); }
}

/* Fallback de transición */
.sheet-wipe.is-entering { animation: wipe-in .5s var(--ease) forwards; }
.sheet-wipe.is-leaving { transform: translateX(0); animation: wipe-out .7s var(--ease) .05s forwards; }
@keyframes wipe-in { from { transform: translateX(101%); } to { transform: translateX(0); } }
@keyframes wipe-out { from { transform: translateX(0); } to { transform: translateX(-101%); } }

/* ---------- Movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js [data-reveal],
  .ink-word {
    opacity: 1 !important;
    transform: none !important;
    clip-path: none !important;
    filter: none !important;
  }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    transition-delay: 0s !important;
  }
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
}
