/* ==========================================================================
   NAVIGATION BAR STYLES
   ========================================================================== */

:root {
  --nav-bg: #ffffff;
  --nav-text: #2d3748;
  --nav-accent: #2563eb;
  --nav-border: #e2e8f0;
  --nav-height-large: 90px;
  --nav-height-small: 56px;
  --img-size-large: 70px;
  --img-size-small: 36px;
}

/* Sticky top bar container */
.main-nav {
  position: sticky;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--nav-height-large);
  background-color: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
  z-index: 1000;
  transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
}

.main-nav.scrolled {
  height: var(--nav-height-small);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.nav-container {
  max-width: 1200px;
  height: 100%;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Brand Area Container */
.nav-brand {
  display: flex;
  align-items: center;
  height: 100%;       /* Fill full navbar height */
  text-decoration: none;
  padding: 4px 0;
}

/* Logo Image - Spans full height of the header */
.brand-img {
  height: calc(var(--nav-height-large, 90px) - 12px); /* Spans full height minus padding */
  width: auto;                                        /* Keeps natural aspect ratio */
  max-width: 250px;                                   /* Optional limit so it doesn't crowd menu links */
  object-fit: contain;
  transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Shrink image smoothy when scrolled */
.main-nav.scrolled .brand-img {
  height: calc(var(--nav-height-small, 56px) - 10px);
}

/* Hide full site title on small scrolled bar if space is tight */
@media (max-width: 480px) {
  .main-nav.scrolled .brand-text {
    display: none;
  }
}

/* Nav Menu List */
.nav-menu {
  display: flex;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 1.5rem;
}

.nav-item {
  position: relative;
}

.nav-link {
  text-decoration: none;
  color: var(--nav-text);
  font-weight: 500;
  font-size: 0.95rem;
  padding: 8px 12px;
  border-radius: 6px;
  transition: color 0.2s, background-color 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link:hover,
.nav-link.active {
  color: var(--nav-accent);
  background-color: #f1f5f9;
}

.arrow {
  font-size: 0.75rem;
  transition: transform 0.2s ease;
}

/* ==========================================================================
   LEVEL 2 DROPDOWN MENU (Desktop)
   ========================================================================== */

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 200px;
  background-color: #ffffff;
  border: 1px solid var(--nav-border);
  border-radius: 8px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  padding: 8px 0;
  list-style: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

/* Reveal dropdown on hover (Desktop) */
@media (min-width: 769px) {
  .has-dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .has-dropdown:hover .arrow {
    transform: rotate(180deg);
  }
}

.dropdown-item {
  display: block;
  padding: 8px 16px;
  text-decoration: none;
  color: var(--nav-text);
  font-size: 0.9rem;
  transition: background-color 0.2s, color 0.2s;
}

.dropdown-item:hover {
  background-color: #f8fafc;
  color: var(--nav-accent);
}

/* Hamburger Button */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}

.hamburger {
  display: block;
  width: 24px;
  height: 2px;
  background-color: var(--nav-text);
  position: relative;
  transition: background-color 0.2s;
}

.hamburger::before,
.hamburger::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 2px;
  background-color: var(--nav-text);
  left: 0;
  transition: transform 0.2s;
}

.hamburger::before { top: -6px; }
.hamburger::after { top: 6px; }

/* ==========================================================================
   MOBILE RESPONSIVENESS
   ========================================================================== */

@media (max-width: 768px) {

  /* 1. SHOW THE HAMBURGER BUTTON ON MOBILE (MISSING PIECE!) */
  .nav-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 1001;
  }

  /* 2. ENSURE HAMBURGER LINES ARE VISIBLE */
  .hamburger,
  .hamburger::before,
  .hamburger::after {
    display: block;
    width: 24px;
    height: 2px;
    background-color: var(--nav-text, #2d3748); /* Fallback color */
    position: relative;
    transition: transform 0.2s ease, background-color 0.2s ease;
  }

  .hamburger::before,
  .hamburger::after {
    content: '';
    position: absolute;
    left: 0;
  }

  .hamburger::before { top: -7px; }
  .hamburger::after { top: 7px; }

  /* 3. Hide menu by default on mobile */
  .nav-menu {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: var(--nav-bg, #ffffff);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    border-bottom: 1px solid var(--nav-border, #e2e8f0);
    
    /* Animation setup */
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: max-height 0.35s ease-in-out, opacity 0.25s ease, visibility 0.25s ease;
  }

  /* SHOW MENU when 'is-open' class is added by JS */
  .nav-menu.is-open {
    max-height: 800px; /* High enough to fit all 12+ links */
    opacity: 1;
    visibility: visible;
    overflow-y: auto; /* Enable scrolling if menu exceeds mobile screen */
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
  }

  .nav-item {
    width: 100%;
    border-top: 1px solid #f1f5f9;
  }

  .nav-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    width: 100%;
    color: var(--nav-text, #2d3748);
  }

  /* Submenu items on mobile */
  .dropdown-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: none;
    background-color: #f8fafc;
    display: none; /* Hidden until parent has .open */
    padding: 0;
  }

  .has-dropdown.open .dropdown-menu {
    display: block;
  }
}