/* ============= VARIABLES Y SISTEMA DE DISENO ============= */
:root {
  --fondo: #0b0f12;
  --superficie: #1e252d;
  --superficie-lectura: rgba(11, 15, 18, 0.98);
  --fondo-cabeceras: linear-gradient(
    90deg,
    rgba(11, 15, 18, 1) 0%,
    rgba(11, 15, 18, 1) 20%,
    rgba(11, 15, 18, 0.8) 45%,
    rgba(11, 15, 18, 0.8) 75%,
    rgba(11, 15, 18, 1) 100%
  );
  --texto: #f1eee9;
  --coral: #e35140;
  --cian: #1caebf;
  --borde: #f1eee933;
  --texto-suave: #f1eee9b8;
  --margen-lateral: 5vw;
  --separacion: 1.25vw;
  --columnas: 12;
  --alto-encabezado: 5.5rem;
  --radio: 0.6rem;
  --transicion: 300ms ease;
  --fuente-titulos: "Poiret One", "Segoe UI", sans-serif;
  --fuente-cuerpo: "Manrope", "Segoe UI", sans-serif;
}

/* ============= BASE ============= */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  /* Escala continua y legible hasta 4K, 8K y resoluciones superiores. */
  font-size: max(16px, 0.94vw);
  scroll-behavior: smooth;
  scroll-padding-top: var(--alto-encabezado);
}
body {
  margin: 0;
  min-width: 280px;
  background: var(--fondo);
  color: var(--texto);
  font-family: var(--fuente-cuerpo);
  line-height: 1.55;
}
body.modal-abierto {
  overflow: hidden;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  cursor: pointer;
  color: inherit;
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.3;
}
a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transicion);
}
a:not(.boton):hover {
  color: var(--coral);
}
img,
svg {
  display: block;
  max-width: 100%;
}
h1,
h2,
h3,
h4,
p {
  margin: 0;
}
p + p {
  margin-top: 1rem;
}
:focus-visible {
  outline: 2px solid var(--cian);
  outline-offset: 4px;
}
[hidden] {
  display: none !important;
}
::selection {
  background: var(--cian);
  color: var(--fondo);
}

/* ============= REJILLA RESPONSIVE 12 COLUMNAS ============= */
.contenedor {
  width: calc(100% - 2 * var(--margen-lateral));
  margin-inline: auto;
}
.rejilla {
  display: grid;
  grid-template-columns: repeat(var(--columnas), minmax(0, 1fr));
  column-gap: var(--separacion);
  row-gap: var(--separacion);
}
.sitio {
  position: relative;
  isolation: isolate;
}

/* ============= GUIAS DE DESARROLLO ============= */
.guia-rejilla {
  position: fixed;
  inset: 0;
  z-index: 1100;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 180ms ease,
    visibility 180ms ease;
}
.guia-rejilla.visible {
  opacity: 1;
  visibility: visible;
}
.guia-rejilla__columnas {
  height: 100%;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--separacion);
}
/* Solo usa cian con transparencias. Bordes y columnas suficientemente visibles. */
.guia-rejilla__columnas span {
  border-left: 1px solid #1caebfc2;
  border-right: 1px solid #1caebfc2;
  background: #1caebf24;
}
.guia-rejilla.visible::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 39px,
    #1caebf20 40px
  );
}
.control-rejilla {
  position: fixed;
  right: 1.1rem;
  bottom: 1.1rem;
  z-index: 1101;
  display: flex;
  gap: 0.4rem;
  align-items: center;
  border: 1px solid var(--borde);
  border-radius: 99px;
  background: var(--superficie);
  color: var(--texto);
  padding: 0.55rem 0.85rem;
  font-size: 0.68rem;
  box-shadow: 0 0.3rem 1.7rem #0b0f1266;
  /* Boton de rejilla visible para facilitar la revision del layout. */
  display: none;
}
.control-rejilla[aria-pressed="true"] {
  border-color: var(--cian);
  color: var(--fondo);
  background: var(--cian);
  font-weight: 800;
}

