/* ==========================================================================
   Mapa de ómnibus de Montevideo — cartel de ruta
   Tema: transporte metropolitano. Azul profundo + acento naranja.
   Tipografía: Anton (rótulos/display), Archivo (UI/datos).
   ========================================================================== */

:root {
  /* Paleta */
  --navy-900: #08182e;
  --navy-800: #0a1b33;
  --navy-700: #123059;
  --navy-600: #1d4b7a;
  --navy-400: #3f6ea0;
  --ink: #17304e;
  --muted: #5c6f85;
  --paper: #f5f8fb;
  --line: rgba(18, 48, 89, 0.12);

  --accent: #ff6b2c;      /* naranja transporte */
  --accent-soft: #ff8a55;
  --amber: #ffc247;       /* amarillo secundario */
  --green: #2fbf71;

  /* Tipografía */
  --font-display: 'Anton', 'Arial Narrow', sans-serif;
  --font-ui: 'Archivo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Dimensiones panel */
  --panel-w: 340px;
  --panel-gap: 14px;
  --radius: 16px;
  --shadow: 0 10px 34px rgba(8, 24, 46, 0.28);

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font-ui);
  color: var(--ink);
}

body {
  position: relative;
  overflow: hidden;
  background: var(--navy-800);
}

/* --------------------------------------------------------------------------
   Mapa
   -------------------------------------------------------------------------- */
#map {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: #dbe7f2;
}

/* --------------------------------------------------------------------------
   Panel flotante
   -------------------------------------------------------------------------- */
.panel {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1000;
  width: var(--panel-w);
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: var(--panel-gap);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  scrollbar-width: thin;
}

/* --------------------------------------------------------------------------
   Encabezado / marca
   -------------------------------------------------------------------------- */
.app-header {
  position: relative;
  padding-bottom: 13px;
  border-bottom: 2px solid var(--ink);
}

.brand-num {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.34em;
  color: var(--accent);
  margin: 0 0 7px;
  text-transform: uppercase;
}

.app-header h1 {
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 0.95;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  color: var(--navy-800);
}

.app-header h1 em {
  font-style: normal;
  color: var(--navy-600);
}

.source {
  margin: 8px 0 0;
  font-size: 11.5px;
  color: var(--muted);
  letter-spacing: 0.01em;
}

.source span {
  color: var(--accent);
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   Selector de línea
   -------------------------------------------------------------------------- */
.field-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--muted);
  margin-bottom: 6px;
}

.field-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

#line-input {
  flex: 1;
  height: 46px;
  padding: 0 14px;
  font-family: var(--font-ui);
  font-size: 17px;
  font-weight: 600;
  color: var(--navy-800);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

#line-input::placeholder { color: #9fb0c2; font-weight: 400; }

#line-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 107, 44, 0.18);
}

.icon-btn {
  width: 46px;
  height: 46px;
  flex: none;
  border: 2px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.icon-btn:hover { color: var(--accent); border-color: var(--accent); }

.field-hint {
  margin: 7px 2px 0;
  font-size: 11.5px;
  color: var(--muted);
  min-height: 15px;
}

/* --------------------------------------------------------------------------
   Cartel de ruta (elemento firma)
   -------------------------------------------------------------------------- */
.route-sign {
  background: linear-gradient(135deg, var(--navy-800) 0%, var(--navy-700) 100%);
  border-radius: 12px;
  color: #fff;
  padding: 14px 16px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  overflow: hidden;
  position: relative;
}

/* textura tipo puntos de trama de malla de paradas */
.route-sign::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.05) 1px, transparent 1.4px);
  background-size: 11px 11px;
  pointer-events: none;
}

.route-sign.hidden { display: none; }
.route-sign.visible { display: block; animation: signIn 0.4s var(--ease); }

@keyframes signIn {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: none; }
}

.sign-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.sign-lead {
  font-size: 10.5px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--amber);
  font-weight: 600;
}

.sign-num {
  font-family: var(--font-display);
  font-size: 46px;
  line-height: 1;
  color: var(--accent);
  text-shadow: 0 0 22px rgba(255, 107, 44, 0.35);
}

.sign-dest {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  margin-top: 6px;
  color: #eaf2fb;
  text-transform: uppercase;
  min-height: 18px;
  position: relative;
  z-index: 1;
}

.sign-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0 0;
  position: relative;
  z-index: 1;
}

.sign-stats div {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  padding: 9px 8px;
  text-align: center;
}

.sign-stats dt {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #9db4ce;
  margin-bottom: 3px;
}

.sign-stats dd {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #fff;
  font-family: var(--font-ui);
}

.sign-band {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #d6e2f0;
}

.band-dot {
  width: 11px;
  height: 11px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

/* --------------------------------------------------------------------------
   Controles
   -------------------------------------------------------------------------- */
.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 42px;
  padding: 0 12px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  color: var(--navy-800);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.16s var(--ease);
}

.toggle:hover:not(:disabled) { border-color: var(--navy-600); }
.toggle:disabled { opacity: 0.4; cursor: not-allowed; }

