/* ============================================================
   BrainX Header — final mobile-safe version
   ============================================================ */

:root {
  --header-height: 84px;
  --header-mobile-height: 68px;
  --header-small-height: 58px;
  --header-red: var(--red, #e14b3a);
  --header-ink: var(--ink, #0b0d14);
  --header-text: var(--charcoal, #3d4350);
  --header-line: var(--line, #e8eaf0);
  --header-white: #ffffff;
  --header-ease: cubic-bezier(0.16, 1, 0.3, 1);
}

body {
  padding-top: var(--header-height);
}

body.nav-open {
  overflow: hidden;
}

/* Header */

.site-header {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 1000;
  width: 100%;
  background: rgba(251, 250, 249, 0.96);
  border-bottom: 1px solid var(--header-line);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.site-header.scrolled {
  background: rgba(255, 255, 255, 0.99);
  box-shadow: 0 10px 28px -18px rgba(23, 24, 28, 0.35);
}

.header-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-height);
  gap: 16px;
}

/* Logo */

.brand {
  position: relative;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}

.brand-logo {
  display: block;
  width: auto;
  height: 40px;
  max-width: 180px;
  object-fit: contain;
}

/* Desktop navigation */

.main-nav {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: center;
}

.nav-container {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.nav-list {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-list > li {
  position: relative;
}

.nav-list > li > a,
.dropdown-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 42px;
  padding: 10px 16px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--header-text);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.nav-list > li > a:hover,
.nav-list > li > a.active,
.dropdown-toggle:hover,
.dropdown-toggle.active,
.active-parent > .dropdown-toggle {
  color: var(--header-red);
  background: rgba(225, 75, 58, 0.08);
}

.nav-list > li > a.active::after,
.dropdown-toggle.active::after,
.active-parent > .dropdown-toggle::after {
  content: "";
  position: absolute;
  right: 16px;
  bottom: 4px;
  left: 16px;
  height: 2px;
  border-radius: 999px;
  background: var(--header-red);
}

.chev {
  flex: 0 0 auto;
  transition: transform 0.22s ease;
}

.has-dropdown:hover > .dropdown-toggle .chev,
.has-dropdown:focus-within > .dropdown-toggle .chev,
.has-dropdown.dropdown-open > .dropdown-toggle .chev {
  transform: rotate(180deg);
}

/* Desktop dropdown */

.dropdown-menu {
  position: absolute;
  top: calc(100% + 12px);
  left: 50%;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 330px;
  margin: 0;
  padding: 10px;
  list-style: none;
  border: 1px solid var(--header-line);
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 24px 55px -22px rgba(23, 24, 28, 0.35);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-50%) translateY(8px);
  transition:
    opacity 0.22s ease,
    visibility 0.22s ease,
    transform 0.22s ease;
}
.dropdown-menu::before {
  content: "";
  position: absolute;
  top: -12px;
  left: 0;
  right: 0;
  height: 12px;
  background: transparent;
}
.has-dropdown:hover > .dropdown-menu,
.has-dropdown:focus-within > .dropdown-menu,
.has-dropdown.dropdown-open > .dropdown-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.dropdown-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--header-ink);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
}

.dropdown-menu a::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: rgba(225, 75, 58, 0.25);
}

.dropdown-menu a:hover {
  color: var(--header-red);
  background: rgba(225, 75, 58, 0.08);
}

.dropdown-menu a:hover::before {
  background: var(--header-red);
}

/* CTA */

.nav-cta {
  position: relative;
  z-index: 5;
  flex: 0 0 auto;
  padding: 12px 22px;
  white-space: nowrap;
}

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

/* Hamburger */

