/* Fire-map tool (/firemap): a full-bleed MapLibre map below the shared nav, not the
   usual 40rem reading column -- see .firemap-main. The map canvas itself (basemap,
   contours, closures) is intentionally its own cartographic look; only the floating
   control chrome below is themed with the site's shared tokens. */
body.firemap-page {
  display: flex;
  flex-direction: column;
  /* 100vh includes the space behind a mobile browser's address bar, which the map
     (touch-action: none, so it eats pan gestures instead of scrolling the page) then
     hides below the fold with no way to reach it. 100dvh tracks the real visible
     viewport instead; the 100vh fallback is only for browsers without dvh support. */
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

body.firemap-page footer.site-footer {
  display: none;
}

.firemap-main {
  position: relative;
  flex: 1;
  max-width: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

/* A flash message is unlikely on this route (the login redirect owns that case), but
   if one ever fires, keep it above the absolutely-positioned map instead of hidden
   under it. */
.firemap-main .flash {
  position: relative;
  z-index: 10;
}

#firemap-map {
  position: absolute;
  inset: 0;
  /* Raw paper tone the basemap tiles load onto -- matches the map's own cartography,
     not a themeable UI surface, so this stays a literal color rather than a token. */
  background: #efe8d8;
}

.firemap-panel {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 5;
  width: min(230px, calc(100vw - 20px));
  max-height: calc(100% - 20px);
  overflow-y: auto;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--divider);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
}

.firemap-panel.hidden {
  display: none;
}

#firemap-toggle {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 6;
  width: 40px;
  height: 40px;
  margin: 0;
  min-height: 0;
  padding: 0;
  border: 1px solid var(--divider);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
  font-size: 18px;
  line-height: 40px;
  text-align: center;
  cursor: pointer;
}

.firemap-panel h1 {
  font-size: 13px;
  margin: 0 0 2px;
  padding-right: 26px;
  color: var(--text);
}

.firemap-panel .close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  font-size: 18px;
  color: var(--muted);
  cursor: pointer;
}

.firemap-panel p.sub {
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 8px;
}

.firemap-panel label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  min-height: 28px;
  cursor: pointer;
}

.firemap-panel label input {
  width: 16px;
  height: 16px;
}

.firemap-panel .rowlabel {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 8px 0 2px;
}

.firemap-panel input[type=range] {
  width: 100%;
}

.firemap-panel select {
  width: 100%;
  padding: 5px 6px;
  margin: 2px 0 4px;
  font: inherit;
  border: 1px solid var(--divider);
  border-radius: 6px;
  background: var(--field-bg);
  color: var(--text);
}

.firemap-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.45;
}

@media (pointer: coarse) {
  .firemap-panel label input {
    width: 20px;
    height: 20px;
  }

  .firemap-panel select {
    min-height: 34px;
  }
}

/* ---- full screen: the map takes the whole viewport, site nav hidden ----
   Toggled by the expand / x button in the map's top-right controls (route_planner.js). */
body.map-fullscreen nav.nav {
  display: none;
}

.planner-fs-btn svg,
.planner-tool svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.maplibregl-ctrl-group button.planner-fs-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: #fff;
  color: #333;
}

/* ---- route planner ---- */
.planner button {
  margin: 0;
  min-height: 0;
  font-size: 13px;
}

.planner-rail {
  position: absolute;
  top: 60px;
  left: 10px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.planner-tools {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.planner-tools[hidden] {
  display: none;
}

.planner .planner-tool {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--divider);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
}

.planner .planner-tool:hover {
  background: var(--panel-2);
}

.planner .planner-tool[aria-pressed="true"] {
  background: var(--action);
  color: var(--action-contrast);
  border-color: var(--action);
}

.planner .planner-tool:disabled {
  opacity: 0.45;
  cursor: default;
}

.planner-modes {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  width: 40px;
  border: 1px solid var(--divider);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
}

.planner .planner-mode {
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
}

.planner .planner-mode + .planner-mode {
  border-top: 1px solid var(--divider);
}

.planner .planner-mode[aria-checked="true"] {
  background: var(--accent);
  color: var(--accent-contrast);
}

.planner-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 7;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--divider);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.25);
  color: var(--text);
  font-size: 13px;
}

