/* ==========================================================================
   Swaliya Ali — portfolio
   Layout and type modelled on the Nothin' studio case-study template.
   Tokens follow the portfolio design system (design system.pdf, boards 00–07):
   source values are locked; only letter spacing and the marked accessibility
   additions differ from the original build.
   ========================================================================== */

/* ---------- Tokens ---------- */
:root {
  /* Colour: the five source colours. The interface uses no others. */
  --white: #fff;
  --black: #000;
  --neutral: #e3e1de;
  --paper: #f2f1ef;
  --muted: #5c5c5c; /* foreground/secondary: 6.7:1 on white, 5.9:1 on paper */
  /* Accessibility roles added by the design system */
  --muted-inverse: #b8b8b8; /* foreground/secondary on black: 10.6:1 (#5c5c5c is only 3.1:1 there) */
  --control: #767676; /* border/control: 4.5:1 on white, 4.6:1 on black. Only for a boundary that identifies a control, never for decorative rules */

  /* Page colours. JS swaps these, and --muted, when a [data-bg] zone scrolls into view. */
  --bg: var(--white);
  --fg: var(--black);
  --line: color-mix(in srgb, var(--fg) 18%, transparent); /* border/decorative */

  --sans: "Inter Tight", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --fs-xs: 0.75rem;
  --fs-s: 0.875rem;
  --fs-m: 1.25rem;
  --fs-l: clamp(1.25rem, 1.05rem + 0.6vw, 1.5625rem);
  --fs-xl: clamp(1.75rem, 1.2rem + 1.8vw, 2.5rem);
  --fs-2xl: clamp(2.25rem, 1.4rem + 2.8vw, 3.25rem);
  --fs-h1: clamp(3rem, 1.2rem + 6.2vw, 6.25rem);
  --fs-hero: clamp(3.75rem, 0.5rem + 13vw, 12.5rem);

  /* Grid: 12-column stretch, no max width. Margin / gutter: 30/20 from 992px, 20/20, then 16/16 up to 479px */
  --pad: 1.25rem;
  --gap: 1.25rem;

  /* Fluid vertical rhythm: keep the clamps, never fix them */
  --space-section: clamp(5rem, 10vw, 9.375rem); /* 80 → 150px */
  --space-block: clamp(4rem, 9vw, 8.75rem);     /* 64 → 140px, case-study blocks */
  --space-hero: clamp(3rem, 8vw, 7rem);         /* 48 → 112px, top of the home page */

  /* Geometry: flat by design. No shadows, gradients or other radii */
  --radius-focus: 2px;
  --radius-media: 4px;
  --radius-pill: 999px;

  /* Motion */
  --ease: cubic-bezier(0.7, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-zone: 0.7s;
  --dur-button: 0.3s;
  --dur-underline: 0.45s;
  --dur-menu: 0.7s;
  --dur-reveal: 0.9s;
  --dur-bob: 6s;
}

@media (min-width: 992px) {
  :root { --pad: 1.875rem; }
}

@media (max-width: 479px) {
  :root { --pad: 1rem; --gap: 1rem; }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background-color: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: var(--fs-s);
  font-weight: 500;
  line-height: 1.1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--dur-zone) var(--ease), color var(--dur-zone) var(--ease);
  overflow-x: hidden;
}
h1, h2, h3, h4, p, ul, ol, dl, dd, figure, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; height: auto; }
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); }

:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
  border-radius: var(--radius-focus);
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  left: var(--pad); top: 0.75rem;
  z-index: 200;
  padding: 0.75rem 1rem;
  background: var(--fg); color: var(--bg);
  border-radius: var(--radius-pill);
  transform: translateY(-200%);
  transition: transform 0.2s;
}
.skip-link:focus { transform: none; }

/* ---------- Layout ---------- */
.container { width: 100%; padding-left: var(--pad); padding-right: var(--pad); }
.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--gap);
}

