:root {
  --bg: #000;
  --fg: #fff;
  --muted: #8c8c8c;
  --line: rgba(255, 255, 255, 0.9);
  --accent: #fff;      /* hover card colour — swap for a blue to bring back the sketch's "on blue" */
  --accent-ink: #000;  /* text on the accent */
  --hatch: rgba(0, 0, 0, 0.14);
  color-scheme: dark;
  --gutter: clamp(16px, 3vw, 44px);
  --display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(0.2, 0.9, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Alternate screens flip to black on white. Everything inside reads the same tokens. */
.is-inverse {
  --bg: #fff;
  --fg: #000;
  --muted: #6e6e6e;
  --line: rgba(0, 0, 0, 0.9);
  --accent: #000;
  --accent-ink: #fff;
  --hatch: rgba(255, 255, 255, 0.2);
  background: var(--bg);
  color: var(--fg);
}

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

html {
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--display);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body.is-locked { overflow: hidden; }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
::selection { background: var(--fg); color: var(--bg); }

.label {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.u-link {
  position: relative;
  display: inline-block;
}
.u-link::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -3px;
  height: 1.5px;
  background: currentColor;
  transform-origin: left;
  transition: transform 0.45s var(--ease);
}
.u-link:hover::after { transform: scaleX(0); transform-origin: right; }

/* ---------- Nav ---------- */

.nav {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 40;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  padding: 18px var(--gutter);
  mix-blend-mode: difference;
  pointer-events: none;
}
.nav > * { pointer-events: auto; }
.nav__name { justify-self: start; font-size: 16px; font-weight: 900; font-stretch: 125%; letter-spacing: 0; transition: opacity 0.3s, transform 0.4s var(--spring); }
.at-home:not(.is-locked) .nav__name { opacity: 0; transform: translateY(-8px); pointer-events: none; }
.nav__right { justify-self: end; }

/* ---------- Screens ---------- */

.screen {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  scroll-snap-align: start;
  padding: 80px var(--gutter) 28px;
  background: var(--bg);
  color: var(--fg);
}

.display {
  margin: 0;
  font-family: var(--display);
  font-weight: 900;
  font-stretch: 125%;
  line-height: 0.84;
  letter-spacing: -0.035em;
  text-transform: uppercase;
}

.fit { display: block; width: 100%; }
.fit__inner { display: inline-block; white-space: nowrap; }

/* Letters: rise in on entry, boing on hover */
.ch {
  display: inline-block;
  transform: translateY(105%);
  transition: transform 0.9s var(--ease);
  transition-delay: calc(var(--i) * 45ms);
  will-change: transform;
}
.clip { display: inline-block; overflow: hidden; padding-bottom: 0.04em; vertical-align: top; }
.is-settled .clip { overflow: visible; }
.is-in .ch { transform: none; }
.ch.boing { animation: boing 0.7s var(--spring); }
.ch.flip { animation: somersault 0.9s var(--ease); transform-origin: 50% 55%; }
@keyframes somersault {
  0% { transform: none; }
  15% { transform: translateY(6%) scale(1.1, 0.85); }
  55% { transform: translateY(-55%) rotate(-300deg); }
  80% { transform: translateY(0) rotate(-360deg) scale(1.12, 0.84); }
  100% { transform: rotate(-360deg); }
}
@keyframes boing {
  0% { transform: none; }
  25% { transform: scale(1.12, 0.78) translateY(10%); }
  55% { transform: scale(0.92, 1.14) translateY(-12%); }
  80% { transform: scale(1.03, 0.97); }
  100% { transform: none; }
}

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

.hero .fit { line-height: 0.86; }
.hero__side { grid-area: grid; align-self: center; display: grid; gap: 22px; }
.hero__rule { height: 1.5px; background: var(--line); transform: scaleX(0); transform-origin: left; transition: transform 1.2s var(--ease) 0.4s; }
.is-in .hero__rule { transform: none; }
.hero__cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px 24px;
  align-items: start;
}
.hero__intro { font-size: clamp(18px, 1.8vw, 26px); line-height: 1.2; font-weight: 500; max-width: 26ch; margin: 0; }
.hero__index { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.hero__index a { display: inline-flex; gap: 10px; font-weight: 600; }
.hero__index span { color: var(--muted); font-variant-numeric: tabular-nums; }
.hero__reach { display: grid; gap: 6px; justify-items: end; }
.stack { display: grid; gap: 4px; }
.stack b { font-weight: 700; }
.muted { color: var(--muted); }

/* ---------- Section screens ---------- */

.sec {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 36vw);
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "num  num"
    "title grid"
    "cue  grid";
  column-gap: clamp(24px, 5vw, 80px);
  row-gap: 24px;
}
.sec__num { grid-area: num; }
.sec__titlewrap { grid-area: title; align-self: center; min-width: 0; }
.sec__grid { grid-area: grid; align-self: center; }

.cue {
  grid-area: cue;
  align-self: end;
  display: inline-flex;
  align-items: flex-end;
  gap: 12px;
  font-weight: 900;
  font-stretch: 125%;
  font-size: clamp(22px, 2.6vw, 38px);
  letter-spacing: -0.02em;
  text-transform: uppercase;
  justify-self: start;
}
.cue__arrow { display: inline-block; animation: nudge 1.6s var(--ease) infinite; }
@keyframes nudge {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(8px); }
}
.cue:hover .cue__arrow { animation-duration: 0.5s; }

