.opening__brand {
  margin-bottom: var(--space-sm);
  line-height: 0;
}

.opening__mark {
  height: clamp(3.5rem, 8vw, 6rem);
  width: auto;
  filter: var(--logo-filter);
  opacity: calc(1 - var(--hero-progress, 0) * 0.85);
  transform: scale(calc(1 - var(--hero-progress, 0) * 0.12));
  will-change: transform, opacity;
}

.media-frame--hero { aspect-ratio: 4 / 5; }
.media-frame--surface { aspect-ratio: 16 / 9; }
.media-frame--square { aspect-ratio: 1 / 1; }
.media-frame--portrait { aspect-ratio: 3 / 4; }
.media-frame--landscape { aspect-ratio: 5 / 4; }
.media-frame--wide { aspect-ratio: 4 / 3; }
.media-frame--tall { aspect-ratio: 2 / 3; }

.page-home {
  --chrome-bleed-top: 88px;
  --chrome-bleed-bottom: 96px;
}

.opening {
  --hero-header-pad: 3rem;
  --hero-end-w: min(calc(100vw - 2 * var(--gutter)), calc(var(--max) + 2 * var(--gutter)));
  --hero-end-h: calc(100dvh - 2 * var(--gutter) - var(--hero-header-pad));
  min-height: 155dvh;
  padding: 0;
  position: relative;
  width: 100%;
  max-width: none;
  margin: 0;
}

.opening__text {
  position: fixed;
  left: calc(var(--gutter) * 2);
  bottom: calc(var(--gutter) * 2);
  z-index: 3;
  max-width: clamp(18rem, 28vw, 26rem);
  opacity: min(1, calc(1 - var(--hero-progress, 0) * 1.4));
  transform: translateY(calc(var(--hero-progress, 0) * -48px));
  will-change: transform, opacity;
  pointer-events: none;
}

.opening.is-hero-done .opening__text {
  opacity: 0;
  visibility: hidden;
}

.opening__text .reveal {
  opacity: 1;
  transform: translateY(0);
}

.opening__text .copy-statement {
  margin-bottom: var(--space-sm);
  max-width: 11ch;
}

.opening__text .copy-note {
  text-shadow: 0 1px 18px rgba(0, 0, 0, 0.3);
}

:root[data-theme="dark"] .opening__text .copy-note {
  color: rgba(244, 243, 240, 0.84);
}

.opening__media {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.opening__media .media-frame {
  --hero-frame-w: calc(
    (1 - var(--hero-progress, 0)) * 100vw +
    var(--hero-progress, 0) * var(--hero-end-w)
  );
  --hero-frame-h: calc(
    (1 - var(--hero-progress, 0)) * 100dvh +
    var(--hero-progress, 0) * var(--hero-end-h)
  );
  --hero-inset: min(
    calc((100vw - var(--hero-frame-w)) / 2),
    calc((100dvh - var(--hero-frame-h)) / 2)
  );
  width: var(--hero-frame-w);
  height: var(--hero-frame-h);
  border-radius: min(var(--media-radius), var(--hero-inset));
  aspect-ratio: auto;
  pointer-events: auto;
  will-change: width, height, border-radius;
}

.opening__media .media-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(var(--paper-rgb), 0.42), rgba(var(--paper-rgb), 0) 54%),
    linear-gradient(0deg, rgba(var(--paper-rgb), 0.34), rgba(var(--paper-rgb), 0) 38%);
}

.opening__media .media-frame img {
  will-change: auto;
}

.scroll-scene__track {
  height: 220vh;
  position: relative;
}

.scroll-scene__sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: stretch;
  overflow: hidden;
}

.scroll-scene__zoom {
  transform: scale(calc(1.18 - var(--scene-progress, 0) * 0.18));
  will-change: transform;
}

.scroll-scene__fade {
  opacity: calc(0.35 + var(--scene-progress, 0) * 0.65);
  will-change: opacity;
}

.graph-study {
  --graph-cost: #9cc3ae;
  --graph-prod: #1f7a4d;
  margin-top: var(--space-md);
}

:root[data-theme="dark"] .graph-study {
  --graph-cost: #6f9a83;
  --graph-prod: #4fd394;
}

.graph-study__inner {
  box-sizing: border-box;
  position: relative;
  width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  padding: var(--gutter);
  padding-top: calc(var(--gutter) + 2rem);
  padding-bottom: calc(var(--gutter) + 3.5rem);
  max-width: calc(var(--max) + var(--gutter) * 2);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: var(--space-sm);
  overflow: hidden;
}

.graph-study__header {
  flex: 0 0 auto;
}

.graph-study__header {
  display: grid;
  gap: var(--space-xs);
  max-width: 52ch;
}

.graph-study__statement {
  font-size: clamp(1.75rem, 4vw, 3.25rem);
  font-weight: 300;
  letter-spacing: -0.03em;
  line-height: 1.08;
  max-width: 14ch;
}

.graph-study__support {
  max-width: 42ch;
  color: var(--muted);
}

