/*
 * Memory Clone shared header - single source of truth for desktop and compact (hamburger) layouts.
 * Loaded last by mc_site_render_page_start(). Selectors use #header#header so they outrank every
 * older header lock in account.css / mc-marketing.css / mc-mobile-fixes.css / mc-i18n.css.
 *
 * Layout switch:
 *  - With JS: assets/js/mc-nav.js measures whether the desktop row fits (every language, logged-in
 *    or not) and sets html.mc-nav-compact. html.mc-nav-js marks that the measurement is in charge.
 *  - Without JS: the @media fallback at the end applies the compact layout below 1440px, the widest
 *    measured fit (German, logged in as admin). The desktop row also never lets items overlap:
 *    every item keeps its max-content width, so in the worst case the row is clipped, not stacked.
 */

/* ---------- Desktop row ---------- */
html body #header#header {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  height: 66px !important;
  min-height: 66px !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center !important;
  overflow: visible !important;
  z-index: 2147483000 !important;
}
html body #header#header .header-container {
  width: min(1360px, calc(100% - 36px)) !important;
  max-width: 1360px !important;
  height: 66px !important;
  min-height: 66px !important;
  margin: 0 auto !important;
  padding: 0 18px !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 18px !important;
  flex-wrap: nowrap !important;
  box-sizing: border-box !important;
}
html body #header#header .logo {
  flex: 0 1 246px !important;
  width: auto !important;
  min-width: max-content !important;
  max-width: none !important;
  order: 0 !important;
}
html body #header#header .logo .sitename {
  width: auto !important;
  flex: 0 0 auto !important;
}
html body #header#header .mc-nav-panel {
  display: contents !important;
}
html body #header#header .navmenu {
  flex: 1 1 auto !important;
  min-width: max-content !important;
  width: auto !important;
  max-width: none !important;
  display: flex !important;
  flex-direction: row !important;
  justify-content: center !important;
  align-items: center !important;
  position: static !important;
  transform: none !important;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  order: 1 !important;
}
html body #header#header .navmenu ul {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 2px !important;
  flex-wrap: nowrap !important;
  width: auto !important;
  margin: 0 !important;
  padding: 0 !important;
  list-style: none !important;
}
html body #header#header .navmenu li {
  display: flex !important;
  width: auto !important;
  margin: 0 !important;
  padding: 0 !important;
}
html body #header#header .navmenu a,
html body #header#header .navmenu a.active,
html body #header#header .navmenu a:hover {
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  height: 36px !important;
  min-height: 36px !important;
  padding: 0 10px !important;
  margin: 0 !important;
  justify-content: center !important;
  white-space: nowrap !important;
  text-align: center !important;
  transform: none !important;
}
html body #header#header .header-actions {
  flex: 0 0 auto !important;
  width: auto !important;
  min-width: max-content !important;
  max-width: none !important;
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: flex-end !important;
  gap: 10px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  overflow: visible !important;
  order: 2 !important;
}
html body #header#header .header-actions .btn {
  width: auto !important;
  min-width: 0 !important;
  max-width: none !important;
  padding: 0 16px !important;
  flex: 0 0 auto !important;
}
html body #header#header .header-actions .btn[hidden] {
  display: none !important;
}
html body #header#header .mc-logout-form {
  display: inline-flex !important;
  width: auto !important;
  margin: 0 !important;
}
html body #header#header .mc-lang {
  flex: 0 0 auto !important;
  margin: 0 !important;
  order: 3 !important;
}
html body #header#header .mobile-nav-toggle {
  display: none !important;
}

/* Globe label: shown on the roomy desktop row, icon-only on the tight row (mc-nav.js decides). */
html body #header#header .mc-lang .mc-lang-toggle {
  width: auto !important;
  padding: 0 11px !important;
}
html body #header#header .mc-lang .mc-lang-current,
html body #header#header .mc-lang .mc-lang-caret {
  display: inline !important;
}
/* Tight desktop row: tried before falling back to the compact layout. */
html.mc-nav-tight body #header#header .header-container { gap: 12px !important; }
html.mc-nav-tight body #header#header .navmenu a,
html.mc-nav-tight body #header#header .navmenu a.active,
html.mc-nav-tight body #header#header .navmenu a:hover { padding: 0 8px !important; }
html.mc-nav-tight body #header#header .header-actions { gap: 8px !important; }
html.mc-nav-tight body #header#header .header-actions .btn { padding: 0 13px !important; }
html.mc-nav-tight body #header#header .mc-lang .mc-lang-toggle,
html.mc-nav-compact body #header#header .mc-lang .mc-lang-toggle,
html:not(.mc-nav-js) body #header#header .mc-lang .mc-lang-toggle {
  width: 36px !important;
  padding: 0 !important;
  justify-content: center !important;
}
html.mc-nav-tight body #header#header .mc-lang .mc-lang-current,
html.mc-nav-tight body #header#header .mc-lang .mc-lang-caret,
html:not(.mc-nav-js) body #header#header .mc-lang .mc-lang-current,
html:not(.mc-nav-js) body #header#header .mc-lang .mc-lang-caret {
  display: none !important;
}

