:root {
  --bg: #000;
  --fg: #f5f5f3;
  --muted: #8a8a8a;
  --dim: #4a4a4a;
  --line: rgba(255, 255, 255, 0.12);
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Instrument Serif", "Times New Roman", serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", monospace;
  --script: "Herr Von Muellerhoff", "Brush Script MT", cursive;
  --gutter: clamp(1rem, 4vw, 3rem);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 300 1rem/1.7 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Static film grain: texture without motion. */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: var(--fg); color: var(--bg); }

a { color: inherit; text-decoration: none; }
a:focus-visible { outline: 1px solid var(--fg); outline-offset: 4px; }

h1, h2, h3, p, ul, ol { margin: 0; padding: 0; }
ul, ol { list-style: none; }

em { font-family: var(--serif); font-style: italic; font-weight: 400; }

.skip {
  position: absolute;
  left: -999px;
  top: 1rem;
  z-index: 200;
  padding: 0.5rem 1rem;
  background: var(--fg);
  color: var(--bg);
}
.skip:focus { left: 1rem; }

.label, .hero-tagline, .row-when, .work-idx, .work-kind {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.label { display: block; margin-bottom: 2.5rem; }

/* ---------- Top bar (appears after the title screen) ---------- */

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem var(--gutter) 2rem;
  background: linear-gradient(var(--bg) 35%, transparent);
  pointer-events: none;
  opacity: 0;
  visibility: hidden; /* also takes its links out of the tab order */
  transform: translateY(-100%);
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease), visibility 0s 0.5s;
}
.scrolled .topbar { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.topbar a { pointer-events: auto; }
.monogram { font: 2.5rem/1 var(--script); }
.topbar ul {
  display: flex;
  gap: clamp(1rem, 3vw, 2rem);
  font-family: var(--mono);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.topbar ul a { position: relative; }
.topbar ul a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -4px;
  width: 100%;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.4s var(--ease);
}
.topbar ul a:hover::after { transform: scaleX(1); transform-origin: left; }

/* ---------- Title screen ---------- */

.hero {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
}

.hero-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 var(--gutter);
}

.signature { font-weight: 400; }
.signature-svg {
  display: block;
  width: clamp(15rem, 40vw, 28rem);
  height: auto;
  overflow: visible;
}
/* Hidden until main.js has picked pen strokes or the loaded font, so neither
   a fallback font nor an unstyled frame flashes first. */
