/* ==========================================================================
   layout.css — masthead (header) and colophon (footer)
   Both are injected by js/includes.js into #header and #footer.
   ========================================================================== */

/* ==========================================================================
   HEADER
   #header is the injected container and carries the sticky behaviour,
   because position:sticky on a child would only stick inside this box.
   ========================================================================== */

#header {
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: var(--header-h);   /* reserves space so nothing jumps on load */
}

.masthead {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  transition: box-shadow var(--speed) var(--ease),
              background-color var(--speed) var(--ease);
}

/* Shadow appears only once the page has scrolled — set by js/nav.js */
#header.is-stuck .masthead {
  box-shadow: var(--shadow-m);
}

.masthead__inner {
  width: 100%;
  margin-inline: auto;
  padding-inline: var(--gutter);
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-m);
}

/* ---- Logo (left) --------------------------------------------------------- */

.masthead__logo {
  display: grid;
  place-items: center;
  flex-shrink: 0;
  line-height: 0;
}

.masthead__logo img {
  height: 40px;
  width: auto;
}

/* ---- Hamburger (mobile only) --------------------------------------------- */

.masthead__toggle {
  display: grid;
  place-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  margin-right: calc(var(--space-2xs) * -1);
  border-radius: var(--radius-s);
}

.masthead__toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--pine);
  border-radius: 2px;
  transition: transform var(--speed) var(--ease),
              opacity var(--speed) var(--ease);
}

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

/* ---- Drawer: the whole right-hand group ---------------------------------- */
/* Mobile-first — this is the slide-down panel. Desktop rules are further down. */

.masthead__drawer {
  position: fixed;
  inset: var(--header-h) 0 auto 0;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-l);
  padding: var(--space-s) var(--gutter) var(--space-l);
  max-height: calc(100dvh - var(--header-h));
  overflow-y: auto;

  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity var(--speed) var(--ease),
              transform var(--speed) var(--ease),
              visibility var(--speed) var(--ease);
}

.masthead__drawer.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* ---- Nav list ------------------------------------------------------------ */

.nav__list {
  display: flex;
  flex-direction: column;
}

.nav__item {
  border-bottom: 1px solid var(--line);
}

.nav__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav__link {
  display: block;
  flex: 1;
  padding: var(--space-s) 0;
  font-family: var(--font-display);
  font-size: var(--step-1);
  font-weight: 600;
  color: var(--pine);
  text-decoration: none;
  transition: color var(--speed) var(--ease);
}

.nav__link:hover { color: var(--sage); }

/* Chevron / disclosure button for the Services group */
.nav__disclosure {
  display: grid;
  place-content: center;
  width: 44px;
  height: 44px;
  color: var(--ink-soft);
}

.nav__disclosure svg {
  width: 12px;
  height: 12px;
  transition: transform var(--speed) var(--ease);
}

.nav__disclosure[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

/* ---- Submenu (mobile: accordion) ----------------------------------------- */

.submenu {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--speed) var(--ease);
}

.submenu > * {
  overflow: hidden;
  min-height: 0;
}

.submenu.is-open {
  grid-template-rows: 1fr;
}

.submenu__inner {
  padding-bottom: var(--space-s);
}

.submenu__link {
  display: block;
  padding: var(--space-2xs) 0 var(--space-2xs) var(--space-s);
  border-left: 2px solid var(--line);
  font-size: var(--step-0);
  color: var(--ink-soft);
  text-decoration: none;
  transition: color var(--speed) var(--ease),
              border-color var(--speed) var(--ease);
}

.submenu__link:hover {
  color: var(--pine);
  border-color: var(--sage);
}

/* ---- Actions: phone + CTA ------------------------------------------------ */

.masthead__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-s);
  padding-top: var(--space-m);
}

.masthead__phone {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--step-1);
  color: var(--pine);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
}

.masthead__phone:hover { color: var(--brass-dark); }
.masthead__phone svg { width: 16px; height: 16px; }

/* ==========================================================================
   HEADER — desktop (1100px and up)
   ========================================================================== */

