/* ============================================================================
   NAVIGATION SYSTEM - Consolidated & Organized
   ============================================================================
   
   STRUCTURE:
   1. CSS Custom Properties (Design Tokens)
   2. Base Styles (Desktop-first, works at all sizes)
   3. Desktop Enhancements (1100px+)
   4. Tablet/Medium Screens (641px - 1099px)
   5. Small Screens (481px - 640px)
   6. Mobile Screens (≤480px)
   7. Mobile Drawer (Touch devices only, ≤400px)
   8. Theme Toggle Component
   
   ============================================================================ */

/* ============================================================================
   1. CSS CUSTOM PROPERTIES
   ============================================================================ */

:root {
  /* Nav bar height - responsive, used for spacing */
  --nav-bar-height: clamp(3rem, 10vw + 1.5rem, 4.75rem);
  
  /* Consistent icon size across all breakpoints */
  --nav-icon-size: clamp(1.3rem, 2.2vw + 0.6rem, 4rem);
  
  /* Consistent logo size */
  --nav-logo-size: clamp(1rem, 6vw + 0.3rem, calc(var(--nav-bar-height) - 0.6rem));
}

/* ============================================================================
   2. BASE STYLES - Header & Nav Container
   ============================================================================ */

/* Reset any default header margins */
header {
  margin: 0;
  padding: 0;
}

.site-header {
  background: var(--brandPrimary);
  color: var(--surface);
  box-shadow: 0 12px 24px color-mix(in srgb, var(--brandPrimary) 18%, transparent);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0;
  padding: 0;
  border: none;
  border-top: none;
  border-bottom: none;
  min-height: auto;
}

.site-nav {
  background: var(--brandPrimary);
  display: flex;
  align-items: center;
  width: 100%;
  height: clamp(3rem, 10vw + 1.5rem, 4.75rem);
  padding: 0.25rem clamp(0.5rem, 2vw, 1.75rem);
  position: relative;
  overflow: visible;
}

/* ============================================================================
   2a. Brand / Logo
   ============================================================================ */

.site-nav__desktop-brand {
  display: inline-flex;
  align-items: center;
  gap: clamp(0.15rem, 0.5vw, 0.75rem);
  text-decoration: none;
  height: 100%;
  flex-shrink: 0;
  margin-right: 0.5rem;
  overflow: visible;
}

.site-nav__desktop-brand img {
  display: block;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}

.site-nav__desktop-brand-flags,
.site-nav__desktop-brand-logo {
  height: var(--nav-logo-size);
  max-height: var(--nav-logo-size);
}

/* ============================================================================
   2b. Navigation Links List
   ============================================================================ */

.site-nav__links {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: clamp(0.15rem, 0.8vw, 1.2rem);
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  overflow: visible;
}

.site-nav__links > li {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  flex-shrink: 1;
}

/* ============================================================================
   2c. Navigation Link Items (Buttons/Anchors)
   ============================================================================ */

.site-nav__links > li > a,
.site-nav__links > li > button {
  color: #fff !important;
  opacity: 0.95;
  text-decoration: none;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: clamp(0.15rem, 0.5vw, 0.75rem);
  line-height: 1.15;
  border-radius: 9999px;
  padding: clamp(0.2rem, 0.5vw, 0.8rem) clamp(0.3rem, 1vw, 1.2rem);
  transition: background-color 0.18s ease, color 0.18s ease, opacity 0.18s ease;
  font-size: clamp(0.65rem, 1.3vw + 0.3rem, 1.55rem);
  border: none;
  background: transparent;
  cursor: pointer;
  min-width: 0;
  flex-shrink: 1;
}

/* Hover & Focus States */
.site-nav__links > li > a:hover,
.site-nav__links > li > a:focus-visible,
.site-nav__links > li > button:hover,
.site-nav__links > li > button:focus-visible {
  background: color-mix(in srgb, var(--brandAccent) 30%, transparent);
  color: #fff !important;
  opacity: 1;
  outline: none;
  text-decoration: none;
}

/* Active/Current State */
.site-nav__links > li > a[aria-current="page"],
.site-nav__links > li > a.is-active,
.site-nav__links > li > button[aria-pressed="true"] {
  background: color-mix(in srgb, var(--brandAccent) 45%, transparent);
  color: #fff !important;
  opacity: 1;
}