.menu-toggle {
  position: relative;
  z-index: 30;
  display: none;
  flex: 0 0 44px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 12px;
  background: #ffffff;
  color: var(--header-ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.menu-toggle span {
  display: block;
  width: 24px;
  height: 2.5px;
  border-radius: 999px;
  background: currentColor;
  transform-origin: center;
  transition:
    transform 0.25s ease,
    opacity 0.2s ease;
}

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

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

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

/* Backdrop is BELOW the fixed header. */

.mobile-nav-backdrop {
  position: fixed;
  z-index: 998;
  inset: 0;
  display: none;
  background: rgba(10, 10, 15, 0.5);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.25s ease,
    visibility 0.25s ease;
}

.mobile-nav-backdrop.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Tablet and mobile */

@media (max-width: 1024px) {
  body {
    padding-top: var(--header-mobile-height);
  }

  .site-header {
    overflow: visible;
  }

  .header-inner {
    min-height: var(--header-mobile-height);
    gap: 10px;
  }

  .brand-logo {
    height: 32px;
    max-width: 150px;
  }

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

  .menu-toggle {
    display: flex;
  }

  .mobile-nav-backdrop {
    display: block;
  }

  /*
    Important fix:
    The menu is absolute below the header, not fixed inside
    a backdrop-filter stacking context.
  */
  .main-nav {
    position: absolute;
    top: calc(100% + 1px);
    right: 12px;
    left: 12px;
    z-index: 25;
    display: block;
    width: auto;
    max-height: calc(100dvh - var(--header-mobile-height) - 18px);
    padding: 10px;
    border: 1px solid rgba(23, 24, 28, 0.09);
    border-radius: 0 0 20px 20px;
    background: #ffffff;
    box-shadow: 0 26px 60px -28px rgba(23, 24, 28, 0.5);
    overflow-x: hidden;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-12px);
    transition:
      opacity 0.24s ease,
      visibility 0.24s ease,
      transform 0.24s ease;
  }

  .main-nav.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
  }

  .nav-container {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: 100%;
  }

  .nav-list {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 7px;
    width: 100%;
  }

  .nav-list > li {
    position: static;
    width: 100%;
  }

  .nav-list > li > a,
  .dropdown-toggle {
    width: 100%;
    min-height: 46px;
    padding: 11px 14px;
    border: 1px solid rgba(23, 24, 28, 0.07);
    border-radius: 13px;
    background: #ffffff;
    color: var(--header-text);
    font-size: 14px;
    font-weight: 700;
    text-align: left;
    white-space: normal;
    justify-content: flex-start;
  }

  .dropdown-toggle {
    justify-content: space-between;
  }

  .nav-list > li > a.active::after,
  .dropdown-toggle.active::after,
  .active-parent > .dropdown-toggle::after {
    display: none;
  }

  /*
    Do not allow hover/focus rules to force the dropdown open on mobile.
  */
  .has-dropdown:hover > .dropdown-menu,
  .has-dropdown:focus-within > .dropdown-menu {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
  }

  .has-dropdown:hover > .dropdown-toggle .chev,
  .has-dropdown:focus-within > .dropdown-toggle .chev {
    transform: none;
  }

  .has-dropdown.dropdown-open > .dropdown-toggle .chev {
    transform: rotate(180deg);
  }

  .dropdown-menu {
    position: static;
    display: none;
    width: 100%;
    margin: 7px 0 0;
    padding: 8px;
    border: 0;
    border-radius: 14px;
    background: #f7f7f9;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
  }

  .has-dropdown.dropdown-open > .dropdown-menu {
    display: flex;
  }

  .dropdown-menu a {
    min-height: 40px;
    padding: 9px 11px;
    border-radius: 10px;
    background: #ffffff;
    font-size: 13px;
  }

  .mobile-nav-cta {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 48px;
    margin-top: 2px;
    padding: 13px 18px;
    border-radius: 14px;
  }
}

/* Small mobile */

