/* ==========================================================================
   Shared components
   ========================================================================== */

/* --------------------------------------------------------------------------
   Button
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.8em 1.4em;
  border: 1.5px solid transparent;
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color var(--duration-fast) ease,
    border-color var(--duration-fast) ease,
    color var(--duration-fast) ease;
}

.btn--primary {
  background: var(--brand-green);
  color: var(--surface);

  &:hover {
    background: var(--brand-green-hover);
  }
}

.btn--secondary {
  border-color: var(--ink-900);
  color: var(--ink-900);

  &:hover {
    background: var(--ink-900);
    color: var(--surface);
  }
}

/* For dark backgrounds */
.btn--light {
  background: var(--surface);
  color: var(--ink-900);

  &:hover {
    background: var(--surface-alt);
  }
}

.btn--lg {
  padding: 1em 1.75em;
  font-size: var(--fs-base);
}

/* --------------------------------------------------------------------------
   Text link: underlined link with a sliding arrow
   -------------------------------------------------------------------------- */

.text-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--ink-900);
  text-decoration: underline;
  text-decoration-color: var(--brand-green);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 0.35em;

  &:hover .text-link__arrow {
    translate: 4px 0;
  }
}

.text-link__arrow {
  width: 1em;
  height: 1em;
  color: var(--brand-green);
  transition: translate var(--duration-fast) var(--ease-out);
}

/* --------------------------------------------------------------------------
   Eyebrow label and lead paragraph
   -------------------------------------------------------------------------- */

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--ink-700);

  &::before {
    content: "";
    flex-shrink: 0;
    width: 1.75rem;
    height: 2px;
    border-radius: 2px;
    background: var(--brand-gradient);
  }
}

.lead {
  font-size: var(--fs-md);
  color: var(--ink-700);
}

/* --------------------------------------------------------------------------
   Site header
   Full-bleed with a bottom border at the top of the page. Once scrolled it
   morphs into a floating, frosted pill, and stays until the visitor scrolls
   back to the top (nav.js toggles .is-scrolled).
   -------------------------------------------------------------------------- */

.site-header {
  /* One slow, soft curve for every part of the full-bleed <-> pill morph */
  --morph: 0.85s cubic-bezier(0.65, 0, 0.35, 1);

  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-header);
  /* Transparent sides so they can fade in when the header becomes a pill */
  border: 1px solid transparent;
  border-bottom-color: var(--line);
  border-radius: 0;
  transition:
    top var(--morph),
    left var(--morph),
    right var(--morph),
    border-radius var(--morph),
    border-color var(--morph),
    box-shadow var(--morph);

  /* Background lives on a pseudo-element: a backdrop-filter on the header
     itself would trap the fixed-position mobile menu inside the header box.
     It is always on, so content scrolling under the header never shows
     through while the shape morphs. */
  &::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    border-radius: inherit;
    background: rgb(255 255 255 / 0.82);
    backdrop-filter: blur(14px) saturate(1.4);
  }

  &.is-scrolled {
    /* Floating pill, centred, no wider than the content */
    top: var(--space-3);
    left: max(var(--gutter), calc((100% - 72rem) / 2));
    right: max(var(--gutter), calc((100% - 72rem) / 2));
    border-color: var(--line);
    border-radius: var(--radius-pill);
    box-shadow: var(--shadow-md);
  }
}

/* Set by nav.js until the page has loaded: the first state shows without animating */
.site-header.is-instant,
.site-header.is-instant::before,
.site-header.is-instant * {
  transition: none;
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  height: var(--header-height);
  transition:
    height var(--morph),
    width var(--morph),
    padding var(--morph);

  /* Inside the pill: tighter, with the button snug against the right end */
  .is-scrolled & {
    width: 100%;
    height: 3.75rem;
    padding-inline: var(--space-5) var(--space-2);
  }
}

.site-header__logo {
  flex-shrink: 0;
  border-radius: var(--radius-sm);

  img {
    width: auto;
    height: 3.25rem;
    transition: height var(--morph);
  }

  .is-scrolled & img {
    height: 2.5rem;
  }
}

/* --------------------------------------------------------------------------
   Site navigation
   Inline on desktop, full-screen panel on mobile.
   -------------------------------------------------------------------------- */

.site-nav {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  margin-left: auto;
}

