/* Map page (V1-WEB B; V1-WEB-DESIGN "Concept"): iCloud Find Devices-style top
   bar, near-opaque floating panel / bottom sheet, tile pins, map controls and
   the launcher. Loaded only on the map page. Without JS (no html.js) the
   page stays a plain document with the panel content. */
:root {
  --panel-bg: var(--bg-elevated);
  --panel-tile: #F2F2F7;
  --mtile-bg: #E5E5EA;
  --bar-bg: color-mix(in srgb, var(--bg-elevated) 92%, transparent);
  --pin-bg: #1C1C1E;
  --pin-tile: #2C2C2E;
  --neutral: #8E8E93;
  --indigo: #5856D6;
  --purple: #AF52DE;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --panel-bg: color-mix(in srgb, #2C2C2E 96%, transparent);
    --panel-tile: #3A3A3C;
    --mtile-bg: #3A3A3C;
    --bar-bg: #1C1C1E;
  }
}
:root[data-theme="dark"] { --panel-bg: color-mix(in srgb, #2C2C2E 96%, transparent); --panel-tile: #3A3A3C; --mtile-bg: #3A3A3C; --bar-bg: #1C1C1E; }

.mapapp { --accent: var(--gas); }
.mapapp[data-tab="ev"] { --accent: var(--ev); }

/* Top bar: "Carga" + the section in its accent color; +, launcher, avatar. */
.mbar { position: sticky; top: 0; z-index: 30; height: 52px; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: var(--bar-bg); border-bottom: .5px solid var(--separator); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.wordmark { font: 600 1.25rem/1 var(--font); color: var(--label); letter-spacing: -.01em; white-space: nowrap; }
.wordmark:hover { text-decoration: none; }
.wm-section { color: var(--gas); }
body:has(.mapapp[data-tab="ev"]) .wm-section { color: var(--ev); font-style: italic; }
/* Brand mark: the section's unit icon (outline, --label) before the wordmark. */
.wordmark { display: inline-flex; align-items: center; gap: 6px; }
.wm-icon { display: inline-flex; color: var(--label); }
.wm-icon .brand-icon { display: block; }
body:has(.mapapp[data-tab="ev"]) .b-gas, body:not(:has(.mapapp[data-tab="ev"])) .b-ev { display: none; }
@media (max-width: 379.98px) { .wm-carga { display: none; } }
.mbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.mbar-btn { width: 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; color: var(--label); background: none; border: 0; cursor: pointer; }
.mbar-btn:hover { background: var(--fill); text-decoration: none; }
.mbar-avatar { min-width: 44px; height: 44px; padding: 0 12px; border-radius: 999px; background: var(--fill); color: var(--label); font: var(--t-footnote); font-weight: 600; display: grid; place-items: center; }
.mbar-avatar:hover { text-decoration: none; filter: brightness(1.1); }

/* Launcher popover. */
.launcher { margin: 0; inset: 56px 12px auto auto; width: min(340px, calc(100vw - 24px)); max-height: calc(100dvh - 68px); overflow: auto; padding: 8px 20px 16px; border: .5px solid var(--separator); border-radius: 20px; background: var(--bg-elevated); color: var(--label); box-shadow: 0 16px 48px rgba(0, 0, 0, .3); }
.launcher-h { font: var(--t-headline); margin: 14px 0 10px; }
.launcher ul { list-style: none; margin: 0; padding: 0; }
.launcher-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 8px; }
.launcher-grid a { display: grid; justify-items: center; gap: 6px; color: var(--label-2); font: var(--t-caption); text-align: center; }
.launcher-grid a:hover { text-decoration: none; color: var(--label); }
.app-icon { width: 56px; height: 56px; border-radius: 14px; display: grid; place-items: center; color: #fff; box-shadow: inset 0 0 0 .5px rgba(255, 255, 255, .15); }
.app-icon .icon { width: 28px; height: 28px; }
.c-gas { background: var(--gas); } .c-ev { background: var(--ev); } .c-tint { background: var(--tint-fill); }
.c-gray { background: #8E8E93; } .c-purple { background: var(--purple); } .c-indigo { background: var(--indigo); }
.launcher-rows a { display: flex; align-items: center; gap: 12px; min-height: 40px; color: var(--label); font: var(--t-body); }
.launcher-rows .icon { color: var(--tint); }
@media (max-width: 599.98px) { .launcher { inset: 52px 0 0 0; width: 100%; max-height: none; height: calc(100dvh - 52px); border-radius: 0; } }

/* No JavaScript: a plain page. */
.map, .mctl, .mctl-bottom, .tabbar, .msegmented, .panel-grab, .panel-collapse, #results, .results-status { display: none; }
.map-nojs { display: flex; gap: 8px; align-items: center; color: var(--label-2); font: var(--t-subhead); margin: 16px; }
html:not(.js) .panel { max-width: var(--content-max); margin: 0 auto; padding: 0 16px; }
.panel-title { font: var(--t-title2); }
.accent-link { color: var(--accent); font: var(--t-body); }
.section-cap { font: var(--t-footnote); font-weight: 600; color: var(--label-2); margin: 0; }
.mchips[hidden] { display: none; }
.mapapp[data-tab="ev"] .accent-link { display: none; }
.accent-link { display: inline-flex; align-items: center; min-height: 44px; justify-self: start; }
.mchips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 0; }
.mchips .chip[aria-current="true"] { background: var(--accent); color: #000; }

/* With JavaScript: the full-screen app. */
html.js, html.js .map-body { height: 100%; overflow: hidden; overscroll-behavior: none; }
.js .map-nojs { display: none; }
.js .mapapp { position: fixed; inset: 52px 0 0 0; overflow: hidden; }
.js .map { display: block; position: absolute; inset: 0; background: var(--bg); }
.map-msg { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); z-index: 5; display: flex; gap: 10px; align-items: center; padding: 10px 16px; border-radius: 16px; background: var(--bg-elevated); color: var(--label-2); font: var(--t-footnote); box-shadow: 0 8px 24px rgba(0, 0, 0, .15); }
.map-msg strong { color: var(--label); }
.map-msg[hidden] { display: none; }

/* Map controls: style at the top trailing corner; locate + zoom capsule and
   compass at the bottom trailing corner. */
.js .mctl, .js .mctl-bottom { display: flex; }
.mctl { position: absolute; z-index: 4; background: var(--pin-bg); border-radius: 12px; box-shadow: 0 4px 16px rgba(0, 0, 0, .25); overflow: hidden; }
.mctl-style { top: 16px; right: 16px; }
.mctl-bottom { position: absolute; z-index: 4; right: 16px; bottom: 24px; gap: 10px; align-items: center; }
.mctl-bottom .mctl { position: static; border-radius: 999px; }
.mctl-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; color: #fff; cursor: pointer; }
.mctl-btn:hover { background: rgba(255, 255, 255, .12); }
.compass { width: 44px; height: 44px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .25); background: var(--pin-bg); color: #fff; font: 700 .8125rem/1 var(--font); cursor: pointer; box-shadow: 0 4px 16px rgba(0, 0, 0, .25); }
.compass[hidden] { display: none; }
.compass-n { display: inline-block; transition: transform 200ms var(--ease); }
.compass-n::before { content: ""; display: block; margin: 0 auto 1px; width: 0; height: 0; border: 4px solid transparent; border-bottom: 6px solid #FF453A; border-top: 0; }
.mapapp[data-mapkit="off"] .mctl-style, .mapapp[data-mapkit="off"] #btn-zoom-in, .mapapp[data-mapkit="off"] #btn-zoom-out, .mapapp[data-mapkit="off"] .compass { display: none; }

/* Panel: floating on tablet/desktop. */
.js .panel { position: absolute; z-index: 10; top: 24px; left: 24px; bottom: 56px; width: 360px; display: flex; flex-direction: column; background: var(--panel-bg); border-radius: var(--r-panel); box-shadow: 0 12px 40px rgba(0, 0, 0, .25); border: .5px solid color-mix(in srgb, var(--label) 8%, transparent); overflow: hidden; }
@media (min-width: 1024px) { .js .panel { width: 400px; } }
.js .panel-collapse { display: grid; }
.panel-collapse { place-items: center; width: 44px; height: 44px; border: 0; background: none; color: var(--accent); border-radius: 8px; cursor: pointer; }
.panel-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.panel-view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.panel-view[hidden] { display: none; }
.panel-head { padding: 20px 20px 8px; display: grid; gap: 8px; }
.panel-titlerow { display: flex; align-items: center; justify-content: space-between; }
.sortrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 4px; }
.js .msegmented { display: inline-flex; }
.msegmented { background: var(--fill); border-radius: 9px; padding: 2px; }
.msegmented button { position: relative; border: 0; background: none; color: var(--label); font: var(--t-footnote); font-weight: 600; padding: 4px 10px; border-radius: 7px; cursor: pointer; }
.msegmented button::after { content: ""; position: absolute; inset: -8px -2px; }
.msegmented button[aria-pressed="true"] { background: var(--segment); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.js .panel-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0 8px 96px; -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 40px), transparent); }
/* The server-rendered national/state/footer content is the no-JS page; with JS the launcher carries those links and the rows would otherwise push it down (CLS). */
.js .fallback { display: none; }
.fallback .footer { padding: 16px 4px 0; margin: 0; }
.panel.is-collapsed { bottom: auto; }
.panel.is-collapsed .panel-scroll, .panel.is-collapsed .mchips, .panel.is-collapsed .sortrow, .panel.is-collapsed .tabbar, .panel.is-collapsed #view-detail > :not(.dtop) { display: none; }
.panel.is-collapsed .panel-collapse .icon { transform: rotate(180deg); }

/* Rows: 48 px rounded-square tiles, three lines, no separators. */
.js #results { display: block; list-style: none; margin: 0; padding: 0; }
.mrow { width: 100%; display: flex; align-items: center; gap: 12px; padding: 8px 12px; margin-bottom: 4px; border: 0; border-radius: 14px; background: none; color: var(--label); text-align: left; font: inherit; cursor: pointer; }
.mrow:hover, .mrow[aria-current="true"] { background: var(--fill); }
.mtile { width: 48px; height: 48px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--mtile-bg); color: var(--gas); }
.mtile.ev { color: var(--ev); }
.mtile .icon { width: 24px; height: 24px; }
.mrow-main { flex: 1; min-width: 0; display: grid; }
.mrow-title { font: var(--t-body); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mrow-sub, .mrow-meta { font: var(--t-subhead); color: var(--label-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mrow-meta.stale { color: var(--gas); }
.mrow-trail { flex: none; display: grid; justify-items: end; gap: 2px; }
.mrow-price { font: var(--t-headline); font-variant-numeric: tabular-nums; }
.mrow-dist { display: flex; align-items: center; gap: 6px; font: var(--t-footnote); color: var(--label-2); font-variant-numeric: tabular-nums; }
.qdot { width: 8px; height: 8px; border-radius: 50%; background: var(--neutral); flex: none; display: inline-block; }
.qdot.q-low { background: var(--down); } .qdot.q-high { background: var(--up); }
.js .results-status { display: block; font: var(--t-footnote); color: var(--label-2); margin: 8px 12px; }
.results-status:empty { display: none; }

/* Station detail inside the panel. */
#view-detail { display: block; overflow-y: auto; padding: 16px 20px 96px; }
#view-detail[hidden] { display: none; }
.dtop { display: flex; justify-content: space-between; align-items: center; }
.back-link { display: inline-flex; align-items: center; gap: 2px; border: 0; background: none; padding: 4px 0; color: var(--accent); font: var(--t-body); font-size: 1.1875rem; cursor: pointer; }
.dhero { width: 96px; height: 96px; margin: 12px auto 14px; border-radius: 22px; display: grid; place-items: center; background: var(--mtile-bg); color: var(--gas); }
.dhero.ev { color: var(--ev); }
.dhero-icon { width: 48px; height: 48px; }
.dtitle { font: var(--t-title3); font-weight: 700; text-align: center; overflow-wrap: anywhere; }
.dtitle:focus { outline: none; }
.dsub { text-align: center; color: var(--label-2); font: var(--t-subhead); margin: 4px 0 0; overflow-wrap: anywhere; }
.daddr { font: var(--t-body); margin: 16px 0 0; }
.dstatus { display: flex; align-items: center; gap: 8px; color: var(--label-2); font: var(--t-body); margin: 4px 0 0; }
.fresh-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--down); }
.dstatus.stale .fresh-dot { background: var(--gas); }
.dprices { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 8px; margin-top: 16px; }
.dprice { background: var(--panel-tile); border-radius: 14px; padding: 10px 12px; display: grid; gap: 2px; }
.dprice-fuel { font: var(--t-footnote); color: var(--label-2); }
.dprice-value { font: var(--t-title3); font-variant-numeric: tabular-nums; }
.dprice .pill { justify-self: start; }
.dnote { color: var(--label-2); font: var(--t-footnote); margin: 12px 0 0; }
.dtiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.dtile { display: grid; gap: 10px; padding: 14px; border-radius: 16px; background: var(--panel-tile); color: var(--label); border: .5px solid color-mix(in srgb, var(--label) 8%, transparent); }
.dtile:hover { text-decoration: none; filter: brightness(1.06); }
.dtile-icon { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.dtile-icon .icon { width: 18px; height: 18px; }
.dtile-label { font: var(--t-body); }
.dcard { list-style: none; margin: 10px 0 0; padding: 0 16px; border-radius: 16px; background: var(--panel-tile); }
.dcard li + li { border-top: .5px solid var(--separator); }
.dcard a { display: flex; align-items: center; justify-content: space-between; min-height: 48px; color: var(--label); font: var(--t-body); }
.dcard a:hover { text-decoration: none; color: var(--accent); }

/* Floating tab bar inside the panel. */
.js .tabbar { display: grid; grid-template-columns: repeat(3, 1fr); position: absolute; z-index: 2; left: 50%; bottom: 12px; transform: translateX(-50%); width: min(300px, calc(100% - 32px)); padding: 4px; border-radius: 999px; background: color-mix(in srgb, var(--bg-elevated) 80%, transparent); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%); box-shadow: 0 8px 24px rgba(0, 0, 0, .2); border: .5px solid color-mix(in srgb, var(--label) 10%, transparent); }
.tab { position: relative; z-index: 1; display: grid; justify-items: center; gap: 1px; padding: 6px 0 4px; color: var(--label); font: var(--t-caption2); font-weight: 600; border-radius: 999px; }
.tab:hover { text-decoration: none; }
.tab[aria-current="page"] { color: var(--tint); }
.tab-pill { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc((100% - 8px) / 3); border-radius: 999px; background: color-mix(in srgb, var(--tint) 16%, transparent); transition: transform 200ms var(--ease); }
.tabbar[data-tab="ev"] .tab-pill { transform: translateX(100%); }

/* Phone: bottom sheet with detents (heights set by map.js). */
@media (max-width: 599.98px) {
  .js .panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; height: var(--sheet-h, 50%); transform: translateY(var(--sheet-y, 0)); border-radius: var(--r-panel) var(--r-panel) 0 0; transition: transform 350ms var(--ease); touch-action: pan-x; }
  .js .panel.is-dragging { transition: none; }
  .js .panel[data-detent="large"] { background: var(--bg-elevated); }
  .js .panel-grab { display: flex; justify-content: center; padding: 8px 0 0; touch-action: none; cursor: grab; }
  .js .panel-head { touch-action: none; padding-top: 8px; }
  .js .panel-collapse { display: none; }
  .grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--label-3); }
  .panel-toggle { position: absolute; top: 4px; right: 12px; font: var(--t-footnote); color: var(--tint); background: var(--fill); border: 0; border-radius: 999px; padding: 4px 10px; min-height: 44px; clip-path: inset(50%); }
  .panel-toggle:focus-visible { clip-path: none; }
  .mctl-style { top: 12px; right: 12px; }
  .mctl-bottom { top: 64px; bottom: auto; right: 12px; flex-direction: column; }
  .mctl-bottom .mctl { flex-direction: column; border-radius: 12px; }
  #btn-zoom-in, #btn-zoom-out { display: none; }
}
@media (prefers-reduced-motion: reduce) { .js .panel, .tab-pill, .compass-n, .pin-tile { transition: none !important; } }

