/*
 * ECAR Header.
 *
 * The .ecar-btn component moved to global.css — the header, hero,
 * why-choose-us and pricing-promise sections all use it, so it no longer
 * belongs to one section's stylesheet.
 *
 * Interactive color note: every hover in here used to resolve to navy, which
 * on a near-black bar meant hovering made text darker and less readable.
 * Hover now goes to the accent (bone) or to white.
 */

.ecar-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background-color: rgba(10, 10, 10, 0.9);
  border-bottom: 1px solid var(--ecar-hairline);
  transition: background-color var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.ecar-header.is-scrolled {
  background-color: var(--ecar-bg);
  border-bottom-color: var(--ecar-border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* .ecar-shell supplies max-width + fluid gutter; this only owns the row. */
.ecar-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-row-h);
  gap: 32px;
}

/* --- Logo + service-area link --- */
.ecar-header__brand {
  display: flex;
  align-items: center;
  min-width: 0;
  flex-shrink: 0;
  z-index: 1001;
}

.ecar-header__logo {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.ecar-header__logo img,
.ecar-header__logo .custom-logo {
  display: block;
  max-height: 44px;
  max-width: 220px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.ecar-header__logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1;
}

.ecar-header__logo-title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: 0.1em;
  color: var(--ecar-text-primary);
}

.ecar-header__logo-subtitle {
  font-size: 0.5625rem;
  letter-spacing: 0.24em;
  color: var(--ecar-text-secondary);
  text-transform: uppercase;
  margin-top: 4px;
}

.ecar-header__location {
  display: grid;
  grid-template-columns: minmax(18px, auto) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin-left: 24px;
  padding-left: 24px;
  border-left: 1px solid var(--ecar-border);
  color: var(--ecar-text-primary);
}

.ecar-header__location-icon {
  display: inline-flex;
  width: 20px;
  height: 20px;
  align-items: center;
  justify-content: center;
  flex: 0 0 20px;
}

.ecar-header__location-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ecar-header__location-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.12;
}

.ecar-header__location-kicker {
  color: var(--ecar-text-muted);
  font-size: 0.625rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.ecar-header__location-title {
  margin-top: 3px;
  color: var(--ecar-text-primary);
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transition: color var(--transition);
}

.ecar-header__location:hover .ecar-header__location-title,
.ecar-header__location:focus-visible .ecar-header__location-title {
  color: var(--ecar-accent);
}

/* --- Nav wrapper (nav + actions) --- */
.ecar-header__nav-wrapper {
  display: flex;
  align-items: center;
  gap: 36px;
  flex: 1;
  justify-content: flex-end;
}

.ecar-header__nav-list {
  display: flex;
  align-items: center;
  list-style: none;
  gap: 28px;
  margin: 0;
  padding: 0;
}

.ecar-header__nav-list li {
  display: flex;
}

.ecar-header__nav-list a {
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ecar-text-secondary);
  padding: 6px 0;
  position: relative;
  transition: color var(--transition);
}

.ecar-header__nav-list a::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 0;
  height: 1px;
  background-color: var(--ecar-accent);
  transition: width var(--transition);
}

.ecar-header__nav-list a:hover,
.ecar-header__nav-list a:focus-visible,
.ecar-header__nav-list .current-menu-item > a {
  color: var(--ecar-text-primary);
}

.ecar-header__nav-list a:hover::after,
.ecar-header__nav-list a:focus-visible::after,
.ecar-header__nav-list .current-menu-item > a::after {
  width: 100%;
}

/* --- Dropdown submenus ---
   WordPress nests a child <ul class="sub-menu"> straight into the parent
   <li> for any menu item given children in Appearance > Menus (e.g. the
   6 individual service pages under a "Services" parent) — with no CSS at
   all that would render as an unstyled list flowing inline into the bar.
   Desktop: an absolutely-positioned panel revealed on hover/focus. The
   caret only marks items that actually have one (.menu-item-has-children,
   also added by core). */