.site-nav__list {
  position: relative;
  display: flex;
  gap: var(--space-1);

  /* Sliding pill: nav.js sets its position and width from the active or hovered link */
  &::before {
    content: "";
    position: absolute;
    inset-block: 0;
    left: 0;
    width: var(--pill-width, 0);
    translate: var(--pill-x, 0) 0;
    border-radius: var(--radius-pill);
    background: var(--brand-green-tint);
    opacity: var(--pill-opacity, 0);
    transition:
      translate 0.45s var(--ease-out),
      width 0.45s var(--ease-out),
      opacity var(--duration-fast) ease;
  }

  /* Used to place the pill without sliding (first paint, resize) */
  &.is-pill-instant::before {
    transition: none;
  }
}

.site-nav__link {
  position: relative;
  display: inline-flex;
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  color: var(--ink-700);
  font-size: var(--fs-sm);
  font-weight: 500;
  text-decoration: none;
  transition:
    color var(--duration-fast) ease,
    background-color var(--duration-fast) ease;

  &:hover,
  &[aria-current="page"] {
    color: var(--ink-900);
  }
}

/* Without JavaScript the pill can't move, so the link tints itself instead */
.site-nav__list:not(.has-pill) .site-nav__link:is(:hover, [aria-current="page"]) {
  background: var(--brand-green-tint);
}

/* --------------------------------------------------------------------------
   Menu toggle (mobile only)
   -------------------------------------------------------------------------- */

.menu-toggle {
  display: none;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  margin-left: auto;
  border-radius: var(--radius-pill);
}

.menu-toggle__bars {
  position: relative;
  width: 1.375rem;
  height: 0.75rem;

  &::before,
  &::after {
    content: "";
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    border-radius: 2px;
    background: var(--ink-900);
    transition:
      top var(--duration-fast) var(--ease-out),
      rotate var(--duration-fast) var(--ease-out);
  }

  &::before { top: 0; }
  &::after { top: calc(100% - 2px); }

  [aria-expanded="true"] & {
    &::before,
    &::after {
      top: calc(50% - 1px);
    }

    &::before { rotate: 45deg; }
    &::after { rotate: -45deg; }
  }
}

/* --------------------------------------------------------------------------
   Mobile layout
   -------------------------------------------------------------------------- */

@media (width < 60rem) {
  .site-header__logo img {
    height: 2.75rem;
  }

  .menu-toggle {
    display: grid;
  }

  .site-nav {
    position: fixed;
    inset: 0;
    z-index: -1;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: var(--space-6);
    padding: calc(var(--header-height) + var(--space-6)) var(--gutter) var(--space-6);
    overflow-y: auto;
    background: var(--surface);
    visibility: hidden;
    clip-path: inset(0 0 100% 0);
    transition:
      clip-path var(--duration-base) var(--ease-out),
      visibility 0s linear var(--duration-base);

    .is-menu-open & {
      visibility: visible;
      clip-path: inset(0);
      transition: clip-path var(--duration-base) var(--ease-out);
    }
  }

  .site-nav__list {
    flex-direction: column;
    gap: 0;

    &::before {
      display: none;
    }
  }

  .site-nav__item,
  .site-nav__cta {
    opacity: 0;
    translate: 0 1.5rem;
    transition:
      opacity var(--duration-fast) ease,
      translate var(--duration-fast) ease;

    /* Items rise in one after another once the panel opens */
    .is-menu-open & {
      opacity: 1;
      translate: 0 0;
      transition:
        opacity var(--duration-base) var(--ease-out),
        translate var(--duration-base) var(--ease-out);
      transition-delay: calc(var(--i, 0) * 60ms + 150ms);
    }
  }

  .site-nav__link {
    display: flex;
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    font-family: var(--font-display);
    font-size: var(--fs-xl);
    font-weight: 600;
    letter-spacing: var(--tracking-tight);
    color: var(--ink-900);

    &[aria-current="page"] {
      color: var(--brand-green);
    }
  }

  .site-nav__cta {
    width: 100%;
    padding-block: 1em;
    font-size: var(--fs-base);
  }
}

/* --------------------------------------------------------------------------
   Site footer (shared by every page)
   A links panel (sitemap columns and legal row) that scrolls up to uncover
   the brand wordmark and tagline beneath it.
   -------------------------------------------------------------------------- */

