/* =============================================================================
 * Custom Header Navigation
 * ============================================================================= */

.md-header {
  position: sticky;
  top: 0;
  z-index: 20;
  overflow: visible;
  color: var(--lupaxa-white);
  background: linear-gradient(180deg, var(--lupaxa-card-bg-raised), var(--lupaxa-card-bg));
}

.md-header__inner {
  position: relative;
}

.lupaxa-header__inner {
  display: flex;
  width: 100%;
  max-width: var(--lupaxa-content-width);
  min-height: var(--lupaxa-header-height);
  align-items: center;
  gap: 0;
  /* Same side inset as the page column, so the logo and language
     picker sit on the body edges. Overrides Material's 0.2rem padding. */
  padding-right: var(--lupaxa-gutter-right);
  padding-left: var(--lupaxa-gutter-left);
}

/* Brand mark */

.md-header__button.md-logo.lupaxa-header__logo {
  display: inline-flex;
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  align-items: center;
  justify-content: center;
  margin: 0 0.75rem 0 0;
  padding: 0;
  border-radius: 50%;
}

.md-header__button.md-logo.lupaxa-header__logo img,
.md-header__button.md-logo.lupaxa-header__logo svg {
  display: block;
  width: 64px;
  height: 64px;
  max-width: none;
  max-height: none;
  object-fit: contain;
}

/* Primary desktop navigation */

.lupaxa-header__nav {
  position: relative;
  z-index: 2;
  min-width: 0;
  flex: 1 1 auto;
  align-self: stretch;
  pointer-events: auto;
}

.lupaxa-header__nav-list {
  display: flex;
  height: 100%;
  align-items: stretch;
  gap: var(--lupaxa-spacing-xs);
  margin: 0;
  padding: 0;
  list-style: none;
  pointer-events: auto;
}

.lupaxa-header__nav-item {
  position: relative;
  display: flex;
  height: 100%;
  align-items: stretch;
  margin: 0;
  padding: 0;
  pointer-events: auto;
}

/* Child pages of a header section. Hidden until the section is hovered. */

.lupaxa-header__menu {
  position: absolute;
  top: calc(100% - 0.35rem);
  /* Same inset as the header label, so the panel lines up with the text. */
  left: 0.75rem;
  z-index: 30;
  display: none;
  min-width: 12rem;
  margin: 0;
  padding: 0.35rem;
  list-style: none;
  background: var(--lupaxa-card-bg);
  border: 1px solid color-mix(in srgb, var(--lupaxa-light-blue) 28%, transparent);
  border-radius: var(--lupaxa-radius-button);
  box-shadow: var(--lupaxa-shadow-panel);
}

/* Upward caret, 20px in from the panel's left edge. */
.lupaxa-header__menu::before,
.lupaxa-header__menu::after {
  content: "";
  position: absolute;
  width: 0;
  height: 0;
  border-style: solid;
  border-right-color: transparent;
  border-left-color: transparent;
}

.lupaxa-header__menu::before {
  top: -11px;
  left: 20px;
  border-width: 0 7px 11px 7px;
  border-bottom-color: color-mix(in srgb, var(--lupaxa-light-blue) 28%, transparent);
}

.lupaxa-header__menu::after {
  top: -10px;
  left: 21px;
  border-width: 0 6px 10px 6px;
  border-bottom-color: var(--lupaxa-card-bg);
}

.lupaxa-header__nav-item--menu:hover > .lupaxa-header__menu,
.lupaxa-header__nav-item--menu:focus-within > .lupaxa-header__menu {
  display: block;
}

/* Stay closed after a click until the pointer leaves the section. */

html.lupaxa-header-menu-dismissed .lupaxa-header__nav-item--menu:hover > .lupaxa-header__menu,
html.lupaxa-header-menu-dismissed .lupaxa-header__nav-item--menu:focus-within > .lupaxa-header__menu {
  display: none;
}

.lupaxa-header__menu-item {
  margin: 0;
  padding: 0;
}

