/* ===================================================================
   FANGJIAN · v4 — after peterbauman.art
   Black room, ivory type, yellow marker. One grotesque across widths:
   regular for reading, condensed for apparatus and the large figures.
   =================================================================== */
@font-face { font-family: "Antony"; src: url("./assets/fonts/antony-400.otf") format("opentype"); font-weight: 400; font-stretch: normal; font-display: swap; }
@font-face { font-family: "Antony"; src: url("./assets/fonts/antony-500.otf") format("opentype"); font-weight: 500; font-stretch: normal; font-display: swap; }
@font-face { font-family: "Antony"; src: url("./assets/fonts/antony-600.otf") format("opentype"); font-weight: 600; font-stretch: normal; font-display: swap; }
@font-face { font-family: "Antony"; src: url("./assets/fonts/antony-condensed-300.otf") format("opentype"); font-weight: 300; font-stretch: condensed; font-display: swap; }
@font-face { font-family: "Antony"; src: url("./assets/fonts/antony-condensed-500.otf") format("opentype"); font-weight: 500; font-stretch: condensed; font-display: swap; }
@font-face { font-family: "Antony"; src: url("./assets/fonts/antony-extracondensed-700.otf") format("opentype"); font-weight: 700; font-stretch: extra-condensed; font-display: swap; }
@font-face { font-family: "Antony"; src: url("./assets/fonts/antony-extracondensed-800.otf") format("opentype"); font-weight: 800; font-stretch: extra-condensed; font-display: swap; }
@font-face { font-family: "Antony"; src: url("./assets/fonts/antony-semicondensed-900.otf") format("opentype"); font-weight: 900; font-stretch: semi-condensed; font-display: swap; }
@font-face { font-family: "Antony"; src: url("./assets/fonts/antony-expanded-400.otf") format("opentype"); font-weight: 400; font-stretch: expanded; font-display: swap; }

:root {
  --void: #000;
  --ink: #f3f1ea;
  --dim: #a3a199;
  --rule: #2a2a2d;
  --yellow: #f6d51e;
  --paper: #f3f0e8;
  --sans: "Archivo", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  color-scheme: dark;

  --xs: clamp(0.88rem, 0.84rem + 0.16vw, 1.04rem);
  --s0: clamp(1.02rem, 0.97rem + 0.25vw, 1.26rem);
  --s1: clamp(1.2rem, 1.04rem + 0.72vw, 1.95rem);
  --s2: clamp(1.6rem, 1.08rem + 2.2vw, 3.6rem);
  --gutter: clamp(16px, 3.6vw, 72px);
  --gap: clamp(14px, 1.8vw, 32px);
  --ease: cubic-bezier(0.2, 0.7, 0.1, 1);
  --line: color-mix(in oklab, currentColor 38%, transparent);
}

