/* nav-mobile.css — accessible responsive top bar (shared across all pages).
   Desktop layout is unchanged: the runtime .nav-collapse wrapper is display:contents,
   so its children flow into the original .nav / .topbar flex exactly as before.
   At <=768px the collapsible items fold into a hamburger dropdown. No overflow-x hacks. */

/* Hamburger button — hidden on desktop, shown on mobile. */
.nav-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  margin-left: auto;
  background: transparent;
  border: 1.5px solid #D6E6F7;
  border-radius: 10px;
  color: #185FA5;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
}
.nav-hamburger:hover { border-color: #378ADD; }

/* Desktop: the wrapper is transparent to layout → original bar layout preserved. */
.nav-collapse { display: contents; }

/* Shared focus-visible affordance (accessibility). Applies site-wide. */
a:focus-visible,
button:focus-visible,
select:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid #378ADD;
  outline-offset: 2px;
  border-radius: 4px;
}

@media (max-width: 768px) {
  /* Anchor the dropdown to the bar and stop children from forcing overflow. */
  .nav,
  .topbar {
    position: relative;
    flex-wrap: nowrap;
  }

  .nav-hamburger { display: inline-flex; }

  /* Collapsible group becomes an absolutely-positioned dropdown panel. */
  .nav-collapse {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 10px 16px 14px;
    background: #fff;
    border-top: 1px solid #D6E6F7;
    box-shadow: 0 10px 24px rgba(20, 40, 80, 0.12);
    z-index: 300;
  }
  .nav-collapse.open { display: flex; }

  /* Normalize the nested link list inside the dropdown (overrides style.css @640 rule). */
  .nav-collapse .nav-links,
  .nav-collapse nav {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 2px;
    order: 0;
    margin: 0;
    padding: 0;
    border-top: none;
  }
  .nav-collapse .nav-links a,
  .nav-collapse nav a {
    display: block;
    padding: 12px 8px;
    font-size: 15px;
    border-radius: 8px;
    white-space: nowrap;
  }
  .nav-collapse .nav-links a:hover,
  .nav-collapse nav a:hover { background: #F0F7FD; }

  /* Buttons / badges / switches stack full-width and stay tappable. */
  .nav-collapse .nav-btn,
  .nav-collapse .rom-toggle-btn {
    display: block;
    width: 100%;
    text-align: center;
    margin: 4px 0 0;
  }
  .nav-collapse .level-badge {
    width: 100%;
    text-align: center;
    margin: 4px 0 0;
  }
  .nav-collapse .lang-switch { margin: 6px 0 0; }
  .nav-collapse .lang-switch select { width: 100%; }
  .nav-collapse #authControl {
    margin: 6px 0 0 !important;
    justify-content: center;
  }

  /* Keep the logo and (on learning pages) the progress bar visible in the bar. */
  .topbar .progress-wrap,
  .nav .logo,
  .topbar .logo { flex-shrink: 1; min-width: 0; }
}
