/* .muli-nav — the section bar rendered by partials/site_nav.html on all three
   chromes (muli_base.html, todo/base.html, admin/base_site.html).
   Includes the brand block from partials/site_branding.html, which is a flex
   item inside the same bar.

   ── LOAD THIS FILE LAST IN EVERY <head>. ──────────────────────────────────
   The rules used to live in an inline <style> inside the <body>, which beats
   any <head> stylesheet at equal specificity, while admin-overrides.css's
   `!important` beat the inline block regardless. Loading last is what
   reproduces the first half of that; admin-overrides.css keeps the second
   half for free. Anything appended after this file silently takes the nav
   back — pinned by NavStylesheetTests in test_nav_assets.py.

   The literals are deliberate and are NOT to be replaced by tokens.
   admin-overrides.css records why: pinning the items to var(--text-sm)
   instead made the admin nav a different size from the frontend nav whenever
   a style variant moves the token off 0.875rem — 12px under compact-mono,
   15px under aurora, against the frontend's constant 14px. #main-nav in
   base.css is pinned to the same 16px / 44px / 0.875rem so the two stacked
   bars agree under every variant. */

/*
  Default values for every CSS custom property used by .muli-nav.
  Declared inside @layer so they lose to any unlayered :root rule —
  meaning todo.scss defaults and CUSTOM_CSS overrides both win.
  In the admin (where no :root vars are defined at all) these take effect.
*/
@layer muli-nav-defaults {
  :root {
    --c-primary:    #2c5282;
    --c-primary-dk: #1a365d;
    --c-bg:         #ffffff;
    --c-text:       #2d3748;
    --c-border:     #cbd5e0;
    --c-surface2:   #edf2f7;
    --r2:           8px;
    --shadow-md:    0 4px 12px rgba(0,0,0,.12);
    --font:         system-ui, -apple-system, sans-serif;
    --text-sm:      0.875rem;
  }
}

.muli-nav__brand {
  display: flex;
  align-items: center;
  padding: 4px 16px;
  background: var(--c-primary, #2c5282);
}
.muli-nav__brand a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
}
.muli-nav__brand img { height: 2rem; width: auto; }

/* Brand rendered *inside* the bar (nav_inline_brand). As a flex item it
   reserves its own width, so the item list shrinks and wraps around it
   instead of being overlapped — which is what the absolutely positioned
   brand this replaces could never do, in admin or frontend alike.
   flex-shrink:0 keeps the logo at full size and makes the <ul> give way,
   not the other way round. */
.muli-nav > .muli-nav__brand {
  margin-left: auto;
  flex: 0 0 auto;
  padding-right: 0;
}

/* Sticky rather than static: on a 1000-row changelist the bar would
   otherwise scroll away and leave no way to switch section without
   scrolling back to the top. The nav is a direct child of #page-wrapper
   (frontend) resp. #container (admin, it is emitted *before* #header),
   so its containing block spans the whole page and the pin holds for the
   full scroll. z-index sits one above the sticky submit bar
   (admin-submit-bar.css, z-index:100) so a long dropdown opened near the
   bottom of a short viewport draws over it instead of under it. */
