:root {
  --bg: #0b1020;
  --ink: #f2ede3;
  --dim: #8f97ad;
  --line: rgba(242, 237, 227, 0.16);
  --coral: #ff6b4a;
  --sky: #8ec5ff;
  --serif: "Instrument Serif", Georgia, serif;
  --sans: "Space Grotesk", system-ui, sans-serif;
  --gutter: clamp(16px, 4vw, 56px);
  --ease: cubic-bezier(.2, .7, .2, 1);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: underline 1px var(--line); text-underline-offset: .22em; transition: color .2s, text-decoration-color .2s; }
a:hover, a:focus-visible { color: var(--coral); text-decoration-color: currentColor; }

.skip { position: absolute; left: 12px; top: -60px; background: var(--ink); color: var(--bg); padding: 8px 12px; z-index: 20; }
.skip:focus { top: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#scene {
  position: fixed; inset: 0; width: 100%; height: 100vh; height: 100lvh;
  z-index: 0; pointer-events: none;
  opacity: 0; transition: opacity 1.2s ease;
}
#scene.ready { opacity: 1; }
body.card-hover { cursor: pointer; }

.top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px var(--gutter);
  font-size: 14px;
  background: linear-gradient(var(--bg), transparent);
}
.top a { text-decoration: none; }
.top nav { display: flex; gap: 20px; }
.brand { font-weight: 500; }

main, .foot { position: relative; z-index: 1; }
section { padding: 0 var(--gutter); }

.hero { min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; justify-content: center; max-width: 720px; padding-top: 80px; }
.eyebrow { color: var(--dim); font-size: 14px; letter-spacing: .04em; text-transform: uppercase; margin: 0 0 12px; }
h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(56px, 9vw, 132px); line-height: .9; letter-spacing: -.02em; margin: 0 0 28px; }
.lede { font-size: clamp(18px, 1.6vw, 22px); max-width: 34ch; margin: 0 0 28px; }
.ctas { display: flex; gap: 22px; flex-wrap: wrap; margin: 0; }
.cta { text-decoration: none; font-weight: 500; border-bottom: 2px solid var(--coral); padding-bottom: 3px; }
.hint { color: var(--dim); font-size: 13px; margin-top: 40px; }

.stats { display: grid; grid-template-columns: repeat(4, auto); justify-content: start; gap: 8px 36px; margin: 44px 0 0; }
.stats div { border-top: 1px solid var(--line); padding-top: 10px; }
.stats dt { font-family: var(--serif); font-size: clamp(28px, 2.6vw, 40px); line-height: 1; }
.stats dd { margin: 6px 0 0; color: var(--dim); font-size: 12px; max-width: 16ch; }

