:root {
  color-scheme: light;
  --fox-rust: 148, 73, 55;
  --fox-outline: 125, 56, 43;
  --eastern-gray-blue: 7, 30, 233;
  --western-gray-black: 0, 0, 0;
  --douglas-fill: 250, 169, 12;
  --douglas-outline: 209, 139, 35;
  --humboldt-flying-green: 12, 109, 4;
  --california-ground-purple: 94, 39, 113;
  --golden-mantled-gold: 194, 169, 5;
  --nelsons-antelope-blue: 108, 170, 184;
  --paper: 252, 250, 246;
  --ink: #2d2925;
  --muted-ink: #665f57;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  min-width: 280px;
  overflow: hidden;
  background: rgb(var(--paper));
  color: var(--ink);
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
}

.map-topbar {
  position: relative;
  display: flex;
  flex: 0 0 50px;
  align-items: center;
  min-height: 50px;
  padding: 0 14px;
  background: #1b1606;
  color: #e8dfc8;
}

.map-topbar__back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 14px 3px 6px;
  border: 1px solid #616161;
  border-radius: 8px;
  background: #b7dbc6;
  color: #1b1606;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.map-topbar__back:hover {
  background: #a3d0b6;
  color: #000;
}

.map-topbar__back:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.72);
  outline-offset: 2px;
}

.map-topbar__back img {
  display: block;
  width: auto;
  height: 32px;
}

.map-topbar__back-short {
  display: none;
}

.map-topbar__title {
  position: absolute;
  right: 58px;
  width: 276px;
  color: #d3a90f;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: center;
  white-space: nowrap;
}

.map-topbar__species-menu {
  display: none;
  align-items: center;
  gap: 7px;
  height: 40px;
  margin-left: auto;
  padding: 3px 14px;
  border: 1px solid #8d5709;
  border-radius: 8px;
  background: #d37e0f;
  color: #1b1606;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.map-topbar__species-menu:hover {
  background: #e09223;
}

.map-topbar__species-menu:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.72);
  outline-offset: 2px;
}

.map-topbar__species-menu-icon {
  font-size: 0.85rem;
  line-height: 1;
}

.prototype-shell {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
}

.map-stage {
  position: relative;
  width: 100%;
  height: 100%;
}

#fox-range-map {
  position: absolute;
  inset: 0;
}

.map-footer {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 24px;
  padding: 8px 18px;
  background: #d37e0f;
  color: #3f2805;
}

.map-footer__caption {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
}

.map-footer__links {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
  font-size: 0.9rem;
}

.map-footer__links a {
  color: #1b1606;
  font-weight: 700;
  text-decoration: none;
}

.map-footer__links a:hover {
  text-decoration: underline;
}

.map-footer__links a:focus-visible {
  outline: 2px solid rgba(27, 22, 6, 0.7);
  outline-offset: 2px;
}

.map-footer__credit {
  margin-left: 6px;
  color: #4a3208;
  font-size: 0.78rem;
}

.species-marker {
  display: block;
  width: auto;
  height: var(--marker-height, 76px);
  padding: 0;
  border: 0;
  border-radius: 4px;
  appearance: none;
  background: transparent;
  cursor: pointer;
  line-height: 0;
}

.species-marker[hidden] {
  display: none;
}

.species-marker img {
  display: block;
  width: auto;
  height: 100%;
}

.species-marker:focus-visible {
  outline: 2px solid rgba(38, 77, 130, 0.65);
  outline-offset: 3px;
}

.maplibregl-popup-content {
  padding: 10px 12px 12px;
  border-radius: 7px;
  color: var(--ink);
  font-family: "Avenir Next", Avenir, "Segoe UI", sans-serif;
}

.species-popup {
  width: 240px;
  max-width: 72vw;
}

.species-popup__photo {
  display: block;
  width: 100%;
  height: auto;
  margin: 0 0 8px;
  border-radius: 6px;
}

.species-popup__common {
  margin: 0;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  line-height: 1.25;
}

