/**
 * Site Header Block Styles
 * Pixel-perfect replica of coveredbridges.com header
 * 
 * @package Bridges
 */

/* ==========================================================================
   SITE HEADER STYLES
   ========================================================================== */

:root {
  /* Dynamic header height variables for responsive positioning */
  --header-height-small: 100px;
  --header-height-large: 128px;
  --header-height-tablet: 150px;
  --header-height-desktop: 183px;
  --header-height-large-desktop: 140px;
  /* Default current height - will be overridden by responsive breakpoints */
  --header-height-current: var(--header-height-large);
}

/* ==========================================================================
   CRITICAL CSS - Above the fold styles
   ========================================================================== */

/* WordPress Block Override - Ensure header is not constrained by block containers */
.wp-block-group .site-header,
.wp-block-group .wp-block-bridges-site-header,
.alignfull .site-header,
.alignfull .wp-block-bridges-site-header {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  max-width: 100vw !important;
  margin: 0 !important;
  z-index: 1000 !important;
}



.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  width: 100%;
  border-bottom: 1px solid #e0e0e0;
  font-family: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI",
    Roboto, sans-serif;
  font-size: 15px;
  font-weight: 400;
  color: #292929;
  /* Ensure header stays within viewport */
  max-width: 100vw;
  overflow-x: hidden;
  overflow-y: visible;
  /* Prevent creating containing block for fixed positioned children */
  /* Removed transform, filter, and perspective to avoid containing block issues */
}

/* Prevent body scroll when mobile menu is open */
body.mobile-menu-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100vh;
}

/* Header Inner Container */
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 0 4vw;
  height: 128px;
  position: relative;
  gap: 15px;
  /* Prevent horizontal overflow but allow vertical for mobile menu */
  overflow-x: hidden;
  overflow-y: visible;
}

/* Logo Section */
.header-logo {
  flex-shrink: 0;
  z-index: 2;
}

.logo-link {
  display: inline-block;
  text-decoration: none;
  line-height: 0;
}

.site-logo {
  width: 149px;
  height: 88px;
  object-fit: contain;
  display: block;
}

.site-title {
  font-size: 24px;
  font-weight: 700;
  color: #292929;
  text-decoration: none;
}

/* ==========================================================================
   DESKTOP NAVIGATION
   ========================================================================== */

.header-nav {
  display: none;
  flex: 0 1 auto;
  text-align: right;
  padding-left: 21.6px;
  max-width: 60%;
}

.nav-menu {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.header-nav-item {
  position: relative;
}

.nav-link {
  display: block;
  color: #292929;
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
  padding: 15px 0;
  transition: color 0.3s ease;
  white-space: nowrap;
}

.nav-link:hover,
.nav-link:focus {
  color: #b82330;
  outline: none;
}

/* Dropdown Menus */
.header-nav-item--folder .nav-link::after {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid #292929;
  margin-left: 8px;
  vertical-align: middle;
  transition: transform 0.3s ease;
}

.header-nav-item--folder:hover .nav-link::after {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  list-style: none;
  margin: 0;
  padding: 8px 0;
  min-width: 200px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  z-index: 100;
}

.header-nav-item--folder:hover .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  margin: 0;
}

.dropdown-link {
  display: block;
  padding: 12px 20px;
  color: #292929;
  text-decoration: none;
  font-size: 14px;
  transition: background-color 0.2s ease;
}

.dropdown-link:hover,
.dropdown-link:focus {
  background-color: #f5f5f5;
  color: #b82330;
}

/* ==========================================================================
   CTA BUTTON
   ========================================================================== */

.header-cta {
  flex-shrink: 0;
}

.cta-button {
  display: inline-block;
  background-color: #b82330;
  color: #ffffff;
  text-decoration: none;
  font-size: 13.56px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 15px;
  border: 0;
  border-radius: 0;
  text-align: center;
  line-height: 1;
  transition: all 0.3s ease;
  white-space: nowrap;
  cursor: pointer;
}

.cta-button:hover,
.cta-button:focus {
  background-color: #a01e2a;
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(184, 35, 48, 0.3);
}

/* ==========================================================================
   MOBILE MENU TOGGLE
   ========================================================================== */

.mobile-menu-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  padding: 10px;
  cursor: pointer;
  color: #292929;
  font-family: inherit;
  font-size: 14px;
  z-index: 3;
}

.hamburger {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 28px;
}

.top-bun,
.patty,
.bottom-bun {
  height: 2px;
  background-color: #292929;
  transition: all 0.3s ease;
}