/* ---------- Type ---------- */
.label, .mono {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.p-m { font-size: var(--fs-m); line-height: 1.25; font-weight: 400; }
.p-l { font-size: var(--fs-l); line-height: 1.15; letter-spacing: -0.01em; }
.p-xl { font-size: var(--fs-xl); line-height: 1.05; letter-spacing: -0.015em; }
.h1-case {
  font-size: var(--fs-h1);
  font-weight: 500;
  line-height: 0.95;
  letter-spacing: -0.025em;
}
.h-hero {
  font-size: var(--fs-hero);
  font-weight: 500;
  line-height: 0.85;
  letter-spacing: -0.045em;
}
.muted { color: var(--muted); }

/* Split-letter title reveal (JS adds .is-split, then .is-in).
   Each word clips its letters so they can rise into place. Inter Tight's glyphs are 1.21em tall
   (ascent 0.97 + descent 0.24), more than these titles' line-heights (0.85–0.95), so the clip box
   reaches the overhang, (1.21em − line-height) / 2, above and below the line; negative margins keep
   it out of the layout. The first pair is a fallback for browsers without the lh unit. */
.split .word {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  padding-block: 0.2em;
  margin-block: -0.2em;
  padding-block: max(0px, (1.21em - 1lh) / 2);
  margin-block: min(0px, (1lh - 1.21em) / 2);
}
.split .char { display: inline-block; }
.is-split .char {
  /* A full glyph height down: starts entirely below the clip box */
  transform: translateY(1.21em);
  transition: transform var(--dur-reveal) var(--ease-out);
  transition-delay: calc(var(--i) * 28ms);
}
.is-split.is-in .char { transform: none; }

/* Scroll reveal */
.js .reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity var(--dur-reveal) var(--ease-out), transform var(--dur-reveal) var(--ease-out);
}
.js .reveal.is-visible { opacity: 1; transform: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 2.75rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-pill);
  background: var(--fg);
  color: var(--bg);
  border: 1px solid var(--fg);
  font-size: var(--fs-s);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.005em;
  white-space: nowrap;
  transition: background-color var(--dur-button), color var(--dur-button);
}
.btn--outline { background: transparent; color: var(--fg); }
.btn--outline:hover { background: var(--fg); color: var(--bg); }
.btn--sm { position: relative; min-height: 2.25rem; padding: 0.5rem 1rem; }
/* 36px visual, 44px touch target: the hit area grows, the type and layout don't */
.btn--sm::before { content: ""; position: absolute; inset: -0.25rem 0; }
.btn-arrow {
  display: inline-block;
  overflow: hidden;
  width: 1em; height: 1em;
  position: relative;
}
.btn-arrow::before, .btn-arrow::after {
  content: "→";
  position: absolute; inset: 0;
  line-height: 1;
  transition: transform 0.45s var(--ease);
}
.btn-arrow::after { transform: translateX(-120%); }
.btn:hover .btn-arrow::before { transform: translateX(120%); }
.btn:hover .btn-arrow::after { transform: none; }
.btn-arrow--ne::before, .btn-arrow--ne::after { content: "↗"; }

.link-u {
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size var(--dur-underline) var(--ease);
  padding-bottom: 2px;
}
.link-u:hover, .link-u[aria-current="page"] { background-size: 100% 1px; }
/* Links inside running text are underlined by default, so they don't rely on hover to be found */
.link-u--inline { background-size: 100% 1px; }
/* 12px mono links: grow the hit area to 24px without moving the text or its underline */
.nav-social a, .footer-bottom a { position: relative; }
.nav-social a::before, .footer-bottom a::before { content: ""; position: absolute; inset: -0.3rem -0.25rem; }

/* ---------- Header ---------- */
.site-header { position: relative; z-index: 50; padding-top: 1.25rem; }
.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}
.wordmark {
  display: inline-flex;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.045em;
  line-height: 1;
  overflow: hidden;
  padding-bottom: 0.1em;
}
.wordmark span { display: inline-block; transition: transform 0.5s var(--ease); }
.wordmark:hover span { transform: translateY(-110%); }
.wordmark:hover span:nth-child(2) { transition-delay: 0.03s; }
.wordmark:hover span:nth-child(3) { transition-delay: 0.06s; }
.wordmark:hover span:nth-child(4) { transition-delay: 0.09s; }
.wordmark:hover span:nth-child(5) { transition-delay: 0.12s; }
.wordmark:hover span:nth-child(6) { transition-delay: 0.15s; }
.wordmark:hover span:nth-child(7) { transition-delay: 0.18s; }
.wordmark:hover span:nth-child(8) { transition-delay: 0.21s; }
.wordmark span { text-shadow: 0 1.1em 0 currentColor; }

.nav-links { display: flex; align-items: center; gap: 2rem; }
.nav-links ul { display: flex; gap: 1.5rem; }
.nav-links ul a { display: inline-block; padding: 0.35rem 0; }
.menu-btn { display: none; min-height: 2.75rem; padding: 0 1rem; border: 1px solid currentColor; border-radius: var(--radius-pill); }

.nav-sub {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  border-top: 1px solid var(--line);
}
.nav-social { display: flex; gap: 1.25rem; }

@media (max-width: 767px) {
  .menu-btn { display: inline-flex; align-items: center; position: relative; z-index: 2; }
  .js .nav-links {
    position: fixed;
    inset: 0;
    z-index: 1;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    gap: 2rem;
    padding: 6rem var(--pad) 2.5rem;
    background: var(--fg);
    color: var(--bg);
    clip-path: inset(0 0 100% 0);
    visibility: hidden;
    transition: clip-path var(--dur-menu) var(--ease), visibility 0s var(--dur-menu);
  }
  .js .nav-links ul { flex-direction: column; gap: 0.25rem; }
  .js .nav-links ul a { font-size: clamp(3rem, 15vw, 4.5rem); letter-spacing: -0.04em; line-height: 1; }
  .js .nav-links .btn { background: var(--bg); color: var(--fg); border-color: var(--bg); }
  .menu-open .nav-links { clip-path: inset(0); visibility: visible; transition: clip-path var(--dur-menu) var(--ease), visibility 0s; }
  .menu-open .menu-btn { color: var(--bg); }
  .menu-open .wordmark { position: relative; z-index: 2; color: var(--bg); }
  .menu-open body { overflow: hidden; }
  .no-js-hide, .nav-sub .nav-social { display: none; }
  html:not(.js) .nav { flex-wrap: wrap; }
  html:not(.js) .nav-links { flex-wrap: wrap; gap: 1rem; }
}

