/* ============================================================
   svah-x · site.css — "the annotated forward pass"
   near-black · paper serif · mono annotations · magma accents
   ============================================================ */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg:        #0A0A0E;
  --bg-2:      #0F0F16;
  --bg-3:      #14141D;
  --ink:       #E8E3D7;
  --ink-2:     #C7C2BA;
  --mut:       #908C9C;
  --faint:     #625F70;
  --line:      rgba(232, 227, 215, .08);
  --line-2:    rgba(232, 227, 215, .17);
  --amber:     #EFA94A;
  --amber-hi:  #FFD9A0;
  --amber-dim: rgba(239, 169, 74, .55);
  --amber-soft:rgba(239, 169, 74, .09);
  --violet:    #8F7FDE;
  --rose:      #C9617F;
  --serif: 'Instrument Serif', 'Noto Serif SC', Georgia, serif;
  --body:  'Newsreader', 'Noto Serif SC', Georgia, serif;
  --mono:  'Spline Sans Mono', 'Noto Sans SC', ui-monospace, 'SF Mono', monospace;
  --wrap: 880px;
}

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.7;
  background: var(--bg);
  color: var(--ink-2);
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* zh: swap display + body serif for Noto Serif SC */
body.zh { --serif: 'Noto Serif SC', serif; }
body.zh h1, body.zh h2, body.zh h3 { font-weight: 600; letter-spacing: .015em; }
body.zh p { letter-spacing: .012em; }

/* ambient color wash, very low */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1100px 700px at 70% -8%, rgba(143, 127, 222, .055), transparent 62%),
    radial-gradient(900px 640px at 8% 108%, rgba(239, 169, 74, .045), transparent 60%);
}

/* film grain above everything */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 90; pointer-events: none;
  opacity: .038; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
}

/* token-vector field canvas */
#field { position: fixed; inset: 0; z-index: -2; pointer-events: none; }

::selection { background: var(--amber); color: #0A0A0E; }

a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; border-radius: 2px; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 28px; }

/* ---------- reveal on scroll ---------- */
.js .rv { opacity: 0; transform: translateY(16px); transition: opacity .7s ease, transform .7s cubic-bezier(.2, .7, .2, 1); }
.js .rv.in { opacity: 1; transform: none; }
.js [data-d="1"] { transition-delay: .08s; }
.js [data-d="2"] { transition-delay: .16s; }
.js [data-d="3"] { transition-delay: .24s; }
.js [data-d="4"] { transition-delay: .32s; }

/* ---------- header ---------- */
.hdr { position: fixed; top: 0; left: 0; right: 0; z-index: 50; transition: background .35s ease, border-color .35s ease; border-bottom: 1px solid transparent; }
.hdr.on { background: rgba(10, 10, 14, .82); -webkit-backdrop-filter: blur(14px) saturate(140%); backdrop-filter: blur(14px) saturate(140%); border-bottom-color: var(--line); }
.nav { max-width: var(--wrap); margin: 0 auto; padding: 0 28px; height: 62px; display: flex; align-items: center; justify-content: space-between; }
.brand { font-family: var(--mono); font-size: 13px; letter-spacing: .14em; color: var(--ink); }
.links { display: flex; align-items: center; gap: 24px; font-family: var(--mono); font-size: 12px; letter-spacing: .05em; color: var(--mut); }
.links a { transition: color .25s ease; }
.links a:hover { color: var(--ink); }
.lang { border: 1px solid var(--line-2); border-radius: 3px; padding: 4px 10px; color: var(--ink-2); }
.lang:hover { border-color: var(--amber-dim); }
.menu-btn { display: none; font-family: var(--mono); font-size: 12px; letter-spacing: .08em; color: var(--ink-2); background: none; border: 1px solid var(--line-2); border-radius: 3px; padding: 6px 12px; cursor: pointer; }

/* mobile sheet */
.sheet { position: fixed; inset: 0; z-index: 45; background: rgba(9, 9, 13, .96); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 48px 36px; opacity: 0; pointer-events: none; transition: opacity .3s ease; }
body.nav-open .sheet { opacity: 1; pointer-events: auto; }
body.nav-open { overflow: hidden; }
.sheet a { font-family: var(--serif); font-size: 34px; color: var(--ink); padding: 10px 0; border-bottom: 1px solid var(--line); display: flex; align-items: baseline; gap: 16px; }
.sheet a .ix { font-family: var(--mono); font-size: 11px; color: var(--faint); }

