/* =====================================================================
   CAPA DE EFECTOS (fx)
   Se suma encima de los estilos existentes, sin reemplazarlos.
   Inspirado en patrones de Aceternity UI / Magic UI, en CSS puro:
   foco de luz que sigue al cursor, borde luminoso que gira, brillo que
   recorre los botones, grilla que se revela bajo el cursor.
   Todo se apaga con "reducir movimiento" y en pantallas táctiles.
   ===================================================================== */

@property --fx-a { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
@keyframes fx-spin { to { --fx-a: 360deg; } }
@keyframes fx-shine { 0%, 64% { transform: translateX(-135%); } 100% { transform: translateX(135%); } }

/* ---------- tarjetas: foco de luz + borde que gira ---------- */
.card, .pcard { isolation: isolate; }
/* se suma la sombra a las transiciones que cada tarjeta ya tenía */
.card { transition: border-color .3s, transform .35s cubic-bezier(.16, 1, .3, 1), background .3s, box-shadow .45s; }
.pcard { transition: border-color .4s, background .4s, box-shadow .45s; }

/* foco de luz que sigue al cursor (las coordenadas las pone fx.js) */
.card::after, .pcard::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; z-index: -1; pointer-events: none;
  background: radial-gradient(440px circle at var(--fx-x, 50%) var(--fx-y, 0%), rgba(143, 172, 130, .17), rgba(209, 176, 135, .05) 32%, transparent 52%);
  opacity: 0; transition: opacity .45s ease;
}

/* borde luminoso: un anillo de 1px con un gradiente cónico que rota */
.card::before, .pcard::before {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px; z-index: -1; pointer-events: none;
  background: conic-gradient(from var(--fx-a), transparent 0deg 225deg, rgba(143, 172, 130, .9) 285deg, rgba(209, 176, 135, .95) 318deg, transparent 352deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  opacity: 0; transition: opacity .45s ease;
  animation: fx-spin 3.8s linear infinite; animation-play-state: paused;
}

@media (hover: hover) and (pointer: fine) {
  .card:hover::after, .pcard:hover::after, .card:focus-within::after { opacity: 1; }
  .card:hover::before, .pcard:hover::before, .card:focus-within::before { opacity: 1; animation-play-state: running; }
  /* sombra dinámica con un halo de la paleta */
  .card:hover, .pcard:hover {
    box-shadow: 0 22px 48px -18px rgba(0, 0, 0, .75), 0 0 0 1px rgba(143, 172, 130, .08), 0 18px 60px -30px rgba(143, 172, 130, .45);
  }
}
/* en el celular, el borde luminoso aparece al tocar */
@media (hover: none) {
  .card:active::before, .pcard:active::before { opacity: 1; animation-play-state: running; }
}

/* tarjeta de invitación (Mis cuadernos): borde que gira siempre, lento */
.invite::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: conic-gradient(from var(--fx-a), transparent 0deg 200deg, rgba(209, 176, 135, .85) 280deg, rgba(143, 172, 130, .7) 320deg, transparent 355deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  animation: fx-spin 7s linear infinite;
}

/* ---------- botones: un destello de luz que los recorre ---------- */
.btn { position: relative; overflow: hidden; }
.mbtn::after, .pay::after, .btn::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: linear-gradient(105deg, transparent 36%, rgba(255, 255, 255, .17) 50%, transparent 64%);
  transform: translateX(-135%);
  animation: fx-shine 6.5s cubic-bezier(.45, 0, .2, 1) infinite;
}
.pcard:nth-child(2) .pay::after { animation-delay: 1.4s; }
.pcard:nth-child(3) .pay::after { animation-delay: 2.8s; }
.pcard:nth-child(4) .pay::after { animation-delay: 4.2s; }
.mbtn.wa::after, .btn.wa::after { animation-delay: 2s; }
.mbtn:hover::after, .pay:hover::after, .btn:hover::after { opacity: 0; }
.mbtn:hover, .pay:hover, .btn:hover { box-shadow: 0 10px 34px -10px rgba(143, 172, 130, .55); }
.mbtn.wa:hover, .btn.wa:hover { box-shadow: 0 10px 34px -10px rgba(209, 176, 135, .55); }