/* ---------- Grids & tiles ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(8px, 1vw, 14px);
}
.grid--full {
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: 16px;
  /* As wide as possible while every row still fits on screen */
  width: min(100%, 1100px, calc((100svh - 150px) * var(--cols) / var(--rows)));
}

.tile {
  position: relative;
  aspect-ratio: 1;
  border: 1.5px solid var(--line);
  overflow: hidden;
  cursor: pointer;
  outline: none;
  transform: perspective(600px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) scale(var(--s, 1));
  transition: transform 0.35s var(--ease), border-color 0.2s;
  opacity: 0;
  translate: 0 18px;
}
.is-in .tile, .grid--full .tile { animation: tileIn 0.7s var(--spring) forwards; animation-delay: calc(var(--i) * 55ms + 150ms); }
@keyframes tileIn {
  from { opacity: 0; translate: 0 18px; rotate: -4deg; }
  to { opacity: 1; translate: 0 0; rotate: 0deg; }
}
.tile:hover, .tile:focus-visible { --s: 1.04; z-index: 2; }
.tile:focus-visible { box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--fg); }

.tile__face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 10%;
}
.tile__face img, .tile__face svg { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile--image .tile__face, .tile--project .tile__face { padding: 0; }
.tile--image .tile__face img { object-fit: cover; }
.tile__n { position: absolute; top: 8px; left: 10px; font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; }
.grid:not(.grid--full) .tile__peek { display: none; }
.tile__peek { position: absolute; left: 10px; right: 10px; bottom: 10px; font-weight: 800; font-stretch: 125%; text-transform: uppercase; font-size: 13px; line-height: 1; }
/* Logos are used as a mask, so whatever colours the file has, it's drawn in the screen's text colour */
.tile__logo {
  width: 88%;
  height: 60%;
  background: currentColor;
  -webkit-mask: var(--logo) center / contain no-repeat;
  mask: var(--logo) center / contain no-repeat;
}
.tile__wordmark { font-weight: 900; font-stretch: 125%; text-transform: uppercase; text-align: center; line-height: 0.9; font-size: clamp(11px, 1.05vw, 15px); overflow-wrap: anywhere; }
.grid--full .tile__wordmark { font-size: clamp(16px, 1.8vw, 24px); }
.tile__book {
  position: absolute; inset: 14% 22%;
  border: 1.5px solid var(--line);
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 8px;
  font-size: 10px; line-height: 1.1; font-weight: 700; text-transform: uppercase;
  box-shadow: 6px 6px 0 -1.5px var(--bg), 6px 6px 0 0 var(--line);
}

/* Hover card: the hatched inversion */
.tile__hover {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
  padding: 12px;
  color: var(--accent-ink);
  background:
    repeating-linear-gradient(135deg, transparent 0 13px, var(--hatch) 13px 14.5px),
    var(--accent);
  clip-path: inset(100% 0 0 0);
  transition: clip-path 0.45s var(--ease);
}
.tile:hover .tile__hover, .tile:focus-visible .tile__hover { clip-path: inset(0 0 0 0); }
.tile__title {
  font-weight: 900;
  font-stretch: 125%;
  text-transform: uppercase;
  line-height: 0.92;
  letter-spacing: -0.02em;
  font-size: clamp(13px, 1.35vw, 20px);
}
.grid--full .tile__title { font-size: clamp(16px, 1.6vw, 24px); }
.tile__line { font-size: 12px; line-height: 1.25; font-weight: 500; }
.tile__meta { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Pictures: just one line on hover */
.tile--image .tile__hover {
  inset: auto 0 0 0;
  padding: 8px 10px;
  background: var(--accent);
}
.tile--image .tile__line { font-weight: 700; }

.btn {
  align-self: flex-start;
  border: 1.5px solid currentColor;
  padding: 6px 10px 5px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: 999px;
  transition: background 0.2s, color 0.2s;
}
.btn:hover { background: var(--accent-ink); color: var(--accent); }

/* ---------- Overlay (expanded grid + post) ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--bg);
  color: var(--fg);
  overflow-y: auto;
  overscroll-behavior: contain;
  clip-path: inset(100% 0 0 0);
  transition: clip-path 0.65s var(--ease);
}
.overlay.is-open { clip-path: inset(0 0 0 0); }
.overlay[hidden] { display: none; }

.ov__bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 58px var(--gutter) 14px;
  background: var(--bg);
  border-bottom: 1.5px solid var(--line);
}
.ov__bar .ov__actions { display: flex; gap: 22px; }
.ov__grid {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 80px var(--gutter);
}

.post {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: clamp(24px, 5vw, 80px);
  padding: 48px var(--gutter) 80px;
}
.post__heading {
  position: sticky;
  top: 120px;
  align-self: start;
  font-size: clamp(44px, 7.4vw, 132px);
  overflow-wrap: anywhere;
  hyphens: auto;
}
.post__meta { display: flex; flex-wrap: wrap; gap: 8px 22px; padding-bottom: 18px; margin-bottom: 26px; border-bottom: 1.5px solid var(--line); }
.post__body { max-width: 62ch; font-size: clamp(16px, 1.25vw, 19px); line-height: 1.6; }
.post__body p { margin: 0 0 1.1em; }
.post__body ul { list-style: none; margin: 0 0 1.1em; padding: 0; display: grid; gap: 0.6em; }
.post__body li { position: relative; padding-left: 1.3em; }
.post__body li::before { content: "→"; position: absolute; left: 0; }
.post__body h3 { font-weight: 900; font-stretch: 125%; text-transform: uppercase; letter-spacing: -0.01em; font-size: 1.35em; line-height: 1; margin: 1.8em 0 0.7em; }
.post__lede { font-size: 1.3em; line-height: 1.3; font-weight: 600; }
/* Roles at one company, newest first, strung on a line like a small timeline */
.roles { display: grid; gap: 36px; border-left: 1.5px solid var(--line); padding-left: 22px; }
.role { position: relative; }
.role::before { content: ""; position: absolute; left: -29px; top: 0.35em; width: 12px; height: 12px; border-radius: 50%; background: var(--fg); }
.role h3 { margin: 0 0 6px; }
.role__dates { margin-bottom: 12px; }
.post__cta {
  margin-top: 48px; padding: 22px; border: 1.5px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
}
.post__cta b { font-weight: 900; font-stretch: 125%; text-transform: uppercase; font-size: 20px; }
.post__nav { display: flex; justify-content: space-between; gap: 16px; margin-top: 28px; }

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

.footer { min-height: 0; display: flex; flex-direction: column; gap: 56px; scroll-snap-align: end; }
.footer__cols { display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; }
.footer__links { display: grid; gap: 4px; justify-items: start; }
.footer__bottom { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.clock { font-variant-numeric: tabular-nums; }

/* ---------- Toast & cursor ---------- */

.toast {
  position: fixed;
  left: 50%; bottom: 24px;
  z-index: 60;
  translate: -50% 0;
  display: flex; gap: 14px; align-items: center;
  padding: 12px 18px 11px;
  background: var(--fg); color: var(--bg);
  font-weight: 700; font-size: 13px;
  transform: translateY(calc(100% + 40px)) rotate(-4deg);
  visibility: hidden;
  transition: transform 0.5s var(--spring), visibility 0s 0.5s;
}
.toast.is-on { transform: none; visibility: visible; transition: transform 0.5s var(--spring); }
.toast a { text-decoration: underline; font-weight: 500; }

.cursor {
  position: fixed; left: 0; top: 0; z-index: 70;
  width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border-radius: 999px;
  background: #fff;
  mix-blend-mode: difference;
  pointer-events: none;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 900; font-stretch: 125%; letter-spacing: 0.04em;
  color: #000;
  transition: width 0.35s var(--spring), height 0.35s var(--spring), margin 0.35s var(--spring);
}
.cursor span { opacity: 0; transition: opacity 0.2s; }
.cursor.has-label { width: 76px; height: 76px; margin: -38px 0 0 -38px; }
.cursor.has-label span { opacity: 1; }
@media (hover: none), (pointer: coarse) { .cursor { display: none; } }

/* ---------- Responsive ---------- */

@media (max-width: 860px) {
  .sec {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto auto;
    grid-template-areas: "num" "title" "grid" "cue";
    align-content: space-between;
  }
  .post { grid-template-columns: 1fr; }
  .post__heading { position: static; }
  .footer__cols { grid-template-columns: 1fr 1fr; }
  .grid--full { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; }
}

/* No hover on touch: show titles under tiles in the expanded view */
@media (hover: none) {
  .grid--full .tile__hover { clip-path: none; inset: auto 0 0 0; padding: 8px; background: var(--accent); }
  .grid--full .tile__line { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; transition-delay: 0s !important; }
}
