/* ==========================================================================
   SuperMathWorksheets — Header Navigation stylesheet
   Pairs with header_navigation.html + assets/main.js.
   Self-contained: tokens, resets and header rules included so the header
   works standalone on any page.

   ALIGNED WITH FOOTER: the header branding and gutters are driven by the
   --hn-* tokens in section 3, which use the SAME values as
   footer_navigation.css (44px gutter / 27px title / 14px tagline / 55px mark)
   and the SAME single breakpoint (768px: 16px gutter, 22px title). Below
   ~377px the title and mark scale down fluidly so the brand + burger always
   fit on one row. The tagline is never hidden.

   Layout map
   ----------
   >1200px          full horizontal nav + inline search (index.html parity)
   993px – 1200px   condensed horizontal nav; nav gap + search pill flex
   <=992px          burger button + slide-in panel; topics always listed (no accordion)
   <=768px          footer breakpoint: 16px gutter, 22px title
   <=420px          full-width panel
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens
   -------------------------------------------------------------------------- */
:root{
  --color-blue:        #2F5FEE;
  --color-blue-dark:   #1E46C4;
  --color-blue-light:  #EAF0FF;
  --color-ink:         #1B2237;
  --color-ink-soft:    #000000;
  --color-body-bg:     #FFFFFF;
  --color-panel:       #EFF4FC;
  --color-border:      #E4E9F2;

  --color-green:       #17A673;
  --color-green-soft:  #E4F7EE;
  --color-purple:      #7C5CFB;
  --color-purple-soft: #EFEAFE;
  --color-yellow:      #F5A623;
  --color-yellow-soft: #FEF3DF;
  --color-pink:        #F0508A;
  --color-pink-soft:   #FDE9F0;
  --color-teal:        #1FB6C9;
  --color-teal-soft:   #E1F7FA;
  --color-orange:      #FF8A3D;
  --color-orange-soft: #FFEEE0;
  --color-gray-soft:   #EEF1F6;

  /* -- Topic dot palette: 18 distinct, soft/friendly, cohesive colors --
     Grouped by family (blues, greens/teals, purples, warm) so neighbours
     in the same family still read as clearly different swatches. */
  --topic-01: #4C8DF6; /* soft blue        — Kids Zone */
  --topic-02: #bce42c; /* sky blue         — Counting */
  --topic-03: #fddc47; /* deeper sky blue  — Comparing */
  --topic-04: #00ff62; /* teal             — Size */
  --topic-05: #1FB6C9; /* bright teal      — Patterns */
  --topic-06: #2CC2A0; /* teal-mint        — Position */
  --topic-07: #3FB884; /* mint green       — Subtraction */
  --topic-08: #17A673; /* green            — Skip Counting */
  --topic-09: #6BBF4D; /* leaf green       — Addition */
  --topic-10: #9A8CFB; /* lavender         — Time */
  --topic-11: #7C5CFB; /* soft purple      — Money */
  --topic-12: #a95fe9; /* orchid purple    — Fractions */
  --topic-13: #e845fdd2; /* soft pink        — Probability */
  --topic-14: #F0508A; /* coral pink       — Classifying & Sorting */
  --topic-15: #F08769; /* coral            — Shapes */
  --topic-16: #FF8A3D; /* soft orange      — Data and Graph */
  --topic-17: #F5A623; /* warm yellow      — Vocabulary */
  --topic-18: #eb7ed3; /* golden yellow    — Measurement */

  --color-browse-all: #005aff; /* softer, milder tone for "Browse All Topics" */


  --color-brand-super:  #2F8FEF;
  --color-brand-math:   #F5A623;
  --color-brand-sheets: #1B2A6B;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-pill: 999px;

  --shadow-card: 0 1px 2px rgba(20, 30, 60, .04), 0 8px 24px rgba(20, 30, 60, .06);
  --shadow-card-hover: 0 4px 10px rgba(20, 30, 60, .06), 0 16px 32px rgba(20, 30, 60, .10);
  --shadow-header: 0 1px 0 rgba(20, 30, 60, .06);

  --font-display: var(--smw-font-stack);
  --font-body: var(--smw-font-stack);

  --header-h: 76px;          /* single source of truth, updated per breakpoint */
  --nav-panel-w: min(340px, 86vw);
  --ease: .2s ease;
}