.lupaxa-header__menu-link {
  display: block;
  /* Same inset as the menu padding on every side, so the label sits as
     far inside the hover as the hover sits inside the panel. */
  padding: 0.35rem;
  color: rgb(255 255 255 / 82%);
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.3;
  text-decoration: none;
  border-radius: var(--lupaxa-radius-sm);
}

.lupaxa-header__menu-link:hover,
.lupaxa-header__menu-link:focus-visible,
.lupaxa-header__menu-link--active {
  color: var(--lupaxa-white);
  background: var(--lupaxa-card-bg-raised);
}

.lupaxa-header__menu-link--active {
  font-weight: 700;
}

.lupaxa-header__nav-link {
  position: relative;
  z-index: 1;
  display: flex;
  height: 100%;
  align-items: center;
  padding: 0 0.75rem;
  color: rgb(255 255 255 / 72%);
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  background: none;
  border-radius: 0;
  box-shadow: none;
  pointer-events: auto;
  transition: color var(--lupaxa-transition-fast);
}

.lupaxa-header__nav-link:hover,
.lupaxa-header__nav-link:focus-visible {
  color: var(--lupaxa-white);
  background: none;
  box-shadow: none;
}

.lupaxa-header__nav-item--active .lupaxa-header__nav-link {
  color: var(--lupaxa-white);
  font-weight: 700;
  background: none;
  box-shadow: none;
}

.lupaxa-header__nav-label {
  text-decoration: none;
}

.lupaxa-header__nav-link:hover .lupaxa-header__nav-label,
.lupaxa-header__nav-link:focus-visible .lupaxa-header__nav-label,
.lupaxa-header__nav-item--active .lupaxa-header__nav-label {
  text-decoration: underline;
  text-decoration-color: var(--lupaxa-light-blue);
  text-decoration-thickness: 2px;
  text-underline-offset: 0.12em;
  text-decoration-skip-ink: auto;
}

/* GitHub and the language picker sit together at the right of the header. */

.lupaxa-header__tools {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  margin-left: auto;
  pointer-events: auto;
}

.lupaxa-header__drawer-button {
  display: none;
  margin: 0;
  color: var(--lupaxa-white);
}

/* Repository link (top right) */

.lupaxa-header__tools > .md-header__source {
  position: relative;
  z-index: 3;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  width: auto;
  max-width: none;
  padding-right: 0;
  pointer-events: auto;
}

.md-header__source .md-source {
  color: rgb(255 255 255 / 85%);
  text-decoration: none;
}

.md-header__source .md-source:hover,
.md-header__source .md-source:focus-visible {
  color: var(--lupaxa-white);
}

.md-header__source .md-source__repository {
  max-width: 14rem;
}

/* Language preference */

.lupaxa-lang-picker {
  position: relative;
  z-index: 3;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  margin-left: 1rem;
  padding: 0;
}

.lupaxa-lang-picker__select {
  color: var(--lupaxa-white);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.4;
  appearance: none;
  cursor: pointer;
  background-color: rgb(255 255 255 / 10%);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ffffff'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.35rem center;
  background-size: 0.9rem;
  border: 1px solid rgb(255 255 255 / 28%);
  border-radius: var(--lupaxa-radius-button);
  padding: 0.35rem 1.35rem 0.35rem 0.55rem;
}

.lupaxa-lang-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.4rem 1rem;
  color: var(--lupaxa-white);
  background-color: color-mix(in srgb, var(--lupaxa-blue) 82%, black);
}

.lupaxa-lang-fallback[hidden] {
  display: none;
}

.lupaxa-lang-fallback__text {
  margin: 0;
  font-size: 0.9rem;
}

.lupaxa-lang-fallback__dismiss {
  color: var(--lupaxa-white);
  font-size: 0.85rem;
  background: none;
  border: 1px solid rgb(255 255 255 / 40%);
  border-radius: var(--lupaxa-radius-pill);
  padding: 0.15rem 0.7rem;
}