*, *::before, *::after { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: 20px;
  scroll-behavior: smooth;
}
body {
  margin: 0;
  background: var(--void);
  color: var(--ink);
  font: 300 var(--s0)/1.55 var(--sans);
  font-stretch: 100%;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-kerning: normal;
  overflow-x: hidden;
}
img { max-width: 100%; height: auto; }
h1, h2, h3, p, ul, figure { margin: 0; padding: 0; }
h1, h2, h3 { font-weight: 400; }
ul { list-style: none; }
p, li { text-wrap: pretty; }
a {
  color: inherit;
  text-decoration: underline 1px var(--line);
  text-underline-offset: 0.22em;
  transition: color 0.2s, text-decoration-color 0.2s;
}
a:hover { color: var(--yellow); text-decoration-color: currentColor; }
::selection { background: var(--yellow); color: #000; }
:focus-visible { outline: 2px solid var(--yellow); outline-offset: 4px; }

.skip {
  position: absolute; left: 12px; top: -100px; z-index: 10;
  background: var(--yellow); color: #000;
  padding: 8px 12px;
  font: 400 var(--xs)/1.35 var(--sans); font-stretch: 75%;
}
.skip:focus { top: 12px; }

.page { position: relative; }
.wrap {
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  max-width: 2200px;
  margin-inline: auto;
}
.label {
  font: 500 var(--xs)/1.35 var(--sans);
  font-stretch: 75%;
  color: var(--dim);
}

/* ---------- Masthead ---------- */
.masthead {
  display: flex; justify-content: space-between; align-items: baseline;
  flex-wrap: wrap; gap: 0 20px;
  padding-block: 10px;
  position: relative;
  isolation: isolate;
}
.masthead::before {
  content: ""; position: absolute; inset: 0 0 -44px; z-index: -1;
  background: linear-gradient(#000 30%, transparent);
  pointer-events: none;
}
.masthead a {
  display: inline-block; padding-block: 10px;
  text-decoration: none; color: var(--ink);
}
.masthead a:hover { color: var(--yellow); }
.masthead a[aria-current] { color: var(--yellow); }
.masthead ul {
  display: flex; flex-wrap: wrap; align-items: baseline;
  gap: 0 clamp(16px, 2vw, 30px);
}

/* ---------- Hero ---------- */
.hero {
  position: relative;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--gap);
  padding-bottom: clamp(36px, 5vw, 72px);
}
.stage-hero {
  grid-column: 1 / -1;
  height: min(54svh, 600px);
  min-height: 280px;
  display: grid;
  place-items: center;
}
.print {
  width: min(62%, 36svh);
  aspect-ratio: 3 / 4;
  background: var(--paper);
  color: #141414;
  padding: 3.4%;
  rotate: -2.5deg;
  box-shadow: 0 30px 60px -20px #000;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: rotate 0.8s var(--ease);
}
.print:hover { rotate: -0.6deg; }
.print-top {
  display: flex; justify-content: space-between; gap: 8px;
  font-stretch: 75%; font-weight: 400;
  font-size: calc(var(--xs) * 0.78);
  letter-spacing: 0.08em;
  color: #55554f;
}
.print-body { display: flex; flex-direction: column; gap: 0.15em; }
.print-cn {
  font-size: clamp(2.4rem, 5.2vw, 4.2rem);
  font-weight: 700; line-height: 1; letter-spacing: -0.02em;
}
.print-en {
  font-stretch: 62.5%; font-weight: 500;
  font-size: clamp(0.95rem, 1.5vw, 1.35rem);
  letter-spacing: 0.22em;
  color: #1e5b46;
}
.print-meta {
  display: flex; flex-direction: column; gap: 2px;
  border-top: 1px solid rgba(0, 0, 0, 0.24);
  padding-top: 8px;
  font-stretch: 75%; font-weight: 400;
  font-size: calc(var(--xs) * 0.72);
  letter-spacing: 0.07em;
  color: #55554f;
}
.print-role {
  font-stretch: 100%; font-weight: 600;
  font-size: calc(var(--xs) * 0.92);
  letter-spacing: 0.02em;
  color: #141414;
  margin-bottom: 1px;
}
.print-mail { color: #1e5b46; }

.hero-copy { grid-column: 1 / -1; position: relative; min-width: 0; }
h1 {
  display: flex;
  align-items: flex-end;
  gap: clamp(10px, 1.4vw, 26px);
  font-size: clamp(2.8rem, 13.5vw, 7rem);
  font-weight: 600;
  line-height: 0.84;
  letter-spacing: -0.035em;
  white-space: nowrap;
  margin: 0 0 0.3em -0.045em;
}
h1 .name-cn {
  display: inline-block;
  line-height: 0.82;
  letter-spacing: 0.01em;
}
h1 .name-en {
  display: inline-flex;
  flex-direction: column;
  font-size: 0.4em;
  font-stretch: 62.5%;
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: 0.12em;
  padding-bottom: 0;
  color: var(--ink);
}
h1 .name-en span { display: block; }
.lede {
  font-size: var(--s1);
  line-height: 1.28;
  letter-spacing: -0.008em;
  max-width: 34ch;
}
.lede + .lede { margin-top: 0.75em; }
.links {
  display: flex; flex-wrap: wrap;
  gap: 10px 26px;
  margin-top: clamp(20px, 2.4vw, 32px);
}
.cta {
  font-weight: 500;
  text-decoration: none;
  border-bottom: 2px solid var(--yellow);
  padding-bottom: 3px;
}
.cta:hover { color: var(--yellow); }

@media (min-width: 960px) {
  .hero {
    min-height: min(calc(100svh - 58px), 1200px);
    align-items: end;
  }
  .stage-hero { position: absolute; inset: 0 0 0 47%; height: auto; }
  .print { width: min(46%, 50svh); }
  .hero-copy { grid-column: 1 / 8; }
  h1 { font-size: min(11vw, 26svh, 13rem); }
  .lede { max-width: 37ch; }
}

/* ---------- Sections ---------- */
.sec { padding-block: clamp(60px, 8.5vw, 168px); }
.head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  border-top: 1px solid var(--rule);
  padding-top: clamp(12px, 1.2vw, 18px);
  margin-bottom: clamp(28px, 4.4vw, 72px);
}
.head h2 {
  font-size: var(--s1); font-weight: 600; line-height: 1.1;
  letter-spacing: -0.015em;
}
.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--gap);
  row-gap: clamp(24px, 3.2vw, 52px);
}
.grid > * { grid-column: 1 / -1; min-width: 0; }
.lede a, .lead a, .more a { text-decoration-color: color-mix(in oklab, currentColor 26%, transparent); }
.lede a:hover, .lead a:hover, .more a:hover { text-decoration-color: currentColor; }
.lead {
  font-size: var(--s2);
  line-height: 1.16;
  letter-spacing: -0.02em;
  max-width: 25em;
}
.more { display: grid; gap: 1em; max-width: 33em; }
.ai-lead {
  font-size: var(--s1);
  line-height: 1.25;
  max-width: 33em;
  margin-bottom: clamp(24px, 3.2vw, 52px);
}
@media (min-width: 960px) { #ai .ai-lead { max-width: 58%; } }
@media (min-width: 960px) {
  #about .lead { grid-column: 1 / 9; }
  #about .more { grid-column: 1 / 7; }

  /* every section below the hero keeps its right third free for the sheets */
  #experience .works,
  #work .rows,
  #numbers .years,
  #contact .reach { grid-column: 1 / 8; }

  #capabilities .cells,
  #opportunities .cells,
  #ai .cells {
    grid-column: 1 / 8;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #numbers .year .rows { grid-column: 1 / -1; }
}

/* ---------- Selected writing / experience ---------- */
.works { border-bottom: 1px solid var(--rule); }
.work {
  position: relative;
  display: grid;
  grid-template-columns: 8.2em minmax(0, 1fr);
  gap: 4px 12px;
  align-items: baseline;
  padding-block: clamp(13px, 1.5vw, 22px);
  border-top: 1px solid var(--rule);
  text-decoration: none;
}
.work::before {
  content: ""; position: absolute;
  left: calc(-1 * var(--gutter) + 6px);
  top: 50%;
  width: max(6px, calc(var(--gutter) - 18px));
  height: 2px;
  background: var(--yellow);
  transform: scaleX(0);
  transform-origin: 0 50%;
  transition: transform 0.45s var(--ease);
}
.work:hover::before { transform: scaleX(1); }
.work-year {
  font: 400 var(--xs)/1.35 var(--sans);
  font-stretch: 75%;
  color: var(--dim);
  font-variant-numeric: tabular-nums lining-nums;
}
.work-title {
  font-size: var(--s1);
  font-weight: 500;
  line-height: 1.14;
  letter-spacing: -0.012em;
  text-wrap: balance;
  transition: color 0.25s;
}
.work-src {
  grid-column: 2;
  font: 400 var(--xs)/1.35 var(--sans);
  font-stretch: 75%;
  color: var(--dim);
}
.work:hover .work-title { color: var(--yellow); }

/* ---------- Dated rows ---------- */
.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px var(--gap);
  padding-block: clamp(12px, 1.3vw, 18px);
  border-top: 1px solid var(--rule);
  align-items: baseline;
}
.row-date {
  font: 400 var(--xs)/1.35 var(--sans);
  font-stretch: 75%;
  color: var(--dim);
  font-variant-numeric: lining-nums;
}
.row-main { display: grid; gap: 5px; min-width: 0; }
.row-title {
  font-size: var(--s1);
  font-weight: 500;
  line-height: 1.18;
  letter-spacing: -0.012em;
}
.row-sub {
  font-size: calc(var(--s0) * 0.9);
  line-height: 1.45;
  color: var(--dim);
}
.row-title { transition: color 0.25s; }
.row:hover .row-title { color: var(--yellow); }
.rows { border-bottom: 1px solid var(--rule); }
@media (min-width: 700px) {
  .row { grid-template-columns: 7.4em minmax(0, 1fr); }
}

