/* =========================================================
   Greenleaf LTD — header.css
   Pairs with includes/header.html. Load on every page that
   includes the header fragment.
   ========================================================= */

.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  max-width: 1200px;
  height: 100%;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

/* --- Logo --- */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-mark {
  height: 52px;
  width: auto;
  flex-shrink: 0;
}

/* --- Nav --- */
.primary-nav {
  display: flex;
  align-items: center;
  gap: 32px;
}

.nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-head);
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--navy-700);
  padding: 6px 0;
}

.nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0%;
  height: 2px;
  background: var(--gold-600);
  transition: width 0.2s ease;
}

.nav-link:hover::after,
.nav-link:focus-visible::after {
  width: 100%;
}

/* --- "Our products" dropdown --- */
.nav-item.has-dropdown {
  position: relative;
}

.dropdown-toggle .caret {
  width: 8px;
  height: 8px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.15s ease;
}

.nav-item.has-dropdown.open .caret,
.nav-item.has-dropdown:hover .caret {
  transform: rotate(225deg) translateY(2px);
}

.dropdown-menu {
  position: absolute;
  /* Flush against the button — no gap for the mouse to fall through
     between here and the toggle above. Visual spacing comes from
     transparent padding-top below, which is still part of this
     element's hoverable box, so the hover state never drops while
     the cursor crosses it. */
  top: 100%;
  left: 0;
  padding-top: 14px;
  display: none;
  z-index: 50;
}

.nav-item.has-dropdown.open .dropdown-menu,
.nav-item.has-dropdown:hover .dropdown-menu,
.nav-item.has-dropdown:focus-within .dropdown-menu {
  display: block;
}

.dropdown-menu-inner {
  display: flex;
  flex-direction: column;
  min-width: 220px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  box-shadow: 0 16px 32px rgba(20, 36, 92, 0.10);
}

.dropdown-menu-inner a {
  padding: 10px 12px;
  border-radius: 6px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--navy-700);
}

.dropdown-menu-inner a:hover,
.dropdown-menu-inner a:focus-visible {
  background: var(--paper);
}

.header-cta {
  flex-shrink: 1;
  min-width: 0;
}
.header-cta .btn-cta {
  padding: 12px 22px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Mobile menu toggle --- */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
}

.menu-toggle span,
.menu-toggle span::before,
.menu-toggle span::after {
  content: "";
  display: block;
  width: 22px;
  height: 2px;
  background: var(--navy-900);
  position: relative;
}

.menu-toggle span::before { position: absolute; top: -7px; }
.menu-toggle span::after { position: absolute; top: 7px; }

@media (max-width: 860px) {
  .header-inner { gap: 12px; padding: 0 16px; }
  .brand-mark { height: 46px; }

  /* Swap to the shorter label so the button never has to fight the
     logo and hamburger for space (this is what was overflowing). */
  .header-cta .cta-full { display: none; }
  .header-cta .cta-short { display: inline; }
  .header-cta .btn-cta { padding: 10px 16px; font-size: 0.85rem; }

  .primary-nav {
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    background: var(--white);
    border-bottom: 1px solid var(--line);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 8px 24px 16px;
    display: none;
  }

  .primary-nav.open { display: flex; }

  .primary-nav > a,
  .nav-link {
    width: 100%;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
  }

  .primary-nav > a:last-child { border-bottom: none; }

  .nav-item.has-dropdown { border-bottom: 1px solid var(--line); }
  .nav-item.has-dropdown:last-child { border-bottom: none; }
  .nav-item.has-dropdown .nav-link { border-bottom: none; }

  /* On mobile the dropdown behaves as an inline accordion, not a floating panel */
  .dropdown-menu {
    position: static;
    display: none;
    padding: 0;
  }

  .nav-item.has-dropdown.open .dropdown-menu,
  .nav-item.has-dropdown:focus-within .dropdown-menu {
    display: block;
  }

  /* Hover-to-open makes no sense on touch; rely on the .open class from JS */
  .nav-item.has-dropdown:hover .dropdown-menu { display: none; }
  .nav-item.has-dropdown.open .dropdown-menu { display: block; }

  .dropdown-menu-inner {
    min-width: 0;
    box-shadow: none;
    border: none;
    border-radius: 0;
    padding: 0 0 8px 16px;
  }

  .dropdown-menu-inner a {
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
  }

  .dropdown-menu-inner a:last-child { border-bottom: none; }

  .menu-toggle { display: block; }
}