/* en la web principal, las escenas ocultas no gastan cuadros animando destellos que nadie ve */
.deck .scene:not(.on) .pay::after, .deck .scene:not(.on) .mbtn::after,
.deck .scene:not(.on) .pcard::before { animation-play-state: paused; }

/* ---------- controles de Mis cuadernos: brillo y profundidad ---------- */
.chip, .tab, .dd-btn, .tags span, .tag { transition: border-color .25s, color .25s, background .25s, box-shadow .3s, transform .3s cubic-bezier(.16, 1, .3, 1); }
@media (hover: hover) and (pointer: fine) {
  .chip:hover, .dd-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 22px -12px rgba(143, 172, 130, .6); }
  .tags span:hover { box-shadow: 0 0 18px -6px rgba(143, 172, 130, .7); }
}
.chip[aria-pressed="true"] { box-shadow: 0 0 0 1px rgba(143, 172, 130, .25), 0 8px 26px -12px rgba(143, 172, 130, .7); }
.tab[aria-selected="true"] { box-shadow: 0 8px 28px -10px rgba(143, 172, 130, .65), inset 0 1px 0 rgba(255, 255, 255, .25); }
.search input:focus { box-shadow: 0 0 0 4px rgba(143, 172, 130, .12), 0 14px 40px -20px rgba(143, 172, 130, .6); }
.dd-list { box-shadow: 0 24px 60px -12px rgba(0, 0, 0, .7), 0 0 0 1px rgba(143, 172, 130, .06); }

