/*
  public/css/site-nav.css — the site menu's panels, one copy for every page
  ------------------------------------------------------------------------
  Loaded last on every page with the standard menu. Styles the desktop
  dropdown (#desktopDropdown), the phone slide-in (#mobileMenu), its
  overlay and their items. js/site-nav.js opens and closes them by toggling
  .is-open, and places the dropdown under the menu button.

  Not here: the menu *button* (.menu-btn*) and the .desktop-only /
  .mobile-only helpers. Those are part of each page's header and stay in
  the page's stylesheet.

  Colours use each page's own variables, so the menu matches the page's
  palette. Fallbacks cover pages whose palette lacks a variable (details
  and screeners have --bg-panel / --bg-hover instead of --bg-tertiary).
*/

/* ---------- Desktop dropdown ---------- */
.desktop-dropdown {
  position: fixed;
  top: 80px;    /* replaced at open time from the menu button's position */
  right: 20px;
  width: 280px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 1001;
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.desktop-dropdown.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.desktop-dropdown-content {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  /* Fill the panel. The dropdown also carries the page's .desktop-only
     helper, which on some pages is display: inline-flex (a flex row), and
     the content would otherwise shrink to its text width. */
  flex: 1 1 auto;
  width: 100%;
  box-sizing: border-box;
}
.desktop-dropdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: none;
  border: none;
  color: var(--text-primary);
  padding: 12px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  text-align: left;
  text-decoration: none;
  transition: background-color 0.15s;
}
.desktop-dropdown-item:hover,
.desktop-dropdown-item:focus-visible {
  background-color: var(--bg-hover, var(--bg-tertiary));
  outline: none;
}
.desktop-dropdown-icon {
  font-size: 18px;
  width: 20px;
  text-align: center;
}
.desktop-dropdown-divider {
  height: 1px;
  background-color: var(--border-color);
  margin: 4px 0;
}
.desktop-dropdown-logout {
  color: var(--color-red, #ef5350);
}
.desktop-dropdown-logout:hover {
  background-color: rgba(239, 83, 80, 0.1);
}

/* ---------- Phone slide-in menu ---------- */
.mobile-menu {
  position: fixed;
  top: 0;
  right: -300px;
  width: 280px;
  height: 100vh;
  background-color: var(--bg-secondary);
  z-index: 2000;
  transition: right 0.3s ease;
}
/* Shadow only while open: parked off-screen, a shadow bled a few pixels
   into the right edge of every page. */
.mobile-menu.is-open {
  right: 0;
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.3);
}
.mobile-menu-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1999;
  display: none;
}
.mobile-menu-overlay.is-open {
  display: block;
}
.mobile-menu-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mobile-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  border: none;
  color: var(--text-primary);
  padding: 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  font-family: inherit;
  text-align: left;
  text-decoration: none;
  transition: background-color 0.2s;
  background-color: var(--bg-tertiary, var(--bg-panel));
}
.mobile-menu-item:hover {
  background-color: var(--bg-hover, var(--bg-primary));
}
.mobile-menu-item:active {
  transform: scale(0.98);
}
.mobile-menu-icon {
  font-size: 20px;
  width: 24px;
  text-align: center;
}
.mobile-menu-link {
  text-decoration: none;
  color: var(--text-primary);
}
.mobile-logout {
  background-color: rgba(239, 83, 80, 0.15);
  border: 1px solid rgba(239, 83, 80, 0.3);
}
.mobile-logout:hover {
  background-color: rgba(239, 83, 80, 0.25);
}
.mobile-menu-divider {
  height: 1px;
  background-color: var(--border-color);
  margin: 12px 0;
}
.mobile-menu-info {
  padding: 12px 16px;
  background-color: var(--bg-tertiary, var(--bg-panel));
  border-radius: 8px;
  font-size: 13px;
}
.mobile-menu-info-label {
  color: var(--text-muted);
  margin-bottom: 4px;
}
.mobile-menu-info-value {
  color: var(--text-primary);
  font-weight: 500;
}

/* The slide-in is taller than a phone screen once the page's own actions
   are added, and iOS's 100vh includes the area behind the toolbars: let it
   scroll and size it to the visible viewport, so Logout is reachable.
   Scoped to the widths where the slide-in is used (at desktop widths the
   panel sits off-screen and overflow there shifted its shadow by a
   colour level along the right edge). */
@media (max-width: 1024px) {
  .mobile-menu {
    height: 100dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .mobile-menu-content {
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }
}

/* Keyboard focus on the menu button and panel items. */
.menu-btn:focus-visible,
.mobile-menu-item:focus-visible {
  outline: 2px solid var(--color-blue, #2196f3);
  outline-offset: 2px;
}
