:root {
  --bg: #050505;
  --ink: #ecebe6;
  --ink-2: rgba(236, 235, 230, 0.58);
  --ink-3: rgba(236, 235, 230, 0.32);
  --line: rgba(236, 235, 230, 0.16);
  --edge: max(clamp(16px, 2.4vw, 40px), env(safe-area-inset-left), env(safe-area-inset-right));
  --gap: clamp(10px, 1vw, 16px);
  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
  --mono: "Geist Mono", ui-monospace, Menlo, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-smooth [data-lenis-prevent] { overscroll-behavior: contain; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 12px/1.45 var(--mono);
  letter-spacing: 0.02em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
::selection { background: var(--ink); color: var(--bg); }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: var(--edge); top: var(--edge); z-index: 200; background: var(--ink); color: var(--bg); padding: 8px 12px; }

/* Type */
.display, .hero-name, .chapter-title, .proj-client, .marquee-item, .foot-mark, .menu-client {
  font-family: var(--display);
  font-stretch: 62.5%;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.005em;
  line-height: 0.86;
}
.serif { font-family: var(--serif); font-style: italic; font-weight: 400; letter-spacing: 0; text-transform: none; }
.label, .hero-meta, .bar, .proj-n, .proj-meta, .media-label, .menu-chapter, .chapter-n, .chapter-count, .marquee-label, .now, .foot-label,
.foot-row, .menu-head, .menu-meta, .player-ui {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Split text: each word masks its letters as they rise. */
.w { display: inline-block; overflow: hidden; vertical-align: top; padding: 0.06em 0.01em 0.04em; margin: -0.06em -0.01em -0.04em; }
.c { display: inline-block; }
.mask { display: block; overflow: hidden; }
.mask > span { display: block; width: 100%; }
.proj-n.mask > span, .proj-meta.mask > span, .chapter-top.mask > span {
  display: flex; gap: inherit; flex-wrap: inherit; justify-content: inherit;
}

/* Grain: a still noise tile nudged in steps. No blend mode, so it costs one layer. */
.grain {
  position: fixed; inset: -10%; z-index: 90;
  pointer-events: none;
  opacity: 0.035;
  background-size: 180px 180px;
  animation: grain 0.9s steps(6) infinite;
}
@keyframes grain {
  0% { transform: translate3d(0, 0, 0); }
  20% { transform: translate3d(-4%, 3%, 0); }
  40% { transform: translate3d(3%, -5%, 0); }
  60% { transform: translate3d(-6%, -2%, 0); }
  80% { transform: translate3d(5%, 4%, 0); }
  100% { transform: translate3d(-2%, 6%, 0); }
}

/* Header */
.bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: max(18px, env(safe-area-inset-top)) var(--edge) 18px;
  pointer-events: none;
}
.bar::before {
  content: ""; position: absolute; inset: 0 0 -48px 0; z-index: -1;
  background: linear-gradient(rgba(5, 5, 5, 0.92) 30%, rgba(5, 5, 5, 0));
  opacity: 0.55; transition: opacity 0.6s var(--ease);
  pointer-events: none;
}
.bar.is-named::before { opacity: 1; }
.bar > * { pointer-events: auto; }
.bar-progress {
  position: absolute; left: 0; top: 0; height: 1px; width: 100%;
  background: var(--ink);
  transform-origin: 0 50%; transform: scaleX(0);
  pointer-events: none;
}
.bar-name { opacity: 0; transition: opacity 0.6s var(--ease); }
.bar.is-named .bar-name { opacity: 1; }
.bar-role { color: var(--ink-2); }
.bar-nav { justify-self: end; display: flex; gap: 22px; }
.bar-count { font-size: 9px; color: var(--ink-2); vertical-align: top; margin-left: 2px; }
.bar a, .bar button { position: relative; }
.bar a::after, .bar button::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -3px; height: 1px; background: currentColor;
  transform: scaleX(0); transform-origin: right; transition: transform 0.5s var(--ease);
}
@media (hover: hover) {
  .bar a:hover::after, .bar button:hover::after { transform: scaleX(1); transform-origin: left; }
}