.planner-sheet[hidden] {
  display: none;
}

.planner-head,
.planner-body,
.planner-notice {
  max-width: 40rem;
  margin: 0 auto;
}

/* the body scrolls, not the sheet, so the route menu can open upward past the sheet */
.planner-body {
  max-height: 40vh;
  max-height: 40dvh;
  overflow-y: auto;
}

.planner-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}

.planner-name {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.planner-title {
  width: 100%;
  padding: 3px 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
}

.planner-title:hover,
.planner-title:focus {
  border-color: var(--divider);
  background: var(--field-bg);
}

.planner-status {
  min-height: 1em;
  padding: 0 7px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  color: var(--muted);
}

.planner .planner-save {
  padding: 6px 14px;
  border-width: 2px;
}

.planner .planner-save:disabled {
  opacity: 0.5;
  cursor: default;
}

.planner .planner-icon-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
}

.planner .planner-icon-btn:hover {
  background: var(--panel-2);
  color: var(--text);
}

.planner-menu {
  position: absolute;
  right: 40px;
  bottom: calc(100% + 6px);
  z-index: 10;
  display: flex;
  flex-direction: column;
  min-width: 180px;
  padding: 4px;
  border: 1px solid var(--divider);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

.planner-menu[hidden],
.planner-menu button[hidden] {
  display: none;
}

.planner .planner-menu button {
  justify-content: flex-start;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-weight: 600;
  text-align: left;
}

.planner .planner-menu button:hover {
  background: var(--panel-2);
}

.planner .planner-menu button.danger {
  color: var(--error);
}

.planner-notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--panel-2);
  font-size: 12px;
}

.planner-notice[hidden] {
  display: none;
}

.planner-notice.warn {
  background: color-mix(in srgb, var(--error) 14%, var(--panel));
}

.planner-notice.ok {
  background: color-mix(in srgb, var(--success) 16%, var(--panel));
}

.planner .planner-notice button {
  padding: 3px 10px;
  border-width: 1px;
  font-size: 12px;
}

.planner-closures {
  margin: 6px 0 0;
  padding: 6px 10px;
  border-left: 3px solid #e00000;
  border-radius: 4px;
  background: color-mix(in srgb, #e23b3b 12%, var(--panel));
  font-size: 12px;
}

.planner-closures[hidden] {
  display: none;
}

.planner .planner-closures button {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font-size: 12px;
  font-weight: 400;
  text-decoration: underline;
}

.planner-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-top: 6px;
}

.planner-stats div {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.planner-stats .v {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.1;
}

.planner-stats .u {
  font-size: 11px;
  color: var(--muted);
}

.planner-sheet.collapsed .planner-surface,
.planner-sheet.collapsed .planner-profile {
  display: none;
}

.planner-surface {
  margin-top: 8px;
}

.planner-surface .bar {
  display: flex;
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--divider);
}

.planner-surface .paved { --c: #4a5568; }
.planner-surface .dirt { --c: #b7791f; }
.planner-surface .unknown { --c: #a0aec0; }

.planner-surface .bar span {
  background: var(--c);
}

.planner-surface .legend {
  display: flex;
  gap: 12px;
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
}

.planner-surface .legend span::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 4px;
  border-radius: 2px;
  background: var(--c);
}

.planner-surface .legend b {
  color: var(--text);
  font-weight: 600;
}

.planner-profile {
  position: relative;
  margin-top: 8px;
}

#pl-profile-svg {
  display: block;
  width: 100%;
  height: 80px;
  touch-action: none;
  cursor: crosshair;
}

#pl-profile-svg:empty {
  display: none;
}

#pl-profile-svg .area {
  fill: color-mix(in srgb, #1f5fd1 18%, transparent);
}

#pl-profile-svg .line {
  fill: none;
  stroke: #1f5fd1;
  stroke-width: 2;
}

#pl-profile-svg .scrub {
  stroke: var(--text);
  stroke-width: 1;
}

