/* =========================================================================
   Component — site header and top navigation
   -------------------------------------------------------------------------
   The markup is produced once, in assets/js/site.js. Each page carries a
   MINIMAL static fallback inside the mount point so a public page stays
   navigable without JavaScript; site.js replaces it with the interactive
   chrome (drawer, dropdown, theme toggle, active state).

   Two variants:
     .site-header              themed — light/dark like the rest of the page
     .site-header.on-brand     white-on-gradient, for a header on a dark band
                               (none since U-2278: the home page takes the themed one)

   THE HEADER IS A SURFACE, NOT THE PAGE (DESIGN_TOKENS.md §9.7)
   -------------------------------------------------------------------------
   It carried `--doc-bg` — the SAME value as the page behind it — with a 1 px
   border as its only separation. That is a bar which exists because a border
   says so. `--doc-panel` is the surface ground, so the chrome now reads as a
   plane the page runs under, in both themes, and the hairline frames a
   difference rather than inventing one. The six ground tokens were never the
   gap; the shapes were.
   ========================================================================= */

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--doc-panel);
  border-bottom: 1px solid var(--doc-line);
}

.site-header.on-brand {
  position: relative;
  background: transparent;
  border-bottom: 0;
  color: var(--brand-on-dark);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  /* The public frame's header bar, 66 px (U-2277, DESIGN_TOKENS.md §8.2). */
  min-height: 66px;
  flex-wrap: wrap;
}

.site-brand {
  display: inline-flex;
  align-items: center;
  line-height: 0;
}

.site-brand img {
  height: 32px;
  width: auto;
}

/* --- The wordmark is not here any more ----------------------------------- *
 * The theme-aware pair and its print swap moved to `components/wordmark.css`
 * in U-732. The argument that put them here — "every page that has chrome
 * links nav.css, and a file of its own would be a fourth <link> on 31 pages
 * for two rules" — held only while every page carrying the mark also carried
 * chrome. The six auth pages carry the mark and no chrome, so the caller set
 * outgrew the file. What stays here is the SIZING of whatever the brand link
 * holds, which really is the header's business.                            */

/* Logo, then the navigation 16 px after it (the nav's gap), then the
   language switch, the theme toggle and the sign-in pushed to the right
   (U-2277). The server prints the languages and the sign-in as links in the
   list, `site.js` puts them in `.nav-utils`; the first of them takes the
   free space in both shapes, so the page needs no script for it. */
.nav-list {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.nav-list > .nav-link:not(.nav-lang) + .nav-lang,
.nav-list > .nav-link:not(.nav-lang) + .nav-cta {
  margin-left: auto;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: var(--nav-h);
  padding: 6px 12px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--doc-ink);
  font: inherit;
  font-size: var(--text-body);
  line-height: var(--text-body-lh);
  font-weight: 600;
  cursor: pointer;
}

.nav-link:hover {
  color: var(--doc-ink);
  background: var(--sd-surface-alt);
  text-decoration: none;
}

/* THE CURRENT PAGE IS A MUTED PLATE (DESIGN_TOKENS.md §9.7, U-2277): the
   label in the link colour, weight 600, on the muted ground, radius 6 — the
   approved canvas. `aria-current="page"` carries the state for a reader who
   sees no colour (audit rule E-4). Computed from the tokens: #027261 on
   #F4F4F4 5.33:1 in light, #5FE7A7 on #2E2E2E 8.71:1 in dark. */
.nav-link[aria-current="page"] {
  color: var(--sd-secondary);
  background: var(--sd-surface-alt);
  font-weight: 600;
}

.nav-link svg {
  width: 15px;
  height: 15px;
}

/* The badge after a link's text (U-2286, „Neu“ beside KI-Apps): the primary
   pill of the canvas. Text, so it is translated and read with the link. */
.nav-badge {
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--sd-primary);
  color: var(--sd-on-primary);
  font-size: var(--text-caption);
  line-height: var(--text-caption-lh);
  font-weight: 700;
}

.on-brand .nav-link {
  color: var(--brand-on-dark);
}

.on-brand .nav-link:hover {
  color: var(--brand-on-dark);
  background: color-mix(in srgb, var(--brand-on-dark) 16%, transparent);
}

/* The same plate on the one surface that stays dark in both themes, in the
   ink that surface uses. No page with the brand header is in `NAV` today, so
   it has no reachable caller; it is kept so the next one does not inherit the
   themed plate on a dark ground. */
.on-brand .nav-link[aria-current="page"] {
  color: var(--brand-on-dark);
  background: var(--on-dark-hover);
}

/* --- Dropdown ------------------------------------------------------------ */

.nav-dropdown {
  position: relative;
}

.nav-dd-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 210px;
  padding: 8px;
  background: var(--doc-panel);
  border: 1px solid var(--doc-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 50;
}