.toggle-dot {
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 50%;
  background: #cdd7e2;
  transition: background 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.toggle[aria-pressed="true"] {
  background: var(--navy-800);
  color: #fff;
  border-color: var(--navy-800);
}

.toggle[aria-pressed="true"] .toggle-dot {
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.toggle--metric strong {
  color: var(--accent);
  text-transform: lowercase;
}

.footnote {
  margin: 2px 0 0;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--muted);
}

.footnote a { color: var(--navy-600); text-decoration: none; border-bottom: 1px solid var(--line); }
.footnote a:hover { color: var(--accent); }

/* --------------------------------------------------------------------------
   Estado de carga
   -------------------------------------------------------------------------- */
.loading {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--navy-800);
  color: #fff;
  transition: opacity 0.45s var(--ease);
}

.loading p {
  font-size: 14px;
  letter-spacing: 0.02em;
  color: #9db4ce;
}

.loading.done { opacity: 0; pointer-events: none; }

.loader { display: flex; gap: 8px; }
.loader span {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent);
  animation: bounce 1s var(--ease) infinite;
}
.loader span:nth-child(2) { background: var(--amber); animation-delay: 0.12s; }
.loader span:nth-child(3) { background: var(--navy-400); animation-delay: 0.24s; }

@keyframes bounce {
  0%, 100% { transform: translateY(0); opacity: 0.6; }
  50% { transform: translateY(-12px); opacity: 1; }
}

.noscript {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--navy-800);
  color: #fff;
  font-family: var(--font-ui);
  padding: 24px;
  text-align: center;
}

/* --------------------------------------------------------------------------
   Leaflet refinamientos
   -------------------------------------------------------------------------- */
.leaflet-control-container .leaflet-top { top: 12px; }
.leaflet-control-container .leaflet-left { left: 12px; }
.leaflet-control-layers,
.leaflet-bar {
  border: none !important;
  border-radius: 10px !important;
  box-shadow: var(--shadow) !important;
  font-family: var(--font-ui);
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
}

.leaflet-control-zoom a {
  width: 34px !important;
  height: 34px !important;
  line-height: 34px !important;
  color: var(--navy-800) !important;
  background: var(--paper) !important;
}

.leaflet-control-zoom a:hover { background: #fff !important; color: var(--accent) !important; }

.leaflet-control-layers-toggle {
  width: 34px !important;
  height: 34px !important;
}

.leaflet-popup-content-wrapper {
  border-radius: 12px;
  box-shadow: var(--shadow);
  font-family: var(--font-ui);
  color: var(--ink);
}

.leaflet-popup-content { margin: 14px 16px; line-height: 1.4; }

.stop-popup { min-width: 220px; }

.stop-popup .sp-cal {
  font-family: var(--font-display);
  font-size: 17px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--navy-800);
  line-height: 1.05;
}

.stop-popup .sp-esq {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin: 1px 0 8px;
}

.stop-popup .sp-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 8px 0;
}

.stop-popup .sp-meta .cell {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 12px;
}
.stop-popup .sp-meta .cell b { color: var(--accent); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stop-popup .sp-meta .cell small { display: block; color: var(--muted); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.1em; }

.stop-popup .sp-lines {
  font-size: 12px;
  margin: 6px 0;
}
.stop-popup .sp-lines b { color: var(--navy-800); }

.stop-popup .sp-lines-tags { margin: 2px 0 8px; }
.sp-tag {
  display: inline-block;
  background: var(--navy-700);
  color: #fff;
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 5px;
  margin: 2px 3px 2px 0;
}

/* metros viajes: los centros de mayor actividad en acento */
.sp-tag.hot { background: var(--accent); }

.stop-popup .sp-usu { border-top: 1px solid var(--line); padding-top: 7px; }
.stop-popup .sp-usu h4 {
  margin: 0 0 6px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}
.stop-popup .sp-usu-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 2px 0;
}
.stop-popup .sp-usu-row + .sp-usu-row { border-top: 1px solid var(--paper); }
.stop-popup .sp-usu-row span { color: var(--muted); font-size: 10.5px; text-transform: capitalize; }
.stop-popup .sp-usu-row em { font-style: normal; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--navy-800); }

/* --------------------------------------------------------------------------
   Responsive: mobile → panel como lámina inferior
   -------------------------------------------------------------------------- */
@media (max-width: 600px) {
  .panel {
    top: auto;
    left: 0;
    bottom: 0;
    max-width: 100vw;
    max-height: 62vh;
    width: 100%;
    border-radius: 18px 18px 0 0;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
    gap: 11px;
  }

  .app-header { padding-bottom: 10px; }
  .app-header h1 { font-size: 24px; }

  .sign-num { font-size: 40px; }

  .leaflet-control-container .leaflet-top,
  .leaflet-control-container .leaflet-left { top: 10px; left: 10px; }

  /* el control de capas queda debajo del panel en móvil */
  .leaflet-control-layers { max-height: 38vh; overflow-y: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}