/* 
 * LeanPress Navigation Styles
 * Dedicated stylesheet for navigation components
 * Optimized for transparent header usage across all pages
 */

:root {
  /* Navigation-specific variables */
  --nav-header-height: 80px;
  --nav-item-gap: 2rem;
  --nav-font-size: 1.2rem;
  --nav-font-weight: 600;
  --nav-shine-shadow: 0 0 10px #fff;
  --mobile-nav-bg: #1F1F1F;
  --mobile-menu-padding: 1rem;
  --nav-breakpoint: 1040px; /* New breakpoint for mobile navigation */
}

/* 
 * Header Components
 */

/* Transparent header */
.site-header {
  padding: 0.5rem 0;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background-color: transparent;
  z-index: 100;
  width: 100%;
}

/* Header layout */
.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: var(--site-width);
  margin: 0 auto;
  padding: 0 1rem;
  height: var(--nav-header-height);
}

/* Header sections */
.header-left,
.header-right,
.primary-nav {
  display: flex;
  align-items: center;
}

.header-left {
  gap: 2.2rem;
}

.header-right {
  gap: 0.5rem;
  padding-top: 6px;
}

@media (max-width: 1040px) {
  .header-right {
    padding-top: 0;
  }
}

.primary-nav {
  position: relative;
}

/* Logo */
.logo {
  font-weight: 700;
  font-size: 1.5rem;
  color: #ffffff;
  text-decoration: none;
  display: flex;
  align-items: center;
  transition: all 0.3s ease;
}

.logo-img {
  height: 46px;
  width: 180px;
  display: block;
  /* Explicit dimensions for Core Web Vitals */
}

/* Logo responsive sizing - only change on very small screens */
@media (max-width: 1040px) {
  .logo {
    flex-shrink: 0; /* Prevent logo container from shrinking */
  }
  
  .logo-img {
    height: 38px; /* Explicit height at 1040px breakpoint */
    width: 170px; /* Maintain width */
  }
}

/* Search toggle hover effect */
.search-toggle:hover svg {
  filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.3));
}

/* Header button styles now handled by the unified button system */

/* Top level menu */
.menu {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
  justify-content: flex-start;
}

.menu > li {
  position: relative;
  margin-left: var(--nav-item-gap);
}

.menu > li:first-child {
  margin-left: 0;
}

.menu > li > a {
  display: flex;
  align-items: center;
  height: var(--nav-header-height);
  padding: 0;
  color: var(--c-fg);
  text-decoration: none;
  font-weight: var(--nav-font-weight);
  font-size: var(--nav-font-size);
  letter-spacing: 0.01em;
  /* Remove transition to prevent state persistence */
}

/* Menu item colors and hover effects */
.menu > li > a,
.menu > li.current-menu-item > a,
.menu > li.current-menu-parent > a {
  color: #ffffff;
}

/* Menu links hover effect */
.menu > li > a:hover,
.menu > li.current-menu-item > a:hover,
.menu > li.current-menu-parent > a:hover {
  color: var(--c-accent);
}

/* 
 * Dropdown navigation system
 * With fixes for submenu persistence
 */

/* Base submenu styles */
.menu .sub-menu {
  position: absolute;
  top: calc(100% - 15px); /* Reduce gap between parent and dropdown */
  left: 0;
  z-index: 100;
  min-width: 200px;
  padding: 0.5rem 0;
  margin: 0;
  list-style: none;
  background-color: var(--mobile-nav-bg); /* Dark background for better visibility with white text */
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
  display: none;
}

/* Submenu indicator */
.menu-item-has-children > a::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 0.5rem;
  margin-top: -2px;
  vertical-align: middle;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(315deg);
}

/* Force reset of menu item states */
.menu-item-has-children {
  pointer-events: auto !important;
}

/* Submenu item styles */
.menu .sub-menu li {
  padding: 0;
  margin: 0;
}

.menu .sub-menu a {
  display: block;
  padding: 0.5rem 1.5rem;
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  font-size: 1.05rem;
}

/* Submenu item colors and hover effects */
.menu .sub-menu a,
.menu .sub-menu .current-menu-item > a {
  color: rgba(255, 255, 255, 0.9);
}

.menu .sub-menu a:hover,
.menu .sub-menu .current-menu-item > a:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--c-accent);
}



/* Desktop styles - these apply when viewport is wider than 960px */
@media (min-width: 1041px) {
  /* Ensure proper positioning for dropdown menus */
  .menu-item-has-children {
    position: relative;
  }
  
  /* Hide mobile menu toggle on desktop */
  .menu-toggle {
    display: none !important;
  }
  
  /* Ensure desktop menu is always displayed */
  .primary-nav .menu {
    display: flex !important;
    position: static;
    background: transparent;
    width: auto;
    flex-direction: row;
    padding-top: 6px;
    box-shadow: none;
    border: none;
  }
}

/* Show submenu when parent has open class (all viewports) */
.menu-item-has-children.open > .sub-menu {
  display: block;
}

/* Mobile-specific submenu behavior */
@media (max-width: 1040px) {
  .menu .sub-menu {
    position: static;
    width: 100%;
    box-shadow: none;
    border: none;
    border-radius: 0;
    padding: 0.25rem 1rem;
    margin: 0.5rem 0;
    background-color: rgba(255, 255, 255, 0.05);
    border-left: 2px solid rgba(255, 255, 255, 0.2);
  }
  
  /* Ensure submenu links have proper padding on mobile */
  .menu .sub-menu a {
    padding: 0.75rem 1rem;
  }
}

/* Search toggle */
.search-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: #ffffff !important;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease;
}

