/* =========================================================================
   FinanzApp · capa de movimiento
   Portada de entrada, reveals por scroll, inclinación y transiciones
   entre páginas. Todo nativo: sin librerías.

   Reglas de la casa:
   - Nada se mueve si el visitante pidió menos movimiento.
   - El contenido vive en el HTML; el movimiento sólo lo presenta.
   - Los efectos de puntero se activan sólo con mouse fino.
   ========================================================================= */

/* ---------------------------------------------------------------- tokens */
:root {
  --fx-ease: cubic-bezier(.22, 1, .36, 1);
  --fx-brand: #10b981;
  --fx-brand-soft: #4ade80;
  --fx-brand-pale: #6ee7b7;
  --fx-ink: #070d16;
}

/* ------------------------------------------------- transición entre páginas */
@view-transition { navigation: auto; }

@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root) { animation: fxFadeOut .22s var(--fx-ease) both; }
  ::view-transition-new(root) { animation: fxFadeIn .32s var(--fx-ease) both; }
  ::view-transition-group(marca) { animation-duration: .45s; animation-timing-function: var(--fx-ease); }
}
@keyframes fxFadeOut { to { opacity: 0; transform: translateY(-8px); } }
@keyframes fxFadeIn { from { opacity: 0; transform: translateY(10px); } }

/* La marca viaja de una página a otra en lugar de parpadear.
   Sólo la del header: cada página tiene otra igual en el pie, y dos
   elementos con el mismo view-transition-name abortan la transición entera. */
.erp-brand-logo { view-transition-name: none; }
header#navbar .erp-brand-logo { view-transition-name: marca; }

/* ------------------------------------------------------- barra de progreso */
.fx-progress {
  position: fixed;
  inset: 0 0 auto;
  height: 2px;
  z-index: 60;
  transform-origin: 0 50%;
  background: linear-gradient(90deg, var(--fx-brand), var(--fx-brand-pale));
  opacity: .9;
  pointer-events: none;
  scale: 0 1;
}
@supports (animation-timeline: scroll()) {
  @media (prefers-reduced-motion: no-preference) {
    .fx-progress { animation: fxProgress linear both; animation-timeline: scroll(root block); }
  }
}
@keyframes fxProgress { from { scale: 0 1; } to { scale: 1 1; } }

/* ------------------------------------------------------------ grano sutil */
.fx-grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: .035;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}
html:not(.dark) .fx-grain { opacity: .022; mix-blend-mode: multiply; }

/* ------------------------------------------------- reveals impulsados por scroll */
html.fx-on .fx-up,
html.fx-on .fx-mask,
html.fx-on .fx-stagger > * { will-change: opacity, transform; }

@media (prefers-reduced-motion: no-preference) {
  html.fx-on .fx-up { opacity: 0; transform: translateY(22px); transition: opacity .7s var(--fx-ease) var(--d, 0ms), transform .7s var(--fx-ease) var(--d, 0ms); }
  html.fx-on .fx-up.is-in { opacity: 1; transform: none; }

  /* El titular se descubre detrás de una máscara, como un telón. */
  html.fx-on .fx-mask {
    opacity: 0;
    clip-path: inset(0 0 102% 0);
    transition: opacity .5s var(--fx-ease), clip-path .9s var(--fx-ease);
  }
  html.fx-on .fx-mask.is-in { opacity: 1; clip-path: inset(-20% -10% -20% -10%); }

  html.fx-on .fx-stagger > * { opacity: 0; transform: translateY(18px); transition: opacity .6s var(--fx-ease) var(--d, 0ms), transform .6s var(--fx-ease) var(--d, 0ms); }
  html.fx-on .fx-stagger > *.is-in { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------ tilt del mockup */
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .fx-tilt-scene { perspective: 1400px; }
  .fx-tilt {
    transform: rotateX(var(--ry, 0deg)) rotateY(var(--rx, 0deg)) translateZ(0);
    transition: transform .5s var(--fx-ease);
    transform-style: preserve-3d;
  }
  .fx-tilt.is-live { transition: transform .12s linear; }
}

/* --------------------------------------------------------- botón magnético */
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .fx-magnet { transition: transform .35s var(--fx-ease); transform: translate(var(--bx, 0), var(--by, 0)); }
}

