/* =========================================================================
   Header, desktop nav, mobile overlay
   Prototype public/css/site.css header block + width-driven breakpoints.
   Verification widths: 1920 / 1440 (full row), 1366 (phone hidden),
   1180 / 1024 (hamburger), 768 / 680 / 390 / 320 (scaled lockup, no sub-line).
   ========================================================================= */

.header {
  position: sticky; top: 0; z-index: 90;
  background: rgba(244, 247, 250, .9);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .3s var(--ease);
}
.header.is-stuck { border-bottom-color: var(--line); }

.header-trust {
  border-bottom: 1px solid var(--line-2);
  background: rgba(244, 247, 250, .96);
}
.header-trust-inner {
  width: 100%;
  max-width: var(--chrome-max, 1440px);
  margin-inline: auto;
  /* Same horizontal inset as .footer .wrap so logos share one left edge. */
  padding: 7px var(--gap);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--ink);
  box-sizing: border-box;
}
.header-trust-item { white-space: nowrap; }
.header-trust-sep { color: var(--muted); font-weight: 400; }

.header-inner {
  width: 100%;
  max-width: var(--chrome-max, 1440px);
  margin-inline: auto;
  /* Match footer .wrap padding so header/footer brand left edges align. */
  padding-inline: var(--gap);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  height: 96px;
  box-sizing: border-box;
}

.brand {
  display: flex; flex-direction: column; align-items: flex-start;
  justify-content: center;
  gap: 3px; text-decoration: none; flex: 0 0 auto;
}
.header .brand picture { display: contents; }
/* Wide header lockup (~3:1): larger mark; icon scale closer to footer logo. */
.header .brand img {
  width: auto;
  height: auto;
  max-height: 88px;
  max-width: min(400px, 34vw);
  display: block;
  object-fit: contain;
}
.brand .mark {
  font-family: var(--display);
  font-weight: 400;
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: -.012em;
  color: var(--ink-2);
}
/* CIL logo already includes the trading name; hide the duplicate sub-line in the header. */
.header .brand .sub {
  display: none;
  font-size: 10px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase;
  color: var(--blue); white-space: nowrap;
}
.brand:hover .mark { color: var(--blue-deep); }

.primary-nav {
  display: flex;
  align-items: center;
  justify-content: stretch;
  flex: 1 1 auto;
  min-width: 0;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
  width: 100%;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.nav-item { position: relative; flex: 0 0 auto; }
.nav-link {
  display: inline-flex; align-items: center; gap: 6px; padding: 10px 0;
  font-size: 15px; font-weight: 500; color: var(--ink); text-decoration: none; white-space: nowrap;
  transition: color .2s var(--ease);
}
.nav-link:hover, .nav-link[aria-current="page"] { color: var(--blue-deep); }
.nav-link[aria-current="page"] { position: relative; }
.nav-link[aria-current="page"]::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 4px; height: 2px;
  border-radius: 2px; background: var(--blue);
}
.nav-item.has-menu > .nav-link::after {
  content: ""; width: 5px; height: 5px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}

.submenu {
  position: absolute; top: 100%; left: 50%; transform: translate(-50%, 8px);
  min-width: 292px; padding: 8px; list-style: none;
  background: var(--card); border: 1px solid var(--line); border-radius: 6px;
  box-shadow: 0 22px 50px -26px rgba(22, 32, 46, .3);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity .22s var(--ease), transform .22s var(--ease), visibility .22s;
}
.nav-item:hover .submenu, .nav-item:focus-within .submenu {
  opacity: 1; visibility: visible; pointer-events: auto; transform: translate(-50%, 0);
}
.submenu a {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding: 11px 14px; border-radius: var(--r);
  text-decoration: none; color: var(--ink); font-size: 15px;
  transition: background .18s var(--ease);
}
.submenu a:hover { background: var(--paper-2); }
.submenu .note { font-size: 12px; color: var(--muted-2); white-space: nowrap; }
.submenu-heading { list-style: none; }
.submenu-label {
  display: block;
  padding: 10px 14px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--blue);
}
.mobile-nav .sub .submenu-heading { border: 0; padding: 0; }
.mobile-nav .sub .submenu-label {
  display: block;
  margin: 8px 0 0;
  padding: 8px 0 0 16px;
  font-family: var(--sans);
  font-size: 11px;
  min-height: 0;
}

.header-cta { display: flex; align-items: center; gap: 14px; flex: 0 0 auto; flex-shrink: 0; }
.header-tel {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding-block: 10px;
  font-size: 15px; font-weight: 600; color: var(--ink); text-decoration: none; white-space: nowrap;
}
.header-tel:hover { color: var(--blue-deep); }
.header-tel svg { width: 16px; height: 16px; flex: 0 0 auto; color: var(--blue); }
.header .btn { min-height: 44px; padding: 11px 18px; font-size: 14px; white-space: nowrap; flex-shrink: 0; }
.header .header-callback { padding-inline: 14px; }

.burger {
  display: none; width: 46px; height: 46px; margin-left: auto;
  align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--line); border-radius: var(--r); cursor: pointer;
}
.burger span { display: block; width: 18px; height: 1.5px; background: var(--ink); position: relative; transition: background .2s; }
.burger span::before, .burger span::after {
  content: ""; position: absolute; left: 0; width: 18px; height: 1.5px; background: var(--ink);
  transition: transform .28s var(--ease), top .2s var(--ease);
}
.burger span::before { top: -6px; }
.burger span::after { top: 6px; }
.burger[aria-expanded="true"] span { background: transparent; }
.burger[aria-expanded="true"] span::before { top: 0; transform: rotate(45deg); }
.burger[aria-expanded="true"] span::after { top: 0; transform: rotate(-45deg); }

