/* =====================================================================
   Estilo "Tótem de gasolinera" — ver diseno-visual.md
   ===================================================================== */

/* Letras alojadas en la propia web (no se cargan desde Google) */
@font-face { font-family: "Archivo"; src: url("../fonts/archivo-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Archivo"; src: url("../fonts/archivo-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Archivo Narrow"; src: url("../fonts/archivo-narrow-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Archivo Narrow"; src: url("../fonts/archivo-narrow-latin-700-normal.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Doto"; src: url("../fonts/doto-latin-900-normal.woff2") format("woff2"); font-weight: 900; font-style: normal; font-display: swap; }

:root {
  /* Alturas: 0 = fondo del mapa … 3 = elementos flotantes */
  --n0: #0A0B0D;
  --n1: #111317;
  --n2: #181B20;
  --n3: #20242A;
  --borde1: #1F2227;
  --borde2: #2B2F35;
  --borde3: #343940;
  --texto: #EDEBE6;
  --texto2: #B4B7BC;
  --texto3: #9A9EA5;
  --texto4: #8C9198;
  --pantalla: #040506;
  /* Escala de precios (accesible por defecto) */
  --barata: #5CC8FF;
  --media: #E6E1D6;
  --cara: #FF9F43;
  --estrecha: "Archivo Narrow", "Arial Narrow", system-ui, sans-serif;
}
:root[data-escala="semaforo"] {
  --barata: #3EE08F;
  --media: #F2CE4B;
  --cara: #FF6B5E;
}

html, body { margin: 0; height: 100%; background: var(--n0); color: var(--texto); font-family: "Archivo", system-ui, sans-serif; }
body { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }

/* ---------- Cabecera ---------- */
.barra {
  flex: none;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
  padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: var(--n1);
  border-bottom: 1px solid var(--borde1);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  position: relative; z-index: 2;
}
.marca { display: flex; align-items: baseline; gap: 10px; }
.nombre { font-family: var(--estrecha); font-weight: 700; font-size: 20px; letter-spacing: 0.14em; }
.etiqueta { font-family: var(--estrecha); font-weight: 600; font-size: 11px; letter-spacing: 0.16em; color: var(--texto4); }

.combustibles { display: flex; flex-wrap: wrap; gap: 6px; }
.combustibles button {
  height: 44px; min-width: 44px; padding: 0 12px;
  background: #1B1E23; color: var(--texto);
  border: 1px solid var(--borde2); border-radius: 4px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  font-family: var(--estrecha); font-weight: 700; font-size: 13px; letter-spacing: 0.08em;
  cursor: pointer;
}
.combustibles button[aria-pressed="true"] { background: var(--texto); color: var(--n0); border-color: var(--texto); box-shadow: none; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--barata); outline-offset: 2px; }

/* ---------- Mapa ---------- */
.zona-mapa { flex: 1; position: relative; min-height: 0; }
#mapa { position: absolute; inset: 0; background: var(--n0); }

.leyenda {
  position: absolute; left: 12px; bottom: max(12px, env(safe-area-inset-bottom)); z-index: 1;
  display: flex; align-items: center; gap: 10px;
  padding: 6px 9px;
  background: var(--n3); border: 1px solid var(--borde3); border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  font-family: var(--estrecha); font-weight: 600; font-size: 11px; letter-spacing: 0.1em;
  pointer-events: none;
}
.leyenda span { display: flex; align-items: center; gap: 5px; }
.leyenda span::before { content: ""; width: 8px; height: 8px; background: currentColor; }
.t0 { color: var(--barata); }
.t1 { color: var(--media); }
.t2 { color: var(--cara); }

/* La ficha queda por encima de la leyenda, la etiqueta y los botones del mapa */
.maplibregl-popup { z-index: 4; }

.aviso {
  position: absolute; left: 12px; right: 12px; top: 52px; z-index: 5;
  display: flex; align-items: flex-start; gap: 8px;
  padding: 12px 6px 12px 14px;
  background: var(--n3); border: 1px solid var(--borde3); border-radius: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  font-size: 14px; line-height: 1.4;
}
.aviso[hidden] { display: none; }
.aviso span { flex: 1; padding-top: 2px; }
.aviso button {
  flex: none; width: 36px; height: 36px; margin: -6px 0;
  background: transparent; border: 0; border-radius: 4px; color: var(--texto3);
  font-size: 22px; line-height: 1; cursor: pointer;
}

/* Etiqueta con la hora de los precios (sustituye a la barra inferior) */
.chip {
  position: absolute; left: 12px; top: 12px; z-index: 2;
  height: 30px; padding: 0 10px;
  background: var(--n3); color: var(--texto3);
  border: 1px solid var(--borde3); border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  font-family: var(--estrecha); font-weight: 600; font-size: 11px; letter-spacing: 0.12em;
  cursor: default;
}
.chip[hidden] { display: none; }
.chip.antiguo { color: var(--cara); }

/* Marca de "tu ubicación" */
/* Distinta de las gasolineras (que son puntos rellenos de color):
   un aro blanco hueco con centro, como una diana, y una onda suave. */
.yo {
  position: relative;
  width: 24px; height: 24px; box-sizing: border-box; border-radius: 50%;
  border: 3px solid var(--texto);
  background: rgba(10, 11, 13, 0.75);
  box-shadow: 0 0 0 1.5px var(--n0), 0 3px 10px rgba(0, 0, 0, 0.7);
}
.yo::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 8px; height: 8px; margin: -4px 0 0 -4px; border-radius: 50%;
  background: var(--texto);
}
.yo::before {
  content: ""; position: absolute; inset: -10px; border-radius: 50%;
  border: 2px solid rgba(237, 235, 230, 0.55);
  animation: onda 2.2s ease-out infinite;
}
@keyframes onda { from { transform: scale(0.55); opacity: 1; } to { transform: scale(1.5); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .yo::before { animation: none; opacity: 0.4; } }

/* ---------- Controles del mapa ---------- */
.maplibregl-ctrl-group { background: var(--n3); border: 1px solid var(--borde3); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5) !important; }
.maplibregl-ctrl-group button { width: 44px; height: 44px; }
.maplibregl-ctrl-group button + button { border-top: 1px solid var(--borde3); }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(0.92); }
.maplibregl-ctrl-attrib { background: rgba(17, 19, 23, 0.85) !important; color: var(--texto4); }
.maplibregl-ctrl-attrib a { color: var(--texto3); }
.maplibregl-ctrl-attrib-button { filter: invert(0.85); }
.boton-ubicacion { display: flex; align-items: center; justify-content: center; color: var(--texto); }
.boton-ubicacion svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.boton-ubicacion.buscando svg { animation: latido 1s ease-in-out infinite; color: var(--barata); }
@keyframes latido { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { .boton-ubicacion.buscando svg { animation: none; } }

/* ---------- Ficha (ventana al tocar una gasolinera) ---------- */
.maplibregl-popup-content {
  background: var(--n3); color: var(--texto);
  border: 1px solid var(--borde3); border-radius: 6px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  padding: 14px;
  font-family: "Archivo", system-ui, sans-serif;
}
.maplibregl-popup-anchor-bottom .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip { border-top-color: var(--borde3); }
.maplibregl-popup-anchor-top .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-left .maplibregl-popup-tip,
.maplibregl-popup-anchor-top-right .maplibregl-popup-tip { border-bottom-color: var(--borde3); }
.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--borde3); }
.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--borde3); }
.maplibregl-popup-close-button { width: 40px; height: 40px; font-size: 22px; color: var(--texto3); border-radius: 4px; }
.maplibregl-popup-close-button:hover { background: #2A2F36; color: var(--texto); }

.ficha h3 { margin: 0 32px 2px 0; font-family: var(--estrecha); font-weight: 700; font-size: 20px; letter-spacing: 0.06em; text-transform: uppercase; line-height: 1.15; }
.ficha .sub { margin: 0; font-size: 13px; color: var(--texto2); }
.ficha .pantalla { margin: 10px 0; background: var(--pantalla); border: 1px solid #000; border-radius: 3px; box-shadow: inset 0 3px 12px rgba(0, 0, 0, 0.9), 0 1px 0 rgba(255, 255, 255, 0.05); }
.ficha .fila { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 8px 12px; border-bottom: 1px solid #15171A; }
.ficha .fila:last-child { border-bottom: 0; }
.ficha .comb { font-family: var(--estrecha); font-weight: 700; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; }
.ficha .led { font-family: "Doto", ui-monospace, monospace; font-weight: 900; font-size: 28px; line-height: 1; color: var(--texto); }
.ficha .fila.elegido .led { font-size: 34px; }
.ficha .led.t0 { color: var(--barata); }
.ficha .led.t1 { color: var(--media); }
.ficha .led.t2 { color: var(--cara); }
.ficha .led.sin { font-family: var(--estrecha); font-weight: 600; font-size: 12px; letter-spacing: 0.1em; color: var(--texto4); }
.ficha .aviso-horas { margin: 0 0 10px 0; font-size: 12px; color: var(--cara); }
.ficha .rutas-titulo { margin: 4px 0 8px 0; font-family: var(--estrecha); font-weight: 600; font-size: 11px; letter-spacing: 0.14em; color: var(--texto3); }
.ficha .rutas { display: flex; gap: 6px; }
.ficha .ruta {
  flex: 1 1 auto;
  display: flex; align-items: center; justify-content: center; height: 44px; padding: 0 10px;
  background: #2A2F36; color: var(--texto);
  border: 1px solid #3A3F46; border-radius: 4px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  text-decoration: none; white-space: nowrap;
  font-family: var(--estrecha); font-weight: 700; font-size: 14px; letter-spacing: 0.02em;
}
.ficha .ruta:hover { background: #333941; }