.planner-profile-readout {
  position: absolute;
  top: -2px;
  width: 110px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--text);
  color: var(--panel);
  font-size: 11px;
  text-align: center;
  pointer-events: none;
}

.planner-empty {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.planner-dialog {
  position: absolute;
  top: 10px;
  left: 60px;
  z-index: 9;
  width: min(330px, calc(100% - 70px));
  max-height: calc(100% - var(--planner-sheet-h, 0px) - 20px);
  overflow-y: auto;
  padding: 10px 12px;
  border: 1px solid var(--divider);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 13px;
}

.planner-dialog[hidden] {
  display: none;
}

.planner-dialog h2 {
  margin: 0 28px 8px 0;
  font-size: 15px;
}

.planner-dialog p {
  margin: 6px 0;
}

.planner .planner-dialog .close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 18px;
}

.planner-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0;
}

.planner .planner-dialog-actions button,
.planner .planner-rev-actions button,
.planner .planner-rev-actions .btn,
.planner .planner-people button,
.planner .planner-add button {
  margin: 0;
  min-height: 0;
  padding: 4px 10px;
  border-width: 1px;
  font-size: 12px;
}

.planner-muted {
  color: var(--muted);
  font-size: 12px;
}

.planner-sub {
  margin-top: 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.planner-list {
  margin: 6px 0;
  padding: 0;
  list-style: none;
}

.planner-list li {
  border-top: 1px solid var(--divider);
}

.planner-list li:first-child {
  border-top: 0;
}

.planner .planner-list li > button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  padding: 8px 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.planner .planner-list li > button:hover {
  background: var(--panel-2);
}

.planner-list .t {
  font-weight: 700;
}

.planner-list .m {
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
}

.planner-list .m.current {
  color: var(--success);
  font-weight: 600;
}

.planner-revs li,
.planner-people li {
  padding: 7px 2px;
}

.planner-people li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.planner-people li .m {
  flex: 1;
}

.planner-rev-actions {
  display: flex;
  gap: 6px;
  margin-top: 5px;
}

.planner-add {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.planner-add input {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  border: 1px solid var(--divider);
  border-radius: 6px;
  background: var(--field-bg);
  color: var(--text);
  font: inherit;
}

.planner-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
}

.planner-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin: 2px 0 8px;
  font-size: 12px;
}

.planner-legend i {
  display: inline-block;
  width: 14px;
  height: 4px;
  margin-right: 5px;
  border-radius: 2px;
  vertical-align: middle;
}

/* the point popup lives in MapLibre's popup container, outside .planner */
.planner-pop {
  min-width: 170px;
  font-size: 13px;
}

.planner-pop-label {
  margin: 6px 0 3px;
  font-size: 11px;
  color: #666;
}

.planner-pop-modes {
  display: flex;
  gap: 4px;
}

.planner-pop button {
  margin: 0;
  min-height: 0;
  padding: 4px 8px;
  border: 1px solid #999;
  border-radius: 5px;
  background: #fff;
  color: #222;
  font-size: 12px;
  font-weight: 600;
}

.planner-pop button[aria-pressed="true"] {
  background: #1f5fd1;
  border-color: #1f5fd1;
  color: #fff;
}

.planner-pop .planner-pop-delete {
  width: 100%;
  margin-top: 8px;
  color: #c92a2a;
  border-color: #c92a2a;
}

.planner-pop-by {
  margin-top: 6px;
  font-size: 11px;
  color: #666;
}

/* keep the feedback button clear of the planner sheet */
body.planner-open .feedback-fab {
  bottom: calc(var(--planner-sheet-h, 0px) + 1rem);
}

body.planner-open .feedback-panel {
  bottom: calc(var(--planner-sheet-h, 0px) + 4.5rem);
}

@media (pointer: coarse) {
  .planner .planner-tool {
    width: 44px;
    height: 44px;
  }

  .planner-modes {
    width: 44px;
  }

  .planner .planner-mode {
    height: 34px;
  }

  .planner-rail {
    top: 62px;
  }
}
