/* =========================================================
   FreeLink — animaciones (scroll reveal + hover + ambient)
   Sin librerías. Easing estilo GSAP (expo-out) con CSS puro.
   Progressive enhancement: el contenido solo se oculta si hay JS,
   así que sin JS o con JS fallido, todo se ve igual.
   ========================================================= */

/* ---------- Reveal al hacer scroll (con desenfoque sutil) ---------- */
html.js [data-reveal]{
  opacity:0;
  transform:translateY(26px);
  filter:blur(6px);
  transition:opacity .8s cubic-bezier(.16,1,.3,1),
             transform .8s cubic-bezier(.16,1,.3,1),
             filter .8s cubic-bezier(.16,1,.3,1);
  transition-delay:calc(var(--d, 0) * 80ms);
}
html.js [data-reveal].in{
  opacity:1;
  transform:none;
  filter:none;
}

/* ---------- Hero: titular palabra por palabra (máscara) ---------- */
/* El contenedor queda visible; las palabras entran desde una máscara. */
html.js h1[data-split]{
  opacity:1; transform:none; filter:none; transition:none;
}
html.js h1[data-split] .w{
  display:inline-block;
  overflow:hidden;
  vertical-align:top;
  padding-bottom:.1em;      /* espacio para las descendentes de Playfair */
  margin-bottom:-.1em;
}
html.js h1[data-split] .wi{
  display:inline-block;
  transform:translateY(115%) rotate(2deg);
  transform-origin:left top;
  transition:transform .9s cubic-bezier(.16,1,.3,1);
  transition-delay:calc(var(--wd, 0) * 65ms + 120ms);
  will-change:transform;
}
html.js h1[data-split].in .wi{ transform:none; }

/* Énfasis en cursiva: brillo cremoso que viaja lentamente */
h1 em{
  background:linear-gradient(105deg,
    var(--accent) 30%, var(--text) 50%, var(--accent) 70%);
  background-size:220% 100%;
  background-position:110% 0;
  -webkit-background-clip:text;
  background-clip:text;
  color:transparent;
  animation:emShine 6s ease-in-out 1.6s infinite;
}
@keyframes emShine{
  0%,100%{background-position:110% 0;}
  50%    {background-position:-10% 0;}
}

/* ---------- Logomark: entra girando al cargar ---------- */
@keyframes markIn{
  from{opacity:0; transform:rotate(-100deg) scale(.5);}
  to  {opacity:1; transform:none;}
}
html.js header .logomark{ animation:markIn .7s cubic-bezier(.16,1,.3,1) .1s both; }

/* ---------- Fondo ambiental: orbes de luz con deriva ---------- */
.ambient{
  position:fixed; inset:0; z-index:-1;
  overflow:hidden; pointer-events:none;
  transform:translate3d(calc(var(--px, 0) * 1px), calc(var(--py, 0) * 1px), 0);
}
.orb{ position:absolute; border-radius:50%; filter:blur(70px); }
.orb-a{
  width:46vw; height:46vw; min-width:380px; min-height:380px;
  left:-12vw; top:-14vw;
  background:radial-gradient(circle, color-mix(in srgb,var(--accent) 28%,transparent), transparent 65%);
  animation:driftA 24s ease-in-out infinite alternate;
}
.orb-b{
  width:40vw; height:40vw; min-width:320px; min-height:320px;
  right:-14vw; top:34%;
  background:radial-gradient(circle, color-mix(in srgb,var(--up) 16%,transparent), transparent 65%);
  animation:driftB 30s ease-in-out infinite alternate;
}
@keyframes driftA{
  from{transform:translate3d(0,0,0) scale(1);}
  to  {transform:translate3d(6vw,8vh,0) scale(1.15);}
}
@keyframes driftB{
  from{transform:translate3d(0,0,0) scale(1.1);}
  to  {transform:translate3d(-5vw,-6vh,0) scale(.95);}
}