/* ============= ESCENA GRAFICA COMPARTIDA ============= */
/* Fondo (0), lineas (1), filtro (2), nebulosa (3), esferas (4) y contenido (5).
   Todos los componentes interactivos siguen delante de la escena. */
.escena-fondo {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  isolation: isolate;
  overflow: hidden;
  background: transparent;
}
.escena-fondo__lineas,
.escena-fondo__filtro,
.escena-fondo__nebulosa,
.escena-fondo__esferas {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.escena-fondo__lineas {
  z-index: 1;
}
.escena-fondo__lienzo {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  pointer-events: none;
}
.escena-fondo__filtro {
  z-index: 2;
  background: rgba(30, 37, 45, 0.3);
}
.escena-fondo__nebulosa {
  z-index: 3;
  opacity: 0.85;
}
/* GSAP desplaza el contenedor; CSS mueve solamente su contenido.
   Así no compiten dos animaciones sobre el mismo transform. */
.escena-fondo__nebulosa::before {
  content: "";
  position: absolute;
  inset: 0;
  animation: nebulosa-flotante 19s ease-in-out infinite alternate;
  /* Niebla atmosferica sobre las lineas; todas las tintas usan la paleta. */
  background:
    radial-gradient(ellipse 34% 44% at 12% 45%, #0b0f12cb 0%, #0b0f1200 100%),
    radial-gradient(ellipse 30% 32% at 44% 31%, #1caebf0d 0%, #0b0f1200 90%),
    radial-gradient(ellipse 35% 46% at 94% 75%, #e351400e 0%, #0b0f1200 90%),
    linear-gradient(to bottom, #0b0f1200 55%, #0b0f1230);
}
.escena-fondo__esferas {
  z-index: 4;
}
.esfera-grafica {
  position: absolute;
  top: 0;
  left: 0;
  width: 100px;
  height: 100px;
  background-position: center;
  background-size: contain;
  background-repeat: no-repeat;
  border-radius: 50%;
  will-change: transform;
}
.esfera-grafica[data-esfera="celeste-grande"],
.esfera-grafica[data-esfera="celeste-pequena"] {
  background-image: url("../assets/img/esferas/esfera_celeste_desktop.webp");
}
.esfera-grafica[data-esfera="salmon-grande"],
.esfera-grafica[data-esfera="salmon-pequena"] {
  background-image: url("../assets/img/esferas/esfera_salmon_desktop.webp");
}
/* El escenario grafico es compartido y permanece detras del contenido. */
.sitio,
.pie-global {
  position: relative;
  z-index: 1;
}
.banner-presentacion,
.panel__envoltura,
.panel__interior,
.pie-global {
  background: transparent;
}

/* ============= AJUSTES DE ESCALA ============= */
/* 1920px => 96px margen, 24px gap, 16px rem. 4K y 8K crecen sin max-width. */
@media (max-width: 767px) {
  :root {
    --margen-lateral: 20px;
    --separacion: 8px;
    --alto-encabezado: 78px;
  }
  html {
    font-size: 16px;
  }
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ============= ESCENA MOBILE ============= */
@media (max-width: 767px) {
  .esfera-grafica[data-esfera="celeste-grande"],
  .esfera-grafica[data-esfera="celeste-pequena"] {
    background-image: url("../assets/img/esferas/esfera_celeste_mobile.webp");
  }
  .esfera-grafica[data-esfera="salmon-grande"],
  .esfera-grafica[data-esfera="salmon-pequena"] {
    background-image: url("../assets/img/esferas/esfera_salmon_mobile.webp");
  }
  .escena-fondo__nebulosa {
    opacity: 0.92;
  }
}
@keyframes nebulosa-flotante {
  from {
    transform: translate3d(-1%, 0, 0) scale(1);
  }
  to {
    transform: translate3d(1%, -1.5%, 0) scale(1.045);
  }
}
@media (prefers-reduced-motion: reduce) {
  .escena-fondo__nebulosa::before {
    animation: none;
  }
}
