/* Infill map page. Every rule is scoped to #jd-app or body.infill-map-page. */

body.infill-map-page {
  overflow: hidden;
}
body.infill-map-page .nav-footer {
  display: none;
}

#jd-app {
  --jd-nav-h: 56px;
  --jd-card-bg: color-mix(in srgb, var(--bs-body-bg) 94%, transparent);
  --jd-border: var(--bs-border-color);
  --jd-muted: var(--bs-secondary-color, #6c757d);
  --jd-accent: #663f5f;
  position: fixed;
  inset: var(--jd-nav-h) 0 0 0;
  z-index: 1;
  font-size: 0.9rem;
  color: var(--bs-body-color);
}
body.quarto-dark #jd-app {
  --jd-accent: #c79dbf;
}

#jd-map {
  position: absolute;
  inset: 0;
  background: var(--bs-body-bg);
}

.jd-sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.jd-muted {
  color: var(--jd-muted);
}

.jd-card {
  position: absolute;
  z-index: 2;
  background: var(--jd-card-bg);
  border: 1px solid var(--jd-border);
  border-radius: 8px;
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.15);
  backdrop-filter: blur(4px);
}

#jd-error {
  position: absolute;
  z-index: 5;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.6rem 1rem;
  border-radius: 6px;
  background: #b3261e;
  color: #fff;
  max-width: 90%;
}

/* ---- controls card -------------------------------------------------------- */
#jd-controls {
  top: 12px;
  left: 12px;
  width: 300px;
  max-height: calc(100% - 24px);
  overflow-y: auto;
  padding: 0.75rem 0.85rem;
}
.jd-controls-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
#jd-controls h1 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
  line-height: 1.25;
}
#jd-controls fieldset {
  border: 0;
  margin: 0.6rem 0 0;
  padding: 0;
  min-width: 0;
}
#jd-controls legend {
  float: none;
  width: auto;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--jd-muted);
  margin: 0 0 0.25rem;
  padding: 0;
}
.jd-time-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.jd-time-row input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--jd-accent);
  height: 2rem;
}
.jd-time-label {
  font-weight: 600;
  margin-left: calc(2.2rem + 0.6rem);
}
#jd-more {
  margin-top: 0.4rem;
}
#jd-controls.collapsed #jd-more {
  display: none;
}

.jd-btn,
.jd-icon-btn,
.jd-chip,
.jd-link {
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.jd-btn {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  border: 1px solid var(--jd-border);
  background: var(--bs-body-bg);
  line-height: 1;
  flex: none;
}
.jd-icon-btn {
  border: 0;
  background: transparent;
  font-size: 1.3rem;
  line-height: 1;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
}
.jd-icon-btn:hover,
.jd-btn:hover,
.jd-chip:hover {
  background: color-mix(in srgb, var(--jd-accent) 14%, transparent);
}
.jd-chips {
  display: flex;
  gap: 0.4rem;
  margin: 0.3rem 0 0.2rem;
}
.jd-chip {
  border: 1px solid var(--jd-border);
  background: var(--bs-body-bg);
  border-radius: 999px;
  padding: 0.1rem 0.7rem;
  font-size: 0.8rem;
}
.jd-mode label,
.jd-types label,
.jd-row label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
}
.jd-seg-row {
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
  margin-top: 0.4rem;
}
.jd-seg label,
.jd-transit label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  padding: 0.1rem 0;
}
.jd-ticks {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  margin: -0.15rem 0 0.1rem calc(2.2rem + 0.6rem);
  font-size: 0.75rem;
  color: var(--jd-muted);
  white-space: nowrap;
}
.jd-ticks span:nth-child(2) {
  text-align: center;
}
.jd-ticks span:last-child {
  text-align: right;
}
.jd-ticks[hidden] {
  display: none;
}
.jd-sub {
  margin-left: 1.55rem;
}
.jd-sub label:has(input:disabled) {
  opacity: 0.5;
  cursor: default;
}
.jd-line-swatch {
  display: inline-block;
  width: 22px;
  height: 0;
  border-top: 2px solid var(--jd-lrt-ink, #2b2b2b);
  flex: none;
}
.jd-line-swatch.jd-dashed {
  border-top-style: dashed;
}
.jd-line-swatch.jd-bus {
  border-top-color: var(--jd-bus-ink, #6b5b4b);
  border-top-width: 3px;
}
.jd-line-swatch.jd-thick {
  border-top-width: 3px;
}
.jd-line-key {
  display: flex;
  flex-wrap: wrap;
  gap: 0.1rem 0.9rem;
  margin: 0.05rem 0 0.25rem 1.55rem;
  font-size: 0.8rem;
}
.jd-line-key span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.jd-line-key .jd-line-swatch {
  width: 18px;
  border-top-width: 4px;
}
.jd-note-line {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.75rem;
  color: var(--jd-muted);
  margin-top: 0.15rem;
}
.jd-types label {
  padding: 0.15rem 0;
}
.jd-types .jd-count {
  margin-left: auto;
  color: var(--jd-muted);
  font-variant-numeric: tabular-nums;
}
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--jd-accent);
}
.jd-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid var(--bs-body-bg);
  box-shadow: 0 0 0 1px var(--jd-border);
  flex: none;
}
.jd-legend {
  margin-top: 0.6rem;
}
.jd-legend-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--jd-muted);
  margin-bottom: 0.25rem;
}
#jd-legend-ramp {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(4, auto);
  grid-auto-flow: column; /* decline down the left, growth down the right */
  gap: 0.2rem 0.6rem;
  font-size: 0.75rem;
}
#jd-legend-ramp span {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
#jd-legend-ramp i {
  width: 14px;
  height: 10px;
  border: 1px solid var(--jd-border);
}
.jd-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin-top: 0.7rem;
}
.jd-spacer {
  flex: 1;
}
.jd-link {
  border: 0;
  background: none;
  padding: 0;
  text-decoration: underline;
  color: var(--jd-accent);
}

