/* ==========================================================
   Lo que no pude decir…  —  capa AURORA GLOBAL

   Se carga en TODAS las páginas públicas y en el Portal (después de sus hojas propias).
   Contiene: atmósfera (@property --a1/--a2/--a3/--a-int), el cielo animado, modos de intensidad
   por página, transiciones entre páginas, carga y estados.
   La paleta vive en tokens.css (--aurora-*); el feed y la bienvenida, en feed.css.
   La aurora es «algo que aparece en la oscuridad»: la historia se lee en la noche
   (escena oscura, introspectiva) y la respuesta llega con más luz (escena luminosa).

   ATMÓSFERA POR TEMA
     La escena activa escribe en <html> data-atmo="<paleta>" y data-modo="story|reply|pausa".
     Cada paleta solo define tres luces (--a1 verde/azul, --a2 cian/azul, --a3 acento violeta);
     las propiedades están registradas (@property) para que el cielo cambie de color despacio.
     Para ajustar un tema basta con su bloque [data-atmo="…"].

   Rendimiento: solo CSS (gradientes + transform/opacity). Sin vídeo, canvas ni librerías.
   Movimiento reducido: el cielo queda quieto y todo aparece sin desplazamientos.
   ========================================================== */

@property --a1 { syntax: "<color>"; inherits: true; initial-value: #36dca0; }
@property --a2 { syntax: "<color>"; inherits: true; initial-value: #24b4d6; }
@property --a3 { syntax: "<color>"; inherits: true; initial-value: #7356d6; }
@property --a-int { syntax: "<number>"; inherits: true; initial-value: 1; }

:root {
  --a1: var(--aurora-green);
  --a2: var(--aurora-cyan);
  --a3: var(--aurora-violet);
  --a-int: 1;
  --shift: 0;
  --sky-0: var(--aurora-night);
  --sky-1: var(--aurora-deep);
  --sky-2: var(--aurora-dusk);
  transition: --a1 1.6s ease, --a2 1.6s ease, --a3 1.6s ease, --a-int 1.2s ease;
}

/* Paletas por tema (temas existentes; nada inventado) */
:root[data-atmo="duelo"]    { --a1: #3557d6; --a2: #7a5ad8; --a3: #2aa6c7; }
:root[data-atmo="familia"]  { --a1: #2fd59a; --a2: #22b0c4; --a3: #5c78e0; }
:root[data-atmo="amor"]     { --a1: #3cc9e0; --a2: #a07ae6; --a3: #4fdcb0; }
:root[data-atmo="ruptura"]  { --a1: #2f8fd6; --a2: #6a52cf; --a3: #39cfa0; }
:root[data-atmo="culpa"]    { --a1: #6c4fd0; --a2: #2c64cf; --a3: #36b9b0; }
:root[data-atmo="miedo"]    { --a1: #2440b0; --a2: #563cb0; --a3: #3399c4; }
:root[data-atmo="soledad"]  { --a1: #1d4f9e; --a2: #2a87b2; --a3: #4a5cc0; }
:root[data-atmo="infancia"] { --a1: #4fe0a6; --a2: #6fd0e6; --a3: #9a86e6; }
:root[data-atmo="cuerpo"]   { --a1: #36cfc0; --a2: #6888e6; --a3: #ab8ae0; }
:root[data-atmo="sexualidad"] { --a1: #8a5ad6; --a2: #3fb8cf; --a3: #5e6fe0; }
:root[data-atmo="otro"]     { --a1: #3ad49e; --a2: #2aa2d0; --a3: #6a68dc; }

/* La historia se lee en penumbra; la respuesta, con la aurora encendida */
:root[data-modo="story"] { --a-int: 0.72; }
:root[data-modo="reply"] { --a-int: 1.3; }
:root[data-modo="pausa"] { --a-int: 1; }

/* ==========================================================
   EL CIELO
   ========================================================== */

.aurora {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(120% 70% at 50% 115%, color-mix(in srgb, var(--a2) 14%, transparent), transparent 62%),
    linear-gradient(180deg, var(--sky-0) 0%, var(--sky-1) 48%, var(--sky-2) 100%);
}

/* Estrellas: tres capas de puntos repetidos (un solo elemento, sin imágenes) */
.aurora-sky,
.aurora-sky::after {
  position: absolute;
  inset: -10% 0 30%;
  background-image:
    radial-gradient(1px 1px at 12% 18%, rgba(255, 255, 255, 0.85), transparent 60%),
    radial-gradient(1px 1px at 63% 9%, rgba(255, 255, 255, 0.7), transparent 60%),
    radial-gradient(1.4px 1.4px at 82% 31%, rgba(220, 245, 255, 0.85), transparent 60%),
    radial-gradient(1px 1px at 37% 42%, rgba(255, 255, 255, 0.55), transparent 60%),
    radial-gradient(1.2px 1.2px at 91% 64%, rgba(255, 255, 255, 0.6), transparent 60%),
    radial-gradient(1px 1px at 24% 71%, rgba(255, 255, 255, 0.45), transparent 60%);
  background-size: 230px 230px, 310px 310px, 420px 420px, 190px 190px, 370px 370px, 270px 270px;
  opacity: 0.8;
}
.aurora-sky::after {
  content: "";
  inset: 0;
  background-position: 60px 90px, 120px 40px, 30px 160px, 90px 20px, 200px 120px, 10px 60px;
  opacity: 0;
  animation: twinkle 7s ease-in-out infinite alternate;
}
@keyframes twinkle { to { opacity: 0.75; } }

/* Las cortinas de luz: gradientes con rayos verticales suaves (máscara), sin filtros pesados */
.aurora-band {
  position: absolute;
  left: -35%;
  width: 170%;
  height: 62%;
  top: -6%;
  background:
    linear-gradient(180deg,
      transparent 4%,
      color-mix(in srgb, var(--a1) 70%, transparent) 36%,
      color-mix(in srgb, var(--a2) 42%, transparent) 60%,
      transparent 96%);
  -webkit-mask-image:
    repeating-linear-gradient(90deg, #000 0 3px, rgba(0, 0, 0, 0.72) 3px 8px, rgba(0, 0, 0, 0.92) 8px 13px, rgba(0, 0, 0, 0.6) 13px 21px),
    radial-gradient(58% 52% at 50% 50%, #000 22%, transparent 74%);
  -webkit-mask-composite: source-in;
  mask-image:
    repeating-linear-gradient(90deg, #000 0 3px, rgba(0, 0, 0, 0.72) 3px 8px, rgba(0, 0, 0, 0.92) 8px 13px, rgba(0, 0, 0, 0.6) 13px 21px),
    radial-gradient(58% 52% at 50% 50%, #000 22%, transparent 74%);
  mask-composite: intersect;
  mix-blend-mode: screen;
  opacity: calc(0.5 * var(--a-int));
  transform-origin: 50% 0;
  transition: opacity 1.2s ease, translate 1.8s cubic-bezier(0.22, 0.61, 0.36, 1);
  translate: calc((var(--shift) - 1.5) * 3%) 0;
  will-change: transform;
}
.aurora-band.b1 { transform: rotate(-9deg) skewX(-14deg); animation: curtain1 24s ease-in-out calc(var(--aurora-t, 0) * -1s) infinite alternate; }
.aurora-band.b2 {
  top: 4%;
  height: 54%;
  background: linear-gradient(180deg, transparent 8%, color-mix(in srgb, var(--a2) 60%, transparent) 40%, color-mix(in srgb, var(--a3) 40%, transparent) 66%, transparent 96%);
  opacity: calc(0.42 * var(--a-int));
  transform: rotate(7deg) skewX(12deg);
  translate: calc((1.5 - var(--shift)) * 4%) 0;
  animation: curtain2 31s ease-in-out calc(var(--aurora-t, 0) * -1s) infinite alternate;
}
.aurora-band.b3 {
  top: 18%;
  height: 40%;
  left: -10%;
  width: 120%;
  background: linear-gradient(180deg, transparent 10%, color-mix(in srgb, var(--a3) 46%, transparent) 46%, color-mix(in srgb, var(--a1) 30%, transparent) 70%, transparent 95%);
  opacity: calc(0.3 * var(--a-int));
  transform: rotate(-3deg);
  animation: curtain3 38s ease-in-out calc(var(--aurora-t, 0) * -1s) infinite alternate;
}
@keyframes curtain1 {
  0%   { transform: rotate(-9deg) skewX(-14deg) scaleY(0.9); }
  50%  { transform: rotate(-5deg) skewX(-6deg) scaleY(1.08) translateX(3%); }
  100% { transform: rotate(-11deg) skewX(-18deg) scaleY(0.96) translateX(-2%); }
}
@keyframes curtain2 {
  0%   { transform: rotate(7deg) skewX(12deg) scaleY(1); }
  100% { transform: rotate(3deg) skewX(4deg) scaleY(1.12) translateX(-4%); }
}
@keyframes curtain3 {
  0%   { transform: rotate(-3deg) scaleY(0.85); }
  100% { transform: rotate(2deg) scaleY(1.1) translateX(5%); }
}

/* Partículas: muy pocas, lentas */
.aurora-motes i {
  position: absolute;
  bottom: -8px;
  width: 3px; height: 3px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--a1) 60%, #fff);
  box-shadow: 0 0 8px 1px color-mix(in srgb, var(--a1) 70%, transparent);
  opacity: 0;
  animation: mote 22s linear infinite;
}
.aurora-motes i:nth-child(1) { left: 8%;  animation-delay: 0s; }
.aurora-motes i:nth-child(2) { left: 21%; animation-delay: -6s; animation-duration: 27s; }
.aurora-motes i:nth-child(3) { left: 34%; animation-delay: -12s; width: 2px; height: 2px; }
.aurora-motes i:nth-child(4) { left: 49%; animation-delay: -3s; animation-duration: 30s; }
.aurora-motes i:nth-child(5) { left: 61%; animation-delay: -16s; width: 2px; height: 2px; }
.aurora-motes i:nth-child(6) { left: 73%; animation-delay: -9s; animation-duration: 25s; }
.aurora-motes i:nth-child(7) { left: 86%; animation-delay: -19s; }
.aurora-motes i:nth-child(8) { left: 95%; animation-delay: -4s; animation-duration: 33s; width: 2px; height: 2px; }
@keyframes mote {
  0%   { transform: translate3d(0, 0, 0); opacity: 0; }
  12%  { opacity: 0.7; }
  80%  { opacity: 0.4; }
  100% { transform: translate3d(14px, -92vh, 0); opacity: 0; }
}

/* Horizonte oscuro: garantiza contraste del texto en la parte baja */
.aurora-floor {
  position: absolute;
  inset: auto 0 0;
  height: 55%;
  background: linear-gradient(180deg, transparent, rgba(3, 6, 13, 0.55) 55%, rgba(3, 6, 13, 0.85));
}

/* ==========================================================
   EL CIELO EN TODO EL ECOSISTEMA
   Bienvenida: cinematográfica (feed.css) · Feed: inmersivo (feed.css)
   Páginas interiores: atmosféricas · Portal: sobrio y quieto.
   ========================================================== */

html { background-color: var(--aurora-night); }

/* Fuera del feed el cielo queda DETRÁS del contenido normal de la página */
body:not([data-shell="feed"]) { background: transparent; }
body:not([data-shell="feed"]) > .aurora { z-index: -1; }

/* Páginas interiores: la misma aurora, más lenta y con menos partículas */
body:not([data-shell="feed"]) { --a-int: 0.62; }
body:not([data-shell="feed"]) .aurora-band.b1 { animation-duration: 46s; }
body:not([data-shell="feed"]) .aurora-band.b2 { animation-duration: 58s; }
body:not([data-shell="feed"]) .aurora-band.b3 { animation-duration: 70s; }
body:not([data-shell="feed"]) .aurora-motes i:nth-child(n+5) { display: none; }

/* Atmósfera de cada lugar (solo matiz e intensidad; la paleta es siempre la misma) */
body[data-page="sobre"]    { --a-int: 0.7; }
body[data-page="escribir"] { --a1: #2a6fd6; --a2: #6a5ad8; --a3: #36c9a6; --a-int: 0.5; }   /* más íntima */
body[data-page="donar"]    { --a1: #3fd6a0; --a2: #2fb2c9; --a3: var(--aurora-warm); --a-int: 0.72; }  /* un poco más cálida */
body[data-page="terminos"] { --a-int: 0.4; }   /* lectura legal: la aurora casi se retira */
body[data-page="terminos"] .aurora-motes { display: none; }

/* Portal: profesional + atmosférico. Cielo tenue y quieto: nada que distraiga del trabajo */
body[data-shell="portal"] { --a-int: 0.34; }
body[data-shell="portal"] .aurora-band,
body[data-shell="portal"] .aurora-sky::after { animation: none; }
body[data-shell="portal"] .aurora-motes { display: none; }

/* ==========================================================
   TRANSICIÓN ENTRE PÁGINAS (navegadores con View Transitions)
   El cielo no se interrumpe: solo el contenido se funde y sube un poco (200–360 ms).
   ========================================================== */
.aurora { view-transition-name: aurora-cielo; }
::view-transition-group(aurora-cielo) { animation: none; }
::view-transition-old(aurora-cielo) { animation: none; opacity: 0; }
::view-transition-new(aurora-cielo) { animation: none; }
::view-transition-old(root) { animation: var(--aurora-page-out) ease both aurora-vt-out; }
::view-transition-new(root) { animation: var(--aurora-page-in) var(--aurora-ease) both aurora-vt-in; }
@keyframes aurora-vt-out { to { opacity: 0; } }
@keyframes aurora-vt-in { from { opacity: 0; transform: translateY(10px); } }

/* ==========================================================
   CARGA: una línea de aurora que pasa (sin spinners)
   ========================================================== */
.aurora-loader,
body[data-shell="portal"] .main:empty::before {
  content: "";
  display: block;
  height: 2px;
  width: min(320px, 70%);
  margin: 3rem auto;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--a1), var(--a2), var(--a3), transparent) 0 0 / 50% 100% no-repeat, var(--aurora-line);
  animation: aurora-sweep 1.4s ease-in-out infinite;
}
@keyframes aurora-sweep { from { background-position: -60% 0, 0 0; } to { background-position: 160% 0, 0 0; } }

/* ==========================================================
   MOVIMIENTO REDUCIDO (capa global): cielo quieto, sin partículas, solo fundidos breves
   ========================================================== */
@media (prefers-reduced-motion: reduce) {
  :root { transition: none; }
  .aurora-band, .aurora-sky::after, .aurora-motes i { animation: none !important; }
  .aurora-motes { display: none; }
  .aurora-band { transition: opacity 0.3s ease; translate: none; }
  .aurora-loader, body[data-shell="portal"] .main:empty::before { animation: none; background: var(--aurora-line); }
  ::view-transition-old(root) { animation: 120ms linear both aurora-vt-out; }
  ::view-transition-new(root) { animation: 150ms linear both aurora-vt-fade; }
  @keyframes aurora-vt-fade { from { opacity: 0; } }
}