/* ---------- Loader (home only) ---------- */
.loader { display: none; }
.is-loading .loader {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  background: var(--white);
  color: var(--black);
  overflow: hidden;
  transition: transform 0.9s var(--ease);
  /* CSS fallback if the script never runs */
  animation: loader-out 0.9s var(--ease) 3.4s forwards;
}
.is-loaded .loader { transform: translateY(-100%); }
@keyframes loader-out { to { transform: translateY(-100%); visibility: hidden; } }

.loader-word {
  display: flex;
  font-size: clamp(4rem, 18vw, 15rem);
  font-weight: 600;
  letter-spacing: -0.06em;
  line-height: 0.9;
  overflow: hidden;
  padding-bottom: 0.08em;
}
.loader-word span { display: inline-block; transform: translateY(110%); animation: rise 0.9s var(--ease-out) forwards; }
.loader-word span:nth-child(1) { animation-delay: 0.15s; }
.loader-word span:nth-child(2) { animation-delay: 0.21s; }
.loader-word span:nth-child(3) { animation-delay: 0.27s; }
.loader-word span:nth-child(4) { animation-delay: 0.33s; }
.loader-word span:nth-child(5) { animation-delay: 0.39s; }
.loader-word span:nth-child(6) { animation-delay: 0.45s; }
.loader-word span:nth-child(7) { animation-delay: 0.51s; }
.loader-word span:nth-child(8) { animation-delay: 0.57s; }
@keyframes rise { to { transform: none; } }

.loader-obj {
  position: absolute;
  width: clamp(4.5rem, 11vw, 9rem);
  transform: scale(0) rotate(-20deg);
  animation: pop 0.7s var(--ease-out) forwards;
}
.loader-obj:nth-of-type(1) { top: 14%; left: 12%; animation-delay: 0.7s; }
.loader-obj:nth-of-type(2) { top: 10%; right: 16%; animation-delay: 0.85s; }
.loader-obj:nth-of-type(3) { bottom: 14%; left: 20%; animation-delay: 1s; }
.loader-obj:nth-of-type(4) { bottom: 12%; right: 12%; animation-delay: 1.15s; }
.loader-obj:nth-of-type(5) { top: 44%; left: 4%; animation-delay: 1.3s; }
.loader-obj:nth-of-type(6) { top: 40%; right: 4%; animation-delay: 1.45s; }
@keyframes pop { to { transform: scale(1) rotate(0deg); } }
.loader-count { position: absolute; left: var(--pad); bottom: var(--pad); }

/* ---------- Home: hero ---------- */
.hero { padding-top: var(--space-hero); }
.hero-top { margin-bottom: 1.5rem; }
.hero-top > :first-child { grid-column: 1 / span 6; }
.hero-top > :last-child { grid-column: 7 / -1; text-align: right; }
.hero-objects {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--gap);
  margin: clamp(2rem, 5vw, 4.5rem) 0;
}
.hero-objects img {
  width: 100%;
  animation: bob var(--dur-bob) ease-in-out infinite;
  transition: transform 0.6s var(--ease-out);
}
.hero-objects img:nth-child(2) { animation-delay: -1s; }
.hero-objects img:nth-child(3) { animation-delay: -2s; }
.hero-objects img:nth-child(4) { animation-delay: -3s; }
.hero-objects img:nth-child(5) { animation-delay: -4s; }
.hero-objects img:nth-child(6) { animation-delay: -5s; }
.hero-objects img:hover { animation-play-state: paused; transform: scale(1.08) rotate(-6deg); }
@keyframes bob {
  0%, 100% { translate: 0 0; rotate: 0deg; }
  50% { translate: 0 -10px; rotate: 3deg; }
}
/* WCAG 2.2.2: decorative bobbing stops once it has been on screen for 5 seconds (main.js adds .is-resting) */
.hero-objects img.is-resting, .about-obj.is-resting { animation-play-state: paused; }
.hero-bottom > :first-child { grid-column: 1 / span 5; }
.hero-bottom > :last-child { grid-column: 7 / -1; }

/* ---------- Section heads ---------- */
.section { padding-top: var(--space-section); }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 0.75rem;
}

/* ---------- Home: works tabs ---------- */
.works-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: var(--gap);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.works-tab {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 1.25rem 0;
  font-size: var(--fs-xl);
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--muted);
  transition: color 0.35s;
}
.works-tab::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.6s var(--ease);
}
.works-tab:hover, .works-tab[aria-selected="true"] { color: var(--fg); }
.works-tab[aria-selected="true"]::after { transform: none; }
.works-tab-count { letter-spacing: 0.03em; }
html:not(.js) .works-tab { color: var(--fg); }
html:not(.js) .works-tab::after { display: none; }

/* Leaves the section head and tab bar in view when the URL points at a panel */
.works-panel { scroll-margin-top: 9rem; }
.works-panel-intro { row-gap: 0.75rem; padding: clamp(1.5rem, 3vw, 2.25rem) 0 clamp(2rem, 4vw, 3rem); }
.works-panel-intro > .label { grid-column: 1 / span 6; }
.works-panel-intro > .p-m { grid-column: 7 / -1; max-width: 38em; }
.js .works-panel:not([hidden]) .works-panel-intro { animation: panel-in 0.6s var(--ease-out); }
@keyframes panel-in { from { opacity: 0; transform: translateY(12px); } }

