/* Copyright (c) 2025-2026 Tahseen Huda / Ooua */
/* The app's own rules. Loaded after tokens.css and components.css; every size, space and colour is a token, nothing is a literal here. */
:root { --side: 440px; }
html, body { height: 100%; }
body { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto auto minmax(0, 1fr); height: 100dvh; overflow: hidden; }
#bar, #compact, #near, #filters, main { min-width: 0; }
#bar { grid-row: 1; } #compact { grid-row: 2; } #near { grid-row: 3; } #filters { grid-row: 4; } main { grid-row: 5; }
#tabs button:focus-visible, .chip:focus-visible, #window label:focus-within { outline: 2px solid var(--focus); outline-offset: 1px; box-shadow: 0 0 0 4px var(--bg); }
.rows .row:focus-visible { outline-offset: -2px; box-shadow: none; }

/* the app's secondary buttons share the .btn look (components.css) */
#compact button, #loc-btn, #loc-pop .row button, #pin-here, #layers-toggle, #company-btn, .more, #tabs #sources-btn, #theme-btn {
  border: var(--border); background: var(--bg); color: var(--fg); border-radius: var(--r-md); padding: 0 var(--s3); min-height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: var(--s1); }
#compact button:hover, #loc-btn:hover, #pin-here:hover, #layers-toggle:hover, .more:hover, #tabs #sources-btn:hover, #theme-btn:hover { background: var(--bg-soft); }

/* header: brand, the view tabs, Sources, theme */
#bar { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s3); border-bottom: var(--border); background: var(--bg); }
#brand { display: flex; flex-direction: column; line-height: var(--lh-tight); min-width: 0; flex: 1 1 auto; }
#brand h1 { font-size: var(--fs-lead); margin: 0; white-space: nowrap; }
#brand .muted { overflow-wrap: anywhere; }
#tabs { display: flex; align-items: center; gap: var(--s1); margin-left: auto; min-width: 0; flex: 0 1 auto; position: relative; }
#tablist { display: flex; gap: var(--s1); min-width: 0; overflow-x: auto; scrollbar-width: none; scroll-behavior: smooth; }
#tablist::-webkit-scrollbar { display: none; }
/* when the tabs really do overflow, JS sets data-more on #tabs: the list fades out at its right edge and a chevron shows */
#tabs[data-more] #tablist { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
#tabs[data-more]::before { content: '›'; position: absolute; right: 116px; top: 50%; transform: translateY(-50%); color: var(--fg); font-size: var(--fs-title); line-height: var(--lh-tight); pointer-events: none; z-index: 1; }
#tabs [role=tab] { white-space: nowrap; flex: 0 0 auto; min-height: 36px; border: 0; background: transparent; padding: 0 var(--s3); border-radius: var(--r-md); color: var(--fg-muted); font-weight: var(--fw-bold); }
#tabs [role=tab].on { background: var(--fg); color: var(--bg); }
#tabs [role=tab] .short { display: none; }
#tabs #sources-btn, #theme-btn { flex: 0 0 auto; }
#tabs #sources-btn[aria-expanded="true"] { background: var(--bg-soft); border-color: var(--fg); }

/* compact row (phones only): location + radius on the left, a Filters disclosure on the right */
#compact { display: none; align-items: stretch; gap: var(--s2); padding: var(--s1) var(--s2); border-bottom: var(--border); background: var(--bg-soft); }
#compact-loc { flex: 1 1 auto; min-width: 0; justify-content: flex-start; }
#compact-loc::before { content: "📍"; flex: 0 0 auto; }
#compact-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
#compact-radius, #compact-filters { flex: 0 0 auto; }
#compact-filters::after { content: "▾"; color: var(--fg-muted); }
#compact-filters[aria-expanded="true"]::after { content: "▴"; }
#compact-counts { display: inline-block; min-width: 5em; text-align: left; }  /* reserved, so the button does not grow when the count arrives */
#compact-counts:not(:empty)::before { content: "· "; }

