/* Styles shared by / and /power-cuts: the page switcher and the power cut map
   (see pcut-map.js). One copy, so the pages cannot drift apart. Each page sets
   its own #map height, and colours come from each page's own tokens. */

/* ---- page switcher: Overview · Power cuts ---- */
.views { display: flex; gap: 4px; margin: -6px 0 18px; flex-wrap: wrap; }
.views a {
  border: 1px solid var(--line); color: var(--text-dim); text-decoration: none;
  font-size: 0.86rem; font-weight: 600; padding: 6px 14px; border-radius: 999px;
}
.views a:hover { color: var(--text-hi); border-color: var(--text-dim); }
.views a[aria-current="page"] { color: var(--text-hi); border-color: var(--text-dim); background: var(--panel); }
.views a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- map ---- */
.map-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px 16px; margin-bottom: 12px; }
.map-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.map-head h2 {
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--text-hi); margin: 0; flex: 1 1 auto;
}
.layers { display: flex; gap: 4px; flex-wrap: wrap; }
.layer-btn {
  appearance: none; border: 1px solid var(--line); background: transparent;
  color: var(--text-dim); font: inherit; font-size: 0.78rem; font-weight: 600;
  padding: 5px 11px; border-radius: 999px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.layer-btn:hover { color: var(--text-hi); border-color: var(--text-dim); }
.layer-btn[aria-pressed="true"] { color: var(--text-hi); border-color: var(--text-dim); background: var(--bg); }
.layer-btn .dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; opacity: .45; }
.layer-btn[aria-pressed="true"] .dot { opacity: 1; }
.layer-btn:focus-visible { outline: 2px solid var(--series); outline-offset: 2px; }

.leaflet-container { background: var(--bg); font: inherit; }

