/* ==========================================================================
   Site chrome — Variation A three-zone sticky header

   SPECIFICITY RULE: every anchor-based control in the header is scoped under
   `.site-chrome` (the <header> element). Page stylesheets ship blanket link
   rules, e.g. `body.page-detail a` (0,1,2) and `body.page-detail a:hover`
   (0,2,2), which out-rank a bare `.header-cta` (0,1,0) or `.site-nav a`
   (0,1,1) and turned the CTA charcoal-on-charcoal on listing pages. Scoped
   selectors are one class heavier (0,2,0 at rest, 0,3,0 on :hover), which
   beats those page rules without !important. Every state that sets colour,
   border or transition is written out under the scope. Do not drop the
   `.site-chrome` prefix from these rules.

   Logo height is one custom property (--chrome-logo-h) so the breakpoints
   and the scrolled state each only change a single value.
   ========================================================================== */

.site-chrome {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--cream);
  --chrome-logo-h: 60px;
}

.site-chrome[data-scrolled="true"] {
  --chrome-logo-h: 48px;
}

/* ── Zone 1: Path switcher strip ──────────────────────────────────────── */

.chrome-switcher {
  background: var(--linen);
  border-bottom: 1px solid var(--pebble);
  height: var(--switcher-h, 36px);
  overflow: hidden;
  transition:
    max-height var(--dur-base) var(--ease),
    opacity var(--dur-base) var(--ease);
  max-height: var(--switcher-h, 36px);
  opacity: 1;
}

.site-chrome[data-scrolled="true"] .chrome-switcher {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  border-bottom-color: transparent;
}

.chrome-switcher-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: var(--switcher-h, 36px);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 20px;
}

.chrome-switcher-text {
  font-size: 12px;
  color: var(--stone);
  letter-spacing: 0.02em;
}

.site-chrome .chrome-switcher-link {
  font-size: 12px;
  color: var(--charcoal);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  white-space: nowrap;
  transition:
    color var(--dur-base) var(--ease),
    border-color var(--dur-base) var(--ease);
}

.site-chrome .chrome-switcher-link:hover {
  color: var(--brass);
  border-bottom-color: var(--brass);
}

/* ── Zone 2 + 3 wrapper ───────────────────────────────────────────────── */

.chrome-main {
  background: var(--cream);
  border-bottom: 1px solid var(--pebble);
}

/* ── Zone 2: Logo bar ─────────────────────────────────────────────────── */

.chrome-logo-bar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 22px 24px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: padding var(--dur-base) var(--ease);
}

.site-chrome[data-scrolled="true"] .chrome-logo-bar-inner {
  padding: 12px 24px;
}

/* The brand never gives up width: the logo link and image refuse to shrink,
   so lower-priority items (phone, CTA label, CTA) are removed by the
   breakpoints below instead of the flex algorithm squeezing the logo. */
.site-chrome .chrome-wordmark {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  line-height: 0;
  border-bottom: 0;
  text-decoration: none;
}

.site-chrome .chrome-wm-img {
  height: var(--chrome-logo-h);
  width: auto;
  /* base.css gives every img max-width:100%, which makes its min-content
     contribution 0 and lets a flex row crush the lockup to 0px wide. */
  max-width: none;
  flex-shrink: 0;
  display: block;
  transition: height var(--dur-base) var(--ease);
}

.chrome-logo-right {
  display: flex;
  align-items: center;
  gap: 24px;
}

.site-chrome .chrome-phone {
  font-size: 14px;
  font-weight: 500;
  color: var(--charcoal);
  text-decoration: none;
  border-bottom: 0;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: var(--numerals-tabular, "lnum", "tnum");
  white-space: nowrap;
  transition: color var(--dur-base) var(--ease);
}

.site-chrome .chrome-phone:hover {
  color: var(--brass);
}

/* Header CTA button — scoped so .btn in components.css is unaffected.
   Colours for rest / hover / focus are all spelled out here (and written
   under .site-chrome) so no page-level `a` rule can flip them. The scrolled
   state needs no colour rules of its own: [data-scrolled] only changes
   sizing (below), and these rules apply in both states. */
.site-chrome .header-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  border-radius: var(--radius-button);
  font-family: var(--font-sans);
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid var(--charcoal);
  background: var(--charcoal);
  color: var(--cream);
  transition:
    background-color var(--dur-base) var(--ease),
    color var(--dur-base) var(--ease),
    border-color var(--dur-base) var(--ease);
}

.site-chrome .header-cta:hover {
  background: var(--brass);
  border-color: var(--brass);
  color: var(--cream);
  text-decoration: none;
}