@media (min-width: 1100px) {

  .masthead__toggle { display: none; }

  /* ---- Logo shelf --------------------------------------------------------
     Pinned to the top of the bar and taller than it, so it hangs below.
     align-self keeps it from stretching the flex row, and the bar's own
     height is untouched — that's the whole point of the pattern. */
  .masthead__logo {
    position: relative;
    z-index: 2;
    align-self: flex-start;
    height: var(--logo-panel-h);
    /* Pull flush to the viewport edge, then pad the gutter back in */
    margin-left: calc(var(--gutter) * -1);
    padding-left: var(--gutter);
    padding-right: var(--space-l);
    background: var(--paper);
    border-radius: 0 0 var(--radius-m) 0;
    box-shadow: 0 10px 26px -14px rgba(27, 33, 29, 0.5);
  }

  .masthead__logo img { height: var(--logo-h); }

  .masthead__drawer {
    position: static;
    inset: auto;
    background: none;
    border: 0;
    box-shadow: none;
    padding: 0;
    max-height: none;
    overflow: visible;

    opacity: 1;
    visibility: visible;
    transform: none;

    display: flex;
    align-items: center;
    gap: var(--space-l);
  }

  .nav__list {
    flex-direction: row;
    align-items: center;
    gap: var(--space-m);
  }

  .nav__item {
    border-bottom: 0;
    position: relative;
  }

  .nav__row { gap: 0; }

  .nav__link {
    flex: 0 0 auto;
    padding: 0;
    font-size: var(--step--1);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
  }

  /* Signature: the active page is marked with a peak, not an underline. */
  .nav__link[aria-current="page"] {
    color: var(--pine);
  }

  .nav__link[aria-current="page"]::after {
    content: "";
    display: block;
    width: 0;
    height: 0;
    margin: 6px auto 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid var(--brass);
  }

  .nav__disclosure {
    width: auto;
    height: auto;
    margin-left: var(--space-3xs);
    pointer-events: none;   /* hover opens it on desktop; button is for keyboards */
  }

  .nav__disclosure svg { width: 9px; height: 9px; }

  /* Submenu becomes a dropdown panel */
  .submenu {
    position: absolute;
    top: calc(100% + 18px);
    left: 50%;
    translate: -50% 0;
    display: block;
    min-width: 250px;
    background: var(--paper);
    border-radius: var(--radius-m);
    box-shadow: var(--shadow-l);
    border-top: 3px solid var(--brass);
    padding: var(--space-2xs);

    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity var(--speed) var(--ease),
                transform var(--speed) var(--ease),
                visibility var(--speed) var(--ease);
  }

  /* Invisible bridge so the pointer can travel from link to panel */
  .submenu::before {
    content: "";
    position: absolute;
    inset: -18px 0 100% 0;
  }

  .nav__item--has-menu:hover .submenu,
  .nav__item--has-menu:focus-within .submenu,
  .submenu.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .submenu__inner { padding-bottom: 0; }

  .submenu__link {
    padding: var(--space-2xs) var(--space-s);
    border-left: 0;
    border-radius: var(--radius-s);
    font-size: var(--step--1);
    color: var(--ink);
    white-space: nowrap;
  }

  .submenu__link:hover {
    background: var(--bone);
    color: var(--pine);
  }

  .submenu__link[aria-current="page"] {
    background: var(--bone);
    color: var(--pine);
    font-weight: 600;
  }

  .masthead__actions {
    flex-direction: row;
    align-items: center;
    gap: var(--space-m);
    padding-top: 0;
  }

  .masthead__phone { font-size: var(--step-0); }
}

/* Five nav items, a phone number and a button won't all fit the moment the
   desktop bar appears. The phone waits until there's room; below this it's
   still in the mobile drawer, the footer, and every CTA on the page. */
@media (min-width: 1100px) and (max-width: 1319px) {
  .masthead__phone { display: none; }
}

/* ==========================================================================
   HEADER — overlay variant
   Add class="overlay-header" to <body> on pages whose hero is a full-bleed
   image. The header floats over the hero, then turns solid on scroll.
   ========================================================================== */

.overlay-header #header {
  position: fixed;
  inset: 0 0 auto 0;
}

.overlay-header .masthead {
  background: transparent;
  border-bottom-color: transparent;
}

/* Only needed below the shelf breakpoint, where the mark sits directly on
   the photo. Once the shelf exists, the real logo shows in brand colour. */
.overlay-header .masthead__logo img {
  filter: brightness(0) invert(1);
}

@media (min-width: 1100px) {
  .overlay-header .masthead__logo img { filter: none; }
}

@media (min-width: 1100px) {
  .overlay-header .nav__link,
  .overlay-header .masthead__phone { color: var(--paper); }
  .overlay-header .nav__link:hover,
  .overlay-header .masthead__phone:hover { color: var(--brass-soft); }
}

.overlay-header .masthead__toggle span { background: var(--paper); }

/* Once scrolled, the overlay header resolves into the normal solid one */
.overlay-header #header.is-stuck .masthead {
  background: var(--paper);
  border-bottom-color: var(--line);
}
.overlay-header #header.is-stuck .masthead__logo img { filter: none; }
.overlay-header #header.is-stuck .masthead__toggle span { background: var(--pine); }

@media (min-width: 1100px) {
  .overlay-header #header.is-stuck .nav__link,
  .overlay-header #header.is-stuck .masthead__phone { color: var(--pine); }
}

/* While the mobile drawer is open the bar must be solid regardless */
.overlay-header #header.nav-open .masthead { background: var(--paper); }
.overlay-header #header.nav-open .masthead__logo img { filter: none; }
.overlay-header #header.nav-open .masthead__toggle span { background: var(--pine); }

