/* Responsive Breakpoint Adjustments */

/* Devices below 1024px (Mobiles and Tablets) */
@media (max-width: 1023px) {
  .header-container {
    height: 70px;
    padding-left: 15px;
    padding-right: 15px;
  }

  /* Header Actions Container */
  .header-actions {
    display: flex !important;
    align-items: center;
    gap: 12px;
    margin-left: auto;
  }

  /* Scale down logo on mobile to fix pixelation on high-DPI screens */
  .header-logo-img {
    max-width: 140px !important;
    height: auto !important;
  }

  /* Hide header contact text on mobile */
  .header-contact-text {
    display: none !important;
  }

  /* Hamburger Menu Toggle Button */
  .menu-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px;
    margin: 0;
    z-index: 10001;
    box-sizing: border-box;
    flex-shrink: 0;
  }

  .menu-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background-color: #003b71;
    border-radius: 2px;
    margin: 3px 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
  }

  /* Hamburger transform when menu is active */
  .menu-toggle.is-active span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
  }

  .menu-toggle.is-active span:nth-child(2) {
    opacity: 0;
  }

  .menu-toggle.is-active span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
  }

  /* Mobile Navigation Drawer - Slide in from the RIGHT starting at top 0 */
  .main-navigation {
    position: fixed;
    top: 0;
    right: -100%;
    left: auto;
    width: 320px;
    max-width: 85vw;
    height: 100vh;
    background-color: #ffffff;
    box-shadow: -4px 0 25px rgba(0, 0, 0, 0.2);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100000;
    overflow-y: auto;
    padding: 0;
    display: block;
    box-sizing: border-box;
  }

  .main-navigation.is-active {
    right: 0;
    left: auto;
  }

  /* Mobile Drawer Header */
  .mobile-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background-color: #003b71;
    color: #ffffff;
    position: sticky;
    top: 0;
    z-index: 10;
    width: 100%;
    box-sizing: border-box;
  }

  .mobile-nav-title {
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #ffffff;
    margin: 0;
  }

  .mobile-nav-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #ffffff;
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
  }

  .mobile-nav-close:hover {
    background-color: rgba(255, 255, 255, 0.35);
  }

  /* Mobile Menu List */
  #primary-menu-list,
  .nav-menu {
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
    gap: 0;
    padding: 16px 0;
    box-sizing: border-box;
  }

  #primary-menu-list li,
  .nav-menu li {
    width: 100%;
    padding: 0 15px;
    border-bottom: 1px solid #e2e8f0;
    box-sizing: border-box;
  }

  .nav-menu li:last-child {
    border-bottom: none;
  }

  /* Align link text on LEFT and dropdown toggle button on RIGHT side of the same row */
  .nav-menu li.menu-item-has-children {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    width: 100%;
  }

  .nav-menu li a {
    display: block;
    width: 100%;
    padding: 14px 0;
    font-size: 15px;
    font-weight: 600;
    color: #0f2d4a;
    text-decoration: none;
    border-bottom: none !important;
  }

  .nav-menu li.menu-item-has-children > a {
    flex: 1;
    width: auto;
  }

  .nav-menu li a::after {
    display: none !important;
  }

  /* Dropdown Toggle Button aligned side-by-side with text */
  .dropdown-toggle-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    cursor: pointer;
    margin-left: auto;
    flex-shrink: 0;
    color: #003b71;
  }

  .dropdown-toggle-btn .arrow {
    display: inline-block;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid currentColor;
    transition: transform 0.2s ease;
  }

  /* Mobile Submenu */
  .nav-menu .sub-menu {
    flex-basis: 100%;
    width: 100%;
    position: static;
    display: none;
    box-shadow: none;
    border: none;
    padding: 0 0 10px 16px;
    background-color: transparent;
    box-sizing: border-box;
  }

  .nav-menu .sub-menu li {
    border-bottom: none;
  }

  .nav-menu .sub-menu a {
    font-size: 14px;
    font-weight: 400;
    color: #475569;
    padding: 8px 0;
  }

  .nav-menu li.is-open > .sub-menu {
    display: block;
  }

  /* Grid adaptations */
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4 {
    grid-template-columns: 1fr;
  }

  h2, .h2 {
    font-size: 28px;
    line-height: 38px;
  }
}

/* Devices 1024px and above (Desktop) */
@media (min-width: 1024px) {
  .menu-toggle {
    display: none !important;
  }

  .mobile-nav-header {
    display: none !important;
  }

  .main-navigation {
    position: static;
    width: auto;
    height: auto;
    background: transparent;
    box-shadow: none;
    display: flex;
  }

  .nav-menu {
    flex-direction: row;
    align-items: center;
    padding: 0;
    gap: var(--space-md);
  }

  .nav-menu li {
    width: auto;
    padding: 0;
    border-bottom: none;
  }

  .nav-menu li.menu-item-has-children {
    display: inline-flex;
    align-items: center;
  }

  .nav-menu .menu-item-has-children > a {
    display: inline-flex;
    align-items: center;
    padding-right: 0;
  }

  .nav-menu .menu-item-has-children > a::after {
    display: none !important;
  }

  /* Display the exact same dropdown toggle button icon as mobile on desktop */
  .dropdown-toggle-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    margin: 0 0 0 4px;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    outline: none !important;
    cursor: pointer;
    color: currentColor;
    vertical-align: middle;
  }

  .dropdown-toggle-btn .arrow {
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    transition: transform 0.2s ease;
    opacity: 0.85;
  }

  .nav-menu .menu-item-has-children:hover .dropdown-toggle-btn .arrow,
  .nav-menu .menu-item-has-children.is-open .dropdown-toggle-btn .arrow {
    transform: rotate(180deg);
  }

  /* Desktop Dropdown Submenu Scroll Constraint */
  .nav-menu .sub-menu {
    max-height: 350px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
  }

  .nav-menu .sub-menu::-webkit-scrollbar {
    width: 6px;
  }

  .nav-menu .sub-menu::-webkit-scrollbar-track {
    background: transparent;
  }

  .nav-menu .sub-menu::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 3px;
  }

  .site-content {
    padding-top: var(--space-xl);
    padding-bottom: var(--space-xxl);
  }
}

/* Focus outline optimizations for touch devices */
@media (hover: none) {
  *:focus {
    outline: none;
  }
  *:focus-visible {
    outline: 3px solid var(--secondary-color);
    outline-offset: 3px;
  }
}
