:root {
  --bg: #ffffff;
  --fg: #0a0a0a;
  --muted: #626262;
  --line: #f0f0f0;
  --soft: #f5f5f5;
  --sans: "Inter Tight", ui-sans-serif, system-ui, sans-serif;
  --serif: "Instrument Serif", Georgia, serif;
  --max: 1400px;
  --gutter: clamp(16px, 4vw, 48px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
em { font-family: var(--serif); font-style: italic; font-weight: 400; }
img { display: block; max-width: 100%; }

.container { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.strong { font-weight: 500; }
.right { text-align: right; }
.label { font-size: 0.875rem; }
.link { transition: color .25s; }
.link:hover { color: var(--muted); }

/* ---------- Nav ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px var(--gutter);
  font-size: 0.875rem;
  mix-blend-mode: difference; color: #fff;
}
.nav-name { font-weight: 500; }
.nav-links { display: flex; gap: clamp(14px, 3vw, 32px); }
.nav-links a { opacity: .9; transition: opacity .2s; }
.nav-links a:hover { opacity: .5; }

/* ---------- Home: project carousel ---------- */
.intro { padding-top: 120px; padding-bottom: 72px; }
.intro .bio { margin: 16px 0 24px; max-width: 30ch; }

/* ---------- About ---------- */
.about {
  display: grid; grid-template-columns: 1fr; gap: 64px;
  padding-top: 64px; padding-bottom: 64px;
}
@media (min-width: 1024px) {
  .about { grid-template-columns: minmax(0, 380px) 1fr; gap: 128px; padding-top: 128px; padding-bottom: 128px; }
}
.label-row { display: flex; justify-content: space-between; margin-bottom: 16px; }
.portrait { aspect-ratio: 3 / 4; overflow: hidden; margin-bottom: 16px; background: var(--soft); }
.portrait img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(1); transition: filter .6s; }
.portrait:hover img { filter: grayscale(0); }
.portrait-placeholder {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-style: italic; font-size: 6rem; color: #d4d4d4;
}
.bio {
  font-size: clamp(1.5rem, 2.8vw, 2.4rem); font-weight: 300;
  line-height: 1.2; letter-spacing: -0.02em; max-width: 26ch;
}
.socials { display: flex; flex-wrap: wrap; gap: 24px; margin: 32px 0 64px; font-size: 0.875rem; }
.socials a { position: relative; }
.socials a::after {
  content: ""; position: absolute; left: 0; bottom: -2px; height: 1px; width: 100%;
  background: currentColor; transform: scaleX(0); transform-origin: right; transition: transform .35s;
}
.socials a:hover::after { transform: scaleX(1); transform-origin: left; }

.exp-head { display: flex; justify-content: space-between; font-size: 0.875rem; padding-bottom: 12px; border-bottom: 1px solid var(--fg); }
.exp-row {
  display: grid; grid-template-columns: 1.1fr 1.4fr 1.1fr .4fr; gap: 16px;
  font-size: 0.875rem; padding: 12px 0; border-bottom: 1px solid var(--line);
  transition: padding .3s, background .3s;
}
.exp-row:hover { padding-left: 8px; padding-right: 8px; background: var(--soft); }
@media (max-width: 600px) {
  .exp-row { grid-template-columns: 1fr auto; row-gap: 2px; }
  .exp-row span:nth-child(2) { order: 3; color: var(--muted); }
  .exp-row span:nth-child(3) { order: 4; color: var(--muted); }
}

/* ---------- Sections ---------- */
.section { padding-top: 48px; padding-bottom: 96px; }
.section-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 48px; }
.section-title { font-size: clamp(1.9rem, 3vw, 2.5rem); font-weight: 400; letter-spacing: -0.02em; margin-bottom: 8px; }

/* Projects list */
.project {
  display: grid; grid-template-columns: 48px 1fr auto; align-items: baseline; gap: 16px;
  padding: 24px 0; border-top: 1px solid var(--line);
}
.project:last-child { border-bottom: 1px solid var(--line); }
.project-name {
  font-size: clamp(1.5rem, 4vw, 3rem); font-weight: 300; letter-spacing: -0.03em;
  transition: transform .4s ease, font-style .4s;
}
.project-desc { grid-column: 2; font-size: 0.875rem; }
.project-arrow { grid-column: 3; grid-row: 1; font-size: 1.5rem; transition: transform .4s; }
.project:hover .project-name { transform: translateX(12px); font-family: var(--serif); font-style: italic; }
.project:hover .project-arrow { transform: rotate(45deg); }

/* Stories grid */
.stories { display: grid; grid-template-columns: 1fr; gap: 40px 32px; }
@media (min-width: 768px) {
  .stories { grid-template-columns: repeat(3, 1fr); }
  .story-wide { grid-column: span 2; }
}
.story-meta { font-size: 0.75rem; font-weight: 300; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }
.story-title { font-size: 1.25rem; font-weight: 400; letter-spacing: -0.01em; line-height: 1.25; }
.story-wide .story-title { font-size: clamp(1.25rem, 2vw, 1.75rem); }
.story-desc { font-size: 0.875rem; margin-top: 6px; max-width: 60ch; }

/* ---------- Footer ---------- */
.footer { padding-top: 96px; overflow: hidden; }
.footer-top { border-top: 1px solid var(--fg); padding-top: 24px; display: flex; flex-direction: column; gap: 16px; }
.footer-mail {
  font-size: clamp(1.8rem, 5vw, 4rem); font-weight: 300; letter-spacing: -0.03em;
  width: fit-content; transition: color .3s;
}
.footer-mail:hover { color: var(--muted); }
.footer-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-top: 64px; }