.mobile-nav {
  position: fixed; left: 0; right: 0; top: var(--header-h); z-index: 89;
  height: calc(100vh - var(--header-h));
  height: calc(100dvh - var(--header-h));
  background: var(--paper); padding: 22px var(--gap) calc(120px + env(safe-area-inset-bottom));
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  opacity: 0; visibility: hidden; transform: translateY(-8px);
  transition: opacity .28s var(--ease), transform .28s var(--ease), visibility .28s;
}
body.nav-open .header { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--paper); }
body.nav-open { position: fixed; width: 100%; overflow: hidden; }
.mobile-nav.is-open { opacity: 1; visibility: visible; transform: none; }
.mobile-nav a {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  min-height: 56px; padding: 12px 0; border-bottom: 1px solid var(--line-2);
  text-decoration: none; color: var(--ink);
  font-family: var(--display); font-weight: 400; font-size: 25px;
}
.mobile-nav .sub { list-style: none; margin: 0; padding: 0; }
.mobile-nav .sub a { font-family: var(--sans); font-size: 16px; min-height: 50px; padding-left: 16px; color: var(--muted); }
.mobile-nav .mob-actions { margin-top: 32px; display: grid; gap: 12px; }
.mobile-nav .mob-actions .btn { width: 100%; }

@media (max-width: 1600px) {
  .header-tel { display: none; }
}

@media (max-width: 1440px) {
  .header-inner { gap: 18px; }
  .header .brand img {
    max-height: 84px;
    max-width: min(380px, 32vw);
  }
  .nav { gap: 10px; }
  .nav-link { font-size: 14.5px; }
  .header .btn { padding: 10px 15px; font-size: 13.5px; }
  .header .header-callback { padding-inline: 12px; }
}

@media (max-width: 1340px) {
  .header-callback { display: none; }
}

@media (max-width: 1260px) and (min-width: 1181px) {
  .brand .sub { display: none; }
}
@media (max-width: 1260px) {
  .header-inner { gap: 16px; }
  .nav { gap: 8px; }
  .nav-link { font-size: 14px; }
}

@media (max-width: 1180px) {
  .primary-nav,
  .header-cta { display: none; }
  .burger { display: flex; }
  .header-inner { height: 92px; justify-content: space-between; }
  .header-trust-inner { justify-content: flex-start; }
  :root { --header-h: 124px; }
  .header .brand img {
    max-height: 82px;
    max-width: min(360px, 64vw);
  }
}

@media (max-width: 1024px) {
  .header-inner { height: 88px; }
  :root { --header-h: 120px; }
  .header .brand img {
    max-height: 78px;
    max-width: min(340px, 62vw);
  }
}

@media (max-width: 768px) {
  .header-inner { height: 84px; gap: 18px; }
  :root { --header-h: 116px; }
  .header .brand img {
    max-height: 72px;
    max-width: min(300px, 66vw);
  }
}

@media (max-width: 680px) {
  .header-inner { height: 80px; gap: 16px; }
  :root { --header-h: 108px; }
  .brand .sub { display: none; }
  .header .brand img {
    max-height: 64px;
    max-width: min(260px, 68vw);
  }
  .header-trust-inner { padding-block: 6px; font-size: 11px; letter-spacing: 0; gap: 6px 10px; }
  .header-trust-sep { display: none; }
}

@media (max-width: 390px) {
  .header-inner { height: 76px; }
  :root { --header-h: 104px; }
  .header .brand img {
    max-height: 58px;
    max-width: min(230px, 70vw);
  }
}

@media (max-width: 320px) {
  .header-inner { height: 74px; }
  :root { --header-h: 102px; }
  .header .brand img {
    max-height: 52px;
    max-width: min(200px, 64vw);
  }
}

.admin-bar .header {
  top: var(--wp-admin--admin-bar--height, 32px);
}
.admin-bar .mobile-nav {
  top: calc(var(--header-h) + var(--wp-admin--admin-bar--height, 32px));
  height: calc(100vh - var(--header-h) - var(--wp-admin--admin-bar--height, 32px));
  height: calc(100dvh - var(--header-h) - var(--wp-admin--admin-bar--height, 32px));
}

/* Horizontal header lockup: width caps leave room for nav / burger. */
.header .brand img[src*="header-logo"],
.header .brand img[src*="logo-wordmark"] {
  max-width: min(400px, 34vw);
}
/* Wide lockup leaves no room for the phone link beside the nav buttons. */
.header .header-tel { display: none; }
@media (max-width: 1440px) {
  .header .brand img[src*="header-logo"],
  .header .brand img[src*="logo-wordmark"] {
    max-width: min(380px, 32vw);
  }
}
@media (max-width: 1180px) {
  .header .brand img[src*="header-logo"],
  .header .brand img[src*="logo-wordmark"] {
    max-width: min(360px, 64vw);
  }
}
@media (max-width: 680px) {
  .header .brand img[src*="header-logo"],
  .header .brand img[src*="logo-wordmark"] {
    max-width: min(260px, 68vw);
  }
}
@media (max-width: 390px) {
  .header .brand img[src*="header-logo"],
  .header .brand img[src*="logo-wordmark"] {
    max-width: min(230px, 70vw);
  }
}