body.nav-open { overflow: hidden; }

/* ==========================================================================
   FOOTER
   ========================================================================== */

.colophon {
  position: relative;
  background: var(--pine-deep);
  color: var(--bone);
  margin-top: var(--space-3xl);
}

/* Signature: ridgeline along the top edge, echoing the logo's mountains. */
.colophon__ridge {
  position: absolute;
  bottom: 100%;
  left: 0;
  width: 100%;
  height: clamp(38px, 5vw, 64px);
  display: block;
  fill: var(--pine-deep);
  pointer-events: none;
}

.colophon__main {
  padding-block: var(--space-2xl) var(--space-xl);
  display: grid;
  gap: var(--space-xl);
  grid-template-columns: 1fr;
}

@media (min-width: 720px) {
  .colophon__main { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1000px) {
  .colophon__main {
    grid-template-columns: 1.5fr 1fr 1fr 1.2fr;
    gap: var(--space-l);
  }
}

.colophon__logo img {
  height: 64px;
  width: auto;
  filter: brightness(0) invert(1);
  margin-bottom: var(--space-s);
}

.colophon__blurb {
  color: var(--sage-light);
  font-size: var(--step--1);
  line-height: 1.7;
  max-width: 34ch;
}

.colophon__title {
  font-family: var(--font-display);
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--paper);
  margin-bottom: var(--space-s);
}

.colophon__list { display: grid; gap: var(--space-2xs); }

.colophon__list a,
.colophon__contact a {
  color: var(--sage-light);
  font-size: var(--step--1);
  text-decoration: none;
  transition: color var(--speed) var(--ease);
}

.colophon__list a:hover,
.colophon__contact a:hover { color: var(--brass); }

.colophon__contact { display: grid; gap: var(--space-s); }

.colophon__contact-item {
  display: flex;
  gap: var(--space-2xs);
  font-size: var(--step--1);
  color: var(--sage-light);
  line-height: 1.5;
}

.colophon__contact-item svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  margin-top: 4px;
  stroke: var(--brass);
}

.colophon__contact strong {
  display: block;
  color: var(--paper);
  font-family: var(--font-display);
  font-size: var(--step-0);
}

/* ---- Bottom bar ---------------------------------------------------------- */

.colophon__base {
  border-top: 1px solid rgba(138, 174, 132, 0.22);
  padding-block: var(--space-m);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-s) var(--space-m);
  align-items: center;
  justify-content: space-between;
  font-size: var(--step--1);
  color: var(--sage-light);
}

.colophon__legal {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-m);
}

.colophon__legal a {
  color: var(--sage-light);
  text-decoration: none;
}
.colophon__legal a:hover { color: var(--brass); }

.colophon__license {
  font-variant-numeric: tabular-nums;
  color: var(--ink-faint);
}


/* ==========================================================================
   CONTACT RAIL
   Fixed to the right edge, vertically centred. Lives in the footer partial
   so it lands on every page; position:fixed makes its DOM location moot.
   ========================================================================== */

.rail {
  position: fixed;
  top: 50%;
  right: var(--space-s);
  transform: translateY(-50%);
  z-index: 90;                    /* under the header (100) so the drawer wins */
  display: flex;
  flex-direction: column;
  align-items: flex-end;          /* labels expand leftward, not off-screen */
  gap: var(--space-2xs);
  transition: opacity var(--speed) var(--ease),
              visibility var(--speed) var(--ease);
}

.rail__link {
  display: inline-flex;
  align-items: center;
  height: 52px;
  border-radius: 999px;
  background: var(--pine);
  color: var(--paper);
  text-decoration: none;
  box-shadow: var(--shadow-m);
  transition: background-color var(--speed) var(--ease);
}

.rail__link:hover { background: var(--brass); }

.rail__icon {
  width: 52px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}

.rail__icon svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Label sits before the icon in the DOM, so revealing it grows the pill to
   the left. Three icons with no words is a guessing game otherwise. */
.rail__label {
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: var(--step--1);
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: max-width 260ms var(--ease),
              opacity 180ms var(--ease),
              padding-left 260ms var(--ease);
}

.rail__link:hover .rail__label,
.rail__link:focus-visible .rail__label {
  max-width: 14rem;
  opacity: 1;
  padding-left: var(--space-m);
}

/* Out of the way while the mobile drawer is open */
body.nav-open .rail {
  opacity: 0;
  visibility: hidden;
}

@media (max-width: 640px) {
  .rail { right: var(--space-2xs); gap: 6px; }
  .rail__link { height: 46px; }
  .rail__icon { width: 46px; }
  .rail__icon svg { width: 19px; height: 19px; }
  /* No hover on touch — the labels would never show, so don't reserve for them */
  .rail__label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .rail__label { transition: none; }
}

@media print {
  .rail { display: none; }
}