#approach { padding-top: 10vh; padding-bottom: 12vh; }
.approach-inner { position: sticky; top: 9vh; }
.approach-space { height: 100vh; }   /* scroll room for the timeline (padding wouldn't let it stay pinned) */
.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 32px; max-width: 1100px; }
.steps li { position: relative; border-top: 1px solid var(--line); padding: 26px 0 40px; }
/* the timeline: a coral line along each step's top edge that fills as the project moves on */
.steps li::before {
  content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 3px; background: var(--coral);
  transform: scaleX(0); transform-origin: 0 50%; transition: transform .7s var(--ease);
  box-shadow: 0 0 14px rgba(255, 107, 74, .55);
}
.steps li.done::before, .steps li.now::before { transform: scaleX(1); }
.steps .num {
  display: inline-flex; align-items: center; justify-content: center; white-space: nowrap;
  min-width: 34px; height: 34px; padding: 0 10px; border-radius: 999px;
  color: var(--coral); font-size: 13px; font-weight: 700; border: 1px solid rgba(255, 107, 74, .5);
  transition: background .4s, color .4s, transform .5s var(--ease);
}
.steps li.done .num { background: var(--coral); color: #1f0f0b; }
.steps li.done .num::after { content: " ✓"; }
.steps li.now .num { background: var(--coral); color: #1f0f0b; transform: scale(1.12); box-shadow: 0 0 22px rgba(255, 107, 74, .7); }
.steps h3 {
  font-family: var(--serif); font-weight: 400; font-size: clamp(42px, 4.6vw, 72px); line-height: 1; margin: 14px 0 12px;
  color: #fffaf0; text-shadow: 0 0 28px rgba(255, 250, 240, .18);
}
.steps li.now h3 { color: var(--coral); text-shadow: 0 0 34px rgba(255, 107, 74, .45); }
.steps p { margin: 0; color: #ece7dc; font-size: 17px; max-width: 28ch; }
.steps li:not(.done):not(.now) h3, .steps li:not(.done):not(.now) p { opacity: .55; }
.steps h3, .steps p { transition: color .4s, opacity .4s, text-shadow .4s; }

/* letters rise in one by one when a step first appears */
.steps .ch { display: inline-block; opacity: 0; transform: translateY(.55em) rotate(4deg); filter: blur(6px);
  transition: opacity .55s, transform .7s var(--ease), filter .55s; transition-delay: calc(var(--j) * 45ms + var(--k) * 90ms); }
.steps li.in .ch { opacity: 1; transform: none; filter: none; }
.steps li .num, .steps li p { opacity: 0; transform: translateY(10px); }
.steps li.in .num { opacity: 1; transform: none; transition: opacity .5s calc(var(--k) * 90ms), transform .5s calc(var(--k) * 90ms), background .4s, color .4s; }
.steps li.in p { transform: none; transition: opacity .6s calc(var(--k) * 90ms + 350ms), transform .6s calc(var(--k) * 90ms + 350ms); }
.steps li.in:not(.done):not(.now) p { opacity: .55; }
.steps li.in.done p, .steps li.in.now p { opacity: 1; }
@media (prefers-reduced-motion: reduce), (max-width: 700px), (hover: none) {
  .steps .ch, .steps li .num, .steps li p { opacity: 1 !important; transform: none !important; filter: none !important; transition: none !important; }
}

#skills { padding-top: 12vh; padding-bottom: 12vh; }
.skills-inner { position: sticky; top: 8vh; }
.skills-space { height: 90vh; }   /* scroll room while the notes fly in (the list stays pinned) */
#skills .skill-groups > div { cursor: default; }
/* the tool chest sits on the right, so the groups use two columns on the left */
#skills .skill-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: min(760px, 54vw); }
#skills .skill-groups > div { transition: opacity .35s, transform .45s var(--ease); }
#skills .skill-groups > div:not(.is-active) { opacity: .45; }
#skills .skill-groups > div.is-active { transform: translateX(6px); }
#skills .skill-groups > div.is-active h3 { color: var(--coral); }
#skills .skill-groups > div.is-active .chips li { border-color: var(--coral); }
@media (max-width: 700px) { #skills .skill-groups { grid-template-columns: 1fr; max-width: none; } }
.skill-groups { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 36px 32px; max-width: 1100px; }
.skill-groups h3 { font-family: var(--serif); font-weight: 400; font-size: 28px; margin: 0 0 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; }
.chips li { font-size: 13px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: rgba(11, 16, 32, .6); transition: border-color .2s, color .2s; }
.chips li:hover { border-color: var(--coral); color: var(--coral); }

.label { font-size: 14px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; color: var(--dim); border-top: 1px solid var(--line); padding-top: 14px; margin: 0 0 40px; }

#about { padding-top: 30vh; padding-bottom: 30vh; }
.statement { font-family: var(--serif); font-size: clamp(36px, 5vw, 72px); line-height: 1.05; max-width: 18ch; margin: 0 0 40px; }
.about-body { max-width: 46ch; margin-left: auto; margin-right: 8vw; color: #d9d4ca; }

#work { padding-top: 20vh; padding-bottom: 30vh; }
.works { list-style: none; padding: 0; margin: 0; max-width: 640px; counter-reset: w; }
.works li { border-bottom: 1px solid var(--line); }
.work { position: relative; display: grid; grid-template-columns: 52px 1fr auto; align-items: baseline; gap: 12px; padding: 20px 0; text-decoration: none; }
.work::before { content: ""; position: absolute; left: calc(-1 * var(--gutter) + 4px); top: 50%; width: max(6px, calc(var(--gutter) - 14px)); height: 2px; background: var(--coral); transform: scaleX(0); transform-origin: 0 50%; transition: transform .45s var(--ease); }
.work:hover::before, .work.is-active::before { transform: scaleX(1); }
.work-n { color: var(--dim); font-size: 13px; }
.work-title { font-family: var(--serif); font-size: clamp(26px, 2.6vw, 38px); line-height: 1.05; transition: color .25s, transform .45s var(--ease); }
.work:hover .work-title, .work.is-active .work-title { color: var(--coral); transform: translateX(6px); }
.work-meta { color: var(--dim); font-size: 13px; text-align: right; white-space: nowrap; }

#writing { padding-top: 10vh; padding-bottom: 24vh; }
.count { color: var(--coral); margin-left: 6px; }
.section-title { font-family: var(--serif); font-size: clamp(64px, 9vw, 132px); line-height: .9; margin: -18px 0 14px; letter-spacing: -.01em; }
.section-title .count { font-size: .38em; vertical-align: super; margin-left: 10px; }
.writing-intro { margin: 0 0 22px; max-width: 46ch; font-size: 15px; }
#writing .work-title { font-size: clamp(20px, 1.8vw, 26px); }
.all-posts { max-width: 640px; margin: 28px 0; }
.all-posts summary { cursor: pointer; color: var(--dim); font-size: 14px; }
.all-posts summary:hover { color: var(--coral); }
.index { padding-left: 0; list-style: none; margin: 16px 0 0; columns: 1; }
.index li { padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 15px; display: grid; grid-template-columns: 1fr auto; gap: 12px; }
.index a { text-decoration: none; }
.index span { color: var(--dim); font-size: 12px; white-space: nowrap; }

#archive { padding-top: 10vh; }
.archive-head { display: flex; justify-content: space-between; align-items: baseline; gap: 20px; flex-wrap: wrap; }
.archive-head .label { flex: 1; }
.small { color: var(--dim); font-size: 13px; margin: 0; }
.archive-space { height: 120vh; } /* main.js sets the exact height to fit the grid */
#archive { padding-bottom: 20vh; }

#experience { padding-top: 20vh; padding-bottom: 30vh; }
.rows { list-style: none; padding: 0; margin: 0; max-width: 820px; }
.rows li { display: grid; grid-template-columns: 140px 1fr; gap: 16px; padding: 22px 0; border-bottom: 1px solid var(--line); }
.rows .yrs { color: var(--dim); font-size: 14px; }
.rows .role { font-family: var(--serif); font-size: 28px; line-height: 1.1; transition: color .3s; }
/* the role whose page is on top of the clipboard */
.rows li { transition: opacity .3s; }
#experience .rows li:not(.is-active) { opacity: .55; }
#experience .rows li.is-active .role { color: var(--coral); }
#experience .rows li.is-active .yrs { color: var(--ink); }
.rows .org { color: var(--sky); }
.rows .note { color: #c9c4ba; font-size: 15px; margin-top: 4px; }

#contact { height: 260vh; padding-top: 10vh; }              /* scroll room for the packing animation */
.contact-inner { position: sticky; top: 12vh; height: 82vh; }
/* --c goes 0 → 1 as the closed box moves to the centre (set by main.js) */
.big-links { opacity: calc(1 - var(--c, 0)); transform: translateX(calc(var(--c, 0) * -40px)); }
#contact.is-packed .big-links { pointer-events: none; }
.box-links {
  position: absolute; left: 50%; bottom: 0; transform: translate(-50%, calc((1 - var(--c, 0)) * 20px));
  margin: 0; width: max-content; max-width: calc(100vw - 2 * var(--gutter));
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 28px;
  opacity: var(--c, 0); pointer-events: none;
  font-size: 15px;
}
#contact.is-packed .box-links { pointer-events: auto; }
.box-links a { text-decoration: none; border-bottom: 2px solid var(--coral); padding-bottom: 3px; font-weight: 500; }
.big-links { list-style: none; padding: 0; margin: 0; }
.big-links a { font-family: var(--serif); font-size: clamp(56px, 10vw, 150px); line-height: 1; text-decoration: none; display: inline-block; transition: color .2s, transform .45s var(--ease); }
.big-links a:hover { transform: translateX(10px); }
.big-links small { display: block; color: var(--dim); font-size: 13px; margin: 4px 0 22px; font-family: var(--sans); }

.foot { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 22px var(--gutter); border-top: 1px solid var(--line); color: var(--dim); font-size: 13px; }

/* On phones and tall windows the card pile sits at the top; text goes below it. */
@media (max-width: 700px), (max-aspect-ratio: 9/10) {
  .hero { justify-content: flex-start; padding-top: 58svh; padding-bottom: 8vh; }
  .hero .hint { margin-top: 28px; }
  .hero > * { text-shadow: 0 1px 14px rgba(5, 8, 18, .95), 0 0 3px rgba(5, 8, 18, .7); }
}

@media (max-width: 1000px) {
  .steps, .skill-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .top nav { gap: 12px; }
  .top nav a:nth-child(3), .top nav a:nth-child(4), .top nav a:nth-child(5) { display: none; }
  .stats { grid-template-columns: repeat(2, auto); }
  .steps, .skill-groups { grid-template-columns: 1fr; }
  .work { grid-template-columns: 34px 1fr; }
  .work-meta { grid-column: 2; text-align: left; }
  .rows li { grid-template-columns: 1fr; gap: 4px; }
  .about-body { margin-right: 0; }
  .archive-space { height: 90vh; }
  /* no pinned scenes on phones: the lists just scroll, with no empty scroll room */
  .approach-inner, .skills-inner { position: static; }
  .approach-space { height: 0; }
  #approach .steps li { padding-top: 14px; padding-bottom: 14px; }
  #approach .steps h3 { font-size: clamp(30px, 9vw, 40px); }
  .skills-space { height: 0; }
  /* the 3D props sit behind the text on phones: give text a soft backing so it always reads */
  #experience .rows li, #skills .skill-groups > div, #writing .writing-intro, #writing .works .work, #approach .steps li {
    /* no blur: backdrop-filter over a canvas that redraws is what made phones lag */
    background: rgba(11, 16, 32, .88);
    border-radius: 10px; padding-left: 12px; padding-right: 12px;
  }
  /* About: the sheets scatter behind the words, so back them like the other sections */
  #about .statement, #about .about-body p { background: rgba(11, 16, 32, .88); border-radius: 10px; padding: 10px 12px; }
  #about .statement { max-width: none; }
  #about .about-body p { margin: 0 0 10px; }
  /* header stays readable over the sheets */
  .top { background: rgba(11, 16, 32, .92); padding-top: 10px; padding-bottom: 10px; }
  #experience .rows, #skills .skill-groups { gap: 10px; }
}

/* phones: no transitions or animations beyond a colour change */
@media (max-width: 700px), (hover: none) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; transition-delay: 0s !important; }
  html { scroll-behavior: auto; }
}
