/* Friends Overhead customizations layered on the Grayscale theme (styles.css).
   Keep the compiled theme file pristine; all app-specific rules live here. */

/* Navbar height, used to clear the fixed-top nav. Fallback values; scripts.js
   overwrites --nav-h with the measured height on load/resize. */
:root {
  --nav-h: 4.5rem;
}
@media (min-width: 992px) {
  :root {
    --nav-h: 5.5rem;
  }
}

/* Brand wordmark in the navbar. */
#mainNav .navbar-brand {
  font-family: Montserrat, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto;
  font-weight: 800;
}

/* Single fixed full-viewport background on every page. A fixed element is
   used instead of background-attachment: fixed, which iOS Safari ignores. */
.site-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.7) 75%, #000 100%),
    url("../assets/img/bg-masthead.jpg");
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
}

/* Content pages: centered column of cards, cleared below the fixed navbar. */
.page-wrap {
  padding-top: calc(var(--nav-h) + 2rem);
  padding-bottom: 3rem;
  min-height: 100dvh;
}

/* White card at ~12% transparency over the dark background. */
.page-card {
  background: rgba(255, 255, 255, 0.88);
  color: #212529;
  border-radius: 0.5rem;
  box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.35);
  padding: 1.5rem;
}
@media (min-width: 768px) {
  .page-card {
    padding: 2.5rem;
  }
}

/* The theme's .btn padding (1.25rem 2rem) is hero-sized; restore sane
   proportions inside cards and the map controls. */
.page-card .btn,
.map-controls .btn {
  padding: 0.5rem 1rem;
  letter-spacing: 0.1rem;
}
.map-controls .btn {
  padding: 0.375rem 0.75rem;
}
/* Square-ish icon-only buttons (e.g. friend Edit/Delete). */
.page-card .btn-icon {
  padding: 0.375rem 0.6rem;
  letter-spacing: 0;
  line-height: 1;
}
/* The theme zeroes .btn borders, which erases the outline day-buttons. */
.map-controls .btn-outline-primary,
.page-card .btn-outline-primary,
.page-card .btn-outline-secondary,
.page-card .btn-outline-danger {
  border: 1px solid currentColor;
}

/* Flash messages must clear the fixed navbar; on the map page they float
   over the map instead of pushing it down. */
.flash-container {
  position: relative;
  z-index: 1029;
  margin-top: calc(var(--nav-h) + 0.75rem);
}
body.map-page .flash-container {
  position: fixed;
  top: calc(var(--nav-h) + 0.5rem);
  left: 0;
  right: 0;
  margin-top: 0;
}

/* Content pages that flash then render a .page-wrap would double the top
   clearance; collapse it when a flash is showing. */
.flash-container + main .page-wrap,
.flash-container ~ .page-wrap {
  padding-top: 1rem;
  min-height: 0;
}

/* Full-bleed content pages on phones, matching the map: card flush to the
   navbar and screen edges, filling the viewport. Opt in with .page-bleed. */
@media (max-width: 575.98px) {
  .page-bleed {
    padding-top: var(--nav-h);
    padding-bottom: 0;
  }
  .flash-container ~ .page-bleed {
    padding-top: 0; /* the flash already clears the navbar */
  }
  .page-bleed > .row {
    --bs-gutter-x: 0; /* drops the row's negative margins and the col padding */
  }
  .page-bleed .page-card {
    min-height: calc(100dvh - var(--nav-h));
    border-radius: 0;
    box-shadow: none;
  }
}

/* ------------------------------------------------------------------ */
/* Map page: navbar on top, map fills the rest of the viewport.        */
/* ------------------------------------------------------------------ */

body.map-page {
  overflow: hidden;
}

/* Responsive map frame (mobile-first): full-bleed on phones, inset with
   the background showing around it from 576px, and fluid gutters plus a
   centred width cap on large screens. Tiers only change --map-gutter. */
