/* ==========================================================================
   Dr. Midhun Physiotherapy — Unified Responsive Navigation System
   
   Breakpoints:
     - Desktop: min-width 1024px (Horizontal nav with hover/click dropdowns)
     - Tablet:  768px – 1023px   (Logo + Book CTA + Hamburger, Flow-based dropdown)
     - Mobile:  max-width 767px  (Logo + Animated Hamburger, Flow-based dropdown)

   Key Architectural Guarantees:
     1. Flow-Based Mobile Navigation: Occupies document layout space inside
        the sticky header; smoothly pushes the hero section downward without
        any overlap or clipping.
     2. Stacking Context (Z-Index Specification):
        - Main Header:     z-index: 1000
        - Mobile Dropdown: z-index: 1001
        - Desktop Menu:    z-index: 1001
        - Hero Section:    normal document stacking
     3. 100% Opaque Background: Clean white (#ffffff) ensures zero bleed-through.
     4. Zero Horizontal Overflow: html, body constrained to 100vw.
   ========================================================================== */

:root {
  --nav-height-desktop: 76px;
  --nav-height-tablet: 70px;
  --nav-height-mobile: 66px;
  --nav-z-header: 1000;
  --nav-z-dropdown: 1001;
  --nav-z-mobile-panel: 1001;
  --nav-teal-900: #102a43;
  --nav-teal-700: #1a4d6e;
  --nav-teal-600: #2a698f;
  --nav-teal-100: #e8f1f5;
  --nav-slate: #486581;
  --nav-coral: #fb7185;
  --nav-coral-hover: #f43f5e;
  --nav-border: rgba(40, 85, 122, 0.12);
  --nav-shadow-sm: 0 2px 8px rgba(16, 42, 67, 0.05);
  --nav-shadow-md: 0 10px 25px -3px rgba(16, 42, 67, 0.10), 0 4px 6px -2px rgba(16, 42, 67, 0.05);
}

/* Guarantee zero horizontal page overflow */
html,
body {
  overflow-x: hidden;
  max-width: 100vw;
}

/* --------------------------------------------------------------------------
   Header & Wrapper
   -------------------------------------------------------------------------- */
header.site-header {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  z-index: var(--nav-z-header);
  background: #ffffff;
  border-bottom: 1px solid var(--nav-border);
  box-shadow: var(--nav-shadow-sm);
  transition: box-shadow 0.2s ease;
}

.site-header .nav-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  height: var(--nav-height-desktop);
  position: relative;
  box-sizing: border-box;
}

/* Logo */
.site-header .logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--nav-teal-900);
  text-decoration: none;
  flex-shrink: 0;
  z-index: 2;
}

.site-header .logo-mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--nav-teal-700), var(--nav-teal-600));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 3px 8px rgba(26, 77, 110, 0.25);
}

.site-header .logo-text {
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Desktop Navigation (min-width: 1024px)
   -------------------------------------------------------------------------- */
.desktop-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.desktop-link,
.desktop-dropdown-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 13px;
  color: var(--nav-slate);
  font-size: 0.93rem;
  font-weight: 500;
  text-decoration: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.18s ease, background-color 0.18s ease;
  white-space: nowrap;
  font-family: inherit;
  line-height: 1.4;
}

.desktop-link:hover,
.desktop-dropdown-btn:hover,
.desktop-link:focus-visible,
.desktop-dropdown-btn:focus-visible {
  color: var(--nav-teal-700);
  background-color: var(--nav-teal-100);
  outline: none;
}

.desktop-link.active,
.nav-dropdown-item.is-open > .desktop-dropdown-btn {
  color: var(--nav-teal-700);
  font-weight: 600;
}

/* Dropdown Container */
.nav-dropdown-item {
  position: relative;
}

/* Dropdown Chevron */
.dropdown-chevron {
  display: inline-block;
  transition: transform 180ms cubic-bezier(0.4, 0, 0.2, 1);
  color: currentColor;
  opacity: 0.75;
  flex-shrink: 0;
}

.nav-dropdown-item:hover .dropdown-chevron,
.nav-dropdown-item.is-open .dropdown-chevron,
.desktop-dropdown-btn[aria-expanded="true"] .dropdown-chevron {
  transform: rotate(180deg);
}

/* Dropdown Menu Box */
.desktop-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 240px;
  background: #ffffff;
  border: 1px solid var(--nav-border);
  border-radius: 10px;
  box-shadow: var(--nav-shadow-md);
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: var(--nav-z-dropdown);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 180ms cubic-bezier(0.4, 0, 0.2, 1),
              transform 180ms cubic-bezier(0.4, 0, 0.2, 1),
              visibility 180ms;
}

/* Invisible hover bridge to eliminate pointer gap */
.nav-dropdown-item::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 12px;
  background: transparent;
}

/* Show Dropdown on Hover or Open class */
.nav-dropdown-item:hover .desktop-dropdown-menu,
.nav-dropdown-item:focus-within .desktop-dropdown-menu,
.nav-dropdown-item.is-open .desktop-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

