@font-face { font-family: "Anaktoria"; src: url("fonts/anaktoria.woff2") format("woff2"); font-display: swap; }

/* Umbra Espectral - Sistema Visual de Videollamada & Terror Ambiental */
:root {
  color-scheme: dark;
  --bg-main: #0a0a0c;        /* Negro noche */
  --bg-tile: #12131a;        /* Fondo de cuadro de llamada */
  --purple-spectral: #8a2be2; /* Púrpura espectral */
  --fire-orange: #ff4500;     /* Naranja fuego tenue */
  --white: #eef0ff;
  --gray-1: #b6bae0;
  --gray-2: #7b80b3;
  --gray-3: #2d3154;
  --line-spectral: rgba(138, 43, 226, 0.35);
  --line-orange: rgba(255, 69, 0, 0.35);
  --line-soft: rgba(238, 240, 255, 0.15);
  
  --font-horror: "Space Mono", "Courier New", Consolas, monospace;
  --font-display: "Space Mono", "Anaktoria", Georgia, monospace;
  
  --aura-shadow: 0 0 15px rgba(138, 43, 226, 0.75);
  --aura-fire: 0 0 15px rgba(255, 69, 0, 0.75);
  
  --bar-h: 42px;
  --dock-w: 200px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  background-color: var(--bg-main);
  color: var(--white);
  font-family: var(--font-horror);
  line-height: 1.5;
  margin: 0;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--purple-spectral);
  color: #fff;
}