.map-shell {
  --map-gutter: 0px; /* needs a unit: used inside calc()/max() */
  --map-max-w: 100rem;
  position: fixed;
  top: calc(var(--nav-h) + var(--map-gutter));
  bottom: var(--map-gutter);
  /* Centre within the cap, never closer to the edge than the gutter. */
  left: max(var(--map-gutter), calc((100% - var(--map-max-w)) / 2));
  right: max(var(--map-gutter), calc((100% - var(--map-max-w)) / 2));
}
.map-shell #map {
  height: 100%;
  width: 100%;
  border-radius: 0;
  overflow: hidden;
}

/* Floating controls card, top-right so Leaflet's zoom keeps top-left. */
.map-controls {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 1001; /* above Leaflet's controls (1000) */
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(17rem, calc(100vw - 6rem));
  background: rgba(255, 255, 255, 0.7);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  color: #212529;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 0.5rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 0.5rem 1.5rem rgba(0, 0, 0, 0.25);
  padding: 0.5rem;
}

@media (min-width: 576px) {
  .map-shell {
    --map-gutter: 0.75rem;
  }
  .map-shell #map {
    border-radius: 0.5rem;
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.35);
  }
  .map-controls {
    top: 0.75rem;
    right: 0.75rem;
    padding: 0.75rem;
  }
}
@media (min-width: 768px) {
  .map-shell {
    --map-gutter: 1.25rem;
  }
}
@media (min-width: 1200px) {
  .map-shell {
    --map-gutter: clamp(1.5rem, 3vw, 3rem);
  }
  .map-controls {
    top: 1rem;
    right: 1rem;
  }
}

/* Legend expand (+, status line) and collapse (chevron, bottom of legend) controls (map.html).
   map.js toggles .legend-collapsed on .map-controls; the collapse button hides with #legend. */
.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.legend-toggle {
  background: none;
  border: 0;
  padding: 0;
  color: #6c757d;
  font-size: 0.85em;
  line-height: 1;
  cursor: pointer;
}
.legend-toggle:hover {
  color: #212529;
}
#legend-collapse {
  display: block;
  margin: 0.25rem 0 0 auto; /* right-aligned under the + */
}
.map-controls.legend-collapsed #legend,
.map-controls:not(.legend-collapsed) #legend-expand {
  display: none;
}

#legend .legend-swatch {
  display: inline-block;
  width: 1em;
  height: 1em;
  border-radius: 50%;
  margin-right: 0.4em;
  vertical-align: -0.15em;
}
#legend > span {
  display: inline-block;
  margin-right: 1rem;
  white-space: nowrap;
}
/* Latest-location key below the friends; icon matches latestIcon() in map.js. */
#legend .legend-target svg {
  margin-right: 0.4em;
  vertical-align: -0.25em;
}
/* Fade legend entries whose friend is hidden. */
#legend > span:has(.visibility-toggle[data-visible="false"]) {
  opacity: 0.5;
}

/* Legend eye toggle, after the name (map.html); CSS picks the icon from data-visible. */
#legend .visibility-toggle {
  background: none;
  border: 0;
  padding: 0;
  margin-left: 0.15em;
  color: #6c757d;
  font-size: 0.85em;
  line-height: 1;
  cursor: pointer;
}
#legend .visibility-toggle:hover {
  color: #212529;
}
#legend .visibility-toggle[data-visible="true"] .icon-hidden,
#legend .visibility-toggle[data-visible="false"] .icon-shown {
  display: none;
}

/* Direction-of-travel arrows on track nodes and latest-position marker (map.js). */
.track-arrow,
.latest-marker {
  background: none;
  border: none;
}
.track-arrow div {
  font-size: 16px;
  line-height: 16px;
  text-align: center;
}

/* Copy link in map popups: muted grey, otherwise like the surrounding popup text.
   Qualified with .leaflet-container to beat Leaflet's own link color. */
.leaflet-container a.copy-coords,
.leaflet-container a.copy-coords:hover {
  color: #6c757d;
  font-size: 0.8em;
  font-weight: inherit;
  text-decoration: none;
}