.graph-study__stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100vw;
  max-width: 100vw;
  margin-left: calc(50% - 50vw);
  display: flex;
  align-items: center;
}

.graph-study__canvas {
  position: relative;
  width: 100%;
  height: 100%;
  max-height: min(440px, 36dvh);
  min-height: 140px;
}

.graph-study__svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.graph-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.graph-line--cost {
  stroke: var(--graph-cost);
  stroke-width: 1.5;
}

.graph-line--prod {
  stroke: var(--graph-prod);
  stroke-width: 1.75;
}

.graph-marker__ring,
.graph-marker__core {
  vector-effect: non-scaling-stroke;
}

.graph-marker__ring {
  fill: none;
  stroke-width: 1.25;
}

.graph-marker__core {
  stroke: none;
}

.graph-marker--cost .graph-marker__ring { stroke: var(--graph-cost); }
.graph-marker--cost .graph-marker__core { fill: var(--graph-cost); }

.graph-marker--prod .graph-marker__ring { stroke: var(--graph-prod); }
.graph-marker--prod .graph-marker__core { fill: var(--graph-prod); }

.graph-study__footer {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-md);
  width: 100%;
  padding:
    1.25rem
    calc(var(--gutter) * 2)
    var(--gutter);
  background: linear-gradient(to top, var(--paper) 72%, transparent);
  pointer-events: none;
}

.graph-study__footer > * {
  pointer-events: auto;
}

.graph-study__legend {
  display: flex;
  flex: 0 0 auto;
  gap: var(--space-sm);
  color: var(--muted);
  font-size: var(--type-kicker);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.graph-legend__item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.graph-legend__item::before {
  content: "";
  width: 1.25rem;
  height: 2px;
}

.graph-legend__item--cost::before { background: var(--graph-cost); }
.graph-legend__item--prod::before { background: var(--graph-prod); }

.graph-study__active {
  display: flex;
  justify-content: flex-end;
  flex: 1 1 auto;
  min-width: 0;
  font-size: var(--type-kicker);
  letter-spacing: 0.04em;
  color: var(--muted);
  text-align: right;
  perspective: 720px;
}

.graph-active__panel {
  display: flex;
  gap: 0.75rem;
  align-items: baseline;
  max-width: 100%;
  min-width: 0;
  transform-origin: 50% 55%;
  backface-visibility: hidden;
  transition:
    transform 0.48s var(--ease),
    opacity 0.36s var(--ease);
}

.graph-active__panel.is-turning {
  transform: rotateX(82deg);
  opacity: 0;
}

.graph-active__date {
  flex: 0 0 auto;
  text-transform: uppercase;
  white-space: nowrap;
}

.graph-active__label {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--ink);
  font-size: var(--type-note);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.principles {
  padding: var(--space-xl) var(--gutter) 0;
  max-width: var(--max);
  margin: 0 auto;
}

.principles__grid {
  display: grid;
  gap: var(--space-lg);
}

.principle {
  display: grid;
  gap: var(--space-xs);
}

.principle:nth-child(1) { max-width: 26ch; }
.principle:nth-child(2) {
  margin-left: auto;
  margin-right: clamp(0rem, 14vw, 10rem);
  max-width: 22ch;
  text-align: right;
}
.principle:nth-child(3) {
  margin-left: clamp(1rem, 22vw, 18rem);
  max-width: 28ch;
}
.principle:nth-child(4) {
  margin-left: auto;
  max-width: 20ch;
}

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

.principle__text {
  font-size: var(--type-principle);
  font-weight: 300;
  letter-spacing: -0.025em;
  line-height: 1.3;
}

.gallery {
  padding: var(--space-xl) var(--gutter) 0;
  max-width: var(--max);
  margin: 0 auto;
}

.gallery__intro {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.gallery__intro .copy-statement {
  max-width: 10ch;
  font-size: clamp(1.75rem, 4vw, 3.5rem);
}

.gallery__grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--gutter);
  align-items: start;
}

.gallery__item:nth-child(1) { grid-column: 1 / 7; }
.gallery__item:nth-child(2) {
  grid-column: 7 / 13;
  margin-top: var(--space-lg);
}
.gallery__item:nth-child(3) {
  grid-column: 2 / 12;
  margin-top: var(--space-md);
}

.gallery__item .media-frame { aspect-ratio: 4 / 3; }
.gallery__item:nth-child(3) .media-frame { aspect-ratio: 16 / 9; }

.gallery__caption {
  display: flex;
  justify-content: space-between;
  gap: var(--space-sm);
  padding-top: 0.875rem;
  color: var(--muted);
}

.gallery__caption span:last-child {
  max-width: 28ch;
  text-align: right;
}