/* ---------- Home: works list ---------- */
.works-list { border-top: 1px solid var(--line); }
.works-list li { border-bottom: 1px solid var(--line); }
.work-row {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--gap);
  align-items: baseline;
  padding: 1.25rem 0;
  transition: color 0.35s;
}
.work-nbr { grid-column: span 1; }
.work-title {
  grid-column: span 5;
  font-size: var(--fs-xl);
  letter-spacing: -0.02em;
  line-height: 1;
  transition: transform 0.5s var(--ease);
}
.work-client { grid-column: span 2; }
.work-tags { grid-column: span 3; }
.work-year { grid-column: span 1; text-align: right; }
.work-thumb { display: none; }
/* Listed project whose case study isn't published yet: not a link, no hover preview */
.work-row--soon { color: var(--muted); }
@media (hover: hover) and (pointer: fine) {
  .works-list:hover .work-row { color: var(--muted); }
  .works-list .work-row:hover { color: var(--fg); }
  .work-row:hover .work-title { transform: translateX(1.25rem); }
  .works-list .work-row--soon:hover { color: var(--muted); }
  .work-row--soon:hover .work-title { transform: none; }
}

.hover-preview {
  position: fixed;
  left: 0; top: 0;
  z-index: 40;
  width: clamp(16rem, 26vw, 26rem);
  aspect-ratio: 16 / 10;
  pointer-events: none;
  opacity: 0;
  scale: 0.85;
  transition: opacity 0.35s, scale 0.5s var(--ease-out);
  will-change: transform;
}
.hover-preview.is-active { opacity: 1; scale: 1; }
.hover-preview img { width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius-media); }

/* ---------- Home: intro / about teaser ---------- */
.intro-aside { grid-column: 1 / span 4; display: grid; gap: 1.5rem; align-content: start; justify-items: start; }
.intro-photo { width: min(100%, 18rem); height: auto; border-radius: var(--radius-media); background: var(--paper); }
.intro-body { grid-column: 5 / -1; display: grid; gap: 2rem; justify-items: start; }
.orgs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--gap);
  width: 100%;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}
.orgs li { display: grid; gap: 0.35rem; }
.orgs strong { font-size: var(--fs-m); font-weight: 500; letter-spacing: -0.02em; }

/* ---------- Case study ---------- */
.case-hero { padding-top: clamp(4rem, 10vw, 9.375rem); }
.case-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}
.case-nbr { font-family: var(--mono); font-size: var(--fs-m); font-weight: 400; padding-top: 0.5em; }
.case-intro { margin-top: clamp(2.5rem, 6vw, 4.0625rem); row-gap: 2rem; }
.case-meta { grid-column: 1 / span 4; display: grid; gap: 0.75rem; align-content: start; }
.tags { display: flex; flex-wrap: wrap; gap: 0.25rem 0.5rem; }
.tags li + li::before { content: "/ "; }
.case-desc { grid-column: 7 / -1; display: grid; gap: 1.5rem; align-content: start; }
.pull { font-size: var(--fs-l); line-height: 1.15; letter-spacing: -0.01em; }
.pull::before { content: "“"; }
.pull::after { content: "”"; }

.case-hero + .work-img { margin-top: var(--space-block); }
.work-img + .work-img, .work-img + .work-pair, .work-pair + .work-img { margin-top: var(--gap); }
.case-block { padding-top: var(--space-block); padding-bottom: var(--space-block); row-gap: 1.5rem; }
.case-block + .case-block { padding-top: 0; }
.case-block > .label { grid-column: 1 / span 4; }
.case-block-body { grid-column: 7 / -1; display: grid; gap: 1.75rem; }
.case-block-body > ul { display: grid; gap: 0.5rem; }
.case-block-body > ul > li { font-size: var(--fs-m); line-height: 1.25; font-weight: 400; padding-left: 1.25rem; position: relative; }
.case-block-body > ul > li::before { content: "—"; position: absolute; left: 0; }
.closing { font-size: var(--fs-xl); line-height: 1.02; letter-spacing: -0.03em; }

.work-imgs { display: grid; gap: var(--gap); }
.work-img img { width: 100%; height: auto; background: var(--paper); }
.work-img.std { padding-left: var(--pad); padding-right: var(--pad); }
.work-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  padding-left: var(--pad);
  padding-right: var(--pad);
}

.credits { padding-top: var(--space-block); row-gap: 1.5rem; }
.credits > .label { grid-column: 1 / span 4; }
.credits-list { grid-column: 7 / -1; border-top: 1px solid var(--line); }
.credits-list > div {
  display: grid;
  grid-template-columns: minmax(7rem, 1fr) 2fr;
  gap: var(--gap);
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}
.credits-list dt { font-family: var(--mono); font-size: var(--fs-xs); font-weight: 400; text-transform: uppercase; line-height: 1.5; }
.credits-list dd { font-size: var(--fs-s); line-height: 1.35; }
.credits-actions { grid-column: 7 / -1; display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.5rem; }

