/* =====================================================================
   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; }

button:focus-visible, a:focus-visible { outline: 2px solid var(--barata); outline-offset: 2px; }

/* ---------- Controles flotantes de arriba ----------
   Móvil:      [botón combustible]            [nombre]
               [barra de combustible a todo el ancho]   (solo si está abierta)
               [hora de los precios]
               [aviso]
   Escritorio: [barra siempre visible]        [nombre]
               [hora] / [aviso]                                         */
.superior {
  position: absolute; z-index: 3;
  top: max(12px, env(safe-area-inset-top)); left: 12px; right: 12px;
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "boton marca" "barra barra" "chip chip" "aviso aviso";
  gap: 6px 10px; align-items: start; justify-items: start;
  pointer-events: none;
}
.superior > * { pointer-events: auto; }

.boton-combustible {
  grid-area: boton;
  display: flex; align-items: center; gap: 10px;
  min-height: 52px; padding: 6px 12px 6px 10px; box-sizing: border-box;
  background: var(--n3); color: var(--texto);
  border: 1px solid var(--borde3); border-radius: 6px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  cursor: pointer; text-align: left;
}
.boton-combustible .textos { display: flex; flex-direction: column; gap: 1px; }
.boton-combustible .caption { font-family: var(--estrecha); font-weight: 600; font-size: 10px; letter-spacing: 0.16em; color: var(--texto3); }
.boton-combustible .valor { font-family: var(--estrecha); font-weight: 700; font-size: 16px; letter-spacing: 0.08em; }
.icono-surtidor, .icono-flecha { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icono-surtidor { color: var(--texto3); }
.icono-flecha { color: var(--texto3); }
.boton-combustible[aria-expanded="true"] .icono-flecha { transform: rotate(180deg); }
.boton-combustible .nota { font-family: var(--estrecha); font-weight: 600; font-size: 10px; letter-spacing: 0.14em; color: var(--media); }
.boton-combustible .nota[hidden] { display: none; }

.marca-mini {
  grid-area: marca; justify-self: end;
  display: flex; align-items: baseline; gap: 6px;
  padding: 6px 9px;
  background: rgba(17, 19, 23, 0.85); border: 1px solid var(--borde2); border-radius: 4px;
  font-family: var(--estrecha); font-weight: 700; font-size: 13px; letter-spacing: 0.14em;
}
.marca-mini span { font-weight: 600; font-size: 9px; letter-spacing: 0.16em; color: var(--texto4); }

/* ---------- Barra de combustible ---------- */
.barra-comb {
  grid-area: barra; justify-self: stretch;
  display: flex; align-items: center; gap: 3px;
  min-height: 52px; padding: 4px; box-sizing: border-box;
  background: var(--n3); border: 1px solid var(--borde3); border-radius: 8px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.07);
}
.barra-comb[hidden] { display: none; }
.familia { display: flex; align-items: center; gap: 3px; border-radius: 6px; }
.familia + .familia { border-left: 1px solid var(--borde3); padding-left: 3px; }
.familia.abierta { background: #2C3138; padding: 3px 3px 3px 6px; }
.familia + .familia.abierta { border-left-color: transparent; }
.familia.abierta + .familia { border-left-color: transparent; }
.fam-nombre { font-family: var(--estrecha); font-weight: 700; font-size: 13px; letter-spacing: 0.06em; color: var(--texto); padding-right: 2px; }

/* Familia plegada (o GLP): un botón */
.fam-boton {
  height: 44px; padding: 0 8px;
  background: transparent; color: var(--texto3);
  border: 1.5px solid transparent; border-radius: 6px;
  font-family: var(--estrecha); font-weight: 700; font-size: 13px; letter-spacing: 0.06em;
  cursor: pointer; white-space: nowrap;
}
/* La familia que contiene el combustible elegido se distingue, sin parecer "seleccionada" */
.fam-boton.contiene { color: var(--texto); border-color: #6A7079; }
/* GLP elegido: relleno blanco, como cualquier opción elegida */
.fam-boton[aria-pressed="true"] { background: var(--texto); color: var(--n0); border-color: var(--texto); box-shadow: 0 0 0 3px rgba(237, 235, 230, 0.2); }

/* Variantes: sin elegir = solo contorno; elegida = relleno blanco, bien visible */
.variante {
  height: 40px; min-width: 38px; padding: 0 8px;
  background: transparent; color: var(--texto);
  border: 1.5px solid #5E646C; border-radius: 20px;
  font-family: var(--estrecha); font-weight: 700; font-size: 14px; letter-spacing: 0.04em;
  cursor: pointer; white-space: nowrap;
}
.variante:hover, .fam-boton:hover { border-color: #8C9198; }
.variante[aria-pressed="true"] {
  background: var(--texto); color: var(--n0); border-color: var(--texto);
  box-shadow: 0 0 0 3px rgba(237, 235, 230, 0.2);
}

/* Móviles estrechos: un poco más compacto para que todo quepa sin deslizar */
@media (max-width: 419px) {
  .fam-nombre, .fam-boton { font-size: 12px; letter-spacing: 0.02em; }
  .fam-boton { padding: 0 5px; }
  .familia.abierta { padding-left: 5px; }
  .variante { min-width: 34px; padding: 0 6px; font-size: 13px; letter-spacing: 0.02em; }
}
@media (max-width: 339px) { .barra-comb { flex-wrap: wrap; } }

/* Escritorio: barra siempre visible con todo desplegado, sin botón */
@media (min-width: 900px) {
  .superior {
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "barra marca" "chip ." "aviso .";
  }
  .superior .boton-combustible { display: none; }
  .barra-comb[hidden] { display: flex; }
  .barra-comb { justify-self: start; }
  .aviso { max-width: 520px; }
}

/* ---------- 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 {
  grid-area: aviso; justify-self: stretch; box-sizing: border-box;
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px 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 #aviso-texto { flex: 1 1 200px; padding-top: 2px; }
.aviso-cerrar {
  flex: none; order: 2; 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;
}
.aviso-accion {
  order: 3; flex: 1 1 100%; height: 44px; margin-right: 8px;
  background: var(--texto); color: var(--n0); border: 0; border-radius: 4px;
  font-family: var(--estrecha); font-weight: 700; font-size: 14px; letter-spacing: 0.1em; cursor: pointer;
}
.aviso-accion[hidden] { display: none; }

/* Etiqueta con la hora de los precios */
.chip {
  grid-area: chip;
  height: 28px; 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 .no-vende { margin: -4px 0 10px 2px; font-size: 12px; color: var(--texto4); }
.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; }