/* --------------------------------------------------------------------------
   2. Minimal resets required by the header
   -------------------------------------------------------------------------- */
*{ box-sizing:border-box; }
img{ max-width:100%; display:block; }
a{ color:inherit; text-decoration:none; }
button{ font-family:inherit; cursor:pointer; }

/* Guarantees zero horizontal scrolling caused by the header at any width. */
html, body{ overflow-x:hidden; }

/* MATCH FOOTER: Use the exact same container max-width and padding as footer */
.wrap{
  max-width:1400px;
  margin:0 auto;
  padding:0 44px;
  box-sizing: border-box;
}

a:focus-visible, button:focus-visible, input:focus-visible{
  outline:3px solid var(--color-blue);
  outline-offset:2px;
  border-radius:6px;
}

/* --------------------------------------------------------------------------
   3. Header shell + brand
   -------------------------------------------------------------------------- */
/* Font isolation: this component enforces the exact font family from count_color.css */
.site-header,
.site-header *{
  font-family: var(--smw-font-stack) !important;
}
.site-header{
  position:fixed;
  top:0;
  left:0;
  right:0;
  width:100%;
  z-index:1000;
  background:#fff;
  box-shadow:var(--shadow-header);
  font-family:var(--smw-font-stack);
  /* Equal space above and below the row so its content is truly centred.
     4px + 76px row + 4px = the same 84px total the fixed-header spacer below
     already assumes (previously 8px top / 0 bottom, which sat 4px low). */
  padding:4px 0;

  /* Branding + gutter tokens. These mirror footer_navigation.css exactly:
     container padding 44px, mark 55px, title 27px, tagline 14px. Scoped to
     the header so nothing else on the page is affected. */
  --hn-gutter:44px;
  --hn-mark:55px;
  --hn-title:27px;
  --hn-tagline:14px;
}
/* Footer's one breakpoint (768px): gutter 44 -> 16, title 27 -> 22. The two
   clamp() values only matter on phones narrower than ~386px, where the 22px
   title + 55px mark + burger would no longer fit on one row. Below that the
   title and mark scale down together in proportion to the room left after
   the gutters and burger (about 17px / 43px at 320px), instead of hiding or
   clipping anything. From ~386px up they resolve to exactly the footer's
   22px title and 55px mark. */
@media (max-width:768px){
  .site-header{
    --hn-gutter:16px;
    --hn-title:clamp(15px, calc(7.7vw - 7.7px), 22px);
    --hn-mark:clamp(32px, calc(19.3vw - 19.3px), 55px);
  }
}
/* Same gutters as the footer container at every width, so header and footer
   content edges line up. Scoped to the header; the generic .wrap rules above
   and in the media queries below are left as they were for other users. */
.site-header .wrap{
  padding-left:var(--hn-gutter);
  padding-right:var(--hn-gutter);
}
/* Fixed positioning takes the header out of document flow, so the element
   right after it needs an equivalent spacer to avoid being tucked
   underneath it. */
.site-header + *{
  margin-top:calc(var(--header-h) + 8px);
}
@media (max-width:992px){
  /* Mobile/tablet: the header is a normal in-flow element that scrolls away
     with the page (no fixed/sticky overlay). `relative` (not `static`) keeps
     the z-index:1000 stacking context, so the slide-in panel and scrim still
     layer above page content exactly as before. The spacer is removed because
     the header now occupies its own space in the flow. */
  .site-header{
    position:relative;
    top:auto;
    left:auto;
    right:auto;
  }
  .site-header + *{
    margin-top:0;
  }
}
.header-inner{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px 24px;
  height:var(--header-h);
}