.nav-dropdown.is-open .nav-dd-menu {
  display: flex;
}

.nav-dropdown.is-open .nav-dd-toggle svg {
  transform: rotate(180deg);
}

.nav-dd-menu a {
  padding: 9px 12px;
  border-radius: var(--radius);
  color: var(--doc-ink);
  font-size: 14px;
  font-weight: 500;
}

.nav-dd-menu a:hover {
  background: var(--sd-surface-alt);
  text-decoration: none;
}

/* --- Call to action and utilities ---------------------------------------- */

.nav-cta {
  margin-left: 8px;
}

/* The JavaScript chrome's group of language switch and theme toggle. */
.nav-utils {
  margin-left: auto;
}

.on-brand .nav-cta {
  background: var(--brand-mint);
  color: var(--brand-mint-ink);
}

.on-brand .nav-cta:hover {
  background: var(--brand-mint-hover);
  color: var(--brand-mint-ink);
}

.nav-utils {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.theme-toggle {
  width: var(--control-h);
  height: var(--control-h);
}

/* --- Theme menu (U-2320) -------------------------------------------------- */

/* The theme button and its menu, in the language menu's shape (U-2291). Here and
   not in sidebar.css: the public header has it too, and every portal and
   administration page loads this file as well. */
.theme-dropdown {
  position: relative;
}

.theme-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 180px;
  padding: 8px;
  background: var(--doc-panel);
  border: 1px solid var(--doc-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  z-index: 30;
}

.theme-dropdown.is-open .theme-menu {
  display: block;
}

.theme-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: var(--doc-ink);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}

.theme-menu-item:hover {
  background: var(--sd-surface-alt);
}

/* The chosen setting: weight and the mark at the end, not colour alone. */
.theme-menu-item.is-current {
  font-weight: 600;
}

.theme-menu-item > span:not(.ico) {
  flex: 1;
}

/* A drawn glyph (glyphs.js `themeGlyph`) fills its box like a font glyph. */
.ico-drawn {
  display: inline-flex;
  width: 16px;
  height: 16px;
}

.icon-btn .ico-drawn svg,
.ico-drawn svg {
  width: 100%;
  height: 100%;
}

.theme-menu-item .ico-drawn:last-child:not(:first-child) {
  color: var(--sd-secondary);
}

/* --- Mobile drawer ------------------------------------------------------- */

.nav-burger {
  display: none;
  margin-left: auto;
  width: var(--control-h);
  height: var(--control-h);
}

/* Below 1200 px the public header is the menu button and its drawer (U-2277;
   1024 until U-2286, whose seventh item with its badge needs about 115 px the
   German and Dutch rows did not have — the redesign session's value, the links
   keep their 12 px); without JavaScript the static list stays inline, see
   `.nav-list-static`. */
@media (max-width: 1199px) {
  .nav-burger {
    display: inline-flex;
  }

  .nav-list {
    position: absolute;
    top: 100%;
    left: clamp(12px, 4vw, 24px);
    right: clamp(12px, 4vw, 24px);
    z-index: 45;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    margin-left: 0;
    padding: 10px;
    background: var(--doc-panel);
    border: 1px solid var(--doc-line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-pop);
    display: none;
  }

  .nav-list.is-open {
    display: flex;
  }

  .nav-link,
  .on-brand .nav-link {
    color: var(--doc-ink);
    font-size: 15px;
  }

  .on-brand .nav-link:hover {
    color: var(--doc-ink);
    background: var(--sd-surface-alt);
  }

  /* In the drawer the link sits on `--doc-panel`, not on a dark band, so
     the brand variant takes the themed plate. */
  .on-brand .nav-link[aria-current="page"] {
    color: var(--sd-secondary);
    background: var(--sd-surface-alt);
  }

  .nav-dropdown {
    position: static;
  }

  .nav-dd-menu {
    position: static;
    display: flex;
    min-width: 0;
    padding: 0 0 4px 12px;
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  /* The links below are always visible in the drawer, so a disclosure toggle
     for them would be a focusable no-op reporting aria-expanded="false" over
     content that is already on screen. Hide the control and keep the links —
     site.js gives the group its own role="group" + aria-label, so the name
     survives the toggle disappearing. */
  .nav-dd-toggle {
    display: none;
  }

  .nav-dd-menu {
    border-left: 1px solid var(--doc-line);
  }

  .nav-cta,
  .nav-utils,
  .nav-list > .nav-link:not(.nav-lang) + .nav-lang,
  .nav-list > .nav-link:not(.nav-lang) + .nav-cta {
    margin-left: 0;
    margin-top: 6px;
  }

  /* Without JavaScript the drawer never opens, so the static fallback nav
     must stay laid out inline rather than in a hidden panel. */
  .nav-list-static {
    position: static;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    margin-left: 0;
  }
}
