/* .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 tellurion, 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.

   That rule is about sizes. The bar's *colours* go through --nav-* custom
   properties (--nav-bg, --nav-fg, --nav-hover-bg, --nav-active-bg,
   --nav-active-shadow, --nav-border-bottom, --nav-focus, --nav-brand-bg and
   the three --nav-mobile-* ones), each with today's value as its fallback.
   No shared token feeds them: only a variant that wants a different bar
   sets them (tokens_fischhase.css, light block: a light bar with a yellow
   edge), so every other variant renders exactly as before. The admin copies
   of the burger and the mobile menu in admin-overrides.css read the same
   properties with the same fallbacks. */

/*
  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-surface:    #f7fafc;
    --c-surface2:   #edf2f7;
    --c-danger:     #e53e3e;
    --c-danger-dk:  #c53030;
    --c-active-bg:  #276749;
    --c-active-dk:  #1e5035;
    --r1:           4px;
    --r2:           8px;
    --shadow-md:    0 4px 12px rgba(0,0,0,.12);
    --font:         system-ui, -apple-system, sans-serif;
    --text-sm:      0.875rem;
    --text-md:      1rem;
    --text-xs:      0.75rem;
    --s0:           2px;
    --s1:           4px;
    --s2:           8px;
    --s3:           12px;
    --s4:           16px;
    --touch:        44px;
    --touch-sm:     32px;
  }

  /* ── Shared .btn system ────────────────────────────────────────
     Used by the floating timer widget on every chrome.  Declared
     inside @layer so base.css / todo-app.css (unlayered) win at
     equal specificity on pages that load them. */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--touch);
    padding: var(--s2) var(--s4);
    border: 1px solid var(--c-border);
    border-radius: var(--r1);
    font-family: inherit;
    font-size: var(--text-md);
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    background: var(--c-bg);
    color: var(--c-text);
    white-space: nowrap;
  }
  .btn:hover {
    background: var(--c-surface2);
    text-decoration: none;
  }
  .btn:focus-visible {
    outline: 3px solid var(--c-primary);
    outline-offset: 2px;
  }
  .btn--primary {
    background: var(--c-primary);
    color: #fff;
    border-color: var(--c-primary);
  }
  .btn--primary:hover {
    background: var(--c-primary-dk);
    color: #fff;
  }
  .btn--danger {
    background: var(--c-danger);
    color: #fff;
    border-color: var(--c-danger);
  }
  .btn--danger:hover {
    background: var(--c-danger-dk);
    color: #fff;
  }
  .btn--sm {
    min-height: var(--touch-sm);
    padding: var(--s1) var(--s3);
    font-size: var(--text-sm);
  }
  .btn--ghost {
    background: transparent;
    border-color: transparent;
  }
  .btn--ghost:hover {
    background: var(--c-surface2);
  }
  .btn--active {
    background: var(--c-active-bg);
    color: #fff;
    border-color: var(--c-active-bg);
  }
  .btn--active:hover {
    background: var(--c-active-dk);
    color: #fff;
  }
}

/* --c-brand-bg / --c-on-brand: a variant whose logo cannot sit on its
   --c-primary (fischhase: dark olive on warm grey) supplies its own pair.
   Every other variant leaves them unset and gets the bar colour and white.
   --nav-brand-bg sits in front of both: a variant whose bar is already light
   enough for the logo sets it to transparent, and keeps --c-brand-bg for the
   login badge (login.css), which does not read --nav-brand-bg. */