/* ---------- grilla interactiva y halo que siguen al cursor (Mis cuadernos) ---------- */
.fx-grid, .fx-glow { position: fixed; pointer-events: none; z-index: -2; }
.fx-grid {
  inset: 0;
  background-image: radial-gradient(rgba(236, 231, 223, .26) 1px, transparent 1.5px);
  background-size: 30px 30px;
  -webkit-mask-image: radial-gradient(300px circle at var(--cx, -999px) var(--cy, -999px), #000 0%, rgba(0, 0, 0, .4) 45%, transparent 75%);
  mask-image: radial-gradient(300px circle at var(--cx, -999px) var(--cy, -999px), #000 0%, rgba(0, 0, 0, .4) 45%, transparent 75%);
  opacity: 0; transition: opacity .6s;
}
.fx-glow {
  left: 0; top: 0; width: 680px; height: 680px; margin: -340px 0 0 -340px; border-radius: 50%;
  background: radial-gradient(circle, rgba(143, 172, 130, .11), rgba(209, 176, 135, .04) 40%, transparent 65%);
  opacity: 0; transition: opacity .6s; will-change: transform;
}
.fx-on .fx-grid, .fx-on .fx-glow { opacity: 1; }

/* ---------- texto que se descifra (enlaces del menú) ---------- */
.fx-scr { display: inline-block; }

/* ---------- con GSAP activo, las tarjetas las revela GSAP al entrar en pantalla ---------- */
.fx-gsap .card.enter { animation: none; }
.fx-char { display: inline-block; will-change: transform, opacity, filter; }

/* ---------- respeto por "reducir movimiento" y pantallas táctiles ---------- */
@media (prefers-reduced-motion: reduce) {
  .card::before, .pcard::before, .invite::after { animation: none; }
  .mbtn::after, .pay::after, .btn::after { animation: none; display: none; }
  .fx-grid, .fx-glow { display: none; }
}
@media (hover: none), (pointer: coarse) {
  .fx-grid, .fx-glow { display: none; }
}

/* =====================================================================
   INTRO: apertura de la esclusa (www/intro.js)
   ===================================================================== */
/* cortina inicial: evita ver la web un instante antes de que arranque la intro */
html.intro-pending body::after {
  content: ''; position: fixed; inset: 0; z-index: 99990; pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, #10151b 0%, #06080b 72%);
}
html.intro-pending.intro-running body::after { display: none; }
#intro { position: fixed; inset: 0; z-index: 99995; overflow: hidden; }
#intro canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; }
#intro .intro-vig { position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse 80% 75% at 50% 50%, transparent 60%, rgba(0, 0, 0, .35) 100%); }
.intro-hud { position: absolute; inset: 0; pointer-events: none; opacity: 0;
  font-family: Inter, sans-serif; color: #e9e4da; text-transform: uppercase; letter-spacing: .24em; font-size: 11px; }
.intro-hud .h-tl, .intro-hud .h-tr { position: absolute; top: 30px; display: flex; align-items: center; gap: 10px; }
.intro-hud .h-tl { left: 34px; } .intro-hud .h-tr { right: 34px; opacity: .55; }
.intro-hud .h-tl i { width: 7px; height: 7px; border-radius: 50%; background: #7fd18a; box-shadow: 0 0 12px #7fd18a; animation: intro-blink 1.1s infinite; }
@keyframes intro-blink { 50% { opacity: .25; } }
.intro-hud .h-c { position: absolute; left: 50%; bottom: 10%; transform: translateX(-50%); width: min(380px, 78vw); text-align: center; }
.intro-hud .h-status { font-size: 12px; letter-spacing: .32em; color: #d1b087; text-shadow: 0 0 18px rgba(209, 176, 135, .45); }
.intro-hud .h-status.flash { animation: intro-flash .5s steps(4) 1; }
@keyframes intro-flash { 0%, 50% { opacity: .2; } 25%, 100% { opacity: 1; } }
.intro-hud .h-bar { height: 1px; margin: 14px 0 10px; background: rgba(233, 228, 218, .18); overflow: hidden; }
.intro-hud .h-bar b { display: block; height: 100%; background: linear-gradient(90deg, #8fac82, #d1b087); transform: scaleX(0); transform-origin: left; box-shadow: 0 0 10px rgba(143, 172, 130, .8); }
.intro-hud .h-sub { font-size: 10px; letter-spacing: .26em; opacity: .7; }
.intro-hud .h-kpa { font-variant-numeric: tabular-nums; display: inline-block; min-width: 2.4em; text-align: right; color: #f2eee7; }
.intro-hud .h-corner { position: absolute; width: 22px; height: 22px; border: 1px solid rgba(233, 228, 218, .35); }
.intro-hud .c1 { top: 18px; left: 18px; border-right: 0; border-bottom: 0; }
.intro-hud .c2 { top: 18px; right: 18px; border-left: 0; border-bottom: 0; }
.intro-hud .c3 { bottom: 18px; left: 18px; border-right: 0; border-top: 0; }
.intro-hud .c4 { bottom: 18px; right: 18px; border-left: 0; border-top: 0; }
.intro-skip { position: absolute; right: 32px; bottom: 28px; z-index: 2; padding: 10px 18px; border-radius: 40px; cursor: pointer;
  font: 500 11px/1 Inter, sans-serif; letter-spacing: .2em; text-transform: uppercase; color: rgba(233, 228, 218, .78);
  background: rgba(10, 12, 16, .45); border: 1px solid rgba(233, 228, 218, .2); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: color .25s, border-color .25s, background .25s; }
.intro-skip:hover, .intro-skip:focus-visible { color: #0d0f12; background: #8fac82; border-color: #8fac82; outline: none; }
@media (max-width: 700px) {
  .intro-hud { font-size: 9px; letter-spacing: .18em; }
  .intro-hud .h-tl { left: 22px; top: 24px; } .intro-hud .h-tr { display: none; }
  .intro-hud .h-c { bottom: 15%; }
  .intro-skip { right: 50%; transform: translateX(50%); bottom: 22px; }
}