/* ---------- Cells ---------- */
.cells {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: clamp(22px, 2.6vw, 40px) var(--gap);
}
.cell {
  display: grid;
  gap: 8px;
  align-content: start;
  border-top: 1px solid var(--rule);
  padding-top: 13px;
}
.cell .row-title { transition: color 0.25s; }
.cell:hover .row-title { color: var(--yellow); }

/* ---------- Figures by year ---------- */
.years { display: grid; gap: clamp(36px, 5vw, 88px); }
.year {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--gap);
  row-gap: 12px;
}
.year > * { grid-column: 1 / -1; min-width: 0; }

/* ---------- Contact ---------- */
.reach { display: grid; gap: clamp(8px, 1.4vw, 20px); align-self: center; }
.reach a {
  display: inline-grid;
  gap: 4px;
  text-decoration: none;
  font-size: clamp(2.4rem, 1rem + 6.4vw, 7.4rem);
  font-weight: 600;
  line-height: 0.92;
  letter-spacing: -0.03em;
  transition: color 0.2s;
}
.reach a:hover { color: var(--yellow); }
.reach .label { letter-spacing: 0; }
.reach .address { user-select: all; }
.play { margin-top: clamp(28px, 4vw, 64px); }
.play a { color: var(--ink); }
.play a:hover { color: var(--yellow); }