.ecar-header__nav-list li {
  position: relative;
}

.ecar-header__nav-list .menu-item-has-children > a {
  padding-right: 16px;
}

.ecar-header__nav-list .menu-item-has-children > a::before {
  content: '';
  position: absolute;
  right: 0;
  top: 45%;
  width: 6px;
  height: 6px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  opacity: 0.7;
  transform: translateY(-50%) rotate(45deg);
  transition: transform var(--transition);
}

.ecar-header__nav-list .menu-item-has-children:hover > a::before,
.ecar-header__nav-list .menu-item-has-children:focus-within > a::before {
  transform: translateY(-25%) rotate(225deg);
}

.ecar-header__nav-list .sub-menu {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 10;
  min-width: 232px;
  margin: 0;
  padding: 8px;
  list-style: none;
  background-color: var(--ecar-bg);
  border: 1px solid var(--ecar-border);
  border-radius: var(--r-md);
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity var(--transition), transform var(--transition), visibility var(--transition);
}

.ecar-header__nav-list .menu-item-has-children:hover > .sub-menu,
.ecar-header__nav-list .menu-item-has-children:focus-within > .sub-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Added by main.js beside a parent link. Hidden on desktop because hover and
   keyboard focus already operate the dropdown there; on touch layouts it
   becomes a proper, separately labelled accordion control. */
.ecar-header__submenu-toggle {
  display: none;
}

.ecar-header__nav-list .sub-menu li {
  display: block;
}

.ecar-header__nav-list .sub-menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  text-transform: none;
  letter-spacing: 0.01em;
}

.ecar-header__menu-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  color: var(--ecar-text-secondary);
}

.ecar-header__menu-icon-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* The built-in appliance marks render as inline SVG rather than an <img>, so
   they need their own sizing — and the gold they carry in the services list,
   which is also what stops a service with no uploaded icon from looking like
   a broken row next to one that has a photographic icon. */
.ecar-header__menu-icon svg {
  width: 20px;
  height: 20px;
  color: var(--ecar-gold);
}

.ecar-header__menu-label {
  min-width: 0;
}

.ecar-header__nav-list .sub-menu a::after {
  display: none;
}

.ecar-header__nav-list .sub-menu a:hover,
.ecar-header__nav-list .sub-menu a:focus-visible {
  background-color: var(--ecar-surface);
  color: var(--ecar-text-primary);
}

/* --- Actions: phone + CTA --- */
.ecar-header__actions {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-shrink: 0;
}

.ecar-header__phone {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding-left: 22px;
  border-left: 1px solid var(--ecar-border);
}

.ecar-header__phone-icon {
  display: inline-flex;
  width: 17px;
  height: 17px;
  color: var(--ecar-text-muted);
  flex-shrink: 0;
  transition: color var(--transition);
}

.ecar-header__phone-icon svg {
  width: 100%;
  height: 100%;
}

.ecar-header__phone-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.ecar-header__phone-number {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--ecar-text-primary);
  transition: color var(--transition);
}

.ecar-header__phone:hover .ecar-header__phone-number,
.ecar-header__phone:focus-visible .ecar-header__phone-number,
.ecar-header__phone:hover .ecar-header__phone-icon,
.ecar-header__phone:focus-visible .ecar-header__phone-icon {
  color: var(--ecar-accent);
}

.ecar-header__phone-label {
  font-size: 0.625rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ecar-text-muted);
}

/* --- Mobile menu toggle --- */
.ecar-header__menu-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  width: 32px;
  height: 22px;
  position: relative;
  z-index: 1001;
  padding: 0;
  color: var(--ecar-text-primary);
}

.ecar-header__hamburger-line {
  display: block;
  width: 100%;
  height: 2px;
  background-color: currentColor;
  position: absolute;
  left: 0;
  transition: transform var(--transition), opacity var(--transition), top var(--transition);
}