/* Hide search toggle on small mobile screens */
@media (max-width: 480px) {
  .header-right .header-search,
  .search-toggle,
  button.search-toggle {
    display: none !important;
  }
}

/* Search icon sizing and thickness */
.search-toggle svg {
  width: 22px;
  height: 22px;
  stroke-width: 2.5;
  stroke: #ffffff !important;
}

/* Header button styles now handled by the unified button system in main.css */

/* Mobile menu toggle */
.menu-toggle {
  margin-right: -0.25rem;
  display: none; /* Hidden by default, shown in mobile media query */
  background: none;
  border: none;
  cursor: pointer;
  color: #ffffff;
  z-index: 101; /* Ensure it's above other elements */
  align-items: center;
}

/* Hamburger icon */
.hamburger {
  display: inline-block;
  width: 26px;
  height: 18px;
  position: relative;
}

.hamburger span {
  display: block;
  position: absolute;
  height: 2px;
  width: 100%;
  background: #ffffff; /* White hamburger lines for dark background */
  border-radius: 2px;
  opacity: 1;
  left: 0;
  transform: rotate(0deg);
  transition: .25s ease-in-out;
}

.hamburger span:nth-child(1) {
  top: 0px;
}

.hamburger span:nth-child(2),
.hamburger span:nth-child(3) {
  top: 8px;
}

.hamburger span:nth-child(4) {
  top: 16px;
}

/* Hamburger animation */
.menu-toggle[aria-expanded="true"] .hamburger span:nth-child(1),
.menu-toggle[aria-expanded="true"] .hamburger span:nth-child(4) {
  top: 8px;
  width: 0%;
  left: 50%;
}

.menu-toggle[aria-expanded="true"] .hamburger span:nth-child(2) {
  transform: rotate(45deg);
}

.menu-toggle[aria-expanded="true"] .hamburger span:nth-child(3) {
  transform: rotate(-45deg);
}

/* Hide text but keep it accessible */
.menu-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Responsive styles */
@media (max-width: 1040px) {
  .header-inner {
    position: relative;
    justify-content: space-between;
  }
  
  /* Keep logo on the left */
  .header-left {
    gap: 0; /* Remove gap between logo and nav on mobile */
    flex-shrink: 0;
    flex-basis: auto; /* Allow logo to take its natural width */
  }
  
  /* Rearrange header-right elements for mobile */
  .header-right {
    gap: 0.25rem; /* Tighter gap between elements */
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }
  
  /* Order elements: hamburger (rightmost), search, button (leftmost) */
  .menu-toggle {
    order: 3; /* Hamburger on the far right */
  }
  
  .header-search {
    order: 2; /* Search icon in the middle */
  }
  
  /* Button to the left of search icon */
  .header-button {
    order: 1; /* Button on the left of the controls */
    /* Styling now handled by unified button system in main.css */
    /* Use .btn.btn--on-black.btn--sm for header buttons */
  }
  
  /* Primary navigation on mobile */
  .primary-nav {
    position: static;
    order: -1; /* Move to beginning of flex container */
  }
  
  /* Show menu toggle on mobile */
  .menu-toggle {
    display: flex;
  }
  
  /* Show search icon on mobile and rearrange elements */
  .search-toggle {
    display: flex;
  }
  
  /* Hide desktop menu and set up mobile menu */
  .menu {
    display: none;
    position: absolute;
    box-sizing: border-box;
    top: 100%;
    left: 0;
    right: 0;
    width: 100%;
    flex-direction: column;
    background: var(--mobile-nav-bg);
    padding: var(--mobile-menu-padding);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    z-index: 100;
  }
  
  /* Menu open state */
  .menu.open {
    display: flex;
  }
  
  .menu > li {
    margin: 0 0 0.5rem;
  }
  
  .menu > li:last-child {
    margin-bottom: 0;
  }
  
  /* Adjust mobile menu links height and padding */
  .menu > li > a,
  .menu > li.current-menu-item > a,
  .menu > li.current-menu-parent > a {
    height: auto;
    padding: 0.5rem 0;
  }
  
  /* Mobile submenu */
  .menu .sub-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: none;
    background: transparent;
    border-left: 2px solid var(--c-accent);
    margin-left: 1rem;
    padding: 0.25rem 0.5rem 0.25rem 1rem;
    min-width: auto;
    display: none;
  }
  
  /* Adjust submenu links hover effect on mobile */
  .menu .sub-menu a:hover,
  .menu .sub-menu .current-menu-item > a:hover {
    background-color: transparent;
    color: var(--c-accent);
  }
  
  .menu .menu-item-has-children.open > .sub-menu {
    display: block;
  }
  
  /* Mobile-specific indicator properties */
  .menu .menu-item-has-children > a::after {
    margin-top: 2px;
    transition: transform 0.2s ease;
    transform: rotate(222deg);
  }
  
  .menu .menu-item-has-children.open > a::after {
    transform: rotate(315deg);
  }
  
  /* Mobile search styles */
  .mobile-search {
    margin: 1rem 0;
    width: 100%;
  }
  
  .mobile-search-form {
    display: flex;
    width: 100%;
    position: relative;
  }
  
  .mobile-search-input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 0.95rem;
    box-sizing: border-box; /* Ensure padding is included in width calculation */
  }
  
  .mobile-search-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
  }
  
  .mobile-search-submit {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: #fff;
  }
  
  .mobile-search-submit svg {
    width: 18px;
    height: 18px;
    stroke-width: 2.5;
    stroke: rgba(255, 255, 255, 0.8);
  }
}

/* Small screen button styles are now handled by the unified button system in main.css */
/* Use .btn.btn--on-black.btn--sm for header buttons on all screen sizes */
