/**
 * @file
 * Header component styles.
 */

.header {
  position: sticky;
  top: 0;
  z-index: 100;
  padding-block: var(--sp3);
  background-color: var(--white);
  box-shadow: none;
  transition: box-shadow 0.3s ease;
}

@media (width < 1240px) {
  .header {
    position: relative;
  }
}

.header.is-scrolled {
  box-shadow: var(--shadow-md);
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp3);
  max-width: var(--container-width);
  margin-inline: auto;
  padding-inline: var(--sp3);
}

.header-container > div:first-child {
  display: flex;
}

.header-navigation > div {
  display: flex;
  flex: 1 1 auto;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp5);
}

.header-navigation .block-button {
  flex: none;
}

/**
 * Site branding / logo.
 */
.header .block-system-branding-block a {
  display: block;
  line-height: 0;
}

.header .block-system-branding-block img {
  height: var(--sp5);
  width: auto;
}

/**
 * Header navigation wrapper.
 */
.header-navigation {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--sp5);
}

/**
 * Main navigation menu.
 */
.header nav ul:not(.contextual-links) {
  display: flex;
  align-items: center;
  gap: var(--sp5);
  margin: 0;
  padding: 0;
  list-style: none;
  justify-content: center;
}

.header nav li {
  margin: 0;
}

.header nav a {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-sans);
  font-size: var(--body-s-size);
  line-height: var(--body-l-line-height);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.2s ease;
}

.header nav a:hover,
.header nav a:focus {
  color: var(--primary-600);
}

.header nav a:focus-visible {
  outline: var(--focus-ring-style) var(--focus-ring-width) var(--primary);
  outline-offset: var(--radius-sm);
}

/**
 * Active menu item.
 */
.header nav li.menu-item--active-trail > a,
.header nav a.is-active {
  color: var(--primary-700);
}

/**
 * Mobile menu toggle button.
 */
.mobile-menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: var(--sp5);
  height: var(--sp5);
  padding: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
  order: 3;
}

.mobile-menu-toggle__icon {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: var(--sp3);
  height: var(--sp3);
}

.mobile-menu-toggle__icon span {
  display: block;
  width: 100%;
  height: 2px;
  background-color: var(--black);
  border-radius: 1px;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Hamburger to X animation */
.mobile-menu-toggle[aria-expanded="true"] .mobile-menu-toggle__icon span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.mobile-menu-toggle[aria-expanded="true"] .mobile-menu-toggle__icon span:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle[aria-expanded="true"] .mobile-menu-toggle__icon span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.mobile-menu-toggle:focus-visible {
  outline: var(--focus-ring-style) var(--focus-ring-width) var(--primary);
  outline-offset: var(--radius-sm);
}

/**
 * Hide contextual links in header.
 */
.header .contextual {
  display: none;
}

/**
 * Responsive: Mobile styles (below 1240px breakpoint).
 */
@media (width < 1240px) {
  .mobile-menu-toggle {
    display: flex;
  }

  .header-navigation {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    padding: var(--sp3);
    background-color: var(--white);
    box-shadow: var(--shadow-md);
  }

  .header-navigation.is-open {
    display: flex;
  }

  .header-navigation > div {
    flex-direction: column;
    align-items: stretch;
    gap: var(--sp3);
    padding-inline: var(--sp3);
  }

  .header nav ul:not(.contextual-links) {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .header nav li {
    border-block-end: 1px solid var(--neutral-200);
  }

  .header nav li:last-child {
    border-block-end: 0;
  }

  .header nav a {
    justify-content: flex-start;
    padding-block: var(--sp2);
    font-size: var(--body-l-size);
  }

  .header .block-button {
    margin-block-start: var(--sp2);
  }

  .header .block-button .button {
    width: 100%;
    justify-content: center;
  }
}

/**
 * Body class when mobile menu is open.
 */
body.mobile-menu-open {
  overflow: hidden;
}
