/* ------------------------------------------------------------------
   Music Display — estilos
   Todo lo que late a pantalla completa se hace aqui con variables CSS
   que escribe js/core/beatfx.js una vez por frame.
   ------------------------------------------------------------------ */

:root {
  --fx-scale: 1;
  --fx-x: 0px;
  --fx-y: 0px;
  --fx-rot: 0deg;
  --fx-filter: none;
  --ui-bg: rgba(10, 8, 20, .82);
  --ui-line: rgba(255, 255, 255, .14);
  --ui-fg: #eaf0ff;
  --ui-accent: #7cf3ff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%; width: 100%;
  background: #000; color: var(--ui-fg);
  overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
}
body.hide-cursor, body.hide-cursor * { cursor: none !important; }

/* ---------- escenario 3D ---------- */
#stage {
  position: fixed; inset: 0;
  transform: translate3d(var(--fx-x), var(--fx-y), 0) scale(var(--fx-scale)) rotate(var(--fx-rot));
  transform-origin: 50% 50%;
  filter: var(--fx-filter);
  will-change: transform, filter;
  backface-visibility: hidden;
}
#gl { display: block; width: 100%; height: 100%; }

#flash {
  position: absolute; inset: -12%;
  background: #fff; opacity: 0; pointer-events: none;
  mix-blend-mode: screen;
}

#vignette {
  position: fixed; inset: 0; pointer-events: none; opacity: .35;
  background: radial-gradient(ellipse at center, transparent 42%, rgba(0, 0, 0, .78) 100%);
}

#shocks { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.shockwave {
  position: absolute; left: 50%; top: 50%;
  width: 3vmin; height: 3vmin; border-radius: 50%;
  border: 14px solid rgba(255, 255, 255, .85);
  mix-blend-mode: screen;
  will-change: transform, opacity;
}

/* ---------- frases y logos ---------- */
#phrases {
  position: fixed; inset: 0; pointer-events: none; overflow: hidden;
  --beat-scale: 1; --beat-glow: .5;
}
.phrase-wrap {
  position: absolute; left: 0; top: 0;
  will-change: transform, opacity;
}
.phrase-inner {
  display: block;
  transform: scale(var(--beat-scale));
  transform-origin: 50% 50%;
  white-space: nowrap;
  line-height: .95;
  letter-spacing: .01em;
}
.phrase-logo { height: auto; }
/* zoom vectorial: nada de will-change ni capas, queremos que el SVG se
   vuelva a rasterizar en cada tamano y salga nitido */
.phrase-wrap.wild { will-change: auto; }
.phrase-wrap.wild .phrase-inner { transform: none; mix-blend-mode: screen; }
.phrase-hero {
  position: absolute; left: 50%; top: 50%;
  width: min(46vw, 62vh);
  transform: translate(-50%, -50%) scale(var(--hero-scale, 1));
  filter: drop-shadow(0 0 2vw rgba(255, 255, 255, .35));
  mix-blend-mode: screen;
  will-change: transform, opacity;
}

/* ---------- panel de depuración ----------
   Vive encima del icono de ajustes. Todo lo que se mueve por frame se anima
   con transform/opacity: nada de width ni height, que provocan reflow. */