@media (max-width: 560px) {
  body {
    padding-top: var(--header-small-height);
  }

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

  .brand-logo {
    height: 26px;
    max-width: 126px;
  }

  .menu-toggle {
    flex-basis: 38px;
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

  .menu-toggle span {
    width: 20px;
    height: 2px;
  }

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

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

  .main-nav {
    right: 8px;
    left: 8px;
    max-height: calc(100dvh - var(--header-small-height) - 12px);
    padding: 8px;
    border-radius: 0 0 17px 17px;
  }

  .nav-list {
    gap: 6px;
  }

  .nav-list > li > a,
  .dropdown-toggle {
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 11px;
    font-size: 13px;
  }

  .dropdown-menu a {
    min-height: 38px;
    font-size: 12.5px;
  }

  .mobile-nav-cta {
    min-height: 44px;
    font-size: 13px;
  }
}

/* Desktop reset */

@media (min-width: 1025px) {
  .menu-toggle,
  .mobile-nav-cta,
  .mobile-nav-backdrop {
    display: none !important;
  }

  .main-nav {
    position: static;
    width: auto;
    max-height: none;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    overflow: visible;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
  }

  body.nav-open {
    overflow: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .main-nav,
  .mobile-nav-backdrop,
  .dropdown-menu,
  .chev,
  .menu-toggle span {
    transition: none !important;
  }
}
/* ============================================================
   SERVICES PAGE LINK + SEPARATE DROPDOWN BUTTON
   ============================================================ */

.services-nav-control {
  display: flex;
  align-items: center;
  border-radius: 10px;
}

.services-page-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 10px 8px 10px 16px;
  border-radius: 10px 0 0 10px;
  color: var(--header-text, #3d4350);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}

.services-arrow-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  min-height: 42px;
  padding: 0;
  border: 0;
  border-radius: 0 10px 10px 0;
  color: var(--header-text, #3d4350);
  background: transparent;
  cursor: pointer;
}

.services-nav-control:hover,
.has-dropdown.active-parent .services-nav-control {
  background: rgba(225, 75, 58, 0.08);
}

.services-nav-control:hover .services-page-link,
.services-nav-control:hover .services-arrow-toggle,
.services-page-link.active,
.has-dropdown.active-parent .services-page-link,
.has-dropdown.active-parent .services-arrow-toggle {
  color: var(--header-red, #e14b3a);
}

.services-page-link.active::after {
  content: "";
  position: absolute;
  right: 8px;
  bottom: 4px;
  left: 16px;
  height: 2px;
  border-radius: 999px;
  background: var(--header-red, #e14b3a);
}

.services-arrow-toggle .chev {
  transition: transform 0.22s ease;
}

.has-dropdown:hover .services-arrow-toggle .chev,
.has-dropdown.dropdown-open .services-arrow-toggle .chev {
  transform: rotate(180deg);
}

@media (max-width: 1024px) {
  .services-nav-control {
    width: 100%;
    min-height: 46px;
    border: 1px solid rgba(23, 24, 28, 0.07);
    border-radius: 13px;
    background: #ffffff;
  }

  .services-page-link {
    flex: 1 1 auto;
    min-width: 0;
    min-height: 46px;
    padding: 11px 14px;
    border-radius: 13px 0 0 13px;
    font-size: 14px;
    font-weight: 700;
    white-space: normal;
  }

  .services-arrow-toggle {
    flex: 0 0 46px;
    width: 46px;
    min-height: 46px;
    border-left: 1px solid rgba(23, 24, 28, 0.07);
    border-radius: 0 13px 13px 0;
  }

  .services-nav-control:hover,
  .has-dropdown.active-parent .services-nav-control {
    border-color: rgba(225, 75, 58, 0.16);
    background: rgba(225, 75, 58, 0.1);
  }

  .services-page-link.active::after {
    display: none;
  }

  .has-dropdown:hover .services-arrow-toggle .chev {
    transform: none;
  }

  .has-dropdown.dropdown-open .services-arrow-toggle .chev {
    transform: rotate(180deg);
  }
}

@media (max-width: 560px) {
  .services-nav-control,
  .services-page-link,
  .services-arrow-toggle {
    min-height: 42px;
  }

  .services-page-link {
    padding: 10px 12px;
    font-size: 13px;
  }

  .services-arrow-toggle {
    flex-basis: 42px;
    width: 42px;
  }
}
