/* stelfox design studio — monochromatic system
   Black #000000 · Structure Gray #A0A0A0 · White #FFFFFF
   The chrome stays monochrome; color is reserved for the data. */

:root {
  --black: #000000;
  --gray: #a0a0a0;
  --gray-2: #6b6b6b;
  --white: #ffffff;
  --hairline: #e4e4e4;
  --row-hover: #f2f2f2;
  --panel-w: 336px;
  font-size: 15px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  color: var(--black);
  background: var(--white);
}

body { display: flex; }

/* ---------- Sidebar ---------- */

#sidebar {
  width: var(--panel-w);
  flex: 0 0 var(--panel-w);
  height: 100%;
  overflow-y: auto;
  background: var(--white);
  border-right: 1px solid var(--black);
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.brand {
  padding: 26px 24px 22px;
  border-bottom: 1px solid var(--hairline);
}

.brand img {
  display: block;
  width: 39%;
  max-width: 125px;
  height: auto;
}

.brand a { display: block; }

.intro { padding: 22px 24px 8px; }

.intro h1 {
  margin: 0 0 10px;
  font-size: 1.42rem;
  line-height: 1.22;
  font-weight: 700;
  letter-spacing: -0.015em;
  text-transform: lowercase;
}

.intro p {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.55;
  font-weight: 300;
  color: var(--gray-2);
}

.panel-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px 4px;
}

#layer-count { font-size: 0.76rem; color: var(--gray); }

#clear-all {
  border: 1px solid var(--black);
  background: var(--white);
  color: var(--black);
  font: inherit;
  font-size: 0.76rem;
  letter-spacing: 0.02em;
  padding: 3px 12px;
  border-radius: 0;
  cursor: pointer;
}

#clear-all:hover { background: var(--black); color: var(--white); }

/* ---------- Layer list ---------- */

#layers { padding: 8px 16px 20px; flex: 1 0 auto; }

.group-title {
  margin: 18px 8px 6px;
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: lowercase;
  color: var(--gray);
}

.layer-row, .era-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  cursor: pointer;
  user-select: none;
}

.layer-row:hover, .era-head:hover { background: var(--row-hover); }

.layer-row input, .era-head input {
  accent-color: var(--black);
  width: 15px;
  height: 15px;
  margin: 0;
  flex: 0 0 auto;
  cursor: pointer;
}

.swatch {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  border-radius: 0;
}

.swatch.line { height: 4px; }

.swatch.dashed {
  height: 0;
  border-top: 3px dashed currentColor;
  background: none !important;
}

.layer-name { font-size: 0.86rem; line-height: 1.3; flex: 1 1 auto; }

.layer-name .era-year { color: var(--gray); font-size: 0.79rem; margin-left: 4px; }

.layer-row .spin, .era-head .spin {
  width: 12px; height: 12px;
  border: 2px solid var(--hairline);
  border-top-color: var(--black);
  border-radius: 50%;
  flex: 0 0 auto;
  animation: spin 0.8s linear infinite;
  visibility: hidden;
}

.loading > .spin { visibility: visible; }

@keyframes spin { to { transform: rotate(360deg); } }

.well-legend {
  margin: 0 0 4px 34px;
  border-left: 2px solid var(--hairline);
  padding-left: 4px;
}

.well-legend-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 3px 8px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
}

.well-legend-row:hover { background: var(--row-hover); }

.well-legend-row input {
  accent-color: var(--black);
  width: 13px;
  height: 13px;
  margin: 0;
  flex: 0 0 auto;
  cursor: pointer;
}

.well-legend-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 2px;
}

.well-filter-count {
  flex: 1 1 auto;
  font-size: 0.72rem;
  color: var(--ink-3);
}

.well-legend-actions button {
  border: 1px solid var(--hairline);
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-size: 0.72rem;
  padding: 2px 9px;
  border-radius: 999px;
  cursor: pointer;
}

.well-legend-actions button:hover { background: var(--row-hover); color: var(--ink); }

.well-legend-row .swatch { width: 10px; height: 10px; border-radius: 50%; }

.well-legend-row .layer-name { font-size: 0.8rem; color: var(--ink-2); }

.underlay-opacity { padding: 0 8px 4px 32px; }

.group-op { padding: 0 16px 4px 10px; }

/* ---------- Address search ---------- */

