/* =========================================================
   SITE HEADER, NAVIGATION AND MOBILE CALL BAR
   Issue #44: approved design D1 Variant C4 (design-review/d1-header-variant-c4.html).
   Markup: includes/header.php and includes/mobile-cta.php. Behaviour: assets/js/header.js.
   Loaded on every page after style.css (and after service-page-additions.css /
   repair-cases.css where those are used). Navy, white and neutral tones only.
   ========================================================= */

:root {
  --hdr-h: 80px;
  --hdr-h-mobile: 64px;
  --bar-h: 56px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

/* Anchor offsets: in-page jumps land below the sticky header (and above the mobile bar). */
html {
  scroll-padding-top: calc(var(--hdr-h) + 16px);
}

@media (max-width: 1023.98px) {
  html {
    scroll-padding-top: calc(var(--hdr-h-mobile) + 12px);
  }
}

@media (max-width: 900px) {
  html {
    scroll-padding-bottom: calc(var(--bar-h) + 12px);
  }
}

/* Mobile menu open: the page behind does not scroll. */
html.menu-open {
  overflow: hidden;
}

/* Skip link: first Tab stop, visible only on focus. */
.skip-link {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3000;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--navy);
  color: #fff;
  font-weight: 700;
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: none;
}

/* Reduced motion: header, menu and bar change state without animating. */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .ss-header,
  .ss-header *,
  .ss-menu,
  .ss-menu *,
  .mobile-cta-bar,
  .mobile-cta-bar * {
    transition-duration: 0.01ms !important;
  }
}

/* =========================================================
   D1 VARIANT C4 (Issue #44 §T, §U, §W, §Y) — rules as approved in the prototype.
   - 80px desktop header: logo | divider + navigation | phone + Request Service.
   - Navigation, phone and Request Service share one hover motion:
     translateY(-2px) scale(1.02), 190ms; light-navy highlights.
   - Below 1024px: logo + 44px phone icon + Menu; the phone icon stays
     visible while the menu is open; the menu pins Call Now / Request Service.
   ========================================================= */

:root {
  --hdr-h: 80px;
  --logo-h: 58px;
  --logo-h-mobile: 44px;
  --tint: rgba(22, 40, 66, 0.06);
  --tint-strong: rgba(22, 40, 66, 0.1);
  --chip: #eef2f7;
  --chip-strong: #e3e9f1;
  --dur: 190ms;
  --hover-bg: #e4eaf3;        /* light navy: navigation + dropdown hover */
  --hover-bg-strong: #d9e2ee; /* pressed / Services open */
  --cta-shadow-hover: 0 14px 30px rgba(22, 40, 66, 0.28);
  --cta-shadow-press: 0 6px 16px rgba(22, 40, 66, 0.2);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link:focus {
  outline: 2px solid var(--navy);
  outline-offset: 3px;
}

.ss-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: #fff;
  border-bottom: 1px solid var(--line);
  transition: box-shadow 0.2s ease;
}

.ss-header.is-scrolled {
  box-shadow: 0 10px 30px rgba(22, 40, 66, 0.08);
}

.ss-header__inner {
  display: flex;
  align-items: center;
  width: min(1320px, 100%);
  height: var(--hdr-h);
  margin: 0 auto;
  padding: 0 40px;
}

/* Logo: the file is used as is. The wrapper only hides the transparent
   padding around the artwork (content box 741 x 337 of 821 x 501). */
.ss-logo {
  position: relative;
  display: block;
  flex-shrink: 0;
  height: var(--logo-h);
  aspect-ratio: 741 / 337;
  overflow: hidden;
  transition: opacity var(--dur) ease;
}

.ss-logo:hover {
  opacity: 0.82;
}

.ss-logo img {
  position: absolute;
  top: calc(var(--logo-h) * -68 / 337);
  left: calc(var(--logo-h) * -44 / 337);
  width: auto;
  max-width: none;
  height: calc(var(--logo-h) * 501 / 337);
}

/* ---------- Desktop navigation ---------- */

.ss-nav {
  align-self: stretch;
  margin-left: 30px;
  padding-left: 18px;
  background: linear-gradient(var(--line), var(--line)) left center / 1px 36px no-repeat;
}

.ss-nav__list {
  display: flex;
  align-items: stretch;
  gap: 6px;
  height: 100%;
  margin: 0;
  padding: 0;
  list-style: none;
}

.ss-nav__item {
  position: relative;
  display: flex;
  align-items: center;
}