/* Measurement pass (mc-nav.js, synchronous, never painted): intrinsic widths only. */
html.mc-nav-measuring body #header#header .logo,
html.mc-nav-measuring body #header#header .navmenu,
html.mc-nav-measuring body #header#header .header-actions,
html.mc-nav-measuring body #header#header .mc-lang {
  flex: 0 0 auto !important;
}
html.mc-nav-measuring body #header#header .logo {
  flex-basis: auto !important;
}
html.mc-nav-measuring body #header#header,
html.mc-nav-measuring body #header#header * {
  transition: none !important;
  animation: none !important;
}

/* ---------- Compact layout (JS decided) ---------- */
html.mc-nav-compact body #header#header .header-container {
  width: 100% !important;
  padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left)) !important;
  gap: 8px !important;
}
html.mc-nav-compact body #header#header .logo {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  max-width: none !important;
  overflow: hidden !important;
}
html.mc-nav-compact body #header#header .logo .sitename {
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}
html.mc-nav-compact body #header#header .mc-lang {
  order: 1 !important;
  margin-left: auto !important;
}
html.mc-nav-compact body #header#header .mc-lang .mc-lang-toggle {
  width: 42px !important;
  height: 42px !important;
  padding: 0 !important;
  justify-content: center !important;
}
html.mc-nav-compact body #header#header .mc-lang .mc-lang-current,
html.mc-nav-compact body #header#header .mc-lang .mc-lang-caret {
  display: none !important;
}
html.mc-nav-compact body #header#header .mc-lang .mc-lang-menu {
  position: fixed !important;
  top: 72px !important;
  right: 10px !important;
  left: auto !important;
  max-height: calc(100vh - 90px) !important;
}
html.mc-nav-compact body #header#header .mobile-nav-toggle {
  order: 2 !important;
  display: inline-grid !important;
  place-items: center !important;
  flex: 0 0 42px !important;
  width: 42px !important;
  height: 42px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 1px solid rgba(255, 255, 255, .16) !important;
  border-radius: 12px !important;
  background: rgba(255, 255, 255, .06) !important;
  color: #fffaf0 !important;
  font-size: 1.35rem !important;
  line-height: 1 !important;
  cursor: pointer !important;
}
html.mc-nav-compact body #header#header .mobile-nav-toggle:focus-visible {
  outline: 3px solid rgba(143, 240, 191, .75) !important;
  outline-offset: 2px !important;
}
html.mc-nav-compact body #header#header .mc-nav-panel {
  display: none !important;
  position: fixed !important;
  top: 66px !important;
  left: 0 !important;
  right: 0 !important;
  max-height: calc(100vh - 66px) !important;
  max-height: calc(100dvh - 66px) !important;
  overflow-y: auto !important;
  overscroll-behavior: contain !important;
  padding: 12px 16px 22px !important;
  background: #080a10 !important;
  border-bottom: 1px solid rgba(255, 255, 255, .1) !important;
  box-shadow: 0 28px 60px rgba(0, 0, 0, .55) !important;
  box-sizing: border-box !important;
}
html.mc-nav-compact.mc-nav-open body #header#header .mc-nav-panel {
  display: block !important;
}
html.mc-nav-compact body #header#header .navmenu,
html.mc-nav-compact body #header#header .header-actions {
  width: 100% !important;
  max-width: 640px !important;
  min-width: 0 !important;
  margin: 0 auto !important;
}
html.mc-nav-compact body #header#header .navmenu {
  display: block !important;
}
html.mc-nav-compact body #header#header .navmenu ul {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 4px !important;
  width: 100% !important;
}
html.mc-nav-compact body #header#header .navmenu li {
  display: block !important;
  width: 100% !important;
  height: auto !important;
  min-height: 0 !important;
}
html.mc-nav-compact body #header#header .navmenu a,
html.mc-nav-compact body #header#header .navmenu a.active,
html.mc-nav-compact body #header#header .navmenu a:hover {
  display: flex !important;
  width: 100% !important;
  height: auto !important;
  min-height: 46px !important;
  padding: 10px 14px !important;
  justify-content: flex-start !important;
  text-align: left !important;
  white-space: normal !important;
  font-size: 1rem !important;
  line-height: 1.25 !important;
}
html.mc-nav-compact body #header#header .header-actions {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 10px !important;
  margin-top: 12px !important;
  padding-top: 14px !important;
  border-top: 1px solid rgba(255, 255, 255, .1) !important;
}
html.mc-nav-compact body #header#header .header-actions .btn,
html.mc-nav-compact body #header#header .mc-logout-form,
html.mc-nav-compact body #header#header .mc-logout-form .btn {
  display: flex !important;
  width: 100% !important;
  height: 46px !important;
  min-height: 46px !important;
  justify-content: center !important;
  font-size: .95rem !important;
}
html.mc-nav-compact body #header#header .header-actions .btn[hidden] {
  display: none !important;
}
html.mc-nav-open,
html.mc-nav-open body {
  overflow: hidden !important;
}