#search {
  position: fixed;
  top: 12px;
  left: calc(var(--panel-w) + 14px);
  z-index: 25;
  width: min(330px, 50vw);
}

#search-input {
  width: 100%;
  font: inherit;
  font-size: 0.88rem;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid #b9b2a2;
  border-radius: 10px;
  padding: 8px 12px;
  box-shadow: 0 3px 14px rgba(33, 29, 24, 0.22);
}

#search-input::placeholder { color: var(--ink-2); opacity: 1; }

#search-input:focus { outline: 2px solid var(--brand); outline-offset: 1px; }

#search-results {
  margin-top: 4px;
  background: #ffffff;
  border: 1px solid #b9b2a2;
  border-radius: 10px;
  box-shadow: 0 4px 18px rgba(33, 29, 24, 0.22);
  overflow: hidden;
}

.search-hit {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.84rem;
  color: var(--ink);
  padding: 7px 12px;
  cursor: pointer;
}

.search-hit:hover { background: var(--row-hover); }

@media (max-width: 760px) {
  #search { left: 12px; top: 58px; width: min(330px, calc(100vw - 24px)); }
}

.underlay-opacity input[type="range"] {
  width: 100%;
  accent-color: var(--black);
  height: 18px;
  cursor: pointer;
}

.era { margin: 1px 0; }

.era-caret {
  flex: 0 0 auto;
  width: 18px; height: 18px;
  display: grid;
  place-items: center;
  border: none;
  background: none;
  color: var(--gray);
  cursor: pointer;
  padding: 0;
}

.era-caret:hover { color: var(--black); }

.era-caret svg { transition: transform 0.15s ease; }

.era.open .era-caret svg { transform: rotate(90deg); }

.era-sub {
  display: none;
  margin: 0 0 2px 34px;
  border-left: 1px solid var(--gray);
  padding-left: 5px;
}

.era.open .era-sub { display: block; }

.era-sub .layer-row { padding: 4px 8px; }

.era-sub .layer-name { font-size: 0.82rem; font-weight: 300; color: var(--gray-2); }

/* ---------- Credits ---------- */

.credits {
  border-top: 1px solid var(--hairline);
  padding: 18px 24px 22px;
  font-size: 0.79rem;
  line-height: 1.55;
  font-weight: 300;
  color: var(--gray-2);
}

.credits h2 {
  margin: 0 0 8px;
  font-size: 0.7rem;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: lowercase;
  color: var(--gray);
}

.credits strong { color: var(--black); font-weight: 600; }

.credits a { color: var(--black); text-decoration-thickness: 1px; text-underline-offset: 2px; }

.credits ul { margin: 8px 0; padding-left: 18px; }

.credits li { margin: 3px 0; }

.citation { margin: 0; }

.fineprint { margin: 12px 0 0; font-size: 0.71rem; color: var(--gray); }

.fineprint a { color: var(--gray-2); }

/* ---------- Map ---------- */

#map { flex: 1 1 auto; height: 100%; min-width: 0; }

#panel-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 30;
  align-items: center;
  gap: 7px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--black);
  background: var(--white);
  border: 1px solid var(--black);
  border-radius: 0;
  padding: 8px 12px;
  cursor: pointer;
}

#panel-toggle:hover { background: var(--black); color: var(--white); }

/* Popup */

.maplibregl-popup-content {
  font-family: inherit;
  border-radius: 0;
  border: 1px solid var(--black);
  padding: 12px 16px 10px;
  box-shadow: none;
}

.popup-title { font-weight: 600; font-size: 0.92rem; margin: 0 12px 2px 0; }

.popup-meta { font-size: 0.79rem; font-weight: 300; color: var(--gray-2); margin: 2px 0 0; }

.popup-meta .dot {
  display: inline-block;
  width: 9px; height: 9px;
  margin-right: 5px;
}

.maplibregl-popup-anchor-bottom .maplibregl-popup-tip { border-top-color: var(--black); }
.maplibregl-popup-anchor-top .maplibregl-popup-tip { border-bottom-color: var(--black); }
.maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: var(--black); }
.maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: var(--black); }

/* ---------- Mobile ---------- */

@media (max-width: 760px) {
  #panel-toggle { display: inline-flex; }

  #sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(86vw, var(--panel-w));
    transform: translateX(-105%);
    transition: transform 0.22s ease;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.25);
  }

  body.panel-open #sidebar { transform: translateX(0); }
}
