/* AudioStellar · Beta 2.0 — primera pantalla (sin dependencias, texto centrado a la izquierda) */

:root {
  --bg: #161616;
  --ink: #f1efe9;
  --muted: rgba(241, 239, 233, 0.62);
  --side: #1c1c1e;
  --cut: 68%;
  --grain: 0.4;
  --accent: #ff1f6b;
  --font-a: "Archivo", Georgia, serif;
  --font-b: "Archivo", system-ui, sans-serif;
  --font-ui: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --size-a: 3.8vw;
  --size-b: 2.6vw;
  --left-w: 56vw;
  --right-x: 42%;
  --pad: clamp(20px, 5vw, 88px);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; }

.hero { position: fixed; inset: 0; height: 100svh; overflow: hidden; isolation: isolate; }
.stage { position: absolute; inset: 0; z-index: 0; }

/* el mapa CSS vive en la zona derecha */
.stage .cssmap { --cm-left: 70%; --cm-w: 60vw; --cm-glow: 2.4; --cm-haze: 0.55; }

/* degradado lateral: una sola rampa recta desde x=0, sin stops intermedios
   (cada stop agrega un quiebre de pendiente que se percibe como una línea) */
.side {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(90deg, var(--side) 0%, transparent var(--cut));
}

/* grano: dos capas de ruido que derivan muy despacio, con recorridos y tiempos distintos
   para que el movimiento no se perciba como un ciclo */
.grain {
  position: absolute; inset: -50%; z-index: 2; pointer-events: none;
  opacity: var(--grain);
  mix-blend-mode: overlay;
}
.grain::before,
.grain::after {
  content: "";
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .5  0 0 0 0 .5  0 0 0 0 .5  0 0 0 1.4 -.2'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  will-change: transform;
}
.grain::before { background-size: 220px 220px; opacity: 0.8; animation: grain-a 47s ease-in-out infinite alternate; }
.grain::after { background-size: 340px 340px; opacity: 0.6; animation: grain-b 71s ease-in-out infinite alternate; }
@keyframes grain-a {
  0%   { transform: translate3d(0, 0, 0); }
  21%  { transform: translate3d(-34px, 17px, 0); }
  47%  { transform: translate3d(22px, -29px, 0); }
  73%  { transform: translate3d(-12px, -44px, 0); }
  100% { transform: translate3d(38px, 9px, 0); }
}
@keyframes grain-b {
  0%   { transform: translate3d(10px, -14px, 0); }
  27%  { transform: translate3d(41px, 20px, 0); }
  58%  { transform: translate3d(-19px, 36px, 0); }
  100% { transform: translate3d(-40px, -22px, 0); }
}

/* texto, alineado a la izquierda y centrado en vertical */
.copy {
  position: absolute; z-index: 3; left: 0; top: 0; bottom: 0;
  width: var(--left-w);
  padding: var(--pad);
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
  gap: clamp(10px, 2.2vh, 28px);
  text-align: left;
  opacity: 0; transition: opacity 0.6s ease;
}
.fonts-ready .copy { opacity: 1; }

.copy > * { max-width: 100%; }
.brand { margin: 0; display: flex; flex-direction: column; align-items: flex-start; gap: clamp(10px, 2vh, 26px); }
.brand-block { display: flex; flex-direction: column; align-items: flex-start; }
.logo { display: block; width: clamp(230px, 34vw, 560px); height: auto; }

.t-a, .t-b { margin: 0; overflow-wrap: normal; hyphens: manual; text-wrap: balance; }
.t-a {
    font-family: var(--font-b);
    font-weight: 100;
    font-size: clamp(16px, 2.2vw, 24px);
    line-height: 1;
    letter-spacing: 0.01em;
    color: #7b7474;
    margin-top: 0.5em;
}
.t-b {
  font-family: var(--font-b); font-weight: 340;
  font-size: var(--size-b); line-height: 1.2; letter-spacing: 0.3;
  max-width: 18ch;
  color: color-mix(in oklab, var(--ink) 86%, transparent);
}

/* dedicatoria: misma tipografía que los enlaces de sistemas operativos */
.t-note {
  position: relative;
  margin: 32px 0 0;
  font-family: var(--font-ui);
  font-size: 11px;
  line-height: 1.4;
  letter-spacing: 0.02em;
  color: var(--muted);
  white-space: nowrap;
}