/* Understated hover: a soft navy tint behind the label, no underline. */
.ss-nav__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--navy);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
  cursor: pointer;
  transition: transform var(--dur) var(--ease), background-color var(--dur) var(--ease);
}

/* Navigation and the Services trigger: light-navy highlight + the same
   lift as the CTAs. Transforms do not affect layout, so neighbours stay put. */
.ss-nav__link:hover {
  background: var(--hover-bg);
  transform: translateY(-2px) scale(1.02);
}

.ss-nav__link:active,
.ss-dd.is-open > .ss-nav__link {
  background: var(--hover-bg-strong);
}

.ss-chev {
  flex-shrink: 0;
  opacity: 0.7;
  transition: transform 0.2s var(--ease);
}

.ss-dd.is-open .ss-chev {
  transform: rotate(180deg);
}

/* Simple Services list (Variant A). */
.ss-dd__panel {
  position: absolute;
  top: calc(100% - 12px);
  left: 0;
  z-index: 5;
  width: 316px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 24px 48px rgba(22, 40, 66, 0.14);
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 0.16s ease, transform 0.16s var(--ease), visibility 0s linear 0.16s;
}

.ss-dd.is-open .ss-dd__panel {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 0.16s ease, transform 0.16s var(--ease), visibility 0s;
}

.ss-dd__panel ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.ss-dd__panel a {
  display: block;
  padding: 9px 14px;
  border-radius: 9px;
  color: var(--text);
  font-size: 15px;
  line-height: 1.35;
  transition: background-color var(--dur) ease, color var(--dur) ease;
}

/* The label moves, not the highlight, so the item edges stay aligned. */
.ss-dd__panel a span {
  display: inline-block;
  transition: transform var(--dur) var(--ease);
}

.ss-dd__panel a:hover {
  background: var(--hover-bg);
  color: var(--navy);
}

.ss-dd__panel a:hover span {
  transform: translateX(4px);
}

.ss-dd__panel .ss-dd__all {
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  border-radius: 0 0 9px 9px;
  color: var(--navy);
  font-weight: 700;
}

/* ---------- Phone + Request Service ---------- */

.ss-actions {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-left: auto;
  flex-shrink: 0;
}

.ss-call {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 4px 14px 4px 4px;
  border-radius: 999px;
  color: var(--navy);
  white-space: nowrap;
}

/* Phone: the whole control (icon + label + number) rises as a white
   card; the icon circle also turns navy. */
.ss-call:hover {
  background: #fff;
}

.ss-call__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--chip);
  color: var(--navy);
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

@media (min-width: 1024px) {
  .ss-call:hover .ss-call__icon {
    background: var(--navy);
    color: #fff;
  }
}

.ss-call__icon svg {
  width: 18px;
  height: 18px;
}

.ss-call__text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.ss-call__label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.ss-call__num {
  margin-top: 3px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.ss-request {
  display: inline-flex;
  align-items: center;
  height: 46px;
  padding: 0 24px;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(22, 40, 66, 0.16);
}

.ss-request:hover {
  background: var(--navy2);
}

/* Phone + Request Service: ONE shared hover motion (Issue #44 §W).
   Same lift, scale, shadow, 190ms duration and easing. Resting colours
   stay different for hierarchy. Mouse/trackpad only, so taps on touch
   screens do not leave a control stuck in its hover state. */
.ss-call,
.ss-request {
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background-color var(--dur) var(--ease);
}

@media (hover: hover) and (pointer: fine) {
  .ss-call:hover,
  .ss-request:hover {
    box-shadow: var(--cta-shadow-hover);
    transform: translateY(-2px) scale(1.02);
  }

  .ss-call:active,
  .ss-request:active {
    box-shadow: var(--cta-shadow-press);
    transform: translateY(0) scale(1);
  }
}

/* Reduced motion: keep the colour and shadow feedback, drop the movement. */
@media (prefers-reduced-motion: reduce) {
  .ss-nav__link:hover,
  .ss-call:hover,
  .ss-call:active,
  .ss-request:hover,
  .ss-request:active,
  .ss-dd__panel a:hover span {
    transform: none;
  }
}

.ss-menu-btn {
  display: none;
}

/* Keyboard focus: a 2px navy ring with a white gap, on every control. */
.ss-header a:focus-visible,
.ss-header button:focus-visible,
.ss-menu a:focus-visible,
.ss-menu button:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}

.ss-request:focus-visible,
.ss-btn:focus-visible {
  outline-offset: 3px !important;
}

.ss-dd__panel a:focus-visible {
  outline-offset: -2px !important;
  background: var(--soft);
}

