/* ==========================================================================
   Direct Homes – Header
   Markup: includes/header.php
   Colors/fonts come from css/directhomes-theme.css (--dh-* variables).
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Layout: logo left | menu center | actions right
   -------------------------------------------------------------------------- */
#header .dh-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

#header .dh-header::before,
#header .dh-header::after {
  display: none; /* remove Bootstrap clearfix pseudo elements in the flex row */
}

.dh-header__logo,
.dh-header__actions {
  flex: 1 1 0;
  display: flex;
  align-items: center;
}

.dh-header__actions {
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 24px;
}

.dh-header__logo #logo {
  margin: 0;
}

/* Centered navigation */
#header .dh-header__nav {
  float: none;
  flex: 0 0 auto;
  margin: 0 !important;
}

#header .dh-header__nav ul#responsive {
  display: flex;
  align-items: center;
  margin: 0;
}

/* --------------------------------------------------------------------------
   1b. Navigation with a moving green glass pill (only on the active/hovered link)
   -------------------------------------------------------------------------- */
#header .dh-nav-pill {
  position: relative;
  gap: 4px;
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
}

#header .dh-nav-pill > li {
  float: none;
  position: relative;
  z-index: 1;
  margin: 0;
  border-radius: 999px;
  background: transparent !important;
}

#header .dh-nav-pill > li > a {
  display: block;
  padding: 9px 20px;
  line-height: 24px;
  border-radius: 999px;
  font-family: var(--dh-font-body);
  font-size: 15px;
  font-weight: 500;
  text-transform: none; /* keep "How It Works" casing */
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.85) !important;
  transition: color 0.25s ease;
}

#header .dh-nav-pill > li > a:hover,
#header .dh-nav-pill > li.is-active > a,
#header .dh-nav-pill > li.is-hovered > a {
  color: #fff !important;
}

#header .dh-nav-pill > li.is-active > a {
  font-weight: 600;
}

/* No dropdown arrows on the main links */
#header .dh-nav-pill > li > a::after {
  content: none !important;
}

/* The moving pill – brand green with a light glass finish.
   Same look in the normal and in the sticky header. */
#header .dh-nav-pill > li.dh-nav-indicator {
  position: absolute;
  z-index: 0;
  top: 0;
  left: 0;
  width: 0;
  height: 100%;
  padding: 0;
  pointer-events: none;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0) 55%),
    rgba(var(--dh-primary-rgb), 0.62) !important;
  border: 1px solid rgba(255, 255, 255, 0.30);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    0 6px 18px rgba(var(--dh-primary-rgb), 0.28);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  backdrop-filter: blur(10px) saturate(140%);
  opacity: 0;
  transition:
    left 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.25s ease;
}

#header .dh-nav-pill > li.dh-nav-indicator.is-visible {
  opacity: 1;
}

/* --------------------------------------------------------------------------
   1c. Sticky header – light frosted glass bar, same pill
   -------------------------------------------------------------------------- */
#header.cloned {
  background-color: rgba(var(--dh-bg-rgb), 0.78) !important;
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  backdrop-filter: blur(16px) saturate(160%);
  border-bottom: 1px solid rgba(var(--dh-primary-rgb), 0.08);
  box-shadow: 0 8px 30px rgba(var(--dh-primary-rgb), 0.08);
}

/* Inactive links readable on the light glass bar */
#header.cloned .dh-nav-pill > li > a {
  color: var(--dh-primary) !important;
}

/* Active / hovered link sits on the green pill → white text (same as top) */
#header.cloned .dh-nav-pill > li.is-active > a,
#header.cloned .dh-nav-pill > li.is-hovered > a,
#header.cloned .dh-nav-pill > li > a:hover {
  color: #fff !important;
}

/* While the pill is on another link, the active link goes back to green text */
#header.cloned .dh-nav-pill.is-hovering > li.is-active:not(.is-hovered) > a {
  color: var(--dh-primary) !important;
}