/* MATCH FOOTER: Brand alignment and sizing */
.brand{
  display:flex;
  align-items:center;
  gap:8px;
  min-width:0;
  flex:0 0 auto;
}
.brand-mark{
  width:var(--hn-mark);
  height:var(--hn-mark);
  border-radius:0px;
  object-fit:contain;
  flex:none;
}
.brand-text{
  display:flex;
  flex-direction:column;
  line-height:1.12;
  min-width:0;
}
.brand-text .name{
  font-family:var(--smw-font-stack);
  font-weight:800;
  font-size:var(--hn-title);
  color:var(--color-ink);
  white-space:nowrap;
  letter-spacing:normal; /* = footer title */
  line-height:1.12;
}
.brand-text .name .c-super{ color: #028fff; }
.brand-text .name .c-math{ color: #fe8802; }
.brand-text .name .c-sheets{ color:#101d76; }
.brand-text .tagline{
  margin-top:2px;
  font-size:var(--hn-tagline);
  font-weight:600;
  color:var(--color-ink-soft);
  white-space:nowrap;
}

/* --------------------------------------------------------------------------
   4. Burger toggle + scrim (mobile only)
   -------------------------------------------------------------------------- */
.menu-toggle{
  display:none;
  align-items:center;
  justify-content:center;
  width:44px;
  height:44px;
  flex:none;
  border:1px solid var(--color-border);
  border-radius:var(--radius-sm);
  background:#fff;
  color:var(--color-ink);
  transition:background var(--ease), color var(--ease);
  padding:0;
}
.menu-toggle:hover{ background:var(--color-panel); color:var(--color-blue); }
.menu-toggle .icon-close{ display:none; }
.menu-toggle[aria-expanded="true"] .icon-burger{ display:none; }
.menu-toggle[aria-expanded="true"] .icon-close{ display:block; }

.nav-scrim{ display:none; }

/* --------------------------------------------------------------------------
   5. Primary nav — desktop horizontal bar
   -------------------------------------------------------------------------- */
.main-nav{
  display:flex;
  align-items:center;
  gap:26px;
  flex-wrap:nowrap;
  min-width:0;
}
.nav-item{ position:relative; }
.nav-link{
  display:flex;
  align-items:center;
  gap:6px;
  padding:10px 12px;
  font-size:15.5px;
  font-weight:700;
  color:var(--color-ink);
  border-radius:var(--radius-sm);
  background:none;
  border:none;
  font-family:var(--smw-font-stack);
  white-space:nowrap;
  transition:background var(--ease), color var(--ease);
}
.nav-link:hover{ background:var(--color-panel); color:var(--color-blue); }
/* Contact / Privacy / Terms live in the mobile drawer only (shown <= 992px). */
.nav-utility{ display:none; }
.nav-link .chev{ transition:transform .15s ease; flex:none; }
.nav-item.is-open > .nav-link{ background:var(--color-panel); color:var(--color-blue); }
.nav-item.is-open > .nav-link .chev{ transform:rotate(180deg); }

/* --------------------------------------------------------------------------
   6. HOME text link (icon removed)
   -------------------------------------------------------------------------- */
.nav-link--home{
  text-transform:uppercase;
  letter-spacing:.04em;
}
.nav-link--home:hover{ background:var(--color-panel); color:var(--color-blue); }

/* --------------------------------------------------------------------------
   7. By Topic mega menu (hover to open on desktop, click/tap everywhere)
   NOTE: the panel stays in the layout with visibility/opacity instead of
   `display:none`, so the transition can run and so the browser can hit-test
   it while the pointer travels across the 8px gap.
   -------------------------------------------------------------------------- */
.nav-item--mega{ position:static; }

.dropdown{
  position:absolute;
  top:calc(100% + 8px);
  left:50%;
  right:auto;
  width:max-content;
  max-width:min(700px, calc(100vw - 32px));
  /* Solid, fully opaque white panel — no glass, no transparency. */
  background:#ffffff;
  border:1px solid var(--color-border);
  box-shadow:0 2px 6px rgba(20,30,60,.06), 0 18px 40px rgba(20,30,60,.14);
  border-radius:var(--radius-md);
  padding:8px 10px 6px;
  opacity:0;
  visibility:hidden;
  pointer-events:none;
  transform:translate(-50%, 6px);
  transition:opacity .15s ease, transform .15s ease, visibility .15s linear;
  z-index:110;
}
.nav-item.is-open > .dropdown{
  opacity:1;
  visibility:visible;
  pointer-events:auto;
  transform:translate(-50%, 0);
}


.mega-grid{
  display:grid;
  grid-template-columns:auto auto auto;
  gap:0 14px;
  justify-content:center;
  align-items:start;
}
.mega-col{ list-style:none; margin:0; padding:0; min-width:0; }

.mega-all{
  grid-column:1; /* sits under column 1 on desktop (same spot as before it left the <ul>) */
  display:inline-flex;
  align-items:center;
  gap:8px;
  margin-top:6px;
  padding:7px 10px 2px;
  border-top:1px solid var(--color-border);
  width:100%;
  font-size:15px;
  font-weight:800;
  /* Softer/milder than the topic colors, per design requirement. */
  color:var(--color-browse-all);
  transition:color var(--ease);
}
/* .mega-all:hover{ color:rgb(71, 71, 201) } */

.dropdown-link{
  display:flex; align-items:center; gap:9px;
  padding:6px 10px;
  white-space:nowrap;
  border-radius:10px;
  font-size:15px;
  font-weight:650;
  color:var(--color-ink);
  transition:background var(--ease), color var(--ease);
}
.dropdown-link:hover{ background:var(--color-panel); color:var(--color-blue); }

.dropdown-link .dot{
  width:8px; height:8px; border-radius:50%;
  background:var(--color-blue);
  flex:none;
}
/* 18 unique topic colors — one per dropdown item, see token list above. */
.dropdown-link .dot--t1{  background:var(--topic-01); }
.dropdown-link .dot--t2{  background:var(--topic-02); }
.dropdown-link .dot--t3{  background:var(--topic-03); }
.dropdown-link .dot--t4{  background:var(--topic-04); }
.dropdown-link .dot--t5{  background:var(--topic-05); }
.dropdown-link .dot--t6{  background:var(--topic-06); }
.dropdown-link .dot--t7{  background:var(--topic-07); }
.dropdown-link .dot--t8{  background:var(--topic-08); }
.dropdown-link .dot--t9{  background:var(--topic-09); }
.dropdown-link .dot--t10{ background:var(--topic-10); }
.dropdown-link .dot--t11{ background:var(--topic-11); }
.dropdown-link .dot--t12{ background:var(--topic-12); }
.dropdown-link .dot--t13{ background:var(--topic-13); }
.dropdown-link .dot--t14{ background:var(--topic-14); }
.dropdown-link .dot--t15{ background:var(--topic-15); }
.dropdown-link .dot--t16{ background:var(--topic-16); }
.dropdown-link .dot--t17{ background:var(--topic-17); }
.dropdown-link .dot--t18{ background:var(--topic-18); }

/* Legacy dot classes kept for backward compatibility with any other markup
   that still references them (unchanged colors). */
.dropdown-link .dot--green{  background:var(--color-green);  }
.dropdown-link .dot--pink{   background:rgba(250, 46, 80, 0.418);   }
.dropdown-link .dot--purple{ background:var(--color-purple); }
.dropdown-link .dot--yellow{ background:var(--color-yellow); }
.dropdown-link .dot--orange{ background:var(--color-orange); }
.dropdown-link .dot--teal{   background:var(--color-teal);   }

/* --------------------------------------------------------------------------
   8. Header search
   -------------------------------------------------------------------------- */
.header-search{
  position:relative;
  display:flex;
  align-items:center;
  background:#fff;
  border:1px solid var(--color-border);
  border-radius:var(--radius-pill);
  padding:6px 6px 6px 18px;
  gap:8px;
  width:220px;
  flex:none;
}
.header-search input{
  flex:1 1 auto;
  border:none;
  outline:none;
  font-size:14px;
  font-family:var(--smw-font-stack);
  color:var(--color-ink);
  background:transparent;
  min-width:0;
  padding:6px 0;
  width:100%;
}
.header-search input::placeholder{ color:#9AA3B5; }
.header-search-btn{
  flex:none;
  width:34px;
  height:34px;
  border-radius:50%;
  border:none;
  background:var(--color-blue);
  color:#fff;
  display:grid;
  place-items:center;
  transition:background var(--ease);
  padding:0;
}
.header-search-btn:hover{ background:var(--color-blue-dark); }

.header-search--mobile{ display:none; }

/* Suggestions dropdown */
.header-search-suggestions{
  position:absolute;
  top:calc(100% + 8px);
  left:0;
  right:0;
  background:#ffffff;
  border:1px solid var(--color-border);
  border-radius:14px;
  box-shadow:0 8px 24px rgba(16, 29, 118, 0.12);
  padding:6px 0;
  margin:0;
  list-style:none;
  z-index:1100;
  max-height:280px;
  overflow-y:auto;
}
.header-search-suggestions[hidden]{
  display:none;
}
.header-search-sugg-item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  padding:8px 14px;
  font-size:14px;
  font-weight:600;
  color:var(--color-ink);
  text-decoration:none;
  cursor:pointer;
  transition:background var(--ease), color var(--ease);
}
.header-search-sugg-item:hover,
.header-search-sugg-item.is-selected{
  background:var(--color-panel);
  color:var(--color-blue);
}
.header-search-sugg-item .sugg-category{
  font-size:11px;
  font-weight:700;
  color:var(--color-ink-soft);
  text-transform:uppercase;
  letter-spacing:0.03em;
  background:#eef2f7;
  padding:2px 6px;
  border-radius:6px;
  flex:none;
}
.header-search-sugg-empty{
  padding:10px 14px;
  font-size:13px;
  color:var(--color-ink-soft);
  text-align:center;
}

/* --------------------------------------------------------------------------
   9. Responsive — condensed desktop
   MATCH FOOTER: Use the same padding values as footer at this breakpoint
   -------------------------------------------------------------------------- */
@media (max-width:1200px){
  .wrap{ padding:0 16px; }
  .brand{ margin-left:0; }
  .nav-link{ font-size:14.5px; font-weight:700; padding:10px 9px; }
  .header-search--desktop{ padding-left:14px; }
  .dropdown{ max-width:min(640px, calc(100vw - 24px)); padding:8px 10px 6px; }
}

/* --------------------------------------------------------------------------
   10. Responsive — tablet & mobile (slide-in panel, vertical stack)
   MATCH FOOTER: Use the same 16px padding as footer at this breakpoint
   -------------------------------------------------------------------------- */
@media (max-width:992px){
  :root{ --header-h:76px; } /* accounts for the added 8px header padding-top */

  .wrap{ padding:0 16px; }

  .header-search--desktop{ display:none; }
  .menu-toggle{ display:flex; }

  /* Slide-in panel: everything stacks vertically, never scrolls sideways. */
  .main-nav{
    position:fixed;
    top:var(--header-h);
    right:0;
    bottom:0;
    width:var(--nav-panel-w);
    max-width:100vw;
    background:#fff;
    flex-direction:column;
    align-items:stretch;
    gap:0;
    padding:12px 16px 24px;
    overflow-y:auto;
    overflow-x:hidden;
    overscroll-behavior:contain;
    box-shadow:-8px 0 24px rgba(20,30,60,.12);
    transform:translate3d(100%, 0, 0);
    transition:transform .22s ease, visibility 0s linear .22s;
    visibility:hidden;
    backface-visibility:hidden;
    will-change:transform;
    z-index:120;
  }
  .main-nav.is-open{
    transform:translate3d(0, 0, 0);
    visibility:visible;
    transition-delay:0s;
  }

  .header-search--mobile{
    display:flex;
    width:100%;
    margin-bottom:12px;
  }

  .nav-item{ position:static; width:100%; }

  .nav-link{
    width:100%;
    justify-content:space-between;
    padding:14px 10px;
    font-size:17px;
    font-weight:700;
    border-radius:0;
    border-bottom:1px solid var(--color-border);
    white-space:normal;
  }
  .nav-link:hover{ background:none; color:var(--color-blue); }
  /* Topics are always listed in the drawer: the "Browse by Topics" trigger is
     not needed here, and the panel is a plain static block (no accordion).
     Desktop keeps its trigger and hover/click dropdown (>= 993px). */
  .nav-item--mega > [data-dropdown-trigger]{ display:none; }

  .dropdown{
    position:static;
    min-width:0;
    max-width:none;
    width:100%;
    border:none;
    box-shadow:none;
    border-radius:0;
    background:transparent;
    backdrop-filter:none;
    padding:0;
    left:auto;
    transform:none;
    opacity:1;
    visibility:visible;
    pointer-events:auto;
    transition:none;
    display:block;
  }
  /* Needs the same specificity as the base `.nav-item.is-open > .dropdown`
     (translate(-50%)) so the static drawer panel is never shifted, open or not. */
  .nav-item.nav-item--mega > .dropdown{ transform:none; left:auto; }
  .nav-item--mega{ position:static; }
  .mega-grid{ grid-template-columns:1fr; gap:0; justify-content:stretch; }
  .dropdown-link{ white-space:normal; }
  .dropdown-link{ padding:11px 8px; min-height:44px; font-size:16px; font-weight:650; }

  /* "Browse All Topics": one soft button directly after the last topic.
     The desktop divider (border-top) is dropped here — it was the line that
     used to cut the list in two. */
  .mega-all{
    grid-column:auto; /* single-column grid: auto-place after the last topic list */
    justify-content:space-between;
    margin:8px 0 4px;
    padding:12px 14px;
    min-height:44px;
    border-top:0;
    border-radius:10px;
    background:var(--color-panel);
    font-size:16px;
  }
  .mega-all:hover{ background:var(--color-blue-light); }

  /* Informational group: About Us + Contact / Privacy / Terms, set apart from
     the topics by one deliberate divider above About Us. */
  .nav-link--about{
    margin-top:12px;
    border-top:1px solid var(--color-border);
  }
  .nav-link--about,
  .nav-link--utility{
    justify-content:flex-start;
    padding:12px 8px;
    min-height:44px;
    font-size:16px;
    font-weight:600;
    border-bottom:0;
  }
  .nav-utility{ display:block; }

  /* HOME sits inline in the slide-in panel. */
  .nav-link--home{ justify-content:flex-start; }


  .nav-scrim{
    display:block;
    position:fixed;
    inset:var(--header-h) 0 0 0;
    background:rgba(20,30,60,.35);
    opacity:0;
    visibility:hidden;
    transition:opacity var(--ease), visibility 0s linear .2s;
    z-index:110;
  }
  .nav-scrim.is-open{ opacity:1; visibility:visible; transition-delay:0s; }

  body.nav-open{ overflow:hidden; }
}

@media (max-width:420px){
  :root{ --nav-panel-w:100vw; }
  .wrap{ padding:0 12px; }
}

/* --------------------------------------------------------------------------
   11. Motion preferences
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion:reduce){
  .main-nav, .dropdown, .nav-link, .chev, .nav-scrim{ transition:none !important; }
}

/* --------------------------------------------------------------------------
   11. Desktop dropdown open state (pointer devices)
   `.is-open` (set by header-navigation.js on hover/focus/click) is the SINGLE
   source of truth for which panel is visible. CSS :hover / :focus-within are
   deliberately NOT used to open panels: they could keep a previously opened
   menu visible (e.g. a still-focused trigger) while another one opened,
   leaving two overlapping dropdowns on screen.
   The `padding-bottom / negative margin` on .nav-item bridges the 8px gap
   between the trigger and the panel, so the pointer never leaves the hover
   area on its way into the menu.
   -------------------------------------------------------------------------- */
@media (min-width:993px){
  .nav-item{ padding-bottom:8px; margin-bottom:-8px; }

  /* Any non-open panel is fully hidden and un-hittable, immediately. */
  .nav-item:not(.is-open) > .dropdown{
    opacity:0;
    visibility:hidden;
    pointer-events:none;
    transform:translate(-50%, 6px);
    transition:none;
  }

  /* Browse by Topics ships open-by-default in the markup for the mobile
     panel; on desktop that must never apply — desktop open/close stays
     purely hover/click-driven via JS, as before. */
  .nav-item--mega.is-open > .dropdown{
    opacity:0;
    visibility:hidden;
    pointer-events:none;
    transform:translate(-50%, 6px);
    transition:none;
  }
  .nav-item--mega.is-open[data-hn-opened] > .dropdown{
    opacity:1;
    visibility:visible;
    pointer-events:auto;
    transform:translate(-50%, 0);
    transition:opacity .15s ease, transform .15s ease, visibility .15s linear;
  }

  /* Nav keeps its intrinsic width so links can never be squeezed/overlapped;
     the search pill is the element that flexes. */
  .main-nav{ flex:0 0 auto; }

  /* Give the header row a little more horizontal room on wide screens so the
     wider search pill stays balanced instead of crowding "About Us". */
  .site-header .wrap{ max-width:1400px; }

  /* Search box: vertically centred on the nav baseline, balanced gap after
     "About Us", noticeably wider than before, and it shrinks first so it
     never covers a nav item on tighter desktop widths. */
  .header-search--desktop{
    align-self:center;
    margin-left:32px;
    width:280px;      /* noticeably wider than the previous 132–160px pill */
    flex:0 1 auto;    /* still shrinks first on tighter desktop widths */
    min-width:170px;  /* keeps the placeholder fully readable */
  }
}

/* Condensed desktop (993px–1200px). The brand now keeps its full footer size
   here, so the row is kept balanced by easing the spacing instead of by
   shrinking the brand: the gap between nav links grows smoothly from 12px at
   993px to the normal 26px at 1200px (no step at the 1200/1201 boundary), and
   the search pill drops its extra left margin. margin-right is left at 0 so
   the row has identical left and right gutters (it used to be 16px left /
   32px right). */
@media (min-width:993px) and (max-width:1200px){
  .main-nav{ gap:clamp(12px, calc(12px + (100vw - 993px) * .0676), 26px); }
  .header-search--desktop{ margin-left:0; margin-right:0; }
}






/* --------------------------------------------------------------------------
   12. Compatibility layer for pages that ALSO load assets/index.css
   (index.html loads index.css in <head>; this file is loaded by the
   {% include %} inside <body>, so it wins on source order — but index.css
   ships an older header block whose breakpoints (860px / 992px) and
   display rules fight this component. These rules pin the correct values.)
   -------------------------------------------------------------------------- */

/* index.css hides the whole nav below 860px and hides every .header-search
   below 992px, which would blank out the slide-in panel and its search. */
@media (max-width:992px){
  .site-header .main-nav{ display:flex; }
  .site-header .header-search--mobile{ display:flex; width:100%; }
  .site-header .header-search--desktop{ display:none; }

  /* Tighter, better balanced mobile header + sidebar. */
  .header-inner{ gap:12px; }
  .main-nav{ padding:8px 14px 20px; }
  .nav-link{ padding:12px 8px; }
  .dropdown{ max-width:none; width:100%; }
}

/* index.css toggles dropdowns with display:none/grid, which breaks the
   visibility+opacity transition and hover hit-testing used here. */
@media (min-width:993px){
  .site-header .dropdown{ display:block !important; grid-template-columns:none !important; }
  .site-header .nav-item:not(.is-open) > .dropdown{ display:block !important; }
  .site-header .mega-grid{ display:grid !important; grid-template-columns:auto auto auto !important; width:auto; justify-content:center; }
}

/* Vertical alignment. (Header padding is now symmetric — see section 3.) */
.header-inner{ align-items:center; }
.header-inner > .brand{ align-self:center; }

/* index.css line ~898 sets `.brand-text .name{font-size:32px!important}`,
   which leaks into this component when both stylesheets load. Matched with
   !important only because the source rule is !important — scoped to
   .site-header so nothing else is affected. The size comes from the --hn-title
   token (section 3), so desktop / tablet / mobile all follow the footer's
   scale from ONE place instead of a stack of per-breakpoint overrides.
   The tagline is forced visible for the same reason: it must never be hidden
   by a stray rule on any viewport. */
.site-header .brand-text .name{ font-size:var(--hn-title) !important; }
.site-header .brand-text .tagline{ display:block !important; font-size:var(--hn-tagline); }
.site-header .brand{ min-width:0; }
.site-header .brand-mark{ width:var(--hn-mark); height:var(--hn-mark); }


/* --------------------------------------------------------------------------
   13. Spacing fine-tuning (keeps the layout balanced on small screens)
   -------------------------------------------------------------------------- */
@media (max-width:992px){
  .site-header .header-search--desktop{ margin-left:0; margin-right:0; }
}

/* The dropdown must always be fully opaque, on every breakpoint. */
.site-header .dropdown{
  background:#ffffff;
  backdrop-filter:none;
  -webkit-backdrop-filter:none;
}

/* --------------------------------------------------------------------------
   14. Mobile drawer: viewport-attached panel, own close bar, locked page
   --------------------------------------------------------------------------
   Below 993px the header is in normal flow and scrolls away with the page,
   but the drawer and scrim were pinned at top:var(--header-h). Once the page
   was scrolled, a strip of the page showed above the drawer and the header's
   X toggle was off-screen. The drawer is now attached to the whole viewport
   and carries its own sticky close bar. Page scroll is locked from JS
   (header_navigation.js), because `body.nav-open{overflow:hidden}` above is
   overridden elsewhere and cannot lock the page by itself.
   Desktop (>=993px) is untouched: the close bar is hidden there. */
.nav-drawer-head{ display:none; }

@media (max-width:992px){
  .site-header .main-nav{
    top:0;
    bottom:0;
    height:100vh;               /* fallback */
    height:100dvh;              /* tracks the mobile browser toolbar */
    padding:0 14px calc(20px + env(safe-area-inset-bottom, 0px));
    z-index:120;
  }

  .site-header .main-nav a:focus-visible,
  .site-header .nav-drawer-close:focus-visible{
    outline:2px solid var(--color-blue);
    outline-offset:-2px;
  }

  .site-header .nav-scrim{
    inset:0;
    touch-action:none;
    overscroll-behavior:contain;
  }

  .nav-drawer-head{
    display:flex;
    align-items:center;
    justify-content:space-between;
    flex:none;
    position:sticky;
    top:0;
    z-index:2;
    margin:0 -14px 8px;
    padding:8px 14px 8px 24px;
    background:#fff;
    border-bottom:1px solid var(--color-border);
  }
  .nav-drawer-title{
    font-size:13px;
    font-weight:800;
    letter-spacing:.08em;
    text-transform:uppercase;
    color:#0e2770;
  }
  .nav-drawer-close{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    width:44px;
    height:44px;
    padding:0;
    background:transparent;
    border:0;
    border-radius:50%;
    color:var(--color-ink, #1B2237);
  }
  .nav-drawer-close:hover{ background:var(--color-panel); color:var(--color-blue); }
}