/* Efectos que no conviene expresar como utilidades de Tailwind.
   Los tokens de diseño viven en el bloque @theme de index.php. */

html { scroll-behavior: smooth; scroll-padding-top: 6rem; overflow-x: clip; }
body { background: #04070f; overflow-x: clip; }

/* ---------- Fondo: grano ---------- */
.grain::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  opacity: .05;
  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='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Texto "ON" encendido ---------- */
.text-on-glow {
  color: #e9fdff;
  text-shadow: 0 0 12px rgba(62, 230, 255, .75), 0 0 42px rgba(62, 230, 255, .45), 0 0 90px rgba(47, 107, 255, .45);
  animation: flicker 6s infinite;
}
@keyframes flicker {
  0%, 18%, 22%, 62%, 64%, 100% { opacity: 1; }
  20%, 63% { opacity: .55; }
}

/* ---------- Letrero "siempre ON" del footer: se enciende al pasar el mouse ---------- */
.neon-sign { cursor: default; }
.neon-sign > span {
  color: transparent;
  -webkit-text-stroke: 1px rgba(255, 255, 255, .12);
  transition: color .5s, -webkit-text-stroke-color .5s, text-shadow .5s;
}
.neon-sign:hover .neon-sign__word {
  -webkit-text-stroke-color: rgba(62, 230, 255, .55);
  text-shadow: 0 0 24px rgba(62, 230, 255, .25), 0 0 70px rgba(47, 107, 255, .25);
  animation: neon-ignite .7s steps(1, end) both;
}
.neon-sign:hover .neon-sign__on {
  color: #e9fdff;
  -webkit-text-stroke-color: rgba(165, 245, 255, .9);
  text-shadow: 0 0 14px rgba(62, 230, 255, .8), 0 0 48px rgba(62, 230, 255, .5), 0 0 120px rgba(47, 107, 255, .55);
  animation: neon-ignite .7s .15s steps(1, end) both, flicker 6s 1s infinite;
}
@keyframes neon-ignite {
  0% { opacity: .3; }
  15% { opacity: 1; }
  25% { opacity: .4; }
  40% { opacity: 1; }
  50% { opacity: .6; }
  60%, 100% { opacity: 1; }
}

/* ---------- Borde cónico animado ---------- */
@property --angle { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
.border-beam { position: relative; isolation: isolate; }
.border-beam::before {
  content: "";
  position: absolute;
  inset: 0;
  padding: 1px;
  border-radius: inherit;
  background: conic-gradient(from var(--angle), transparent 0 70%, #3ee6ff 82%, #2f6bff 90%, transparent 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask-composite: exclude;
  animation: spin-angle 5s linear infinite;
  pointer-events: none;
  z-index: 1;
}
@keyframes spin-angle { to { --angle: 360deg; } }

/* ---------- Cuadros de sistemas: se encienden al pasar el mouse ---------- */
@property --glow { syntax: "<number>"; initial-value: 0; inherits: false; }
.sys-card {
  --glow: 0;
  background-image: linear-gradient(to bottom, rgb(29 79 216 / calc(var(--glow) * .25)), rgb(12 20 38 / calc(var(--glow) * .6)));
  transition: --glow .5s, box-shadow .5s, transform .3s ease-out;
}
.sys-card.is-featured,
.sys-card:hover { --glow: 1; }
.sys-card:hover { box-shadow: 0 0 60px -10px rgba(62, 230, 255, .25); }
.sys-card::before { opacity: 0; transition: opacity .5s; }
.sys-card.is-featured::before,
.sys-card:hover::before { opacity: 1; }

/* ---------- Spotlight que sigue al cursor ---------- */
.spotlight { --x: 50%; --y: 50%; }
.spotlight::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity .3s;
  background: radial-gradient(420px circle at var(--x) var(--y), rgba(62, 230, 255, .12), transparent 45%);
}
.spotlight:hover::after { opacity: 1; }

/* ---------- Reveal al hacer scroll (solo si hay JS) ---------- */
.js [data-reveal] {
  opacity: 0;
  transform: translateY(28px);
  filter: blur(6px);
  transition: opacity .9s cubic-bezier(.2, .8, .2, 1), transform .9s cubic-bezier(.2, .8, .2, 1), filter .9s;
  transition-delay: var(--d, 0ms);
}
.js [data-reveal].is-in { opacity: 1; transform: none; filter: none; }

/* ---------- Marquee ---------- */
.marquee { mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); }
.marquee__track { animation: marquee 38s linear infinite; }
.marquee:hover .marquee__track { animation-play-state: paused; }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- Palabras rotativas ---------- */
.rotator { display: inline-grid; vertical-align: bottom; overflow: hidden; }
.rotator > span {
  grid-area: 1 / 1;
  transform: translateY(105%);
  opacity: 0;
  transition: transform .7s cubic-bezier(.2, .8, .2, 1), opacity .7s;
}
.rotator > span.is-active { transform: none; opacity: 1; }
.rotator > span.is-leaving { transform: translateY(-105%); opacity: 0; }
html:not(.js) .rotator > span:first-child { transform: none; opacity: 1; }

/* ---------- Intro: encendido ---------- */
@property --hole { syntax: "<length>"; initial-value: 0px; inherits: false; }
.power-intro {
  --hole: 0px;
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: #02040a;
  -webkit-mask: radial-gradient(circle at 50% 50%, transparent var(--hole), #000 calc(var(--hole) + 80px));
          mask: radial-gradient(circle at 50% 50%, transparent var(--hole), #000 calc(var(--hole) + 80px));
  transition: --hole 1.2s cubic-bezier(.7, 0, .2, 1), opacity .3s 1.1s;
}
.power-intro.is-on { --hole: 150vmax; opacity: 0; pointer-events: none; }
.power-intro.is-on .power-intro__btn, .power-intro.is-on p { opacity: 0; transition: opacity .2s; }
.power-intro__btn { transition: transform .25s, filter .4s, color .4s; }
.power-intro__btn:active { transform: scale(.94); }
.power-intro.is-pressing .power-intro__btn {
  color: #3ee6ff;
  filter: drop-shadow(0 0 18px rgba(62, 230, 255, .9)) drop-shadow(0 0 60px rgba(47, 107, 255, .7));
}
.power-intro__ring { animation: ring 2.4s cubic-bezier(.2, .8, .2, 1) infinite; }
@keyframes ring {
  from { transform: scale(.6); opacity: .7; }
  to { transform: scale(2.2); opacity: 0; }
}

/* ---------- Mock del dashboard ---------- */
.bar { transform-origin: bottom; transition: transform 1.2s cubic-bezier(.2, .8, .2, 1); }
.toast-in { animation: toast 4.5s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes toast {
  0% { transform: translateY(16px) scale(.96); opacity: 0; }
  10%, 85% { transform: none; opacity: 1; }
  100% { transform: translateY(-8px); opacity: 0; }
}
.js .chart-line { stroke-dasharray: 600; stroke-dashoffset: 600; }
.js.powered .chart-line { animation: draw 2.4s .6s cubic-bezier(.2, .8, .2, 1) forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---------- Switch OFF / ON ---------- */
.state-off [data-on-only], .state-on [data-off-only] { display: none; }
.state-on .switch-knob { transform: translateX(100%); }
.state-on .switch-track { background: linear-gradient(90deg, #2f6bff, #3ee6ff); box-shadow: 0 0 30px rgba(62, 230, 255, .45); }
.state-off .pain-card { filter: grayscale(1); }
.pain-card { transition: filter .6s, border-color .6s, background-color .6s; }
.state-on .pain-card { border-color: rgba(62, 230, 255, .25); }

/* ---------- Timeline ---------- */
.timeline__fill { transform-origin: top; transform: scaleY(var(--p, 0)); }

/* ---------- Ventana de detalle de cada sistema ---------- */
html.modal-open, html.modal-open body { overflow: hidden; }
.sys-modal {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.sys-modal[open] { display: block; animation: modal-fade .3s ease-out; }
.sys-modal[open] .sys-modal__panel { animation: modal-in .45s cubic-bezier(.2, .8, .2, 1); }
.sys-modal::backdrop { background: rgb(2 4 10 / .78); backdrop-filter: blur(8px); }
.sys-modal__panel { width: min(76rem, 100%); min-height: 100%; margin: 0 auto; }
/* Margen en el panel y no padding en el dialog: así la cabecera fija se pega arriba de todo. */
@media (min-width: 640px) {
  .sys-modal__panel { width: min(76rem, calc(100% - 3rem)); min-height: 0; margin: 2rem auto; }
}
@keyframes modal-fade { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(32px) scale(.98); } }

/* Galería: tira deslizable con snap (en el celular se arrastra con el dedo) */
.gal {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  outline: none;
}
.gal::-webkit-scrollbar { display: none; }
.gal:focus-visible { box-shadow: inset 0 0 0 2px #3ee6ff; border-radius: 1.5rem; }
.gal__slide { flex: 0 0 100%; min-width: 0; margin: 0; scroll-snap-align: center; }
.gal__frame {
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  padding: .75rem;
  border-radius: 1.5rem;
  background: radial-gradient(ellipse at 50% 40%, rgb(47 107 255 / .18), transparent 70%), rgb(255 255 255 / .02);
}
/* En pantallas grandes la captura no ocupa todo el alto: debajo se asoma la explicación. */
@media (min-width: 640px) { .gal__frame { aspect-ratio: auto; height: clamp(18rem, 58vh, 40rem); padding: 1.25rem; } }
.gal__frame img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; min-height: 0; }
.gal__nav {
  position: absolute;
  top: calc(50% - 1.5rem);
  display: none; /* en el celular se desliza con el dedo */
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 9999px;
  border: 1px solid rgb(255 255 255 / .15);
  background: rgb(7 12 24 / .85);
  color: #fff;
  backdrop-filter: blur(8px);
  transition: border-color .2s, background-color .2s, transform .2s;
}
@media (min-width: 640px) { .gal__nav { display: grid; } }
.gal__nav:hover { border-color: rgb(62 230 255 / .6); background: rgb(20 32 56 / .95); }
.gal__nav:active { transform: scale(.94); }
.gal__nav:focus-visible { outline: 2px solid #3ee6ff; outline-offset: 2px; }
.gal__thumbs { scrollbar-width: thin; scrollbar-color: rgb(255 255 255 / .15) transparent; }
.gal__thumb {
  flex: 0 0 auto;
  height: 3.5rem;
  padding: .2rem;
  border-radius: .75rem;
  border: 1px solid rgb(255 255 255 / .08);
  background: rgb(255 255 255 / .03);
  opacity: .5;
  transition: opacity .2s, border-color .2s;
}
.gal__thumb img { height: 100%; width: auto; }
.gal__thumb:hover { opacity: .85; }
.gal__thumb.is-active { opacity: 1; border-color: rgb(62 230 255 / .7); }
.gal__thumb:focus-visible { outline: 2px solid #3ee6ff; outline-offset: 2px; }

/* ---------- Movimiento reducido ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .js [data-reveal] { opacity: 1; transform: none; filter: none; }
  .marquee__track { animation: none; }
  .chart-line { stroke-dashoffset: 0; }
}
