:root {
  --bg: #0e0e0c;
  --bg-2: #161613;
  --ink: #ece7dc;
  --muted: #8a857a;
  --line: rgba(236, 231, 220, 0.12);
  --gold: #c9a96e;
  --pad: clamp(20px, 4.5vw, 72px);
  --serif: "Instrument Serif", "Times New Roman", serif;
  --sans: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; overflow-x: clip; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 300;
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
body.loading { overflow: hidden; }
::selection { background: var(--gold); color: var(--bg); }
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3 { margin: 0; font-weight: 400; }
em { font-style: italic; color: var(--gold); }
.serif { font-family: var(--serif); }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.muted { color: var(--muted); }

.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 16px; z-index: 1000; background: var(--ink); color: var(--bg); padding: 8px 14px; }
a:focus-visible, button:focus-visible { outline: 1px solid var(--gold); outline-offset: 4px; }

/* ---------- FX: grain, progress, cursor, loader ---------- */
.grain {
  position: fixed; inset: -50%; z-index: 90; pointer-events: none; opacity: 0.07;
  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='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 1.2s steps(6) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); } 20% { transform: translate(-5%, 3%); } 40% { transform: translate(3%, -6%); }
  60% { transform: translate(-7%, -2%); } 80% { transform: translate(6%, 5%); } 100% { transform: translate(0, 0); }
}
.progress { position: fixed; top: 0; left: 0; height: 1px; width: 100%; background: var(--gold); transform-origin: 0 50%; transform: scaleX(0); z-index: 95; }

.cursor, .cursor-ring { position: fixed; top: 0; left: 0; pointer-events: none; z-index: 99; border-radius: 50%; opacity: 0; }
.cursor { width: 6px; height: 6px; margin: -3px 0 0 -3px; background: var(--ink); mix-blend-mode: difference; }
.cursor-ring {
  width: 38px; height: 38px; margin: -19px 0 0 -19px; border: 1px solid rgba(236,231,220,.45);
  display: grid; place-items: center; font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--bg);
  transition: width .45s var(--ease), height .45s var(--ease), margin .45s var(--ease), background .3s, border-color .3s;
}
.cursor-ring span { opacity: 0; transition: opacity .2s; }
body.has-cursor .cursor, body.has-cursor .cursor-ring { opacity: 1; }
body.cursor-link .cursor-ring { width: 64px; height: 64px; margin: -32px 0 0 -32px; border-color: var(--gold); }
body.cursor-view .cursor-ring { width: 86px; height: 86px; margin: -43px 0 0 -43px; background: var(--gold); border-color: var(--gold); }
body.cursor-view .cursor-ring span { opacity: 1; }
body.cursor-view .cursor { opacity: 0; }
@media (hover: hover) and (pointer: fine) { body.has-cursor, body.has-cursor a, body.has-cursor button { cursor: none; } }

.loader {
  position: fixed; inset: 0; z-index: 200; background: var(--bg);
  display: flex; flex-direction: column; justify-content: space-between; padding: var(--pad);
  transition: clip-path 1.2s var(--ease);
  clip-path: inset(0 0 0 0);
}
.loader.done { clip-path: inset(0 0 100% 0); }
.loader-name { font-family: var(--serif); font-size: clamp(48px, 9vw, 140px); line-height: 1.1; overflow: hidden; padding-bottom: .12em; }
.loader-name span { display: inline-block; transform: translateY(110%); animation: rise 1s var(--ease) .15s forwards; }
.loader-name em { animation-delay: .3s; }
.loader-row { display: flex; justify-content: space-between; align-items: flex-end; }
.loader-count { font-family: var(--serif); font-size: clamp(64px, 12vw, 200px); line-height: .8; color: var(--gold); font-variant-numeric: tabular-nums; }
@keyframes rise { to { transform: translateY(0); } }
.loader-bar { position: absolute; left: 0; bottom: 0; height: 1px; background: var(--gold); width: 0; }
.no-js .loader { display: none; }

