/* California Public Safety Map (/map/). Colours come from style.css's tokens. */
body.app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
body.app header.site { position: relative; z-index: 5; background: var(--bg); }
body.app header.site, body.app main.full { margin: 0; width: 100%; } /* style.css centres them with auto margins */
header.site.full { max-width: none; padding-top: 10px; padding-bottom: 8px; }
main.full { max-width: none; padding: 0; flex: 1 1 auto; min-height: 0; position: relative; }

#am { position: absolute; inset: 0; }
#am-map { position: absolute; inset: 0; background: #d9dde3; }
.am-noscript { position: absolute; top: 40%; width: 100%; text-align: center; }

#am-panel {
  position: absolute; z-index: 3; top: 10px; left: 10px; bottom: 34px; width: 370px; max-width: calc(100% - 20px);
  display: flex; flex-direction: column; background: var(--bg); color: var(--fg);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22); font-size: 14px; line-height: 1.45;
}
#am-panel[hidden] { display: none; }
#am-open {
  position: absolute; z-index: 2; top: 10px; left: 10px; font: inherit; font-size: 14px; font-weight: 600;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--fg);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.2); cursor: pointer;
}
.am-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px 4px 14px; }
.am-head h1 { font-size: 1.05rem; margin: 0; }
#am-close { font: inherit; font-size: 22px; line-height: 1; width: 32px; height: 32px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
#am-close:hover { background: var(--tag); color: var(--fg); }
.am-warn { margin: 0 14px 8px; padding: 6px 10px; border-radius: 6px; font-size: 12.5px; background: #fff4e5; color: #6b3a00; border: 1px solid #f5c88a; }
@media (prefers-color-scheme: dark) { .am-warn { background: #2e2213; color: #ffd8a8; border-color: #6b4a1f; } }
.am-tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 8px; }
.am-tabs button { flex: 1; font: inherit; font-size: 13.5px; padding: 8px 4px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); cursor: pointer; }
.am-tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); font-weight: 600; }
.am-tabs .am-badge { display: inline-block; min-width: 18px; margin-left: 4px; padding: 0 5px; border-radius: 9px; font-size: 11px; font-weight: 600; background: var(--accent); color: var(--bg); }
.am-body { flex: 1 1 auto; overflow-y: auto; padding: 8px 12px 16px; overscroll-behavior: contain; }