/* ---------- Long-form case study components ---------- */
.case-block--wide > .label,
.case-block--wide .case-block-body { grid-column: 1 / -1; }
.case-block--wide .case-block-body { gap: 2.5rem; }
/* Let scroll regions (tables, galleries, diagrams) scroll inside grid items instead of widening the page */
.case-block > *, .case-block-body > *, .screen-group > *, .spotlight > * { min-width: 0; }
.case-block-intro { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gap); row-gap: 1.25rem; }
.case-block-intro > * { grid-column: 7 / -1; }
.case-block-intro > .p-xl { grid-column: 1 / span 8; }
.anchor { scroll-margin-top: 1.5rem; }

.case-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin-top: clamp(2.5rem, 5vw, 4rem);
  padding: 0.85rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.case-toc a { display: inline-block; padding: 0.35rem 0; }

.facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.25rem var(--gap);
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}
.facts dt { font-family: var(--mono); font-size: var(--fs-xs); font-weight: 400; text-transform: uppercase; line-height: 1.5; }
.facts dd { font-size: var(--fs-m); letter-spacing: -0.01em; line-height: 1.2; margin-top: 0.35rem; }

.info-grid { display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); gap: var(--gap); }
.info-card {
  display: grid;
  align-content: start;
  gap: 0.75rem;
  padding: 1.25rem;
  background: var(--paper);
  border-radius: var(--radius-media);
}
.info-card h3 { font-size: var(--fs-l); font-weight: 500; letter-spacing: -0.01em; line-height: 1.1; }
.info-card p, .info-card li { font-size: var(--fs-s); font-weight: 400; line-height: 1.45; }
.info-card ul { display: grid; gap: 0.35rem; }
.info-card li { padding-left: 1.1rem; position: relative; }
.info-card li::before { content: "—"; position: absolute; left: 0; }
.info-card .label { margin-bottom: 0.5rem; }

.table-scroll { overflow-x: auto; }
.data-table { width: 100%; min-width: 40rem; border-collapse: collapse; text-align: left; }
.data-table th {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 400;
  text-transform: uppercase;
  padding: 0 1.25rem 0.75rem 0;
  border-bottom: 1px solid var(--fg);
}
.data-table td {
  padding: 1rem 1.25rem 1rem 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: var(--fs-s);
  font-weight: 400;
  line-height: 1.45;
}
.data-table td:first-child { font-weight: 500; font-size: var(--fs-m); line-height: 1.2; }

.ideas { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3rem var(--gap); }
.ideas h3 { font-size: var(--fs-l); font-weight: 500; letter-spacing: -0.02em; padding-bottom: 0.75rem; border-bottom: 1px solid var(--fg); }
.idea-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.4rem 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
}
.idea-list h4 { font-size: var(--fs-m); font-weight: 500; letter-spacing: -0.01em; line-height: 1.2; }
.idea-list p { grid-column: 1 / -1; font-size: var(--fs-s); font-weight: 400; line-height: 1.45; }
.pill {
  align-self: start;
  font-family: var(--mono);
  font-size: var(--fs-xs);
  font-weight: 400;
  text-transform: uppercase;
  line-height: 1;
  letter-spacing: 0;
  padding: 0.35rem 0.6rem;
  border: 1px solid currentColor;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}
.pill--solid { background: var(--fg); color: var(--bg); border-color: var(--fg); }

.rules { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--gap); border-top: 1px solid var(--line); }
.rules li {
  display: grid;
  grid-template-columns: 3rem 1fr;
  align-items: baseline;
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--fs-l);
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.screen-group { display: grid; gap: 1.5rem; }
.screen-group + .screen-group { margin-top: clamp(3rem, 6vw, 5rem); }
.screen-group-head { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gap); row-gap: 0.75rem; padding-top: 0.85rem; border-top: 1px solid var(--line); }
.screen-group-head h3 { grid-column: 1 / span 5; font-size: var(--fs-xl); font-weight: 500; letter-spacing: -0.03em; line-height: 1; }
.screen-group-head p { grid-column: 7 / -1; font-size: var(--fs-m); font-weight: 400; line-height: 1.25; }
.screens { display: flex; flex-wrap: wrap; gap: 2.5rem var(--gap); }
.screen { flex: 0 0 calc((100% - 4 * var(--gap)) / 5); display: grid; gap: 0.85rem; align-content: start; }
.screens--6 .screen { flex-basis: calc((100% - 5 * var(--gap)) / 6); }
.screen img { width: 100%; height: auto; }
.screen figcaption { display: grid; gap: 0.3rem; }
.screen figcaption strong { font-size: var(--fs-s); font-weight: 500; line-height: 1.2; }
.screen figcaption span { font-size: var(--fs-s); font-weight: 400; line-height: 1.4; color: var(--muted); }

.spotlight { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--gap); row-gap: 2rem; align-items: center; }
.spotlight-text { grid-column: 1 / span 5; display: grid; gap: 1.5rem; }
.spotlight .screens { grid-column: 8 / -1; }
.spotlight .screen { flex-basis: calc((100% - var(--gap)) / 2); }

.figure-scroll { overflow-x: auto; }
.figure-scroll img { width: 100%; min-width: 48rem; height: auto; }
.figure-note { margin-top: 0.75rem; }

