/* ===============================================
   ISUZU MIGORI — HEADER
   Navy utility bar + white main bar.

   The header is position: sticky with a negative top equal to
   the utility-bar height, so the utility bar simply scrolls away
   and the main bar pins to the top. No JS-driven transforms →
   nothing flashes behind the header when scrolling quickly.
   Tokens live in theme.css.
   =============================================== */

.header {
  position: sticky;
  top: calc(-1 * var(--topbar-h));
  z-index: 1000;
  background: #FFFFFF;
  transition: box-shadow .3s ease;
}
.header.is-scrolled { box-shadow: 0 8px 28px rgba(11, 29, 46, .10); }

/* ── Utility bar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--navy);
  color: rgba(255, 255, 255, .78);
  font-size: .78rem;
  font-weight: 500;
}
.topbar-inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 28px;
  padding-inline: clamp(16px, 2.4vw, 32px);
}
.topbar-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}
.topbar-item .fi { font-size: 15px; color: var(--gold); }
a.topbar-item:hover { color: #FFFFFF; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 28px; }
.topbar-cta {
  height: 26px;
  padding: 0 14px;
  margin-left: 8px;
  border-radius: 4px;
  background: var(--brand-red);
  color: #FFFFFF;
  font-weight: 700;
  transition: background .2s ease;
}
.topbar-cta .fi { color: #FFFFFF; }
a.topbar-cta:hover { background: var(--brand-red-dark); }

/* ── Main bar ── */
.mainbar {
  height: var(--header-h);
  background: #FFFFFF;
  border-bottom: 1px solid var(--line);
}
.header-content {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 24px;
  padding-inline: clamp(16px, 2.4vw, 32px);
}

/* Brand lock-up: ISUZU / MIGORI (home) | Smartlake (smartlakemotors.com) */
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}
.brand a { text-decoration: none; }
.brand-isuzu {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
}
.brand-isuzu img { width: 100px; height: auto; }
.brand-place {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .78rem;
  letter-spacing: .44em;
  line-height: 1;
  color: var(--navy);
  padding-left: 2px;
}
.brand-divider {
  width: 2px;
  height: 38px;
  background: var(--gold);
  transform: skewX(-14deg);
}
.brand-partner img { height: 44px; width: auto; transition: opacity .2s ease; }
.brand-partner:hover img { opacity: .8; }

/* Primary navigation */
.nav {
  display: flex;
  align-items: center;
  margin-left: auto;
  height: 100%;
}
.nav-item { position: relative; height: 100%; display: flex; }
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 100%;
  padding: 0 15px;
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  transition: color .2s ease;
}
.nav-link::after {
  content: '';
  position: absolute;
  left: 15px; right: 15px; bottom: -1px;
  height: 4px;
  background: var(--brand-red);
  transform: scaleX(0) skewX(-24deg);
  transform-origin: left;
  transition: transform .3s var(--ease);
}
.nav-link:hover,
.nav-link.active,
.has-sub:hover > .nav-link,
.has-sub:focus-within > .nav-link { color: var(--brand-red); }
.nav-link:hover::after,
.nav-link.active::after { transform: scaleX(1) skewX(-24deg); }
/* .nav-link prefix beats the generic .fi size whatever order the stylesheets load in */
.nav-link .nav-caret { font-size: 14px; transition: transform .25s var(--ease); }
.has-sub:hover .nav-caret,
.has-sub:focus-within .nav-caret { transform: rotate(180deg); }