/* Pins. Zoomed out: dark price capsule + quartile dot. Zoomed in
   (.mapapp[data-near]) or selected: a 44 px tile with the name under it and
   the capsule at its top trailing corner. Clusters: count tiles. */
.pin { position: relative; display: flex; flex-direction: column; align-items: center; cursor: pointer; font: var(--t-caption); }
.pin-cap { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px 3px 6px; border-radius: 999px; background: var(--pin-bg); color: #fff; border: 2px solid rgba(255, 255, 255, .85); box-shadow: 0 2px 8px rgba(0, 0, 0, .3); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pin-cap .qdot { width: 6px; height: 6px; }
.pin-cap-icon { width: 12px; height: 12px; color: var(--ev); }
.pin-tile, .pin-name, .pin-price { display: none; }
.mapapp[data-near] .pin .pin-price, .pin.is-selected .pin-price { display: inline; }
.pin-tile { width: 44px; height: 44px; border-radius: 12px; place-items: center; background: var(--pin-tile); color: var(--gas); border: 2px solid #fff; box-shadow: 0 4px 12px rgba(0, 0, 0, .35); transition: transform 200ms var(--ease); }
.pin-tile.ev { color: var(--ev); }
.pin-tile .icon { width: 22px; height: 22px; }
.pin-name { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 4px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: var(--t-caption2); font-weight: 700; color: var(--label); text-shadow: 0 0 2px var(--bg-elevated), 0 0 4px var(--bg-elevated); pointer-events: none; }
.mapapp[data-near] .pin .pin-tile, .pin.is-selected .pin-tile { display: grid; }
.mapapp[data-near] .pin .pin-name, .pin.is-selected .pin-name { display: block; }
.mapapp[data-near] .pin .pin-cap, .pin.is-selected .pin-cap { position: absolute; top: -10px; left: 30px; padding: 1px 6px 1px 4px; font: var(--t-caption2); font-weight: 700; }
.mapapp[data-near] .pin .pin-cap:empty { display: none; }
.pin.is-selected { z-index: 10; }
.pin.is-selected .pin-tile { transform: scale(1.2); transform-origin: 50% 100%; }
.pin.poi .pin-tile { color: var(--ev); background: #fff; }
.pin-cluster { min-width: 40px; min-height: 40px; padding: 2px 8px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; white-space: nowrap; background: var(--pin-tile); color: #fff; border: 2px solid #fff; box-shadow: 0 4px 12px rgba(0, 0, 0, .35); font: var(--t-subhead); font-weight: 700; font-variant-numeric: tabular-nums; cursor: pointer; }
.pin-cluster-sub { font: var(--t-caption2); font-weight: 600; opacity: .85; }
.pin-cluster.ev .pin-cluster-n { color: var(--ev); }
.user-dot { width: 18px; height: 18px; border-radius: 50%; background: #0A84FF; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(10, 132, 255, .2), 0 2px 6px rgba(0, 0, 0, .3); }
.dprice .pill { min-width: 0; padding: 1px 5px; font: var(--t-caption); font-weight: 700; text-align: left; }

/* Performance: cheap paint while the map moves (class set by map.ts), and
   isolated pin subtrees so moving annotations never re-layout the page. */
.pin, .pin-cluster { contain: layout style; }
.mapapp.is-interacting .mbar, .mapapp.is-interacting .tabbar { -webkit-backdrop-filter: none; backdrop-filter: none; }
.mapapp.is-interacting .mbar { background: var(--bg-elevated); }
.mapapp.is-interacting .tabbar { background: var(--bg-elevated); }
.mapapp.is-interacting .pin-cap, .mapapp.is-interacting .pin-tile, .mapapp.is-interacting .pin-cluster { box-shadow: none; }
.mapapp.is-interacting .pin-name { text-shadow: none; }