/* ============================================================================
   2d. Nav Icons - CONSISTENT SIZE AT ALL BREAKPOINTS
   ============================================================================ */

.site-nav__links .nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--nav-icon-size);
  height: var(--nav-icon-size);
  flex-shrink: 0;
  min-width: 0;
  line-height: 0;
}

.site-nav__links .nav-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
  stroke: currentColor;
}

.site-nav__links .nav-icon svg [fill] { fill: currentColor !important; }
.site-nav__links .nav-icon svg [stroke] { stroke: currentColor !important; }

/* ============================================================================
   2e. Nav Labels
   ============================================================================ */

.site-nav__links .nav-label {
  display: inline-block;
  white-space: normal;
  line-height: 1.15;
  text-align: center;
  max-width: 9ch;
  word-wrap: break-word;
}

/* ============================================================================
   2f. Dropdown Menus
   ============================================================================ */

.site-nav__item.has-dropdown {
  position: relative;
}

.nav-dropdown {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  width: max-content;
  background: var(--brandPrimary);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  padding: 0.5rem;
  margin-top: 0.25rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
  z-index: 9999;
  list-style: none;
}

.site-nav__item.has-dropdown:hover .nav-dropdown,
.site-nav__item.has-dropdown:focus-within .nav-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.nav-dropdown__item {
  display: block;
}

.nav-dropdown__link {
  display: block;
  padding: 0.5rem 1rem;
  margin: 0.15rem 0;
  color: #fff !important;
  text-decoration: none !important;
  font-size: 0.95rem;
  white-space: nowrap;
  border-radius: 9999px;
  transition: background 0.15s ease;
  text-align: left;
}

.nav-dropdown__link:hover,
.nav-dropdown__link:focus-visible,
.nav-dropdown__link:active {
  background: color-mix(in srgb, var(--brandAccent) 30%, transparent);
  color: #fff !important;
  text-decoration: none !important;
}

/* Active/current page state - red pill highlight */
.nav-dropdown__link.is-active,
.nav-dropdown__link[aria-current="page"] {
  background: #6e2745;
  color: #fff !important;
}

.nav-dropdown__link.is-active:hover,
.nav-dropdown__link[aria-current="page"]:hover {
  background: #6e2745;
  color: #fff !important;
}

/* Hide nav-icon in dropdown - only show dot + text */
.nav-dropdown__link .nav-icon {
  display: none !important;
}

/* Dot bullet before dropdown item text */
.nav-dropdown__link .nav-label {
  display: inline-flex !important;
  align-items: center;
  white-space: nowrap !important;
  max-width: none !important;
  word-wrap: normal !important;
  text-align: left;
}

.nav-dropdown__link .nav-label::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #fff;
  border-radius: 50%;
  opacity: 0.7;
  flex-shrink: 0;
  margin-right: 0.65rem;
  vertical-align: middle;
}

/* ============================================================================
   2g. Gear/Settings Button (Desktop)
   ============================================================================ */

.nav-gear--desktop { display: none; }
.nav-gear--mobile { display: none; }

.nav-gear {
  position: relative;
  display: flex;
  align-items: center;
  height: 100%;
}

.nav-gear[open] {
  z-index: 15;
}

.nav-gear__button {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0 clamp(0.4rem, 2vw, 1.2rem);
  border-radius: 9999px;
  border: none;
  background: transparent;
  color: inherit;
  opacity: 0.95;
  transition: background-color 0.18s ease, color 0.18s ease, opacity 0.18s ease;
  height: 100%;
}

.nav-gear__button::-webkit-details-marker {
  display: none;
}

.nav-gear__button:hover,
.nav-gear__button:focus-visible {
  background: color-mix(in srgb, var(--brandPrimary) 38%, transparent);
  color: #fff;
  opacity: 1;
  outline: none;
}

.nav-gear[open] .nav-gear__button {
  background: color-mix(in srgb, var(--brandPrimary) 45%, transparent);
  color: #fff;
  opacity: 1;
}

.nav-gear__icon svg {
  width: var(--nav-icon-size);
  height: var(--nav-icon-size);
  display: block;
  stroke: currentColor;
}