.mobile-menu-toggle[aria-expanded="true"] .top-bun {
  transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle[aria-expanded="true"] .patty {
  opacity: 0;
}

.mobile-menu-toggle[aria-expanded="true"] .bottom-bun {
  transform: rotate(-45deg) translate(7px, -6px);
}

.menu-text {
  font-size: 12px;
  font-weight: 500;
}

.close-text {
  display: none;
}

.mobile-menu-toggle[aria-expanded="true"] .open-text {
  display: none;
}

.mobile-menu-toggle[aria-expanded="true"] .close-text {
  display: inline;
}

/* ==========================================================================
   MOBILE NAVIGATION
   ========================================================================== */

/* Mobile Navigation - Simple Full Screen Overlay */
.mobile-nav {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: #ffffff;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  z-index: 999999; /* Extremely high z-index */
  padding-top: 120px; /* Space for header */
}

/* Prevent body scroll when mobile menu is open */
body.mobile-menu-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

.mobile-nav.active {
  transform: translateX(0);
}

.mobile-menu {
  list-style: none;
  margin: 0;
  padding: 20px;
}

.mobile-nav-item {
  border-bottom: 1px solid #eee;
}

.mobile-nav-link {
  display: block;
  padding: 15px 0;
  color: #333;
  text-decoration: none;
  font-size: 18px;
}

.mobile-nav-link:hover {
  color: #b82330;
}

/* Mobile Overlay - Hidden since we're using full screen nav */
.mobile-overlay {
  display: none;
}

.mobile-nav-item {
  border-bottom: 1px solid #f0f0f0;
}

.mobile-nav-link {
  display: block;
  padding: 15px 20px;
  color: #292929;
  text-decoration: none;
  font-size: 16px;
  font-weight: 600;
  transition: background-color 0.2s ease;
}

.mobile-nav-link:hover,
.mobile-nav-link:focus {
  background-color: #f5f5f5;
  color: #b82330;
}

.mobile-submenu {
  list-style: none;
  margin: 0;
  padding: 0;
  background-color: #f9f9f9;
}

.mobile-submenu-link {
  display: block;
  padding: 12px 40px;
  color: #666;
  text-decoration: none;
  font-size: 14px;
  transition: background-color 0.2s ease;
}

.mobile-submenu-link:hover,
.mobile-submenu-link:focus {
  background-color: #f0f0f0;
  color: #b82330;
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS
   ========================================================================== */

/* Mobile First - Base styles above are mobile */

/* Small Mobile */
@media (max-width: 374px) {
  :root {
    --header-height-current: var(--header-height-small);
  }

  .header-inner {
    height: var(--header-height-small);
    padding: 0 3vw;
  }

  .site-logo {
    width: 120px;
    height: 70px;
  }

  .cta-button {
    font-size: 12px;
    padding: 12px;
  }
}

/* Large Mobile */
@media (min-width: 375px) and (max-width: 767px) {
  :root {
    --header-height-current: var(--header-height-large);
  }

  .header-inner {
    height: var(--header-height-large);
  }

  .site-logo {
    width: 130px;
    height: 76px;
  }

  .mobile-nav {
    top: var(--header-height-large);
    max-height: calc(100vh - var(--header-height-large));
  }
}

/* Tablet */
@media (min-width: 768px) {
  :root {
    --header-height-current: var(--header-height-tablet);
  }

  .mobile-menu-toggle {
    display: none;
  }

  .header-nav {
    display: block;
  }

  .mobile-nav {
    display: none;
  }

  .header-inner {
    height: var(--header-height-tablet);
    padding: 0 3vw;
  }

  .site-logo {
    width: 140px;
    height: 82px;
  }

  .nav-menu {
    gap: 20px;
  }

  .cta-button {
    font-size: 13px;
    padding: 12px 15px;
  }
}

/* Desktop */
@media (min-width: 1024px) {
  :root {
    --header-height-current: var(--header-height-desktop);
  }

  .header-inner {
    height: var(--header-height-desktop);
    padding: 0 3.5vw;
  }

  .site-logo {
    width: 149px;
    height: 88px;
  }

  .nav-menu {
    gap: 30px;
  }

  .cta-button {
    font-size: 13.56px;
    padding: 15px;
  }
}

/* Large Desktop */
@media (min-width: 1200px) {
  .header-inner {
    /* Removed max-width to allow full width header */
  }
}

/* Large Desktop (1440px+) */
@media (min-width: 1440px) {
  :root {
    --header-height-current: var(--header-height-large-desktop);
  }

  .header-inner {
    padding: 0 3.5vw;
    max-width: 1600px;
    margin: 0 auto;
  }

  .site-logo img {
    height: 60px;
  }

  .mobile-nav {
    top: var(--header-height-large-desktop);
    max-height: calc(100vh - var(--header-height-large-desktop));
  }

  .cta-button {
    padding: 12px 24px;
    font-size: 16px;
  }
}

/* Hide CTA on Mobile */
@media (max-width: 767px) {
  .header-cta {
    display: none;
  }

  .header-inner {
    justify-content: center;
  }

  .mobile-menu-toggle {
    position: absolute;
    right: 3.5vw;
    left: auto;
  }

  .mobile-menu-toggle .menu-text {
    display: none;
  }
}

/* ==========================================================================
   ACCESSIBILITY & FOCUS STATES
   ========================================================================== */

.nav-link:focus,
.cta-button:focus,
.mobile-nav-link:focus,
.dropdown-link:focus {
  outline: 2px solid #b82330;
  outline-offset: 2px;
}

.mobile-menu-toggle:focus {
  outline: 2px solid #b82330;
  outline-offset: 2px;
  border-radius: 4px;
}

/* ==========================================================================
   PERFORMANCE OPTIMIZATIONS
   ========================================================================== */

/* GPU acceleration for animations */
.dropdown-menu,
.mobile-nav,
.hamburger span {
  will-change: transform;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  .nav-link,
  .cta-button,
  .dropdown-menu,
  .mobile-nav,
  .hamburger span {
    transition: none;
  }
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
  .site-header {
    position: static;
    box-shadow: none;
    border-bottom: 1px solid #000;
  }

  .mobile-menu-toggle,
  .mobile-nav,
  .dropdown-menu {
    display: none;
  }

  .header-nav {
    display: block;
  }

  .nav-link {
    color: #000;
  }
}