/* ---- stat strip ----------------------------------------------------------- */
#jd-stats {
  top: 12px;
  left: 324px;
  right: 60px;
  width: fit-content;
  max-width: calc(100% - 384px);
  padding: 0.5rem 0.75rem;
}
.jd-tiles {
  display: flex;
  gap: 1.4rem;
  flex-wrap: wrap;
}
.jd-tile-v {
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.1;
}
.jd-tile-l {
  font-size: 0.75rem;
  color: var(--jd-muted);
}
.jd-disclosure {
  font-size: 0.75rem;
  color: var(--jd-muted);
  margin-top: 0.35rem;
  max-width: 46rem;
}

/* ---- neighbourhood panel and table view ------------------------------------ */
#jd-panel {
  top: 132px;
  right: 12px;
  width: 320px;
  max-height: calc(100% - 152px);
  overflow-y: auto;
  padding: 0.75rem 0.85rem;
}
#jd-tableview {
  top: 84px;
  left: 324px;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  padding: 0.75rem 0.85rem;
  z-index: 2;
}
#jd-tableview[hidden] {
  display: none;
}
.jd-tv-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}
.jd-tv-toolbar input[type="search"],
.jd-tv-toolbar select {
  font: inherit;
  color: inherit;
  background: var(--bs-body-bg);
  border: 1px solid var(--jd-border);
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  min-width: 0;
}
.jd-tv-toolbar input[type="search"] {
  width: 14rem;
}
.jd-view-switch {
  display: flex;
  gap: 1rem;
}
/* Table view hides the map and everything that only applies to it. */
#jd-app.jd-view-table #jd-map,
#jd-app.jd-view-table .jd-map-only,
#jd-app.jd-view-table #jd-panel,
#jd-app.jd-view-table #jd-error {
  display: none;
}
#jd-app.jd-view-table {
  background: var(--bs-body-bg);
}
.jd-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}
#jd-app h1,
#jd-app h2,
#jd-app h3 {
  color: inherit;
}
.jd-panel-head h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
  border: 0;
  padding: 0;
}
#jd-panel-body dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 1rem;
  margin: 0.6rem 0 0;
}
#jd-panel-body dt {
  font-weight: 400;
  color: var(--jd-muted);
}
#jd-panel-body dd {
  margin: 0;
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
#jd-panel-body h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--jd-muted);
  margin: 0.8rem 0 0.2rem;
}
#jd-panel-body .jd-by-type {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.1rem 0;
}
#jd-panel-body .jd-by-type b {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}
.jd-note {
  font-size: 0.75rem;
  color: var(--jd-muted);
  margin-top: 0.6rem;
}
.jd-table-wrap {
  overflow: auto;
  margin-top: 0.5rem;
  flex: 1;
  min-height: 0;
}
#jd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
#jd-table th,
#jd-table td {
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--jd-border);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
#jd-table th:first-child,
#jd-table td:first-child,
#jd-table th:nth-child(2),
#jd-table td:nth-child(2),
#jd-table th:nth-child(3),
#jd-table td:nth-child(3) {
  text-align: left;
}
#jd-table th {
  position: sticky;
  top: 0;
  background: var(--bs-body-bg);
}
#jd-table th button,
#jd-table td button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: inherit;
}
#jd-table td button {
  color: var(--jd-accent);
  text-decoration: underline;
}

