/* ==========================================================================
   ItemSpan — Layout
   --------------------------------------------------------------------------
   Containers, the site header, and the site footer. These three things appear
   on every page and are identical everywhere, so they live together.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Containers
   --------------------------------------------------------------------------
   `min(100% - gutter*2, max)` is the whole responsive story in one line: the
   container is as wide as the screen minus the gutters, until it hits its max
   width, after which it centres. No media queries required.
   -------------------------------------------------------------------------- */

.container {
  width: min(100% - (var(--gutter) * 2), var(--container-max));
  margin-inline: auto;
}

.container-wide {
  width: min(100% - (var(--gutter) * 2), var(--container-wide));
  margin-inline: auto;
}

.container-narrow {
  width: min(100% - (var(--gutter) * 2), var(--container-narrow));
  margin-inline: auto;
}

/* Standard vertical rhythm between major page sections. */
.section {
  padding-block: var(--space-9);
}

.section-tight {
  padding-block: var(--space-7);
}

/* Pale green band used to separate sections without drawing a line. */
.section-mist {
  background: var(--mist);
}

/* --------------------------------------------------------------------------
   Site header
   --------------------------------------------------------------------------
   Sticky, with a translucent blurred backdrop. It condenses on scroll: the
   `.is-scrolled` class is added by js/site.js once the page moves past 40px.
   -------------------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(252, 253, 251, 0.85);
  backdrop-filter: blur(12px) saturate(150%);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  transition: box-shadow var(--duration-base) var(--ease);
}

.site-header.is-scrolled {
  box-shadow: 0 1px 0 var(--border-soft), 0 6px 24px var(--ink-a06);
}

.header-inner {
  width: min(100% - (var(--gutter) * 2), var(--container-wide));
  height: 92px;
  margin-inline: auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-6);
  transition: height var(--duration-base) var(--ease);
}

.site-header.is-scrolled .header-inner {
  height: 76px;
}

/* The gold hairline that runs the full width under the header. It is the one
   place gold appears on every page, and it is the signature of the brand. */
.gold-rule {
  height: 1px;
  background: var(--gold);
}

/* --- Brand lockup --- */

.brand {
  width: fit-content;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 1.85rem;
  line-height: 1;
  font-weight: var(--weight-semibold);
  letter-spacing: -0.015em;
  color: var(--ink);
}

.brand img {
  width: 56px;
  height: 42px;
  object-fit: contain;
  transition: transform var(--duration-base) var(--ease);
}

.brand:hover img {
  transform: translateX(2px);
}

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

.desktop-nav {
  display: flex;
  align-items: stretch;
  gap: 52px;
  height: 100%;
}

.desktop-nav a {
  position: relative;
  display: flex;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
  font-weight: 520;
}

/* Underline grows from nothing on hover and stays put on the current page.
   scaleX is animated rather than width because transforms don't cause reflow. */
.desktop-nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 19px;
  height: 2px;
  border-radius: 2px;
  background: var(--evergreen);
  transform: scaleX(0);
  transition: transform var(--duration-fast) var(--ease);
}

.desktop-nav a:hover::after,
.desktop-nav a[aria-current="page"]::after {
  transform: scaleX(1);
}

.header-cta {
  justify-self: end;
}

/* Hidden on desktop, shown at the 820px breakpoint at the bottom of this file. */
.menu-button,
.mobile-nav {
  display: none;
}

/* --------------------------------------------------------------------------
   Site footer
   -------------------------------------------------------------------------- */

.site-footer {
  margin-top: var(--space-9);
  border-top: 1px solid var(--border-soft);
  background: var(--mist);
}

.footer-inner {
  width: min(100% - (var(--gutter) * 2), var(--container-max));
  margin-inline: auto;
  padding: var(--space-7) 0 var(--space-6);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-6) 72px;
  align-items: start;
}

.footer-nav {
  justify-self: end;
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
}

.footer-nav a {
  text-decoration: none;
  font-size: var(--text-small);
  font-weight: var(--weight-medium);
}

.footer-nav a:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.footer-meta {
  grid-column: 1 / -1;
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: var(--space-5);
  flex-wrap: wrap;
}

.footer-meta p {
  font-size: var(--text-tiny);
  line-height: 1.5;
}

/* ==========================================================================
   Responsive
   --------------------------------------------------------------------------
   Two breakpoints only. 1080px reflows multi-column page layouts; 820px is
   where the desktop nav is replaced by the mobile menu.
   ========================================================================== */

@media (max-width: 820px) {
  :root {
    --gutter: 16px;
  }

  .header-inner {
    height: 76px;
    grid-template-columns: 1fr auto;
  }

  .site-header.is-scrolled .header-inner {
    height: 68px;
  }

  .brand {
    font-size: 1.55rem;
  }

  .brand img {
    width: 45px;
    height: 36px;
  }

  /* Scoped to .site-header on purpose. `.header-cta` alone is one class, the
     same weight as the `.button` rule in components.css — and because
     components.css loads later, `.button { display: inline-flex }` would win
     the tie and the desktop CTA would never hide. Two classes settles it. */
  .site-header .desktop-nav,
  .site-header .header-cta {
    display: none;
  }

  .menu-button {
    width: 48px;
    height: 48px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    display: grid;
    place-items: center;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease);
  }

  .menu-button:hover {
    background: var(--mist);
  }

  /* The icon swap is pure CSS driven off aria-expanded, so the button's
     accessible state and its appearance can never disagree. */
  .menu-button .icon-close,
  .menu-button[aria-expanded="true"] .icon-open {
    display: none;
  }

  .menu-button[aria-expanded="true"] .icon-close {
    display: block;
  }

  /* Toggled by js/site.js adding .is-open. */
  .mobile-nav {
    display: none;
    padding: var(--space-3) var(--space-4) var(--space-4);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    background: var(--canvas);
  }

  .mobile-nav.is-open {
    display: flex;
    animation: slide-down var(--duration-base) var(--ease);
  }

  .mobile-nav a:not(.button) {
    min-height: 50px;
    padding: 0 var(--space-2);
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    font-weight: 600;
  }

  .mobile-nav a[aria-current="page"] {
    color: var(--evergreen);
  }

  .mobile-nav .button {
    margin-top: var(--space-3);
  }

  .footer-inner {
    grid-template-columns: 1fr;
    gap: var(--space-5);
  }

  .footer-nav {
    justify-self: start;
    gap: var(--space-4) var(--space-5);
  }

  .footer-meta {
    flex-direction: column;
    gap: var(--space-2);
  }
}

@keyframes slide-down {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
