@font-face {
  font-family: "Agrandir";
  src: url("assets/type/AgrandirGrotesk-Variable.ttf") format("truetype");
  font-weight: 100 900;
  font-stretch: 50% 200%;
  font-display: swap;
}

:root {
  --bg: #F9F4F0;
  --ink: #2C2721;
  --tile: #ECE4DB; /* image placeholder while it loads */
  --green: #176659;

  --font-display: "Agrandir", "Helvetica Neue", Arial, sans-serif;
  --font-text: "Work Sans", "Helvetica Neue", Arial, sans-serif;

  /* Side margins the collage keeps clear, so the chrome always has room */
  --gutter: clamp(62px, 7vw, 116px);
  --chrome-inset: clamp(20px, 2.6vw, 20px);

  /* Gap between the hero, each chapter and the outro (1 unit = 1% of page) */
  --section-gap: 16cqw;
  /* Gap between a chapter's opening (title + intro) and its first images */
  --head-gap: 9cqw;
}

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

html {
  background: var(--bg);
  color: var(--ink);
}

body {
  margin: 0;
  font-family: var(--font-text);
  font-weight: 300;
  line-height: 1.3;
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------
   Stage: the SVG line and the content share one coordinate space
   --------------------------------------------------------------- */

.stage {
  position: relative;
  overflow-x: clip;
}

.thread {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.thread__path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.25;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The padding is inside the container, so 1cqw (and every --x/--y below)
   measures the space between the gutters, not the whole window. */
.page {
  position: relative;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 var(--gutter);
  container-type: inline-size;
}

/* ---------------------------------------------------------------
   Chrome: logo bottom-up on the left, page name top-down on the right
   --------------------------------------------------------------- */

.chrome {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.chrome > * {
  position: absolute;
  top: var(--chrome-inset);
  pointer-events: auto;
  transition: opacity .35s ease;
}

/* The chrome is dark ink; the footer is green. They never overlap. */
.chrome.is-away > * {
  opacity: 0;
  pointer-events: none;
}

.chrome__logo {
  left: var(--chrome-inset);
  height: clamp(140px, 21svh, 225px);
}

.chrome__logo img {
  display: block;
  height: 100%;
  width: 50px;
}

.chrome__mark {
  display: block;
  right: var(--chrome-inset);
  height: auto;
  width: 50px;
  
}

/* ---------------------------------------------------------------
   Chapter tag: the name of the chapter, held at the top of the
   window while you scroll it. JS swaps the name at the next chapter.
   --------------------------------------------------------------- */

.chapter-tag {
  position: fixed;
  top: calc(var(--chrome-inset) + 15px);
  left: 0;
  right: 0;
  z-index: 4;
  /* the same track as .page, so the tag ends on the content's right edge */
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 max(var(--gutter), 20px);
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
  font-weight: 400;
  
}

.chapter-tag span {
  padding: 0.66em 1.05em;
  border: 1px solid currentColor;
  /* the collage can pass underneath, so the name keeps its own ground */
  background: var(--bg);
  font-size: clamp(13px, 1.15vw, 17px);
  line-height: 1;
  white-space: nowrap;
  /* the name leaves upwards and the next one arrives the same way */
  opacity: 0;
  translate: 0 -8px;
  transition: opacity .3s ease, translate .3s cubic-bezier(.16, 1, .3, 1);
}

.chapter-tag.is-in span {
  opacity: 1;
  translate: 0 0;
}

/* ---------------------------------------------------------------
   Hero: the whole first screen, the line only just breaking in
   --------------------------------------------------------------- */

.block.hero {
  height: 100svh;
  min-height: 620px;
}

.block > .hero__inner {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  translate: 0 -92%;
  width: auto;
}

.hero__title {
  margin: 0 0 clamp(28px, 4.2svh, 52px);
  font-family: var(--font-display);
  font-weight: 250;
  font-size: clamp(30px, 5.7cqw, 92px);
  line-height: 1.05;
  letter-spacing: -0.004em;
  word-spacing: 0.055em;
  text-align: center;
  text-wrap: balance;
}

.hero__cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(16px, 2cqw, 28px);
  width: min(100%, 56cqw);
  margin: 0 auto;
}

.hero__cols p {
  margin: 0;
  font-size: clamp(14px, 1.72cqw, 23px);
  line-height: 1.42;
  text-align: center;
  text-wrap: pretty;
  font-weight: 400;
}

/* ---------------------------------------------------------------
   Blocks: children are placed in units (1 unit = 1cqw = 1% of page)
   --------------------------------------------------------------- */

/* Quiet stretches between the hero, the chapters and the outro, where
   only the line carries the eye from one to the next. */
.page > * + * {
  margin-top: var(--section-gap);
}

.block {
  position: relative;
  height: calc(var(--h) * 1cqw);
}

/* The title and intro keep their distance from the collage that follows */
.block.head { margin-bottom: var(--head-gap); }

.block > * {
  position: absolute;
  left: calc(var(--x, 0) * 1cqw);
  top: calc(var(--y, 0) * 1cqw);
  width: calc(var(--w, 20) * 1cqw);
  margin: 0;
}

/* Nodes are expressed relative to their block so they survive layout changes */
.block > .node {
  left: calc(var(--x) * 1%);
  top: calc(var(--y) / var(--h) * 100%);
  width: 0;
  height: 0;
}

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

.block > .title {
  inset: 0;
  width: auto;
  font-family: var(--font-display);
  font-weight: 260;
  font-stretch: 100%;
  font-size: clamp(28px, 3.75cqw, 58px);
  line-height: 1.1;
  letter-spacing: -0.005em;
  
}

.title span {
  position: absolute;
  left: calc(var(--x) * 1cqw);
  top: calc(var(--y) * 1cqw);
  white-space: nowrap;
  
}

.kicker {
  font-weight: 400;
  font-size: clamp(12px, 1.3cqw, 17px);
  text-align: right;
}

.intro {
  font-size: clamp(14px, 1.45cqw, 20px);
  font-weight: 450;
}

.caption {
  font-size: clamp(12px, 1.22cqw, 17px);
  line-height: 1.25;
}

/* A text-only interlude between chapters: bigger than a caption, carried
   by the line itself rather than paired with an image. */
.statement {
  font-size: 18px;
  line-height: 1.35;
  font-weight: 450;
}

/* A statement is placed against the line, not against the page: --x is where
   the line runs at that height, and the box is anchored by the edge facing it,
   so the gap reads the same whichever side the text is on. The box shrink-wraps
   its text (--w is only the point it wraps at), so a short line sits as close
   to the thread as a full one. */
.block > .statement {
  width: max-content;
  max-width: calc(var(--w, 20) * 1cqw);
  left: calc((var(--x) + var(--gap, 3.5)) * 1cqw);
}

/* ...and this one hangs off the other side, so its right edge is the anchor. */
.block > .statement--left {
  left: auto;
  right: calc((100 - var(--x) + var(--gap, 3.5)) * 1cqw);
}

/* .statement--lead {
  color: color-mix(in srgb, currentColor 80%, transparent);
} */

/* ---------------------------------------------------------------
   Media: scales out of the nearest point on the line.
   JS sets transform-origin (that point), --i / --n (stagger),
   and the floating translate / rotate.
   --------------------------------------------------------------- */

.media {
  aspect-ratio: var(--r, 3 / 2);
  will-change: translate, scale;

  scale: 0;
  opacity: 0;
  /* closing: fold back into the line, last in first out */
  --out: calc((var(--n, 1) - 1 - var(--i, 0)) * 45ms);
  z-index: 0;
  transition:
    scale .7s cubic-bezier(.7, 0, .84, 0) var(--out),
    opacity .3s linear calc(var(--out) + .4s);
}

.is-open .media {
  scale: 1;
  opacity: 1;
  --in: calc(var(--i, 0) * 110ms);
  transition:
    scale 1.3s cubic-bezier(.16, 1, .3, 1) var(--in),
    opacity .25s linear var(--in);
}

/* The frame holds the crop, so it can grow from its own centre on hover
   while the figure keeps the transform-origin it scales out of the line with */
.media__frame {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--tile);
  transition: transform .55s cubic-bezier(.16, 1, .3, 1);
}

.media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  scale: 1.2;
  transition: scale .8s ease-in;
}