.nav-gear__panel {
  position: absolute;
  top: calc(100% + 0.75rem);
  right: 0;
  background: color-mix(in srgb, var(--surface) 96%, transparent);
  border: 1px solid color-mix(in srgb, var(--brandPrimary) 18%, transparent);
  border-radius: 1rem;
  box-shadow: 0 20px 40px color-mix(in srgb, var(--brandSecondary) 25%, transparent);
  padding: 1rem;
  min-width: 12rem;
  display: grid;
  gap: 0.75rem;
  color: var(--text);
}

/* ============================================================================
   2h. Mobile-Only Elements (Hidden by Default)
   ============================================================================ */

.site-nav__row { display: none; }
.site-nav__drawer { display: none; }
.site-nav__drawer-panel { display: none; }
.site-nav__brand { display: none; } /* Mobile brand, shown only in drawer mode */

/* ============================================================================
   3. DESKTOP ENHANCEMENTS (1100px+)
   ============================================================================ */

@media (min-width: 1100px) {
  :root {
    --nav-bar-height: 5.5rem;
  }

  .site-nav__links {
    gap: clamp(0.1rem, 1vw, 2rem);
    margin-left: -3.15rem;
  }

  .site-nav__links > li > a,
  .site-nav__links > li > button {
    flex-direction: row;
    font-size: clamp(0.8rem, 1.1vw + 0.45rem, 1.9rem);
    padding: clamp(0.3rem, 0.6vw, 1rem) clamp(0.5rem, 1.1vw, 1.9rem);
    gap: clamp(0.2rem, 0.7vw, 1.1rem);
  }

  .site-nav__links .nav-label {
    font-size: clamp(0.7rem, 1.1vw + 0.35rem, 1.7rem);
    max-width: 8ch;
  }
}

/* ============================================================================
   4. TABLET / MEDIUM SCREENS (641px - 1099px)
   ============================================================================ */

@media (min-width: 641px) {
  .site-nav {
    padding-left: 0.9rem;
    padding-right: 1.75rem;
  }

  .site-nav__links {
    flex: 1 1 auto;
    overflow-x: visible;
    margin-left: -1.25rem;
  }

  /* Show desktop gear button */
  .nav-gear--desktop {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    margin-right: 0.5rem;
    height: 100%;
    flex-shrink: 0;
  }

  .nav-gear--desktop > summary.nav-gear__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent !important;
    border: 0 !important;
    padding: 0;
    width: auto;
    height: 100%;
    border-radius: 0;
    cursor: pointer;
  }

  /* Desktop gear icon - smaller than other nav icons (reduced by 1/3) */
  .nav-gear--desktop .nav-gear__icon svg {
    width: calc(var(--nav-icon-size) * 0.67);
    height: calc(var(--nav-icon-size) * 0.67);
  }

  .nav-gear--desktop > summary .nav-gear__label { display: none; }
}