/* ============================== PORTADA ==================================
   Sólo la marca, pero trabajada: la pieza se enciende, un destello recorre
   su borde, un pulso sale hacia la derecha y va escribiendo el nombre.
   Dura dos segundos y entra sola; un clic o una tecla la saltean.
   ======================================================================== */
html.fx-intro-open,
html.fx-intro-open body { overflow: hidden; }

.fx-intro {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: #05080e;
  cursor: pointer;
  overflow: hidden;
}
/* Retícula técnica que se desvanece: el fondo del sistema. */
.fx-intro::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgba(148, 163, 184, .07) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(148, 163, 184, .07) 1px, transparent 1px);
  background-size: 54px 54px;
  mask-image: radial-gradient(60% 55% at 50% 50%, #000 10%, transparent 75%);
}
.fx-intro::after {
  content: "";
  position: absolute;
  width: min(46rem, 80vw);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(16, 185, 129, .18), transparent 62%);
  pointer-events: none;
}

.fx-lockup {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: clamp(.9rem, 2vw, 1.3rem);
}
.fx-lockup-row { position: relative; display: flex; align-items: center; gap: clamp(.7rem, 1.6vw, 1.1rem); }

.fx-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(3rem, 5.4vw, 4.2rem);
  height: clamp(3rem, 5.4vw, 4.2rem);
}
.fx-mark img { width: 100%; height: 100%; }
/* Destello que da una vuelta por el canto de la pieza. */
.fx-mark-sheen {
  position: absolute;
  inset: -2px;
  border-radius: 30%;
  padding: 1.5px;
  background: conic-gradient(from 0turn, transparent 0 62%, rgba(167, 243, 208, .95) 78%, rgba(16, 185, 129, 0) 92%);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
}
/* Onda que se expande una sola vez, como un sistema que arranca. */
.fx-mark-ring {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(110, 231, 183, .7);
  border-radius: 30%;
  opacity: 0;
}

/* Mismo lockup que el login del ERP: FinanzApp en verde, ERP en tinta. */
.fx-brand-title {
  margin: 0;
  letter-spacing: -.035em !important;
  font-family: "Plus Jakarta Sans", Inter, system-ui, sans-serif;
  font-size: clamp(2rem, 5.2vw, 3.5rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.035em;
  white-space: nowrap;
  color: #f8fafc;
}
.fx-brand-title .brand-app { color: #4ade80; }
.fx-brand-title .erp-product { margin-left: 1px; color: #f8fafc; font-weight: 800; }

/* La pastilla IA, igual que en el ERP y en el encabezado del sitio. */
.fx-lockup .ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid rgba(74, 222, 128, .48);
  background: linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,.025)), rgba(6, 78, 59, .48);
  box-shadow: 0 0 0 1px rgba(74,222,128,.10), 0 0 14px rgba(34,197,94,.20), 0 5px 12px rgba(0,0,0,.20), inset 0 1px 0 rgba(255,255,255,.10);
  color: #86efac;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.fx-lockup .ai-badge svg { width: 11px; height: 11px; }

.fx-lockup-line {
  width: min(16rem, 52vw);
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(110, 231, 183, .75), transparent);
  transform: scaleX(0);
}