/* Indicator is not used inside the mobile menu */
.mm-menu .dh-nav-indicator,
.mmenu-init .dh-nav-indicator {
  display: none !important;
}

/* Items that only belong in the mobile menu */
#header .dh-header__nav .dh-mobile-only {
  display: none;
}

/* --------------------------------------------------------------------------
   2. Language switcher
   -------------------------------------------------------------------------- */
.dh-lang {
  position: relative;
}

.dh-lang__toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border: 0;
  background: transparent;
  color: #fff;
  font-family: var(--dh-font-body);
  font-size: 15px;
  cursor: pointer;
}

.dh-lang__toggle strong {
  font-weight: 600;
}

.dh-lang__caret {
  width: 7px;
  height: 7px;
  margin-left: 2px;
  margin-top: -3px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}

.dh-flag {
  display: inline-flex;
  line-height: 0;
}

.dh-flag svg {
  border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.dh-lang__menu {
  list-style: none;
  margin: 0;
  padding: 8px;
  min-width: 170px;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 999;
  background: #fff;
  border: 1px solid var(--dh-sand);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(var(--dh-primary-rgb), 0.15);
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: all 0.2s ease;
}

/* Invisible bridge so the menu stays open while moving the mouse into it */
.dh-lang__menu::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -12px;
  height: 12px;
}

.dh-lang:hover .dh-lang__menu,
.dh-lang:focus-within .dh-lang__menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dh-lang:hover .dh-lang__caret,
.dh-lang:focus-within .dh-lang__caret {
  transform: rotate(-135deg);
  margin-top: 3px;
}

.dh-lang__menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--dh-primary);
  font-family: var(--dh-font-body);
  font-size: 14px;
  text-decoration: none;
}

.dh-lang__menu a:hover,
.dh-lang__menu a.is-current {
  background: var(--dh-bg);
  color: var(--dh-primary);
}

.dh-lang__menu a.is-current {
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   3. Login button
   -------------------------------------------------------------------------- */
#header .dh-header__cta {
  position: static;
  top: auto;
  width: auto;
  float: none;
  padding: 0;
  margin: 0;
}

#header .dh-header__cta a.dh-btn-login {
  position: relative;     /* keeps the hover circle (dh-btn__fx) inside */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;              /* space between "Login" and the icon */
  height: 46px;
  min-width: 128px;
  margin: 0 !important;
  padding: 0 24px !important;
  line-height: 1;
  white-space: nowrap;
  text-align: center;
  font-family: var(--dh-font-body);
  font-size: 15px;
  font-weight: 600;
}

#header .dh-btn-login__text {
  display: inline-block;
  line-height: 1;
}

#header .dh-btn-login__icon {
  flex: none;
  display: block;
  margin: 0;
}

/* --------------------------------------------------------------------------
   4. Sticky (cloned) header – white bar, so switch text to brand green
   -------------------------------------------------------------------------- */
#header.cloned .dh-lang__toggle {
  color: var(--dh-primary);
}

#header.cloned.sticky .dh-flag svg {
  box-shadow: 0 0 0 1px rgba(var(--dh-primary-rgb), 0.2);
}

@media (max-width: 1024px) {
  #header .dh-header__logo #logo {
    position: static;
    width: auto;
    margin: 0;
    text-align: left;
  }

  #header .dh-header__nav #responsive {
    display: flex;
  }

  #header .dh-header .dh-menu-trigger {
    display: none !important;
  }

  #header .dh-header__cta {
    border-top: 0;
  }

  #header .dh-header__cta a.button.border.dh-btn-login {
    float: none;
    background-color: var(--dh-primary);
    color: #fff;
  }
}

/* Tighter menu spacing on small laptops */
@media (min-width: 992px) and (max-width: 1199px) {
  #header .dh-nav-pill > li > a {
    padding-left: 12px;
    padding-right: 12px;
    font-size: 14px;
  }
  .dh-header__actions {
    gap: 16px;
  }
}

/* --------------------------------------------------------------------------
   -------------------------------------------------------------------------- */