.ss-logo:focus-visible {
  border-radius: 4px;
}

/* ---------- Compact desktop (1024–1199) ---------- */

@media (max-width: 1199.98px) {
  .ss-header__inner {
    padding: 0 24px;
  }

  .ss-nav {
    margin-left: 18px;
    padding-left: 10px;
  }

  .ss-nav__list {
    gap: 4px;
  }

  .ss-nav__link {
    padding: 0 9px;
    font-size: 14.5px;
  }

  .ss-actions {
    gap: 14px;
  }

  .ss-call {
    padding: 4px 10px;
  }

  .ss-call__icon {
    display: none;
  }

  .ss-call__num {
    font-size: 17px;
  }

  .ss-request {
    height: 44px;
    padding: 0 18px;
    font-size: 14.5px;
  }
}

/* ---------- Tablet + mobile (below 1024) ---------- */

@media (max-width: 1023.98px) {
  .ss-header__inner {
    height: var(--hdr-h-mobile);
    padding: 0 20px;
  }

  .ss-logo {
    --logo-h: var(--logo-h-mobile);
  }

  .ss-nav {
    display: none;
  }

  .ss-actions {
    gap: 8px;
  }

  /* Compact phone icon (Issue #44 §W). Still the same #header-call-button
     tel: link; the label and number stay in its text, visually hidden,
     so the accessible name and CallRail number swapping still work. */
  .ss-call {
    justify-content: center;
    gap: 0;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 50%;
    background: var(--chip);
  }

  .ss-call:hover {
    background: var(--chip-strong);
  }

  .ss-call__icon {
    display: block;
    width: auto;
    height: auto;
    background: none;
  }

  .ss-call__icon svg {
    display: block;
    width: 18px;
    height: 18px;
  }

  .ss-call__label,
  .ss-call__num {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  /* Hidden label: normal case so it is announced "Call · Daily…", not spelled in capitals. */
  .ss-call__label {
    text-transform: none;
  }

  .ss-request {
    display: none;
  }

  /* Menu open: the menu's pinned row carries Call Now + Request Service,
     so the header drops to logo + close. Restored when the menu closes. */
  html.menu-open .ss-request {
    display: none;
  }
  /* C4: the phone icon stays visible beside the Close control. */

  .ss-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #fff;
    color: var(--navy);
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color var(--dur) ease;
  }

  .ss-menu-btn:hover {
    background: var(--soft);
  }
}

/* 901–1023: no bottom bar here, so the header keeps Request Service. */
@media (min-width: 901px) and (max-width: 1023.98px) {
  .ss-request {
    display: inline-flex;
    height: 44px;
    padding: 0 18px;
    font-size: 14.5px;
    box-shadow: none;
  }
}

@media (max-width: 599.98px) {
  .ss-header__inner {
    padding: 0 16px;
  }

  .ss-menu-btn {
    padding: 0 13px;
  }
}

@media (max-width: 359.98px) {
  .ss-menu-btn__text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
}

.ss-burger {
  position: relative;
  display: block;
  width: 18px;
  height: 12px;
}

.ss-burger span {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.2s var(--ease), opacity 0.15s ease;
}

.ss-burger span:nth-child(1) { top: 0; }
.ss-burger span:nth-child(2) { top: 5px; }
.ss-burger span:nth-child(3) { top: 10px; }

[aria-expanded="true"] .ss-burger span:nth-child(1) { transform: translateY(5px) rotate(45deg); }
[aria-expanded="true"] .ss-burger span:nth-child(2) { opacity: 0; }
[aria-expanded="true"] .ss-burger span:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }

/* ---------- Mobile / tablet menu ---------- */