/* ---------- Header sticky: blur al hacer scroll ---------- */
body.scrolled header{
  background:color-mix(in srgb,var(--bg) 84%,transparent);
  -webkit-backdrop-filter:blur(14px) saturate(1.2);
  backdrop-filter:blur(14px) saturate(1.2);
  box-shadow:0 1px 0 var(--line);
}

/* ---------- Barra de progreso de lectura ---------- */
.scroll-progress{
  position:fixed; top:0; left:0; right:0; height:2px; z-index:60;
  background:linear-gradient(90deg, var(--accent), var(--up));
  transform:scaleX(0); transform-origin:left;
  pointer-events:none;
}

/* ---------- Etiquetas de sección: la línea se dibuja ---------- */
.sec-label{ position:relative; }
html.js .sec-label::after{
  content:''; position:absolute; top:-1px; left:0;
  width:100%; height:1px; background:var(--accent);
  transform:scaleX(0); transform-origin:left;
  transition:transform 1.1s cubic-bezier(.16,1,.3,1) .15s;
}
html.js .sec-label.in::after{ transform:scaleX(1); }

/* ---------- Spotlight que sigue el cursor en tarjetas ---------- */
.servicio, .trabajo{ position:relative; overflow:hidden; }
.connection-demo{ position:relative; }
.servicio::after, .trabajo::after, .connection-demo::after{
  content:''; position:absolute; inset:0; pointer-events:none;
  opacity:0;
  background:radial-gradient(240px circle at var(--mx, 50%) var(--my, 50%),
    color-mix(in srgb,var(--accent) 10%,transparent), transparent 65%);
  transition:opacity .35s ease;
}
@media (hover:hover){
  .servicio:hover::after, .trabajo:hover::after,
  .connection-demo:hover::after{ opacity:1; }
}

/* ---------- Botones: elevar, brillo que recorre, oscurecer al click ---------- */
.cta-button{
  position:relative; overflow:hidden;
  transition:transform .22s cubic-bezier(.16,1,.3,1),
             box-shadow .25s ease,
             background-color .15s ease;
}
.cta-button::after{
  content:''; position:absolute; top:0; left:-80%;
  width:50%; height:100%;
  background:linear-gradient(105deg, transparent, color-mix(in srgb,var(--text) 22%,transparent), transparent);
  transform:skewX(-20deg);
  pointer-events:none;
}
@media (hover:hover){
  .cta-button:hover{
    transform:translateY(-3px);
    box-shadow:0 14px 30px -10px rgba(0,0,0,.55);
  }
  .cta-button:hover::after{ left:130%; transition:left .65s ease; }
  .cta-button.outline:hover{
    background-color:color-mix(in srgb,var(--accent) 10%,transparent);
  }
}
.cta-button:active{transform:translateY(-1px) scale(.99);}
.cta-button:not(.outline):active{background-color:color-mix(in srgb,var(--accent) 88%,var(--bg));}
.cta-button.outline:active{background-color:color-mix(in srgb,var(--accent) 18%,transparent);}

/* ---------- Tarjetas de servicio: elevar en hover (solo desktop) ---------- */
@media (hover:hover) and (min-width:768px){
  .servicio{
    transition:transform .28s cubic-bezier(.16,1,.3,1),
               border-color .28s ease,
               border-top-color .28s ease,
               box-shadow .28s ease;
  }
  .servicio:hover{
    transform:translateY(-5px);
    border-top-color:var(--accent);
    box-shadow:0 18px 36px -16px rgba(0,0,0,.6);
  }
}

/* ---------- Panel de conexión: el tilt lo aplica JS; transición algo más ágil ---------- */
.connection-demo{
  transition:transform .18s ease-out,
             box-shadow .3s ease, border-color .3s ease;
  will-change:transform;
}

/* ---------- Respeto a quien pide menos movimiento ---------- */
@media (prefers-reduced-motion:reduce){
  html.js [data-reveal]{opacity:1;transform:none;filter:none;}
  html.js h1[data-split] .wi{transform:none;}
  h1 em{background:none;color:var(--accent);}
  .ambient{transform:none!important;}
  .cta-button:hover,.servicio:hover{transform:none;}
  .cta-button::after{display:none;}
}
