/* =========================================================
   COAPRENDE 2026 — Sistema de motion
   Todo efecto se desactiva con prefers-reduced-motion.
   ========================================================= */

/* ---------- Keyframes ---------- */
@keyframes twinkle { 0%, 100% { transform: scale(1) rotate(0); opacity: 1; } 50% { transform: scale(.65) rotate(25deg); opacity: .6; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise-in { from { opacity: 0; transform: translateY(1.5rem); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.85) translateY(1rem); } to { opacity: 1; transform: none; } }
@keyframes float { 0%, 100% { transform: translate3d(0, 0, 0) rotate(0); } 50% { transform: translate3d(0, -14px, 0) rotate(2deg); } }
@keyframes drift { 0%, 100% { transform: translate(0, 0) rotate(0); } 33% { transform: translate(12px, -18px) rotate(12deg); } 66% { transform: translate(-10px, 8px) rotate(-8deg); } }
@keyframes morph {
  0%, 100% { border-radius: 42% 58% 63% 37% / 41% 44% 56% 59%; }
  33% { border-radius: 63% 37% 39% 61% / 55% 62% 38% 45%; }
  66% { border-radius: 38% 62% 51% 49% / 36% 39% 61% 64%; }
}
@keyframes marquee { to { transform: translateX(-100%); } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes orbit { to { transform: rotate(360deg); } }
@keyframes orbit-counter { to { transform: rotate(-360deg); } }
@keyframes wheel { 0% { transform: translate(-50%, 0); opacity: 1; } 80% { transform: translate(-50%, .9rem); opacity: 0; } 100% { opacity: 0; } }
@keyframes wave-shift { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(-2.5%); } }
@keyframes grow-x { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---------- Barra de progreso de lectura (scroll-driven CSS) ---------- */
.scroll-progress {
  position: fixed; inset: 0 0 auto; z-index: 200; height: 4px; transform-origin: 0 50%;
  background: linear-gradient(90deg, var(--color-teal), var(--color-yellow), var(--color-orange), var(--color-purple));
  transform: scaleX(0);
}
@supports (animation-timeline: scroll()) {
  .scroll-progress { animation: grow-x linear both; animation-timeline: scroll(root block); }
}

/* ---------- Revelado al entrar en pantalla ---------- */
.js [data-reveal] {
  opacity: 0; transform: translate3d(0, 2.5rem, 0);
  transition: opacity .9s var(--ease-out), transform 1.1s var(--ease-out), clip-path 1.2s var(--ease-out);
  transition-delay: calc(var(--d, 0) * 90ms);
}
.js [data-reveal="left"] { transform: translate3d(-3rem, 0, 0); }
.js [data-reveal="right"] { transform: translate3d(3rem, 0, 0); }
.js [data-reveal="scale"] { transform: scale(.92); }
.js [data-reveal="clip"] { opacity: 1; transform: none; clip-path: inset(18% 8% 18% 8% round var(--radius-lg)); }
.js [data-reveal].is-in { opacity: 1; transform: none; }
.js [data-reveal="clip"].is-in { clip-path: inset(0 0 0 0 round var(--radius-lg)); }

.js [data-stagger] > * {
  opacity: 0; transform: translate3d(0, 2rem, 0) scale(.98);
  transition: opacity .8s var(--ease-out), transform 1s var(--ease-out);
  transition-delay: calc(var(--i, 0) * 80ms);
}
.js [data-stagger].is-in > * { opacity: 1; transform: none; }

/* ---------- Texto dividido por palabras ---------- */
.w { display: inline-block; overflow: clip; overflow-clip-margin: .2em; vertical-align: top; padding-bottom: .08em; margin-bottom: -.08em; }
.w__i { display: inline-block; transform: translate3d(0, 110%, 0) rotate(4deg); transform-origin: 0 100%; transition: transform 1s var(--ease-out); transition-delay: calc(var(--wi, 0) * 45ms + 60ms); }
.is-split.is-in .w__i { transform: none; }

/* ---------- Texto que se "enciende" con el scroll ---------- */
[data-scrub-text] .sw { opacity: .16; transition: opacity .35s linear, color .35s; }
[data-scrub-text] .sw.is-lit { opacity: 1; }

/* ---------- Trazos SVG que se dibujan ---------- */
.js [data-draw] { stroke-dasharray: 1; stroke-dashoffset: 1; }
.js .is-in [data-draw], .js [data-draw].is-in { animation: draw 2s var(--ease-in-out) forwards .3s; }

/* ---------- Marquee ---------- */
.marquee {
  --gap: clamp(1.25rem, 3vw, 2.5rem);
  display: flex; overflow: hidden; user-select: none; gap: var(--gap);
  padding-block: clamp(.9rem, 2vw, 1.4rem);
  background: var(--color-teal); color: #fff;
  transform: rotate(-1.5deg) scale(1.03); margin-block: clamp(1rem, 3vw, 2.5rem);
  mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
}
.marquee__group {
  display: flex; flex-shrink: 0; align-items: center; gap: var(--gap); min-width: 100%;
  animation: marquee var(--marquee-duration, 32s) linear infinite;
}
.marquee:hover .marquee__group { animation-play-state: paused; }
.marquee__item { font-family: var(--font-script); font-size: clamp(2rem, 1.4rem + 2.6vw, 3.75rem); line-height: 1; white-space: nowrap; }
.marquee__item--1 { color: var(--color-yellow); }
.marquee__item--3 { color: var(--color-yellow-soft); }
.marquee__star { width: clamp(1.25rem, 2vw, 1.75rem); filter: brightness(0) invert(1); animation: spin 8s linear infinite; }

/* ---------- Cursor personalizado (solo puntero fino) ---------- */
.cursor { display: none; }
@media (hover: hover) and (pointer: fine) {
  .has-cursor .cursor { display: block; position: fixed; inset: 0; z-index: 300; pointer-events: none; }
  .cursor__dot, .cursor__ring { position: fixed; top: 0; left: 0; border-radius: 50%; translate: -50% -50%; will-change: transform; }
  .cursor__dot { width: .5rem; height: .5rem; background: var(--color-teal-dark); }
  .cursor__ring {
    width: 2.5rem; height: 2.5rem; border: 2px solid rgb(100 202 193 / .7);
    transition: width .35s var(--ease-out), height .35s var(--ease-out), background-color .35s, border-color .35s;
  }
  .cursor.is-hover .cursor__ring { width: 4.5rem; height: 4.5rem; background: rgb(255 211 110 / .35); border-color: transparent; }
  .cursor.is-down .cursor__ring { width: 2rem; height: 2rem; }
  .cursor.is-hidden { opacity: 0; }
}

/* ---------- Elementos con inclinación 3D ---------- */
[data-tilt] { transform-style: preserve-3d; transition: transform .6s var(--ease-out), box-shadow .6s var(--ease-out); }
[data-tilt].is-tilting { transition: transform .1s linear, box-shadow .3s; }

/* ---------- Transiciones entre páginas (View Transitions) ---------- */
@view-transition { navigation: auto; }
::view-transition-old(root) { animation: .35s var(--ease-in-out) both vt-out; }
::view-transition-new(root) { animation: .55s var(--ease-out) both vt-in; }
::view-transition-group(site-header) { animation-duration: 0s; }
@keyframes vt-out { to { opacity: 0; transform: translateY(-1.5rem) scale(.985); filter: blur(4px); } }
@keyframes vt-in { from { opacity: 0; transform: translateY(2rem) scale(1.01); filter: blur(4px); } }

/* ---------- Respaldo: si el JS no carga, todo queda visible ---------- */
.motion-fallback [data-reveal], .motion-fallback [data-stagger] > *, .motion-fallback .w__i { opacity: 1 !important; transform: none !important; clip-path: none !important; }

/* ---------- Movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; transition-delay: 0s !important; scroll-behavior: auto !important;
  }
  .js [data-reveal], .js [data-stagger] > *, .w__i { opacity: 1 !important; transform: none !important; clip-path: none !important; }
  [data-scrub-text] .sw { opacity: 1; }
  .marquee__group { animation: none; }
  .js [data-draw] { stroke-dashoffset: 0; }
  @view-transition { navigation: none; }
}
