/* Talkie — tema oscuro, móvil primero.
   La regla de oro del layout: la app ocupa exactamente la altura visible y no
   hace scroll nunca. 50% mapa arriba, 50% panel abajo. */

:root {
  --bg: #0b0f14;
  --panel: #10161e;
  --line: #1e2936;
  --text: #e6edf3;
  --muted: #8b9bb0;
  --accent: #35d0a5;
  --accent-dim: #1c6b57;
  --danger: #ff5c5c;
  --live: #ffb020;
}

* {
  box-sizing: border-box;
}

/* Los `display` de #join y #app son selectores de id: le ganan por
   especificidad al `[hidden] { display: none }` del navegador, y la pantalla
   oculta seguiría ocupando su alto. Sin esto, la app arranca empujada un
   viewport hacia abajo. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.screen {
  height: 100dvh;
  width: 100vw;
}

/* --- Pantalla de entrada --------------------------------------------------- */

#join {
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(120% 90% at 50% 0%, #16202c 0%, var(--bg) 60%);
}

.join-card {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.join-card h1 {
  margin: 0;
  font-size: 34px;
  letter-spacing: -0.02em;
}

.logo {
  filter: saturate(1.2);
}

.tagline {
  margin: 0 0 12px;
  color: var(--muted);
}

label {
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

input[type="text"] {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font-size: 17px; /* < 16px hace que iOS haga zoom al enfocar */
  padding: 14px 16px;
  width: 100%;
}

input[type="text"]:focus {
  outline: 2px solid var(--accent-dim);
  border-color: var(--accent);
}

.room-line {
  margin: 4px 0 8px;
  color: var(--muted);
  font-size: 14px;
}

.room-line strong {
  color: var(--accent);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

button.primary {
  background: var(--accent);
  color: #04120d;
  border: 0;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 700;
  padding: 16px;
  cursor: pointer;
}

button.primary:disabled {
  opacity: 0.55;
  cursor: progress;
}

.perm-note {
  color: var(--muted);
  font-size: 13px;
  margin: 8px 0 0;
}

.error {
  color: var(--danger);
  font-size: 14px;
  margin: 4px 0 0;
}

/* --- App ------------------------------------------------------------------- */

#app {
  display: flex;
  flex-direction: column;
}

#map {
  flex: 0 0 50%;
  height: 50%;
  background: #0d1117;
  z-index: 0;
}

#panel {
  flex: 0 0 50%;
  height: 50%;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-top: 1px solid var(--line);
  position: relative;
  padding-bottom: env(safe-area-inset-bottom);
}

#status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
}

.dot.ok {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.dot.bad {
  background: var(--danger);
}

#status-text {
  flex: 1 1 auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#status-text.live {
  color: var(--live);
  font-weight: 600;
}

button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  padding: 4px 10px;
  cursor: pointer;
}

#meter {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  display: block;
  background: #070b10;
}

#ptt-wrap {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 12px 16px;
}

.ptt {
  width: min(30vh, 42vw, 168px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 3px solid var(--accent-dim);
  background: radial-gradient(circle at 50% 35%, #1b2a36, #101922);
  color: var(--text);
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.06em;
  cursor: pointer;
  /* Sin esto, mantener pulsado en móvil dispara el scroll o el menú de
     selección y el walkie se corta a media frase. */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 80ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.ptt.talking {
  border-color: var(--accent);
  box-shadow: 0 0 0 6px rgba(53, 208, 165, 0.16), 0 0 32px rgba(53, 208, 165, 0.5);
  transform: scale(0.96);
  background: radial-gradient(circle at 50% 35%, #1f4f43, #0f2b25);
}

.ptt:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  border-color: var(--line);
}

#hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

kbd {
  background: #0a1018;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 11px;
}

/* Lista de participantes: se despliega sobre el panel, no empuja el layout. */
#people {
  position: absolute;
  inset: 33px 0 0 0;
  margin: 0;
  padding: 8px 12px;
  list-style: none;
  background: rgba(9, 13, 19, 0.96);
  backdrop-filter: blur(6px);
  overflow-y: auto;
  z-index: 5;
}

#people li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  border-bottom: 1px solid var(--line);
}

#people .swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}

#people .who {
  flex: 1 1 auto;
}

#people .meta {
  color: var(--muted);
  font-size: 12px;
}

/* --- Mapa ------------------------------------------------------------------ */

/* Los tiles de OpenStreetMap son claros y aquí todo es oscuro. El filtro va
   SOLO en el panel de tiles: los marcadores y las etiquetas viven en el panel
   de overlays y conservan su color. */
.leaflet-tile-pane {
  filter: invert(1) hue-rotate(180deg) brightness(0.92) contrast(0.9) saturate(0.7);
}

.leaflet-container {
  background: #0d1117;
  font: inherit;
}

.leaflet-control-attribution {
  background: rgba(11, 15, 20, 0.7) !important;
  color: var(--muted) !important;
  font-size: 10px !important;
}

.leaflet-control-attribution a {
  color: var(--muted) !important;
}

.peer-tip {
  background: rgba(11, 15, 20, 0.85);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  box-shadow: none;
}

.peer-tip::before {
  display: none;
}

.peer-tip.speaking {
  border-color: var(--live);
  color: var(--live);
}

.recenter {
  background: rgba(16, 22, 30, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 7px 9px;
}