@media (max-width: 991px) {
  #header .dh-header__nav {
    display: none;
  }

  #header .dh-header .dh-menu-trigger {
    display: inline-block !important;
    margin: 0;
  }
}

@media (max-width: 767px) {
  .dh-header__actions {
    gap: 14px;
  }

  #header .dh-header__cta {
    display: none; /* Login is inside the mobile menu */
  }
}

/* Mobile menu (mmenu clones the navigation): show the mobile-only items */
.mmenu-init .dh-mobile-only,
.mm-menu .dh-mobile-only {
  display: block !important;
}

/* Sticky bar is light, so give the same glass pill a bit more green for contrast */
#header.cloned .dh-nav-pill > li.dh-nav-indicator {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22) 0%, rgba(255, 255, 255, 0) 55%),
    rgba(var(--dh-primary-rgb), 0.82) !important;
}

/* Language menu items: keep text readable on hover */
#header .dh-lang__menu li a,
#header .dh-lang__menu li a:hover,
#header .dh-lang__menu li a:focus,
#header.cloned .dh-lang__menu li a {
  color: var(--dh-primary) !important;
}

#header .dh-header__cta a.dh-btn-login,
#header .dh-header__cta a.dh-btn-login:hover,
#header .dh-header__cta a.dh-btn-login:focus {
  border-radius: 999px !important;
  box-shadow: none !important;
}

/* --------------------------------------------------------------------------
   Active link = underline (no pill) – normal and sticky header
   -------------------------------------------------------------------------- */
#header .dh-nav-pill > li.dh-nav-indicator,
#header.cloned .dh-nav-pill > li.dh-nav-indicator {
  display: none !important;
}

@media (min-width: 993px) {
  .dh-header-light #header:not(.cloned) .dh-nav-pill,
  #header .dh-nav-pill {
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
}

#header .dh-nav-pill > li > a {
  position: relative;
}

#header .dh-nav-pill > li > a::before {
  content: "";
  position: absolute;
  right: 18px;
  bottom: 6px;
  left: 18px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.3s ease;
}

#header .dh-nav-pill > li.is-active > a::before,
#header .dh-nav-pill > li > a:hover::before {
  transform: scaleX(1);
}

/* text keeps its normal colour (no white text on a green pill any more) */
#header.cloned .dh-nav-pill > li > a,
#header.cloned .dh-nav-pill > li.is-active > a,
#header.cloned .dh-nav-pill > li.is-hovered > a,
#header.cloned .dh-nav-pill > li > a:hover,
.dh-header-light #header:not(.cloned) .dh-nav-pill > li > a,
.dh-header-light #header:not(.cloned) .dh-nav-pill > li.is-active > a,
.dh-header-light #header:not(.cloned) .dh-nav-pill > li.is-hovered > a,
.dh-header-light #header:not(.cloned) .dh-nav-pill > li > a:hover {
  color: var(--dh-primary) !important;
}

#header:not(.cloned) .dh-nav-pill > li.is-active > a,
#header:not(.cloned) .dh-nav-pill > li.is-hovered > a {
  color: #fff;
}

/* mobile menu: no underline */
.mm-menu .dh-nav-pill > li > a::before {
  display: none;
}

/* --------------------------------------------------------------------------
   Logo image + mobile row: logo keeps its proportions and shrinks to the
   space left next to the language switch and the menu button, so the
   hamburger always stays inside the container

   -------------------------------------------------------------------------- */
#header .dh-header__logo #logo img {
  display: block;
  width: auto !important;
  max-width: 100%;
  height: 34px;
  margin: 0 !important;
  object-fit: contain;
  object-position: left center;
}

@media (max-width: 991px) {
  #header .dh-header {
    gap: 12px;
  }

  #header .dh-header__logo {
    flex: 1 1 auto;
    min-width: 0;
  }

  #header .dh-header__logo #logo,
  #header .dh-header__logo #logo a {
    display: block;
    min-width: 0;
    max-width: 100%;
  }

  #header .dh-header__logo #logo img {
    height: auto;
    max-height: 32px;
  }

  #header .dh-header__actions {
    flex: 0 0 auto;
    gap: 14px;
  }
}

