/**
 * Day Navigation fullscreen overlay — GPS turn-following UI.
 * Shared by /my-tour, /demo, and the public /track page.
 *
 * Self-sufficient: colors/fonts resolve to the global tokens in styles.css
 * (--color-*, --font-*) where an equivalent design-system value exists;
 * where none does (a few muted/green tones only the overlay uses), the
 * literal value is hardcoded in place below rather than introduced as a
 * new shared variable. This file does not depend on my-tour.css — any page
 * that links it (styles.css must also be linked, for the tokens above).
 */

.day-nav {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  background: var(--color-cream);
}

/* Open/closed is the `hidden` attribute rather than an inline display, so the
   landscape rule below can switch this to `display: grid` — an inline style
   would outrank the media query and the rail would never apply. */
.day-nav[hidden] {
  display: none;
}

.day-nav__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(20, 28, 48, 0.08);
  flex-shrink: 0;
}

.day-nav__close,
.day-nav__gps-btn,
.day-nav__fs-btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 11px;
  border-radius: 13px;
  background: var(--color-white);
  color: var(--color-charcoal);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 1px 5px rgba(20, 28, 48, 0.08);
}

.day-nav__close svg,
.day-nav__gps-btn svg,
.day-nav__fs-btn svg {
  width: 16px;
  height: 16px;
}

/* See .day-nav__cue[hidden] below — same [hidden]-vs-author-display quirk.
   This one stays hidden wherever the Fullscreen API is missing. */
.day-nav__fs-btn[hidden] {
  display: none;
}

.day-nav__gps-btn--active {
  background: #ddf3e3;
  color: #1fa958;
}

.day-nav__title {
  flex: 1;
  min-width: 0;
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.day-nav__map {
  flex: 1;
  min-height: 0;
}

.day-nav__map .leaflet-container {
  width: 100%;
  height: 100%;
}

/* Recentre button — floats over the map, clear of the stats strip, and is only
   visible while GPS is on and a pan/zoom has detached follow (nav-overlay.js).
   Above Leaflet's own controls (z-index 1000) so it can't hide behind the
   attribution line it sits over. */
.day-nav__recenter {
  position: absolute;
  right: 14px;
  bottom: 74px;
  z-index: 1100;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 13px;
  border-radius: 19px;
  background: var(--color-white);
  color: #1e4a8d;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(20, 28, 48, 0.2);
}

.day-nav__recenter svg {
  width: 16px;
  height: 16px;
}

/* See .day-nav__cue[hidden] below — same [hidden]-vs-author-display quirk. */
.day-nav__recenter[hidden] {
  display: none;
}

.day-nav__poi-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  max-height: 50vh;
  overflow-y: auto;
  padding: 18px;
  background: var(--color-white);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -10px 30px rgba(20, 28, 48, 0.14);
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.day-nav__poi-panel--open {
  transform: translateY(0);
}

.day-nav__poi-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.day-nav__poi-name {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 800;
}

.day-nav__poi-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f3f0e8;
  color: var(--color-stone);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.day-nav__poi-desc {
  color: var(--color-stone);
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.5;
}

/* Track-following navigation HUD (instruction banner + live stats + heading arrow) */
.day-nav__cue {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(20, 28, 48, 0.08);
  flex-shrink: 0;
}
/* Author styles normally beat the UA [hidden] rule (origin trumps
   specificity in the cascade), so the explicit display:flex above would
   keep this band visible even with showNavHud(false) setting the hidden
   attribute. This override has higher specificity (class + attribute) and
   restores the expected hidden behavior — same pattern as track.css's
   .track-errors[hidden] / .track-preview[hidden]. */
.day-nav__cue[hidden] {
  display: none;
}
.day-nav__cue-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  color: #1fa958;
}
.day-nav__cue-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.day-nav__cue-primary {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--color-charcoal);
}
.day-nav__cue-secondary {
  font-size: 13px;
  font-weight: 700;
  color: #9aa0b0;
}
.day-nav__cue--alert {
  background: #fdecec;
}
.day-nav__cue--alert .day-nav__cue-icon,
.day-nav__cue--alert .day-nav__cue-primary {
  color: #c0392b;
}

.day-nav__stats {
  display: flex;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid rgba(20, 28, 48, 0.08);
  padding: 8px 0;
}
/* See .day-nav__cue[hidden] above — same [hidden]-vs-author-display quirk. */
.day-nav__stats[hidden] {
  display: none;
}
.day-nav__stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.day-nav__stat + .day-nav__stat {
  border-left: 1px solid rgba(20, 28, 48, 0.08);
}
.day-nav__stat-value {
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 800;
  color: var(--color-charcoal);
  line-height: 1;
}
.day-nav__stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #9aa0b0;
}