/* ---------- NAV ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 80;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 22px var(--pad);
  mix-blend-mode: difference;
}
.logo { font-family: var(--serif); font-size: 22px; letter-spacing: 0.01em; }
.nav-links { display: flex; gap: 34px; }
.nav-links a, .footer a, .link-arrow { position: relative; }
.nav-links a { font-size: 14px; letter-spacing: .02em; }
.nav-links a::after, .footer a::after, .link-arrow::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -3px; height: 1px; background: currentColor;
  transform: scaleX(0); transform-origin: right; transition: transform .6s var(--ease);
}
.nav-links a:hover::after, .footer a:hover::after, .link-arrow:hover::after { transform: scaleX(1); transform-origin: left; }
.nav-meta { justify-self: end; color: var(--ink); }
.nav-toggle { display: none; }

/* ---------- HERO ---------- */
.hero { position: relative; padding: clamp(120px, 16vh, 180px) var(--pad) clamp(60px, 8vw, 100px); }
.hero-glow {
  position: absolute; width: 60vw; height: 60vw; max-width: 900px; max-height: 900px; left: 0; top: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(circle, rgba(201,169,110,.13) 0%, rgba(201,169,110,0) 60%); border-radius: 50%;
  transform: translate(-50%, -50%); transition: opacity .6s; will-change: transform;
}
.hero > *:not(.hero-glow) { position: relative; z-index: 1; }
.hero-top p { margin: 0; }
.hero-top { display: flex; justify-content: space-between; gap: 20px; margin-bottom: clamp(36px, 6vw, 72px); padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.hero-title { font-family: var(--serif); font-size: clamp(52px, 9.4vw, 168px); line-height: .95; letter-spacing: -0.025em; }
.hero-title .line { display: block; overflow: hidden; padding-bottom: .06em; }
.hero-title .word { display: inline-block; transform: translateY(105%) rotate(4deg); transform-origin: 0 100%; transition: transform 1.3s var(--ease); }
.hero-title.in .word { transform: none; }

.hero-grid { display: grid; grid-template-columns: minmax(220px, 340px) 1fr; gap: clamp(28px, 6vw, 110px); margin-top: clamp(48px, 7vw, 100px); align-items: end; }
.portrait { margin: 0; overflow: hidden; aspect-ratio: 4 / 5; clip-path: inset(100% 0 0 0); transition: clip-path 1.6s var(--ease) .2s; }
.portrait.in { clip-path: inset(0 0 0 0); }
.portrait img { width: 100%; height: 115%; object-fit: cover; filter: grayscale(.35) contrast(1.05); transform: scale(1.15); transition: transform 2s var(--ease), filter .8s; will-change: transform; }
.portrait.in img { transform: scale(1); }
.portrait:hover img { filter: grayscale(0); }
.lede { font-size: clamp(19px, 1.7vw, 25px); line-height: 1.5; max-width: 38ch; margin: 0 0 36px; color: var(--ink); }
.hero-links { display: flex; gap: 36px; flex-wrap: wrap; }
.link-arrow { display: inline-flex; gap: 10px; align-items: center; font-size: 15px; letter-spacing: .02em; }
.link-arrow span { display: inline-block; transition: transform .5s var(--ease); color: var(--gold); }
.link-arrow:hover span { transform: translate(4px, -2px) rotate(-8deg); }

.figures { display: grid; grid-template-columns: repeat(4, 1fr); margin: clamp(72px, 10vw, 140px) 0 0; border-top: 1px solid var(--line); }
.figures > div { padding: 28px 24px 0 0; }
.figures > div + div { padding-left: 24px; border-left: 1px solid var(--line); }
.figures dt { font-family: var(--serif); font-size: clamp(42px, 4.6vw, 76px); line-height: 1; color: var(--ink); font-variant-numeric: tabular-nums; }
.figures dd { margin: 12px 0 0; font-size: 14px; color: var(--muted); max-width: 24ch; }

/* ---------- MARQUEE ---------- */
.marquee { overflow: hidden; padding: clamp(40px, 6vw, 80px) 0; border-block: 1px solid var(--line); }
.marquee-track { display: flex; width: max-content; will-change: transform; }
.marquee-track span {
  font-family: var(--serif); font-size: clamp(80px, 13vw, 220px); line-height: 1; white-space: nowrap; padding-right: .3em;
  color: transparent; -webkit-text-stroke: 1px rgba(236,231,220,.35);
}
.marquee-track span em { -webkit-text-stroke: 0; color: var(--gold); }

/* ---------- SECTIONS ---------- */
.section { padding: clamp(100px, 13vw, 190px) var(--pad) 0; }
.section-head { display: grid; grid-template-columns: 80px 1fr auto; align-items: end; gap: 20px; padding-bottom: 28px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.section-head h2 { font-family: var(--serif); font-size: clamp(48px, 7.5vw, 124px); line-height: .95; letter-spacing: -0.02em; }

/* ---------- WORK INDEX ---------- */
.index { counter-reset: row; }
.row {
  position: relative; display: grid; grid-template-columns: 80px 1.6fr 1fr 1fr 90px; gap: 20px; align-items: baseline;
  padding: 34px 0; border-bottom: 1px solid var(--line); transition: padding .6s var(--ease), color .4s;
}
.row::before { content: ""; position: absolute; inset: 0; background: var(--bg-2); transform: scaleY(0); transform-origin: bottom; transition: transform .6s var(--ease); z-index: -1; }
.row:hover::before { transform: scaleY(1); }
.row:hover { padding-left: 16px; padding-right: 16px; }
.row h3 { font-family: var(--serif); font-size: clamp(36px, 4.4vw, 68px); line-height: 1; transition: transform .6s var(--ease), color .4s; }
.row:hover h3 { color: var(--gold); font-style: italic; transform: translateX(10px); }
.row p { margin: 14px 0 0; max-width: 52ch; font-size: 15px; color: var(--muted); max-height: 0; opacity: 0; overflow: hidden; transition: max-height .8s var(--ease), opacity .5s, margin .6s; }
.row:hover p, .row:focus-within p { max-height: 120px; opacity: 1; }
.row-kind { font-size: 15px; }
.row-num, .row-stack, .row-year { color: var(--muted); }
.row-year { text-align: right; }
.more { margin-top: 40px; }

.preview {
  position: fixed; top: 0; left: 0; z-index: 70; width: 320px; height: 220px; pointer-events: none;
  border-radius: 4px; overflow: hidden; opacity: 0; transform: translate(0, -50%) scale(.6) rotate(-6deg);
  transition: opacity .4s var(--ease), transform .6s var(--ease);
}
.preview.show { opacity: 1; transform: translate(0, -50%) scale(1) rotate(0); }
.preview-inner { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; padding: 20px; color: #0e0e0c; transition: background .5s var(--ease); }
.preview-inner b { font-family: var(--serif); font-weight: 400; font-size: 44px; line-height: 1; }
.preview-inner small { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }

/* ---------- TIMELINE ---------- */
.timeline { position: relative; padding-left: 0; }
.timeline::before { content: ""; position: absolute; left: 199px; top: 0; bottom: 0; width: 1px; background: var(--line); }
.timeline-fill { position: absolute; left: 199px; top: 0; width: 1px; height: 100%; background: var(--gold); transform-origin: top; transform: scaleY(0); }
.job { display: grid; grid-template-columns: 200px 1fr; gap: 0; padding: 48px 0; border-bottom: 1px solid var(--line); }
.job-when { display: flex; flex-direction: column; gap: 6px; padding-right: 40px; }
.job-when .serif { font-size: clamp(44px, 4.4vw, 68px); line-height: .9; }
.job-body { position: relative; padding-left: 48px; }
.job-body::before { content: ""; position: absolute; left: -4px; top: 14px; width: 7px; height: 7px; border-radius: 50%; background: var(--bg); border: 1px solid var(--gold); transition: background .5s; }
.job.in .job-body::before { background: var(--gold); box-shadow: 0 0 0 6px rgba(201,169,110,.12); }
.job h3 { font-family: var(--serif); font-size: clamp(28px, 2.8vw, 42px); line-height: 1.1; }
.job h3 .muted { font-size: .55em; font-family: var(--sans); letter-spacing: .02em; }
.role { margin: 10px 0 20px; color: var(--gold); }
.job ul { display: grid; gap: 10px; max-width: 70ch; }
.job li { position: relative; padding-left: 22px; color: #c9c3b6; font-size: 15.5px; }
.job li::before { content: "—"; position: absolute; left: 0; color: var(--muted); }

/* ---------- ABOUT ---------- */
.about-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: clamp(40px, 7vw, 120px); padding-top: 24px; }
.edu { display: grid; grid-template-columns: 110px 1fr; gap: 20px; padding: 28px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.edu h3 { font-family: var(--serif); font-size: clamp(26px, 2.6vw, 38px); line-height: 1.1; transition: color .4s; }
.edu:hover h3 { color: var(--gold); }
.edu p { margin: 6px 0 0; font-size: 15px; color: var(--muted); }
.skills { margin: 0; }
.skills > div { padding: 28px 0; border-bottom: 1px solid var(--line); }
.skills dd { margin: 10px 0 0; font-size: 17px; line-height: 1.55; }

/* ---------- CONTACT ---------- */
.contact { padding: clamp(120px, 16vw, 240px) var(--pad) clamp(80px, 10vw, 140px); text-align: center; position: relative; }
.contact-title { font-family: var(--serif); font-size: clamp(52px, 9vw, 160px); line-height: .95; letter-spacing: -0.025em; margin: 28px 0 56px; }
.contact-mail {
  display: inline-block; font-family: var(--serif); font-size: clamp(26px, 3.6vw, 56px); position: relative; padding-bottom: 6px;
  background: linear-gradient(var(--gold), var(--gold)) 0 100% / 0 1px no-repeat, linear-gradient(var(--line), var(--line)) 0 100% / 100% 1px no-repeat;
  transition: background-size .8s var(--ease), color .4s;
  word-break: break-word;
}
.contact-mail:hover { background-size: 100% 1px, 100% 1px; color: var(--gold); }
.contact-links { display: flex; justify-content: center; gap: 40px; margin-top: 48px; }

.footer { display: flex; justify-content: space-between; padding: 28px var(--pad) 36px; border-top: 1px solid var(--line); color: var(--muted); }
.footer a:hover { color: var(--ink); }

/* ---------- REVEAL ---------- */
.reveal { opacity: 0; transform: translateY(40px); transition: opacity 1.1s var(--ease), transform 1.1s var(--ease); }
.reveal.in { opacity: 1; transform: none; }
.magnetic { display: inline-block; transition: translate .6s var(--ease), opacity 1.1s var(--ease), transform 1.1s var(--ease), background-size .8s var(--ease), color .4s; }
.no-js .reveal, .no-js .hero-title .word { opacity: 1; transform: none; }
.no-js .portrait { clip-path: none; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1000px) {
  .row { grid-template-columns: 50px 1fr auto; }
  .row-kind, .row-stack { display: none; }
  .figures { grid-template-columns: 1fr 1fr; }
  .figures > div:nth-child(3) { padding-left: 0; border-left: 0; }
  .figures > div { padding-bottom: 28px; }
  .about-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  body { font-size: 16px; }
  .nav { grid-template-columns: 1fr auto; mix-blend-mode: normal; background: rgba(14,14,12,.75); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); padding: 16px var(--pad); }
  .nav-meta { display: none; }
  .nav-toggle { display: inline-flex; flex-direction: column; justify-content: center; gap: 7px; width: 40px; height: 40px; background: none; border: 0; padding: 0 8px; cursor: pointer; }
  .nav-toggle span { display: block; height: 1px; background: var(--ink); transition: transform .4s var(--ease); }
  .nav-toggle[aria-expanded="true"] span:first-child { transform: translateY(4px) rotate(45deg); }
  .nav-toggle[aria-expanded="true"] span:last-child { transform: translateY(-4px) rotate(-45deg); }
  .nav-links { position: fixed; inset: 72px 0 auto 0; flex-direction: column; gap: 0; background: var(--bg); padding: 12px var(--pad) 28px; border-bottom: 1px solid var(--line); clip-path: inset(0 0 100% 0); transition: clip-path .6s var(--ease); }
  .nav-links.open { clip-path: inset(0 0 0 0); }
  .nav-links a { display: block; font-family: var(--serif); font-size: 36px; padding: 8px 0; }
  .hero-top { flex-direction: column; gap: 6px; }
  .hero-grid { grid-template-columns: 1fr; }
  .portrait { width: 70%; max-width: 300px; }
  .section-head { grid-template-columns: 1fr; gap: 8px; }
  .section-head > p { display: none; }
  .row { grid-template-columns: 1fr auto; padding: 26px 0; }
  .row-num { display: none; }
  .row p { max-height: none; opacity: 1; }
  .timeline::before, .timeline-fill { left: 0; }
  .job { grid-template-columns: 1fr; gap: 14px; padding-left: 24px; }
  .job-body { padding-left: 0; }
  .job-body::before { left: -28px; top: -44px; }
  .job-when { flex-direction: row; align-items: baseline; gap: 12px; }
  .edu { grid-template-columns: 1fr; gap: 4px; }
  .contact-links { gap: 28px; }
  .footer { flex-direction: column; gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .reveal, .hero-title .word { opacity: 1; transform: none; }
  .portrait { clip-path: none; }
  .loader, .cursor, .cursor-ring, .grain, .preview { display: none !important; }
}