.journey-group + .journey-group { margin-top: 3rem; }
.journey-group > h3 { font-size: var(--fs-l); font-weight: 500; letter-spacing: -0.02em; padding-bottom: 0.75rem; border-bottom: 1px solid var(--fg); }
.journey {
  display: grid;
  grid-template-columns: minmax(9rem, 2fr) 7fr minmax(12rem, 3fr);
  gap: 0.75rem var(--gap);
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
}
.journey-name { display: grid; gap: 0.25rem; }
.journey-name strong { font-size: var(--fs-m); font-weight: 500; letter-spacing: -0.01em; }
.steps { display: flex; flex-wrap: wrap; gap: 0.4rem 0.5rem; }
.steps li { font-size: var(--fs-s); font-weight: 400; line-height: 1.4; }
.steps li + li::before { content: "→"; margin-right: 0.5rem; }
.journey-exception { font-size: var(--fs-s); font-weight: 400; line-height: 1.4; }

.qa { border-top: 1px solid var(--line); }
.qa details { border-bottom: 1px solid var(--line); }
.qa summary {
  display: grid;
  grid-template-columns: 3rem 1fr auto;
  align-items: baseline;
  gap: 1rem;
  padding: 1.25rem 0;
  cursor: pointer;
  list-style: none;
  font-size: var(--fs-l);
  letter-spacing: -0.01em;
  line-height: 1.15;
}
.qa summary::-webkit-details-marker { display: none; }
.qa summary::after { content: "+"; content: "+" / ""; font-family: var(--mono); font-size: var(--fs-m); }
.qa details[open] summary::after { content: "−"; content: "−" / ""; }
.qa details p { padding: 0 0 1.5rem 4rem; max-width: 62ch; font-size: var(--fs-m); font-weight: 400; line-height: 1.3; }

/* ---------- Confidential (work experience) case studies ---------- */
.case-kind { display: flex; flex-wrap: wrap; gap: 0.4rem; }
/* Confidentiality notice under the cover */
.nda { margin-top: var(--gap); }
.nda-box {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--gap);
  row-gap: 0.75rem;
  align-items: baseline;
  padding: clamp(1.25rem, 3vw, 2rem);
  background: var(--paper);
  border-radius: var(--radius-media);
}
.nda-box > .label { grid-column: 1 / span 5; }
.nda-text { grid-column: 7 / -1; display: grid; gap: 0.6rem; }
.nda-text p { font-size: var(--fs-s); font-weight: 400; line-height: 1.45; }
.nda-text p:first-child { font-size: var(--fs-m); line-height: 1.25; }

/* Consecutive text-only blocks get a rule above each one */
.case-block--ruled::before { content: ""; grid-column: 1 / -1; border-top: 1px solid var(--line); }
.case-block--ruled { padding-bottom: clamp(3.5rem, 7vw, 6.5rem); }

.process-list { border-top: 1px solid var(--line); }
.process-list li {
  display: grid;
  grid-template-columns: 3rem 1fr;
  gap: 0.35rem 0;
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
}
.process-list .mono { grid-row: span 2; padding-top: 0.3em; }
.process-list h3 { font-size: var(--fs-m); font-weight: 500; letter-spacing: -0.01em; line-height: 1.2; }
.process-list p { grid-column: 2; font-size: var(--fs-s); font-weight: 400; line-height: 1.45; }

.pull--xl { font-size: var(--fs-xl); line-height: 1.05; letter-spacing: -0.015em; }
.note { font-size: var(--fs-s); font-weight: 400; line-height: 1.45; color: var(--muted); max-width: 62ch; }

/* Caption under each visual: marks it as an illustration, separate from the actual work */
.work-cap {
  display: grid;
  gap: 0.25rem;
  margin-top: 0.75rem;
  max-width: 62rem;
  font-size: var(--fs-s);
  font-weight: 400;
  line-height: 1.45;
  color: var(--muted);
}
.work-cap .label { color: var(--fg); }
.work-img.full > .work-cap { padding-left: var(--pad); padding-right: var(--pad); }

/* Line icons drawn inline (stroke follows the text colour) */
.icon { width: 2rem; height: 2rem; flex: none; }
.info-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 0.5rem; }
.case-block > .info-grid { grid-column: 1 / -1; }

/* Full-width HTML diagram on paper; sits between blocks like a work image */
.case-block + .diagram-panel { margin-top: 0; }
.work-img + .diagram-panel, .diagram-panel + .work-img, .diagram-panel + .diagram-panel { margin-top: var(--gap); }
.diagram {
  display: grid;
  gap: clamp(1.5rem, 3vw, 2.25rem);
  padding: clamp(1.25rem, 3.5vw, 3rem);
  background: var(--paper);
  border-radius: var(--radius-media);
}
.diagram-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0.5rem 1.5rem; }
.diagram-title { font-size: var(--fs-xl); font-weight: 500; letter-spacing: -0.02em; line-height: 1; }
.diagram .info-card { background: var(--bg); }
.diagram-sub { display: grid; gap: 0.75rem; }

