/* ==========================================================================
   Global Site Navigation
   --------------------------------------------------------------------------
   Purpose
   Lightweight header navigation shared by root, assistant, and navigator.

   Scope
   - Menu trigger button
   - Dropdown/panel
   - Link groups
   - Language section
   - Active page / language state
   - Mobile / desktop behavior

   Notes
   - Designed to sit next to theme pills without dominating the header.
   - Keeps site navigation separate from page-specific UI logic.
   ========================================================================== */


/* ==========================================================================
   Navigation shell
   ========================================================================== */

.site-nav {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}


/* ==========================================================================
   Menu trigger
   ========================================================================== */

.site-nav-toggle {
  appearance: none;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  border-radius: 12px;
  min-height: 42px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition:
    background 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease;
}

.site-nav-toggle:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.14);
}

.site-nav-toggle:active {
  background: rgba(255, 255, 255, 0.05);
}

.site-nav-toggle:focus-visible {
  outline: none;
  border-color: rgba(var(--primary-rgb), 0.55);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.18);
}

.site-nav-toggle[aria-expanded="true"] {
  background: rgba(var(--primary-rgb), 0.08);
  border-color: rgba(var(--primary-rgb), 0.26);
}

.site-nav-toggle-icon {
  display: inline-flex;
  width: 16px;
  height: 16px;
  align-items: center;
  justify-content: center;
  color: currentColor;
  flex: 0 0 auto;
}

.site-nav-toggle-label {
  display: inline-block;
  white-space: nowrap;
}


/* ==========================================================================
   Navigation panel
   ========================================================================== */

.site-nav-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 120;
  width: min(320px, calc(100vw - 32px));
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-bg, var(--card));
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

.site-nav-panel[hidden] {
  display: none;
}


/* ==========================================================================
   Groups
   ========================================================================== */

.site-nav-group + .site-nav-group {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.site-nav-group-label {
  margin: 0 0 6px 2px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}


/* ==========================================================================
   Link list
   ========================================================================== */

.site-nav-links,
.site-nav-language-list {
  display: grid;
  gap: 4px;
}

.site-nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  padding: 10px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 560;
  line-height: 1.25;
  transition:
    background 140ms ease,
    color 140ms ease,
    box-shadow 140ms ease;
}

.site-nav-link:hover {
  background: rgba(255, 255, 255, 0.04);
}

.site-nav-link:active {
  background: rgba(255, 255, 255, 0.05);
}

.site-nav-link:focus-visible {
  outline: none;
  background: rgba(var(--primary-rgb), 0.10);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.18);
}

.site-nav-link.is-active {
  background: rgba(var(--primary-rgb), 0.10);
  color: var(--text);
}

.site-nav-link[aria-current="page"] {
  background: rgba(var(--primary-rgb), 0.10);
  color: var(--text);
}

.site-nav-link-current {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  flex: 0 0 auto;
  white-space: nowrap;
}


/* ==========================================================================
   Home brand link helper
   Optional helper if AltoTrail title becomes clickable
   ========================================================================== */

.site-brand-link {
  color: inherit;
  text-decoration: none;
}

.site-brand-link:hover {
  text-decoration: none;
}

.site-brand-link:focus-visible {
  outline: none;
  border-radius: 8px;
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.18);
}


/* ==========================================================================
   Header integration helpers
   Use these if root/assistant/navigator need calmer spacing in header-right
   ========================================================================== */

.header-right.header-right--site-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}


/* ==========================================================================
   Mobile behavior
   --------------------------------------------------------------------------
   Goal:
   - Menu trigger stays in the top-right corner
   - Theme pills move to their own row below
   - Solve placement at the header level, not inside a full-width wrapper
   ========================================================================== */

@media (max-width: 640px) {
  .header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    column-gap: 12px;
    row-gap: 12px;
  }

  .header-right.header-right--site-nav {
    display: contents;
  }

  .header > div:first-child {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
  }

  .header-right.header-right--site-nav .site-nav {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    align-self: start;
    margin-left: 0;
  }

  .header-right.header-right--site-nav .theme-pills {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: center;
    width: fit-content;
    max-width: 100%;
    justify-content: center;
  }

  .site-nav-toggle {
    min-height: 40px;
    padding: 0 13px;
    font-size: 14px;
  }

  .site-nav-panel {
    top: calc(100% + 8px);
    right: 0;
    width: min(300px, calc(100vw - 24px));
    padding: 9px;
    border-radius: 10px;
  }

  .site-nav-link {
    min-height: 42px;
    padding: 10px 11px;
  }
}


/* ==========================================================================
   Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .site-nav-toggle,
  .site-nav-link {
    transition: none;
  }
}