.contact {
  min-height: 70vh;
  min-height: 70dvh;
  padding: var(--space-xl) var(--gutter) var(--space-md);
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.contact__inner { max-width: 18ch; }
.contact .copy-kicker { margin-bottom: var(--space-sm); }
.contact .copy-statement { margin-bottom: var(--space-md); }

.contact__link {
  font-size: var(--type-note);
  display: inline-block;
  border-bottom: 1px solid var(--ink);
  padding-bottom: 0.15rem;
  transition: border-color var(--duration) var(--ease), color var(--duration) var(--ease);
}

.contact__link:hover {
  color: var(--muted);
  border-color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  .opening__text,
  .opening__mark {
    transform: none !important;
    opacity: 1 !important;
    will-change: auto;
  }

  .opening__media .media-frame {
    width: var(--hero-end-w);
    height: var(--hero-end-h);
    border-radius: var(--media-radius);
    will-change: auto;
  }

  .scroll-scene__zoom,
  .scroll-scene__fade {
    transform: none !important;
    opacity: 1 !important;
    will-change: auto;
  }

  .graph-active__panel {
    transition: none;
  }

  .graph-active__panel.is-turning {
    transform: none;
    opacity: 1;
  }

  .scroll-scene__track { height: auto; }
  .scroll-scene__sticky { position: relative; height: auto; }
  .graph-study__inner {
    height: auto;
    max-height: none;
    overflow: visible;
  }
  .contact__link { transition: none; }
}

@media (min-width: 769px) {
  .graph-study__legend {
    font-size: 0.6875rem;
  }

  .graph-active__label {
    font-size: 0.9375rem;
  }
}

@media (max-width: 960px) {
  .opening {
    --hero-header-pad: 2.5rem;
    --hero-end-h: calc(100dvh - 2 * var(--gutter) - var(--hero-header-pad));
  }

  .opening__text {
    left: calc(var(--gutter) * 1.5);
    right: calc(var(--gutter) * 1.5);
    bottom: calc(var(--gutter) * 1.5);
    max-width: none;
  }

  .opening__text .copy-statement { max-width: 12ch; }

  .principle:nth-child(n) {
    margin-left: 0;
    margin-right: 0;
    text-align: left;
    max-width: 32ch;
  }

  .gallery__grid {
    grid-template-columns: 1fr;
    gap: calc(var(--gutter) * 1.25);
  }

  .gallery__item:nth-child(n) {
    grid-column: 1;
    margin-top: 0;
  }

  .gallery__intro,
  .gallery__caption {
    flex-direction: column;
    align-items: flex-start;
  }

  .gallery__caption span:last-child { text-align: left; }
  .contact { min-height: auto; }
  .opening__mark { height: clamp(2.75rem, 14vw, 4rem); }
}

@media (max-width: 768px) {
  /* iOS Safari chrome fix only — keeps fullscreen sticky scenes intact. */
  .page-home::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--chrome-bleed-top);
    background-color: var(--paper);
    z-index: 0;
    pointer-events: none;
  }

  .page-home main {
    position: relative;
    z-index: 1;
  }

  .page-home #opening {
    margin-top: calc(-1 * var(--chrome-bleed-top));
  }

  .opening__media {
    top: calc(-1 * var(--chrome-bleed-top));
    height: calc(100dvh + var(--chrome-bleed-top) + var(--chrome-bleed-bottom));
  }

  .opening__media .media-frame {
    --hero-frame-h: calc(
      (1 - var(--hero-progress, 0)) * (100dvh + var(--chrome-bleed-top) + var(--chrome-bleed-bottom)) +
      var(--hero-progress, 0) * var(--hero-end-h)
    );
    --hero-inset: min(
      calc((100vw - var(--hero-frame-w)) / 2),
      calc((100dvh + var(--chrome-bleed-top) + var(--chrome-bleed-bottom) - var(--hero-frame-h)) / 2)
    );
  }

  .scroll-scene__track {
    height: 200vh;
  }

  .scroll-scene__sticky {
    top: calc(-1 * var(--chrome-bleed-top));
    height: calc(100dvh + var(--chrome-bleed-top) + var(--chrome-bleed-bottom));
    background: var(--paper);
    align-items: stretch;
  }

  .graph-study__inner {
    height: 100%;
    max-height: none;
    padding-top: calc(var(--gutter) + 2rem + var(--chrome-bleed-top));
    gap: var(--space-xs);
  }

  .graph-study__statement {
    font-size: clamp(1.5rem, 7vw, 1.75rem);
    line-height: 1.15;
  }

  .graph-study__support {
    font-size: 0.8125rem;
    line-height: 1.5;
  }

  .graph-study__canvas,
  .graph-study__svg {
    max-height: 28dvh;
    min-height: 120px;
  }

  .graph-study__inner {
    padding-bottom: calc(var(--gutter) + 4.5rem + var(--chrome-bleed-bottom));
  }

  .graph-study__footer {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs);
    padding:
      1rem
      calc(var(--gutter) * 1.5)
      var(--gutter);
  }

  .graph-study__active {
    justify-content: flex-start;
    text-align: left;
    width: 100%;
  }

  .graph-active__panel {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    transform-origin: 50% 40%;
  }

  .graph-active__date {
    white-space: nowrap;
  }

  .graph-active__label {
    width: 100%;
  }
}