.ecar-header__hamburger-line:nth-child(1) { top: 0; }
.ecar-header__hamburger-line:nth-child(2) { top: 50%; transform: translateY(-50%); }
.ecar-header__hamburger-line:nth-child(3) { bottom: 0; }

.ecar-header__menu-toggle[aria-expanded="true"] .ecar-header__hamburger-line:nth-child(1) {
  top: 50%;
  transform: translateY(-50%) rotate(45deg);
}

.ecar-header__menu-toggle[aria-expanded="true"] .ecar-header__hamburger-line:nth-child(2) {
  opacity: 0;
}

.ecar-header__menu-toggle[aria-expanded="true"] .ecar-header__hamburger-line:nth-child(3) {
  bottom: 50%;
  transform: translateY(50%) rotate(-45deg);
}

/* --- Responsive --- */

/* Intermediate desktop carries logo + location + nav + phone + CTA in one
   row. Things drop out in order of redundancy: the location kicker first
   (the city name alone still does the job), then the phone label. */
@media (max-width: 1199px) {
  .ecar-header__inner {
    gap: 24px;
  }

  .ecar-header__location {
    margin-left: 18px;
    padding-left: 18px;
  }

  .ecar-header__location-kicker {
    display: none;
  }

  .ecar-header__location-title {
    margin-top: 0;
  }

  .ecar-header__nav-wrapper {
    gap: 26px;
  }

  .ecar-header__nav-list {
    gap: 20px;
  }

  .ecar-header__phone-label {
    display: none;
  }
}