/* Layers */
.am-group { margin: 6px 0 12px; }
.am-group-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 2px; }
.am-group-head h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0; padding: 0; border: 0; }
.am-group-head button, .am-linkbtn { font: inherit; font-size: 12px; border: 0; background: none; color: var(--link); cursor: pointer; padding: 2px 4px; }
.am-layer { display: flex; align-items: center; gap: 8px; padding: 4px 4px; border-radius: 6px; cursor: pointer; }
.am-layer:hover { background: var(--tag); }
.am-layer input { margin: 0; width: 16px; height: 16px; accent-color: var(--accent); flex: none; }
.am-sw { flex: none; width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, 0.9); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25); }
.am-sw.sq { border-radius: 3px; }
.am-sw.ln { height: 4px; border-radius: 2px; border: 0; box-shadow: none; }
.am-ico { flex: none; width: 20px; height: 20px; margin: -3px; }
.am-sw.am-inline { display: inline-block; vertical-align: -2px; margin-right: 6px; }
.am-name { flex: 1 1 auto; }
.am-count { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.am-flag { font-size: 11px; padding: 0 6px; border-radius: 8px; background: var(--tag); color: var(--muted); }
.am-flag.bad { color: #c92a2a; }
.am-basemap { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 10px 0 4px; font-size: 13px; color: var(--muted); }
.am-basemap select { font: inherit; padding: 3px 6px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); }

/* Lists (fires, alerts) */
.am-tools { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 12.5px; color: var(--muted); margin: 4px 0 8px; }
.am-tools label { display: inline-flex; gap: 4px; align-items: center; cursor: pointer; }
.am-tools select { font: inherit; padding: 2px 4px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); }
.am-list { list-style: none; margin: 0; padding: 0; }
.am-item { display: block; width: 100%; text-align: left; font: inherit; color: inherit; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 8px 4px; cursor: pointer; }
.am-item:hover { background: var(--tag); }
.am-item b { display: block; font-size: 14px; }
.am-item .am-sub { display: block; color: var(--muted); font-size: 12.5px; }
.am-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.am-chip { font-size: 11px; padding: 0 7px; border-radius: 8px; background: var(--tag); color: var(--fg); white-space: nowrap; }
.am-chip.red { background: #c92a2a; color: #fff; }
.am-chip.orange { background: #e8590c; color: #fff; }
.am-chip.amber { background: #f59f00; color: #000; }
.am-chip.blue { background: #1c7ed6; color: #fff; }
.am-chip.gray { background: #868e96; color: #fff; }
.am-empty { color: var(--muted); font-style: italic; padding: 8px 4px; }
.am-note { color: var(--muted); font-size: 12px; margin: 10px 0 0; }

/* Sources */
.am-src { border-bottom: 1px solid var(--line); padding: 7px 2px; font-size: 13px; }
.am-src b { font-weight: 600; }
.am-src .am-sub { display: block; color: var(--muted); font-size: 12px; }
.am-src .bad { color: #c92a2a; }
.am-credits { font-size: 12.5px; padding-left: 18px; }
.am-credits li { margin: 3px 0; }
.am-body h3 { font-size: 13px; margin: 14px 0 4px; }

/* Popups */
.maplibregl-popup { max-width: min(340px, calc(100vw - 30px)) !important; z-index: 4; }
.maplibregl-popup-content { background: var(--bg); color: var(--fg); padding: 10px 12px 8px; border-radius: 8px; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.3); font-size: 13px; line-height: 1.4; max-height: min(70vh, 520px); overflow-y: auto; }
.maplibregl-popup-close-button { color: var(--muted); font-size: 20px; padding: 0 6px; }
.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(--bg); }
.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(--bg); }
.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--bg); }
.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--bg); }
.am-pop + .am-pop { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; }
.am-pop h4 { margin: 0 22px 2px 0; font-size: 14px; line-height: 1.3; }
.am-pop .am-kind { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 0 0 4px; }
.am-pop dl { display: grid; grid-template-columns: auto 1fr; gap: 1px 10px; margin: 6px 0; }
.am-pop dt { color: var(--muted); }
.am-pop dd { margin: 0; overflow-wrap: anywhere; }
.am-pop p { margin: 4px 0; }
.am-pop .am-text { white-space: pre-line; max-height: 180px; overflow-y: auto; font-size: 12.5px; padding: 4px 6px; background: var(--tag); border-radius: 6px; }
.am-pop img, .am-pop video { display: block; width: 100%; height: auto; min-height: 60px; border-radius: 6px; background: #000; margin: 6px 0; }
.am-pop a { font-weight: 600; }
.am-pop button { font: inherit; font-size: 12.5px; padding: 4px 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--tag); color: var(--fg); cursor: pointer; }
.am-pop .am-sign { white-space: pre-line; text-align: center; font: 700 13px/1.35 ui-monospace, Consolas, monospace; letter-spacing: 0.05em; color: #ffb000; background: #111; padding: 8px; border-radius: 4px; margin: 6px 0; }
.am-pop ul { margin: 4px 0; padding-left: 16px; font-size: 12.5px; }
.am-more { font-size: 12px; color: var(--muted); margin-top: 6px; }

.maplibregl-ctrl-group { background: var(--bg); }
@media (prefers-color-scheme: dark) {
  .maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1); }
  .maplibregl-ctrl-attrib { background: rgba(20, 20, 20, 0.7) !important; color: #ccc; }
  .maplibregl-ctrl-attrib a { color: #ccc; }
}

@media (max-width: 760px) {
  #am-panel { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-width: none; height: 58%; border-radius: 12px 12px 0 0; }
  #am-open { top: auto; bottom: 34px; left: 50%; transform: translateX(-50%); }
  header.site.full { padding-top: 8px; padding-bottom: 6px; }
}
