/* ══════════════════════════════════════════════════════════════════════════
   Shared site navigation — Caregivers Asha Society
   ──────────────────────────────────────────────────────────────────────────
   Loaded LAST on every page (after each page's own inline <style> block), so
   these rules win on source order without needing !important.

   The drawer takes over below 1021px. The full desktop nav measures ~975px
   wide (logo + six items + the two buttons), so switching any earlier than
   that would hide navigation people have room for.

   Two things live here:
     1. The mobile drawer. styles.css already ships a checkbox hamburger, but
        every page's inline CSS re-hid .nav-links at its own breakpoint with no
        :checked override — so on a phone the menu vanished with no way to open
        it. Fixed here, once, for all pages.
     2. The "Featured" submenu. Pure CSS: hover and focus-within on desktop,
        always-expanded inside the drawer. No JavaScript required.
   ══════════════════════════════════════════════════════════════════════════ */

/* ── The toggle checkbox ──────────────────────────────────────────────────
   styles.css sets `.nav-toggle { display: none }` unconditionally, which drops
   it out of the accessibility tree and makes the menu keyboard-unreachable.
   Keep it rendered, just visually hidden.                                   */
.site-header .nav-toggle {
  display: block;
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0; overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.site-header .nav-toggle-label { display: none; }

.site-header .nav-toggle:focus-visible + .nav-links + .nav-actions .nav-toggle-label,
.site-header .nav-toggle:focus       + .nav-links + .nav-actions .nav-toggle-label {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

/* ── Submenu: shared ──────────────────────────────────────────────────────  */
.site-header .nav-has-sub { position: relative; }

.site-header .nav-sub-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.site-header .nav-caret {
  width: 9px; height: 9px;
  flex: none;
  transition: transform .2s ease;
}

/* ── Submenu: desktop dropdown ────────────────────────────────────────────  */
@media (min-width: 1021px) {
  /* styles.css hides .nav-links below 1100px for its own hamburger. The full
     nav actually fits from ~975px, so it is restored here for the 1021-1100
     band; without this the menu would vanish entirely in that range. */
  .site-header .nav-links { display: flex; }
  .site-header .nav-toggle-label { display: none; }

  .site-header .nav-sub {
    position: absolute;
    top: 100%;
    left: -18px;
    min-width: 232px;
    max-width: 300px;
    margin: 0;
    padding: 8px;
    list-style: none;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 22px 40px -24px rgba(0, 0, 0, .45);
    z-index: 60;

    /* Hidden but animatable, and kept out of the tab order while closed. */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity .18s ease, transform .18s ease, visibility .18s;
  }

  /* A small bridge across the gap between the label and the panel, so the
     pointer can travel down without the menu closing underneath it. */
  .site-header .nav-has-sub::after {
    content: "";
    position: absolute;
    top: 100%; left: 0; right: 0;
    height: 14px;
  }

  .site-header .nav-has-sub:hover .nav-sub,
  .site-header .nav-has-sub:focus-within .nav-sub {
    opacity: 1;
    visibility: visible;
    transform: translateY(8px);
  }

  .site-header .nav-has-sub:hover .nav-caret,
  .site-header .nav-has-sub:focus-within .nav-caret {
    transform: rotate(180deg);
  }

  .site-header .nav-sub li { display: block; }

  .site-header .nav-sub a {
    display: block;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.35;
    transition: background .15s ease, color .15s ease;
  }

  .site-header .nav-sub a:hover,
  .site-header .nav-sub a:focus-visible {
    background: var(--teal-wash);
    color: var(--teal-deep);
  }
}

/* ── Drawer: phones and tablets ───────────────────────────────────────────
   Matches the 1100px breakpoint styles.css already uses for the hamburger.  */
@media (max-width: 1020px) {
  .site-header .nav-links {
    display: none;
    position: absolute;
    top: 100%; left: 0; right: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    margin: 0;
    padding: var(--s-md) var(--s-lg) var(--s-lg);
    list-style: none;
    background: #fff;
    border-bottom: 1px solid var(--line);
    box-shadow: 0 18px 30px -20px rgba(0, 0, 0, .4);
    max-height: calc(100vh - 68px);
    overflow-y: auto;
    z-index: 49;
  }

  .site-header .nav-toggle:checked ~ .nav-links { display: flex; }

  .site-header .nav-links > li { width: 100%; }

  .site-header .nav-links a,
  .site-header .nav-links .nav-sub-toggle {
    display: block;
    width: 100%;
    padding: 10px 0;
    font-size: 15.5px;
  }

  /* No hover on a phone, so the submenu is simply always open — an indented
     group under its parent. Nothing is unreachable without JavaScript. */
  .site-header .nav-sub {
    display: block;
    margin: 0 0 6px;
    padding: 0 0 0 16px;
    list-style: none;
    border-left: 2px solid var(--line);
  }

  .site-header .nav-sub a {
    padding: 8px 0;
    font-size: 14.5px;
    color: var(--ink-soft);
  }

  .site-header .nav-caret { display: none; }

  /* Make room for the hamburger. */
  .site-header .nav-actions .btn-nav-ghost,
  .site-header .nav-actions .btn-ghost { display: none; }

  .site-header .nav-toggle-label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 44px; height: 44px;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    cursor: pointer;
  }

  .site-header .nav-toggle-label span {
    display: block;
    width: 18px; height: 2px;
    background: var(--ink);
  }
}