/* ---------- No-JS fallback: same compact layout below the widest measured fit ---------- */
@media (max-width: 1439.98px) {
  html:not(.mc-nav-js) body #header#header .header-container {
    width: 100% !important;
    padding: 0 12px !important;
    gap: 8px !important;
  }
  html:not(.mc-nav-js) body #header#header .logo {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    overflow: hidden !important;
  }
  html:not(.mc-nav-js) body #header#header .mc-lang { order: 1 !important; margin-left: auto !important; }
  html:not(.mc-nav-js) body #header#header .mc-lang .mc-lang-current,
  html:not(.mc-nav-js) body #header#header .mc-lang .mc-lang-caret { display: none !important; }
  html:not(.mc-nav-js) body #header#header .mobile-nav-toggle {
    order: 2 !important;
    display: inline-grid !important;
    place-items: center !important;
    flex: 0 0 42px !important;
    width: 42px !important;
    height: 42px !important;
    border: 1px solid rgba(255, 255, 255, .16) !important;
    border-radius: 12px !important;
    background: rgba(255, 255, 255, .06) !important;
    color: #fffaf0 !important;
    font-size: 1.35rem !important;
  }
  html:not(.mc-nav-js) body #header#header .mc-nav-panel {
    display: none !important;
    position: fixed !important;
    top: 66px !important;
    left: 0 !important;
    right: 0 !important;
    max-height: calc(100vh - 66px) !important;
    overflow-y: auto !important;
    padding: 12px 16px 22px !important;
    background: #080a10 !important;
    box-sizing: border-box !important;
  }
  /* Without JS the menu opens while the toggle (or a link inside the panel) has focus. */
  html:not(.mc-nav-js) body #header#header .header-container:has(.mobile-nav-toggle:focus) .mc-nav-panel,
  html:not(.mc-nav-js) body #header#header .mc-nav-panel:focus-within {
    display: block !important;
  }
  html:not(.mc-nav-js) body #header#header .navmenu,
  html:not(.mc-nav-js) body #header#header .header-actions {
    width: 100% !important;
    max-width: 640px !important;
    min-width: 0 !important;
    margin: 0 auto !important;
  }
  html:not(.mc-nav-js) body #header#header .navmenu { display: block !important; }
  html:not(.mc-nav-js) body #header#header .navmenu ul { display: grid !important; grid-template-columns: minmax(0, 1fr) !important; gap: 4px !important; }
  html:not(.mc-nav-js) body #header#header .navmenu li { display: block !important; width: 100% !important; height: auto !important; min-height: 0 !important; }
  html:not(.mc-nav-js) body #header#header .navmenu a {
    display: flex !important;
    width: 100% !important;
    height: auto !important;
    min-height: 46px !important;
    padding: 10px 14px !important;
    justify-content: flex-start !important;
    white-space: normal !important;
  }
  html:not(.mc-nav-js) body #header#header .header-actions {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 10px !important;
    margin-top: 12px !important;
    padding-top: 14px !important;
    border-top: 1px solid rgba(255, 255, 255, .1) !important;
  }
  html:not(.mc-nav-js) body #header#header .header-actions .btn,
  html:not(.mc-nav-js) body #header#header .mc-logout-form,
  html:not(.mc-nav-js) body #header#header .mc-logout-form .btn {
    display: flex !important;
    width: 100% !important;
    height: 46px !important;
    justify-content: center !important;
  }
}
