/* Full-screen map with a title badge, theme and overlay controls, and an area details card.
   The theme comes from the data-theme attribute on <html>, which main.js sets.
   It follows the system setting unless the visitor picks one. System font stack: no web fonts. */

:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --panel-bg: rgba(255, 255, 255, 0.86);
  --panel-text: #1d1d1f;
  --panel-border: rgba(0, 0, 0, 0.1);
  --panel-muted: rgba(29, 29, 31, 0.6);
  --button-bg: #1d1d1f;
  --button-text: #ffffff;
  --button-idle: rgba(0, 0, 0, 0.06);
  --bar: #f03b20;
  --focus: #4285f4;
  --error: #b3261e;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --panel-bg: rgba(28, 30, 34, 0.84);
  --panel-text: #f5f5f7;
  --panel-border: rgba(255, 255, 255, 0.14);
  --panel-muted: rgba(245, 245, 247, 0.6);
  --button-bg: #f5f5f7;
  --button-text: #1d1d1f;
  --button-idle: rgba(255, 255, 255, 0.08);
  --error: #f2b8b5;
}

html,
body {
  height: 100%;
  margin: 0;
  background: #17191c;
}

#map {
  position: fixed;
  inset: 0;
}

.title-badge,
.search-panel,
.overlay-panel,
.detail-card {
  position: fixed;
  z-index: 1;
  border-radius: 12px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  color: var(--panel-text);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.search-panel {
  top: 72px;
  left: 16px;
  width: min(320px, calc(100vw - 32px));
  padding: 10px 12px;
}

.title-badge {
  top: 16px;
  left: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 8px 14px;
}

.title-badge h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.overlay-panel {
  left: 16px;
  bottom: 16px;
  width: min(340px, calc(100vw - 32px));
  padding: 12px 14px;
}

.detail-card {
  top: 16px;
  right: 16px;
  width: min(360px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 14px 16px;
}

.overlay-header,
.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

button {
  font: inherit;
  cursor: pointer;
}

#theme-toggle,
#overlay-toggle,
#search-submit {
  font-size: 13px;
  padding: 6px 12px;
  border: 0;
  border-radius: 8px;
  background: var(--button-bg);
  color: var(--button-text);
}

#detail-close,
#search-clear {
  flex: none;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: var(--button-idle);
  color: var(--panel-text);
  font-size: 18px;
  line-height: 1;
}

button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.overlay-panel[hidden],
#overlay-body[hidden],
.detail-card[hidden] {
  display: none;
}

.status {
  margin: 10px 0 0;
  font-size: 13px;
  opacity: 0.8;
}

.status.error {
  color: var(--error);
  opacity: 1;
}

.search-row {
  display: flex;
  gap: 6px;
}

#postcode-input {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  background: var(--button-idle);
  color: var(--panel-text);
  font: inherit;
  font-size: 14px;
}

#postcode-input::placeholder {
  color: var(--panel-muted);
}

.pin {
  width: 24px;
  height: 34px;
  pointer-events: none;
}

.pin svg {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.35));
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.window-control {
  display: flex;
  gap: 4px;
  margin-top: 12px;
  padding: 3px;
  border-radius: 10px;
  background: var(--button-idle);
}

.dataset-control {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 3px;
  border-radius: 10px;
  background: var(--button-idle);
}

/* The dataset picker: a native select, styled to match the button rows. */
#dataset-select {
  flex: 1;
  min-width: 0;
  padding: 6px 8px;
  border: 0;
  border-radius: 7px;
  background: var(--button-bg);
  color: var(--button-text);
  font: inherit;
  font-size: 13px;
}

.dataset-control .control-label {
  padding-left: 8px;
}

#dataset-select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

#noise-controls .window-control {
  margin-top: 8px;
}

/* Group pickers need more room than one row of the panel gives. */
.group-control {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
  padding: 3px;
  border-radius: 10px;
  background: var(--button-idle);
}

#group-options {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  gap: 4px;
}

.control-label {
  align-self: center;
  padding: 0 4px 0 8px;
  font-size: 13px;
  color: var(--panel-muted);
  white-space: nowrap;
}

#noise-threshold {
  display: flex;
  flex: 1;
  gap: 4px;
}

.noise-source,
.noise-metric,
.noise-threshold,
.group-button {
  flex: 1;
  padding: 6px 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--panel-text);
  font-size: 13px;
  white-space: nowrap;
}

.noise-source[aria-pressed="true"],
.noise-metric[aria-pressed="true"],
.noise-threshold[aria-pressed="true"],
.group-button[aria-pressed="true"] {
  background: var(--button-bg);
  color: var(--button-text);
}

.window-button {
  flex: 1;
  padding: 6px 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--panel-text);
  font-size: 13px;
}

.window-button[aria-pressed="true"] {
  background: var(--button-bg);
  color: var(--button-text);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  font-size: 12px;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid var(--panel-border);
}

.hint {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--panel-muted);
}

.detail-meta {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--panel-muted);
  font-variant-numeric: tabular-nums;
}

.detail-summary {
  margin: 12px 0 0;
  font-size: 14px;
}

.breakdown {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.breakdown li {
  margin-bottom: 10px;
}

.breakdown-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.breakdown-count {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.breakdown-bar {
  height: 6px;
  margin-top: 4px;
  border-radius: 3px;
  background: var(--button-idle);
  overflow: hidden;
}

.breakdown-bar span {
  display: block;
  height: 100%;
  background: var(--bar);
}
