/* Site header ("Glas, 64px"; templates/includes/header_dropdowns.html).
   Fixed solid white bar of constant height (no change on scroll), a spacer
   of the same height below it, logo + main items left, language switch right.
   --agx-nav-h is the header height; the mega-menu scrim reads it, panels hang
   from the header's bottom edge. Tokens: agrex.css. */

:root:has(#header.site-head--glass) {
  --agx-nav-h: 56px;
  /* Anchor jumps: 80px on desktop (64 + 16), header + 16px on mobile. */
  --scroll-offset: calc(var(--agx-nav-h) + 16px);
}
@media (min-width: 992px) {
  :root:has(#header.site-head--glass) { --agx-nav-h: 64px; }
}

.site-head__spacer { height: var(--agx-nav-h); }

#header.site-head--glass {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  height: var(--agx-nav-h);
  padding: 0 var(--agx-safe-right) 0 var(--agx-safe-left);  /* fixed: not inside body's padding */
  border-bottom: 1px solid rgba(29, 35, 39, 0.08);
  background-color: #fff !important;
  box-shadow: none !important;
}

#header.site-head--glass .navbar-nav-wrap { flex-wrap: nowrap; }
/* Logo lockup (static/front/img/brand/agrex-logo-teal.svg, 3.2 : 1): 32px in
   the mobile header, 40px from 992px. The only size rule for the logo. */
#header .site-head__logo {
  display: block;
  width: auto;
  height: 32px;
  max-width: none;
  max-height: none;
}
@media (min-width: 992px) {
  #header .site-head__logo { height: 40px; }
}

/* Main items: 32px after the logo, 4px apart, left-aligned (the theme's
   .navbar-end right-aligns them); the language switch comes last (the theme
   gives the collapse order 2). */
#header.site-head--glass .navbar-collapse {
  flex-grow: 1;
  margin-left: 32px;
}
#header.site-head--glass .navbar-nav {
  flex-grow: 0;
  justify-content: flex-start;
  gap: 4px;
  margin-left: 0 !important;
}
#header.site-head--glass .navbar-nav > .nav-item { margin: 0; }
#header.site-head--glass .lang-switch { order: 3; }

/* Smooth (grayscale) text rendering in the header and the mega-menu panel. */
#header.site-head--glass,
#header.site-head--glass .site-nav__panel {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Main items and the language button share one style: no background on
   hover/open, the text turns AGREX green instead; the chevron turns up when open. */
#header.site-head--glass .navbar-nav .nav-link,
.site-head__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: var(--agx-fs-16);
  font-weight: 500;
  line-height: 22.4px;
  letter-spacing: -0.005em;
  color: #1f2a30;
  white-space: nowrap;
  transition: color 0.15s ease;
}
#header.site-head--glass .navbar-nav .nav-link.active { color: var(--bs-primary); }
#header.site-head--glass .navbar-nav .nav-link:hover,
#header.site-head--glass .navbar-nav .nav-item.is-open > .nav-link,
#header.site-head--glass .navbar-nav .hs-sub-menu-opened > .nav-link,
.site-head__item:hover,
.site-head__item[aria-expanded="true"] {
  background-color: transparent;
  color: var(--bs-primary);
}
#header.site-head--glass .navbar-nav .nav-link:focus-visible,
.site-head__item:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
}

/* Chevrons: 12px, 55 % opacity ("Mit Dropdowns" icon, "Klassisch" ::after),
   turned up while the menu is open. */
#header.site-head--glass .site-nav__chevron,
.site-head__chevron {
  margin-left: 0;
  font-size: 12px;
  opacity: 0.55;
  transition: transform 0.18s ease;
}
#header.site-head--glass .navbar-nav .dropdown-toggle::after {
  width: 12px;
  height: 12px;
  margin-left: 0;
  padding-left: 0;
  background-size: 12px 12px;
  opacity: 0.55;
  transition: transform 0.18s ease;
}
#header.site-head--glass .site-nav__item.is-open .site-nav__chevron,
#header.site-head--glass .hs-sub-menu-opened > .dropdown-toggle::after,
.site-head__item[aria-expanded="true"] .site-head__chevron { transform: rotate(180deg); }

/* "Mit Dropdowns": the panel starts below the 1px bottom line. */
#header.site-head--glass .site-nav__panel { top: calc(100% + 1px); }

/* "Klassisch" (hs-mega-menu): submenus hang from their nav item, so the items
   fill the header height and the submenu starts at the header's bottom edge. */
@media (min-width: 992px) {
  #header.site-head--glass .js-mega-menu,
  #header.site-head--glass .js-mega-menu .navbar-collapse,
  #header.site-head--glass .js-mega-menu .navbar-nav { height: var(--agx-nav-h); }
  #header.site-head--glass .js-mega-menu .navbar-nav > .nav-item {
    display: flex;
    align-items: center;
    height: 100%;
  }
  #header.site-head--glass .js-mega-menu .hs-sub-menu,
  #header.site-head--glass .js-mega-menu .hs-mega-menu {
    top: 100%;
    margin-top: 0;
  }
}

/* --- Language switch ------------------------------------------------------ */
.lang-flag {
  position: relative;
  flex: 0 0 18px;
  display: inline-block;
  width: 18px;
  height: 12px;
  border-radius: 2px;
  overflow: hidden;
}
.lang-flag img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.lang-flag::after {          /* inner hairline */
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(29, 35, 39, 0.12);
}

.lang-switch {
  position: relative;
  flex: 0 0 auto;
  margin-left: auto;
}
/* Desktop trigger: language code + 12px chevron (docs/design-tokens.md). */
.lang-switch .lang-switch__btn {
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--agx-ink);
}
.lang-switch .lang-switch__btn:hover,
.lang-switch .lang-switch__btn[aria-expanded="true"] { color: var(--agx-ink); }
.lang-switch__chevron {
  flex: none;
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.18s ease;
}
.lang-switch__btn[aria-expanded="true"] .lang-switch__chevron { transform: rotate(180deg); }
.lang-switch__menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 2;
  width: 150px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--agx-white);
  border: 1px solid var(--agx-line);
  border-radius: 10px;
  box-shadow: var(--agx-shadow-pop);
}
.lang-switch__menu[hidden] { display: none; }
.lang-switch__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.3;
  color: var(--agx-ink);
  text-decoration: none;
}
.lang-switch__item.is-active { background-color: var(--agx-surface); font-weight: 600; }
.lang-switch__item:hover,
.lang-switch__item:focus-visible { background-color: var(--agx-surface); color: var(--agx-ink); }
.lang-switch__item:focus-visible { outline: 2px solid var(--agx-teal); outline-offset: -2px; }
.lang-switch__label {
  font-size: 14px;
  font-weight: 400;
  color: var(--agx-muted);
}

/* Burger menu language row: css/blocks/menue.css. */

/* Mobile: the header shows logo + burger; the switch lives in the burger menu. */
@media (max-width: 991.98px) {
  #header.site-head--glass .lang-switch { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #header.site-head--glass .navbar-nav .nav-link,
  .site-head__item,
  .site-head__chevron,
  .lang-switch__chevron,
  #header.site-head--glass .site-nav__chevron,
  #header.site-head--glass .navbar-nav .dropdown-toggle::after { transition: none; }
}