@media (max-width: 400px) {
  #header .dh-header__actions {
    gap: 10px;
  }

  #header .dh-header__logo #logo img {
    max-height: 28px;
  }

  #header .dh-lang__toggle {
    gap: 6px;
  }

  #header .dh-menu-trigger .hamburger {
    width: 42px;
    height: 42px;
  }
}

/* --------------------------------------------------------------------------
   Tighter menu + slimmer Login button
   -------------------------------------------------------------------------- */
@media (min-width: 1200px) {
  #header .dh-nav-pill > li > a {
    padding-left: 14px;
    padding-right: 14px;
  }

  #header .dh-nav-pill > li > a::before {
    right: 14px;
    left: 14px;
  }
}

#header .dh-header__cta a.dh-btn-login {
  min-width: 0;
  height: 44px;
  padding: 0 20px !important;
  gap: 8px;
}

#header .dh-header__actions {
  gap: 18px;
}

/* --------------------------------------------------------------------------
   Search button (opens the filter modal #dhAdvancedSearch)
   -------------------------------------------------------------------------- */
#header .dh-search-btn {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(var(--dh-primary-rgb), 0.1);
  border-radius: 50%;
  background: transparent;
  color: var(--dh-primary);
  cursor: pointer;
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

#header .dh-search-btn svg {
  display: block;
  width: 22px;
  height: 22px;
  fill: none !important;
  stroke: currentColor;
  transition: transform 0.35s ease;
}

#header .dh-search-btn svg * {
  fill: none !important;
}

#header .dh-search-btn:hover,
#header .dh-search-btn:focus-visible {
  border-color: var(--dh-primary);
  background: var(--dh-primary);
  color: #fff;
}

#header .dh-search-btn:hover svg {
  transform: rotate(-12deg) scale(1.05);
}

/* number of active filters */
#header .dh-search-btn .dh-advanced-count {
  position: absolute;
  top: -4px;
  right: -4px;
  margin: 0;
}

@media (max-width: 400px) {
  #header .dh-search-btn {
    width: 40px;
    height: 40px;
  }
}

/* --------------------------------------------------------------------------
   Dark hero pages (body.dh-header-dark): white header on top of the photo,
   normal green header once it turns sticky
   -------------------------------------------------------------------------- */
.dh-header-dark #header:not(.cloned) {
  background: transparent !important;
}

.dh-header-dark #header:not(.cloned) #logo img {
  filter: brightness(0) invert(1);
}

.dh-header-dark #header:not(.cloned) .dh-nav-pill > li > a,
.dh-header-dark #header:not(.cloned) .dh-nav-pill > li.is-active > a,
.dh-header-dark #header:not(.cloned) .dh-lang__toggle,
.dh-header-dark #header:not(.cloned) .dh-search-btn {
  color: #fff !important;
}

.dh-header-dark #header:not(.cloned) .dh-search-btn {
  border-color: rgba(255, 255, 255, 0.28);
}

.dh-header-dark #header:not(.cloned) .dh-search-btn:hover {
  border-color: #fff;
  background: #fff;
  color: var(--dh-primary) !important;
}

.dh-header-dark #header:not(.cloned) .dh-header__cta a.dh-btn-login {
  background: #fff !important;
  border-color: #fff !important;
  color: var(--dh-primary) !important;
}

.dh-header-dark #header:not(.cloned) .dh-menu-trigger .hamburger {
  border-color: rgba(255, 255, 255, 0.45);
  background: rgba(255, 255, 255, 0.12);
}

.dh-header-dark #header:not(.cloned) .dh-menu-trigger .hamburger-inner,
.dh-header-dark #header:not(.cloned) .dh-menu-trigger .hamburger-inner::before,
.dh-header-dark #header:not(.cloned) .dh-menu-trigger .hamburger-inner::after {
  background-color: #fff !important;
}