.species-popup__scientific {
  margin-top: 2px;
  color: var(--muted-ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.88rem;
  font-style: italic;
}

.species-selector {
  position: absolute;
  z-index: 2;
  top: 18px;
  right: 58px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(276px, calc(100% - 88px));
  max-height: calc(100% - 36px);
  padding: 14px;
  overflow-y: auto;
  border: 1px solid rgba(67, 58, 49, 0.22);
  border-radius: 7px;
  background: rgba(var(--paper), 0.95);
  box-shadow: 0 4px 16px rgba(43, 37, 31, 0.12);
  backdrop-filter: blur(4px);
}

.species-selector__title {
  margin: 0;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.species-selector__group {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.species-selector__group-title {
  margin: 0;
  color: var(--muted-ink);
  font-size: 0.69rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  line-height: 1.25;
  text-transform: uppercase;
}

.species-toggle {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  width: 100%;
  min-height: 52px;
  padding: 7px 8px;
  border: 1px solid rgba(67, 58, 49, 0.2);
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.species-toggle:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.92);
}

.species-toggle:focus-visible {
  outline: 3px solid rgba(38, 77, 130, 0.35);
  outline-offset: 2px;
}

.species-toggle[aria-pressed="true"] {
  border-color: rgba(45, 41, 37, 0.62);
  background: #fff;
  box-shadow: 0 1px 4px rgba(43, 37, 31, 0.12);
}

.species-toggle:disabled,
.species-selector__clear:disabled {
  cursor: wait;
  opacity: 0.58;
}

.species-toggle__swatch {
  width: 28px;
  height: 18px;
}

.species-toggle__swatch--fox {
  border: 1.15px solid rgba(var(--fox-outline), 0.58);
  background: rgba(var(--fox-rust), 0.16);
}

.species-toggle__swatch--douglas {
  border: 1.15px solid rgba(var(--douglas-outline), 0.55);
  background: rgba(var(--douglas-fill), 0.14);
}

.species-toggle__swatch--eastern-gray {
  border: 1.15px solid rgba(var(--eastern-gray-blue), 0.55);
  background: rgba(var(--eastern-gray-blue), 0.14);
}

.species-toggle__swatch--western-gray {
  border: 1.15px solid rgba(var(--western-gray-black), 0.55);
  background: rgba(var(--western-gray-black), 0.14);
}

.species-toggle__swatch--humboldt-flying {
  border: 1.15px solid rgba(var(--humboldt-flying-green), 0.55);
  background: rgba(var(--humboldt-flying-green), 0.14);
}

.species-toggle__swatch--california-ground {
  border: 1.15px solid rgba(var(--california-ground-purple), 0.55);
  background: rgba(var(--california-ground-purple), 0.14);
}

.species-toggle__swatch--golden-mantled {
  border: 1.15px solid rgba(var(--golden-mantled-gold), 0.55);
  background: rgba(var(--golden-mantled-gold), 0.14);
}

.species-toggle__swatch--nelsons-antelope {
  border: 1.15px solid rgba(var(--nelsons-antelope-blue), 0.55);
  background: rgba(var(--nelsons-antelope-blue), 0.14);
}

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

.species-toggle__identity {
  display: flex;
  min-width: 0;
  flex-direction: column;
  line-height: 1.22;
}

.species-toggle strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.94rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.species-toggle em {
  margin-top: 2px;
  color: var(--muted-ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.79rem;
}

.species-toggle__state {
  color: var(--muted-ink);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: right;
}

.species-toggle[aria-pressed="true"] .species-toggle__state {
  color: var(--ink);
}

.species-selector__clear {
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid rgba(67, 58, 49, 0.28);
  border-radius: 5px;
  background: transparent;
  color: var(--muted-ink);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 650;
  cursor: pointer;
}

.species-selector__clear:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
}

.species-selector__clear:focus-visible {
  outline: 3px solid rgba(38, 77, 130, 0.35);
  outline-offset: 2px;
}

.range-data-attribution {
  position: absolute;
  z-index: 2;
  bottom: 18px;
  left: 18px;
  max-width: min(390px, calc(100% - 36px));
  margin: 0;
  padding: 5px 7px;
  border-radius: 3px;
  background: rgba(var(--paper), 0.86);
  color: var(--muted-ink);
  font-size: 0.7rem;
  line-height: 1.3;
}

.range-data-attribution a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.range-data-attribution a:focus-visible {
  outline: 2px solid rgba(38, 77, 130, 0.5);
  outline-offset: 2px;
}

.map-status {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  width: min(520px, calc(100% - 40px));
  padding: 16px 18px;
  transform: translate(-50%, -50%);
  border: 1px solid rgba(110, 50, 38, 0.3);
  border-radius: 7px;
  background: rgba(var(--paper), 0.98);
  box-shadow: 0 8px 28px rgba(43, 37, 31, 0.18);
  color: #6e3226;
  font-size: 0.96rem;
  line-height: 1.5;
}

.maplibregl-ctrl-attrib {
  font-size: 11px;
}

.maplibregl-ctrl-group {
  border-radius: 6px;
}

@media (max-width: 991px) {
  .map-topbar__title {
    position: static;
    flex: 1 1 auto;
    width: auto;
    padding: 0 12px;
    text-align: center;
  }

  .map-topbar__species-menu {
    display: inline-flex;
    flex: 0 0 auto;
  }

  .species-selector {
    top: 12px;
    right: 52px;
    display: none;
    width: min(320px, calc(100% - 76px));
    max-height: calc(100% - 24px);
    padding: 10px 11px;
  }

  .species-selector[data-mobile-open="true"] {
    display: flex;
  }
}

@media (max-width: 520px) {
  .species-toggle {
    min-height: 50px;
    padding: 6px 7px;
  }

  .range-data-attribution {
    bottom: 34px;
    left: 12px;
    max-width: min(220px, calc(100% - 24px));
    font-size: 0.66rem;
  }
}

@media (max-width: 768px) {
  .map-topbar__back-full,
  .map-topbar__title {
    display: none;
  }

  .map-topbar__back-short {
    display: inline;
  }

  .map-footer {
    padding: 6px 12px;
  }

  .map-footer__caption {
    font-size: 0.82rem;
  }

  .map-footer__links {
    gap: 3px 10px;
    font-size: 0.78rem;
  }

  .map-footer__credit {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
}