.dbg {
  position: fixed; left: 16px; bottom: 96px; z-index: 60;
  width: 252px; padding: 9px 11px 10px;
  font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: rgba(255, 255, 255, .85);
  /* Nada de backdrop-filter aquí: desenfocar lo que hay detrás obliga al
     compositor a releer el canvas entero cada frame y en este panel medimos
     unos 7 fps de coste. Un panel que miente sobre los fps que mide no sirve
     de nada, así que fondo opaco y punto. */
  background: rgba(7, 6, 14, .92);
  border: 1px solid rgba(255, 255, 255, .13); border-radius: 11px;
  pointer-events: none; letter-spacing: .01em;
  transition: opacity .2s ease, transform .2s ease;
}
.dbg.away { opacity: 0; transform: translateY(12px); }
.dbg-dim { color: rgba(255, 255, 255, .42); }
.dbg-line { display: flex; align-items: baseline; gap: 6px; margin-bottom: 7px; }
.dbg-fps { font-size: 15px; font-weight: 700; color: #7cf3ff; }
.dbg-fps[data-zone=mid] { color: #ffcf7a; }
.dbg-fps[data-zone=low] { color: #ff6b6b; }
.dbg-line > span:nth-child(3) { margin-left: auto; }

.dbg-row { display: flex; align-items: flex-end; gap: 8px; margin-top: 6px; }
.dbg-cap { color: rgba(255, 255, 255, .42); width: 18px; flex: 0 0 18px; }

/* nivel de entrada */
.dbg-meter {
  position: relative; flex: 1; height: 12px; border-radius: 3px;
  background: rgba(255, 255, 255, .07); overflow: hidden;
}
.dbg-zones {
  position: absolute; inset: 0;
  background: linear-gradient(90deg,
    rgba(255,80,80,.30) 0%, rgba(255,80,80,.30) 42%,
    rgba(60,255,140,.22) 42%, rgba(60,255,140,.22) 88%,
    rgba(255,150,60,.34) 88%, rgba(255,150,60,.34) 100%);
}
.dbg-fill {
  position: absolute; inset: 0; transform-origin: left center;
  background: #3affa0; transform: scaleX(0);
}
.dbg-fill[data-zone=low] { background: #ff6b6b; }
.dbg-fill[data-zone=hot] { background: #ffa63c; }
.dbg-peak {
  position: absolute; top: 0; bottom: 0; left: 0; width: 100%;
  border-right: 2px solid rgba(255, 255, 255, .9);
  transform: translateX(-100%);
}

/* cinco barras de espectro */
.dbg-bars { display: flex; gap: 6px; flex: 1; }
.dbg-bar {
  position: relative; width: 100%; height: 44px;
  background: rgba(255, 255, 255, .06); border-radius: 2px;
}
.dbg-bfill {
  position: absolute; inset: 0; transform-origin: bottom center;
  background: linear-gradient(0deg, #2b6cff, #7cf3ff 55%, #fff);
  transform: scaleY(0); border-radius: 2px;
}
.dbg-bpeak {
  position: absolute; left: 0; right: 0; top: 0; height: 100%;
  border-bottom: 2px solid rgba(255, 255, 255, .75);
  transform: translateY(0);
}
.dbg-bar u {
  position: absolute; left: 0; right: 0; top: 100%;
  text-align: center; font-size: 8.5px; text-decoration: none;
  color: rgba(255, 255, 255, .35);
}

/* testigo de beat */
.dbg-beatbox { flex: 0 0 62px; text-align: center; }
.dbg-beat {
  border: 1px solid rgba(255, 255, 255, .25); border-radius: 5px;
  padding: 5px 0; font-weight: 700; letter-spacing: .12em; font-size: 10px;
  color: #fff; background: rgba(255, 255, 255, .05);
}
.dbg-beat.on {
  background: #ff2e88; border-color: #ff2e88;
  box-shadow: 0 0 14px rgba(255, 46, 136, .85);
}
.dbg-bc { display: block; margin-top: 3px; color: rgba(255, 255, 255, .35); font-size: 9.5px; }

.dbg-foot {
  margin-top: 12px; padding-top: 6px; border-top: 1px solid rgba(255, 255, 255, .1);
  color: rgba(255, 255, 255, .5); font-size: 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- menu ---------- */
/* La capa de interfaz es transparente al ratón y cada hijo decide si lo
   captura. Antes había aquí un `#ui > * { pointer-events: auto }` que parecía
   inofensivo y no lo era: gana en especificidad a cualquier regla de clase, así
   que el panel cerrado (421x592, invisible pero presente) se comía el ratón por
   encima del icono de ajustes, y el panel de depuración se lo comía por encima
   del menú abierto, mandándole un mouseleave que lo cerraba solo. Pointer-events
   se declara donde vive cada cosa: .menu-hot, .menu-panel(.open) y .dbg. */
#ui { position: fixed; inset: 0; pointer-events: none; z-index: 50; }

.menu-hot {
  position: fixed; left: 0; bottom: 0; z-index: 70;
  pointer-events: auto;
  width: 130px; height: 130px;
  display: flex; align-items: flex-end; justify-content: flex-start;
  padding: 14px;
}
.menu-hot.hidden { pointer-events: none; opacity: 0; }
.menu-hot-dot {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font-size: 19px;
  background: rgba(0, 0, 0, .45); color: rgba(255, 255, 255, .55);
  border: 1px solid rgba(255, 255, 255, .16);
  opacity: .25; transition: opacity .25s, transform .25s;
  cursor: pointer;
}
.menu-hot:hover .menu-hot-dot { opacity: 1; transform: scale(1.1); }

/* Por encima del panel de depuración (z-index 60): comparten esquina y el menú
   es lo que el usuario está mirando mientras está abierto. */
.menu-panel {
  position: fixed; left: 16px; bottom: 16px; z-index: 70;
  width: min(430px, calc(100vw - 32px));
  max-height: min(84vh, 860px);
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--ui-bg);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid var(--ui-line); border-radius: 16px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .65);
  padding: 14px 16px 16px;
  font-size: 13px;
  opacity: 0; transform: translateY(14px) scale(.98);
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
}
.menu-panel.open { opacity: 1; transform: none; pointer-events: auto; }

.menu-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.menu-head strong { font-size: 15px; letter-spacing: .02em; }
.menu-head .status {
  flex: 1; font: 11px/1.3 ui-monospace, Menlo, monospace;
  color: rgba(255, 255, 255, .55); text-align: right;
}
.menu-foot {
  margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--ui-line);
  font-size: 11px; color: rgba(255, 255, 255, .45);
}

.menu-panel details {
  border-top: 1px solid var(--ui-line);
  padding: 8px 0 4px;
}
.menu-panel summary {
  cursor: pointer; font-weight: 600; letter-spacing: .02em;
  padding: 4px 0; list-style: none; color: var(--ui-accent);
}
.menu-panel summary::-webkit-details-marker { display: none; }
.menu-panel summary::before { content: '▸ '; opacity: .6; }
.menu-panel details[open] > summary::before { content: '▾ '; }

.row { display: flex; align-items: center; gap: 10px; margin: 7px 0; }
.row > .lbl { flex: 0 0 108px; color: rgba(255, 255, 255, .72); }
.row > input[type=range] { flex: 1; }
.row > select, .row > input[type=text], .row > input[type=file] { flex: 1; min-width: 0; }
.row > b { flex: 0 0 52px; text-align: right; font: 11px ui-monospace, Menlo, monospace; color: var(--ui-accent); }
.row > textarea { flex: 1; }
.hint { color: rgba(255, 255, 255, .4); font-size: 11px; font-style: normal; }

.chks, .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; margin: 6px 0; }
.displist { margin: 8px 0; }
.disprow { display: flex; align-items: center; gap: 10px; margin: 3px 0; }
.disprow .chk { flex: 0 0 150px; }
.disprow .wslider { flex: 1; min-width: 60px; }
.disprow .wslider:disabled { opacity: .3; }
.disprow b { flex: 0 0 34px; text-align: right; font: 11px ui-monospace, Menlo, monospace; color: var(--ui-accent); }
.hint.warn { color: #ffcf7a; }
.chk { display: flex; align-items: center; gap: 7px; cursor: pointer; color: rgba(255, 255, 255, .82); }
.btns { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 2px; }

button, select, input[type=text], textarea, input[type=file] {
  font: inherit; color: var(--ui-fg);
  background: rgba(255, 255, 255, .07);
  border: 1px solid var(--ui-line); border-radius: 9px;
  padding: 7px 10px;
}
textarea { width: 100%; resize: vertical; font-size: 13px; line-height: 1.35; }
button { cursor: pointer; background: rgba(255, 255, 255, .12); }
button:hover { background: rgba(255, 255, 255, .2); }
button.ghost { background: transparent; }
button.danger { border-color: rgba(255, 90, 90, .5); color: #ffb3b3; }
input[type=range] { accent-color: var(--ui-accent); }
input[type=checkbox] { accent-color: var(--ui-accent); width: 16px; height: 16px; }

.logos { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.logo-thumb {
  position: relative; width: 62px; height: 62px; border-radius: 10px;
  background: repeating-conic-gradient(#2a2a34 0 25%, #1b1b22 0 50%) 0 0 / 14px 14px;
  border: 1px solid var(--ui-line); display: grid; place-items: center; overflow: hidden;
}
.logo-thumb img { max-width: 100%; max-height: 100%; }
.logo-thumb .x {
  position: absolute; top: -1px; right: -1px; width: 20px; height: 20px;
  padding: 0; line-height: 1; border-radius: 0 9px 0 9px;
  background: rgba(0, 0, 0, .6); font-size: 14px;
}

/* ---------- pantalla de arranque ---------- */
#start {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 35%, #17103a 0%, #05030c 70%);
  transition: opacity .7s ease;
}
#start.gone { opacity: 0; pointer-events: none; }
/* mientras comprobamos si ya hay permiso de micro no enseñamos la tarjeta:
   en un kiosko con permiso concedido no debe verse ni un parpadeo */
#start.probing .start-card { opacity: 0; }
.start-card { text-align: center; padding: 30px; max-width: 640px; transition: opacity .3s ease; }
.lang-row { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 0 0 22px; }
.lang-row label { color: rgba(255, 255, 255, .5); font-size: 13px; }
.lang-row select { min-width: 160px; }

/* Clave de la fiesta. Dígitos grandes y espaciados: se teclea de pie, delante
   de una pantalla y a veces con el móvil en la otra mano. */
.key-row { display: flex; align-items: center; justify-content: center; gap: 10px; margin: -8px 0 22px; }
.key-row label { color: rgba(255, 255, 255, .5); font-size: 13px; }
.key-row input {
  width: 9ch; padding: 8px 10px; border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .18); background: rgba(255, 255, 255, .06);
  color: #fff; font: 600 20px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .18em; text-align: center;
}
.key-row input:focus { outline: 2px solid rgba(255, 255, 255, .35); outline-offset: 1px; }
.key-row[hidden] { display: none; }
.start-card h1 {
  font-family: 'Anton', system-ui, sans-serif;
  font-size: clamp(42px, 9vw, 96px); margin: 0 0 6px;
  letter-spacing: .01em;
  background: linear-gradient(100deg, #00f0ff, #ff00c8 45%, #ffe600);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.claim { color: rgba(255, 255, 255, .66); margin: 0 0 26px; font-size: clamp(14px, 2vw, 18px); }
#start-btn {
  font-size: 17px; padding: 15px 26px; border-radius: 999px;
  background: linear-gradient(100deg, #00d5e8, #b14bff);
  border: 0; color: #04030a; font-weight: 700; letter-spacing: .01em;
  box-shadow: 0 12px 40px rgba(120, 60, 255, .45);
}
#start-btn:disabled { opacity: .6; }
.msg { color: #ffc9c9; font-size: 13px; min-height: 1.2em; margin: 16px auto 0; max-width: 44em; line-height: 1.5; }
.tips { list-style: none; padding: 0; margin: 30px 0 0; color: rgba(255, 255, 255, .38); font-size: 12.5px; line-height: 1.9; }

@media (prefers-reduced-motion: reduce) {
  #stage { transition: none; }
}