/* Services dropdown */
.subnav {
  position: absolute;
  top: 100%;
  left: 0;
  width: 360px;
  padding: 10px;
  background: #FFFFFF;
  border: 1px solid var(--line);
  border-top: 4px solid var(--brand-red);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  box-shadow: 0 24px 48px rgba(11, 29, 46, .14);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .25s var(--ease), visibility 0s linear .25s;
}
.has-sub:hover .subnav,
.has-sub:focus-within .subnav {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity .2s ease, transform .25s var(--ease);
}
.subnav a {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  transition: background .2s ease;
}
.subnav a:not(.subnav-all):hover, .subnav a:not(.subnav-all).active { background: var(--panel); }
.subnav a > .fi {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--navy);
  color: var(--gold);
  font-size: 20px;
}
.subnav strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  line-height: 1.1;
}
.subnav small { display: block; font-size: .75rem; color: var(--ink-muted); }
.subnav .subnav-all {
  justify-content: space-between;
  margin-top: 6px;
  padding: 12px;
  background: var(--brand-red);
  color: #FFFFFF;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.subnav .subnav-all:hover,
.subnav .subnav-all:focus-visible { background: var(--brand-red-dark); color: #FFFFFF; }
.subnav .subnav-all > .fi { width: auto; height: auto; background: none; color: #FFFFFF; font-size: 18px; }

.nav-mobile-extra { display: none; }

/* Actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-call {
  width: 44px;
  height: 44px;
  display: none;
  place-items: center;
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--brand-red);
  text-decoration: none;
}
.header-call .fi { font-size: 20px; }
.header-actions .header-cta { min-height: 44px; padding: 0 20px; }

/* Mobile toggle */
.mobile-toggle {
  display: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: var(--radius);
  background: var(--navy);
  color: #FFFFFF;
  cursor: pointer;
  place-items: center;
}
.mobile-toggle .fi { font-size: 22px; }
.mobile-toggle .fi-tr-x { display: none; }
.mobile-toggle.active .fi-tr-bars-staggered { display: none; }
.mobile-toggle.active .fi-tr-x { display: inline-flex; }

/* ===============================================
   RESPONSIVE
   =============================================== */
@media (max-width: 1320px) {
  .nav-link { padding: 0 11px; }
  .nav-link::after { left: 11px; right: 11px; }
  .topbar-hide-md { display: none; }
}

/* Mobile-only controls are hidden on desktop */
.subnav-toggle,
.subnav-back { display: none; }

@media (max-width: 1100px) {
  .topbar { display: none; }
  .mobile-toggle, .header-call { display: grid; }
  .header-actions { margin-left: auto; }

  /* The open menu fills exactly the space under the header — no scrolling.
     Spacing scales with the viewport height (dvh) so it fits short phones. */
  .nav {
    position: fixed;
    top: var(--header-h);
    left: 0;
    right: 0;
    height: calc(100vh - var(--header-h));
    height: calc(100dvh - var(--header-h));
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    background: #FFFFFF;
    padding: clamp(4px, 1dvh, 12px) 0 clamp(12px, 2.5dvh, 28px);
    overflow: hidden;
    transform: translateX(100%);
    visibility: hidden;
    transition: transform .4s var(--ease), visibility 0s linear .4s;
  }
  .nav.active {
    transform: none;
    visibility: visible;
    transition: transform .4s var(--ease);
  }
  .nav-item { position: static; height: auto; display: flex; align-items: stretch; }
  .nav-link {
    flex: 1;
    height: auto;
    padding: clamp(7px, 1.55dvh, 15px) var(--gutter);
    font-size: clamp(1.05rem, 2.6dvh, 1.4rem);
    line-height: 1.15;
    border-bottom: 1px solid var(--line);
  }
  .nav-link::after {
    left: 0; right: auto; top: 0; bottom: 0;
    width: 5px; height: auto;
    transform: scaleY(0);
  }
  .nav-link:hover::after,
  .nav-link.active::after { transform: scaleY(1); }
  .nav-link .nav-caret { display: none; }

  /* Services: closed by default; the chevron opens a slide-over panel */
  .subnav-toggle {
    display: grid;
    place-items: center;
    width: 64px;
    border: 0;
    border-bottom: 1px solid var(--line);
    border-left: 1px solid var(--line);
    background: var(--panel-soft);
    color: var(--brand-red);
    cursor: pointer;
  }
  .subnav-toggle .fi { font-size: 22px; }

  .subnav {
    position: absolute;
    inset: 0;
    z-index: 2;
    width: auto;
    display: flex;
    flex-direction: column;
    padding: clamp(4px, 1dvh, 12px) 0 clamp(12px, 2.5dvh, 28px);
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: #FFFFFF;
    opacity: 1;
    visibility: hidden;
    transform: translateX(100%);
    transition: transform .35s var(--ease), visibility 0s linear .35s;
  }
  /* Taps fire :hover / :focus-within on phones; only .open may show the panel */
  .has-sub:hover .subnav,
  .has-sub:focus-within .subnav {
    visibility: hidden;
    transform: translateX(100%);
    transition: transform .35s var(--ease), visibility 0s linear .35s;
  }
  .has-sub:hover > .nav-link,
  .has-sub:focus-within > .nav-link { color: var(--ink); }
  .has-sub > .nav-link.active { color: var(--brand-red); }
  .has-sub.open .subnav {
    visibility: visible;
    transform: none;
    transition: transform .35s var(--ease);
  }
  .subnav-back {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: clamp(10px, 2dvh, 18px) var(--gutter);
    border: 0;
    border-bottom: 1px solid var(--line);
    background: var(--panel-soft);
    font-family: var(--font-display);
    font-size: clamp(1rem, 2.4dvh, 1.2rem);
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--ink);
    cursor: pointer;
    text-align: left;
  }
  .subnav-back .fi { font-size: 20px; color: var(--brand-red); }
  .subnav a {
    padding: clamp(6px, 1.4dvh, 12px) var(--gutter);
    border-radius: 0;
    border-bottom: 1px solid var(--line);
  }
  .subnav strong { font-size: clamp(1rem, 2.4dvh, 1.2rem); }
  .subnav small { display: block; font-size: .72rem; }
  .subnav a > .fi { width: 36px; height: 36px; font-size: 18px; }
  .subnav .subnav-all {
    margin: auto var(--gutter) 0;
    border: 0;
    border-radius: var(--radius);
    justify-content: center;
    gap: 10px;
  }

  .nav-mobile-extra {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: auto;
    padding: clamp(10px, 2dvh, 20px) var(--gutter) 0;
  }
  .nav-mobile-extra .btn { min-height: clamp(42px, 6.4dvh, 50px); padding: 0 12px; }
  .nav-mobile-link {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 4px 0 0;
    font-size: .85rem;
    font-weight: 700;
    color: var(--ink-muted);
    text-decoration: none;
  }
  .nav-mobile-link .fi { font-size: 18px; color: var(--gold); }
}

@media (max-width: 560px) {
  .header-content { gap: 10px; }
  .brand { gap: 10px; }
  .brand-isuzu img { width: 82px; }
  .brand-place { font-size: .66rem; }
  .brand-divider { height: 30px; }
  .brand-partner img { height: 34px; }
  .header-actions .header-cta { display: none; }
}