/* Hero */
.hero { position: relative; height: 100vh; height: 100svh; overflow: hidden; background: #000; }
.hero-media { position: absolute; inset: 0; transform-origin: 50% 60%; }
.hero-media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero-shade {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.45) 0%, rgba(0, 0, 0, 0) 26%, rgba(0, 0, 0, 0) 52%, rgba(0, 0, 0, 0.72) 100%);
}
.hero-dim { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; }
.hero-bars i {
  position: absolute; left: 0; right: 0; height: 14vh; background: var(--bg);
  transform: scaleY(0); pointer-events: none;
}
.hero-bars i:first-child { top: 0; transform-origin: 50% 0; }
.hero-bars i:last-child { bottom: 0; transform-origin: 50% 100%; }
.hero-foot {
  position: absolute; left: var(--edge); right: var(--edge); bottom: calc(var(--edge) * 0.7);
  z-index: 3;
}
.hero-meta {
  display: flex; justify-content: space-between; gap: 16px;
  margin-bottom: clamp(10px, 1.6vw, 22px);
  color: var(--ink-2);
}
.hero-scroll { display: inline-flex; align-items: center; gap: 10px; }
.hero-scroll i {
  display: inline-block; width: 36px; height: 1px; background: var(--ink-3); position: relative; overflow: hidden;
}
.hero-scroll i::after {
  content: ""; position: absolute; inset: 0; background: var(--ink);
  transform: translateX(-100%); animation: scrollcue 2.2s var(--ease) infinite;
}
@keyframes scrollcue { 0% { transform: translateX(-100%); } 60%, 100% { transform: translateX(100%); } }
.hero-name { margin: 0; font-size: 18vw; white-space: nowrap; }
.fit-line { display: inline-block; white-space: nowrap; }

/* Intro: two black halves over the hero that part like a shutter. Only with JS. */
.intro { display: none; }
.js .intro { display: block; position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.intro-half { position: absolute; left: 0; right: 0; height: 50.5%; background: var(--bg); }
.intro-top { top: 0; }
.intro-bottom { bottom: 0; }
.intro-count, .intro-role {
  position: absolute; bottom: var(--edge); font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-2);
}
.intro-count { right: var(--edge); font-variant-numeric: tabular-nums; color: var(--ink); }
.intro-role { left: var(--edge); }
.is-intro .hero-meta, .is-intro .bar { opacity: 0; }
.is-intro .bar { pointer-events: none; }
.is-intro .bar > * { pointer-events: none; }

/* Marquee */
.marquee { padding: clamp(80px, 14vh, 160px) 0 clamp(40px, 8vh, 96px); overflow: hidden; }
.marquee-label { margin: 0 var(--edge) 22px; color: var(--ink-2); }
.marquee-track { display: flex; width: max-content; will-change: transform; }
.marquee-set { display: flex; align-items: center; flex-shrink: 0; }
.marquee-item { font-size: clamp(64px, 11vw, 190px); padding: 0 0.18em; white-space: nowrap; }
.marquee-item:nth-child(even) { color: transparent; -webkit-text-stroke: 1.2px var(--ink); }
.marquee-sep { font-family: var(--serif); font-style: italic; font-size: clamp(40px, 6vw, 110px); color: var(--ink-3); }

/* Chapters */
.chapter { padding: clamp(80px, 16vh, 200px) var(--edge) clamp(40px, 7vh, 80px); }
.chapter-rule { height: 1px; background: var(--line); transform-origin: 0 50%; margin-bottom: 18px; }
.chapter-top { display: flex; justify-content: space-between; color: var(--ink-2); margin-bottom: clamp(16px, 3vh, 36px); }
.chapter-title { margin: 0; font-size: clamp(76px, 17vw, 300px); }