/* near me */
#near { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s3); border-bottom: var(--border); background: var(--bg-soft); position: relative; }
#loc-btn { max-width: 60%; justify-content: flex-start; }
#loc-btn::before { content: "📍"; flex: 0 0 auto; }
#loc-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
#radius-wrap { display: flex; align-items: center; gap: var(--s2); flex: 1 1 0; min-width: 0; min-height: 36px; }
#radius { flex: 1 1 0; min-width: 0; width: 100%; margin: 0; accent-color: var(--fg); }
#radius-label { min-width: 44px; text-align: right; font-variant-numeric: tabular-nums; }
#loc-pop { position: absolute; top: 100%; left: var(--s3); right: var(--s3); z-index: 20; background: var(--bg); border: var(--border); border-radius: var(--r-md); padding: var(--s3); box-shadow: var(--shadow); }
#loc-pop .row { display: flex; gap: var(--s2); margin-top: var(--s2); }
#loc-pop .row button { flex: 1; }
#loc-results, #street-results { list-style: none; margin: var(--s1) 0 0; padding: 0; max-height: 40vh; overflow: auto; border: var(--border); border-radius: var(--r-md); background: var(--bg); }
#loc-results li, #street-results li { padding: 0; margin: 0; }
#loc-results button, #street-results button { width: 100%; text-align: left; border: 0; background: none; padding: var(--s2) var(--s3); min-height: 40px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; gap: var(--s2); border-radius: var(--r-sm); }
#loc-results button:hover, #street-results button:hover, li.active > button { background: var(--bg-soft); }

/* filters */
#filters { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s3); padding: var(--s2) var(--s3); border-bottom: var(--border); background: var(--bg); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.chip { border: var(--border); background: var(--bg); border-radius: var(--r-pill); padding: 0 var(--s3); min-height: 32px; font-size: var(--fs-small); color: var(--fg-muted); display: inline-flex; align-items: center; gap: var(--s1); }
.chip i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; opacity: .35; background: var(--c); }
.chip i.ring { border: 2px solid var(--dev); background: transparent; width: 8px; height: 8px; }
.chip.on { color: var(--fg); border-color: var(--fg); }
.chip.on i { opacity: 1; }
#filters select { border: var(--border); border-radius: var(--r-pill); padding: 0 var(--s2); min-height: 32px; font-size: var(--fs-small); background: var(--bg); color: var(--fg); }
html.nofilters #filters, html.nofilters #compact-filters { display: none !important; }
/* the live counts get a line of their own, present from first paint, so filling them moves nothing */
#counts { flex: 1 0 100%; min-height: 18px; }

/* sign-up: .signup in components.css; the app's box also carries the "Browse by page" and privacy notes */
.privacy { margin-top: var(--s3); }

/* views */
main { position: relative; overflow: hidden; }
.view { display: none; position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; padding: var(--s2) var(--s3) var(--s5); }
.view.on { display: block; }
#view-map { padding: 0; }
.viewhead { display: flex; align-items: baseline; gap: var(--s2); min-height: 32px; }
.viewhead h2 { margin: var(--s1) 0; font-size: var(--fs-lead); white-space: nowrap; }
.viewhead .muted { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* the list area is reserved before the rows arrive, so the sign-up box never jumps */
#new-wrap { min-height: calc(100dvh - 200px); }  /* taller than the first screen, so the sign-up box is below the fold until the rows arrive */

/* rows: each is a real button (address + value) with a descriptive line under it; the whole row is clickable too */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: block; padding: var(--s2) 0; border-bottom: var(--border); cursor: pointer; }
.rows li.skel { height: 60px; position: relative; cursor: default; }
.rows li.skel::before, .rows li.skel::after { content: ''; position: absolute; left: 0; height: 12px; border-radius: var(--r-sm); background: var(--bg-soft); }
.rows li.skel::before { top: var(--s3); width: 55%; } .rows li.skel::after { top: var(--s6); width: 80%; height: 8px; }
.rows .row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s1) var(--s2); align-items: start; width: 100%; min-height: 24px; text-align: left; border: 0; background: none; padding: 0; margin: 0; color: inherit; font: inherit; border-radius: var(--r-sm); cursor: pointer; }
.rows .a { font-weight: var(--fw-bold); min-width: 0; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.rows .v { font-weight: var(--fw-bold); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; align-self: start; }
.rows .v.nd { color: var(--fg-muted); font-weight: var(--fw-normal); font-style: italic; }
.rows .v.st { font-weight: var(--fw-normal); color: var(--fg); }
.rows .m { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s2); align-items: center; margin-top: var(--s1); font-size: var(--fs-small); color: var(--fg-muted); }
.rows .m > span:not(.tag) { min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.rows .m a { color: var(--link); text-decoration: none; display: inline-flex; align-items: center; min-height: 24px; }  /* a 24px tap target */
.rows .m a:hover, .rows .m a:focus-visible { text-decoration: underline; }

/* pipeline groups */
.group h3, h3.sub, #panel h3, #sources h3 { font-size: var(--fs-small); text-transform: uppercase; letter-spacing: .06em; color: var(--fg-muted); margin: var(--s4) 0 var(--s1); }
.group h3 { display: flex; justify-content: space-between; }

/* street */
#street-input { margin: var(--s1) 0; }
.companies { margin: var(--s2) 0; padding: 0; list-style: none; }
.companies li, .companies .row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s2); }
.companies li { padding: var(--s1) 0; border-bottom: var(--border); }
.companies .row { width: 100%; min-height: 28px; text-align: left; border: 0; background: none; padding: 0; margin: 0; color: inherit; font: inherit; border-radius: var(--r-sm); cursor: pointer; }
.companies .row:hover span:first-child { text-decoration: underline; }
.companies li > span:first-child, .companies .row > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.companies .muted { flex: 0 0 auto; white-space: nowrap; }
.more { margin: var(--s2) 0; }