.muli-nav {
  display: flex;
  align-items: stretch;
  position: sticky;
  top: 0;
  z-index: 101;
  padding: 0 16px;
  background: var(--c-primary, #2c5282);
  font-size: 0.875rem;
  font-family: var(--font, system-ui, -apple-system, sans-serif);
}
/* flex-grow is what makes .muli-nav__burger-item's margin-left:auto do
   anything: auto margins only absorb *free* space, and a content-sized
   <ul> has none, so without this the burger just trails the last item
   instead of sitting at the right edge. min-width:0 lets the list shrink
   below its content width so it wraps rather than pushing the brand off. */
.muli-nav > ul {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  flex: 1 1 auto;
  min-width: 0;
  list-style: none;
  margin: 0;
  padding: 0;
}
/* Django admin's base.css declares `ul > li { list-style-type: square }`,
   which applies directly to <li> and so wins over any `list-style: none`
   on the parent <ul>. Reset on every .muli-nav <li> defensively. */
.muli-nav li { list-style: none; }
.muli-nav > ul > li { position: relative; }
.muli-nav > ul > li > a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  color: #fff;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
}
.muli-nav > ul > li > a:hover {
  background: var(--c-primary-dk, #1a365d);
  text-decoration: none;
}
/* Current section. The underline carries the state on its own, so it still
   reads when the darker background is invisible against a tenant's CUSTOM_CSS
   palette. */
.muli-nav > ul > li > a.is-active {
  background: var(--c-primary-dk, #1a365d);
  box-shadow: inset 0 -3px 0 #fff;
}
/* The browser default outline is dark-on-dark here (worst case: the Aurora
   theme's #c084fc primary), so state it explicitly. Inset, because an
   outward outline is clipped by the neighbouring flex items. */
.muli-nav a:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -2px;
}

/* Dropdown panel */
.muli-nav > ul > li > ul {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 500;
  list-style: none;
  margin: 0;
  padding: 4px 0;
  background: var(--c-bg, #fff);
  border: 1px solid var(--c-border, #cbd5e0);
  border-radius: 0 8px 8px 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,.12);
  min-width: 220px;
}
.muli-nav > ul > li > ul > li > a {
  display: block;
  padding: 8px 16px;
  color: var(--c-text, #2d3748);
  white-space: nowrap;
  text-decoration: none;
  font-weight: 400;
}
.muli-nav > ul > li > ul > li > a:hover {
  background: var(--c-surface2, #edf2f7);
}
.muli-nav > ul > li:hover > ul { display: block; }

/* ── Site-nav burger (mobile only) ──────────────────────────────── */
/* These came from base.css, where they were written with the spacing tokens
   (var(--touch), var(--s1)…var(--s4)). They are literals here for the same
   reason the bar above is: admin-overrides.css already hard-codes exactly
   these values for the admin copy of the same button, so a tokenised
   frontend copy would size differently from the admin one under any variant
   that moves the tokens. The numbers are the tokens' own defaults, so this
   changes nothing at baseline — but do not read that as "changes nothing".
   Under a variant that moves these tokens the mobile burger really does
   change: compact-mono sets --touch:28px, --s2:4px, --s3:6px, so the button
   goes from 28px tall with 4px/6px padding to 44px with 8px/12px (compact-card,
   at 32px/6px/8px, moves the same way). Only at <=767px, where
   .muli-nav__burger-item is displayed at all, and only on the two frontend
   chromes: admin-overrides.css has always hard-coded 44px / 8px 12px for the
   admin copy, so that one never moved. */
.muli-nav__burger-item {
  display: none;
}
.muli-nav__burger {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
.muli-nav__burger:hover {
  background: var(--c-primary-dk, #1a365d);
}

@media (max-width: 767px) {
  .muli-nav__burger-item {
    display: flex;
    margin-left: auto;
  }
  .muli-nav > ul > li.muli-nav__collapsible {
    display: none;
  }
  /* Open state: collapsible items stack full-width below */
  .muli-nav.is-open > ul > li.muli-nav__collapsible {
    display: flex;
    flex-direction: column;
    width: 100%;
    border-top: 1px solid rgba(255,255,255,.12);
  }
  /* Subnavs inline, not dropdown */
  .muli-nav.is-open > ul > li.muli-nav__collapsible > ul {
    display: block;
    position: static;
    background: rgba(0,0,0,.18);
    border: none;
    border-radius: 0;
    box-shadow: none;
    min-width: 0;
    padding: 4px 0;
  }
  .muli-nav.is-open > ul > li.muli-nav__collapsible > ul > li > a {
    padding: 4px 16px 4px 32px;
    color: rgba(255,255,255,.8);
  }
  /* Open burger menu stacks the collapsibles, making the bar tall;
     align-items:stretch would then centre the brand halfway down it.
     Pin it to the first row instead. */
  .muli-nav.is-open > .muli-nav__brand { align-self: flex-start; }
}