/* Projects: a header, the lead piece large, the rest in justified rows. */
.proj { position: relative; padding: 0 var(--edge); margin-bottom: clamp(96px, 16vh, 200px); }
.media {
  position: relative; display: block; width: 100%;
  aspect-ratio: var(--w) / var(--h);
  overflow: hidden; background: #0d0d0d; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.media:focus-visible { outline: 1px solid var(--ink); outline-offset: 4px; }
.par { position: absolute; left: 0; right: 0; top: -7%; bottom: -7%; }
.fill { position: absolute; inset: 0; }
.par video, .fill video, .media > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media > img { position: absolute; inset: 0; }
.media-label {
  position: absolute; left: 10px; bottom: 9px; z-index: 1; pointer-events: none;
  padding: 4px 7px; background: rgba(5, 5, 5, 0.72); color: var(--ink);
}
/* The reveal window: page-coloured bars that slide out past the frame's edges. */
.curtain { position: absolute; z-index: 2; background: var(--bg); pointer-events: none; }
.curtain-t { left: 0; right: 0; top: 0; height: 14%; }
.curtain-b { left: 0; right: 0; bottom: 0; height: 14%; }
.curtain-l { top: 0; bottom: 0; left: 0; width: 9%; }
.curtain-r { top: 0; bottom: 0; right: 0; width: 9%; }

.proj-head {
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gap);
  align-items: end; margin-bottom: 22px;
}
.proj-n { grid-column: 1 / span 2; margin: 0; color: var(--ink-2); display: flex; gap: 12px; align-self: start; padding-top: 0.6em; }
.proj-name { grid-column: 3 / span 6; }
.proj-client { margin: 0; font-size: clamp(36px, 5.2vw, 96px); }
.proj-title { margin: 8px 0 0; font-size: clamp(22px, 2.2vw, 36px); line-height: 1.05; }
.proj-meta { grid-column: 9 / -1; margin: 0; color: var(--ink-2); display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px 18px; text-align: right; }

/* Stack: header, the lead at full width, the rest beneath. */
.l-stack .media.is-lead { max-height: 86svh; }

/* Bleed: the lead edge to edge with its header over the picture. */
.l-bleed { padding: 0; }
.l-bleed .media.is-lead { aspect-ratio: auto; height: min(calc(100vw * var(--h) / var(--w)), 100svh); }
.l-bleed .media.is-lead::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 60%;
  background: linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.72)); pointer-events: none;
}
.l-bleed .proj-head { position: absolute; left: var(--edge); right: var(--edge); bottom: var(--edge); z-index: 3; margin: 0; pointer-events: none; }
.l-bleed .proj-client { font-size: clamp(52px, 9vw, 170px); }

/* Side: the lead in one column; the header and the rest in the other. */
.l-side { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gap); align-items: stretch; }
.l-side .media.is-lead { grid-row: 1; align-self: start; max-width: calc(86svh * var(--w) / var(--h)); }
.l-side.is-flip .media.is-lead { justify-self: end; }
.proj-side { grid-row: 1; display: flex; flex-direction: column; justify-content: space-between; gap: 36px; min-width: 0; }
.proj-side.is-solo { justify-content: flex-end; }
.l-side .proj-head { display: block; margin: 0; }
.l-side .proj-n { padding: 0; margin-bottom: 16px; }
.l-side .proj-meta { justify-content: flex-start; text-align: left; margin-top: 18px; }

/* Justified rows; sizes are set by pack() in main.js. */
.gallery { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.gallery .media { aspect-ratio: auto; width: auto; flex: 0 0 auto; }
.proj-side .gallery { margin-top: 0; }

/* Cursor (mouse only) */
.cursor { position: fixed; left: 0; top: 0; z-index: 100; pointer-events: none; display: none; }
.has-cursor .cursor { display: block; }
.has-cursor .media, .has-cursor .menu-list button, .has-cursor .player-box { cursor: none; }
.cursor-dot {
  position: absolute; left: -6px; top: -6px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--ink);
  transition: transform 0.55s var(--ease), opacity 0.3s;
}
.cursor-label {
  position: absolute; left: 0; top: 0; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--bg); font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  opacity: 0; transition: opacity 0.3s;
  white-space: nowrap;
}
.cursor-label i { font-style: normal; opacity: 0.6; font-size: 10px; }
.cursor.is-big .cursor-dot { transform: scale(8.5); }
.cursor.is-big .cursor-label { opacity: 1; transition-delay: 0.08s; }
.cursor.is-hidden .cursor-dot { opacity: 0; }