/* the name card at the centre of the contact ring */
#contact { position: relative; }
.contact-card { display: none; }
@media (min-width: 960px) {
  .contact-card {
    display: flex;
    position: absolute;
    left: 73.5%;
    top: 50%;
    width: min(24.4vw, 50svh);
    padding: 3.4%;
    margin: 0;
    transform: translate(-50%, -50%);
    z-index: 2;
  }
}

/* ---------- Footer ---------- */
footer {
  border-top: 1px solid var(--rule);
  padding-block: 26px 48px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  justify-content: space-between;
  position: relative;
}
footer a { text-decoration: none; }
footer nav { flex-basis: 100%; margin-bottom: 10px; }
footer nav ul {
  display: flex; flex-wrap: wrap;
  gap: 0 clamp(16px, 2vw, 30px);
}
footer nav a { display: inline-block; padding-block: 8px; color: var(--ink); }
footer nav a:hover { color: var(--yellow); }

/* ---------- The room of paper (WebGL) ---------- */
.scene {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.3s ease;
  overflow: hidden;
}
.scene-live .scene { opacity: 1; }
.scene-canvas {
  position: fixed; top: 0; left: 0;
  width: 100%; height: 100vh; height: 100lvh;
  pointer-events: none;
}

/* while the scene is live the printed matter moves into the room */
.scene-live .print { opacity: 0; transition: opacity 0.9s ease; }
.scene-live .contact-card { opacity: 0; pointer-events: none; }

/* the tag that follows the pointer over a sheet: kept out of flow so showing it
   never moves the page; only the visible chip takes clicks */
.sheet-link {
  position: fixed; left: 0; top: 0; z-index: 5;
  display: block;
  width: 84px; height: 84px;
  margin: -42px 0 0 -42px;
  text-decoration: none;
  cursor: pointer;
  pointer-events: none;
}
.sheet-link[hidden] { display: none; }
.sheet-link span {
  position: absolute; left: 60px; top: 58px;
  width: max-content; max-width: min(34ch, 62vw);
  background: var(--yellow); color: #000;
  padding: 6px 10px;
  font: 500 var(--xs)/1.35 var(--sans); font-stretch: 75%;
  pointer-events: auto;
}

/* masthead sound toggle */
.sound {
  font: inherit; color: var(--dim);
  background: none; border: 0; padding: 8px 4px;
  cursor: pointer; display: inline-flex; align-items: center;
}
.sound svg { display: block; }
.sound[aria-pressed="true"] .sound-muted,
.sound[aria-pressed="false"] .sound-on { display: none; }
.sound:hover, .sound[aria-pressed="true"] { color: var(--yellow); }
.sound[hidden] { display: none; }

/* stages: beside each list its items hang as paper; the one in view, or under
   the pointer, comes forward */
.stage { display: none; }
.stage-pile { display: none; }
.scene-live .stage-pile { display: block; }

.staged > .stage { order: -1; }

.row.is-facing .row-title,
.cell.is-facing .row-title,
.work.is-facing .work-title { color: var(--yellow); }
.work.is-facing::before { transform: scaleX(1); }

@media (min-width: 960px) {
  .scene-live .staged > :not(.stage) { grid-column: 1 / 8; grid-row: 1; }
  .scene-live .staged > .stage {
    display: block;
    grid-column: 8 / -1; grid-row: 1;
    height: 100%;
    min-height: 40svh;
    align-self: stretch;
  }
  .scene-live #contact .reach { grid-column: 1 / 7; }
  .scene-live .stage-pile {
    position: absolute;
    left: 73.5%; top: 50%;
    width: min(24.4vw, 50svh);
    aspect-ratio: 3 / 4;
    margin: 0;
    transform: translate(-50%, -50%);
  }
}

/* ---------- Accessibility helper ---------- */
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Small screens ---------- */
@media (max-width: 560px) {
  .work { grid-template-columns: 1fr; }
  .work-src { grid-column: 1; }
  .print { width: min(70%, 34svh); }
  h1 { font-size: clamp(2.7rem, 14vw, 4.6rem); }
  .reach a { font-size: clamp(2.2rem, 10vw, 3.4rem); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
  }
  .scene { display: none; }
  html { scroll-behavior: auto; }
}