/* Dropdown Submenu Links */
.desktop-dropdown-menu .dropdown-item {
  display: block;
  padding: 9px 14px;
  color: var(--nav-teal-900);
  font-size: 0.90rem;
  font-weight: 500;
  text-decoration: none;
  border-radius: 6px;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
  line-height: 1.35;
}

.desktop-dropdown-menu .dropdown-item:hover,
.desktop-dropdown-menu .dropdown-item:focus-visible {
  background-color: var(--nav-teal-100);
  color: var(--nav-teal-700);
  outline: none;
  transform: translateX(2px);
}

.desktop-dropdown-menu .dropdown-item.active {
  background-color: var(--nav-teal-100);
  color: var(--nav-teal-700);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Header Actions & CTA Buttons
   -------------------------------------------------------------------------- */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  z-index: 2;
}

.header-call-btn {
  display: none !important;
}

.header-book-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  font-size: 0.90rem;
  font-weight: 600;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--nav-coral), var(--nav-coral-hover));
  color: #ffffff !important;
  text-decoration: none !important;
  box-shadow: 0 4px 14px rgba(251, 113, 133, 0.35);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  white-space: nowrap;
}

.header-book-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(251, 113, 133, 0.45);
}

.header-book-btn:focus-visible {
  outline: 2px solid var(--nav-coral);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Three-Line Animated Hamburger Button
   Area: >= 44x44px. Icon: 24px.
   -------------------------------------------------------------------------- */
.nav-hamburger {
  display: none; /* Desktop default: hidden */
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  box-sizing: border-box;
  transition: background-color 0.2s ease, border-color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.nav-hamburger:hover {
  background-color: var(--nav-teal-100);
  border-color: rgba(40, 85, 122, 0.15);
}

.nav-hamburger:focus-visible {
  outline: 2px solid var(--nav-teal-700);
  outline-offset: 2px;
}

.hamburger-box {
  width: 24px;
  height: 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
}

.hamburger-line {
  display: block;
  width: 24px;
  height: 2.2px;
  background-color: var(--nav-teal-900);
  border-radius: 2px;
  transition: transform 220ms cubic-bezier(0.4, 0, 0.2, 1),
              opacity 200ms ease,
              background-color 200ms ease;
  transform-origin: center;
}

/* Animated Open State: Transforms cleanly into an X */
.nav-hamburger.is-active .line-top {
  transform: translateY(8px) rotate(45deg);
}

.nav-hamburger.is-active .line-middle {
  opacity: 0;
  transform: scaleX(0);
}

.nav-hamburger.is-active .line-bottom {
  transform: translateY(-8px) rotate(-45deg);
}

/* --------------------------------------------------------------------------
   FLOW-BASED MOBILE NAVIGATION PANEL
   Occupies document layout space inside <header>, smoothly pushing the
   hero section downward when expanded. Zero overlap guaranteed!
   -------------------------------------------------------------------------- */
.mobile-nav-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 260ms cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  z-index: var(--nav-z-mobile-panel);
  background: #ffffff;
  width: 100%;
  box-sizing: border-box;
  border-top: 1px solid transparent;
}

.mobile-nav-panel.is-open {
  grid-template-rows: 1fr;
  border-top-color: var(--nav-border);
  box-shadow: 0 16px 28px rgba(16, 42, 67, 0.08);
}

.mobile-nav-inner {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 0 20px;
  transition: padding 260ms cubic-bezier(0.4, 0, 0.2, 1);
  box-sizing: border-box;
}

.mobile-nav-panel.is-open .mobile-nav-inner {
  padding: 16px 20px 24px;
  max-height: calc(100dvh - var(--nav-height-mobile));
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Mobile Menu Items List */
.mobile-menu-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
}

.mobile-menu-item {
  width: 100%;
}

.mobile-link,
.mobile-accordion-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 44px;
  padding: 11px 14px;
  color: var(--nav-teal-900);
  font-size: 0.98rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 10px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: background-color 0.18s ease, color 0.18s ease;
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
}

.mobile-link:hover,
.mobile-accordion-btn:hover,
.mobile-link:focus-visible,
.mobile-accordion-btn:focus-visible,
.mobile-link.active {
  background: var(--nav-teal-100);
  color: var(--nav-teal-700);
}

.mobile-link:focus-visible,
.mobile-accordion-btn:focus-visible {
  outline: 2px solid var(--nav-teal-700);
  outline-offset: -2px;
}

/* Accordion Chevron */
.accordion-chevron {
  transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1);
  color: var(--nav-teal-700);
  flex-shrink: 0;
  opacity: 0.85;
}

.mobile-accordion-btn[aria-expanded="true"] .accordion-chevron {
  transform: rotate(180deg);
}

.mobile-accordion-btn[aria-expanded="true"] {
  background: rgba(40, 85, 122, 0.06);
  color: var(--nav-teal-700);
}

