/* ==========================================================================
   CLUNKY DESIGN SYSTEM
   Navigation
   File: /assets/css/layout/navigation.css

   Sprint 1 canonical version.

   RESPONSIBILITY
   - Primary navigation
   - Navigation links
   - Mobile navigation
   - Navigation toggle
   - Active/current states

   DO NOT PUT HERE
   - Header container       -> header.css
   - Hero navigation        -> hero.css
   - Button styling         -> buttons.css

   FUTURE EXTENSION POINTS
   1. Dropdown navigation
   2. Mega navigation
   3. Search trigger
   4. Mobile drawer animation
   5. JS-driven aria-expanded states
========================================================================== */


/* ==========================================================================
   1. PRIMARY NAVIGATION
========================================================================== */

.site-nav {
  display: flex;
  align-items: center;

  gap: 1.5rem;

  margin-left: auto;
}


/* ==========================================================================
   2. NAVIGATION LIST
========================================================================== */

.nav-list {
  display: flex;
  align-items: center;

  gap: 0.25rem;

  margin: 0;
  padding: 0;

  list-style: none;
}


/* ==========================================================================
   3. NAVIGATION ITEM
========================================================================== */

.nav-item {
  position: relative;
}


/* ==========================================================================
   4. NAVIGATION LINK
========================================================================== */

.nav-link {
  position: relative;

  display: inline-flex;
  align-items: center;

  min-height: 2.5rem;

  padding: 0.5rem 0.625rem;

  border-radius: 0.5rem;

  color: var(
    --color-text-muted,
    #64748b
  );

  font-size: 0.9375rem;
  font-weight: 600;

  line-height: 1.4;

  text-decoration: none;

  transition:
    color 160ms ease,
    background-color 160ms ease;
}


.nav-link:hover {
  color: var(
    --color-heading,
    #111827
  );

  background: var(
    --color-surface-subtle,
    #f8fafc
  );
}


.nav-link:focus-visible {
  outline: 3px solid var(
    --color-focus,
    #2563eb
  );

  outline-offset: 2px;
}


/* ==========================================================================
   5. CURRENT / ACTIVE PAGE
========================================================================== */

.nav-link[aria-current="page"] {
  color: var(
    --color-heading,
    #111827
  );

  font-weight: 700;
}


.nav-link[aria-current="page"]::after {
  content: "";

  position: absolute;

  right: 0.625rem;
  bottom: 0.25rem;
  left: 0.625rem;

  height: 2px;

  border-radius: 999px;

  background: var(
    --color-accent,
    #2563eb
  );
}


/* ==========================================================================
   6. NAVIGATION TOGGLE
========================================================================== */

.nav-toggle {
  display: none;

  width: 2.75rem;
  height: 2.75rem;

  padding: 0;

  border: 1px solid var(
    --color-border,
    #e5e7eb
  );

  border-radius: 0.625rem;

  background: var(
    --color-surface,
    #ffffff
  );

  color: var(
    --color-heading,
    #111827
  );

  cursor: pointer;

  align-items: center;
  justify-content: center;
  flex-direction: column;

  gap: 0.25rem;
}


.nav-toggle:hover {
  background: var(
    --color-surface-subtle,
    #f8fafc
  );
}


.nav-toggle:focus-visible {
  outline: 3px solid var(
    --color-focus,
    #2563eb
  );

  outline-offset: 2px;
}


/* ==========================================================================
   7. TOGGLE LINES
========================================================================== */

.nav-toggle-line {
  display: block;

  width: 1.125rem;
  height: 2px;

  border-radius: 999px;

  background: currentColor;

  transition:
    transform 180ms ease,
    opacity 180ms ease;
}


/* ==========================================================================
   8. MOBILE OPEN STATE
==========================================================================

   The existing HTML uses:

   aria-expanded="false"

   JavaScript can later change this to:

   aria-expanded="true"

   The CSS below intentionally uses the ARIA state as the source of truth.
========================================================================== */