/* ===================================================================
   Landscape phones — HUD moves into a side rail.

   Stacked, the chrome costs ~170px (header ~59 + cue ~61 + stats ~49).
   A phone in landscape has roughly 340px of viewport, so the map was left
   with about half the screen. Here the cue and stats become a column beside
   the map instead of bands above and below it, and the map takes the full
   height next to them.

   The rail column is sized `auto`, so while the HUD is hidden (GPS off, when
   both the cue and the stats are display:none) it collapses to zero width and
   the map spans the whole grid — no empty gutter.
   =================================================================== */
@media (orientation: landscape) and (max-height: 560px) {
  .day-nav {
    --day-nav-rail-w: 200px;
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto 1fr;
    grid-template-areas:
      "header header"
      "cue    map"
      "stats  map";
  }

  /* Reclaim another ~13px: the header is the one band that stays full width. */
  .day-nav__header {
    grid-area: header;
    padding: 5px 12px;
  }

  .day-nav__close,
  .day-nav__gps-btn,
  .day-nav__fs-btn {
    min-height: 32px;
    padding: 5px 10px;
  }

  .day-nav__title {
    font-size: 13px;
  }

  .day-nav__map {
    grid-area: map;
    min-width: 0;
  }

  .day-nav__cue {
    grid-area: cue;
    width: var(--day-nav-rail-w);
    border-bottom: 0;
    border-right: 1px solid rgba(20, 28, 48, 0.08);
  }

  /* Stretches down the rest of the rail so it reads as one column rather than
     a floating box with cream underneath it. */
  .day-nav__stats {
    grid-area: stats;
    width: var(--day-nav-rail-w);
    flex-direction: column;
    justify-content: flex-start;
    padding: 2px 0;
    border-top: 0;
    border-right: 1px solid rgba(20, 28, 48, 0.08);
  }

  /* One stat per line, label and value side by side — three stacked columns
     would run past the bottom of a landscape screen. */
  .day-nav__stat {
    flex: 0 0 auto;
    flex-direction: row;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 12px;
  }

  .day-nav__stat + .day-nav__stat {
    border-left: 0;
    border-top: 1px solid rgba(20, 28, 48, 0.08);
  }

  /* The stats strip no longer sits at the foot of the map. */
  .day-nav__recenter {
    bottom: 14px;
  }

  /* Same 50vh cap as portrait, but that is only ~170px here — tighten the
     padding so the text inside gets more of it than the whitespace does. */
  .day-nav__poi-panel {
    padding: 12px 16px;
  }
}

/* Heading arrow user marker (north-up map; the glyph rotates to travel direction) */
.day-nav__me {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #1e4a8d;
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}
.day-nav__me-arrow {
  font-size: 12px;
  line-height: 1;
  color: #fff;
  opacity: 0.35;
  transition: transform 0.3s ease-out;
}
.day-nav__me-arrow--moving {
  opacity: 1;
}

/* ===================================================================
   Shared DayMap component styles — used by any compact
   window.DayMap.createDayMap() embed, not just this overlay: the
   overlay's own map wrapper above (via .day-nav__map, separate rule),
   /my-tour's hero/day maps (.my-tour__day-map), and the /track preview
   map (.day-map-injected). Moved here from my-tour.css so /track can use
   them without loading the booking page's stylesheet.
   =================================================================== */

.day-map-injected {
  width: 100%;
  height: 240px;
  margin-bottom: 12px;
  border: 0;
  border-radius: 22px;
  overflow: hidden;
  background: #e9ecdb;
}

.day-map-injected .leaflet-container {
  width: 100%;
  height: 100%;
  font-family: var(--font-body);
}

.day-map-injected.is-fullscreen {
  position: fixed !important;
  inset: 0 !important;
  z-index: 1000 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  border-radius: 0 !important;
  background: var(--color-cream);
}

.day-map-injected .leaflet-tile {
  width: 256.5px !important;
  height: 256.5px !important;
}

/* Start/end markers (S/E, or S1/E1... for multi-day composed routes) */
.map-endpoint {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.16);
}

.map-endpoint--start { background: #1fa958; color: #fff; }
.map-endpoint--end { background: var(--color-red); color: #fff; }

/* leaflet-elevation chart chrome */
.elevation-control.elevation {
  max-width: min(390px, 92vw);
  padding: 8px;
  border: 0;
  border-radius: 16px;
  background: var(--color-white);
  box-shadow: 0 4px 18px rgba(20, 28, 48, 0.12);
}

@media (min-width: 900px) {
  .day-map-injected {
    height: 280px;
  }
}