/* --------------------------------------------------------------------------
   992–1199px: the logo keeps its size; menu, actions and Login get tighter
   -------------------------------------------------------------------------- */
@media (min-width: 992px) and (max-width: 1199px) {
  #header .dh-header {
    gap: 10px;
  }

  #header .dh-header__logo {
    flex: 0 0 auto;
  }

  #header .dh-header__logo #logo img {
    height: 26px;
    max-width: none;
  }

  #header .dh-header__actions {
    flex: 0 0 auto;
    gap: 20px;
  }

  #header .dh-nav-pill > li > a {
    padding-right: 7px;
    padding-left: 7px;
    font-size: 14px;
  }

  #header .dh-nav-pill > li > a::before {
    right: 7px;
    left: 7px;
  }

  #header .dh-header__cta a.dh-btn-login {
    height: 42px;
    padding: 0 14px !important;
  }

  #header .dh-btn-login__icon {
    /* display: none; */
  }

  #header .dh-search-btn {
    width: 40px;
    height: 40px;
  }
}

/* --------------------------------------------------------------------------
   Fixed header (one header, no copy): stays at the top of the screen.
   At the top of the page it keeps its normal look; once the page is
   scrolled (body.dh-header-scrolled, js/directhomes-header.js) the whole
   bar turns into light frosted glass with green text.
   "#header-container #header" beats the page specific header colours.
   -------------------------------------------------------------------------- */
#header-container {
  position: fixed !important;
  top: 0;
  right: 0;
  left: 0;
  z-index: 99999;
}

#header-container #header {
  border-bottom: 1px solid transparent;
  transition: background-color 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

body.dh-header-scrolled #header-container #header {
  background-color: rgba(var(--dh-bg-rgb), 0.78) !important;
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  backdrop-filter: blur(16px) saturate(160%);
  border-bottom-color: rgba(var(--dh-primary-rgb), 0.08);
  box-shadow: 0 8px 30px rgba(var(--dh-primary-rgb), 0.08);
}

body.dh-header-scrolled #header-container #header #logo img {
  filter: none;
}

body.dh-header-scrolled #header-container #header .dh-nav-pill > li > a,
body.dh-header-scrolled #header-container #header .dh-nav-pill > li.is-active > a,
body.dh-header-scrolled #header-container #header .dh-nav-pill > li.is-hovered > a,
body.dh-header-scrolled #header-container #header .dh-nav-pill > li > a:hover,
body.dh-header-scrolled #header-container #header .dh-lang__toggle,
body.dh-header-scrolled #header-container #header .dh-search-btn {
  color: var(--dh-primary) !important;
}

body.dh-header-scrolled #header-container #header .dh-search-btn {
  border-color: var(--dh-sand);
}

/* hover: green circle with a white icon (the icon must not disappear) */
body.dh-header-scrolled #header-container #header .dh-search-btn:hover,
body.dh-header-scrolled #header-container #header .dh-search-btn:focus-visible {
  border-color: var(--dh-primary);
  background: var(--dh-primary);
  color: #fff !important;
}

body.dh-header-scrolled #header-container #header .dh-header__cta a.dh-btn-login {
  background: var(--dh-primary) !important;
  border-color: var(--dh-primary) !important;
  color: #fff !important;
}

body.dh-header-scrolled #header-container #header .dh-menu-trigger .hamburger {
  border-color: var(--dh-sand);
  background: #fff;
}

body.dh-header-scrolled #header-container #header .dh-menu-trigger .hamburger-inner,
body.dh-header-scrolled #header-container #header .dh-menu-trigger .hamburger-inner::before,
body.dh-header-scrolled #header-container #header .dh-menu-trigger .hamburger-inner::after {
  background-color: var(--dh-primary) !important;
}

@media (prefers-reduced-motion: reduce) {
  #header-container #header {
    transition: none;
  }
}