/* ---------- depth rail ---------- */
.rail { position: fixed; left: 30px; top: 50%; transform: translateY(-50%); z-index: 40; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.rail .track { width: 1px; height: 170px; background: var(--line-2); position: relative; }
.rail .pin { position: absolute; left: -2.5px; top: 0; width: 6px; height: 6px; background: var(--amber); transition: top .15s linear; }
.rail .lab { writing-mode: vertical-rl; font-family: var(--mono); font-size: 10.5px; letter-spacing: .2em; color: var(--faint); white-space: nowrap; }
@media (max-width: 1180px) { .rail { display: none; } }

/* ---------- hero ---------- */
.hero { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; padding-top: 130px; padding-bottom: 80px; }
.sys { font-family: var(--mono); font-size: 12px; letter-spacing: .16em; color: var(--mut); }
.sys .dim { color: var(--faint); }

.tokens { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 34px 10px; margin: 30px 0 44px; }
.tok { position: relative; border: 1px solid var(--line-2); border-radius: 7px; padding: 0 .13em .06em; transition: border-color .3s ease, background .3s ease; }
.tok .tk { font-family: var(--serif); font-weight: 400; font-size: clamp(52px, 9.5vw, 92px); line-height: 1.06; color: var(--ink); letter-spacing: -.01em; display: block; }
body.zh .tok .tk { font-weight: 600; }
.tok .tid { position: absolute; left: 7px; bottom: -22px; font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em; color: var(--faint); transition: color .3s ease; }
.tok:hover { border-color: var(--amber-dim); background: var(--amber-soft); }
.tok:hover .tid { color: var(--amber); }
.tokens .caret { width: 16px; height: clamp(44px, 7.5vw, 74px); margin-left: 4px; margin-bottom: 8px; background: var(--amber); animation: blink 1.1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

.lead { font-size: 18.5px; line-height: 1.78; max-width: 33em; color: var(--ink-2); }
.lead strong { color: var(--ink); font-weight: 500; }
body.zh .lead { line-height: 1.95; }

.state { margin-top: 40px; border-left: 1px solid var(--line-2); padding: 4px 0 4px 20px; display: grid; gap: 9px; }
.state > div { display: grid; grid-template-columns: 140px 1fr; gap: 14px; align-items: baseline; }
.state dt { font-family: var(--mono); font-size: 11.5px; letter-spacing: .1em; color: var(--faint); }
.state dd { font-family: var(--mono); font-size: 12.5px; letter-spacing: .02em; color: var(--ink-2); }
.state dd a { border-bottom: 1px solid var(--line-2); transition: border-color .25s, color .25s; }
.state dd a:hover { color: var(--amber-hi); border-color: var(--amber-dim); }

.cta { margin-top: 44px; display: flex; flex-wrap: wrap; gap: 12px; }
.btn { font-family: var(--mono); font-size: 12.5px; letter-spacing: .08em; color: var(--ink-2); border: 1px solid var(--line-2); border-radius: 4px; padding: 11px 18px; transition: border-color .25s ease, color .25s ease, background .25s ease; display: inline-flex; align-items: center; gap: 8px; background: none; cursor: pointer; }
.btn:hover { border-color: var(--amber-dim); color: var(--ink); background: var(--amber-soft); }
.btn--hot { border-color: var(--amber-dim); color: var(--amber-hi); }
.btn--hot:hover { background: rgba(239, 169, 74, .16); }

/* ---------- sections ---------- */
.sec { padding-top: 108px; padding-bottom: 30px; }
.sec .inner { border-top: 1px solid var(--line); padding-top: 26px; }
.mark { font-family: var(--mono); font-size: 11.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--mut); display: flex; align-items: center; gap: 11px; }
.mark::before { content: ""; width: 7px; height: 7px; background: var(--amber); flex-shrink: 0; }
.mark .path { color: var(--faint); letter-spacing: .1em; }
.h2 { font-family: var(--serif); font-weight: 400; font-size: clamp(34px, 5.4vw, 52px); line-height: 1.14; letter-spacing: -.005em; color: var(--ink); margin: 20px 0 0; text-wrap: balance; }
.h2 em { font-style: italic; color: var(--amber); }
body.zh .h2 em { font-style: normal; }
.sec-intro { margin-top: 22px; max-width: 60ch; font-size: 16.5px; color: var(--mut); }

/* ---------- research threads ---------- */
.threads { margin-top: 26px; }
.thread { display: grid; grid-template-columns: 240px 1fr; gap: 48px; padding: 48px 0; border-top: 1px solid var(--line); align-items: start; }
.thread:first-child { border-top: none; }
.thread figure { margin: 0; }
.thread figure svg { width: 100%; height: auto; display: block; }
.thread figcaption { margin-top: 12px; font-family: var(--mono); font-size: 11px; letter-spacing: .04em; line-height: 1.6; color: var(--faint); }
.thread .hx { font-family: var(--mono); font-size: 11.5px; letter-spacing: .14em; color: var(--amber); }
.thread h3 { font-family: var(--serif); font-weight: 400; font-size: 27px; color: var(--ink); margin: 10px 0 14px; }
.thread p { font-size: 16px; line-height: 1.8; max-width: 58ch; }
.thread p + p { margin-top: 12px; }
.thread .ft { margin-top: 18px; font-family: var(--mono); font-size: 11.5px; letter-spacing: .05em; color: var(--faint); }
.thread .ft::before { content: "› "; color: var(--amber-dim); }

/* ---------- project rows ---------- */
.projects { margin-top: 30px; }
.proj { display: grid; grid-template-columns: 52px 1fr auto; gap: 26px; padding: 36px 0; border-top: 1px solid var(--line); align-items: start; }
.proj .ix { font-family: var(--mono); font-size: 13px; color: var(--faint); padding-top: 8px; transition: color .3s ease; }
.proj:hover .ix { color: var(--amber); }
.proj h3 { font-family: var(--serif); font-weight: 400; font-size: 25px; color: var(--ink); }
.proj h3 a { border-bottom: 1px solid transparent; transition: border-color .25s; }
.proj h3 a:hover { border-bottom-color: var(--amber-dim); }
.proj p { margin-top: 9px; font-size: 15.5px; line-height: 1.75; max-width: 56ch; }
.proj .meta { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 7px 16px; font-family: var(--mono); font-size: 11.5px; letter-spacing: .04em; color: var(--faint); }
.proj .meta a { color: var(--ink-2); border-bottom: 1px solid var(--line-2); transition: color .25s, border-color .25s; }
.proj .meta a:hover { color: var(--amber-hi); border-color: var(--amber-dim); }
.proj .year { font-family: var(--mono); font-size: 12px; color: var(--mut); padding-top: 10px; }

/* compact rows (courses, education, awards) */
.rows { margin-top: 26px; }
.row { display: grid; grid-template-columns: 110px 1fr auto; gap: 24px; padding: 26px 0; border-top: 1px solid var(--line); align-items: baseline; }
.row .r-when { font-family: var(--mono); font-size: 12px; color: var(--mut); }
.row .r-t { font-family: var(--serif); font-weight: 400; font-size: 21px; color: var(--ink); }
body.zh .row .r-t { font-weight: 600; }
.row .r-t a { border-bottom: 1px solid transparent; transition: border-color .25s; }
.row .r-t a:hover { border-bottom-color: var(--amber-dim); }
.row .r-s { margin-top: 6px; font-size: 14.5px; line-height: 1.7; color: var(--mut); max-width: 56ch; }
.row .r-go { font-family: var(--mono); font-size: 11.5px; color: var(--faint); transition: color .25s; }
.row:hover .r-go { color: var(--amber); }

/* ---------- about ---------- */
.about-body { margin-top: 26px; max-width: 62ch; }
.about-body p { font-size: 16.5px; line-height: 1.85; }
.about-body p + p { margin-top: 16px; }
.about-body strong { color: var(--ink); font-weight: 500; }
.about-cols { margin-top: 56px; display: grid; grid-template-columns: 1fr 1fr; gap: 56px; align-items: start; }
.subhead { font-family: var(--mono); font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--mut); }