/* Row of boxes: pages in a sitemap, sections in a scroll */
.nodes { display: grid; grid-template-columns: repeat(var(--n, 5), minmax(0, 1fr)); gap: 0.75rem; }
.node {
  display: grid;
  align-content: start;
  gap: 0.5rem;
  min-height: 9rem;
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--fg);
  border-radius: var(--radius-media);
}
.node strong { font-size: var(--fs-m); font-weight: 500; letter-spacing: -0.01em; line-height: 1.15; }
.node p { font-size: var(--fs-s); font-weight: 400; line-height: 1.4; color: var(--muted); }
.node--key { background: var(--fg); color: var(--bg); }
.node--key p { color: var(--bg); }
.node--cut { background: transparent; border-style: dashed; color: var(--muted); }
.node--cut strong { text-decoration: line-through; }

/* Stand-in for a long text page: grey lines, cut off by the frame to suggest more below */
.wire {
  display: grid;
  gap: 0.5rem;
  max-height: 13rem;
  overflow: hidden;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-media);
}
.wire span { height: 0.45rem; border-radius: var(--radius-pill); background: var(--neutral); }
.wire span:nth-child(4n) { width: 65%; }

@media (max-width: 991px) {
  .screen, .screens--6 .screen { flex-basis: calc((100% - 2 * var(--gap)) / 3); }
  .info-grid { --cols: 2 !important; }
  .nodes { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .journey { grid-template-columns: 1fr; }
  .spotlight-text, .spotlight .screens { grid-column: 1 / -1; }
}

@media (max-width: 767px) {
  .case-block-intro > *, .case-block-intro > .p-xl,
  .screen-group-head h3, .screen-group-head p { grid-column: 1 / -1; }
  .info-grid { --cols: 1 !important; }
  .nodes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .node { min-height: 0; }
  .ideas, .rules { grid-template-columns: 1fr; }
  .screens {
    flex-wrap: nowrap;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    margin-left: calc(-1 * var(--pad));
    margin-right: calc(-1 * var(--pad));
    padding: 0 var(--pad) 0.75rem;
    scroll-padding-left: var(--pad);
  }
  .screen, .screens--6 .screen, .spotlight .screen { flex: 0 0 66vw; scroll-snap-align: start; }
  .qa summary { grid-template-columns: 2rem 1fr auto; }
  .qa details p { padding-left: 3rem; }
}

/* ---------- End zone: CTA, next project, footer ---------- */
.end { margin-top: clamp(5rem, 11vw, 10rem); padding-top: clamp(4rem, 8vw, 6.875rem); }
.cta { display: grid; gap: 2rem; justify-items: start; }
.h-cta { font-size: var(--fs-h1); font-weight: 500; line-height: 0.95; letter-spacing: -0.03em; max-width: 12ch; }
.cta-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }

.next-project {
  display: block;
  margin-top: clamp(5rem, 10vw, 8.5rem);
  padding-top: 1.25rem;
  padding-bottom: 1.5rem;
}
.next-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-top: 1.25rem; }
.next-title { display: block; transition: transform 0.6s var(--ease); }
/* Reflow at 320px: an over-long single word (TheInnovationSTORY) wraps, like the split hero titles, instead of being clipped */
.next-title, .orgs strong, .exp-company { overflow-wrap: anywhere; }
.next-project:hover .next-title { transform: translateX(1.5rem); }
.timeline { display: block; height: 2px; margin-top: 1.5rem; background: var(--line); overflow: hidden; }
.timeline-fill {
  display: block;
  height: 100%;
  background: currentColor;
  transform-origin: left;
  transform: scaleX(var(--p, 0));
  transition: transform 0.25s linear;
}
.next-project:hover .timeline-fill { transform: scaleX(1); transition-duration: 0.8s; }