@media (min-width: 641px) and (max-width: 1099px) {
  .site-nav__links {
    margin-left: 0;
    padding-left: 0.35rem;
    padding-right: 0.35rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ============================================================================
   5. HIDE LABELS ON MEDIUM SCREENS (481px - 1000px)
   ============================================================================ */

@media (min-width: 481px) and (max-width: 1000px) {
  :root {
    --nav-bar-height: clamp(3.2rem, 8vw + 1.2rem, 4.5rem);
  }

  .site-nav__links .nav-label {
    display: none !important;
  }

  .site-nav__links {
    gap: clamp(0.8rem, 3vw, 2rem);
  }

  .site-nav__links > li > a,
  .site-nav__links > li > button {
    padding: clamp(0.5rem, 1vw, 1.1rem) clamp(0.9rem, 1.8vw, 1.5rem);
    border-radius: 9999px;
  }

  /* Hover state - light shading (30%) */
  .site-nav__links > li > a:hover,
  .site-nav__links > li > a:focus-visible,
  .site-nav__links > li > button:hover,
  .site-nav__links > li > button:focus-visible {
    background: color-mix(in srgb, var(--brandAccent) 30%, transparent);
  }

  /* Active state - darker shading (45%) */
  .site-nav__links > li > a[aria-current="page"],
  .site-nav__links > li > a.is-active,
  .site-nav__links > li > button[aria-pressed="true"] {
    background: color-mix(in srgb, var(--brandAccent) 45%, transparent);
  }
}

/* ============================================================================
   6. SMALL SCREENS (≤640px) - Icons only, compact layout
   ============================================================================ */

@media (max-width: 640px) {
  .site-header {
    background: var(--brandPrimary) !important;
    width: 100vw !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    border: none !important;
  }

  .site-nav {
    background: var(--brandPrimary) !important;
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    padding: 0 clamp(0.3rem, 1.5vw, 0.75rem) !important;
    position: relative !important;
    top: auto !important;
    right: auto !important;
    float: none !important;
    border: none !important;
    border-radius: 0 !important;
    text-align: left !important;
  }

  .site-nav__desktop-brand {
    flex-shrink: 1;
    gap: clamp(0.05rem, 0.5vw, 0.25rem);
    margin-left: clamp(0.4rem, 1.2vw, 0.7rem);
    margin-right: clamp(0.2rem, 0.8vw, 0.5rem);
  }

  .site-nav__links {
    gap: clamp(0.5rem, 2vw, 1rem);
  }

  .site-nav__links > li > a,
  .site-nav__links > li > button {
    padding: clamp(0.35rem, 1.2vw, 0.6rem);
    border-radius: 9999px;
  }

  /* Hover state - light shading (30%) */
  .site-nav__links > li > a:hover,
  .site-nav__links > li > a:focus-visible,
  .site-nav__links > li > button:hover,
  .site-nav__links > li > button:focus-visible {
    background: color-mix(in srgb, var(--brandAccent) 30%, transparent);
  }

  /* Active state - darker shading (45%) */
  .site-nav__links > li > a[aria-current="page"],
  .site-nav__links > li > a.is-active,
  .site-nav__links > li > button[aria-pressed="true"] {
    background: color-mix(in srgb, var(--brandAccent) 45%, transparent);
  }
}

@media (max-width: 550px) {
  :root {
    --nav-bar-height: clamp(2.8rem, 10vw + 0.5rem, 4rem);
  }
  
  .site-nav__links .nav-label {
    display: none !important;
  }

  .site-nav__links > li > a,
  .site-nav__links > li > button {
    padding: clamp(0.3rem, 1vw, 0.5rem);
    border-radius: 9999px;
  }

  /* Hover state - light shading (30%) */
  .site-nav__links > li > a:hover,
  .site-nav__links > li > a:focus-visible,
  .site-nav__links > li > button:hover,
  .site-nav__links > li > button:focus-visible {
    background: color-mix(in srgb, var(--brandAccent) 30%, transparent);
  }

  /* Active state - darker shading (45%) */
  .site-nav__links > li > a[aria-current="page"],
  .site-nav__links > li > a.is-active,
  .site-nav__links > li > button[aria-pressed="true"] {
    background: color-mix(in srgb, var(--brandAccent) 45%, transparent);
  }
}

@media (max-width: 400px) {
  :root {
    --nav-bar-height: clamp(2.5rem, 12vw, 3.5rem);
  }

  .site-header {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
  }

  .site-nav {
    padding: 0 clamp(0.2rem, 1vw, 0.5rem) !important;
    position: relative !important;
    top: auto !important;
    right: auto !important;
  }

  .site-nav__desktop-brand {
    gap: 0.03rem;
    margin-left: 0.4rem;
    margin-right: 0.15rem;
  }

  .site-nav__links {
    gap: 0.4rem;
  }

  .site-nav__links > li > a,
  .site-nav__links > li > button {
    padding: 0.25rem;
    border-radius: 9999px;
  }

  .site-nav__links .nav-label {
    display: none !important;
  }

  /* Hover state - light shading (30%) */
  .site-nav__links > li > a:hover,
  .site-nav__links > li > a:focus-visible,
  .site-nav__links > li > button:hover,
  .site-nav__links > li > button:focus-visible {
    background: color-mix(in srgb, var(--brandAccent) 30%, transparent);
  }

  /* Active state - darker shading (45%) */
  .site-nav__links > li > a[aria-current="page"],
  .site-nav__links > li > a.is-active,
  .site-nav__links > li > button[aria-pressed="true"] {
    background: color-mix(in srgb, var(--brandAccent) 45%, transparent);
  }
}

/* ============================================================================
   7. MOBILE DRAWER (Touch devices only - PHONES & SMALL TABLETS)
   
   Shows hamburger menu ONLY when:
   - Viewport would show icons-only navigation (≤1000px)
   - AND it's a touch device (no hover, coarse pointer)
   
   If the device can't show text labels next to icons, show hamburger instead.
   Desktop browsers resized small will NOT trigger this - they'll see icons.
   ============================================================================ */

@media (max-width: 1000px) and (hover: none), (max-width: 1000px) and (pointer: coarse) {
  /* Set consistent nav bar height for all hamburger menu devices */
  :root {
    --mobile-nav-height: 68px;
  }

  /* Hide desktop navigation on mobile touch devices */
  .site-nav__links { display: none !important; }
  .nav-gear--desktop { display: none !important; }
  .site-nav__desktop-brand { display: none !important; }

  .site-nav {
    display: block !important;
    padding: 0 0.5rem !important;
    height: var(--mobile-nav-height) !important;
  }

  /* Show mobile row with hamburger, brand, gear - CONSISTENT ACROSS ALL DEVICES */
  .site-nav__row {
    display: grid !important;
    grid-template-columns: 76px 1fr 56px;
    align-items: center;
    justify-items: center;
    height: var(--mobile-nav-height) !important;
    padding: 0;
    background: var(--brandPrimary);
    width: 100%;
  }

  /* Hamburger button - fixed size, centered in grid cell */
  .site-nav__drawer {
    display: flex !important;
    grid-column: 1;
    position: static;
    justify-self: center;
    align-self: center;
    align-items: center;
    justify-content: center;
  }

  .site-nav__drawer-button {
    width: 52px;
    height: 52px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.10);
    color: #fff;
    cursor: pointer;
    list-style: none;
  }

  /* Hide default disclosure triangle on all browsers */
  .site-nav__drawer-button::-webkit-details-marker {
    display: none;
  }

  .site-nav__drawer-button::marker {
    display: none;
    content: '';
  }

  .site-nav__drawer-button:hover,
  .site-nav__drawer-button:focus {
    background: rgba(255,255,255,0.15);
  }

  .site-nav__drawer-button svg {
    width: 28px;
    height: 28px;
  }

  /* Center brand - fixed sizing */
  .site-nav__brand {
    display: inline-flex !important;
    grid-column: 2;
    justify-self: center;
    gap: 0.5rem;
    align-items: center;
    height: 100%;
    max-height: var(--mobile-nav-height);
    padding: 0.35rem 0;
  }

  .site-nav__brand-image {
    height: 58px;
    max-height: 58px;
    width: auto;
    object-fit: contain;
  }

  /* Mobile gear button - fixed size, centered in grid cell */
  .nav-gear--mobile {
    display: flex !important;
    grid-column: 3;
    justify-self: center;
    align-self: center;
    align-items: center;
    justify-content: center;
    height: auto !important;
  }

  .nav-gear--mobile > summary.nav-gear__button {
    width: 44px;
    height: 44px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    background: transparent;
    border: 0;
    color: #fff;
    list-style: none;
    padding: 0;
    cursor: pointer;
  }

  .nav-gear--mobile > summary.nav-gear__button:hover,
  .nav-gear--mobile > summary.nav-gear__button:focus {
    background: rgba(255,255,255,0.08);
  }

  /* Hide default disclosure triangle on all browsers */
  .nav-gear--mobile > summary::-webkit-details-marker { display: none; }
  .nav-gear--mobile > summary::marker { display: none; content: ''; }

  /* Icon wrapper and SVG centering */
  .nav-gear--mobile .nav-gear__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
  }

  .nav-gear--mobile .nav-gear__icon svg {
    width: 24px;
    height: 24px;
    display: block;
  }

  /* Drawer panel - consistent styling */
  .site-nav__drawer:not([open]) .site-nav__drawer-panel { display: none !important; }
  .site-nav__drawer[open] .site-nav__drawer-panel { display: block !important; }

  .site-nav__drawer-panel {
    position: fixed;
    top: var(--mobile-nav-height);
    left: 8px;
    width: auto;
    min-width: 240px;
    max-width: calc(100vw - 16px);
    max-height: calc(100vh - var(--mobile-nav-height) - 20px);
    max-height: calc(100dvh - var(--mobile-nav-height) - 20px);
    overflow-y: auto;
    background: rgba(11,22,48,0.98);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    z-index: 1050;
  }

  .site-nav__drawer-list {
    padding: 0.75rem;
    display: grid;
    gap: 0.5rem;
    margin: 0;
    list-style: none;
  }

  /* Drawer links - consistent fixed sizing */
  .drawer-link {
    display: grid;
    grid-template-columns: 24px 1fr;
    align-items: center;
    column-gap: 0.75rem;
    min-height: 48px;
    padding: 0.65rem 0.85rem;
    border-radius: 12px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.10);
    text-decoration: none;
    color: #fff !important;
    font-size: 1rem;
    font-weight: 500;
    transition: background-color 0.15s ease;
    list-style: none; /* Hide disclosure marker when used as summary */
  }

  /* Hide disclosure triangle on drawer links used as summaries */
  summary.drawer-link::-webkit-details-marker {
    display: none;
  }

  summary.drawer-link::marker {
    display: none;
    content: '';
  }

  .drawer-link:hover,
  .drawer-link:focus,
  .drawer-link:active {
    background: rgba(255,255,255,0.12);
    text-decoration: none;
  }

  .drawer-link.is-active {
    background: #6e2745;
    border-color: #6e2745;
  }

  .drawer-link .nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    line-height: 0;
  }

  .drawer-link .nav-icon svg {
    width: 24px;
    height: 24px;
  }

  /* Unified box for parent + subitems */
  .drawer-submenu {
    display: block;
    border-radius: 12px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.10);
    overflow: hidden;
  }

  .drawer-submenu > summary {
    list-style: none;
  }

  .drawer-submenu > summary::-webkit-details-marker {
    display: none;
  }

  .drawer-submenu > summary::marker {
    display: none;
    content: '';
  }

  /* Parent link inside unified box - no separate box styling */
  .drawer-link--parent {
    background: transparent !important;
    border: none !important;
    border-radius: 12px 12px 0 0;
  }

  /* When closed, parent has full rounded corners */
  .drawer-submenu:not([open]) .drawer-link--parent {
    border-radius: 12px;
  }

  /* Submenu list styling - inside the unified box */
  .drawer-submenu__list {
    list-style: none;
    margin: 0;
    padding: 0 0 0.5rem 0;
    display: grid;
    gap: 0;
    border-top: 1px solid rgba(255,255,255,0.08);
  }

  .drawer-submenu__item {
    padding: 0;
  }

  /* Subitem links - aligned with parent (dot in icon column, text aligned with parent text) */
  .drawer-link--sub {
    display: grid;
    grid-template-columns: 24px 1fr;
    align-items: center;
    column-gap: 0.75rem;
    min-height: 44px;
    padding: 0.5rem 0.85rem;
    border-radius: 0;
    background: transparent;
    border: none;
    text-decoration: none;
    color: rgba(255,255,255,0.9) !important;
    font-size: 0.95rem;
    font-weight: 500;
    transition: background-color 0.15s ease;
  }

  /* White dot in first grid column (aligned with parent icon) */
  .drawer-link--sub::before {
    content: '';
    display: flex;
    align-items: center;
    justify-content: center;
    width: 6px;
    height: 6px;
    background: #fff;
    border-radius: 50%;
    opacity: 0.7;
    margin: 0 auto;
  }

  /* Hide nav-icon in subitems - dot replaces it */
  .drawer-link--sub .nav-icon {
    display: none !important;
  }

  /* Text in second column, aligned with parent text */
  .drawer-link--sub .nav-label {
    display: block !important;
    font-size: 0.95rem;
  }

  .drawer-link--sub:hover,
  .drawer-link--sub:focus,
  .drawer-link--sub:active {
    background: rgba(255,255,255,0.08);
    text-decoration: none;
  }

  .drawer-link--sub.is-active {
    background: #6e2745;
    color: #fff !important;
  }


  .drawer-link .nav-label {
    display: block !important;
    font-size: 1rem;
  }

  /* Mobile gear panel - consistent styling */
  .nav-gear--mobile .nav-gear__panel {
    position: fixed;
    top: calc(var(--mobile-nav-height) + 4px);
    right: 8px;
    z-index: 1100;
    min-width: 240px;
    padding: 0.75rem;
    background: rgba(11,22,48,0.98);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  }
}