.is-open .media img {
  scale: 1;
  transition: scale 1.8s cubic-bezier(.16, 1, .3, 1) calc(var(--i, 0) * 110ms);
}

/* Hovering grows an image and brings it above the ones it overlaps */
@media (hover: hover) {
  .is-open .media:hover {
    z-index: 3;
  }

  .is-open .media:hover .media__frame {
    transform: scale(1.2);
  }
}

/* ---------------------------------------------------------------
   Typed text: the full text is always laid out (the untyped part is
   hidden), so lines never reflow while typing.
   --------------------------------------------------------------- */

.type__rest {
  visibility: hidden;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------------------------------------------------------------
   Outro: the line rests, then the invitation
   --------------------------------------------------------------- */

/* The invitation is the one block whose height follows its content: the
   sentence rewraps as the page narrows, and the button must stay inside. */
.block.outro {
  height: auto;
  min-height: calc(var(--h) * 1cqw);
  padding-bottom: 6cqw;
}

.block > .outro__inner {
  position: relative;
  left: 0;
  right: 0;
  top: auto;
  width: auto;
  padding-top: calc(var(--y) * 1cqw);
}

.outro__text {
  width: min(100%, 74cqw);
  margin: 0 auto clamp(30px, 4.1cqw, 50px);
  font-family: var(--font-display);
  font-weight: 336;
  font-size: clamp(36px, 3.97cqw, 48px);
  line-height: 1.12;
  letter-spacing: -0.004em;
  word-spacing: 0.04em;
  text-align: center;
  text-wrap: balance;
  /* the one text on the page that is not typed: it simply arrives */
  opacity: 0;
  translate: 0 12px;
  transition: opacity .8s ease, translate .8s cubic-bezier(.16, 1, .3, 1);
}

.is-open .outro__text {
  opacity: 1;
  translate: 0 0;
}

.outro__cta {
  display: block;
  width: max-content;
  margin: 0 auto;
  padding: clamp(11px, 1.05cqw, 16px) clamp(26px, 2.7cqw, 42px);
  background: var(--green);
  color: var(--bg);
  font-size: clamp(14px, 1.45cqw, 20px);
  text-decoration: none;
  font-weight: 400;
  /* follows the sentence above it in */
  opacity: 0;
  translate: 0 10px;
  transition: opacity .45s ease, translate .45s ease, background .25s ease;
}

.is-open .outro__cta {
  opacity: 1;
  translate: 0 0;
  transition-delay: .45s, .45s, 0s;
}

.outro__cta:hover,
.outro__cta:focus-visible {
  background: var(--ink);
}

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

/* Type sizes, weights and gaps below are the ones the live
   with-company.com footer uses, so the two read as one footer. */

.site-foot {
  /* shared by both footer rows, so their columns line up exactly */
  --foot-col-gap: clamp(28px, 3.5vw, 56px);
  position: relative;
  background: var(--green);
  color: var(--bg);
  font-weight: 400;
  padding: clamp(54px, 6.5vw, 104px) 0 clamp(26px, 2.8vw, 44px);
}

.site-foot__inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 max(var(--gutter), 20px);
}