.js .signature-svg { opacity: 0; }
.js .sig-ready .signature-svg { opacity: 1; }
.signature-svg text {
  font-family: var(--script);
  font-size: 230px;
  fill: var(--fg);
}
/* Font fallback: a soft-edged wipe left to right, like a pen moving across. */
.writing .signature-svg text {
  -webkit-mask-image: linear-gradient(90deg, #000 40%, transparent 60%);
  mask-image: linear-gradient(90deg, #000 40%, transparent 60%);
  -webkit-mask-size: 300% 100%;
  mask-size: 300% 100%;
  -webkit-mask-position: 100% 0;
  mask-position: 100% 0;
  animation: write 2.4s cubic-bezier(0.45, 0.05, 0.35, 1) 0.3s forwards;
}
@keyframes write {
  to { -webkit-mask-position: 0 0; mask-position: 0 0; }
}
/* Generated signature (signature.svg), written stroke by stroke by main.js. */
.signature-svg .sig-ink { fill: var(--fg); }

/* One quiet line under the signature, joined by thin rules. */
.hero-tagline {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.4rem 0;
  margin-top: clamp(1rem, 2.5vw, 1.5rem);
  animation: fade 1.2s var(--ease) 2.4s both;
}
.hero-tagline span:not(:last-child)::after {
  content: "";
  display: inline-block;
  width: 1.25rem;
  height: 1px;
  margin: 0 0.9rem;
  vertical-align: middle;
  background: var(--dim);
}

/* Title-screen links. Each word rolls up into an italic copy of itself and
   the other links fade back. The real text stays in the DOM (transparent) for
   layout, screen readers and copy-paste; both visible copies are pseudo-
   elements reading data-text, with empty alt text so they aren't announced. */
.hero-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.25rem clamp(1.5rem, 4vw, 2.75rem);
  margin-top: clamp(1.5rem, 4vw, 2.5rem);
  font: 400 clamp(1.25rem, 2.4vw, 1.625rem)/1.15 var(--serif);
  animation: fade 1.2s var(--ease) 2.7s both;
}
.hero-nav a {
  position: relative;
  display: block;
  padding-bottom: 0.15em;
  transition: opacity 0.4s var(--ease);
}
.hero-nav a > span {
  position: relative;
  display: block;
  overflow: hidden;
  padding: 0 0.12em; /* room for the italic overhang */
  color: transparent;
}
.hero-nav a > span::before,
.hero-nav a > span::after {
  content: attr(data-text);
  content: attr(data-text) / "";
  position: absolute;
  left: 0.12em;
  right: 0.12em;
  color: var(--fg);
  transition: transform 0.55s var(--ease);
}
.hero-nav a > span::before { top: 0; }
.hero-nav a > span::after { top: 100%; font-style: italic; }
.hero-nav a:hover > span::before,
.hero-nav a:hover > span::after,
.hero-nav a:focus-visible > span::before,
.hero-nav a:focus-visible > span::after { transform: translateY(-100%); }
.hero-nav a::after {
  content: "";
  position: absolute;
  left: 0.12em;
  right: 0.12em;
  bottom: 0;
  height: 1px;
  background: var(--fg);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 0.55s var(--ease);
}
.hero-nav a:hover::after,
.hero-nav a:focus-visible::after { transform: scaleX(1); transform-origin: left; }
.hero-nav:has(a:hover) a:not(:hover) { opacity: 0.35; }

@keyframes fade {
  from { opacity: 0; transform: translateY(0.5rem); }
  to { opacity: 1; transform: none; }
}

/* ---------- Sections ---------- */

.statement, .block, .contact {
  max-width: 76rem;
  margin: 0 auto;
  padding: clamp(5rem, 14vw, 10rem) var(--gutter) 0;
}

.statement-text {
  max-width: 22ch;
  font-family: var(--serif);
  font-size: clamp(2rem, 5.5vw, 4.25rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
}
/* main.js wraps each word in a span and lights them up as you scroll. */
.statement-text .w {
  color: var(--dim);
  transition: color 0.6s var(--ease);
}
.statement-text .w.lit { color: var(--fg); }

h2 {
  margin-bottom: 3rem;
  font: 400 clamp(2.25rem, 6vw, 4.5rem)/1 var(--sans);
  letter-spacing: -0.04em;
}
h2 em { letter-spacing: -0.01em; }

h3 {
  font-size: 1.125rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

/* Label column + content column. */
.split {
  display: grid;
  grid-template-columns: minmax(8rem, 1fr) 3fr;
  gap: 1rem 2rem;
  padding: 2rem 0;
  border-top: 1px solid var(--line);
}
.split .label { margin: 0.3rem 0 0; }

.rows li {
  display: grid;
  grid-template-columns: 6rem 1fr;
  gap: 0.5rem 2rem;
}
.row-when { padding-top: 0.3rem; }
.row-sub { color: var(--muted); }
.rows p:last-child { margin-top: 0.75rem; max-width: 60ch; color: #c4c4c4; }
.rows .row-sub:last-child { margin-top: 0; }

.focus {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0;
  font: italic 400 clamp(1.25rem, 2.2vw, 1.625rem)/1.4 var(--serif);
}
.focus li:not(:last-child)::after {
  content: "/";
  margin: 0 0.75rem;
  font-style: normal;
  color: var(--dim);
}

/* ---------- Work index ---------- */

.work { border-bottom: 1px solid var(--line); }
.work a {
  position: relative;
  display: grid;
  grid-template-columns: 3rem minmax(10rem, 1.1fr) 2fr 8rem 1.5rem;
  align-items: baseline;
  gap: 1rem;
  padding: 1.75rem 0.75rem;
  border-top: 1px solid var(--line);
  isolation: isolate;
  transition: color 0.45s var(--ease);
}
/* Hover: a white panel rises and the row inverts to black on white. */
.work a::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--fg);
  transform: scaleY(0);
  transform-origin: bottom;
  transition: transform 0.45s var(--ease);
}
.work a:hover::before,
.work a:focus-visible::before { transform: scaleY(1); }
.work a:hover,
.work a:focus-visible,
.work a:hover .work-idx,
.work a:hover .work-kind,
.work a:hover .work-desc { color: var(--bg); }
.work-idx, .work-kind, .work-desc { transition: color 0.45s var(--ease); }
.work-name {
  font: 400 clamp(1.5rem, 3vw, 2.25rem)/1.1 var(--serif);
  letter-spacing: -0.01em;
}
.work-desc { color: #a8a8a8; font-size: 0.9375rem; }
.work-kind { text-align: right; }

.arrow {
  display: inline-block;
  font-family: var(--sans);
  font-style: normal;
  transition: transform 0.4s var(--ease);
}
a:hover .arrow { transform: translate(3px, -3px); }

.work-group + .work-group { margin-top: 3.5rem; }
.work-group .label { margin-bottom: 1rem; }

/* ---------- Contact ---------- */

.contact { padding-bottom: clamp(5rem, 12vw, 9rem); }
.contact h2 {
  margin-bottom: 1.5rem;
  font-size: clamp(3.5rem, 13vw, 10rem);
  letter-spacing: -0.05em;
}
.contact h2 a {
  background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat;
  transition: background-size 0.6s var(--ease);
}
.contact h2 a:hover { background-size: 100% 1px; }
.contact p:last-child { color: var(--muted); }

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

footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.5rem var(--gutter);
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
footer a:hover { color: var(--fg); }

/* ---------- Scroll reveal (class set by main.js) ---------- */

.js .reveal {
  opacity: 0;
  transform: translateY(2.5rem);
  transition: opacity 1s var(--ease), transform 1s var(--ease);
}
.js .reveal.in { opacity: 1; transform: none; }

/* ---------- Case studies ---------- */

.case-hero {
  max-width: 76rem;
  margin: 0 auto;
  padding: clamp(7rem, 16vw, 11rem) var(--gutter) 0;
}
.back {
  display: inline-block;
  margin-bottom: 3rem;
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 0.3s var(--ease), transform 0.3s var(--ease);
}
.back:hover { color: var(--fg); transform: translateX(-3px); }
.case-hero .label { margin-bottom: 1.5rem; }
.case-hero h1 {
  font: 400 clamp(3.5rem, 11vw, 8.5rem)/0.95 var(--sans);
  letter-spacing: -0.05em;
}
.case-hero h1 em { letter-spacing: -0.02em; }
.lede {
  max-width: 38ch;
  margin-top: 2rem;
  font: 400 clamp(1.375rem, 2.6vw, 1.875rem)/1.3 var(--serif);
  color: #d4d4d4;
}
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 1.5rem 2rem;
  margin: 4rem 0 0;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
}
.facts dt {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.facts dd { margin: 0.4rem 0 0; font-size: 0.9375rem; }
.facts a { border-bottom: 1px solid var(--dim); }
.facts a:hover { border-color: var(--fg); }

.prose { max-width: 62ch; margin-top: 2.5rem; color: #c4c4c4; font-size: 1.0625rem; }

/* Traffic-flow diagram: each lane is a row of boxes joined by arrows. */
.flows { display: grid; gap: 1rem; }
.flow-lane {
  display: grid;
  grid-template-columns: 6rem 1fr;
  align-items: center;
  gap: 1rem;
}
.flow-tag {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.flow { display: flex; flex-wrap: wrap; align-items: stretch; gap: 0.5rem; }
.flow li {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  font-size: 0.9375rem;
  line-height: 1.3;
}
.flow li small { color: var(--muted); font-size: 0.75rem; }
.flow li + li { position: relative; margin-left: 1.5rem; }
.flow li + li::before {
  content: "→";
  position: absolute;
  left: -1.55rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.5rem;
  text-align: center;
  color: var(--muted);
}

.decisions { border-bottom: 1px solid var(--line); }
.decisions li {
  display: grid;
  grid-template-columns: 3rem 1fr;
  gap: 1rem;
  padding: 2rem 0.75rem;
  border-top: 1px solid var(--line);
}
.decisions .work-idx { padding-top: 0.35rem; }
.decisions h3 { font: 400 clamp(1.5rem, 2.6vw, 2rem)/1.15 var(--serif); }
.decisions p { max-width: 62ch; margin-top: 0.75rem; color: #c4c4c4; }
.decisions .aside { color: var(--muted); font-size: 0.9375rem; }

.rows.plain li { grid-template-columns: 1fr; }
.rows.plain li + li { margin-top: 1.5rem; }
.rows.plain p { margin-top: 0.4rem; }

.swaps {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}
.swaps li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 1rem 1.25rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transition: background 0.3s var(--ease);
}
.swaps li:hover { background: rgba(255, 255, 255, 0.04); }
.swaps span:first-child {
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: var(--dim);
}
.swaps span:last-child { font: italic 400 1.375rem/1 var(--serif); }

.next {
  max-width: 76rem;
  margin: 0 auto;
  padding: clamp(5rem, 12vw, 8rem) var(--gutter);
}
.next .label { margin-bottom: 1rem; }
.next a {
  font: 400 clamp(3rem, 10vw, 7rem)/1 var(--serif);
  letter-spacing: -0.02em;
}
.next a:hover .arrow { transform: translateX(8px); }

/* ---------- 404 ---------- */

.notfound {
  min-height: 100svh;
  display: grid;
  place-content: center;
  gap: 1rem;
  padding: 0 var(--gutter);
  text-align: center;
}
.notfound h1 { font: 400 clamp(5rem, 16vw, 9rem)/1 var(--script); }
.notfound a { font-family: var(--mono); font-size: 0.8125rem; color: var(--muted); }
.notfound a:hover { color: var(--fg); }

@media (max-width: 760px) {
  .split { grid-template-columns: 1fr; }
  .rows li { grid-template-columns: 1fr; }
  .work a { grid-template-columns: 2.25rem 1fr 1.25rem; padding-inline: 0.5rem; }
  .work-desc { grid-column: 2 / 3; grid-row: 2; }
  .work-kind { display: none; }
  .flow-lane { grid-template-columns: 1fr; }
  .flow { flex-direction: column; align-items: flex-start; gap: 0; }
  .flow li + li { margin: 1.75rem 0 0; }
  .flow li + li::before { content: "↓"; left: 1rem; top: -1.6rem; width: auto; transform: none; }
  .decisions li { grid-template-columns: 2.25rem 1fr; padding-inline: 0.5rem; }
}

@media (max-width: 480px) {
  .topbar ul { gap: 1rem; }
  /* Title on its own line; the other two share the next. */
  .hero-tagline span:first-child { flex-basis: 100%; text-align: center; }
  .hero-tagline span:first-child::after { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
  .js .reveal { opacity: 1; transform: none; }
  .statement-text .w { color: var(--fg); }
}