.nav-toggle[aria-expanded="true"] .nav-toggle-line:nth-child(1) {
  transform: translateY(0.375rem) rotate(45deg);
}


.nav-toggle[aria-expanded="true"] .nav-toggle-line:nth-child(2) {
  opacity: 0;
}


.nav-toggle[aria-expanded="true"] .nav-toggle-line:nth-child(3) {
  transform: translateY(-0.375rem) rotate(-45deg);
}


/* ==========================================================================
   9. DESKTOP NAVIGATION
========================================================================== */

@media (min-width: 901px) {

  .site-nav {
    visibility: visible;
    opacity: 1;
  }

}


/* ==========================================================================
   10. MOBILE NAVIGATION
========================================================================== */

@media (max-width: 900px) {

  .nav-toggle {
    display: inline-flex;
  }


  .site-nav {
    position: absolute;

    top: 100%;
    right: 0;
    left: 0;

    display: flex;
    flex-direction: column;
    align-items: stretch;

    gap: 1rem;

    padding: 1rem;

    background: var(
      --color-surface,
      #ffffff
    );

    border-bottom: 1px solid var(
      --color-border,
      #e5e7eb
    );

    box-shadow: var(
      --shadow-md,
      0 10px 30px rgba(15, 23, 42, 0.08)
    );

    visibility: hidden;
    opacity: 0;

    transform: translateY(-0.5rem);

    pointer-events: none;

    transition:
      opacity 180ms ease,
      transform 180ms ease,
      visibility 180ms ease;
  }


  .site-nav[aria-expanded="true"],
  .nav-toggle[aria-expanded="true"] + .site-nav {
    visibility: visible;

    opacity: 1;

    transform: translateY(0);

    pointer-events: auto;
  }


  .nav-list {
    width: 100%;

    flex-direction: column;
    align-items: stretch;

    gap: 0.25rem;
  }


  .nav-item {
    width: 100%;
  }


  .nav-link {
    width: 100%;

    min-height: 3rem;

    padding: 0.75rem;

    justify-content: flex-start;
  }


  .nav-link[aria-current="page"]::after {
    right: auto;
    bottom: 0.5rem;
    left: 0.75rem;

    width: 2rem;
  }


  .header-actions {
    width: 100%;
  }


  .header-actions .btn {
    width: 100%;
  }

}


/* ==========================================================================
   11. FUTURE EXTENSION — DROPDOWNS
==========================================================================

   Future navigation components can be added here:

   .nav-dropdown
   .nav-dropdown-toggle
   .nav-dropdown-menu
   .nav-dropdown-item

   Keep these out of header.css.

========================================================================== */


/* ==========================================================================
   12. FUTURE EXTENSION — SEARCH
==========================================================================

   If Clunky eventually gets site search:

   .nav-search
   .nav-search-toggle
   .nav-search-panel

   belongs here.

========================================================================== */


/* ==========================================================================
   13. DARK MODE
========================================================================== */

@media (prefers-color-scheme: dark) {

  .nav-link {
    color: var(
      --color-text-muted-dark,
      #94a3b8
    );
  }


  .nav-link:hover,
  .nav-link[aria-current="page"] {
    color: var(
      --color-heading-dark,
      #f8fafc
    );

    background: var(
      --color-surface-subtle-dark,
      #172033
    );
  }


  .nav-toggle {
    border-color: var(
      --color-border-dark,
      #273449
    );

    background: var(
      --color-surface-dark,
      #0f172a
    );

    color: var(
      --color-heading-dark,
      #f8fafc
    );
  }


  .site-nav {
    background: var(
      --color-surface-dark,
      #0f172a
    );

    border-bottom-color: var(
      --color-border-dark,
      #273449
    );
  }

}


/* ==========================================================================
   14. REDUCED MOTION
========================================================================== */

@media (prefers-reduced-motion: reduce) {

  .nav-link,
  .nav-toggle-line,
  .site-nav {
    transition: none;
  }

}