/* Grano analógico tenue */
.grain {
  position: fixed;
  inset: 0;
  z-index: 1000;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

/* ================= BARRAS (ESTILO VIDEOLLAMADA) ================= */
.bar {
  position: fixed;
  left: 0;
  right: 0;
  height: var(--bar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(10, 10, 12, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 900;
  padding: 0 16px;
  font-family: var(--font-horror);
  font-size: 11px;
  color: var(--gray-1);
}

.bar-top {
  top: 0;
  border-bottom: 1px solid var(--line-spectral);
  justify-content: space-between;
}

.bar-bottom {
  bottom: 0;
  border-top: 1px solid var(--line-spectral);
}

.call-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.rec-dot-live {
  color: #ff3333;
  animation: pulseRec 1.6s ease-in-out infinite;
  font-size: 12px;
}

@keyframes pulseRec {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.9); }
}

.rec-pill {
  background: rgba(255, 51, 51, 0.18);
  color: #ff6666;
  border: 1px solid rgba(255, 51, 51, 0.4);
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 2px;
  letter-spacing: 0.05em;
  font-weight: 700;
}

.call-timer {
  color: var(--white);
  font-size: 11px;
}

.call-title {
  color: var(--purple-spectral);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-shadow: 0 0 8px rgba(138, 43, 226, 0.6);
}

.call-sub {
  color: var(--gray-2);
  font-size: 10px;
}

.bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sep {
  width: 1px;
  height: 14px;
  background: var(--line-soft);
}

.grow { flex: 1; }
.group-inline { display: flex; align-items: center; gap: 6px; }

/* Botones */
button, .btn {
  background: rgba(18, 19, 26, 0.8);
  color: var(--white);
  border: 1px solid var(--line-spectral);
  padding: 6px 12px;
  font-family: var(--font-horror);
  font-size: 11px;
  cursor: pointer;
  border-radius: 3px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

button:hover {
  background: rgba(138, 43, 226, 0.2);
  border-color: var(--purple-spectral);
  box-shadow: 0 0 10px rgba(138, 43, 226, 0.5);
}

button[aria-pressed="true"] {
  background: var(--purple-spectral);
  color: #fff;
  border-color: var(--purple-spectral);
  box-shadow: 0 0 12px rgba(138, 43, 226, 0.8);
}

button.btn-spectral {
  border-color: var(--purple-spectral);
  color: #e2c0ff;
  text-shadow: 0 0 6px rgba(138, 43, 226, 0.8);
}

button.btn-spectral:hover {
  background: var(--purple-spectral);
  color: #fff;
}

button.btn-call-reset {
  border-color: rgba(255, 69, 0, 0.4);
  color: #ffa380;
}

button.btn-call-reset:hover {
  background: rgba(255, 69, 0, 0.2);
  border-color: var(--fire-orange);
  box-shadow: 0 0 10px rgba(255, 69, 0, 0.6);
}

button.rec[aria-pressed="true"] {
  background: #ff3333;
  border-color: #ff3333;
  color: #fff;
  box-shadow: 0 0 12px rgba(255, 51, 51, 0.8);
}

/* ================= ESCENARIO Y GRILLA DE LLAMADA ================= */
.stage {
  position: fixed;
  top: var(--bar-h);
  bottom: var(--bar-h);
  left: 0;
  right: 0;
  background: var(--bg-main);
  overflow: hidden;
  z-index: 1;
}

.call-grid {
  display: grid;
  width: 100%;
  height: 100%;
  padding: 10px;
  gap: 10px;
  background: var(--bg-main);
  box-sizing: border-box;
}

/* Distribución según cantidad de participantes/clones */
.call-grid[data-count="1"] {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}

.call-grid[data-count="2"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr;
}

.call-grid[data-count="3"],
.call-grid[data-count="4"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

.call-grid[data-count="5"],
.call-grid[data-count="6"] {
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr;
}

@keyframes criaturaGlitch {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-6px, 4px); filter: contrast(140%); }
  40% { transform: translate(6px, -4px); filter: hue-rotate(180deg); }
  60% { transform: translate(-4px, -3px); }
  80% { transform: translate(4px, 3px); }
  100% { transform: translate(0, 0); }
}

.call-grid.criatura-active {
  animation: criaturaGlitch 0.45s ease-in-out;
}

/* Cada cuadro de participante */
.call-tile {
  position: relative;
  background: var(--bg-tile);
  border: 1px solid var(--line-spectral);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.25s, box-shadow 0.25s;
}

.call-tile canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* Resplandor cuando el participante / clon "habla" (sonido activo) */
.call-tile.speaking {
  border: 2px solid var(--purple-spectral) !important;
  box-shadow: 0 0 20px rgba(138, 43, 226, 0.85), inset 0 0 15px rgba(138, 43, 226, 0.3) !important;
}

.call-tile.speaking-orange {
  border: 2px solid var(--fire-orange) !important;
  box-shadow: 0 0 20px rgba(255, 69, 0, 0.85), inset 0 0 15px rgba(255, 69, 0, 0.3) !important;
}

.call-tile.clone-criatura.speaking,
.call-tile.clone-criatura.speaking-red {
  border: 2px solid #ff2222 !important;
  box-shadow: 0 0 30px rgba(255, 34, 34, 0.95), inset 0 0 20px rgba(255, 34, 34, 0.4) !important;
}

/* Etiquetas y cabeceras dentro de los cuadros de llamada */
.tile-header {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 4;
  pointer-events: none;
}

.live-badge, .spectral-badge {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 2px;
  letter-spacing: 0.08em;
  background: rgba(10, 10, 12, 0.7);
  backdrop-filter: blur(4px);
  border: 1px solid var(--line-spectral);
  color: #cbb2ff;
}

.spectral-badge.orange {
  border-color: var(--line-orange);
  color: #ffaa80;
}

.spectral-badge.red {
  border-color: rgba(255, 51, 51, 0.6);
  color: #ff8888;
}

.tile-tag {
  position: absolute;
  bottom: 10px;
  left: 10px;
  z-index: 4;
  background: rgba(10, 10, 12, 0.8);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(138, 43, 226, 0.3);
  padding: 4px 9px;
  border-radius: 3px;
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--white);
  text-shadow: 0 0 6px rgba(138, 43, 226, 0.7);
  pointer-events: none;
}

.tile-tag .chevron {
  color: var(--gray-2);
  font-size: 9px;
}

/* Efectos visuales fantasmagóricos para los clones */
.clone-susurro canvas {
  filter: hue-rotate(240deg) contrast(1.15) brightness(0.92);
}

.clone-puerta canvas {
  filter: sepia(0.4) hue-rotate(320deg) contrast(1.25) brightness(0.88);
}

.clone-pulso canvas {
  filter: hue-rotate(280deg) saturate(1.4) contrast(1.2);
}

