#header {
  position: relative;
  height: 100px;
  display: flex;
  align-items: center; /* vertical center */

  @media screen and (min-width: 1100px) {
    height: 130px;
  }
  
  #navbar {
    padding: 0 15px;
    display: flex;
    align-items: center;       /* vertical align logo + nav */
    justify-content: space-between; /* logo left, nav right */

    @media screen and (min-width: 1100px) {
      padding: 0 50px;
    }
  }
  .logo img {
    width: 200px;
    height: auto;
    display: block;

    @media screen and (min-width: 1100px) {
      width: 310px;
    }
  }
  .hamburger {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 11;

    @media screen and (min-width: 1100px) {
      display: none;
    }
  }
  .hamburger__line {
    display: block;
    width: 24px;
    height: 2px;
    background-color: var(--color-dark-blue-text);
    transition: transform 0.3s ease, opacity 0.3s ease;
  }
  .hamburger.is-active .hamburger__line:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  .hamburger.is-active .hamburger__line:nth-child(2) {
    opacity: 0;
  }
  .hamburger.is-active .hamburger__line:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  /* ══════════════════════════════════════
     Desktop menu (#navbar-menu)
     Hidden on mobile, flex on desktop
     ══════════════════════════════════════ */
  #navbar .navbar-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: none;

    @media screen and (min-width: 1100px) {
      display: flex;
      gap: 40px;
    }
  }
  #navbar .navbar-menu li {
    position: relative;
  }

  /* ── Desktop submenu (dropdown) ── */
  .navbar-menu .submenu {
    list-style: none;
    margin: 0;
    padding: 0;

    @media screen and (min-width: 1100px) {
      position: absolute;
      top: 100%;
      left: 50%;
      translate: -50% 0;
      display: flex;
      flex-direction: column;
      min-width: max-content;
      background: var(--color-dark-blue-background);
      padding: 10px 0;
      box-shadow: 0 8px 24px rgb(0 0 0 / 0.12);

      /* hidden by default */
      opacity: 0;
      visibility: hidden;
      translate: -50% 8px;
      transition: opacity 0.2s ease, visibility 0.2s ease, translate 0.2s ease;

      /* show on hover / focus-within / JS toggle */
      .navbar-menu-item:hover > &,
      .navbar-menu-item:focus-within > &,
      .navbar-menu-item.is-open > & {
        opacity: 1;
        visibility: visible;
        translate: -50% 0;
      }

      & li a {
        display: block;
        padding: 8px 20px;
        white-space: nowrap;
        font-family: var(--font-sans);
        font-size: var(--text-x-small);
        text-decoration: none;
        color: var(--color-light-blue-text);
        transition: background-color 0.15s ease;
      }
      & li a:hover {
        background-color: rgb(255 255 255 / 0.1);
      }
    }
  }

  /* Style the desktop submenu-trigger buttons */
  #navbar .navbar-menu-item > button {
    cursor: pointer;
    background: none;
    font-family: var(--font-sans);
    font-size: var(--text-x-small);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 9px 0;
    border: 1px solid transparent;
    color: inherit;
  }

  /* Desktop: only on home page */
  @media screen and (min-width: 1100px) {
    .template-home & #navbar li {
      opacity: 0;
      animation: nav-fade-in 0.6s ease forwards;
    }
    .template-home & #navbar li:nth-child(1) { animation-delay: 0.1s; }
    .template-home & #navbar li:nth-child(2) { animation-delay: 0.2s; }
    .template-home & #navbar li:nth-child(3) { animation-delay: 0.3s; }
    .template-home & #navbar li:nth-child(4) { animation-delay: 0.4s; }
    .template-home & #navbar li:nth-child(5) { animation-delay: 0.5s; }
    .template-home & #navbar li:nth-child(6) { animation-delay: 0.6s; }
    .template-home & #navbar li:nth-child(7) { animation-delay: 0.7s; }
    .template-home & #navbar li:nth-child(8) { animation-delay: 0.8s; }
  }

  /* Desktop menu item links & buttons */
  #navbar .navbar-menu-item > a,
  #navbar .navbar-menu-item > button {
    text-decoration: none;
    font-family: var(--font-sans);
    font-size: var(--text-x-small);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 9px 0px;
    border: 1px solid transparent;
    display: block;
    color: var(--color-dark-blue-text);
    &.navbar-button {
      padding: 9px 25px;
      border-radius: 9999px;
      border: 1px solid var(--color-dark-blue-text);
      background-color: transparent;
    }
  }

  /* ══════════════════════════════════════
     Mobile menu (#navbar-menu-mobile)
     Shown via .hamburger.is-active sibling selector
     JS handles focus management + Escape key
     Hidden on desktop
     ══════════════════════════════════════ */
  .navbar-menu-mobile {
    list-style: none;
    margin: 0;
    padding: 0;
    display: none; /* hidden by default */

    @media screen and (min-width: 1100px) {
      display: none !important; /* always hidden on desktop */
    }
  }

  /* Show when hamburger is active */
  .hamburger.is-active ~ .navbar-menu-mobile {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(100dvh - 100px);
    background-color: var(--color-dark-blue-background);
    padding: 2rem 15px;
    gap: 1.5rem;
    z-index: 10;
    animation: mobile-menu-open 0.3s ease forwards;
  }

  @keyframes mobile-menu-open {
    from {
      opacity: 0;
      transform: translateY(-10px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .navbar-menu-mobile a {
    color: var(--color-light-blue-text);
  }

  .navbar-menu-mobile li {
    position: relative;
  }

  /* Mobile menu item links & labels */
  .navbar-menu-mobile-item > a,
  .navbar-menu-mobile-label {
    text-decoration: none;
    font-family: var(--font-sans);
    font-size: var(--text-x-small);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 9px 0px;
    border: 1px solid transparent;
    display: block;
    color: var(--color-light-blue-text);
    &.navbar-button {
      padding: 9px 25px;
      border-radius: 9999px;
      border: 1px solid var(--color-light-blue-text);
      background-color: transparent;
      text-align: center;
    }
  }

  /* Mobile submenu category labels */
  .navbar-menu-mobile-label {
    font-weight: inherit;
    cursor: default;
  }

  /* Mobile submenus: always visible (no toggle JS) */
  .submenu-mobile {
    list-style: none;
    margin: 0;
    padding: 0 0 0 1rem;
    display: flex;
    flex-direction: column;

    & li a {
      display: block;
      padding: 6px 0;
      font-family: var(--font-sans);
      font-size: var(--text-x-small);
      text-decoration: none;
      color: var(--color-light-blue-text);
    }
  }

  /* Mobile: staggered fade-in for menu items */
  .hamburger.is-active ~ .navbar-menu-mobile > li {
    opacity: 0;
    animation: nav-fade-in 0.6s ease forwards;
  }
  .hamburger.is-active ~ .navbar-menu-mobile > li:nth-child(1) { animation-delay: 0.1s; }
  .hamburger.is-active ~ .navbar-menu-mobile > li:nth-child(2) { animation-delay: 0.2s; }
  .hamburger.is-active ~ .navbar-menu-mobile > li:nth-child(3) { animation-delay: 0.3s; }
  .hamburger.is-active ~ .navbar-menu-mobile > li:nth-child(4) { animation-delay: 0.4s; }
  .hamburger.is-active ~ .navbar-menu-mobile > li:nth-child(5) { animation-delay: 0.5s; }
  .hamburger.is-active ~ .navbar-menu-mobile > li:nth-child(6) { animation-delay: 0.6s; }
  .hamburger.is-active ~ .navbar-menu-mobile > li:nth-child(7) { animation-delay: 0.7s; }
  .hamburger.is-active ~ .navbar-menu-mobile > li:nth-child(8) { animation-delay: 0.8s; }
}

@keyframes nav-fade-in {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