.ss-menu {
  position: fixed;
  top: var(--menu-top, var(--hdr-h-mobile));
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 990;
  background: rgba(22, 40, 66, 0.32);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.ss-menu.is-open {
  opacity: 1;
}

/* Phone: a panel that drops from the header and is only as tall as its
   content (the page stays visible below it, so a tap there closes the
   menu). Only .ss-menu__scroll scrolls; the action row stays pinned. */
.ss-menu__sheet {
  display: flex;
  flex-direction: column;
  max-height: 100%;
  overflow: hidden;
  border-radius: 0 0 18px 18px;
  background: #fff;
  box-shadow: 0 18px 40px rgba(22, 40, 66, 0.18);
  transform: translateY(-8px);
  transition: transform 0.22s var(--ease);
}

.ss-menu.is-open .ss-menu__sheet {
  transform: none;
}

.ss-menu__scroll {
  flex: 1 1 auto;
  min-height: 0;
  padding: 2px 20px 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.ss-menu__cta {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line);
  background: #fff;
}

/* Tablet: full-height drawer on the right, same pinned action row. */
@media (min-width: 600px) {
  .ss-menu__sheet {
    width: 400px;
    height: 100%;
    max-height: none;
    margin-left: auto;
    border-radius: 0;
    box-shadow: -20px 0 40px rgba(22, 40, 66, 0.12);
    transform: translateX(24px);
  }

  .ss-menu__scroll {
    padding: 2px 28px 10px;
  }

  .ss-menu__cta {
    padding-left: 28px;
    padding-right: 28px;
  }
}

.ss-menu__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.ss-menu__list > li {
  border-bottom: 1px solid var(--line);
}

.ss-menu__link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 52px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--navy);
  font: inherit;
  font-size: 18px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--dur) ease;
}

.ss-menu__link:hover {
  background: var(--tint);
}

.ss-menu__link[aria-expanded="true"] .ss-chev {
  transform: rotate(180deg);
}

/* Expanded Services: a two-column grid of 15px items instead of a
   ten-row list. Every item keeps a 44px minimum touch target. */
.ss-menu__sub {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.ss-menu__sub[hidden] {
  display: none;
}

.ss-menu__sub li {
  display: flex;
}

.ss-menu__sub a {
  display: flex;
  flex: 1;
  align-items: center;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--soft);
  color: var(--navy);
  font-size: 15px;
  line-height: 1.25;
  transition: background-color var(--dur) ease;
}

.ss-menu__sub a:hover {
  background: var(--chip-strong);
}

.ss-menu__sub .ss-menu__all {
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 700;
}

.ss-menu__sub .ss-menu__all:hover {
  background: var(--soft);
}

.ss-menu__hours {
  margin: 14px 0 4px;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  text-align: center;
}

.ss-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 15.5px;
  font-weight: 700;
  white-space: nowrap;
  transition: background-color var(--dur) ease;
}

.ss-btn svg {
  width: 16px;
  height: 16px;
}

.ss-btn--outline {
  border: 1.5px solid var(--navy);
  color: var(--navy);
}

.ss-btn--outline:hover {
  background: var(--soft);
}

.ss-btn--solid {
  background: var(--navy);
  color: #fff;
}

.ss-btn--solid:hover {
  background: var(--navy2);
}

/* ---------- Mobile call bar (includes/mobile-cta.php): navy + light ----------
   Same markup and IDs everywhere it appears (homepage, service pages, repair cases).
   The "body" prefix and this file's load order override the older gold bar rules in
   service-page-additions.css and repair-cases.css, which are left unchanged. */

.mobile-cta-bar {
  display: none;
}

@media (max-width: 900px) {
  body .mobile-cta-bar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 900;
    gap: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #fff;
    border-top: 1px solid var(--line);
    box-shadow: 0 -6px 20px rgba(22, 40, 66, 0.08);
    transition: transform 0.3s ease, opacity 0.3s ease;
  }

  body .mobile-cta-bar.mobile-cta-bar--hidden,
  html.menu-open body .mobile-cta-bar {
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
  }

  body .mobile-cta-bar .mobile-cta-call,
  body .mobile-cta-bar .mobile-cta-form {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--bar-h);
    padding: 0 12px;
    border-left: 0;
    font-weight: 700;
    letter-spacing: 0.01em;
    text-decoration: none;
  }

  body .mobile-cta-bar .mobile-cta-call {
    background: var(--navy);
    color: #fff;
    font-size: 1rem;
  }

  body .mobile-cta-bar .mobile-cta-call:hover {
    background: var(--navy2);
    color: #fff;
  }

  body .mobile-cta-bar .mobile-cta-form {
    background: var(--soft);
    color: var(--navy);
    font-size: 0.95rem;
  }

  body .mobile-cta-bar .mobile-cta-form:hover {
    background: #e9eef5;
    color: var(--navy);
  }

  body .mobile-cta-bar .mobile-cta-call:focus-visible {
    outline: 3px solid #fff;
    outline-offset: -5px;
  }

  body .mobile-cta-bar .mobile-cta-form:focus-visible {
    outline: 2px solid var(--navy);
    outline-offset: -5px;
  }

  /* Keep the footer's last line clear of the fixed bar. */
  body:has(.mobile-cta-bar) .footer {
    padding-bottom: calc(38px + var(--bar-h) + env(safe-area-inset-bottom, 0px));
  }
}
