/* Tozal — base: fichas de diseño, letra, estructura, botones, pestañas, capas y hojas.
   Blanco y negro como una señal; magenta solo para la ruta (como en los GPS de montaña);
   rojo solo para el SOS y el peligro; azul solo para tu posición. */

@font-face {
  font-family: "Signika";
  src: url("../fonts/signika.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  --fondo: #FFFFFF;
  --tinta: #000000;
  --gris: #5B6260;
  --raya: #CDD1CF;
  --suelo: #F1F2F0;
  --magenta: #C4007A;
  --rojo: #D2141E;
  --azul: #0A62C9;
  --sobre-tinta: #FFFFFF;
  --grad: 0; /* Signika: en oscuro se adelgaza para que la letra clara no se engorde */
  --f: "Signika", system-ui, sans-serif;
  --arriba: env(safe-area-inset-top, 0px);
  --abajo: env(safe-area-inset-bottom, 0px);
  --barra: 64px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) {
    color-scheme: dark;
    --fondo: #000000; --tinta: #F2F4F3; --gris: #A9B0AD; --raya: #2E3331; --suelo: #161918;
    --magenta: #FF5CB8; --rojo: #F23C3C; --azul: #4C9BFF; --sobre-tinta: #000000; --grad: -30;
  }
}
:root[data-tema="oscuro"] {
  color-scheme: dark;
  --fondo: #000000; --tinta: #F2F4F3; --gris: #A9B0AD; --raya: #2E3331; --suelo: #161918;
  --magenta: #FF5CB8; --rojo: #F23C3C; --azul: #4C9BFF; --sobre-tinta: #000000; --grad: -30;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 400 17px/1.4 var(--f);
  font-variation-settings: "GRAD" var(--grad);
  background: var(--fondo);
  color: var(--tinta);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  overflow-wrap: break-word; /* direcciones web y palabras largas: se parten solo si no caben */
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--azul); outline-offset: 2px; }
[tabindex="-1"]:focus { outline: none; } /* títulos que reciben el foco al abrir una pantalla: no son botones */
[hidden] { display: none !important; }

h1 { font-size: 36px; line-height: 1.15; font-weight: 700; letter-spacing: -0.01em; margin: 4px 76px 20px 0; }
h2 { font-size: 24px; line-height: 1.2; font-weight: 700; margin: 32px 0 12px; }
h3 { font-size: 21px; line-height: 1.25; font-weight: 600; margin: 24px 0 8px; }
p { margin: 0 0 12px; max-width: 34em; }
.num { font-variant-numeric: tabular-nums; }
.gris { color: var(--gris); }
.pequeno { font-size: 14px; line-height: 1.35; }

.oculto { position: absolute; top: 0; left: 0; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.ic { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: butt; stroke-linejoin: miter; }

/* ---------- Estructura ---------- */

.app { position: fixed; inset: 0; display: flex; flex-direction: column; }
main { position: relative; flex: 1; min-height: 0; }
.pestana {
  position: absolute; inset: 0;
  overflow-y: auto; overscroll-behavior: contain;
  padding: calc(var(--arriba) + 16px) 16px 32px;
}
.pestana-mapa { padding: 0; overflow: hidden; }

.pestanas {
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  height: calc(var(--barra) + var(--abajo)); padding-bottom: var(--abajo);
  border-top: 1px solid var(--raya); background: var(--fondo);
}
.pestanas a {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-width: 0; overflow: hidden; color: var(--gris); text-decoration: none; font-size: 14px; font-weight: 600; line-height: 1;
}
.pestanas a[aria-current="page"] { color: var(--tinta); }
.pestanas a[aria-current="page"]::before { content: ""; position: absolute; top: -1px; left: 24%; right: 24%; height: 3px; background: var(--tinta); }

.sos {
  position: fixed; z-index: 40; top: calc(var(--arriba) + 12px); right: 12px;
  display: grid; place-items: center; min-width: 64px; height: 48px; padding: 0 14px;
  border-radius: 8px; background: var(--rojo); color: #FFFFFF;
  font-size: 19px; font-weight: 700; letter-spacing: 0.02em; text-decoration: none;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .18);
}

/* ---------- Capas: pantallas que se abren encima ---------- */

.capa {
  position: fixed; inset: 0; z-index: 20;
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--fondo);
  padding: 0 16px calc(var(--abajo) + 32px);
}
.capa-cabecera {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 4px;
  margin: 0 -16px; padding: calc(var(--arriba) + 12px) 84px 8px 8px;
  background: var(--fondo);
}
.capa-cabecera h1 { margin: 0; font-size: 21px; line-height: 1.2; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Botones ---------- */

.boton {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px;
  border: 2px solid var(--tinta); border-radius: 8px;
  background: var(--fondo); color: var(--tinta);
  font-weight: 600; text-decoration: none; text-align: center;
}
.boton.principal { background: var(--tinta); color: var(--sobre-tinta); }
.boton:active { transform: translateY(1px); }
.boton-icono {
  display: grid; place-items: center; width: 48px; height: 48px; flex: none;
  border: 0; border-radius: 8px; background: transparent; color: var(--tinta);
}
.boton-icono:active { background: var(--suelo); }

/* Fila de botones para elegir (filtros, tema…) */
.opciones { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 16px; padding: 0 16px; }
.opciones::-webkit-scrollbar { display: none; }
.opcion {
  flex: none; min-height: 48px; padding: 0 16px;
  border: 1.5px solid var(--raya); border-radius: 24px;
  background: var(--fondo); color: var(--tinta); font-weight: 600;
}
.opcion[aria-pressed="true"] { background: var(--tinta); border-color: var(--tinta); color: var(--sobre-tinta); }

.error { padding: 16px; border-left: 4px solid var(--rojo); background: var(--suelo); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
.pestanas a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