/* Chapter indicator */
.now {
  position: fixed; left: var(--edge); bottom: max(18px, env(safe-area-inset-bottom)); z-index: 41;
  display: flex; gap: 12px; color: var(--ink);
  opacity: 0; transition: opacity 0.5s var(--ease);
  pointer-events: none;
}
.now.is-on { opacity: 1; }
.now-n { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.now-t { display: block; overflow: hidden; height: 1.45em; }
.now-t b { display: block; font-weight: 400; }

/* Footer: fixed under the page, uncovered as the page scrolls off it. */
main { position: relative; z-index: 1; background: var(--bg); }
.foot {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 0;
  padding: clamp(80px, 12vh, 140px) var(--edge) max(var(--edge), env(safe-area-inset-bottom));
  min-height: 70vh; min-height: 70svh;
  display: flex; flex-direction: column;
}
.foot-inner { display: flex; flex-direction: column; justify-content: space-between; flex: 1; gap: 48px; }
.foot-label { margin: 0 0 14px; color: var(--ink-2); }
.foot-email {
  display: inline-block; position: relative;
  font-family: var(--serif); font-style: italic; font-size: clamp(30px, 5vw, 84px); line-height: 1.05;
  overflow-wrap: anywhere;
}
.foot-email::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0.02em; height: 1px; background: currentColor;
  transform: scaleX(0); transform-origin: right; transition: transform 0.7s var(--ease);
}
.foot-links { margin: 22px 0 0; display: flex; flex-wrap: wrap; gap: 10px 28px; font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.foot-links a { color: var(--ink-2); transition: color 0.3s; }
@media (hover: hover) {
  .foot-email:hover::after { transform: scaleX(1); transform-origin: left; }
  .foot-links a:hover { color: var(--ink); }
}
.foot-row { display: flex; justify-content: space-between; gap: 16px; color: var(--ink-2); border-top: 1px solid var(--line); padding-top: 16px; }
.foot-top-btn { color: var(--ink); }
.foot-mark { margin: 0; font-size: 18vw; white-space: nowrap; }

/* Index */
.menu {
  position: fixed; inset: 0; z-index: 50;
  background: var(--bg);
  overflow: hidden;
  display: flex; flex-direction: column;
  padding: max(18px, env(safe-area-inset-top)) var(--edge) 0;
}
.menu[hidden] { display: none; }
.menu-inner { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.menu-head { display: flex; justify-content: space-between; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.menu-list { list-style: none; margin: 0; padding: 0 0 40px; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.menu-list li { border-bottom: 1px solid var(--line); overflow: hidden; }
.menu-list button {
  width: 100%; display: grid; grid-template-columns: 48px minmax(0, 5fr) minmax(0, 4fr) minmax(0, 2fr);
  align-items: baseline; gap: 16px; text-align: left; padding: 12px 0 10px;
  transition: opacity 0.4s var(--ease);
}
.menu-n, .menu-meta { font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
.menu-meta { text-align: right; }
.menu-client { font-size: clamp(30px, 4.2vw, 64px); }
.menu-title { font-family: var(--serif); font-style: italic; font-size: clamp(18px, 1.8vw, 28px); color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (hover: hover) {
  .menu-list.is-hovering button { opacity: 0.28; }
  .menu-list.is-hovering button.is-on { opacity: 1; }
}
.menu-preview {
  position: fixed; left: 0; top: 0; z-index: 51; pointer-events: none;
  width: clamp(220px, 22vw, 360px); aspect-ratio: 16 / 10; overflow: hidden;
  opacity: 0; transform: translate3d(-999px, 0, 0);
}
.menu-preview video, .menu-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.menu-list .menu-chapter {
  display: flex; gap: 16px; padding: 34px 0 10px; color: var(--ink-2); border-bottom: 1px solid var(--line);
}
.menu-chapter span:last-child { margin-left: auto; }

/* Player */
.player { position: fixed; inset: 0; z-index: 60; }
.player[hidden] { display: none; }
.player-back { position: absolute; inset: 0; background: #000; }
.player-box { position: fixed; left: 0; top: 0; overflow: hidden; background: #000; contain: strict; }
.player-snap, .player-video, .player-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.player-ui { position: absolute; inset: 0; pointer-events: none; transition: opacity 0.5s var(--ease); }
.player.is-idle .player-ui { opacity: 0; }
.player.is-idle, .player.is-idle .player-box { cursor: none; }
.player-top, .player-bottom { position: absolute; left: var(--edge); right: var(--edge); pointer-events: auto; }
.player-top { top: max(20px, env(safe-area-inset-top)); display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: baseline; }
.player-n { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.player-name { text-align: center; }
.player-client { font-weight: 500; }
.player-title { font-family: var(--serif); font-size: 18px; letter-spacing: 0; text-transform: none; color: var(--ink-2); margin-left: 6px; }
.player-close { justify-self: end; }
.player-bottom { bottom: max(18px, env(safe-area-inset-bottom)); }
.player-bar { position: relative; height: 22px; cursor: pointer; touch-action: none; }
.player-bar::before { content: ""; position: absolute; left: 0; right: 0; top: 10px; height: 1px; background: var(--ink-3); }
.player-fill { position: absolute; left: 0; right: 0; top: 10px; height: 1px; background: var(--ink); transform-origin: 0 50%; transform: scaleX(0); }
.player-controls { display: flex; gap: 26px; align-items: center; margin-top: 6px; }
.player-time { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.player-step { margin-left: auto; display: flex; gap: 22px; }
.player-img { opacity: 0; object-fit: contain; }
.player.is-image .player-bar, .player.is-image .player-toggle, .player.is-image .player-time, .player.is-image .player-mute,
.player.no-sound .player-mute { visibility: hidden; }

/* Phone */
@media (max-width: 700px) {
  :root { --edge: max(16px, env(safe-area-inset-left), env(safe-area-inset-right)); }
  .bar { grid-template-columns: 1fr auto; }
  .bar-role { display: none; }
  .bar-name { opacity: 1; }
  .hero-meta .hero-years { display: none; }
  .hero-name .fit-line { display: block; }
  .chapter { padding-top: 96px; }
  .proj { margin-bottom: 80px; }
  .proj-head { display: block; margin-bottom: 16px; }
  .proj-n { padding: 0; margin-bottom: 12px; }
  .proj-client { font-size: 48px; }
  .proj-meta { justify-content: flex-start; text-align: left; margin-top: 12px; }
  .l-bleed .media.is-lead { height: auto; aspect-ratio: var(--w) / var(--h); }
  .l-bleed .media.is-lead::after { display: none; }
  .l-bleed .proj-head { position: relative; left: auto; right: auto; bottom: auto; padding: 18px var(--edge) 0; }
  .l-bleed .proj-client { font-size: 54px; }
  .l-side { display: flex; flex-direction: column; }
  .l-side .media.is-lead { order: 2; max-width: none; }
  .proj-side { display: contents; }
  .l-side .proj-head { order: 1; margin-bottom: 16px; }
  .l-side .gallery { order: 3; margin-top: 6px; }
  .gallery { gap: 6px; margin-top: 6px; }
  .media-label { left: 6px; bottom: 6px; padding: 3px 5px; font-size: 9px; max-width: calc(100% - 12px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .menu-list button { grid-template-columns: 34px minmax(0, 1fr); row-gap: 2px; padding: 12px 0; }
  .menu-title { grid-column: 2; }
  .menu-meta { display: none; }
  .menu-client { font-size: 34px; }
  .player-top { grid-template-columns: 1fr auto; }
  .player-n { display: none; }
  .player-name { text-align: left; }
  .player-controls { gap: 18px; }
  .foot-row { flex-wrap: wrap; }
  .foot-row span:nth-child(2) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .grain, .hero-scroll i::after { animation: none; }
}