.muli-nav__brand {
  display: flex;
  align-items: center;
  padding: 4px 16px;
  background: var(--nav-brand-bg, var(--c-brand-bg, var(--c-primary, #2c5282)));
}
.muli-nav__brand a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--c-on-brand, #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;
}

/* The fischhase wordmark is markup only fischhase renders
   (site_branding.html), so its size is a class, not a token: a 1.5rem
   lettering alone, with even 12px either side instead of the 16px / 0 the
   other logos get. Repeats the child-combinator selector so it outranks the
   padding-right:0 just above. */
.muli-nav__brand--fischhase,
.muli-nav > .muli-nav__brand--fischhase { padding: 4px 12px; }
.muli-nav__brand--fischhase img { height: 1.5rem; }

/* 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(--nav-bg, var(--c-primary, #2c5282));
  border-bottom: var(--nav-border-bottom, 0);
  font-size: 0.875rem;
  font-family: var(--font, system-ui, -apple-system, sans-serif);
}
/* Django admin does not carry the frontend's global border-box reset. Keep
   this shared component independent of whichever chrome renders it. */
.muli-nav,
.muli-nav *,
.muli-nav *::before,
.muli-nav *::after {
  box-sizing: border-box;
}
/* 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;
  /* Django admin's `ul > li` adds 1px vertically. Without this reset the
     same bar is 46px in admin and 44px everywhere else. */
  padding: 0;
}
.muli-nav > ul > li { position: relative; }
.muli-nav > ul > li > a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  color: var(--nav-fg, #fff);
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
}
.muli-nav > ul > li > a:hover {
  background: var(--nav-hover-bg, 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. A variant that sets its own --nav-active-bg can drop it with
   --nav-active-shadow: none. */
.muli-nav > ul > li > a.is-active {
  background: var(--nav-active-bg, var(--c-primary-dk, #1a365d));
  box-shadow: var(--nav-active-shadow, inset 0 -3px 0 #fff);
}
/* The browser default outline is dark-on-dark here so state it explicitly. Inset, because an
   outward outline is clipped by the neighbouring flex items. */
.muli-nav a:focus-visible {
  outline: 2px solid var(--nav-focus, #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);
}
/* Two entries in the Protokoll menu are commands, so they are a <button>
   inside a <form> (partials/post_action.html) rather than an <a>. Neither
   element inherits the anchor rule above, and base.css's .btn--linklike —
   written for commands that sit in a run of text — made them underlined blue
   links in a 220px-wide wrapped column instead. The form is only a carrier
   and gets no box; the button is the menu item and restates the anchor's
   values, plus the resets a <button> needs to stop being a button.
   No :focus-visible rule to match `.muli-nav a:focus-visible` above: that one
   draws a white outline, which is for the dark bar and would be invisible on
   the dropdown's white panel. The browser default is the legible one here. */
.muli-nav > ul > li > ul > li > .post-action {
  display: block;
  margin: 0;
}
.muli-nav > ul > li > ul > li > .post-action > button {
  display: block;
  width: 100%;
  padding: 8px 16px;
  background: none;
  border: none;
  border-radius: 0;
  color: var(--c-text, #2d3748);
  font: inherit;
  font-weight: 400;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.muli-nav > ul > li > ul > li > .post-action > button: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: var(--nav-fg, #fff);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
.muli-nav__burger:hover {
  background: var(--nav-hover-bg, 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 var(--nav-mobile-divider, rgba(255,255,255,.12));
  }
  /* Subnavs inline, not dropdown */
  .muli-nav.is-open > ul > li.muli-nav__collapsible > ul {
    display: block;
    position: static;
    background: var(--nav-mobile-sub-bg, 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: var(--nav-mobile-sub-fg, 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; }
}

/* ── Tastaturkürzel dialog (partials/shortcut_help.html) ─────────────
   Here rather than in a sheet of its own: this file is the one stylesheet
   all three chromes load, and it loads last. A native <dialog>, so there is
   nothing to style but the box — the backdrop, centring and Esc are the
   element's own. */

.shortcut-help {
  border: 1px solid var(--c-border);
  border-radius: var(--r2);
  background: var(--c-surface);
  color: var(--c-text);
  padding: var(--s4);
  max-width: min(32rem, calc(100vw - var(--s4) * 2));
  font-size: var(--text-sm);
  line-height: 1.5;
}
.shortcut-help::backdrop { background: rgba(0, 0, 0, .45); }
.shortcut-help h2 { margin: 0 0 var(--s3); font-size: var(--text-md); }
.shortcut-help table { border-collapse: collapse; width: 100%; }
.shortcut-help td { padding: var(--s1) var(--s3) var(--s1) 0; vertical-align: top; }
.shortcut-help td:first-child { white-space: nowrap; }
.shortcut-help kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--c-border);
  border-radius: var(--r1);
  background: var(--c-bg);
  font: inherit;
  font-size: .9em;
}
/* opacity, not a muted colour token: this file defines --c-text and no
   muted variant, and inventing one here would be a token nobody else uses. */
.shortcut-help__note { margin: var(--s3) 0; opacity: .75; }