.kit { margin-top: 26px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255, 255, 255, .015); padding: 8px 22px; }
.kit > div { display: grid; grid-template-columns: 118px 1fr; gap: 16px; padding: 13px 0; border-top: 1px solid var(--line); align-items: baseline; }
.kit > div:first-child { border-top: none; }
.kit dt { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }
.kit dd { font-family: var(--mono); font-size: 12.5px; line-height: 1.8; color: var(--ink-2); }

/* ---------- contact ---------- */
.email-big { display: inline-block; margin-top: 34px; font-family: var(--serif); font-size: clamp(24px, 4.6vw, 42px); color: var(--ink); border-bottom: 1px solid var(--line-2); padding-bottom: 6px; transition: color .3s, border-color .3s; }
.email-big:hover { color: var(--amber-hi); border-color: var(--amber-dim); }
.email-hint { margin-top: 12px; font-family: var(--mono); font-size: 11.5px; letter-spacing: .08em; color: var(--faint); transition: color .25s; }
.email-hint.on { color: var(--amber); }
a.copied { color: var(--amber-hi) !important; }
.clinks { margin-top: 44px; max-width: 560px; }
.clink { display: grid; grid-template-columns: 96px 1fr auto; gap: 20px; align-items: baseline; padding: 16px 0; border-top: 1px solid var(--line); font-family: var(--mono); }
.clink .k { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--faint); }
.clink .v { font-size: 13px; color: var(--ink-2); transition: color .25s; }
.clink .go { font-size: 12px; color: var(--faint); transition: color .25s, transform .25s; }
.clink:hover .v { color: var(--amber-hi); }
.clink:hover .go { color: var(--amber); transform: translateX(3px); }