.site-footer {
  --footer-line: rgb(255 255 255 / 0.12);
  --footer-muted: rgb(255 255 255 / 0.55);
  --footer-text: rgb(255 255 255 / 0.82);

  /* The layer the brand sits on, a shade darker than the panel above it */
  --footer-beneath: #07130e;

  overflow: clip;
  background: var(--footer-beneath);
  color: var(--footer-text);

  /* Plain links only; buttons keep their own colours */
  a:not(.btn) {
    color: inherit;
    text-decoration: none;
  }
}

/* The links panel sits on top and scrolls away to uncover the brand */
.site-footer__panel {
  position: relative;
  z-index: 1;
  padding-top: var(--section-y);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  background: var(--surface-dark);
}

/* ---- Sitemap columns ---- */

.site-footer__columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-7) var(--space-6);
  padding-bottom: var(--space-8);

  @media (width >= 64rem) {
    grid-template-columns: 0.9fr 1fr 1.3fr 1fr 1.2fr;
  }

  ul {
    display: grid;
    gap: var(--space-3);
  }

  /* Links: brighten and underline from the left on hover */
  a:not(.btn) {
    background: linear-gradient(currentColor, currentColor) no-repeat 0 100% / 0 1px;
    transition:
      color var(--duration-fast) ease,
      background-size var(--duration-base) var(--ease-out);

    &:hover {
      color: var(--surface);
      background-size: 100% 1px;
    }
  }
}

.site-footer__heading {
  margin-bottom: var(--space-4);
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  color: var(--footer-muted);
}

.site-footer__address {
  margin-bottom: var(--space-3);
  font-style: normal;
  line-height: 1.7;
}

.site-footer__email {
  color: var(--surface);
  overflow-wrap: anywhere;
}

/* Phones: the contact block gets the full width so the email fits */
@media (width < 48rem) {
  .site-footer__column:last-child {
    grid-column: 1 / -1;
  }
}

/* ---- Legal row ---- */

.site-footer__legal {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-6);
  padding-block: var(--space-5);
  border-top: 1px solid var(--footer-line);
  font-size: var(--fs-sm);
  color: var(--footer-muted);
}

.site-footer__top-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--footer-text);
  transition: color var(--duration-fast) ease;

  svg {
    width: 1em;
    height: 1em;
    transition: translate var(--duration-fast) var(--ease-out);
  }

  &:hover {
    color: var(--surface);

    svg { translate: 0 -3px; }
  }
}

/* ---- Brand beneath the panel: wordmark and tagline ---- */

/* footer.js adds .is-revealing: the brand is then fixed to the bottom of the
   screen, and this wrapper (clipping it, at the brand's height) uncovers it as
   the page scrolls. Without it the brand is simply the last block. */
.site-footer__reveal.is-revealing {
  height: var(--reveal-height);
  clip-path: inset(0);

  .site-footer__brand {
    position: fixed;
    inset: auto 0 0;
  }
}

.site-footer__brand {
  container-type: inline-size;
  display: grid;
  gap: var(--space-4);
  padding: var(--space-9) var(--gutter) var(--space-8);
  background: var(--footer-beneath);
}

.site-footer__wordmark {
  display: flex;
  justify-content: space-between;
  max-width: none;
  /* Room for the "y" descender, so it clears the tagline below */
  padding-bottom: 0.22em;
  font-family: var(--font-brand);
  /* Sized so "KhyGen" in Audiowide spans the full width without overflowing */
  font-size: 22.6cqi;
  font-weight: 400;
  line-height: 0.9;
  letter-spacing: 0;

  /* One continuous brand gradient across all six letters */
  span {
    display: inline-block;
    /* Extra paint area below the line so descenders (the "y") keep their gradient;
       the negative margin cancels it out in the layout */
    padding-bottom: 0.2em;
    margin-bottom: -0.2em;
    background: var(--brand-gradient);
    background-size: 600% 100%;
    background-position: calc(var(--i) * 20%) 0;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
  }

  span:nth-child(1) { --i: 0; }
  span:nth-child(2) { --i: 1; }
  span:nth-child(3) { --i: 2; }
  span:nth-child(4) { --i: 3; }
  span:nth-child(5) { --i: 4; }
  span:nth-child(6) { --i: 5; }
}

.site-footer__brand-tagline {
  max-width: none;
  padding-left: 0.6cqi;
  font-family: var(--font-display);
  font-size: clamp(1.25rem, 0.5rem + 3.6cqi, 3.5rem);
  font-weight: 600;
  line-height: var(--lh-heading);
  letter-spacing: var(--tracking-tight);
  color: rgb(255 255 255 / 0.85);
}
