/* A single horizontal strip: the vertical scroll drives it sideways. */

:root {
  --paper: #e6e6e5;
  --ink: #121212;
  --on-photo: #ffffff;

  --gutter: clamp(16px, 4vw, 80px);
  --edge: 3vh;
  --gap: 6vw;
  --text: 15px;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.76, 0, 0.24, 1);

  color-scheme: light;
}

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

html {
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-x: none;
}

html.is-locked { overflow: hidden; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Inter Tight", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: var(--text);
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
img { display: block; max-width: 100%; }
h1, p { margin: 0; font: inherit; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 4px;
}

/* Text that rises out of a mask; .is-loaded / .is-active lift it into place */

.mask {
  display: block;
  overflow: hidden;
  padding-bottom: 0.06em;
  margin-bottom: -0.06em;
}

.mask > span {
  display: block;
  transform: translateY(105%);
  transition: transform 1100ms var(--ease-out);
}

.is-loaded .intro .mask > span { transform: none; }
.is-loaded .intro__title .mask:nth-child(2) > span { transition-delay: 90ms; }
.is-loaded .intro__count > span { transition-delay: 160ms; }

/* Navigation: fixed across the middle, inverted over photographs */

.nav {
  position: fixed;
  z-index: 10;
  inset: 50% 0 auto 0;
  height: 0;
  color: #fff;
  mix-blend-mode: difference;
  opacity: 0;
  transition: opacity 800ms var(--ease-out) 500ms;
}

.is-loaded .nav { opacity: 1; }

.nav > a,
.nav__contact {
  position: absolute;
  top: 0;
  transform: translateY(-50%);
}

.nav a {
  display: flex;
  align-items: baseline;
  gap: 2.4em;
  white-space: nowrap;
  /* Underline that draws in from the left on hover */
  background: linear-gradient(currentColor, currentColor) no-repeat 100% 100% / 0 1px;
  transition: background-size 500ms var(--ease-out);
}

.nav a:hover,
.nav a[aria-current="page"] {
  background-position: 0 100%;
  background-size: 100% 1px;
}

.nav > :nth-child(1) { left: var(--gutter); }
.nav > :nth-child(2) { left: 23.4vw; }
.nav > :nth-child(3) { left: 57.4vw; }
.nav > :nth-child(4) { left: 89vw; }

/* Contact: a small menu that slides down on hover (or on tap on phones) */

.nav__menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin: 0;
  padding: 0.7em 0 0;
  list-style: none;
  visibility: hidden;
  pointer-events: none;
  transition: visibility 0s linear 500ms;
}

.nav__menu li {
  overflow: hidden;
  padding-top: 0.25em;
}

.nav__menu a {
  width: max-content;
  transform: translateY(110%);
  transition:
    transform 500ms var(--ease-out),
    background-size 500ms var(--ease-out);
}

.nav__menu li:nth-child(2) a { transition-delay: 60ms, 0ms; }

.nav__contact:hover .nav__menu,
.nav__contact:focus-within .nav__menu,
.nav__contact.is-open .nav__menu {
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}

.nav__contact:hover .nav__menu a,
.nav__contact:focus-within .nav__menu a,
.nav__contact.is-open .nav__menu a { transform: none; }

.nav small {
  font-size: 0.68em;
  letter-spacing: 0.02em;
}

/* Scroll hint: a vertical gauge of how far along the strip you are */

.scroll-hint {
  position: fixed;
  z-index: 10;
  left: calc(var(--gutter) * 0.25);
  bottom: var(--edge);
  display: flex;
  align-items: flex-end;
  gap: 10px;
  font-size: 12px;
  color: #fff;
  mix-blend-mode: difference;
}

.scroll-hint__label {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  transition: opacity 400ms var(--ease-out);
}

.scroll-hint__bar {
  position: relative;
  width: 2px;
  height: 10vh;
  background: rgba(255, 255, 255, 0.3);
}

.scroll-hint__bar span {
  position: absolute;
  inset: 0;
  background: #fff;
  transform-origin: top;
  transform: scaleY(0);
}

/* Stage and track */

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

.track {
  position: relative;
  display: flex;
  height: 100%;
  width: max-content;
  padding: var(--edge) var(--gutter) var(--edge) 63vw;
  gap: var(--gap);
  will-change: transform;
}

.intro {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100vw;
  padding: var(--edge) var(--gutter);
  pointer-events: none;
}

.intro__title,
.intro__count {
  font-weight: 500;
  font-size: clamp(3.4rem, 9.6vw, 13rem);
  line-height: 0.92;
  letter-spacing: -0.045em;
}

.intro__count {
  position: absolute;
  top: var(--edge);
  right: var(--gutter);
  letter-spacing: -0.06em;
}

/* Project cards: tall ones sit low, wide ones sit high */

.card {
  position: relative;
  flex: none;
  align-self: flex-end;
  height: 75vh;
  margin: 0;
}

.card:nth-of-type(even) {
  align-self: flex-start;
  height: 60vh;
}

.card__link {
  position: relative;
  display: block;
  height: 100%;
  color: var(--on-photo);
}

.card__media {
  position: relative;
  height: 100%;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.06);
  clip-path: inset(100% 0 0 0);
  transition: clip-path 1300ms var(--ease-in-out);
}

.card.is-in .card__media { clip-path: inset(0 0 0 0); }