/* ---------- footer ---------- */
.foot { margin-top: 110px; border-top: 1px solid var(--line); }
.foot-row { max-width: var(--wrap); margin: 0 auto; padding: 26px 28px 8px; display: flex; flex-wrap: wrap; gap: 12px 28px; align-items: baseline; justify-content: space-between; font-family: var(--mono); font-size: 11.5px; letter-spacing: .04em; color: var(--faint); }
.foot-row a { color: var(--mut); transition: color .25s; }
.foot-row a:hover { color: var(--ink); }
.foot-links { display: flex; flex-wrap: wrap; gap: 18px; }
.eot { text-align: center; font-family: var(--mono); font-size: 12px; letter-spacing: .12em; color: var(--faint); padding: 30px 0 34px; }

/* ---------- language gate (index.html) ---------- */
.gate { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 28px; }
.gate-stage { width: 100%; max-width: 560px; text-align: center; }
.gate .tokens { justify-content: center; margin: 26px 0 40px; }
.gate .tok .tk { font-size: clamp(46px, 11vw, 76px); }
.gate-sub { font-family: var(--mono); font-size: 12px; letter-spacing: .14em; color: var(--mut); }
.gate-q { margin-top: 56px; font-family: var(--mono); font-size: 11.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--faint); }
.gate-opts { margin-top: 24px; display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.gate-opt { flex: 1 1 190px; max-width: 230px; text-align: left; border: 1px solid var(--line-2); border-radius: 8px; padding: 20px 22px 18px; transition: border-color .3s, background .3s, transform .3s cubic-bezier(.2, .7, .2, 1); }
.gate-opt .gl { font-family: var(--serif); font-size: 28px; color: var(--ink); display: block; }
.gate-opt .gp { display: block; margin-top: 14px; font-family: var(--mono); font-size: 11px; letter-spacing: .08em; color: var(--faint); transition: color .3s; }
.gate-opt .bar { display: block; margin-top: 8px; height: 2px; background: var(--line); position: relative; overflow: hidden; }
.gate-opt .bar i { position: absolute; inset: 0; right: 50%; background: var(--amber-dim); transition: right .45s cubic-bezier(.2, .7, .2, 1); }
.gate-opt:hover { border-color: var(--amber-dim); background: var(--amber-soft); transform: translateY(-3px); }
.gate-opt:hover .gp { color: var(--amber); }

/* ---------- responsive ---------- */
@media (max-width: 920px) {
  .thread { grid-template-columns: 1fr; gap: 26px; }
  .thread figure { max-width: 250px; }
  .about-cols { grid-template-columns: 1fr; gap: 44px; }
  .proj { grid-template-columns: 40px 1fr; }
  .proj .year { grid-column: 2; padding-top: 0; }
  .row { grid-template-columns: 1fr; gap: 6px; padding: 22px 0; }
  .row .r-go { display: none; }
}
@media (max-width: 760px) {
  .links { display: none; }
  .menu-btn { display: inline-block; }
  .hero { padding-top: 110px; }
  .sec { padding-top: 84px; }
  .state > div { grid-template-columns: 1fr; gap: 1px; }
  .state dd { padding-bottom: 6px; }
  .tokens { gap: 8px; }
  .tok .tid { bottom: -20px; font-size: 10px; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .rv { opacity: 1 !important; transform: none !important; }
}
