/* Mobile layout for all pages.
   On narrow screens the header becomes a compact bar with the site name and a
   menu button (added by /js/mobile-nav.js); the links and the language and
   background selectors open in a panel below it.
   Load it after the page styles: !important overrides older per-page mobile
   header rules (e.g. maps.css made the header scroll away). */

.nav-brand,
.nav-menu-toggle {
  display: none;
}

/* Menu button icon: three bars that turn into a cross (drawn with CSS: the
   ☰ character is missing from some phone fonts) */
.nav-menu-toggle {
  flex: 0 0 44px;
  margin-left: auto;
  -webkit-tap-highlight-color: transparent;
}

/* The general button styles of the pages (gold on hover, scale, margin,
   transition) stuck to the menu button after a tap on phones (hover and focus
   stay on a touched button), and it could vanish. It keeps its own look. */
.nav-header .nav-menu-toggle,
.nav-header .nav-menu-toggle:hover,
.nav-header .nav-menu-toggle:focus,
.nav-header .nav-menu-toggle:active {
  margin: 0 0 0 auto !important;
  padding: 0 !important;
  transform: none !important;
  transition: none !important;
  background: rgb(28, 46, 74) !important;
  color: #FFD700 !important;
  border: 1px solid rgba(255, 215, 0, 0.75) !important;
  box-shadow: none !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.nav-header .nav-menu-toggle:focus-visible {
  outline: 2px solid #FFD700;
  outline-offset: 2px;
}

.nav-menu-icon,
.nav-menu-icon::before,
.nav-menu-icon::after {
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.2s ease, top 0.2s ease, background 0.2s ease;
}

.nav-menu-icon { position: relative; }

.nav-menu-icon::before,
.nav-menu-icon::after {
  content: '';
  position: absolute;
  left: 0;
}

.nav-menu-icon::before { top: -7px; }
.nav-menu-icon::after { top: 7px; }

.menu-open .nav-menu-icon { background: transparent; }
.menu-open .nav-menu-icon::before { top: 0; transform: rotate(45deg); }
.menu-open .nav-menu-icon::after { top: 0; transform: rotate(-45deg); }

@media (max-width: 768px) {
  :root {
    --header-height: 56px;
  }

  .nav-header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: auto !important;
    min-height: var(--header-height) !important;
    max-height: 100vh;
    overflow-y: auto;
    padding: 0 12px !important;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 0 !important;
    transform: none !important;
    z-index: 1000 !important;
  }

  .nav-brand {
    display: block;
    max-width: calc(100% - 56px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: var(--header-height);
    color: #FFD700;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.3);
  }

  .nav-menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid rgba(255, 215, 0, 0.5);
    border-radius: 8px;
    background: rgba(28, 46, 74, 0.6);
    color: #FFD700;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
  }

  .nav-header .nav-links,
  .nav-header .header-selectors {
    display: none !important;
  }

  /* Opaque, so content scrolling underneath doesn't show through */
  .nav-header {
    background: rgb(22, 36, 71) !important;
  }

  .nav-header.menu-open .nav-links {
    display: flex !important;
    flex: none !important;
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100%;
    gap: 8px !important;
    padding: 4px 0 12px;
  }

  .nav-header.menu-open .nav-link {
    justify-content: center;
    margin: 0 !important;
    padding: 12px 15px !important;
    font-size: 1rem !important;
  }

  .nav-header.menu-open .header-selectors {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: space-between !important;
    width: 100%;
    gap: 12px !important;
    padding-bottom: 14px;
  }

  .nav-header.menu-open .header-selectors .form-group {
    flex: 1 1 0;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 4px !important;
    min-width: 0;
  }

  .nav-header.menu-open .header-selectors select {
    width: 100%;
    height: auto !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 10px !important;
  }

  /* Below 16px, iPhones zoom the whole page in when a field is tapped */
  input,
  select,
  textarea {
    font-size: 16px !important;
  }

  .container {
    margin-top: calc(var(--header-height) + 16px) !important;
  }

  /* Keep page content inside the screen width (no sideways scrolling) */
  .info-panel {
    box-sizing: border-box;
  }

  .info-panel a {
    overflow-wrap: anywhere;
  }

  /* Buttons are full width on mobile; leave room for their side margins */
  .btn {
    max-width: calc(100% - 10px);
  }

  /* Maps page: the map was 100% wide plus side margins */
  .map-container {
    box-sizing: border-box;
    width: auto !important;
  }

  #hourlyTableBlock {
    box-sizing: border-box;
  }

  /* Wide tables scroll inside their own box, not the whole page */
  .table-container {
    max-width: 100%;
    overflow-x: auto;
  }

  #weatherTable th,
  #weatherTable td,
  #hourlyTable th,
  #hourlyTable td {
    padding: 6px 3px !important;
  }

  /* Home page planets: labels were 6-7px (unreadable) next to 15px ones */
  .circular-nav .orbit-button .label {
    font-size: 10px !important;
  }
}

/* Wide screens where the menu links don't fit in one row (long labels in
   some languages): the same compact header with the menu button.
   html.nav-compact is set by /js/mobile-nav.js; generated from the rules above. */
html.nav-compact {
  --header-height: 56px;
}

html.nav-compact .nav-header {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: auto !important;
  min-height: var(--header-height) !important;
  max-height: 100vh;
  overflow-y: auto;
  padding: 0 12px !important;
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 0 !important;
  transform: none !important;
  z-index: 1000 !important;
}

html.nav-compact .nav-brand {
  display: block;
  max-width: calc(100% - 56px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: var(--header-height);
  color: #FFD700;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  text-shadow: 0 0 5px rgba(255, 215, 0, 0.3);
}

html.nav-compact .nav-menu-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(255, 215, 0, 0.5);
  border-radius: 8px;
  background: rgba(28, 46, 74, 0.6);
  color: #FFD700;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

html.nav-compact .nav-header .nav-links,
html.nav-compact .nav-header .header-selectors {
  display: none !important;
}

html.nav-compact .nav-header {
  background: rgb(22, 36, 71) !important;
}

html.nav-compact .nav-header.menu-open .nav-links {
  display: flex !important;
  flex: none !important;
  flex-direction: column !important;
  align-items: stretch !important;
  width: 100%;
  gap: 8px !important;
  padding: 4px 0 12px;
}

html.nav-compact .nav-header.menu-open .nav-link {
  justify-content: center;
  margin: 0 !important;
  padding: 12px 15px !important;
  font-size: 1rem !important;
}

html.nav-compact .nav-header.menu-open .header-selectors {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  justify-content: space-between !important;
  width: 100%;
  gap: 12px !important;
  padding-bottom: 14px;
}

html.nav-compact .nav-header.menu-open .header-selectors .form-group {
  flex: 1 1 0;
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 4px !important;
  min-width: 0;
}

html.nav-compact .nav-header.menu-open .header-selectors select {
  width: 100%;
  height: auto !important;
  min-width: 0 !important;
  margin: 0 !important;
  padding: 10px !important;
}

html.nav-compact .container {
  margin-top: calc(var(--header-height) + 16px) !important;
}


/* The fixed footer must not cover the end of the page (print buttons,
   map credits, last panel). Some page styles fix body at the screen height,
   which leaves the padding behind the first screen, so let it grow. */
body {
  height: auto !important;
  min-height: 100vh;
  padding-bottom: calc(var(--footer-height, 40px) + 16px) !important;
}

@media print {
  .nav-brand,
  .nav-menu-toggle {
    display: none !important;
  }
}