/* Accordion Panel (Smooth Grid Expansion) */
.mobile-accordion-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-accordion-panel.is-expanded {
  grid-template-rows: 1fr;
}

.mobile-sublinks-wrapper {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 0 6px 18px; /* 18px indentation for child items */
}

.mobile-sublink {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 12px;
  font-size: 0.90rem;
  font-weight: 500;
  color: var(--nav-slate);
  text-decoration: none;
  border-radius: 8px;
  border-left: 2px solid rgba(40, 85, 122, 0.15);
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  line-height: 1.35;
}

.mobile-sublink:hover,
.mobile-sublink:focus-visible,
.mobile-sublink.active {
  background: var(--nav-teal-100);
  color: var(--nav-teal-700);
  border-left-color: var(--nav-coral);
  transform: translateX(3px);
  outline: none;
}

/* Prominent Book Appointment CTA in Flow Panel */
.mobile-nav-cta {
  margin-top: 14px;
  width: 100%;
}

.mobile-book-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 13px 20px;
  font-size: 0.98rem;
  font-weight: 600;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--nav-coral), var(--nav-coral-hover));
  color: #ffffff !important;
  text-decoration: none !important;
  box-shadow: 0 6px 18px rgba(251, 113, 133, 0.38);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  box-sizing: border-box;
}

.mobile-book-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(251, 113, 133, 0.48);
}

.mobile-book-cta:focus-visible {
  outline: 2px solid var(--nav-coral);
  outline-offset: 2px;
}

/* Quick Contact Shortcuts Grid */
.mobile-shortcuts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
  padding-top: 14px;
  border-top: 1px solid var(--nav-border);
}

.mobile-shortcut-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 10px 6px;
  border-radius: 10px;
  background: var(--nav-teal-100);
  border: 1px solid rgba(40, 85, 122, 0.10);
  color: var(--nav-teal-900);
  text-decoration: none !important;
  transition: transform 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  min-height: 44px;
  box-sizing: border-box;
}

.mobile-shortcut-btn:hover {
  background: #ffffff;
  transform: translateY(-2px);
  box-shadow: var(--nav-shadow-sm);
}

.mobile-shortcut-btn:focus-visible {
  outline: 2px solid var(--nav-teal-700);
  outline-offset: 2px;
}

.mobile-shortcut-btn .shortcut-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.mobile-shortcut-btn .shortcut-text {
  font-size: 0.76rem;
  font-weight: 600;
  text-align: center;
}

.mobile-shortcut-btn.whatsapp {
  background: rgba(37, 211, 102, 0.12);
  color: #128c7e;
  border-color: rgba(37, 211, 102, 0.25);
}

.mobile-shortcut-btn.whatsapp:hover {
  background: #25d366;
  color: #ffffff;
}

/* --------------------------------------------------------------------------
   RESPONSIVE BREAKPOINTS
   Exact Breakpoints:
     - Desktop: min-width 1024px
     - Tablet:  768px – 1023px
     - Mobile:  max-width 767px
   -------------------------------------------------------------------------- */

/* TABLET (768px to 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
  .site-header .nav-wrap {
    height: var(--nav-height-tablet);
    padding: 0 20px;
  }

  .desktop-nav {
    display: none !important;
  }

  /* Compact Tablet Header: Logo on left, Book Appointment + Hamburger on right */
  .header-book-btn {
    display: inline-flex !important;
    padding: 9px 16px;
    font-size: 0.88rem;
  }

  .nav-hamburger {
    display: inline-flex !important;
  }

  .mobile-shortcuts-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* MOBILE (Below 768px: tested at 320, 360, 375, 390, 412, 414, 430px) */
@media (max-width: 767px) {
  .site-header .nav-wrap {
    height: var(--nav-height-mobile);
    padding: 0 16px;
  }

  .desktop-nav {
    display: none !important;
  }

  /* Header CTA hidden to avoid overcrowding mobile header; placed in mobile panel */
  .header-book-btn {
    display: none !important;
  }

  /* Only Hamburger icon on right */
  .nav-hamburger {
    display: inline-flex !important;
  }
}

/* DESKTOP (1024px and up) */
@media (min-width: 1024px) {
  .desktop-nav {
    display: flex !important;
  }

  .nav-hamburger {
    display: none !important;
  }

  .header-book-btn {
    display: inline-flex !important;
  }

  /* Completely remove mobile flow panel on desktop */
  .mobile-nav-panel {
    display: none !important;
  }
}

/* Ultra-compact desktop tweak for 1024px - 1160px */
@media (min-width: 1024px) and (max-width: 1180px) {
  .site-header .nav-wrap {
    padding: 0 12px;
  }

  .desktop-nav {
    gap: 1px;
  }

  .desktop-link,
  .desktop-dropdown-btn {
    padding: 6px 8px;
    font-size: 0.82rem;
    gap: 3px;
  }

  .header-book-btn {
    padding: 8px 12px;
    font-size: 0.82rem;
  }
}

/* --------------------------------------------------------------------------
   Accessibility & Reduced Motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