@media (prefers-reduced-motion: no-preference) {
  .fx-intro::before { animation: fxReticula 2.1s cubic-bezier(.22, 1, .36, 1) both; }
  .fx-mark { animation: fxMarca .85s cubic-bezier(.22, 1, .36, 1) both; }
  .fx-mark-sheen { animation: fxDestello 1.15s cubic-bezier(.4, 0, .2, 1) .25s both; }
  .fx-mark-ring { animation: fxOnda 1.1s cubic-bezier(.22, 1, .36, 1) .55s both; }
  .fx-pulse { animation: fxPulso .78s cubic-bezier(.65, 0, .35, 1) .52s both; }
  .fx-brand-title { animation: fxNombre .78s cubic-bezier(.65, 0, .35, 1) .52s both; }
  .fx-lockup .ai-badge { animation: fxChip .45s cubic-bezier(.34, 1.56, .64, 1) 1.22s both; }
  .fx-lockup-line { animation: fxLinea .85s cubic-bezier(.22, 1, .36, 1) 1.05s both; }
}
@keyframes fxReticula {
  from { opacity: 0; transform: scale(1.06); }
  45%  { opacity: 1; }
  to   { opacity: .45; transform: none; }
}
@keyframes fxMarca {
  from { opacity: 0; transform: scale(.78) translateY(12px); filter: blur(12px); }
  to   { opacity: 1; transform: none; filter: none; }
}
@keyframes fxDestello {
  0%   { opacity: 0; rotate: 0turn; }
  18%  { opacity: 1; }
  85%  { opacity: 1; }
  100% { opacity: 0; rotate: 1turn; }
}
@keyframes fxOnda {
  from { opacity: .85; transform: scale(1); }
  to   { opacity: 0; transform: scale(1.75); }
}
@keyframes fxPulso {
  0%   { opacity: 0; transform: translateX(0) scaleY(.4); }
  15%  { opacity: 1; transform: translateX(0) scaleY(1); }
  85%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(var(--ancho, 9em)) scaleY(.5); }
}
@keyframes fxNombre {
  from { clip-path: inset(0 100% 0 0); }
  to   { clip-path: inset(0 -12% 0 0); }
}
@keyframes fxChip { from { opacity: 0; transform: scale(.6); } }
@keyframes fxLinea { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* ---------------------------- parallax impulsado por el scroll (nativo) */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) and (min-width: 1024px) {
    /* El mockup del ERP se aleja apenas cuando la portada del hero sale de cuadro. */
    .hero-erp-card {
      animation: fxDespegue linear both;
      animation-timeline: view(block);
      animation-range: exit -10% exit 90%;
    }
    /* Las tarjetas del catálogo entran con profundidad en lugar de aparecer. */
    .sec-card, .solution-card {
      animation: fxEntradaProfunda linear both;
      animation-timeline: view(block);
      animation-range: entry 8% entry 65%;
    }
  }
}
@keyframes fxDespegue { to { transform: translateY(-26px) scale(.985); opacity: .9; } }
@keyframes fxEntradaProfunda { from { opacity: 0; transform: translateY(34px) scale(.985); } }

/* --------------------------------------- equilibrio tipográfico moderno */
h1, h2, .fx-intro-name { text-wrap: balance; }
p, li { text-wrap: pretty; }

/* ------------------------------------------- botón de entrada de la portada */
.fx-enter {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  margin-top: .4rem;
  padding: .85rem 1.5rem;
  border: 0;
  border-radius: .8rem;
  background: linear-gradient(120deg, #10b981 0%, #34d399 100%);
  color: #04221a;
  font-family: inherit;
  font-size: .95rem;
  font-weight: 800;
  letter-spacing: -.01em;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 18px 38px -20px rgba(16, 185, 129, .95), inset 0 1px 0 rgba(255, 255, 255, .28);
  transition: box-shadow .3s var(--fx-ease), filter .3s var(--fx-ease);
}
.fx-enter:hover { box-shadow: 0 22px 46px -18px rgba(16, 185, 129, 1), inset 0 1px 0 rgba(255, 255, 255, .35); filter: brightness(1.06); }
.fx-enter:focus-visible { outline: 2px solid #a7f3d0; outline-offset: 4px; }
.fx-enter-flecha { width: 1.05rem; height: 1.05rem; transition: transform .3s var(--fx-ease); }
.fx-enter:hover .fx-enter-flecha { transform: translateX(3px); }
/* Un brillo recorre el botón, igual que el destello del logo. */
.fx-enter-brillo {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .55) 50%, transparent 65%);
  transform: translateX(-120%);
}
@media (prefers-reduced-motion: no-preference) {
  .fx-enter { animation: fxBoton .6s cubic-bezier(.34, 1.56, .64, 1) 1.75s both; }
  .fx-enter-brillo { animation: fxBrillo 2.6s cubic-bezier(.4, 0, .2, 1) 2s infinite; }
}
@keyframes fxBoton { from { opacity: 0; transform: scale(.94); } }
@keyframes fxBrillo { 0% { transform: translateX(-120%); } 55%, 100% { transform: translateX(120%); } }

/* -------------------------- el destello se repite sobre la marca del header */
.fx-nav-mark { position: relative; display: inline-flex; }
.fx-nav-sheen {
  position: absolute;
  inset: -1px;
  border-radius: 28%;
  padding: 1.2px;
  background: conic-gradient(from 0turn, transparent 0 62%, rgba(167, 243, 208, .95) 78%, rgba(16, 185, 129, 0) 92%);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  pointer-events: none;
}
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .erp-brand-logo.fx-replay .fx-nav-sheen { animation: fxDestello .9s cubic-bezier(.4, 0, .2, 1) both; }
  .erp-brand-logo.fx-replay > span:not(.ai-badge) { animation: fxNombre .6s cubic-bezier(.65, 0, .35, 1) .08s both; }
  .erp-brand-logo.fx-replay .ai-badge { animation: fxChip .42s cubic-bezier(.34, 1.56, .64, 1) .42s both; }
}

