@use '../globals';

.navbar {
  @include globals.flex-center();
  justify-content: space-between;
  padding: 1em;
  background: #042c53; // always night-blue – independent of --color-primary cascade
  color: var(--color-text-on-dark);
  height: 65px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(4, 44, 83, 0.2);

  &__name {
    font-weight: bold;
    font-size: 1.25rem;
    color: var(--color-text-on-dark);
    text-decoration: none;
  }

  &__logo {
    height: 65px;
    max-height: calc(65px - 0.5rem); // stay within navbar height minus padding
    width: auto;
    display: block;

    @media (max-width: 768px) {
      height: 48px;
    }
  }

  &__container {
    display: flex;
    align-items: center;
    // Fluid gap: 0.25rem at 1050px → 0.5rem at 1300px
    gap: clamp(0.25rem, -0.8rem + 1.6vw, 0.5rem);

    &__button {
      @extend %button-reset;
      @extend %hover-lift;
      // Fluid padding: 0.5rem 0.5rem at 1050px → 0.6rem 1.2rem at 1300px
      padding: clamp(0.5rem, 0.08rem + 0.64vw, 0.6rem)
        clamp(0.5rem, -2.44rem + 4.48vw, 1.2rem);
      border-radius: 8px;
      color: var(--color-text-on-dark);
      white-space: nowrap;
      // Fluid font-size: 0.85rem at 1050px → 1rem at 1300px
      font-size: clamp(0.85rem, 0.22rem + 0.96vw, 1rem);
      transition:
        color 0.2s ease,
        box-shadow 0.2s ease,
        transform 0.2s ease;

      &:hover {
        color: var(--color-accent-deco);
        box-shadow: none;
        transform: none;
      }

      &:active {
        box-shadow: none;
        transform: translateY(0);
      }

      &--active {
        color: var(
          --color-text-on-dark
        ); // #E6F1FB – 10:1 contrast, same as default
        box-shadow: none;
        background: rgba(230, 241, 251, 0.12);
        border-bottom: 2px solid var(--color-accent-deco); // ochre underline as accent indicator
        border-radius: 8px 8px 4px 4px;
      }
    }
  }

  &__burger-button {
    @include globals.flex-center();
    flex-direction: column;
    justify-content: space-between;
    width: 20px;
    height: 17px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;

    &__item {
      display: block;
      height: 3px;
      width: 100%;
      background-color: var(--color-text-on-dark); // light on dark navy bg
      border-radius: 2px;
      transition: all 0.3s ease;
      margin: 1px 0;
    }

    &:hover &__item {
      background-color: var(--color-accent-deco); // ochre accent on hover
    }

    &.active {
      &__item:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
      }
      &__item:nth-child(2) {
        opacity: 0;
      }
      &__item:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px);
      }
    }
  }

  /* Mobile Menu Dropdown */
  .navbar__mobile-menu {
    position: absolute;
    top: 65px;
    right: 0;
    background: var(--color-background);
    color: var(--color-text);
    border: 1px solid var(--color-primary);
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 4px 12px var(--box-shadow-hover);
    z-index: 10;
    min-width: 200px;

    &__header {
      display: flex;
      justify-content: flex-end;
      padding: 0.5em;
      border-bottom: 1px solid var(--color-border, rgba(0, 0, 0, 0.1));
    }

    &__close {
      @extend %button-reset;
      font-size: 1.5rem;
      width: 30px;
      height: 30px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 4px;
      transition: background 0.2s;
      color: var(--color-text);

      &:hover {
        background: var(--box-shadow-active);
      }
    }

    &__items {
      display: flex;
      flex-direction: column;
      gap: 0;
      padding: 0.5em;
    }

    &__item {
      @extend %button-reset;
      padding: 0.75em 1em;
      text-align: left;
      border-radius: 4px;
      transition: background 0.2s;
      width: 100%;

      &:hover {
        background: var(--box-shadow-active);
      }
    }
  }
}

@include globals.mobile-only {
  .navbar__container__button {
    display: none;
  }
}

// Landing page has 7 menu items — switch to burger at same breakpoint as regular nav
@media (max-width: 1049px) {
  .navbar--landing .navbar__container__button {
    display: none;
  }
}

@include globals.desktop-only {
  .navbar__burger-button {
    display: none;
  }
}

// Keep burger visible for landing page up to 1049px
@media (min-width: 769px) and (max-width: 1049px) {
  .navbar--landing .navbar__burger-button {
    display: flex;
  }
}