.site-foot__top {
  display: grid;
  grid-template-columns: 1.9fr 1fr 1fr;
  align-items: start;
  gap: var(--foot-col-gap);
}

.site-foot__brand img {
  display: block;
  width: clamp(190px, 22vw, 338px);
  height: auto;
}

.site-foot__col {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.site-foot__col--contact { gap: 10px; }

.site-foot__label {
  margin: 0;
  font-size: 18px;
  font-weight: 400;
  line-height: 18.1px;
  text-transform: uppercase;
}

.site-foot__link {
  color: inherit;
  font-size: 16px;
  font-weight: 400;
  line-height: 18.1px;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: opacity .2s ease;
}

/* The address is set as a block of underlined lines; the underline is
   part of how it is drawn, so it stays put on hover. */
.site-foot__link--address { line-height: 22.4px; }

.site-foot__link:hover { opacity: .7; }

.site-foot__funding {
  margin-top: clamp(52px, 7.5vw, 124px);
}

.site-foot__funding p {
  margin: 0 0 8px;
  font-size: 12px;
  line-height: 16px;
}

.site-foot__funding img {
  display: block;
  width: clamp(250px, 25vw, 364px);
  height: auto;
}

/* Shares the column tracks above, so the socials line up under Contact us */
.site-foot__bottom {
  display: grid;
  grid-template-columns: 1.9fr 1fr 1fr;
  align-items: end;
  gap: clamp(24px, 3vw, 48px) var(--foot-col-gap);
  margin-top: clamp(30px, 3.6vw, 56px);
}

.site-foot__legal {
  display: flex;
  flex-wrap: wrap;
  gap: 41px;
  margin: 0;
  font-size: 12px;
  line-height: 16px;
}

.site-foot__legal a {
  color: inherit;
  text-decoration: none;
  transition: opacity .2s ease;
}

.site-foot__legal a:hover { opacity: .7; }

.socials {
  grid-column: 3;
  display: flex;
  gap: 40px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.socials a {
  display: block;
  transition: opacity .2s ease;
}

.socials a:hover { opacity: .6; }

.socials img {
  display: block;
  width: auto;
  height: 30px;
}

/* ---------------------------------------------------------------
   Small screens: one column, the collage stacked and overlapping
   --------------------------------------------------------------- */

/* Up to tablet portrait: below this the collage's absolute placement
   runs out of room and the type starts to collide with itself. */
@media (max-width: 900px) {
  :root {
    /* The two marks sit in these lanes; the column never reaches them */
    --chrome-inset: clamp(8px, 1.2vw, 16px);
    /* clears the 36px marks plus the few px the collage drifts */
    --gutter: clamp(54px, 7vw, 76px);
    --section-gap: 58px;
    /* the reading column, so the measure stays sane on a tablet */
    --col: 680px;
  }

  .page { max-width: var(--col); }

  /* Chrome: small marks held against the two lateral edges */
  .chrome__logo {
    left: var(--chrome-inset);
    height: auto;
  }

  .chrome__logo img {
    width: 36px;
    height: auto;
  }

  .chrome__mark {
    display: block;
    right: var(--chrome-inset);
    width: 36px;
  }

  /* the tag ends on the column's right edge, not the window's */
  .chapter-tag { max-width: var(--col); padding: 0 var(--gutter); }
  .chapter-tag span { font-size: 12px; padding: 0.6em 0.9em; }

  /* ---- Hero ---- */

  .block.hero {
    height: 100svh;
    min-height: 560px;
    justify-content: center;
    padding: 0;
  }

  .block > .hero__inner {
    position: relative;
    top: auto;
    translate: none;
  }

  .hero__title { font-size: clamp(30px, 8.6vw, 44px); margin-bottom: 26px; }
  .hero__cols { gap: 18px; width: 100%; }
  .hero__cols p { font-size: 16px; line-height: 1.45; background: var(--bg); }

  /* ---- Blocks stack; the gutter comes from .page ---- */

  .block {
    height: auto;
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 26px 0;
  }

  .block > * {
    position: relative;
    left: auto;
    top: auto;
    width: auto;
  }

  /* the nodes still carry the thread, so they keep their placement */
  .block > .node { position: absolute; }

  .block.head { margin-bottom: 0; }
  .block > .title { position: relative; inset: auto; font-size: clamp(27px, 7.6vw, 36px); }

  .title span {
    position: relative;
    display: block;
    left: auto;
    top: auto;
    white-space: normal;
  }

  .title span + span { padding-left: 16%; }

  /* ---- Collage: wide, alternating, overlapping ---- */

  .media {
    width: 84%;
    align-self: flex-start;
    /* later images in a group sit on top of the ones before them */
    z-index: var(--i, 0);
  }

  .media:nth-of-type(even) { align-self: flex-end; }

  /* two images in a row overlap instead of queueing up (the 22px flex
     gap is cancelled first, so this is the real overlap) */
  .media + .media { margin-top: calc(-22px - 11%); }

  /* ---- Text: full column, and it keeps its own ground so the
     thread and the collage pass behind it ---- */

  .kicker, .intro, .caption, .statement, .block > .title {
    position: relative;
    z-index: 20;
    max-width: 100%;
    background: var(--bg);
    padding: 5px 0;
  }

  /* the line is no longer beside the text down here, so a statement
     stops being anchored to it and simply fills the column */
  .block > .statement,
  .block > .statement--left {
    width: auto;
    max-width: 100%;
    left: auto;
    right: auto;
  }

  .kicker { align-self: flex-end; font-size: 13px; text-align: right; }
  .intro { font-size: 16px; line-height: 1.45; }
  .caption { font-size: 15px; line-height: 1.45; }
  .statement { font-size: 18px; line-height: 1.4; }

  /* ---- Outro ---- */

  .block.outro { min-height: 0; padding: 50px 0 70px; }
  .block > .outro__inner {
    position: relative;
    left: auto; right: auto; top: auto;
    padding-top: 0;
    z-index: 20;
  }
  .outro__text {
    width: 100%;
    font-size: clamp(26px, 7.6vw, 36px);
    background: var(--bg);
    margin-bottom: 34px;
  }

  /* ---- Footer ---- */

  .site-foot__inner { max-width: var(--col); padding: 0 var(--gutter); }
  .site-foot__top { grid-template-columns: 1fr; gap: 36px; }
  .site-foot__funding { margin-top: 56px; }
  .site-foot__bottom { grid-template-columns: 1fr; justify-items: start; }
  .socials { grid-column: 1; grid-row: 1; gap: 28px; }
  .site-foot__legal { grid-row: 2; gap: 24px; }
}
/* ---------------------------------------------------------------
   Reduced motion: everything visible, nothing moves
   --------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .media, .media img, .media__frame { transition: none !important; }
  .chapter-tag span { transition: none !important; }
  .outro__text, .outro__cta { transition: none !important; }
}

/* ?debug in the URL shows nodes, group triggers and the pen height */
.debug circle { fill: #e5484d; }
.debug line { stroke: #e5484d; stroke-width: 1; stroke-dasharray: 4 4; }
.debug-tip {
  position: fixed;
  left: 0;
  right: 0;
  border-top: 1px dashed #3e63dd;
  pointer-events: none;
  z-index: 10;
}