/* The first image opens just after the title has risen */
.card:first-of-type .card__media { transition-delay: 250ms; }

/* Sized by its own aspect ratio; the frame crops the parallax overscan */
.card__media img {
  height: 100%;
  width: auto;
  max-width: none;
  transform: translateX(var(--shift, 0%)) scale(1.14);
}

.card__media::after {
  content: "";
  position: absolute;
  inset: 55% 0 0 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.32), transparent);
  pointer-events: none;
}

.card__caption {
  position: absolute;
  z-index: 1;
  left: 1.6vw;
  bottom: 1.5vw;
}

.card__caption .mask > span { transition-duration: 900ms; }
.card__caption .mask:nth-child(2) > span { transition-delay: 70ms; }
.card.is-active .card__caption .mask > span { transform: none; }

.card__arrow {
  position: absolute;
  z-index: 1;
  right: 1.4vw;
  bottom: 1.4vw;
  width: clamp(28px, 2.6vw, 50px);
  height: auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  transition:
    stroke-dashoffset 900ms var(--ease-out),
    transform 500ms var(--ease-out);
}

.card.is-active .card__arrow { stroke-dashoffset: 0; transition-delay: 150ms, 0ms; }

@media (hover: hover) {
  .card__link:hover .card__arrow { transform: translate(4px, -4px); }
}

/* Closing panel */

/* Sits below the navigation line so the two never overlap */
.outro {
  flex: none;
  align-self: flex-end;
  width: min(34rem, 42vw);
  margin: 0 0 6vh 4vw;
}

.outro__text {
  font-size: clamp(18px, 1.9vw, 34px);
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 2em;
}

.outro__links a {
  background: linear-gradient(currentColor, currentColor) no-repeat 0 100% / 100% 1px;
}

/* Fullscreen gallery */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
  background: var(--paper);
  opacity: 0;
  transition: opacity 450ms var(--ease-out);
}

.viewer.is-open { opacity: 1; }

.viewer__bar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--gutter);
  padding: var(--edge) var(--gutter);
  opacity: 0;
  transition: opacity 500ms var(--ease-out);
}

.viewer.is-ready .viewer__bar { opacity: 1; }

.viewer__credits {
  display: flex;
  flex-wrap: wrap;
  gap: 0 1.6em;
  margin-top: 4px;
  color: #6f6f6c;
}

.viewer__credits a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.viewer__credits a:hover { text-decoration-thickness: 2px; }

.viewer__steps { display: flex; gap: 2.4em; }
.viewer__steps button:disabled { opacity: 0.35; cursor: default; }
.viewer__count { font-variant-numeric: tabular-nums; }

.viewer__stage {
  position: relative;
  min-height: 0;
  margin: 0 var(--gutter);
}

/* Centred and contained without depending on the image's own size */
.viewer__stage img {
  position: absolute;
  inset: 0;
  margin: auto;
  max-width: 100%;
  max-height: 100%;
  opacity: 0;
  transition: opacity 500ms var(--ease-out);
  user-select: none;
  -webkit-user-drag: none;
}

.viewer__stage img.is-visible { opacity: 1; }

@media (hover: hover) {
  .viewer__stage { cursor: e-resize; }
  .viewer__stage.is-left { cursor: w-resize; }
}

/* The image that grows from its card into the gallery */
.flip {
  position: fixed;
  z-index: 30;
  overflow: hidden;
  pointer-events: none;
}

.flip img {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
}

/* Phones: the strip becomes a vertical column */

@media (max-width: 760px) {
  :root { --edge: 16px; --gutter: 16px; --text: 14px; }

  .stage { position: relative; overflow: visible; }
  .scroll-space { display: none; }

  .track {
    flex-direction: column;
    width: auto;
    height: auto;
    padding: 0 var(--gutter) 4rem;
    gap: 14vh;
    transform: none !important;
  }

  .intro {
    position: relative;
    width: auto;
    height: 100svh;
    margin: 0 calc(var(--gutter) * -1);
  }

  .intro__title,
  .intro__count { font-size: 19vw; }
  .intro__title { padding-top: 12vh; }
  .intro__count { position: static; margin-top: 0.15em; }

  .nav {
    inset: 0 0 auto 0;
    height: auto;
    display: flex;
    justify-content: space-between;
    padding: var(--edge) var(--gutter);
  }

  .nav > a,
  .nav__contact {
    position: static;
    transform: none;
  }

  .nav a { gap: 0.4em; }

  .nav__contact { position: relative; left: auto !important; }
  .nav__menu { left: auto; right: 0; }
  .nav__menu a { margin-left: auto; }

  .scroll-hint { display: none; }

  .card,
  .card:nth-of-type(even) {
    height: auto;
    align-self: stretch;
  }

  .card:nth-of-type(even) { width: 82%; align-self: flex-end; }

  .card__media img {
    width: 100%;
    height: auto;
    transform: translateY(var(--shift, 0%)) scale(1.1);
  }

  .card__caption { left: 14px; bottom: 14px; }
  .card__arrow { right: 14px; bottom: 14px; }

  .outro { width: auto; margin: 0; }

  .viewer__steps { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .mask > span,
  .card__media,
  .card__arrow,
  .viewer,
  .viewer__bar,
  .viewer__stage img,
  .nav__menu a,
  .nav {
    transition: none !important;
  }

  .card__media img { transform: none; }
}