/* Focus keeps the button's own colours and radius (base.css's
   `a:focus-visible` would otherwise swap in --radius-sm). Background and
   border are inherited from the rest/hover rules above. */
.site-chrome .header-cta:focus-visible {
  color: var(--cream);
  border-radius: var(--radius-button);
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

.header-cta--md {
  min-height: 40px;
  padding: 10px 20px;
  font-size: 15px;
}

.header-cta--sm {
  min-height: 0;
  padding: 8px 16px;
  font-size: 13px;
}

.site-chrome[data-scrolled="true"] .header-cta--md {
  min-height: 0;
  padding: 8px 16px;
  font-size: 13px;
}

/* ── Zone 3: Nav row ──────────────────────────────────────────────────── */

.chrome-nav-row {
  overflow: hidden;
  max-height: 60px;
  opacity: 1;
  transition:
    max-height var(--dur-base) var(--ease),
    opacity var(--dur-base) var(--ease);
}

.site-chrome[data-scrolled="true"] .chrome-nav-row {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

.chrome-nav-row-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
}

/* Nav links */
.site-nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 28px;
}

.site-chrome .site-nav a {
  font-size: 14px;
  font-weight: 400;
  color: var(--charcoal);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 2px;
  white-space: nowrap;
  transition:
    color var(--dur-base) var(--ease),
    border-color var(--dur-base) var(--ease);
}

.site-chrome .site-nav a:hover {
  color: var(--brass);
  border-bottom-color: var(--brass);
}

.site-chrome .site-nav a[aria-current="page"] {
  font-weight: 500;
  color: var(--brass);
  border-bottom-color: var(--brass);
}

/* Click-to-call inside the mobile menu panel. Hidden everywhere except the
   widths where the phone number is dropped from the logo bar (see below). */
.site-chrome .chrome-nav-phone {
  display: none;
}

/* Resident utility links (right of nav row) */
.chrome-resident-links {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-shrink: 0;
}

.chrome-resident-label {
  font-size: 12px;
  color: var(--stone);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
  white-space: nowrap;
}

.site-chrome .chrome-ext-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--stone);
  text-decoration: none;
  border-bottom: 0;
  white-space: nowrap;
  transition: color var(--dur-base) var(--ease);
}

.site-chrome .chrome-ext-link:hover {
  color: var(--brass);
}

.ext-icon {
  width: 11px;
  height: 11px;
  display: inline-block;
  flex-shrink: 0;
  opacity: 0.55;
  transition: opacity var(--dur-base) var(--ease);
}

.chrome-ext-link:hover .ext-icon {
  opacity: 0.9;
}

/* ── Mobile menu toggle (hamburger) ───────────────────────────────────── */

.menu-toggle {
  display: none;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 0;
  position: relative;
  color: var(--charcoal);
}

.menu-toggle__bar,
.menu-toggle__bar::before,
.menu-toggle__bar::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 20px;
  height: 1.5px;
  background: currentColor;
  border-radius: 1px;
  transform: translateX(-50%);
  transition: transform var(--dur-base) var(--ease), top var(--dur-base) var(--ease);
}

.menu-toggle__bar { top: 50%; transform: translate(-50%, -50%); }
.menu-toggle__bar::before { top: -7px; }
.menu-toggle__bar::after  { top: 7px; }

.menu-toggle[aria-expanded="true"] .menu-toggle__bar { background: transparent; }
.menu-toggle[aria-expanded="true"] .menu-toggle__bar::before { top: 0; transform: translateX(-50%) rotate(45deg); }
.menu-toggle[aria-expanded="true"] .menu-toggle__bar::after  { top: 0; transform: translateX(-50%) rotate(-45deg); }

/* ==========================================================================
   Responsive

   Small-screen priority (first to go -> last to go):
     phone number  (<= 767px, moved into the menu panel)
     CTA label     ("View available homes" -> "View homes", <= 479px)
     CTA button    (<= 389px; "Find a home" is the first menu item)
   The logo and the menu button are never removed or squeezed.

   Row height on small screens is set by the 44px menu button + 10px padding
   top and bottom = 64px, matching --header-h-mobile and the dropdown's
   `calc(100vh - 64px)`. The logo is always shorter than that, so the scroll
   shrink (40->36, 32->30, 30->28) cannot change the header's height and
   re-trigger the scroll handler.
   ========================================================================== */

/* Narrow desktop: shrink nav gaps */
@media (max-width: 1080px) {
  .site-nav ul { gap: 20px; }
  .chrome-resident-links { gap: 16px; }
}