/* ============================================================================
   8. THEME TOGGLE COMPONENT
   ============================================================================ */

.theme-toggle__button {
  font: inherit;
  color: inherit;
  padding: 0;
  background: none;
  border: none;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.theme-toggle__button:focus-visible {
  outline: none;
}

.theme-toggle__button:focus-visible .theme-toggle__track {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brandAccent) 45%, transparent);
}

.theme-toggle__track {
  --toggle-track-height: 2.35rem;
  --toggle-track-padding: 0.3rem;
  --toggle-thumb-width: 2.3rem;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 8.75rem;
  height: var(--toggle-track-height);
  padding: 0 var(--toggle-track-padding);
  border-radius: 9999px;
  background: color-mix(in srgb, var(--surfaceAlt) 88%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brandPrimary) 18%, transparent);
  transition: background-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

.theme-toggle__label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.theme-toggle__label--day { color: var(--text-on-light); }
.theme-toggle__label--night { color: color-mix(in srgb, var(--text-on-light) 55%, transparent); }

.theme-toggle__thumb {
  position: absolute;
  top: var(--toggle-track-padding);
  left: calc(100% - var(--toggle-thumb-width) - var(--toggle-track-padding));
  width: var(--toggle-thumb-width);
  height: calc(var(--toggle-track-height) - (var(--toggle-track-padding) * 2));
  border-radius: 9999px;
  background: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 24px color-mix(in srgb, var(--brandSecondary) 25%, transparent);
  transition: left 0.3s ease, background-color 0.3s ease;
}