/* cursor de máquina de escribir */
.t-caret {
  display: none;
  width: 0.55em; height: 1.1em;
  margin-left: 1px;
  vertical-align: -0.2em;
  background: currentColor;
}
.is-armed .t-caret,
.is-typing .t-caret {
  display: inline-block;
  animation: caret-blink 1s steps(1) infinite;
}
@keyframes caret-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* cohete ASCII al final: entra, sale volando y desaparece */
.t-rocket {
  position: absolute; left: 100%; bottom: 0;
  margin-left: 0.4em;
  color: color-mix(in oklab, var(--ink) 74%, transparent);
  transform-origin: 50% 70%;
}
.t-rocket-flame { display: inline-block; opacity: 0.6; }
.is-armed .t-rocket,
.is-typing .t-rocket { opacity: 0; }
.is-done .t-rocket { animation: rocket-flight 2.6s linear both; }
.is-done .t-rocket-flame { animation: flame-flicker 0.5s steps(2, end) 0.7s infinite; }
.is-done .t-rocket::after {
  content: "*";
  position: absolute; right: 100%; bottom: -0.2em;
  font-size: 0.9em; line-height: 1;
  color: var(--muted);
  animation: rocket-puff 0.9s ease-out 1.05s both;
}
@keyframes rocket-flight {
  0%   { opacity: 0; transform: translateX(-9px); }
  16%  { opacity: 1; transform: translateX(2px); }
  38%  { opacity: 1; transform: translateX(2px); }
  52%  { opacity: 1; transform: translateX(9px); }
  72%  { opacity: 1; transform: translateX(27px); }
  100% { opacity: 0; transform: translateX(54px); }
}
@keyframes flame-flicker {
  0%, 100% { opacity: 0.35; transform: translateX(0); }
  50%      { opacity: 1; transform: translateX(-0.5px); }
}
@keyframes rocket-puff {
  0%   { opacity: 0; transform: translate(2px, 0) scale(0.6); }
  20%  { opacity: 0.8; }
  100% { opacity: 0; transform: translate(-9px, -1px) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .is-armed .t-caret { display: none; }
  .is-done .t-rocket,
  .is-done .t-rocket-flame,
  .is-done .t-rocket::after { animation: none; opacity: 0; }
  .is-done .t-rocket { opacity: 1; }
}

/* descarga: centrada en la mitad derecha */
.dl-zone {
  position: absolute; z-index: 4; top: 0; bottom: 0; left: var(--right-x); right: 0;
  display: grid; place-items: center; pointer-events: none;
}
.dl-zone > * { pointer-events: auto; }
.dl { position: relative; display: grid; justify-items: center; gap: 10px; font-family: var(--font-ui); }
.dl-btn {
  display: inline-grid; justify-items: center; gap: 4px;
  padding: 18px 30px;
  border: 1px solid color-mix(in oklab, var(--ink) 70%, transparent);
  border-radius: 2px;
  background: color-mix(in oklab, var(--bg) 35%, transparent);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  color: var(--ink); text-decoration: none;
  transition: background 0.3s, color 0.3s;
}
.dl-btn:hover { background: var(--ink); color: var(--bg); }
.dl-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.dl-text { font-size: 15px; letter-spacing: 0.06em; text-transform: uppercase; }
.dl-sub { font-size: 11px; opacity: 0.7; letter-spacing: 0.02em; }
.dl-alt {
  position: absolute; top: 100%; margin: 0; padding: 8px 24px 12px; list-style: none;
  display: grid; justify-items: center; gap: 4px; font-size: 11px; white-space: nowrap;
  opacity: 0; transform: translateY(-4px); transition: opacity 0.3s, transform 0.3s; pointer-events: none;
}
.dl:hover .dl-alt, .dl:focus-within .dl-alt { opacity: 1; transform: none; pointer-events: auto; }
.dl-alt a { color: var(--muted); text-decoration: none; }
.dl-alt a:hover { color: var(--ink); text-decoration: underline; }
.dl-alt small { opacity: 0.6; }

.nojs { position: absolute; z-index: 5; left: var(--pad); bottom: var(--pad); margin: 0; font-family: var(--font-ui); font-size: 13px; }

/* selector de idioma: Es / En, arriba a la derecha */
.lang-toggle {
  position: fixed; z-index: 6;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  display: flex; align-items: center;
  font-family: var(--font-ui); font-size: 11px; letter-spacing: 0.08em;
  color: var(--muted); user-select: none;
}
.lang-toggle button {
  appearance: none; border: 0; margin: 0; padding: 6px;
  min-width: 36px; min-height: 36px;
  background: none; color: inherit; font: inherit; letter-spacing: inherit;
  cursor: pointer; transition: color 0.2s;
}
.lang-toggle button:hover,
.lang-toggle button[aria-pressed="true"] { color: var(--ink); }
.lang-toggle button:focus-visible { outline: 1px solid var(--accent); outline-offset: 2px; }
.lang-toggle .lang-sep { opacity: 0.4; }

/* celular: el degradado va de arriba hacia abajo y el mapa ocupa la mitad de abajo */
@media (max-width: 720px), (orientation: portrait) and (max-width: 1024px) {
  :root {
    --left-w: 100vw;
    --size-a: clamp(2.3rem, 11.5vw, 4.8rem);
    --size-b: clamp(1.15rem, 6vw, 2.6rem);
  }
  .copy { align-items: center; text-align: center; }
  .brand, .brand-block { align-items: center; }
  .t-b { max-width: 22ch; }
  .side {
    background: linear-gradient(180deg, var(--side) 0%, transparent 58%);
  }
  .copy { bottom: auto; height: 50svh; justify-content: center; padding-top: max(var(--pad), 28px); padding-bottom: 8px; }
  .logo { width: clamp(220px, 70vw, 380px); }
  .dl-zone { left: 0; top: 50svh; }
}

/* movimiento reducido: todo quieto */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
.is-reduced .grain::before, .is-reduced .grain::after { animation: none; }
