/* Mirall · viewport 3D — paleta SkyV2X.
 * Acento ámbar reservado para divergence (ghosts).
 * Verde sage para estados OK (eco live). Azul ice para info pura. */

:root {
  --bg:        #0a0a0a;
  --bg-panel:  rgba(18, 20, 24, 0.85);
  --bg-hover:  #232a36;
  --border:    #232a36;
  --text:      #d6dde6;
  --muted:     #8a94a4;
  --amber:     #f59e0b;  /* ghosts / high divergence */
  --sage:      #34d399;  /* eco live / nitidesa */
  --ice:       #4fc3f7;  /* info / truth */
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  overflow: hidden;
  color: var(--text);
  font: 14px system-ui, -apple-system, "Segoe UI", sans-serif;
}

#map { position: absolute; inset: 0; }

/* <gmp-map-3d> nativo de Maps JavaScript API — debe llenar el contenedor.
 * Display block evita el inline-block default y resuelve el flicker de
 * tamaño inicial. */
gmp-map-3d {
  display: block;
  width: 100%;
  height: 100%;
}

header {
  position: fixed;
  top: 12px;
  left: 16px;
  z-index: 10;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  gap: 10px;
}

header .brand-mark {
  width: 56px;
  height: 56px;
  color: var(--text);
}

header h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

header small {
  color: var(--muted);
  display: block;
  font-size: 11px;
  letter-spacing: 0.02em;
}

/* HUD inferior central — presets de cámara y slider de hora. */
.panel {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  padding: 8px 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  backdrop-filter: blur(8px);
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.panel button {
  background: #1a1f2a;
  color: var(--text);
  border: 1px solid #2a3140;
  padding: 6px 12px;
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
  transition: background 0.12s ease;
}

.panel button:hover  { background: var(--bg-hover); }
.panel button:active { background: #2b3340; }


/* HUD lateral derecho — métricas operativas del twin.
 * Mientras no haya backend conectado las métricas muestran `—`. */
.metrics {
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 10;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font: 11px/1.6 ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--muted);
  min-width: 200px;
  backdrop-filter: blur(8px);
}

.metrics h2 {
  margin: 0 0 6px 0;
  font: 600 11px/1 system-ui, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}

.metrics .row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.metrics .row span:last-child {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* Status dot del WS (eco): rojo desconectado, ámbar reconectando, sage live. */
.metrics .link-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c0392b;
  margin-right: 6px;
  vertical-align: middle;
  transition: background 0.2s ease;
}
.metrics[data-link="connecting"] .link-dot { background: var(--amber); }
.metrics[data-link="live"]       .link-dot { background: var(--sage); }

/* Atribución Google — requerido por ToS de Map Tiles API. */
.credits {
  position: fixed;
  bottom: 8px;
  right: 10px;
  z-index: 5;
  color: rgba(255, 255, 255, 0.6);
  font-size: 10px;
  background: rgba(0, 0, 0, 0.45);
  padding: 2px 6px;
  border-radius: 3px;
}

/* Legend — V2X links and actors (bottom-left). */
.legend {
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 10;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font: 11px/1.5 system-ui, sans-serif;
  color: var(--text);
  backdrop-filter: blur(8px);
}
.legend h2 {
  margin: 0 0 6px 0;
  font: 600 11px/1 system-ui, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.legend .leg-grp {
  margin: 7px 0 3px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.legend .leg-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.legend .sw {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  background: var(--c);
  flex: none;
}
/* Variante "línea" para los enlaces (barra fina, como el polyline). */
.legend .sw.line {
  height: 3px;
  border-radius: 2px;
}

/* --- Móvil: la info se compacta o se pliega; el viewport manda. ----------- */
@media (max-width: 640px) {
  header { top: 8px; left: 10px; gap: 8px; }
  header .brand-mark { width: 42px; height: 42px; }
  header h1 { font-size: 20px; }

  .metrics {
    top: 8px;
    right: 8px;
    min-width: 0;
    padding: 6px 8px;
    font-size: 10px;
    line-height: 1.5;
  }
  .metrics h2 { font-size: 10px; }
  .metrics .row { gap: 8px; }

  .panel {
    bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    max-width: calc(100vw - 16px);
    padding: 6px 8px;
    gap: 6px;
    justify-content: center;
  }
  .panel button { padding: 4px 8px; font-size: 12px; }

  .legend {
    /* despegada del borde: abajo-izquierda vive la atribución de Google (ToS) */
    bottom: calc(34px + env(safe-area-inset-bottom, 0px));
    left: 8px;
    padding: 8px 10px;
  }
  .legend h2 { cursor: pointer; user-select: none; }
  /* Plegada: solo el chip del título; el twin queda a la vista. */
  .legend.collapsed { padding: 6px 10px; }
  .legend.collapsed h2 { margin: 0; }
  .legend.collapsed .leg-grp,
  .legend.collapsed .leg-row { display: none; }
}
