/* ==========================================================================
   Visor /mapas · interfaz móvil (por debajo de 700 px). Lo monta movil.js en #v-ui.
   Usa las clases y los tokens de sistema.css tal cual; aquí solo va lo propio.
   Sale del mockup aprobado visor-movil.html (clases .vm*).
   ========================================================================== */

/* El visor ocupa la pantalla; el mapa (#v-mapa) queda debajo y recibe los gestos donde no hay controles */
.vm { --vis: 68px; --media: 150px; position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; height: 100dvh; font-size: var(--t-2); color: var(--ink); pointer-events: none; overflow: hidden; overflow: clip; }
/* «clip» y no «hidden»: un foco o un scrollIntoView no deben poder desplazar la escena */
.vm__escena { position: relative; flex: 1; min-height: 0; overflow: hidden; overflow: clip; }
.vm__arriba > *, .vm__tiempo, .vm__hoja, .vm__nav, .vm[data-capas] .vm__velo, .vm__capas.es-abierta { pointer-events: auto; }
.vm button { font: inherit; color: inherit; cursor: pointer; }
.vm button[disabled] { cursor: not-allowed; }
.vm :focus-visible { outline: 2px solid var(--senal); outline-offset: 2px; }

/* --- Franja superior: botón de capa y leyenda --- */
.vm__arriba { position: absolute; z-index: 8; top: max(12px, env(safe-area-inset-top, 0px)); left: 12px; right: 12px; display: grid; gap: 6px; }
.vm__barra { display: flex; gap: 8px; align-items: stretch; }
.vm__capa { flex: none; display: flex; align-items: center; gap: 8px; min-height: 56px; max-width: 56%; padding: 0 10px 0 12px; border: 0; border-radius: var(--r-3); background: var(--ink); color: var(--on-ink) !important; box-shadow: var(--s-mapa); text-align: left; }
.vm__capa > span { min-width: 0; }
.vm__capa small { display: block; font-size: var(--t-1); font-weight: 500; letter-spacing: .07em; text-transform: uppercase; opacity: .72; line-height: 1.1; }
/* el nombre de la capa en dos líneas si no cabe («Nieve acumulada · 24 h» se cortaba en «Nieve acumulada …») */
.vm__capa b { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-family: var(--f-titular); font-variation-settings: "wdth" 88; font-size: var(--t-3); font-weight: 700; line-height: 1.12; overflow: hidden; overflow-wrap: anywhere; }
.vm--estrecho .vm__capa { padding: 0 10px; gap: 6px; } .vm--estrecho .vm__capa > svg:last-child { display: none; }
.vm__ley { flex: 1 1 0; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); align-content: center; padding: 6px 10px 5px; border: 0; text-align: left; overflow: hidden; }
.vm__ley[disabled] { cursor: default; opacity: 1; }
.vm__ley .ley__cab { white-space: nowrap; }
.vm__ley .ley__tit { min-width: 0; white-space: normal; line-height: 1.15; text-wrap: balance; } /* entero, en dos líneas si hace falta */
.vm__ley .ley__ud { flex: none; }
.vm__ley .ley__marcas span { overflow: visible; }
.vm__ley.ley--palabras .vm__lpal span { font-size: 10px; white-space: normal; min-width: 0; padding: 4px 1px 0; line-height: 1.1; text-align: center; } /* clases en palabras (Coinciden · Dudan · Discrepan, Poco probable…): centradas y en dos líneas antes que pisarse o salirse */
.vm__lmarcas span:empty::before { content: none; }
.vm__lcont { background-color: transparent; }
.vm__labs { position: relative; height: 17px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.vm__labs span { position: absolute; top: 0; left: var(--p); transform: translateX(-50%); padding-top: 5px; line-height: 1.1; white-space: nowrap; }
.vm__labs span::before { content: ""; position: absolute; left: 50%; top: 0; height: 4px; width: 1px; background: var(--ink-2); }
.vm__labs span.ini { transform: none; } .vm__labs span.ini::before { left: 0; }
.vm__labs span.fin { transform: translateX(-100%); } .vm__labs span.fin::before { left: auto; right: 0; }
.vm__lpal span { font-size: var(--t-1); }

/* Aviso contextual (cobertura de AROME, mensajes del núcleo) */
.vm__aviso { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 10px; min-height: 48px; padding: 2px 4px 2px 12px; background: var(--surface); border-radius: var(--r-3); box-shadow: var(--s-mapa); border-left: 3px solid var(--ink); font-size: var(--t-1); line-height: 1.25; }
.vm__aviso[hidden] { display: none; }
.vm__nada { justify-self: center; margin: 0; padding: 4px 12px; background: var(--surface); border-radius: var(--r-2); box-shadow: var(--s-mapa); font-size: var(--t-1); color: var(--ink-2); pointer-events: none; }
.vm__nada[hidden] { display: none; }
.vm__aviso[data-tipo="error"] { border-left-color: var(--av-naranja); }
.vm__aviso p { margin: 0; padding: 6px 0; }
.vm__aviso .btn { height: 44px; }
.vm__aviso > .ico:first-child { margin: 0; }
.vm[data-hoja="abierta"] .vm__aviso { visibility: hidden; }

/* --- Tiempo: lectura, días y horas --- */
.vm__tiempo { position: absolute; z-index: 10; left: 8px; right: 8px; bottom: calc(min(var(--vis), var(--media)) + 8px); padding: 4px 8px 6px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 3px; transition: bottom .28s cubic-bezier(.2, .8, .2, 1); }
.vm--arrastra .vm__tiempo, .vm--arrastra .vm__hoja { transition: none; }
.vm__lect { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 18px; margin: 0; padding-inline: 2px; font-size: var(--t-1); line-height: 18px; white-space: nowrap; overflow: hidden; }
.vm__lect b { font-weight: 600; }
.vm__lect .proc { flex-wrap: nowrap; white-space: nowrap; gap: 2px 6px; min-width: 0; overflow: hidden; }
.vm__lect .proc > * + *::before { margin-right: 6px; }
.vm .carril { gap: 4px; padding: 0; }
.vm .carril__it { height: 44px; min-width: 46px; padding: 0 6px; position: relative; }
.vm__dias { overflow-x: auto; }
.vm__dias .carril__it { flex: 1 0 44px; min-width: 44px; padding: 0 2px; }
.vm__horas { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 6px; align-items: center; }
/* la primera ficha visible queda entera y los bordes con más contenido se desvanecen */
.vm__horas .carril { position: relative; scroll-snap-type: x mandatory; --fi: 0px; --fd: 0px;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 var(--fi), #000 calc(100% - var(--fd)), transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 var(--fi), #000 calc(100% - var(--fd)), transparent 100%); }
.vm__horas .carril__it, .vm__horas .vm__tramo { scroll-snap-align: start; }
.vm__play { height: 44px; width: 44px; background: var(--ink); color: var(--on-ink) !important; border-color: var(--ink); }
.vm__play[aria-pressed="true"] { background: var(--senal); border-color: var(--senal); color: var(--on-senal) !important; }
.vm .carril__it[data-ahora]::after { content: ""; position: absolute; left: 50%; bottom: 3px; width: 14px; height: 2px; margin-left: -7px; background: var(--senal); }
.vm .carril__it[data-ahora][aria-pressed="true"]::after { background: var(--on-senal); }
.vm .carril__it small { font-size: var(--t-1); font-weight: 600; line-height: 1; }
.vm__tramo { flex: none; align-self: center; padding: 0 4px 0 6px; font-size: var(--t-1); color: var(--muted); white-space: nowrap; }
.vm__corte { color: var(--ink-2); font-weight: 600; border-left: 2px solid var(--ink); margin-left: 2px; }

/* --- Hoja del punto: tres alturas (recogida, media, abierta) --- */
.vm__hoja { position: absolute; z-index: 20; left: 0; right: 0; bottom: 0; height: calc(100% - 88px); padding: 0; display: flex; flex-direction: column; gap: 0; transform: translateY(calc(100% - var(--vis))); transition: transform .28s cubic-bezier(.2, .8, .2, 1); }
.vm__hoja::before { content: none; }
.vm__asa { flex: none; height: 14px; width: 100%; border: 0; background: none; display: grid; place-items: center; touch-action: none; cursor: grab; position: relative; }
.vm__asa::before { content: ""; width: 40px; height: 4px; border-radius: 2px; background: var(--line-2); }
.vm__asa::after { content: ""; position: absolute; inset: -10px 0 -20px; }          /* 44 px de alto para el dedo */
.vm__cuerpo { flex: 1; min-height: 0; overflow: hidden; padding: 0 var(--margen) var(--e-4); overscroll-behavior: contain; }
.vm[data-hoja="abierta"] .vm__cuerpo { overflow-y: auto; }
.vm__vacio { display: grid; gap: 8px; padding: 2px 0 6px; }
.vm__vacio[hidden] { display: none; }
.vm__vacio p { margin: 0; font-size: var(--t-1); color: var(--ink-2); line-height: 1.3; }
.vm__vacio-b { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.vm__vacio-b .btn { height: 44px; font-size: var(--t-1); }

/* --- Hojas secundarias: capas, modelos y búsqueda --- */
.vm__velo { position: absolute; inset: 0; z-index: 30; background: rgba(15, 27, 43, .38); opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s; }
.vm[data-capas] .vm__velo { opacity: 1; visibility: visible; }
.vm__capas { position: absolute; z-index: 31; left: 0; right: 0; bottom: 0; max-height: calc(100% - 20px); overflow-y: auto; overscroll-behavior: contain; padding: 0 12px 14px; gap: 0; display: block; transform: translateY(102%); visibility: hidden; transition: transform .28s cubic-bezier(.2, .8, .2, 1), visibility .28s; }
.vm__capas::before { content: ""; display: block; width: 40px; height: 4px; margin: 10px auto 2px; }
.vm__capas.es-abierta { transform: none; visibility: visible; }
.vm__ccab { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding-left: 4px; }
.vm__ccab .btn { height: 44px; width: 44px; margin-right: -6px; }
.vm__modos { margin: 2px 4px 6px; }
.vm__modos .seg__op { height: 36px; padding: 0 16px; }
.vm__fams { padding: 0; gap: 8px; grid-auto-flow: row dense; }
.vm__capas .capas__grupo { display: flex; align-items: baseline; gap: 8px; padding: 12px 4px 6px; margin: 0; }
.vm__capas .capa { grid-template-columns: 24px minmax(0, 1fr); gap: 4px 10px; padding: 10px 10px 8px; min-height: 92px; align-content: start; border-radius: var(--r-3); background: var(--surface); }
.vm__capas .capa[aria-pressed="true"] { border-color: var(--senal); box-shadow: inset 0 0 0 1px var(--senal); background: var(--senal-suave); }
.vm__capas .capa[aria-expanded="true"]:not([aria-pressed="true"]) { border-color: var(--ink); }
.vm__capas .capa__n { font-size: var(--t-3); font-weight: 600; line-height: 1.2; }
.vm__capas .capa__d { margin-top: 1px; line-height: 1.25; }
.vm .capa__pal { grid-column: 1 / -1; display: grid; gap: 3px; margin-top: 4px; }
.vm .capa__pal i { display: block; height: 6px; border-radius: 1px; box-shadow: inset 0 0 0 1px rgba(15, 27, 43, .18); }
.vm .capa__pal span { display: flex; justify-content: space-between; font-size: var(--t-1); color: var(--ink-2); line-height: 1.1; font-weight: 400; }
.vm .capa__pal em { font-style: normal; }
.vm .capa[aria-pressed="true"] .capa__pal span { color: inherit; }
.vm__capas .capa--mas { border-style: dashed; color: var(--ink-2); align-content: center; min-height: 92px; }
.vm__capas .capa--mas .capa__n { font-size: var(--t-2); }

/* variables de la familia abierta y su selector de ventana o nivel */
.vm__subs { grid-column: 1 / -1; display: grid; gap: 4px; padding: 6px; margin-top: -2px; border: 1px solid var(--line); border-radius: var(--r-3); background: var(--raised); }
.vm__var { display: grid; gap: 1px; width: 100%; min-height: 48px; padding: 6px 10px; border: 1px solid transparent; border-radius: var(--r-2); background: none; text-align: left; }
.vm__var b { font-weight: 600; font-size: var(--t-2); }
.vm__var small { font-size: var(--t-1); color: var(--muted); line-height: 1.25; }
.vm__var:hover:not([disabled]) { background: var(--sunk); }
.vm__var[aria-pressed="true"] { background: var(--senal-suave); color: var(--senal-tinta); box-shadow: inset 2px 0 0 var(--senal); }
.vm__var[aria-pressed="true"] small { color: inherit; opacity: .85; }
.vm__var[disabled] { opacity: .5; }
.vm__exp { display: inline-block; margin-left: 4px; padding: 0 6px; border: 1px dashed currentColor; border-radius: var(--r-pill); font-size: 11px; font-weight: 600; vertical-align: 2px; }
.vm__ops { display: flex; flex-wrap: wrap; margin: 2px 0 6px 10px; max-width: calc(100% - 10px); }
.vm__ops .seg__op { height: 40px; display: grid; justify-items: center; align-content: center; gap: 0; line-height: 1.15; padding: 0 10px; }
.vm__ops .seg__op small { font-size: 11px; font-weight: 400; color: var(--muted); }
.vm__ops .seg__op[disabled] { opacity: .45; }

/* Experto: vistas, encima y compartir */
.vm__vistas { display: flex; margin: 0 4px; }
.vm__vistas .seg__op { height: 36px; }
.vm__encima { display: grid; gap: 2px; margin: 0 4px; }
.vm__interr { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 0 4px; border: 0; background: none; text-align: left; }
.vm__interr i { position: relative; width: 36px; height: 20px; border-radius: var(--r-pill); background: var(--line-2); flex: none; transition: background .15s; }
.vm__interr i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); transition: transform .15s; }
.vm__interr[aria-checked="true"] i { background: var(--ink); }
.vm__interr[aria-checked="true"] i::after { transform: translateX(16px); }
.vm__comp { margin: 10px 4px 0; width: calc(100% - 8px); height: 44px; }

/* Tarjeta del modelo que ha elegido «Automático» */
.vm__modelo { display: grid; grid-template-columns: 4px minmax(0, 1fr); gap: 10px; margin-top: 12px; padding: 10px 12px 10px 0; border: 1px solid var(--line); border-radius: var(--r-3); font-size: var(--t-1); color: var(--ink-2); line-height: 1.35; overflow: hidden; }
.vm__modelo::before { content: ""; background: var(--c, var(--ink)); margin-block: -10px; }
.vm__modelo b { display: block; font-size: var(--t-2); color: var(--ink); font-weight: 600; }
.vm__mbot { grid-column: 2; display: flex; flex-wrap: wrap; gap: 6px; }
.vm__mbot .btn { height: 36px; }
.vm__atrib { margin: 10px 4px 0; }
.vm__atrib a { color: inherit; }

/* Hoja de modelos */
.vm__mayuda { margin: 0 4px 8px; }
.vm__mlista { display: grid; gap: 6px; }
.vm__mod { display: grid; grid-template-columns: 4px minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; min-height: 52px; padding: 6px 12px 6px 0; border: 1px solid var(--line); border-radius: var(--r-3); background: var(--surface); text-align: left; overflow: hidden; }
.vm__mc { align-self: stretch; margin-block: -6px; background: var(--c, var(--ink)); }
.vm__mod b { display: block; font-weight: 600; }
.vm__mod small { display: block; font-size: var(--t-1); color: var(--muted); line-height: 1.25; }
.vm__mod .vm__res { display: inline; font-weight: 500; }
.vm__mod[aria-pressed="true"] { border-color: var(--senal); box-shadow: inset 0 0 0 1px var(--senal); background: var(--senal-suave); }
.vm__mod[disabled] { opacity: .55; }
.vm__mod[disabled] small { color: var(--ink-2); }
.vm__malc { color: var(--muted); }
.vm__pas { display: grid; gap: 4px; margin-top: 12px; }
.vm__pas .campo { width: 100%; height: 44px; }

/* Búsqueda */
.vm__bcaja { margin: 4px 0 8px; }
.vm__bcaja input { font-size: 16px; }                        /* sin zoom automático en iOS */
.vm .busca input:focus-visible { outline: none; }             /* el foco lo marca la caja (.busca:focus-within) */
.vm__bubic { width: 100%; height: 44px; margin-top: 4px; }
.vm .vb__res { max-height: 50vh; overflow-y: auto; }
.vm .vb__msg { margin: 0; padding: 10px; }

/* Barra inferior: en el flujo, por debajo del mapa */
.vm__nav { position: relative; inset: auto; flex: none; z-index: 40; padding-bottom: env(safe-area-inset-bottom, 0px); height: calc(var(--barra-inf-alto) + env(safe-area-inset-bottom, 0px)); }
.vm__nav .barra-inf__a { color: var(--muted); }
.vm__nav .barra-inf__a[aria-current] { color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
  .vm__tiempo, .vm__hoja, .vm__capas, .vm__velo { transition: none; }
}

/* Créditos sobre el mapa (cita de Open-Meteo, fuente del modelo y límites), pegados al panel de tiempo */
.vm__cred { position: absolute; right: 0; bottom: calc(100% + 4px); max-width: 100%; margin: 0; padding: 1px 6px; border-radius: var(--r-1); background: color-mix(in srgb, var(--surface) 78%, transparent); color: var(--ink-2); font-size: 11px; line-height: 15px; white-space: normal; text-align: right; text-wrap: balance; }
.vm__cred a { color: inherit; }
.vm__credf { white-space: nowrap; }
.vm[data-hoja="abierta"] .vm__cred { visibility: hidden; }
.vm__aacc { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.vm__aviso b { display: block; font-weight: 600; }

/* mapa sinóptico en la hoja de capas (Experto) */
.vm .vm__sinnota { margin: 4px 2px 0; font-size: var(--t-1); }
.vm .vm__sinbot { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.vm .vm__sinbot .btn { gap: 6px; }

/* Teléfono en horizontal (menos de 700 px de ancho y poca altura): sin esto la franja de arriba,
   las dos filas de tiempo, la hoja y la barra de abajo tapaban el mapa entero (390 px de alto).
   Fuera la barra de abajo (se vuelve a ver al poner el teléfono en vertical), días y horas en
   una sola fila y la hoja vacía sin su frase. */
@media (orientation: landscape) and (max-height: 499.98px) {
  .vm__nav { display: none; }
  .vm__arriba { top: max(8px, env(safe-area-inset-top, 0px)); left: max(8px, env(safe-area-inset-left, 0px)); right: max(8px, env(safe-area-inset-right, 0px)); }
  .vm__capa { min-height: 44px; }
  .vm__tiempo { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); column-gap: 8px; left: max(8px, env(safe-area-inset-left, 0px)); right: max(8px, env(safe-area-inset-right, 0px)); }
  .vm__lect { grid-column: 1 / -1; }
  .vm__vacio p { display: none; }
  .vm__vacio { padding-bottom: max(4px, env(safe-area-inset-bottom, 0px)); }
  .vm__hoja { height: calc(100% - 12px); }
}
