/* GPX statistics and Leaflet map preview. */
.route-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  margin: 0.5rem 0;
}

.route-stat {
  text-align: center;
}

.route-stat .value {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
}

.route-stat .label {
  font-size: 0.8rem;
  color: var(--muted);
}

.route-map-preview {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 0.3rem;
  border: 1px solid var(--seam);
  background: var(--panel);
  margin-top: 0.5rem;
  /* Contains Leaflet's own z-indices (its zoom-control corner goes up to 1000) so they
     can't escape above page UI like the feedback widget -- position:relative alone
     (which Leaflet sets on this element itself) doesn't create a stacking context
     without an explicit z-index here too. */
  position: relative;
  z-index: 0;
}

.route-map-preview--linked {
  cursor: zoom-in;
}

/* The full-screen route map -- see openFullscreen in route_map.js (feedback #138). Above
   everything, the feedback widget included, and the page under it stops scrolling so a
   pan that runs off the map can't drag the event page along behind it. */
.route-map-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: var(--panel);
}

.route-map-fullscreen-map {
  position: absolute;
  inset: 0;
}

.route-map-fullscreen-close {
  position: absolute;
  top: max(0.75rem, env(safe-area-inset-top));
  right: 0.75rem;
  z-index: 1000;
  width: 3rem;
  height: 3rem;
  margin: 0;
  padding: 0;
  border-radius: 50%;
  font-size: 2rem;
  line-height: 1;
  box-shadow: 0 2px 8px rgb(0 0 0 / 0.35);
}

/* Leaflet's zoom buttons sit top-left; push them clear of a notch the same way. */
.route-map-fullscreen .leaflet-top {
  top: env(safe-area-inset-top);
}

html.route-map-fullscreen-open,
html.route-map-fullscreen-open body {
  overflow: hidden;
}

/* The site reserves a scrollbar gutter on <html>; with nothing to scroll, let the map
   have that strip too instead of leaving a band of page showing down the right edge. */
html.route-map-fullscreen-open {
  scrollbar-gutter: auto;
}

/* CSS-only two-step confirmation for destructive actions. */
.cancel-confirm-submit {
  display: none;
}

.cancel-confirm-input:checked ~ .cancel-confirm-toggle {
  display: none;
}

.cancel-confirm-input:checked ~ .cancel-confirm-submit {
  display: inline-block;
}

.save-bar[hidden] {
  display: none;
}

.save-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--panel);
  border-top: 1px solid var(--seam);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.35);
}

.save-bar span {
  font-size: 0.9rem;
}

.save-bar button {
  margin: 0;
}

/* Leaflet's own attribution/tile layers still need real pointer/keyboard focus styling
   suppressed since we treat the whole box as a single link, not an interactive map. */
.route-map-preview .leaflet-control-container {
  pointer-events: none;
}

/* "Choose the starting location" -- the pin field on the event forms, and the read-only
   meet-point map on the event page. See app/static/js/location_picker.js. */
.start-pin {
  margin-bottom: 1rem;
}

/* Styled like the form's own <label>s, because that is the job it does -- it heads the
   pin control the way "Meeting location" heads the text box, so the two stop reading as
   one field with a button under it. */
.start-pin-heading {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 600;
}

/* The pinned confirmation. Loud on purpose: the first version was small muted text that
   people saved a pin and never noticed, which read as the button doing nothing. */
.start-pin-set {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--accent);
  border-radius: 0.3rem;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.start-pin-set[hidden] {
  display: none;
}

.start-pin-check {
  color: var(--accent);
  font-weight: 700;
}

.start-pin-coords {
  font-variant-numeric: tabular-nums;
}

/* Confirmation, not a working surface -- the picker dialog is where you move the pin. */
.start-pin-preview {
  width: 100%;
  height: 12rem;
  margin-bottom: 0.5rem;
  border-radius: 0.3rem;
  border: 1px solid var(--seam);
  background: var(--field-bg);
  position: relative;
  z-index: 0;
}

.start-pin-preview[hidden] {
  display: none;
}

.start-pin-open {
  margin: 0;
}

.start-pin-textbtn {
  background: none;
  border: none;
  padding: 0;
  margin: 0 0 0 0.5rem;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.start-pin-textbtn:hover {
  background: none;
  color: var(--pop);
}

.start-pin-dialog {
  width: min(44rem, calc(100vw - 2rem));
  padding: 1rem;
  border: 1px solid var(--seam);
  border-radius: 0.4rem;
  background: var(--panel);
  color: var(--text);
}

.start-pin-dialog::backdrop {
  background: rgb(0 0 0 / 0.55);
}

.start-pin-dialog-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.start-pin-dialog-head h2 {
  margin: 0;
}

.start-pin-map {
  width: 100%;
  /* Tall enough to pan around in, short enough that the readout and both buttons stay on
     screen next to it on a phone in landscape -- the dialog does not scroll its own
     actions out of reach. */
  height: min(55vh, 24rem);
  border-radius: 0.3rem;
  border: 1px solid var(--seam);
  background: var(--field-bg);
  /* Same containment as .route-map-preview: Leaflet's controls climb to z-index 1000 and
     would otherwise sit above page chrome. */
  position: relative;
  z-index: 0;
  cursor: crosshair;
}

.start-pin-readout {
  margin: 0.5rem 0;
  font-size: 0.9rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.start-pin-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* The read-only meet-point map on the event page. Shorter than the route preview: it
   answers "where do I turn off the highway", not "what does the ride look like". */
.meet-point-map {
  width: 100%;
  height: 16rem;
  border-radius: 0.3rem;
  border: 1px solid var(--seam);
  background: var(--panel);
  margin: 0.5rem 0;
  position: relative;
  z-index: 0;
}

.meet-point-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.9rem;
}

.meet-point-coords {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
