/* The section itself fills the viewport behind the transparent fixed header. */
.site-header { background: transparent; color: #fff; transition: none; }
.site-header::before { display: none; }
.header-screen-edge { display: none; }
/* A soft fade starts below the header and reaches full strength at the
   menu/logo centre, keeping the video and approaching content visible. */
.site-header::after {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: calc(100% + 24px);
  z-index: -1;
  pointer-events: none;
  background: transparent;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  --header-blur-curve-mask: linear-gradient(
    to bottom,
    #000 0,
    #000 calc((100% - 24px) / 2),
    rgba(0, 0, 0, .95) 43%,
    rgba(0, 0, 0, .8) 50%,
    rgba(0, 0, 0, .6) 58%,
    rgba(0, 0, 0, .35) 67%,
    rgba(0, 0, 0, .14) 78%,
    rgba(0, 0, 0, .04) 90%,
    transparent 100%
  );
  -webkit-mask-image: var(--header-blur-curve-mask);
  mask-image: var(--header-blur-curve-mask);
}
.site-header.is-hero-transparent::after {
  opacity: 0;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  -webkit-mask-image: none;
  mask-image: none;
}
.site-header[data-theme="light"] { color: var(--ink); }
.site-header .header-logo { transition: none; }
/* The transition controller owns the destination theme while the old and new
   chapters overlap. This prevents a stale React paint from flashing the
   outgoing header colour during the reveal. */
html[data-header-theme="dark"] .site-header:not(.is-open) { color: #fff; }
html[data-header-theme="light"] .site-header:not(.is-open) { color: var(--ink); }
html[data-header-theme="dark"] .site-header:not(.is-open) .header-logo--black,
html[data-header-theme="light"] .site-header:not(.is-open) .header-logo--white { opacity: 0; }
html[data-header-theme="dark"] .site-header:not(.is-open) .header-logo--white,
html[data-header-theme="light"] .site-header:not(.is-open) .header-logo--black { opacity: 1; }
.chapter-transition__wash, .contact-transition__wash { inset: 0; }
:root { --chapter-height: 100svh; }
:root { --header-clearance: calc(var(--chapter-header) + clamp(24px, 4svh, 46px)); }
#contact-form { scroll-margin-top: var(--header-clearance); }
html.homepage-scroll, html.chapter-scroll { scroll-padding-top: 0; }
.homepage-scroll .homepage > .hero,
.chapter-scroll .page-shell > .page-intro { scroll-margin-top: 0; }
.homepage-scroll .homepage > .hero { min-height: 100svh; }

.homepage-scroll .homepage > :is(.selected-work, .studio-section, .partners-section, .contact-cta),
.chapter-scroll .page-shell > :is(.agency-chapter, .agency-editorial, .portfolio, .contact-cta) {
  min-height: 100svh;
  padding-top: calc(var(--chapter-header) + var(--section-space));
}

/* Match the shared invitation's route-specific selectors so its padding shorthand
   cannot pull the first label back into the fixed navigation area. */
.contact-cta.container,
html.homepage-scroll .homepage > .contact-cta.container,
html.chapter-scroll .page-shell > .contact-cta.container {
  padding-top: var(--header-clearance);
}
html.agency-scroll .page-shell > :is(.studio-portrait, .agency-editorial),
html.work-scroll .work-page > .portfolio {
  padding-top: var(--header-clearance);
}
main.page-shell > :is(.service-details, .related-work, .case-overview, .case-story, .case-visuals, .case-related) {
  padding-top: max(var(--header-clearance), clamp(40px, 6vw, 120px));
}
/* Keep the natural-flow fallbacks below the header too. */
@media (max-height: 600px), (prefers-reduced-motion: reduce) {
  .homepage-scroll .home-expertise__stage,
  .expertise-scroll .expertise-sequence__stage,
  .expertise-scroll .approach-track > .approach-section {
    padding-top: var(--header-clearance);
  }
}
@media (min-height: 601px) and (prefers-reduced-motion: no-preference) {
  .homepage-scroll .home-expertise__stage,
  .expertise-scroll .expertise-sequence__stage,
  .expertise-scroll .approach-track > .approach-section {
    top: 0;
    height: 100svh;
    min-height: 100svh;
    padding-top: calc(var(--chapter-header) + var(--section-space));
    background: inherit;
  }
  .expertise-scroll .approach-track > .approach-section { background: #000; }
}

/* With viewport-fit=cover, blur can paint from the physical screen edge while
   the logo, controls and section clearances stay below the status-bar safe area. */
@media (max-width: 767px), (max-width: 1024px) and (hover: none) and (pointer: coarse) {
  :root {
    --mobile-safe-top: env(safe-area-inset-top, 0px);
    --mobile-header-base: 76px;
    --chapter-header: calc(var(--mobile-header-base) + var(--mobile-safe-top));
    --gutter: max(clamp(22px, 4.4vw, 76px), env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  }
  .site-header {
    padding-top: calc(20px + var(--mobile-safe-top));
  }
  .site-header .brand-logo {
    top: calc(50% + var(--mobile-safe-top) / 2);
  }
  .site-header::after {
    /* Keep the safe area fully blurred; the existing fade still starts around
       the controls instead of moving upward into the status bar. */
    --header-blur-curve-mask: linear-gradient(
      to bottom,
      #000 0,
      #000 calc(var(--mobile-safe-top) + (100% - var(--mobile-safe-top) - 24px) / 2),
      rgba(0, 0, 0, .95) calc(var(--mobile-safe-top) + (100% - var(--mobile-safe-top)) * .43),
      rgba(0, 0, 0, .8) calc(var(--mobile-safe-top) + (100% - var(--mobile-safe-top)) * .50),
      rgba(0, 0, 0, .6) calc(var(--mobile-safe-top) + (100% - var(--mobile-safe-top)) * .58),
      rgba(0, 0, 0, .35) calc(var(--mobile-safe-top) + (100% - var(--mobile-safe-top)) * .67),
      rgba(0, 0, 0, .14) calc(var(--mobile-safe-top) + (100% - var(--mobile-safe-top)) * .78),
      rgba(0, 0, 0, .04) calc(var(--mobile-safe-top) + (100% - var(--mobile-safe-top)) * .90),
      transparent 100%
    );
  }
  .mobile-nav {
    max-height: calc(100svh - var(--chapter-header) - 16px);
    max-height: calc(100dvh - var(--chapter-header) - 16px);
    overflow-y: auto;
    overscroll-behavior-y: contain;
    padding-bottom: calc(30px + env(safe-area-inset-bottom, 0px));
  }
}
@media (max-width: 767px) {
  :root { --mobile-header-base: 70px; }
}

/* Safari samples a fixed, unfiltered color at the viewport edge for its
   status bar. Keep that surface separate from the blur and fade below it. */
@supports (-webkit-touch-callout: none) and (color: contrast-color(black)) {
  @media (max-width: 767px), (max-width: 1024px) and (hover: none) and (pointer: coarse) {
    .site-header { --header-edge-color: var(--black); }
    .site-header[data-contact-at-edge] { --header-edge-color: var(--coral); }

    .header-screen-edge {
      display: block;
      position: fixed;
      inset: 0 0 auto;
      z-index: 0;
      height: max(12px, calc(var(--mobile-safe-top) + 4px));
      background-color: var(--header-edge-color);
      pointer-events: none;
    }
    .header-screen-edge::after {
      content: '';
      position: absolute;
      inset: 100% 0 auto;
      height: 8px;
      background: linear-gradient(var(--header-edge-color), transparent);
    }
  }
}
