/* ==========================================================================
   Reset, typography, grid
   ========================================================================== */

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

html {
  font-size: var(--base-font-size);   /* 1rem = 10px */
  -webkit-text-size-adjust: 100%;
}

/* Lenis owns the scroll; the html element must not smooth-scroll natively. */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-text);
  font-size: 1.6rem;
  line-height: 1.3;
  letter-spacing: -0.02em;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4, p, figure, blockquote { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
/* height:auto is not optional once images carry width/height attributes. Those
   attributes set a PRESENTATIONAL height, so an <img width="2700" height="2160">
   constrained to 518px wide renders 518 x 2160 — correct width, natural height,
   vertically stretched. height:auto restores the intrinsic ratio while keeping
   the attributes doing their real job: reserving the right box before the file
   arrives. Element-level, so any component rule setting its own height wins. */
img, video, svg { display: block; max-width: 100%; height: auto; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }

::selection { background: var(--color-accent); color: var(--color-white); }

/* --- Type scale ----------------------------------------------------------
   Sizes match the reference (80/64/48/24/18/16/14/12 at 1600px) and scale
   fluidly below that. Display weights stay 500–550 — never bold.
   ------------------------------------------------------------------------ */

.t-display,
.t-h1 {
  font-family: var(--font-display);
  font-weight: 550;
  font-size: clamp(4.4rem, 5vw, 8rem);
  line-height: 1;
  letter-spacing: -0.03em;
}

.t-h2 {
  font-family: var(--font-display);
  font-weight: 550;
  font-size: clamp(3.6rem, 4vw, 6.4rem);
  line-height: 1;
  letter-spacing: -0.03em;
}

.t-h3 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2.8rem, 3vw, 4.8rem);
  line-height: 1;
  letter-spacing: -0.03em;
}

.t-lead {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2rem, 1.5vw, 2.4rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.t-body-lg {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.8rem;
  line-height: 1.2;
}

.t-body {
  font-size: 1.6rem;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

.t-small {
  font-size: 1.4rem;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.t-caption {
  font-size: 1.2rem;
  font-weight: 450;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

/* Eyebrow / meta label */
.t-eyebrow {
  font-size: 1.2rem;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  opacity: .6;
}

/* Cap-height trim: removes the font's built-in leading above the caps and
   below the baseline so headline blocks align to their glyphs, not their boxes. */
.lt::before,
.lt::after {
  content: "";
  display: block;
  height: 0;
}
.lt::before {
  margin-bottom: calc(
    ((var(--lt-cap-height) - var(--lt-ascender)) / var(--lt-units-per-em)) * 1em
  );
}
/* Trimmed to the deepest glyph, not to the baseline. Trimming the full
   descender is the textbook Capsize move, but it means an authored gap is
   measured from the baseline — so "Background" and "Jay Chung" put their g
   straight into the line underneath (measured ink gaps of 2.7px and 2.5px).
   Leaving --lt-descender-ink behind keeps headings hugging their glyphs while
   giving descenders somewhere to sit. Scales with font-size on its own, so
   the margins below headings stay the plain values they were authored as. */
.lt::after {
  margin-top: calc(
    ((var(--lt-descender) + var(--lt-descender-ink)) / var(--lt-units-per-em)) * 1em
  );
}

/* --- Grid ---------------------------------------------------------------- */

.container {
  width: 100%;
  padding-inline: var(--base-padding);
  margin-inline: auto;
}

.grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-columns), 1fr);
  gap: var(--gutter-width);
}

/* --- Line-reveal machinery ----------------------------------------------
   splitLines() in motion.js wraps each visual line in .line > .line__inner.
   The mask lives here so text is hidden before JS runs (no flash of content
   sliding in late), and is released if JS never runs at all.
   ------------------------------------------------------------------------ */

/* Display type runs at line-height 1, but the display font's content area is
   1.15em. That leaves negative half-leading of (1.15 - 1) / 2 = 0.075em, so
   descenders sit *outside* the line box and the mask shears them flat — every
   g, y, j and comma in the hero lost ~5px at 80px type.

   clip-path rather than overflow:hidden, because the mask has to reach *below*
   the box and overflow can only clip to it. Padding plus a negative margin was
   the obvious alternative, but the last line's compensation collapses against
   .lt::after's trim margin (collapsing takes the most-negative, not the sum),
   which left every trimmed headline 6px taller. clip-path has no layout cost
   at all, so the trim keeps hugging the baseline exactly as designed.

   The reveal is unaffected: the inner starts --title-from-y (1.9rem) low, so
   at any point mid-slide exactly that much ink is still hidden. Only the
   resting frame changes, which is the one that was wrong. */
.line {
  display: block;
  clip-path: inset(0 0 calc(var(--line-descender-pad) * -1) 0);
}
.line__inner {
  display: block;
  will-change: transform;
  transform: translate3d(0, var(--title-from-y), 0);
}
.no-js .line__inner { transform: none; }

/* --- Hover: label slides out, duplicate slides in ------------------------ */

.swap {
  position: relative;
  display: inline-block;
  overflow: hidden;
  vertical-align: bottom;
}
.swap__layer {
  display: block;
  transition: transform .4s var(--ease-snappy);
}
.swap__layer--in {
  position: absolute;
  inset: 0;
  transform: translate3d(-105%, 0, 0);
}
.swap:hover .swap__layer--out,
a:hover .swap .swap__layer--out,
button:hover .swap .swap__layer--out { transform: translate3d(105%, 0, 0); }
.swap:hover .swap__layer--in,
a:hover .swap .swap__layer--in,
button:hover .swap .swap__layer--in { transform: translate3d(0, 0, 0); }

/* --- Hover: underline wipes out and returns from the other edge ---------- */

.ul { position: relative; display: inline-block; }
.ul::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -0.2em;
  width: 100%;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right center;
  transition: transform .4s var(--ease-snappy);
}
.ul:hover::after,
a:hover > .ul::after { transform: scaleX(1); transform-origin: left center; }

/* --- Buttons ------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 1.2rem;
  padding: 1.4rem 2.4rem;
  border-radius: var(--radius-pill);
  background: var(--fg);
  color: var(--bg);
  font-size: 1.4rem;
  font-weight: 550;
  letter-spacing: -0.02em;
  transition: background .3s var(--ease-snappy), color .3s var(--ease-snappy);
}
.btn:hover { background: var(--color-accent); color: var(--color-white); }

.btn--ghost {
  background: transparent;
  color: var(--fg);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 30%, transparent);
}
.btn--ghost:hover { background: var(--fg); color: var(--bg); box-shadow: none; }

.btn__arrow { transition: var(--link-transition); }
.btn:hover .btn__arrow { transform: translateX(0.4rem); }

/* --- Accessibility ------------------------------------------------------- */

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

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

/* Everything scroll-driven is decorative. Reduced motion gets the same
   content, laid out statically. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  .line { overflow: visible; }
  .line__inner { transform: none !important; }
}