/* Tablet / phone: mobile layout */
@media (max-width: 860px) {
  /* Zone 1 hidden on mobile */
  .chrome-switcher { display: none; }

  /* Show hamburger, hide desktop resident links */
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }

  /* Logo: 40px (36px scrolled) = 265px / 239px wide */
  .site-chrome { --chrome-logo-h: 40px; }
  .site-chrome[data-scrolled="true"] { --chrome-logo-h: 36px; }

  .chrome-logo-right { gap: 16px; }

  /* Zone 3 nav row becomes a dropdown panel triggered by hamburger */
  .chrome-nav-row {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    background: var(--cream);
    border-bottom: 1px solid var(--pebble);
    transition:
      max-height var(--dur-slow) var(--ease),
      opacity var(--dur-base) var(--ease);
    pointer-events: none;
    z-index: 10;
  }

  /* When menu is open, override the scrolled-collapse AND show the panel */
  .site-chrome .chrome-nav-row.is-open {
    max-height: calc(100vh - 64px);
    opacity: 1;
    pointer-events: auto;
    overflow-y: auto;
  }

  /* Also prevent scrolled state from collapsing the open mobile nav */
  .site-chrome[data-scrolled="true"] .chrome-nav-row.is-open {
    max-height: calc(100vh - 64px);
    opacity: 1;
    pointer-events: auto;
  }

  .chrome-nav-row-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
    padding: 16px 24px 24px;
  }

  .site-nav {
    width: 100%;
  }

  .site-nav ul {
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
  }

  .site-chrome .site-nav a {
    display: block;
    padding: 14px 0;
    font-size: 16px;
    border-bottom: 1px solid var(--pebble);
    width: 100%;
  }

  /* Remove the active underline style on mobile — use weight only */
  .site-chrome .site-nav a[aria-current="page"] {
    border-bottom-color: var(--pebble);
  }

  /* Resident links stacked vertically below nav */
  .chrome-resident-links {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-top: 20px;
    width: 100%;
  }

  .chrome-resident-label {
    margin-bottom: 4px;
  }

  .site-chrome .chrome-ext-link {
    font-size: 14px;
    color: var(--charcoal);
  }

  .site-chrome .chrome-ext-link:hover {
    color: var(--brass);
  }

  /* Chrome main needs relative positioning for the absolute dropdown */
  .chrome-main {
    position: relative;
  }

  .chrome-logo-bar-inner,
  .site-chrome[data-scrolled="true"] .chrome-logo-bar-inner {
    padding: 10px 24px;
  }
}

/* Small tablet / large phone: the phone number leaves the bar and becomes a
   "Call" link at the end of the menu panel (still one tap away). */
@media (max-width: 767px) {
  .site-chrome .chrome-phone {
    display: none;
  }

  .site-chrome .chrome-nav-phone {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 14px 0;
    font-size: 16px;
    font-weight: 500;
    color: var(--charcoal);
    text-decoration: none;
    border-bottom: 0;
    font-variant-numeric: tabular-nums lining-nums;
    transition: color var(--dur-base) var(--ease);
  }

  .site-chrome .chrome-nav-phone:hover {
    color: var(--brass);
  }
}

/* Phone: compact bar. Logo 32px (30px scrolled) = 212px / 199px wide. */
@media (max-width: 620px) {
  .chrome-resident-links {
    display: none;
  }

  .site-chrome { --chrome-logo-h: 32px; }
  .site-chrome[data-scrolled="true"] { --chrome-logo-h: 30px; }

  .chrome-logo-bar-inner,
  .site-chrome[data-scrolled="true"] .chrome-logo-bar-inner {
    padding: 10px 16px;
    gap: 12px;
  }

  /* Tight cluster: the 44px menu button has 12px of empty space either side
     of its 20px bars, so pull it flush with the content edge. */
  .chrome-logo-right {
    gap: 4px;
  }

  .menu-toggle {
    margin-right: -12px;
  }

  /* CTA drops to the compact (scrolled) size in both scroll states so it
     does not change size under the user's finger. */
  .site-chrome .header-cta--md,
  .site-chrome[data-scrolled="true"] .header-cta--md {
    min-height: 36px;
    padding: 8px 14px;
    font-size: 13px;
  }
}

/* Narrow phone: shorten the CTA label to "View homes", logo 30px (28px
   scrolled) = 199px / 186px wide. */
@media (max-width: 479px) {
  .site-chrome { --chrome-logo-h: 30px; }
  .site-chrome[data-scrolled="true"] { --chrome-logo-h: 28px; }

  .site-chrome .header-cta__more {
    display: none;
  }

  .site-chrome .header-cta--md,
  .site-chrome[data-scrolled="true"] .header-cta--md {
    padding: 8px 12px;
  }
}

/* Narrowest phones: logo + menu button only. */
@media (max-width: 389px) {
  .site-chrome .header-cta {
    display: none;
  }
}