/* ---------- Covers (image or generated) ---------- */
.cover { aspect-ratio: 16 / 9; overflow: hidden; background: var(--soft); border: 2px solid #f2f2f2; }
.cover img { width: 100%; height: 100%; object-fit: cover; object-position: center top; transition: transform .6s ease; }
.cover-fill {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  transition: transform .6s ease; padding: 24px; text-align: center;
}
.cover-fill span { font-family: var(--serif); font-style: italic; font-size: clamp(1.6rem, 5vw, 4.5rem); letter-spacing: -0.01em; line-height: 1; }
.tone-light { background: radial-gradient(circle at 30% 30%, #ffffff, #ececec 70%); color: #111; }
.tone-dark { background: radial-gradient(circle at 70% 30%, #3a3a3a, #0a0a0a 70%); color: #f5f5f5; }
a:hover .cover img, a:hover .cover-fill { transform: scale(1.03); }
.story .cover { aspect-ratio: 16 / 10; margin-bottom: 16px; }
.story-wide .cover { aspect-ratio: 2 / 1; }
.story:not(.story-wide) .cover-fill span { font-size: clamp(1.4rem, 3vw, 2.4rem); }

/* Stories grid sits on full rows: wide(2) + small(1) */
.stories .story { display: flex; flex-direction: column; }
@media (min-width: 768px) { .stories .story:not(.story-wide) .cover { aspect-ratio: auto; flex: 1; min-height: 220px; max-height: 100%; } }

/* Projects list extras */
.project { grid-template-columns: 48px 1fr auto; }
.project-type { grid-column: 2; font-size: 0.75rem; letter-spacing: .04em; margin-top: -8px; }

/* ---------- Index page heads ---------- */
.page-head { padding-top: 160px; padding-bottom: 24px; }
.page-title {
  font-size: clamp(3rem, 12vw, 10rem); font-weight: 300; letter-spacing: -0.05em; line-height: .9; margin-top: 12px;
}
.page-title sup { font-size: .18em; letter-spacing: 0; vertical-align: top; margin-left: .3em; color: var(--muted); font-weight: 400; }
.exp-lg .exp-row { font-size: 1rem; padding: 18px 0; }
.exp-lg .exp-head { display: grid; grid-template-columns: 1.1fr 1.4fr 1.1fr .4fr; gap: 16px; }
.exp-head a { font-size: 0.875rem; }
@media (max-width: 600px) { .hide-sm { display: none; } .exp-lg .exp-head { grid-template-columns: 1fr auto; } }

/* ---------- Project / experience detail ---------- */
.detail-head { padding-top: 140px; padding-bottom: 48px; }
.detail-title { font-size: clamp(2.8rem, 9vw, 8rem); font-weight: 300; letter-spacing: -0.05em; line-height: .92; margin: 24px 0 16px; }
.detail-tagline { font-size: clamp(1.15rem, 2vw, 1.6rem); font-weight: 300; letter-spacing: -0.01em; max-width: 34ch; color: #525252; }
.meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; margin-top: 56px; padding-top: 16px; border-top: 1px solid var(--fg); }
@media (min-width: 768px) { .meta { grid-template-columns: repeat(4, 1fr); } }
.meta dt { font-size: 0.75rem; color: var(--muted); margin-bottom: 6px; }
.meta dd { font-size: 0.875rem; line-height: 1.5; }
.detail .cover { aspect-ratio: 16 / 8; }
.detail-body { padding-top: 80px; padding-bottom: 48px; }
.overview { font-size: clamp(1.4rem, 2.6vw, 2.2rem); font-weight: 300; line-height: 1.25; letter-spacing: -0.02em; max-width: 32ch; margin-bottom: 64px; }
.stack { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: baseline; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: 32px; }
.stack ul { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; }
.stack li { font-size: 0.8rem; padding: 4px 12px; border: 1px solid #e5e5e5; border-radius: 999px; }
.block { display: grid; grid-template-columns: 1fr; gap: 16px; padding: 40px 0; border-bottom: 1px solid var(--line); }
@media (min-width: 900px) { .block { grid-template-columns: 1fr 2fr; gap: 64px; } }
.block-title { font-size: 0.875rem; font-weight: 500; }
.block-body { font-size: 1.05rem; line-height: 1.65; max-width: 62ch; color: #262626; }
.block-body ul { list-style: none; }
.block-body li { padding: 10px 0 10px 28px; position: relative; border-bottom: 1px solid var(--line); }
.block-body li:last-child { border-bottom: 0; }
.block-body li::before { content: "→"; position: absolute; left: 0; color: var(--muted); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85em; background: var(--soft); padding: 1px 6px; border-radius: 4px; }

.read-story { display: flex; flex-direction: column; gap: 10px; padding: 40px; background: var(--soft); margin: 48px 0 0; transition: background .3s; }
.read-story:hover { background: #ececec; }
.read-story-title { font-size: clamp(1.4rem, 3vw, 2.4rem); font-weight: 300; letter-spacing: -0.02em; line-height: 1.1; }
.next { display: block; padding: 64px 0 24px; margin-top: 64px; border-top: 1px solid var(--fg); }
.next-title { display: block; margin-top: 12px; font-size: clamp(2rem, 6vw, 5rem); font-weight: 300; letter-spacing: -0.04em; line-height: 1; transition: color .3s; }
.next .arrow { display: inline-block; transition: transform .4s; }
.next:hover .arrow { transform: translateX(16px); }
.next:hover .next-title { color: #525252; }

/* ---------- Article ---------- */
.post-head { padding-top: 140px; padding-bottom: 48px; }
.post-title { font-size: clamp(2.2rem, 6vw, 5rem); font-weight: 300; letter-spacing: -0.04em; line-height: 1; margin: 32px 0 20px; max-width: 18ch; }
.post-desc { font-size: 1.1rem; max-width: 52ch; line-height: 1.5; }
.post .cover { aspect-ratio: 16 / 8; }
.prose { max-width: 680px; margin: 0 auto; padding: 72px var(--gutter) 24px; font-size: 1.125rem; line-height: 1.75; color: #262626; }
.prose p { margin-bottom: 1.4em; }
.prose .lede { font-size: clamp(1.3rem, 2.2vw, 1.6rem); line-height: 1.45; font-weight: 300; color: var(--fg); letter-spacing: -0.01em; margin-bottom: 2em; }
.prose h2 { font-size: 1.6rem; font-weight: 400; letter-spacing: -0.02em; color: var(--fg); margin: 2.2em 0 .7em; }
.prose ul { margin: 0 0 1.4em 1.1em; }
.prose li { margin-bottom: .5em; padding-left: .3em; }
.prose strong { font-weight: 500; color: var(--fg); }
.prose blockquote {
  font-family: var(--serif); font-style: italic; font-size: clamp(1.7rem, 3.4vw, 2.4rem); line-height: 1.15;
  color: var(--fg); margin: 1.6em 0; padding-left: 24px; border-left: 1px solid var(--fg);
}
.prose a { text-decoration: underline; text-underline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* ---------- Small phones: keep the nav on one line ---------- */
@media (max-width: 520px) {
  .nav { font-size: 0.8rem; }
  .nav-links { gap: 14px; }
  .nav-links a[href="#contact"] { display: none; }
}

/* ---------- About page ---------- */
.about { padding-top: 24px; }
.about-text { margin-top: 32px; max-width: 58ch; font-size: 1.05rem; line-height: 1.7; color: #404040; }
.about-text p + p { margin-top: 1em; }
.skills { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 24px; }
.skills p.small { margin-bottom: 6px; }
.exp-lg .exp-row { font-size: 1rem; padding: 18px 0; }

/* ---------- Article (case-study layout) ---------- */
.post-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 0.875rem; font-weight: 300; color: #737373; }
.post-cover { aspect-ratio: 16 / 8; }
.post-body { max-width: 760px; margin: 0 auto; padding: 48px var(--gutter) 0; }
.post-body .prose { padding: 40px 0 24px; max-width: none; }
.post-details { background: #fafafa; border: 1px solid #e1e1e1; border-radius: 6px; }
.post-details summary {
  display: flex; justify-content: space-between; align-items: center; padding: 16px 20px;
  font-size: 1rem; font-weight: 500; cursor: pointer; list-style: none;
}
.post-details summary::-webkit-details-marker { display: none; }
.post-details .chev { transition: transform .3s; color: var(--muted); }
.post-details[open] .chev { transform: rotate(180deg); }
.post-details-inner { padding: 16px 20px 20px; border-top: 1px solid #e1e1e1; }
.details-cols { display: grid; grid-template-columns: 1fr; gap: 24px; }
@media (min-width: 640px) { .details-cols { grid-template-columns: 1fr 1fr; } }
.details-h { font-size: 0.875rem; font-weight: 500; margin-bottom: 10px; }
.toc { list-style: none; }
.toc li { margin-bottom: 8px; }
.toc a { font-size: .875rem; font-weight: 500; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.toc a:hover { color: var(--fg); }
.prose h2 { scroll-margin-top: 90px; }

/* Figures, stats and callouts inside articles */
.prose figure { margin: 2em 0; }
.prose figure img, .prose figure video { width: 100%; border: 2px solid #f2f2f2; background: var(--soft); }
.prose figure.wide { margin-left: calc(-1 * min(12vw, 160px)); margin-right: calc(-1 * min(12vw, 160px)); }
@media (max-width: 900px) { .prose figure.wide { margin-left: 0; margin-right: 0; } }
.prose figcaption { font-size: 0.8rem; color: var(--muted); margin-top: 10px; line-height: 1.5; }
.prose .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 16px; margin: 2em 0; }
.prose .stats div { border-top: 1px solid var(--fg); padding-top: 12px; }
.prose .stats strong { display: block; font-size: 2rem; font-weight: 300; letter-spacing: -0.03em; line-height: 1.1; }
.prose .stats span { font-size: 0.8rem; color: var(--muted); }
.prose .facts { display: grid; grid-template-columns: minmax(82px, 120px) minmax(0, 1fr); gap: 8px 24px; font-size: 0.95rem; margin: 1.5em 0; }
.prose .facts dt { color: var(--muted); }

.keep-reading { padding-top: 96px; }
.keep-reading .section-title { font-size: 1.25rem; font-weight: 500; }
.more { display: grid; grid-template-columns: 1fr; gap: 48px 32px; }
@media (min-width: 768px) { .more { grid-template-columns: repeat(3, 1fr); } }
.more .cover { aspect-ratio: 16 / 10; margin-bottom: 14px; }
.more .cover-fill span { font-size: clamp(1.4rem, 2.4vw, 2.2rem); }

/* ---------- Case-study graphics ---------- */
.prose .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.prose .pair img { aspect-ratio: 16 / 10; object-fit: cover; object-position: top; }
@media (max-width: 600px) { .prose .pair { grid-template-columns: 1fr; } }
.prose figure.tall img { max-height: 900px; object-fit: cover; object-position: top; }

/* Flow diagram: boxes + arrows, wraps on small screens */
.flow { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; margin: 2em 0 0.6em; font-size: 0.8rem; line-height: 1.35; }
.flow .node { flex: 1 1 110px; border: 1px solid var(--fg); padding: 12px; background: var(--bg); }
.flow .node strong { display: block; font-size: 0.9rem; font-weight: 500; margin-bottom: 4px; }
.flow .node span { color: #737373; }
.flow .node.dark { background: var(--fg); color: var(--bg); }
.flow .node.dark span { color: #a3a3a3; }
.flow .arrow { align-self: center; color: var(--muted); font-size: 1.1rem; }
@media (max-width: 600px) { .flow { flex-direction: column; } .flow .arrow { transform: rotate(90deg); align-self: flex-start; margin-left: 16px; } }
.flow-caption { font-size: 0.8rem; color: var(--muted); margin-bottom: 2em; }
.prose .callout { background: #fafafa; border-left: 2px solid var(--fg); padding: 16px 20px; font-size: 1rem; margin: 2em 0; }
.prose .callout p:last-child { margin-bottom: 0; }
.prose .flow .node.dark strong { color: var(--bg); }
@media (min-width: 601px) {
  .flow { flex-wrap: nowrap; margin-left: calc(-1 * min(12vw, 160px)); margin-right: calc(-1 * min(12vw, 160px)); }
  .flow .node { flex: 1 1 0; min-width: 0; }
  .flow-caption { text-align: left; }
}
@media (min-width: 601px) and (max-width: 900px) { .flow { margin-left: 0; margin-right: 0; } }

.home-intro { padding-block: clamp(88px, 12vw, 150px) 44px; }
.home-title { font: 400 clamp(3.5rem, 9vw, 8rem)/.94 var(--serif); letter-spacing: -.045em; margin: 16px 0 20px; }
.home-summary { font-size: clamp(1.125rem, 2vw, 1.5rem); line-height: 1.45; max-width: 44ch; }
.home-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 16px 24px; margin-top: 26px; }
.home-primary { display: inline-block; color: var(--bg); background: var(--fg); padding: 12px 18px; }
#selected-work { scroll-margin-top: 88px; }
.featured-work { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.featured-card .cover { margin-bottom: 16px; }
.featured-card .cover img, .story .cover img, .post-cover img { object-position: center; }
.featured-card h3 { font: 400 2rem/1.1 var(--serif); margin: 6px 0 10px; }
.featured-card p { line-height: 1.5; }
.featured-card > .link { display: inline-block; margin-top: 12px; text-decoration: underline; text-underline-offset: 3px; }
:focus-visible { outline: 2px solid #245c94; outline-offset: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.post-deck { max-width: 55ch; font-size: clamp(1.1rem, 2vw, 1.4rem); line-height: 1.45; margin: 16px 0; }
.about { display: block; }
.about-right { max-width: 75ch; }
@media (max-width: 767px) {
  .featured-work { grid-template-columns: 1fr; gap: 32px; }
}

/* Case-study reading layout */
.toc li:last-child { margin-bottom: 0; }
.case-summary { margin: 1.5em 0; padding: 18px 22px; background: var(--soft); border-left: 3px solid var(--fg); }
.case-summary strong { display: block; font: 500 .875rem/1.3 var(--sans); margin-bottom: 6px; }
.prose .case-summary p { margin: 0; }
.post-body .prose { line-height: 1.7; }
.post-body .prose h2 { border-top: 1px solid #e1e1e1; padding-top: 20px; }
@media (max-width: 520px) {
  .prose .facts { grid-template-columns: minmax(72px, .4fr) minmax(0, 1fr); gap: 8px 12px; }
  .prose .stats { grid-template-columns: repeat(auto-fit, minmax(112px, 1fr)); }
  .prose .flow { flex-direction: column; }
  .flow .node { flex-basis: auto; }
  .flow .arrow { align-self: center; transform: rotate(90deg); }
}