.legend { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; font-size: 0.74rem; color: var(--text-dim); }
.scale { display: flex; align-items: center; gap: 0; }
.scale i { width: 30px; height: 10px; display: block; }
.scale i:first-child { border-radius: 3px 0 0 3px; }
.scale i:last-child { border-radius: 0 3px 3px 0; }
.legend .k { display: inline-flex; align-items: center; gap: 5px; }
.legend .k b { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.legend-lbl { color: var(--text); font-weight: 650; }
/* Power cut help. Deliberately var(--text) not var(--text-dim): someone reading
   this may be sitting in the dark on a phone, and it is the one thing on the
   page that is genuinely useful in that moment. */
.pc-help { margin: 12px 0 0; padding-top: 11px; border-top: 1px solid var(--line); font-size: 0.78rem; line-height: 1.6; color: var(--text); }
/* Stale-DNO note. Amber and the .stale colour deliberately, because this is the
   same "this figure is older than it looks" convention the grid tiles use, not
   a new kind of warning. It sits above the map so it is read before the
   markers, not after. */
.stale-note { margin: 0 0 10px; padding: 9px 12px; border: 1px solid var(--amber); border-radius: 6px; font-size: 0.79rem; line-height: 1.55; color: var(--text); background: rgba(201,145,61,0.09); }
.stale-note strong { color: var(--amber); font-weight: 700; }
.pc-help strong { color: var(--text-hi); font-weight: 700; }
.pc-help .pc-999 { color: var(--text-dim); }

.leaflet-popup-content-wrapper { background: var(--panel); color: var(--text); border-radius: 8px; border: 4px solid transparent; }
/* Never let a popup grow wider than the map. max-width overrides the inline
   width Leaflet sets after measuring, so the value wins; --popup-max is kept in
   step with the map by syncPopupMax() in pcut-map.js. */
.leaflet-popup-content { max-width: var(--popup-max, 300px); max-height: var(--popup-max-h, none); overflow-y: auto; }
.leaflet-popup-tip { background: var(--panel); }
/* Faded by syncZoomFade() (pcut-map.js) while an open popup sits underneath. visibility
   follows the fade, so the hidden buttons also leave the tab order. */
.leaflet-control-zoom { transition: opacity 0.2s ease, visibility 0s linear 0s; }
.leaflet-control-zoom.zoom-faded { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.2s ease, visibility 0s linear 0.2s; }
.popup-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.popup-dno { font-weight: 700; font-size: 0.95rem; color: var(--text-hi); }
.popup-divider { border: none; border-top: 1px solid var(--line); margin: 6px 0; }
.popup-row { display: flex; justify-content: space-between; gap: 16px; font-size: 0.88rem; margin: 3px 0; }
.popup-label { color: var(--text-dim); flex-shrink: 0; }
.popup-ref { font-size: 0.68rem; color: var(--text-dim); margin-top: 6px; }
/* "and N more listed" in a popup's Location, opening to the rest (pcut-map.js locationHtml). */
.popup-more summary { cursor: pointer; color: var(--accent); list-style: none; }
.popup-more summary::-webkit-details-marker { display: none; }
.popup-more summary::after { content: ' \25B8'; }
.popup-more[open] summary::after { content: ' \25BE'; }
.popup-more summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.popup-more-list { max-height: 8.5em; overflow-y: auto; margin-top: 3px; }
.popup-badge { display: inline-block; padding: 1px 7px; border-radius: 8px; font-size: 0.7rem; font-weight: 600; }
.badge-unplanned { background: #c62828; color: #fff; }
.badge-planned { background: #e65100; color: #fff; }
.popup-approx { font-size: 0.68rem; color: var(--text-dim); margin-top: 4px; font-style: italic; }

/* ---- map postcode search ---- */
.map-search { display: flex; align-items: center; gap: 5px; }
.map-search input {
  padding: 5px 9px; background: var(--bg); color: var(--text-hi);
  border: 1px solid var(--line); border-radius: 7px; font: inherit;
  font-size: 0.78rem; width: 110px; outline: none;
}
/* iOS Safari zooms the page in when a text box under 16px is focused, and
   leaves it zoomed after the search, so the page sat shifted sideways until
   pinched back. 16px on touch screens stops that without disabling zoom. */
@media (pointer: coarse) { .map-search input { font-size: 16px; } }
.map-search input::placeholder { color: var(--text-dim); }
.map-search input:focus { border-color: var(--text-dim); }
.search-go {
  padding: 5px 10px; background: var(--accent); color: #fff;
  border: none; border-radius: 7px; font: inherit; font-size: 0.78rem;
  font-weight: 600; cursor: pointer;
}
.search-go:hover { opacity: 0.85; }
.search-go:disabled { opacity: 0.5; cursor: default; }
.search-loc {
  padding: 4px 7px; background: transparent; color: var(--text-dim);
  border: 1px solid var(--line); border-radius: 7px; cursor: pointer;
  font-size: 1.1rem; line-height: 1; display: flex; align-items: center;
}
.search-loc:hover { color: var(--text-hi); border-color: var(--text-dim); }
.search-loc:disabled { opacity: 0.5; cursor: default; }

/* ---- power-cut cluster markers ---- */
.cluster-bubble {
  border-radius: 50%; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  border: 2px solid rgba(255,255,255,0.45);
  box-shadow: 0 2px 8px rgba(0,0,0,.28);
}
.cluster-count { font-weight: 700; font-size: 0.82rem; color: #fff; line-height: 1.1; }
.cluster-cust  { font-size: 0.62rem; color: rgba(255,255,255,0.8); line-height: 1.1; }
/* An outage dot is 9-15px across, well under the ~44px a fingertip needs, so on
   touch devices the icon box is padded out around a dot of unchanged size. Same
   idea as the fat transparent line drawn over each interconnector. */
.pcut-hit { display: flex; align-items: center; justify-content: center; background: none; border: 0; }
.pcut-dot { display: block; border-radius: 50%; border: 1px solid #fff; box-sizing: border-box; }

/* ---- outage unplanned/all filter (shown below layer toggles) ---- */
.pcut-filter { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pcut-filter span { font-size: 0.72rem; color: var(--text-dim); margin-right: 3px; }
.filter-mini {
  appearance: none; border: 1px solid var(--line); background: transparent;
  color: var(--text-dim); font: inherit; font-size: 0.74rem; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; cursor: pointer;
}
.filter-mini:hover { color: var(--text-hi); border-color: var(--text-dim); }
.filter-mini.active { color: var(--text-hi); border-color: var(--text-dim); background: var(--bg); }

/* ---- affected area (pcut-map.js showAffectedArea) ---- */
.popup-show-area {
  display: block; margin-top: 8px; padding: 4px 0; background: none; border: 0;
  font: inherit; font-size: 0.82rem; font-weight: 600; color: var(--accent); cursor: pointer;
}
.popup-show-area:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.area-label {
  display: flex; align-items: center; gap: 8px;   /* max-width set from the map in pcut-map.js */
  padding: 5px 6px 5px 10px; background: var(--panel); color: var(--text-hi);
  border: 1px solid var(--line); border-radius: 8px; font-size: 0.78rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}
.area-label-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.area-label-text { line-height: 1.25; }   /* wraps on a phone rather than cutting the count off */
.area-label-btn {
  flex-shrink: 0; min-height: 28px; padding: 2px 9px; font: inherit; font-size: 0.78rem;
  background: var(--bg); color: var(--text-hi); border: 1px solid var(--line); border-radius: 6px; cursor: pointer;
}
.area-label-x { padding: 2px 8px; font-size: 1rem; line-height: 1; }
.area-label-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
