html,
body {
  height: 100%;
}

body {
  padding-top: 0;
}

main {
  max-width: none;
  margin: 0;
  padding: 0;
}

/* Nav filter controls
–––––––––––––––––––––––––––––––––––––––––––––––––– */
#search-container {
  position: relative;
}

#search-input {
  width: 220px;
  padding: 0.4rem 0.6rem;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}

#search-listbox {
  position: absolute;
  z-index: 200;
  top: 100%;
  left: 0;
  margin: 0.25rem 0 0;
  padding: 0.25rem 0;
  width: 320px;
  max-height: 320px;
  overflow-y: auto;
  list-style: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  font-size: 0.9rem;
}

#search-listbox li {
  padding: 0.4rem 0.75rem;
  cursor: pointer;
}

#search-listbox li[aria-selected="true"] {
  background: var(--accent);
  color: #fff;
}

#limit {
  width: 4.5rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}

#date-container {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
}

#date-container input {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}

#weekday-container fieldset {
  display: flex;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  border: none;
  font-size: 0.85rem;
}

#weekday-container label {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  cursor: pointer;
}

/* Map + resource window
–––––––––––––––––––––––––––––––––––––––––––––––––– */
#wrapper {
  position: relative;
  /* z-index (any value) turns this into a stacking context, so Leaflet's internal
     panes (z-index up to 700) stay contained here instead of leaking above the nav. */
  z-index: 0;
  /* Full viewport height, not (100vh - nav-height): the nav is a floating overlay
     (position: fixed) over the map, not something the map needs to leave room for.
     Shortening this left a nav-height-tall gap of bare body background at the bottom. */
  height: 100vh;
}

#map {
  height: 100%;
  width: 100%;
}

.resource-window {
  position: absolute;
  bottom: 3%;
  left: 2%;
  z-index: 500;
  max-height: 50%;
  max-width: 90%;
  overflow: auto;
  background: #fff;
  border: 1px solid gray;
  border-radius: 4px;
  padding: 0.75rem 1rem;
  opacity: 0.95;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

.resource-window[data-resource="trips"] {
  max-height: 40%;
}

.resource-window ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.resource-window li.header {
  font-weight: bold;
  margin-top: 0.5rem;
}

.resource-window table {
  border-collapse: collapse;
  margin-top: 0.5rem;
}

.resource-window th,
.resource-window td {
  padding: 0.25rem 0.6rem;
  text-align: left;
  font-size: 0.9rem;
  border-bottom: 1px solid #eee;
}

.resource-window tr.selectable {
  cursor: pointer;
}

.resource-window tr.selectable:hover {
  background: #eee;
}

.resource-tabs {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

.resource-tabs button {
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
  border: 1px solid #bbb;
  border-radius: 3px;
  background: #eee;
  cursor: pointer;
}

.resource-tabs button[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.trip-select {
  margin: 0.5rem 0;
  padding: 0.3rem;
}

/* Leaflet popup contents
–––––––––––––––––––––––––––––––––––––––––––––––––– */
.info-window {
  min-width: 320px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

.info-window #location-metrics {
  display: block;
  font-weight: bold;
  margin-top: 0.2rem;
}

.info-window form {
  margin-top: 0.5rem;
}

.info-window .field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.info-window .field label {
  width: 5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.info-window .field input {
  flex: 1;
  padding: 0.25rem 0.4rem;
  border: 1px solid var(--border);
  border-radius: 3px;
}

.info-window button {
  margin-top: 0.25rem;
  padding: 0.3rem 0.8rem;
  cursor: pointer;
}

.info-window .resources {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.info-window .resource-button {
  padding: 0.25rem 0.6rem;
  font-size: 0.85rem;
  border: 1px solid #999;
  border-radius: 3px;
  background: #eee;
  cursor: pointer;
}

.info-window .resource-button[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Duration chart (hand-rolled SVG bar chart)
–––––––––––––––––––––––––––––––––––––––––––––––––– */
.duration-chart {
  display: block;
  max-width: 100%;
}

.duration-chart .bar {
  fill: var(--accent);
}

.duration-chart .axis {
  stroke: #ccc;
}

.duration-chart .axis-label {
  font-size: 10px;
  fill: var(--text-muted);
}