.theme-toggle__thumb svg {
  width: 1.4rem;
  height: 1.4rem;
  stroke: currentColor;
}

.theme-toggle__icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.theme-toggle__icon--sun {
  opacity: 1;
  color: var(--brandAccent-300);
}

.theme-toggle__icon--moon {
  color: var(--brandSecondary-700);
}

/* Dark theme overrides */
:root[data-theme='dark'] .nav-gear__button {
  color: color-mix(in srgb, var(--text-on-dark) 92%, transparent);
}

:root[data-theme='dark'] .nav-gear__button:hover,
:root[data-theme='dark'] .nav-gear__button:focus-visible {
  background: color-mix(in srgb, var(--brandSecondary-700) 42%, transparent);
  color: var(--text-on-dark);
}

:root[data-theme='dark'] .nav-gear[open] .nav-gear__button {
  background: color-mix(in srgb, var(--brandSecondary-700) 55%, transparent);
  color: var(--text-on-dark);
}

:root[data-theme='dark'] .nav-gear__panel {
  background: color-mix(in srgb, var(--brandSecondary-900) 90%, transparent);
  border-color: color-mix(in srgb, var(--text-on-dark) 22%, transparent);
  box-shadow: 0 26px 48px color-mix(in srgb, var(--brandSecondary) 45%, transparent);
  color: var(--text-on-dark);
}

:root[data-theme='dark'] .theme-toggle__track {
  background: color-mix(in srgb, var(--brandSecondary-900) 92%, transparent);
  color: var(--text-on-dark);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text-on-dark) 35%, transparent);
}

:root[data-theme='dark'] .theme-toggle__label--day {
  color: color-mix(in srgb, var(--text-on-dark) 55%, transparent);
}

:root[data-theme='dark'] .theme-toggle__label--night {
  color: var(--text-on-dark);
}

:root[data-theme='dark'] .theme-toggle__thumb {
  left: var(--toggle-track-padding);
}

:root[data-theme='dark'] .theme-toggle__icon--sun { opacity: 0; }
:root[data-theme='dark'] .theme-toggle__icon--moon { opacity: 1; }

/* ============================================================================
   END OF NAVIGATION SYSTEM
   ============================================================================ */