/* ---- about dialog --------------------------------------------------------- */
#jd-about {
  max-width: min(640px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  overflow-y: auto;
  border: 1px solid var(--jd-border);
  border-radius: 10px;
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  padding: 1.2rem 1.4rem;
}
#jd-about::backdrop {
  background: rgb(0 0 0 / 0.45);
}
#jd-about h2 {
  margin-top: 0;
  font-size: 1.3rem;
}
#jd-about h3 {
  font-size: 1rem;
  margin-top: 1rem;
}
.jd-about-close {
  float: right;
}
.jd-licence {
  font-size: 0.8rem;
  margin-top: 1rem;
}

/* ---- map furniture -------------------------------------------------------- */
.maplibregl-ctrl-group button.jd-ctrl-btn {
  font-size: 15px;
  font-weight: 600;
  color: #333;
}
body.quarto-dark .maplibregl-popup-content {
  background: #2a2a2a;
  color: #f2f2f0;
}
body.quarto-dark .maplibregl-popup-anchor-top .maplibregl-popup-tip {
  border-bottom-color: #2a2a2a;
}
body.quarto-dark .maplibregl-popup-anchor-bottom .maplibregl-popup-tip {
  border-top-color: #2a2a2a;
}
body.quarto-dark .maplibregl-popup-anchor-left .maplibregl-popup-tip {
  border-right-color: #2a2a2a;
}
body.quarto-dark .maplibregl-popup-anchor-right .maplibregl-popup-tip {
  border-left-color: #2a2a2a;
}
body.quarto-dark .maplibregl-popup-close-button {
  color: #f2f2f0;
}
#jd-app .maplibregl-popup-content {
  max-height: 50vh;
  overflow-y: auto;
}
.jd-popup {
  font-size: 0.85rem;
  max-width: 240px;
}
.jd-popup + .jd-popup {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid rgb(128 128 128 / 0.35);
}
.jd-popup strong {
  display: block;
}
.jd-popup .jd-muted {
  font-size: 0.78rem;
}
body.quarto-dark .jd-popup .jd-muted {
  color: #b5b5ae;
}

#jd-app :focus-visible {
  outline: 2px solid var(--jd-accent);
  outline-offset: 2px;
}

/* ---- narrow screens: controls become a bottom sheet ------------------------ */
@media (max-width: 820px) {
  #jd-controls {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: auto;
    max-height: 60%;
    border-radius: 14px 14px 0 0;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px));
  }
  #jd-controls h1 {
    font-size: 0.95rem;
  }
  #jd-stats {
    left: 8px;
    right: 56px;
    top: 8px;
    max-width: none;
    width: auto;
    overflow-x: auto;
    padding: 0.4rem 0.6rem;
  }
  .jd-tiles {
    flex-wrap: nowrap;
    gap: 1rem;
  }
  .jd-tile {
    flex: none;
  }
  .jd-tile-v {
    font-size: 1.1rem;
  }
  .jd-disclosure {
    display: none;
  }
  #jd-tableview {
    top: 64px;
    left: 8px;
    right: 8px;
    bottom: 150px;
  }
  .jd-tv-toolbar input[type="search"] {
    width: 100%;
  }
  #jd-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: auto;
    max-height: 62%;
    border-radius: 14px 14px 0 0;
    z-index: 4;
  }
  #jd-app.jd-panel-open #jd-controls {
    visibility: hidden;
  }
  .jd-btn {
    width: 2.75rem;
    height: 2.75rem;
  }
  .jd-time-label {
    margin-left: calc(2.75rem + 0.6rem);
  }
  .jd-ticks {
    margin-left: calc(2.75rem + 0.6rem);
  }
  .jd-icon-btn,
  .jd-chip {
    min-height: 44px;
    min-width: 44px;
  }
  .maplibregl-ctrl-group button {
    width: 36px;
    height: 36px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

@media (forced-colors: active) {
  .jd-card,
  #jd-about {
    border: 1px solid CanvasText;
    background: Canvas;
  }
  .jd-swatch {
    forced-color-adjust: none;
  }
}

/* Occupancy filter, under the project types */
.jd-types .jd-occ {
  margin-top: 0.35rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--jd-border);
}