.clone-criatura canvas {
  filter: invert(0.9) contrast(1.5) hue-rotate(180deg) brightness(0.9);
}

/* Lectura de eventos en el feed principal */
.readout {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 4;
  pointer-events: none;
  font-size: 10px;
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.9), 0 0 12px rgba(138, 43, 226, 0.7);
  max-width: 75%;
}

.readout .note {
  font-size: 26px;
  font-weight: 700;
  color: var(--purple-spectral);
  text-shadow: 0 0 12px rgba(138, 43, 226, 0.9);
  line-height: 1.1;
}

.readout .lbl {
  color: var(--gray-2);
  text-transform: uppercase;
}

.readout .val {
  color: var(--white);
}

.readout .rule {
  margin-top: 4px;
  color: var(--fire-orange);
  text-shadow: 0 0 8px rgba(255, 69, 0, 0.6);
}

/* Toasts / Avisos flotantes */
.toast {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 10, 12, 0.92);
  border: 1px solid var(--purple-spectral);
  color: #e2c0ff;
  padding: 8px 16px;
  border-radius: 4px;
  box-shadow: 0 0 15px rgba(138, 43, 226, 0.7);
  font-size: 11px;
  z-index: 1001;
  pointer-events: none;
}

/* ================= DOCK LATERAL ================= */
.dock {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: var(--dock-w);
}

.trigger {
  width: 100%;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 11px;
  background: rgba(10, 10, 12, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line-spectral);
  color: var(--gray-1);
  text-align: left;
}

.trigger .num {
  color: var(--purple-spectral);
  margin-right: 6px;
}

.trigger .state {
  color: var(--gray-2);
  font-size: 9px;
}

.trigger:hover {
  border-color: var(--purple-spectral);
  box-shadow: 0 0 10px rgba(138, 43, 226, 0.4);
}

.trigger[aria-expanded="true"] {
  background: var(--purple-spectral);
  color: #fff;
  border-color: var(--purple-spectral);
}

.trigger[aria-expanded="true"] .num,
.trigger[aria-expanded="true"] .state {
  color: #fff;
}

.panel {
  position: absolute;
  top: 0;
  right: calc(100% + 8px);
  width: 320px;
  max-width: calc(100vw - var(--dock-w) - 30px);
  max-height: calc(100vh - var(--bar-h) * 2 - 24px);
  overflow-y: auto;
  background: rgba(10, 10, 12, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid var(--purple-spectral);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.8), 0 0 12px rgba(138, 43, 226, 0.3);
  padding: 14px;
  display: grid;
  gap: 10px;
}

.panel-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: -14px -14px 4px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line-spectral);
  font-size: 10px;
  text-transform: uppercase;
  color: var(--purple-spectral);
}

.panel-bar button {
  border: 0;
  border-left: 1px solid var(--line-spectral);
  color: var(--gray-2);
}

.row {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 8px;
}

.row label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--gray-2);
}

.row output {
  font-size: 10px;
  color: var(--white);
  text-align: right;
}

input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  background: var(--gray-3);
  cursor: pointer;
  border-radius: 2px;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: var(--purple-spectral);
  box-shadow: 0 0 6px rgba(138, 43, 226, 0.8);
  border-radius: 50%;
  border: 1px solid #fff;
}

.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 0;
}

.seg button + button { border-left: 0; }
.checks { display: grid; gap: 8px; }
.checks label {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 10px;
  text-transform: uppercase;
  color: var(--gray-1);
  cursor: pointer;
}
.checks input { accent-color: var(--purple-spectral); }

.hint {
  margin: 0;
  font-size: 10px;
  line-height: 1.6;
  color: var(--gray-2);
}

.btnrow {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ================= ADAPTACIÓN MÓVIL ================= */
@media (max-width: 768px) {
  .bar { padding: 0 8px; }
  .call-sub { display: none; }
  .call-grid { padding: 4px; gap: 6px; }
  .dock { width: auto; position: fixed; top: auto; bottom: calc(var(--bar-h) + 10px); right: 10px; }
  .panel {
    position: fixed;
    top: 50px;
    left: 10px;
    right: 10px;
    width: auto;
    max-width: none;
  }
}