.site-footer { margin-top: clamp(4rem, 8vw, 6.875rem); overflow: hidden; }
.footer-grid { row-gap: 2rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.footer-col { grid-column: span 4; display: grid; gap: 0.75rem; align-content: start; }
.footer-col ul { display: grid; gap: 0.4rem; }
.footer-col a, .footer-col p { font-size: var(--fs-m); letter-spacing: -0.01em; line-height: 1.2; }
.footer-email { font-size: var(--fs-l) !important; word-break: break-all; }
.footer-bottom { display: flex; justify-content: space-between; gap: 1rem; margin-top: 3rem; }
.footer-wordmark {
  font-size: 27.5vw;
  font-weight: 600;
  line-height: 0.78;
  letter-spacing: -0.055em;
  margin-top: 1.5rem;
  margin-left: -0.03em;
  white-space: nowrap;
  user-select: none;
}

/* ---------- About ---------- */
.page-hero { padding-top: clamp(4rem, 10vw, 9.375rem); }
.about-block { padding-top: var(--space-block); row-gap: 1.5rem; }
.about-block > .label { grid-column: 1 / span 4; }
.about-block-body { grid-column: 5 / -1; }
.about-portrait { position: relative; max-width: 26rem; margin: 1rem 1.5rem 1.5rem 0; }
.about-photo { width: 100%; height: auto; border-radius: var(--radius-media); background: var(--paper); }
.about-obj { position: absolute; width: clamp(4rem, 7vw, 6rem); animation: bob var(--dur-bob) ease-in-out infinite; }
.about-obj--a { top: -1.5rem; right: -1.5rem; }
.about-obj--b { bottom: -1.5rem; left: -1.25rem; animation-delay: -3s; }

.exp-list { border-top: 1px solid var(--line); }
.exp-item {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  column-gap: var(--gap);
  row-gap: 1rem;
  padding: 1.5rem 0;
  border-bottom: 1px solid var(--line);
}
.exp-date { grid-column: span 2; }
.exp-main { grid-column: span 6; display: grid; gap: 0.4rem; }
.exp-company { font-size: var(--fs-xl); font-weight: 500; letter-spacing: -0.02em; line-height: 1; }
.exp-role { font-size: var(--fs-s); }
.exp-points { grid-column: 3 / -1; display: grid; gap: 0.45rem; }
.exp-points li { font-size: var(--fs-s); line-height: 1.4; font-weight: 400; padding-left: 1.1rem; position: relative; }
.exp-points li::before { content: "—"; position: absolute; left: 0; }
.exp-scope { font-size: var(--fs-s); font-weight: 400; line-height: 1.4; color: var(--muted); margin-top: 0.35rem; }
.exp-projects { grid-column: 3 / -1; line-height: 1.6; }

.method-list { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: var(--gap); grid-column: 1 / -1; margin-top: 2.5rem; }
.method-step {
  display: grid;
  align-content: start;
  gap: 1rem;
  padding: 1.25rem;
  min-height: 18rem;
  background: var(--paper);
  border-radius: var(--radius-media);
  transition: background-color 0.4s, color 0.4s;
}
.method-step:hover { background: var(--fg); color: var(--bg); }
.method-step h3 { font-size: var(--fs-l); font-weight: 500; letter-spacing: -0.01em; margin-top: auto; }
.method-step p { font-size: var(--fs-s); line-height: 1.4; font-weight: 400; }
.method-step .label { margin-bottom: 4rem; }

.skills-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2.5rem var(--gap); }
.skills-grid h3 { font-size: var(--fs-m); font-weight: 500; letter-spacing: -0.01em; padding-bottom: 0.75rem; margin-bottom: 0.75rem; border-bottom: 1px solid var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chips li { padding: 0.45rem 0.75rem; border: 1px solid var(--line); border-radius: var(--radius-pill); font-size: var(--fs-s); line-height: 1; }

.edu { display: grid; gap: 0.5rem; }
.edu strong { font-size: var(--fs-xl); font-weight: 500; letter-spacing: -0.03em; line-height: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 991px) {
  .work-title { grid-column: span 6; }
  .work-client { display: none; }
  .work-tags { grid-column: span 4; }
  .method-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .method-step:last-child { grid-column: 1 / -1; }
  .method-step { min-height: 14rem; }
  .orgs { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 1.25rem; }
}

@media (max-width: 767px) {
  .hero-top > :first-child, .hero-top > :last-child,
  .hero-bottom > :first-child, .hero-bottom > :last-child,
  .intro-aside, .intro-body,
  .works-panel-intro > .label, .works-panel-intro > .p-m,
  .nda-box > .label, .nda-text,
  .case-meta, .case-desc,
  .case-block > .label, .case-block-body,
  .credits > .label, .credits-list, .credits-actions,
  .about-block > .label, .about-block-body,
  .footer-col { grid-column: 1 / -1; }
  .hero-top > :last-child { text-align: left; }
  .hero-top { row-gap: 0.4rem; }
  .hero-bottom { row-gap: 1.25rem; }
  .hero-objects { grid-template-columns: repeat(3, minmax(0, 1fr)); }

  .works-tab { flex-direction: column; gap: 0.4rem; font-size: var(--fs-l); padding: 1rem 0 1.1rem; }
  .intro-photo { width: min(100%, 15rem); }
  .about-portrait { max-width: 20rem; }
  .about-obj--a { right: -1rem; }

  .work-row { grid-template-columns: auto 1fr auto; row-gap: 0.6rem; padding: 1.25rem 0 1.5rem; }
  .work-nbr { grid-column: 1; }
  .work-title { grid-column: 1 / -1; grid-row: 2; }
  .work-tags { grid-column: 2; }
  .work-year { grid-column: 3; }
  .work-thumb { display: block; grid-column: 1 / -1; grid-row: 3; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: var(--radius-media); margin-top: 0.4rem; }

  .work-pair { grid-template-columns: 1fr; }
  .exp-date, .exp-main, .exp-points, .exp-projects { grid-column: 1 / -1; }
  .method-list { grid-template-columns: 1fr; }
  .method-step { min-height: 0; }
  .method-step .label { margin-bottom: 1.5rem; }
  .skills-grid { grid-template-columns: 1fr; }
  .footer-bottom { flex-direction: column; }
}

@media (max-width: 479px) {
  .nav-sub > :first-child { font-size: 0.6875rem; }
  .credits-list > div { grid-template-columns: 1fr; gap: 0.35rem; }
}

/* ---------- Reduced motion ---------- */
@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;
  }
  .js .reveal { opacity: 1; transform: none; }
  .is-split .char { transform: none; }
  /* The menu and its links must become visible at once, or focus can't move into it when it opens */
  .js .nav-links, .js .nav-links * { transition: none !important; }
}
