/*
 * The shared top bar's menu (includes/class-site-header.php,
 * assets/js/common/nav-menu.js). Mobile-first:
 * - up to 1024px (phone, tablet): a hamburger button opens a panel under
 *   the bar with one link per row;
 * - 1025px and up (desktop): the links are an inline row and the button
 *   is gone.
 * The links fold away only once nav-menu.js has marked the nav
 * `data-ready`; without JavaScript they show as a row that wraps.
 */
.site-nav { display: flex; align-items: center; }

.nav-list {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 2px; justify-content: flex-end;
}

.nav-link {
  display: flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 12px; border-radius: 10px;
  color: var(--bar-text); text-decoration: none; font-size: 0.95rem; white-space: nowrap;
}
.nav-link [data-icon] { display: inline-flex; }
.nav-link:hover { background: rgb(255 255 255 / 0.12); }
.nav-link .count { font-size: 0.8rem; font-weight: 700; color: var(--honey); }

/* The hamburger: three bars that turn into a cross while open. */
.nav-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  min-width: 44px; min-height: 44px; padding: 0 10px;
  border: 0; border-radius: 10px; background: transparent; color: var(--bar-text);
  font: inherit; font-size: 0.95rem; cursor: pointer;
}
.nav-toggle:hover { background: rgb(255 255 255 / 0.12); }
.nav-toggle-icon { display: inline-grid; gap: 4px; width: 20px; }
.nav-toggle-icon span { display: block; height: 2px; border-radius: 1px; background: currentColor; transition: transform 0.18s ease, opacity 0.18s ease; }
.site-nav.is-open .nav-toggle-icon span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.site-nav.is-open .nav-toggle-icon span:nth-child(2) { opacity: 0; }
.site-nav.is-open .nav-toggle-icon span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
/* On a phone the word "תפריט" is hidden from sight only; screen readers still read it as the button name. */
.nav-toggle-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (min-width: 768px) { .nav-toggle-text { position: static; width: auto; height: auto; clip: auto; } }

/* Without JavaScript the links wrap under the brand, and the taller bar
   scrolls away instead of staying on top of the page. */
.bar { flex-wrap: wrap; }
@media (max-width: 1024px) {
  .bar:has(.site-nav:not([data-ready])) { position: static; }
}

/* Phone and tablet, with JavaScript: the links become a panel under the bar. */
@media (max-width: 1024px) {
  .site-nav[data-ready] .nav-list {
    display: none;
    position: absolute; top: 100%; inset-inline: 0;
    flex-direction: column; flex-wrap: nowrap; gap: 0;
    padding: 6px max(var(--gutter), env(safe-area-inset-right)) 10px max(var(--gutter), env(safe-area-inset-left));
    background: var(--bar-bg);
    box-shadow: 0 10px 24px rgb(0 0 0 / 0.25);
    max-height: calc(100vh - var(--bar-h)); max-height: calc(100dvh - var(--bar-h)); overflow-y: auto;
    overscroll-behavior: contain;
  }
  .site-nav[data-ready].is-open .nav-list { display: flex; }
  .site-nav[data-ready] .nav-link { min-height: 48px; font-size: 1rem; border-bottom: 1px solid rgb(255 255 255 / 0.1); border-radius: 0; }
  .site-nav[data-ready] li:last-child .nav-link { border-bottom: 0; }
}

/* Desktop: an inline row; the button is never needed. */
@media (min-width: 1025px) {
  .nav-toggle { display: none; }
}

@media (prefers-reduced-motion: reduce) { .nav-toggle-icon span { transition: none; } }

/* Windows high-contrast: the panel and the button keep a visible edge. */
@media (forced-colors: active) {
  .nav-toggle { border: 1px solid ButtonText; }
  .nav-toggle-icon span { background: ButtonText; }
  .site-nav[data-ready] .nav-list { border-bottom: 1px solid CanvasText; }
}