/* ===================== IDENTIDAD DE MARCA ================================
   El lockup del encabezado y del pie es el mismo que el de la portada y el
   del login del ERP: ícono sin recuadro, FinanzApp en degradado verde y ERP
   pegado en tinta, en Plus Jakarta Sans 800 con el mismo tracking.
   Lleva !important y selectores con #navbar porque el CSS heredado los pisa.
   ========================================================================= */
.erp-brand-logo > span:not(.ai-badge):not(.erp-product),
header#navbar .erp-brand-logo > span:not(.ai-badge):not(.erp-product),
footer .erp-brand-logo > span:not(.ai-badge):not(.erp-product) {
  font-family: "Plus Jakarta Sans", Inter, system-ui, sans-serif !important;
  font-weight: 800 !important;
  letter-spacing: -.035em !important;
  background: none !important;
  color: #4ade80 !important;
  -webkit-text-fill-color: #4ade80 !important;
  -webkit-text-stroke: 0 !important;
  text-shadow: none !important;
  paint-order: normal !important;
}
.erp-brand-logo > span.erp-product,
header#navbar .erp-brand-logo > span.erp-product,
footer .erp-brand-logo > span.erp-product {
  margin-left: calc(1px - 10px) !important; /* anula el gap del lockup: FinanzAppERP va pegado */
  font-family: "Plus Jakarta Sans", Inter, system-ui, sans-serif !important;
  font-size: inherit !important;
  font-weight: 800 !important;
  letter-spacing: -.035em !important;
  line-height: inherit !important;
  background: none !important;
  color: #f8fafc !important;
  -webkit-text-fill-color: #f8fafc !important;
  -webkit-text-stroke: 0 !important;
  text-shadow: none !important;
}
/* El ícono va tal cual, sin el recuadro ni la sombra que le agregaba el sitio. */
.erp-brand-logo img.brand-mark,
header#navbar .erp-brand-logo img.brand-mark,
footer .erp-brand-logo img.brand-mark,
html.dark header#navbar .erp-brand-logo img.brand-mark,
html:not(.dark) header#navbar .erp-brand-logo img.brand-mark {
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: none !important;
  filter: none !important;
}

/* En claro, los mismos valores que usa el login: verde oscuro y tinta. */
html:not(.dark) .erp-brand-logo > span:not(.ai-badge):not(.erp-product),
html:not(.dark) header#navbar .erp-brand-logo > span:not(.ai-badge):not(.erp-product),
html:not(.dark) footer .erp-brand-logo > span:not(.ai-badge):not(.erp-product) {
  background: none !important;
  color: #047857 !important;
  -webkit-text-fill-color: #047857 !important;
  -webkit-text-stroke: 0 !important;
  text-shadow: none !important;
}
html:not(.dark) .erp-brand-logo > span.erp-product,
html:not(.dark) header#navbar .erp-brand-logo > span.erp-product,
html:not(.dark) footer .erp-brand-logo > span.erp-product {
  color: #0f172a !important;
  -webkit-text-fill-color: #0f172a !important;
}

/* ------------------------------------- saludo de la portada, en tres idiomas */
.fx-hola {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin: .15rem 0 .1rem;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: clamp(.46rem, .58vw, .54rem);
  font-weight: 500;
  letter-spacing: .34em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, .42);
}
.fx-hola span { white-space: nowrap; }
.fx-hola i { font-style: normal; color: rgba(148, 163, 184, .25); }
@media (prefers-reduced-motion: no-preference) {
  .fx-hola span { animation: fxSaludoPalabra .6s cubic-bezier(.22, 1, .36, 1) both; }
  .fx-hola span:nth-child(1) { animation-delay: 1.55s; }
  .fx-hola span:nth-child(3) { animation-delay: 1.65s; }
  .fx-hola span:nth-child(5) { animation-delay: 1.75s; }
}
@keyframes fxSaludoPalabra { from { opacity: 0; transform: translateY(5px); } }
@media (max-width: 480px) {
  .fx-hola { gap: .45rem; letter-spacing: .18em; }
}