/* map */
#map { position: absolute; inset: 0; }
/* tools and hint stack in one column so they can never overlap; on phones the layer controls fold into a menu */
#map-top { position: absolute; top: var(--s2); left: var(--s2); right: var(--s2); z-index: 4; display: flex; flex-direction: column; align-items: center; gap: var(--s1); pointer-events: none; }
#map-top > * { pointer-events: auto; }
#map-tools { align-self: stretch; display: flex; flex-wrap: wrap; gap: var(--s1) var(--s2); align-items: center;
  background: var(--bg-glass); border: var(--border); border-radius: var(--r-md); padding: var(--s1) var(--s2); font-size: var(--fs-small); max-width: 720px; margin: 0 auto; }
#layers { display: contents; }
#layers-toggle { display: none; }
#map-tools label { display: inline-flex; align-items: center; gap: var(--s1); min-height: 28px; padding: 0 var(--s1); }
#map-tools input[type=checkbox] { margin: 0; width: 16px; height: 16px; accent-color: var(--fg); }
#window { display: inline-flex; border: var(--border); border-radius: var(--r-md); overflow: hidden; }
#window label { padding: 0 var(--s2); min-height: 28px; display: inline-flex; align-items: center; }
#window label:first-child { border-right: var(--border); }
#window input { position: absolute; opacity: 0; width: 1px; height: 1px; }
#window label:has(input:checked) { background: var(--fg); color: var(--bg); }
#pin-here, #layers-toggle { min-height: 28px; padding: 0 var(--s2); font-size: var(--fs-small); }
#layers-toggle { margin-left: 0; }
#layers-toggle::after { content: " ▾"; color: var(--fg-muted); }
#layers-toggle[aria-expanded="true"]::after { content: " ▴"; }
/* highlight mode (Phase 13): the bar under the tools names the company/companies; the Company popover is a search */
#hl-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s1) var(--s2); max-width: 100%; }
.hl-chip { display: inline-flex; align-items: center; gap: var(--s1); background: var(--bg-glass); border: var(--border); border-radius: var(--r-pill); padding: 0 var(--s1) 0 var(--s2); min-height: 32px; font-size: var(--fs-small); max-width: 100%; }
.hl-chip i { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; background: var(--hl-a); }
.hl-chip.b i { background: var(--hl-b); }
.hl-chip .hl-open { border: 0; background: none; color: var(--fg); font-weight: var(--fw-bold); padding: 0; min-height: 24px; text-decoration: underline; text-decoration-color: var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.hl-chip .muted { white-space: nowrap; }
.hl-chip .hl-x { border: 0; background: none; color: var(--fg); width: 28px; min-height: 28px; border-radius: 50%; font-size: var(--fs-lead); padding: 0; }
.hl-chip .hl-x:hover { background: var(--bg-soft); }
#hl-bar #hl-fit { min-height: 32px; font-size: var(--fs-small); background: var(--bg-glass); }
@media (max-width: 599px) { #hl-bar > .muted { display: none; } }
#company-btn { margin-left: auto; min-height: 28px; padding: 0 var(--s2); font-size: var(--fs-small); }
#company-btn[aria-expanded="true"] { background: var(--bg-soft); border-color: var(--fg); }
#company-pop { flex: 1 0 100%; order: 5; background: var(--bg); border: var(--border); border-radius: var(--r-md); padding: var(--s2); margin-top: var(--s1); }
#company-pop .note { margin: var(--s1) 0 0; }
.rows .m .linkish, .linkish { border: 0; background: none; color: var(--link); padding: 0; min-height: 24px; font: inherit; font-size: var(--fs-small); text-decoration: underline; text-decoration-color: var(--line); cursor: pointer; }
#hint { background: var(--fg); color: var(--bg); opacity: .88; font-size: var(--fs-small); line-height: var(--lh-tight); padding: var(--s1) var(--s2); border-radius: var(--r-md); pointer-events: none; max-width: 100%; text-align: center; }
#legend { position: absolute; left: var(--s2); bottom: var(--s6); z-index: 4; background: var(--bg-glass); border: var(--border); border-radius: var(--r-md); padding: 0 var(--s2); font-size: var(--fs-small); line-height: var(--lh-body); }
#legend-toggle { display: block; border: 0; background: none; padding: var(--s1) 0; min-height: 28px; font-weight: var(--fw-bold); font-size: var(--fs-small); width: 100%; text-align: left; color: var(--fg); }
#legend-toggle::after { content: ' ▸'; }
#legend-toggle[aria-expanded="true"]::after { content: ' ▾'; }
#legend-body { padding-bottom: var(--s1); }
#legend .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: var(--s1); vertical-align: -1px; background: var(--c); }
#legend .dot.small { width: 6px; height: 6px; }  /* the common type is drawn small on the map; the legend says so */
#legend .ring { border: 2px solid var(--c); background: transparent; }
#legend .cluster { width: 16px; height: 16px; background: var(--fg-muted); color: var(--bg); font-style: normal; font-size: 9px; line-height: 16px; text-align: center; }
#legend .hl-a, #legend .hl-b { background: var(--c); }
#legend .hl-b { margin-left: calc(-1 * var(--s1)); }
#legend .sep { height: 1px; background: var(--line); margin: var(--s1) 0; }
.maplibregl-ctrl-attrib { font-size: var(--fs-small); }
.maplibregl-ctrl-bottom-right { max-width: 60vw; }
/* MapLibre's own controls in the theme's surface colours */
.maplibregl-ctrl-group, .maplibregl-ctrl-attrib.maplibregl-compact { background: var(--bg-glass) !important; color: var(--fg); }
.maplibregl-ctrl-group button + button { border-top-color: var(--line) !important; }
.maplibregl-ctrl-attrib a { color: var(--link); }
:root[data-theme="dark"] .maplibregl-ctrl button .maplibregl-ctrl-icon { filter: invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .maplibregl-ctrl button .maplibregl-ctrl-icon { filter: invert(1); } }
/* the location marker: a small ring, so the data under it stays visible */
.pin-ring { width: 14px; height: 14px; border-radius: 50%; border: 2.5px solid var(--fg); background: transparent; box-shadow: 0 0 0 2px var(--bg); cursor: default; }

/* detail + sources panels (dialogs): a bottom sheet on phones, a side panel beside the map from tablets up */
#panel, #sources { position: fixed; z-index: 30; background: var(--bg); overflow: auto; padding: var(--s4) var(--s4) var(--s5); box-shadow: var(--shadow);
  left: 0; right: 0; bottom: 0; height: 70dvh; border-top: var(--border); border-radius: var(--r-md) var(--r-md) 0 0; }
#panel:focus, #sources:focus { outline: none; }
#panel-close, #sources-close { position: absolute; top: var(--s2); right: var(--s2); width: 36px; height: 36px; padding: 0; border: 0; border-radius: var(--r-md); background: transparent; font-size: var(--fs-title); line-height: var(--lh-tight); color: var(--fg); }
#panel-close:hover, #sources-close:hover { background: var(--bg-soft); }
#panel h2, #sources h2 { margin: 0 var(--s6) var(--s1) 0; font-size: var(--fs-title); overflow-wrap: anywhere; }
.kind { display: inline-block; font-size: var(--fs-small); line-height: var(--lh-tight); padding: var(--s1) var(--s2); border-radius: var(--r-sm); background: var(--bg-soft); color: var(--fg); margin-bottom: var(--s2); }
dl { margin: 0; display: grid; grid-template-columns: minmax(96px, 150px) minmax(0, 1fr); gap: var(--s1) var(--s2); }
dt { color: var(--fg-muted); overflow-wrap: break-word; hyphens: auto; }
dd { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
dd.nd { color: var(--fg-muted); font-style: italic; }
dd a, .src a { color: var(--link); }
details { margin-top: var(--s2); font-size: var(--fs-small); }
details summary { cursor: pointer; color: var(--fg-muted); padding: var(--s1) 0; min-height: 24px; }
details pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: var(--fs-small); background: var(--bg-soft); padding: var(--s2); border-radius: var(--r-sm); margin: var(--s2) 0 0; }
.src { font-size: var(--fs-small); margin: var(--s1) 0; }
.types .tr { display: grid; grid-template-columns: 10px 110px 1fr 36px; align-items: center; gap: var(--s2); font-size: var(--fs-small); margin: var(--s1) 0; }
.types i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--c); }
.types .tb { height: 8px; background: var(--bg-soft); border-radius: var(--r-sm); overflow: hidden; }
.types .tb span { display: block; height: 100%; background: var(--c); }
.types .tn { text-align: right; font-variant-numeric: tabular-nums; }
#sources ul { padding-left: var(--s4); margin: var(--s1) 0; }
#sources p { margin: var(--s2) 0; }
.stat { font-variant-numeric: tabular-nums; }
.tscroll { overflow-x: auto; margin: var(--s2) 0; -webkit-overflow-scrolling: touch; }
.tt { border-collapse: collapse; font-size: var(--fs-small); margin: 0; width: 100%; }
.tt th, .tt td { padding: var(--s1); text-align: right; border-bottom: var(--border); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tt th:first-child, .tt td:first-child { text-align: left; }

/* tablets and up: two columns — list left, map right — the map always on, the panels beside it (no magic header height: they are grid items) */
@media (min-width: 768px) {
  :root { --side: 360px; }
  body { grid-template-columns: var(--side) minmax(0, 1fr); }
  #bar { grid-column: 1 / -1; }
  #compact { display: none; }
  #near, #filters { grid-column: 1; }
  main { display: contents; }
  .view { position: relative; grid-column: 1; grid-row: 5; min-height: 0; border-right: var(--border); }
  #view-map { display: block !important; grid-column: 2; grid-row: 2 / 6; border: 0; overflow: hidden; }
  #tabs .map-tab { display: none; }
  #panel, #sources { position: relative; grid-column: 2; grid-row: 2 / 6; justify-self: end; z-index: 30; width: min(400px, 100%); height: auto; left: auto; right: auto; bottom: auto;
    border-radius: 0; border-left: var(--border); border-top: 0; }
}
@media (min-width: 1100px) {
  :root { --side: 440px; }
  #brand h1 { font-size: var(--fs-lead); }
}
/* the brand line needs ~1100px beside the tabs; below that it goes, so the tabs never clip */
@media (max-width: 1099px) {
  #brand .muted { display: none; }
}
@media (max-width: 767px) {
  #bar { padding: var(--s1) var(--s2); }
  #brand h1 { font-size: var(--fs-body); }
  #tabs [role=tab] { padding: 0 var(--s2); }
  #compact { display: flex; }
  /* the near-me bar and the filters are folded into #compact until tapped */
  #near, #filters { display: none; }
  body.controls-open #near { display: flex; }
  html:not(.nofilters) body.controls-open #filters { display: flex; }
  #near { padding: var(--s2); }
  #filters { padding: var(--s2); gap: var(--s2); }
  .view { padding: var(--s2) var(--s3) var(--s5); }
}
/* phones: the layer checkboxes fold into a Layers menu so the tools box is one row */
@media (max-width: 599px) {
  #map-tools { padding: var(--s1) var(--s2); gap: var(--s1) var(--s2); }
  #layers-toggle { display: inline-flex; align-items: center; }
  #layers { display: none; }
  #layers.open { display: flex; flex-direction: column; align-items: flex-start; gap: var(--s1); flex: 1 0 100%; order: 3; padding: var(--s1) 0; border-top: var(--border); margin-top: var(--s1); }
  #layers.open label { min-height: 32px; }
  #layers.open #window { margin: var(--s1) 0 var(--s1) var(--s5); }
  #window label { min-height: 28px; display: inline-flex; align-items: center; }
}
/* phones under 480 px: still one header row — the tabs show their short labels ("New" for "What's new"; measured: the long
   label overflows by 16–68 px between 320 and 479 px, the short one fits from 375 up and scrolls 12–46 px at 320–360) */
@media (max-width: 479px) {
  #bar { gap: var(--s1); }
  #tabs { gap: var(--s1); }
  #tablist { gap: 0; }
  #tabs [role=tab] { padding: 0 var(--s2); font-size: var(--fs-small); min-height: 32px; }
  #tabs [role=tab] .long { display: none; }
  #tabs [role=tab] .short { display: inline; }
  #tabs #sources-btn, #theme-btn { min-height: 32px; padding: 0 var(--s2); font-size: var(--fs-small); }
  #theme-btn { width: 32px; padding: 0; }
}
@media (max-width: 369px) {
  #tabs [role=tab], #tabs #sources-btn { padding: 0 var(--s1); }
  #theme-btn { width: 28px; }
}
