:root {
  --bg: #ffffff;
  --chrome: #c0c0c0;
  --text: #000000;
  --text-dim: #444444;
  --border: #808080;
  --link: #0000ee;
  --link-visited: #551a8b;
  --grade: #006400;
  --bus: #8b4500;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  font-family: "Times New Roman", Times, serif;
  background: var(--chrome);
  color: var(--text);
}

a {
  color: var(--link);
}

a:visited {
  color: var(--link-visited);
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

#header {
  display: none;
}

#header h1 {
  margin: 0;
  font-size: 1.8rem;
  font-weight: bold;
}

.subtitle {
  margin: 0.2rem 0 0;
  color: var(--text-dim);
  font-size: 0.9rem;
  font-style: italic;
}

#controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.5rem 1rem;
  background: var(--chrome);
  border-bottom: 1px solid #000000;
  font-size: 0.85rem;
}

.control {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text);
}

.control select {
  background: #ffffff;
  color: var(--text);
  border: 2px outset #dfdfdf;
  border-radius: 0;
  padding: 0.2rem 0.3rem;
  font-family: "Times New Roman", Times, serif;
  font-size: 0.85rem;
}

.search-control {
  position: relative;
}

#search-input {
  width: 220px;
  background: #ffffff;
  color: var(--text);
  border: 2px inset #dfdfdf;
  border-radius: 0;
  padding: 0.25rem 0.4rem;
  font-family: "Times New Roman", Times, serif;
  font-size: 0.85rem;
}

#search-input:focus {
  outline: 1px dotted #000000;
}

#search-results {
  position: fixed;
  max-height: 320px;
  overflow-y: auto;
  background: #ffffff;
  border: 2px solid #000000;
  z-index: 100;
}

.search-result-item {
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover,
.search-result-item.active {
  background: #000080;
  color: #ffffff;
}

.search-result-item:hover .search-result-meta,
.search-result-item.active .search-result-meta {
  color: #d0d0ff;
}

.search-result-name {
  font-weight: bold;
  font-size: 0.9rem;
}

.search-result-meta {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-top: 0.1rem;
}

.search-no-results {
  padding: 0.5rem 0.6rem;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-style: italic;
}

.control.checkbox {
  cursor: pointer;
}

#stats {
  display: none;
}

#map-container {
  position: relative;
  flex: 1;
  min-height: 0;
  border-top: 1px solid #000000;
  border-bottom: 1px solid #000000;
}

#map {
  position: absolute;
  inset: 0;
  /* The fade slider drives the basemap's own layers (including its background)
     toward transparent, so whatever sits behind the canvas becomes the backdrop.
     White keeps a fully faded map clean rather than showing the page's grey. */
  background: #ffffff;
}

#fade-slider {
  width: 90px;
}

#legend {
  position: absolute;
  bottom: 20px;
  left: 8px;
  z-index: 5;
  background: #ffffff;
  border: 2px solid #000000;
  padding: 0.4rem 0.6rem;
  font-size: 0.75rem;
  line-height: 1.5;
  max-width: 170px;
}

.legend-title {
  display: block;
  width: 100%;
  font-family: inherit;
  font-size: inherit;
  font-weight: bold;
  text-decoration: underline;
  margin-bottom: 0.15rem;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.legend-caret {
  text-decoration: none;
  display: inline-block;
}

#legend.collapsed .legend-title {
  margin-bottom: 0;
}

#legend.collapsed .legend-caret {
  transform: rotate(-90deg);
}

#legend.collapsed .legend-item {
  display: none;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  border: 1px solid #000000;
  border-radius: 50%;
}

.swatch-square {
  border-radius: 0;
}

.swatch-line {
  width: 14px;
  height: 3px;
  border-radius: 0;
  border: none;
}

#footer {
  padding: 0.2rem 1rem;
  font-size: 0.6rem;
  color: var(--text);
  background: var(--chrome);
  border-top: 1px solid #000000;
}

#footer a {
  text-decoration: underline;
}

.maplibregl-popup-content {
  background: #ffffff;
  color: var(--text);
  border: 2px solid #000000;
  border-radius: 0;
  padding: 0.6rem 0.8rem;
  font-family: "Times New Roman", Times, serif;
  box-shadow: none;
}

.maplibregl-popup-tip {
  border-top-color: #000000 !important;
  border-bottom-color: #000000 !important;
}

.popup-photo-link {
  display: block;
  margin: -0.6rem -0.8rem 0.5rem;
}

.popup-photo {
  display: block;
  width: 100%;
  height: 140px;
  object-fit: cover;
  border-bottom: 2px solid #000000;
}

.popup-name {
  font-weight: bold;
  font-size: 1rem;
  text-decoration: underline;
}

.popup-grade {
  color: var(--grade);
  font-weight: bold;
  font-size: 0.85rem;
  margin-top: 0.15rem;
}

.popup-area {
  color: var(--text-dim);
  font-size: 0.85rem;
  font-style: italic;
  margin-top: 0.3rem;
}

.popup-stop {
  color: var(--bus);
  font-size: 0.85rem;
  margin-top: 0.2rem;
}

.popup-links {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-top: 0.5rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--border);
}

.popup-beta {
  display: inline;
  color: var(--link);
  font-size: 0.85rem;
  text-decoration: underline;
}

@media (max-width: 768px) {
  #search-input,
  .control select {
    font-size: 16px;
  }

  #controls {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #controls .control {
    flex-shrink: 0;
  }

  #footer {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
}