@media (max-width: 1023px) {
  .ecar-header__location-kicker {
    display: inline;
  }

  .ecar-header__location-title {
    margin-top: 3px;
  }

  .ecar-header__nav-wrapper {
    position: fixed;
    inset: var(--header-h) 0 0 0;
    background-color: var(--ecar-bg);
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    gap: 0;
    padding: 10px var(--gutter) max(28px, env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    transform: translateY(-8px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--transition), transform var(--transition), visibility var(--transition);
  }

  .ecar-header__nav-wrapper.is-active {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .ecar-header__nav {
    width: 100%;
    max-width: 620px;
    margin-inline: auto;
  }

  .ecar-header__nav-list {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    width: 100%;
  }

  .ecar-header__nav-list > li {
    display: block;
    width: 100%;
    border-bottom: 1px solid var(--ecar-hairline);
  }

  .ecar-header__nav-list > li > a {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 54px;
    padding: 14px 4px;
    font-size: var(--fs-body);
    line-height: 1.25;
  }

  .ecar-header__nav-list a::after {
    display: none;
  }

  /* Parent link and its independent 44px accordion button share the first
     grid row. The submenu owns the full second row, so it can never be
     squeezed into a narrow column beside "Services". */
  .ecar-header__nav-list > .menu-item-has-children {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    align-items: center;
  }

  .ecar-header__nav-list > .menu-item-has-children > a {
    grid-column: 1;
    grid-row: 1;
    min-width: 0;
    padding-right: 8px;
  }

  .ecar-header__nav-list .menu-item-has-children > a::before {
    display: none;
  }

  .ecar-header__submenu-toggle {
    display: inline-flex;
    grid-column: 2;
    grid-row: 1;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-left: auto;
    padding: 0;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--ecar-text-secondary);
    cursor: pointer;
    transition: color var(--transition), background-color var(--transition);
  }

  .ecar-header__submenu-toggle::before {
    content: '';
    width: 8px;
    height: 8px;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    transition: transform var(--transition);
  }

  .ecar-header__submenu-toggle:hover,
  .ecar-header__submenu-toggle:focus-visible {
    color: var(--ecar-text-primary);
    background-color: var(--ecar-surface);
  }

  .menu-item-has-children.is-submenu-open > .ecar-header__submenu-toggle::before {
    transform: translateY(2px) rotate(225deg);
  }

  .ecar-header__nav-list .sub-menu {
    grid-column: 1 / -1;
    grid-row: 2;
    position: static;
    width: 100%;
    max-height: 0;
    overflow: hidden;
    visibility: hidden;
    opacity: 0;
    transform: none;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: none;
    pointer-events: none;
    transition: max-height var(--dur-slow) var(--ease), opacity var(--dur) var(--ease),
                visibility var(--dur) var(--ease), padding var(--dur) var(--ease);
  }

  /* Neutralise desktop hover/focus rules on touch widths while the accordion
     is closed. This also prevents a tapped close button from leaving its
     submenu exposed through the parent's :focus-within state. */
  .ecar-header__nav-list .menu-item-has-children:not(.is-submenu-open):hover > .sub-menu,
  .ecar-header__nav-list .menu-item-has-children:not(.is-submenu-open):focus-within > .sub-menu {
    max-height: 0;
    padding: 0;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
  }

  .ecar-header__nav-list .menu-item-has-children.is-submenu-open > .sub-menu {
    max-height: 560px;
    padding: 0 0 10px;
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
  }

  .ecar-header__nav-list .sub-menu li {
    display: block;
    width: 100%;
    border-bottom: 0;
  }

  .ecar-header__nav-list .sub-menu a {
    gap: 12px;
    width: 100%;
    min-height: 48px;
    padding: 11px 12px;
    font-size: var(--fs-body);
    line-height: 1.3;
    white-space: normal;
    color: var(--ecar-text-secondary);
  }

  .ecar-header__nav-list .sub-menu .current-menu-item > a {
    background-color: var(--ecar-surface);
    color: var(--ecar-text-primary);
  }

  /* The phone number + header CTA that used to live here are now covered
     by .ecar-header__quick-actions below, which stays visible whether or
     not this panel is open — so they're dropped from the drawer instead
     of duplicated inside it. */
  .ecar-header__actions {
    display: none;
  }

  .ecar-header__menu-toggle {
    display: block;
  }
}

/* --- Mobile quick actions: Call / Book, always visible ---
   A second row stacked under .ecar-header__inner, inside the same sticky
   header, independent of the hamburger panel's open/closed state — see
   the comment in site-header.php for why this exists. --header-h absorbs
   this row's height at this breakpoint (variables.css) so the hamburger
   drawer's `inset` and every anchor's scroll-margin-top still land below
   both rows, not just the first one. */
.ecar-header__quick-actions {
  display: none;
}

@media (max-width: 1023px) {
  .ecar-header__quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 12px var(--gutter);
    border-top: 1px solid var(--ecar-hairline);
    background-color: var(--ecar-bg);
  }

  .ecar-header__quick-action.ecar-btn {
    height: 44px;
    padding: 0 12px;
    font-size: 0.75rem;
    letter-spacing: 0.03em;
  }

  .ecar-header__quick-action .ecar-btn__icon {
    width: 14px;
    height: 14px;
  }
}

/* Set on <body> by main.js while the panel is open, so the page behind the
   fixed overlay cannot scroll under it. */
body.ecar-nav-open {
  overflow: hidden;
}

@media (max-width: 767px) {
  .ecar-header__location {
    display: none;
  }
}

@media (max-width: 420px) {
  .ecar-header__logo img,
  .ecar-header__logo .custom-logo {
    max-width: 180px;
  }

  .ecar-header__quick-actions {
    gap: 8px;
    padding: 10px var(--gutter);
  }

  .ecar-header__quick-action.ecar-btn {
    height: 42px;
    padding-inline: 8px;
    font-size: 0.6875rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ecar-header,
  .ecar-header__nav-wrapper,
  .ecar-header__hamburger-line,
  .ecar-header__submenu-toggle::before,
  .ecar-header__nav-list .sub-menu,
  .ecar-header__nav-list a::after {
    transition: none;
  }
}
