/* ==========================================================================
   BASE — reset, typography defaults, layout primitives, motion utilities.
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Fixed header must not swallow anchor targets */
  scroll-padding-top: var(--header-h);
}

/* Note: the pinned gallery deliberately does NOT use CSS scroll-snap. Snap
   targets at each project trap the page at the first and last one — past the
   final target there is nothing further within the proximity threshold, so
   every attempt to scroll on gets pulled back. The gallery does its own
   settling instead; see initGallery in main.js. */

body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-display);
  font-size: var(--t-body);
  line-height: var(--leading-body);
  letter-spacing: var(--tracking-tight);
  font-weight: 400;
  /* Stack Sans Headline ships one weight — refuse smeared synthetic bold and
     build hierarchy from scale, case and tracking instead. */
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img,
svg,
video {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
  background-color: var(--c-beige);
}

/* Any author `display` above outranks the UA sheet's [hidden] rule, so an
   element carrying the attribute stays visible. State it once here instead of
   patching it per component. */
[hidden] {
  display: none !important;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  letter-spacing: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

ul,
ol {
  list-style: none;
}

h1,
h2,
h3,
h4 {
  font-weight: 400;
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-display);
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

::selection {
  background: var(--c-cyan);
  color: var(--c-black);
}

:focus-visible {
  outline: 2px solid var(--c-cyan);
  outline-offset: 4px;
}

/* --------------------------------------------------------------------------
   Layout primitives
   -------------------------------------------------------------------------- */

.shell {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--pad-x);
}

/* 12-column editorial grid. Every section composes on this. */
.grid12 {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--gutter);
}

.section {
  padding-block: var(--section-y);
}

.rule {
  border: 0;
  border-top: 1px solid var(--c-rule);
}

/* --------------------------------------------------------------------------
   Type utilities
   -------------------------------------------------------------------------- */

/* Small uppercase meta label — the connective tissue of the whole layout. */
.label {
  font-size: var(--t-small);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  line-height: 1.2;
  color: var(--fg-muted);
}

.label--fg {
  color: var(--fg);
}

.label--micro {
  font-size: var(--t-micro);
}

.display {
  display: block;
  font-size: var(--t-display);
  line-height: var(--leading-display);
  letter-spacing: var(--tracking-display);
  text-transform: uppercase;
}

.heading-xl {
  font-size: var(--t-h2);
  line-height: 0.94;
  letter-spacing: var(--tracking-display);
  text-transform: uppercase;
}

.statement {
  font-size: var(--t-statement);
  line-height: 1.06;
  letter-spacing: var(--tracking-display);
  text-wrap: balance;
}

.lead {
  font-size: var(--t-lead);
  line-height: 1.35;
}

.muted {
  color: var(--fg-muted);
}

.accent {
  color: var(--accent);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 200;
  padding: 0.75rem 1.25rem;
  background: var(--c-black);
  color: var(--c-offwhite);
  font-size: var(--t-small);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  transform: translateY(-110%);
  transition: transform var(--dur-fast) var(--ease-out);
}

.skip-link:focus-visible {
  transform: translateY(0);
  outline-offset: -4px;
}

/* --------------------------------------------------------------------------
   Scroll reveal — opt in with [data-reveal], stagger with --d.

   Every hidden start-state is scoped to .js (set by an inline script in the
   head), so with JavaScript off nothing is ever stuck invisible.
   -------------------------------------------------------------------------- */

/* :where(.js) contributes zero specificity, so these start-states never win
   a cascade fight with the hover/active rules in components.css. */
:where(.js) [data-reveal] {
  opacity: 0;
  transform: translate3d(0, 1.75rem, 0);
  transition:
    opacity var(--dur-slow) var(--ease-out) var(--d, 0ms),
    transform var(--dur-slow) var(--ease-out) var(--d, 0ms);
  will-change: opacity, transform;
}

:where(.js) [data-reveal="fade"] {
  transform: none;
}

:where(.js) [data-reveal].is-visible {
  opacity: 1;
  transform: none;
}

/* Headings wait for the line-splitter so they never flash unmasked. */
:where(.js) [data-split] {
  opacity: 0;
  transition: opacity var(--dur-fast) linear;
}

:where(.js) [data-split].is-split {
  opacity: 1;
}

/* Line-by-line masked reveal for oversized headings (spans injected by JS). */
.line-mask {
  display: block;
  overflow: hidden;
}

.line-mask > span {
  display: block;
  transform: translate3d(0, 110%, 0);
  transition: transform var(--dur-slow) var(--ease-out) var(--d, 0ms);
  will-change: transform;
}

.is-visible .line-mask > span,
.line-mask.is-visible > span {
  transform: none;
}

/* Full-bleed media reveal: the frame wipes open, the image settles from a
   slight over-scale. Used by every image on the page. */
.media {
  position: relative;
  overflow: hidden;
  background: var(--c-beige);
}

.media :is(img, video) {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--dur-image) var(--ease-image) var(--d, 0ms);
}

/* The wipe is a panel, not a clip-path on the frame itself: clipping the
   observed element collapses its intersection rect and IntersectionObserver
   would never fire. */
:where(.js) .media[data-media]::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background: var(--bg);
  transform-origin: bottom;
  transition: transform var(--dur-image) var(--ease-image) var(--d, 0ms);
  pointer-events: none;
}

:where(.js) .media[data-media] :is(img, video) {
  transform: scale(1.14);
}

.media[data-media].is-visible::before {
  transform: scaleY(0);
}

.media[data-media].is-visible :is(img, video) {
  transform: scale(1);
}

/* Subtle tonal overlay — the only permitted gradient. */
.media::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(
    to top,
    color-mix(in srgb, var(--c-black) 26%, transparent),
    transparent 46%
  );
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-out);
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Reduced motion — strip every transform, keep the content
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  [data-reveal],
  .line-mask > span {
    opacity: 1;
    transform: none;
  }

  .media[data-media]::before {
    display: none;
  }

  .media :is(img, video) {
    transform: none;
  }
}
