/* ============================================================
   Nathan Zhang / 张豪楠 — personal site
   Line-art, warm paper, motion-first. No CDN.
   ============================================================ */

@font-face {
  font-family: "Cormorant Garamond";
  src: url("../assets/fonts/CormorantGaramond-Variable.ttf") format("truetype");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Cormorant Garamond";
  src: url("../assets/fonts/CormorantGaramond-Italic-Variable.ttf") format("truetype");
  font-weight: 300 700;
  font-style: italic;
  font-display: swap;
}

@font-face {
  font-family: "Libre Franklin";
  src: url("../assets/fonts/LibreFranklin-Variable.ttf") format("truetype");
  font-weight: 300 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Libre Franklin";
  src: url("../assets/fonts/LibreFranklin-Italic-Variable.ttf") format("truetype");
  font-weight: 300 800;
  font-style: italic;
  font-display: swap;
}

:root {
  --bg: #f3ece0;
  --bg-deep: #e8ddce;
  --paper: #fbf6ee;
  --ink: #2b2218;
  --ink-soft: #5c4d3c;
  --line: #3a2f24;
  --accent: #b55232;
  --accent-soft: #d4a07a;
  --gold: #8a6a3b;
  --hair: rgba(43, 34, 24, 0.18);
  --shadow: rgba(43, 34, 24, 0.08);
  --header-h: 72px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font-display: "Cormorant Garamond", "Noto Serif CJK SC", "Source Han Serif SC",
    "Songti SC", "STSong", "SimSun", Georgia, serif;
  --font-body: "Libre Franklin", "Noto Sans CJK SC", "Source Han Sans SC",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans", sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  background: var(--bg);
  color: var(--ink);
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 17px;
  line-height: 1.7;
  background:
    radial-gradient(1200px 700px at 10% -10%, rgba(212, 160, 122, 0.18), transparent 55%),
    radial-gradient(900px 600px at 110% 20%, rgba(181, 82, 50, 0.07), transparent 50%),
    var(--bg);
  color: var(--ink);
  overflow-x: hidden;
  min-height: 100%;
}

/* Paper grain — CSS only, no image request */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 40;
  opacity: 0.28;
  mix-blend-mode: multiply;
  background-image:
    repeating-radial-gradient(circle at 18% 32%, rgba(43, 34, 24, 0.035) 0 1px, transparent 1px 3px),
    repeating-radial-gradient(circle at 82% 68%, rgba(43, 34, 24, 0.03) 0 1px, transparent 1px 4px);
  background-size: 120px 120px, 90px 90px;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -40px;
  z-index: 80;
  background: var(--ink);
  color: var(--paper);
  padding: 8px 12px;
  text-decoration: none;
}
.skip-link:focus { top: 12px; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* Language visibility */
html[lang="zh-CN"] .t-en { display: none; }
html[lang="en"] .t-zh { display: none; }

html[lang="en"] body { letter-spacing: 0.01em; }
html[lang="zh-CN"] body { letter-spacing: 0.02em; line-height: 1.8; }

main.is-lang-fading {
  opacity: 0;
  transform: translateY(6px);
}
main {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.38s var(--ease), transform 0.38s var(--ease);
  position: relative;
  z-index: 2;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 24px;
  height: var(--header-h);
  padding: 0 36px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.3s ease, background 0.3s ease;
}
.site-header.is-scrolled {
  border-bottom-color: var(--hair);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  flex: 0 0 auto;
}
.logo-mark {
  width: 34px;
  height: 34px;
  color: var(--ink);
}
.logo-mark .draw {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
}
.logo-mark text {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 500;
  fill: currentColor;
}
.logo-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.15rem;
  letter-spacing: 0.06em;
}

.nav {
  display: flex;
  gap: 28px;
  margin-left: auto;
}
.nav a {
  position: relative;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.86rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 6px 0;
}
html[lang="zh-CN"] .nav a {
  text-transform: none;
  letter-spacing: 0.18em;
  font-size: 0.92rem;
}
.nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: var(--ink);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.45s var(--ease);
}
.nav a:hover::after,
.nav a:focus-visible::after { transform: scaleX(1); }

/* Language toggle */
.lang-toggle {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 108px;
  height: 34px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
  flex: 0 0 auto;
}
.lang-toggle button {
  position: relative;
  z-index: 1;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: color 0.3s ease;
}
.lang-knob {
  position: absolute;
  top: 2px; bottom: 2px; left: 2px;
  width: calc(50% - 2px);
  background: var(--ink);
  border-radius: 999px;
  transition: transform 0.45s var(--ease);
  z-index: 0;
}
html[lang="en"] .lang-knob { transform: translateX(100%); }
html[lang="zh-CN"] .lang-toggle button[data-lang="zh-CN"],
html[lang="en"] .lang-toggle button[data-lang="en"] { color: var(--paper); }

/* ---------- Spine ---------- */
.spine {
  position: fixed;
  top: 0;
  left: 18px;
  width: 48px;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  overflow: visible;
}
.spine-path {
  fill: none;
  stroke: var(--gold);
  stroke-width: 1.15;
  opacity: 0.55;
}

/* ---------- Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 40px;
  align-items: center;
  min-height: calc(100svh - var(--header-h));
  padding: 48px 80px 64px 96px;
  position: relative;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 16px;
  font-size: 0.78rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
}
html[lang="zh-CN"] .eyebrow { letter-spacing: 0.28em; text-transform: none; }
.flourish { width: 64px; height: 12px; color: var(--gold); }

.hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(4.2rem, 9vw, 7.2rem);
  line-height: 0.95;
  letter-spacing: 0.02em;
}
html[lang="en"] .hero h1 {
  font-style: italic;
  font-weight: 450;
  letter-spacing: -0.02em;
}

.hero-role {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 0;
  font-size: 1.02rem;
  color: var(--ink-soft);
  letter-spacing: 0.08em;
}
.hero-role .flourish { width: 64px; height: 12px; color: var(--gold); flex: 0 0 auto; }

.lede {
  margin: 28px 0 0;
  max-width: 26em;
  font-size: 1.22rem;
  line-height: 1.75;
  color: var(--ink);
}
html[lang="en"] .lede {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.45rem;
  line-height: 1.45;
}

.hero { position: relative; }
.scroll-cue {
  position: absolute;
  left: 96px;
  bottom: 36px;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-top: 0;
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.scroll-cue svg { width: 22px; height: 44px; color: var(--ink); }
.scroll-cue:hover { color: var(--ink); }
.scroll-cue:hover svg { transform: translateY(4px); }
.scroll-cue svg { transition: transform 0.4s var(--ease); }

/* Portrait */
.portrait-wrap {
  position: relative;
  width: min(420px, 100%);
  margin-left: auto;
  will-change: transform;
}
.portrait {
  margin: 0;
  position: relative;
  aspect-ratio: 320 / 400;
}
.portrait-frame,
.orbit-line {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  color: var(--ink);
}
.orbit-line {
  inset: -8% -8%;
  width: 116%;
  height: 116%;
  color: var(--gold);
  opacity: 0.7;
  pointer-events: none;
}
.portrait-frame .draw,
.orbit-line .draw,
.flourish .draw,
.scroll-cue .draw,
.logo-mark .draw,
.connector .draw,
.title-underline .draw,
.note-frame .draw,
.card-frame .draw,
.note-card-frame .draw,
.footer-line .draw {
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.portrait-frame .frame-outer { stroke-width: 1.6; }
.portrait-frame .frame-inner { stroke-width: 0.9; opacity: 0.7; }
.portrait-frame .sprig { stroke-width: 1.1; color: var(--accent); }
.portrait-frame path { stroke-width: 1.2; }

.portrait-face {
  position: absolute;
  inset: 10% 11% 9% 11%;
  overflow: hidden;
  background: #d9cbb8;
}
.portrait-face.is-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(120% 80% at 50% 20%, #f7efe4, #e9d7c2 55%, #ddc4a8);
}
.portrait-face.is-fallback .portrait-char {
  font-family: var(--font-display);
  font-size: clamp(7rem, 18vw, 10.5rem);
  font-weight: 500;
  line-height: 0.85;
  color: var(--ink);
}
.portrait-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 22%;
  display: block;
  transform: scale(1.02);
  transition: transform 0.8s var(--ease);
}
.portrait:hover .portrait-photo,
.portrait:focus-within .portrait-face.is-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(120% 80% at 50% 20%, #f7efe4, #e9d7c2 55%, #ddc4a8);
}
.portrait-face.is-fallback .portrait-char {
  font-family: var(--font-display);
  font-size: clamp(7rem, 18vw, 10.5rem);
  font-weight: 500;
  line-height: 0.85;
  color: var(--ink);
}
.portrait-photo {
  transform: scale(1.05);
}
.name-seal {
  position: absolute;
  right: 4%;
  bottom: 6%;
  width: 76px;
  height: 76px;
  z-index: 2;
  color: var(--paper);
  pointer-events: none;
}
.seal-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  color: var(--paper);
  filter: drop-shadow(0 1px 2px rgba(43, 34, 24, 0.35));
}
.seal-frame .draw {
  fill: rgba(43, 34, 24, 0.28);
  stroke: var(--paper);
  stroke-width: 1.6;
}
.seal-char {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 500;
  color: var(--paper);
  line-height: 1;
}

/* ---------- Connectors ---------- */
.connector {
  height: 120px;
  padding: 0 80px 0 96px;
  color: var(--gold);
  position: relative;
  z-index: 2;
}
.connector svg { width: 100%; height: 100%; overflow: visible; }
.connector .draw { stroke-width: 1.15; }

/* ---------- Sections ---------- */
.section {
  padding: 40px 80px 24px 96px;
  position: relative;
  z-index: 2;
}

.section-kicker {
  margin-bottom: 36px;
}
.section-kicker .index {
  display: block;
  font-family: var(--font-body);
  font-style: normal;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.16em;
  font-size: 0.78rem;
  margin-bottom: 6px;
  font-variant-numeric: lining-nums tabular-nums;
}
.section-kicker h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  line-height: 1.1;
}
.title-underline {
  display: block;
  width: min(240px, 50%);
  height: 16px;
  margin-top: 4px;
  color: var(--accent);
}

/* About */
.about-grid {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr;
  gap: 64px;
  align-items: start;
}
.about-body {
  max-width: 38em;
}
.about-body p {
  margin: 0 0 1.15em;
  font-size: 1.08rem;
  color: var(--ink);
}
html[lang="en"] .about-body p:first-of-type {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.45rem;
  line-height: 1.4;
}

.about-note {
  position: relative;
  min-height: 0;
  will-change: transform;
}
.note-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: var(--ink);
}
.about-note blockquote {
  position: relative;
  margin: 0;
  padding: 52px 40px 44px;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.45rem;
  line-height: 1.45;
  color: var(--ink);
}

/* Cards */
.cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}
.card {
  position: relative;
  padding: 36px 32px 32px;
  background: color-mix(in srgb, var(--paper) 70%, transparent);
  transition: transform 0.45s var(--ease);
  will-change: transform;
}
.card-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: var(--ink);
  pointer-events: none;
  overflow: visible;
}
.card-frame .draw { stroke-width: 1.05; }
.card-index {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--accent);
  letter-spacing: 0.08em;
  font-size: 0.95rem;
}
.card h3 {
  margin: 10px 0 14px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.85rem;
  line-height: 1.2;
}
.card p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.98rem;
}
.card::after {
  content: "";
  position: absolute;
  right: 22px;
  bottom: 20px;
  width: 22px;
  height: 22px;
  border-right: 1px solid var(--accent);
  border-bottom: 1px solid var(--accent);
  transform: scale(0.4) translate(-6px, -6px);
  opacity: 0;
  transition: transform 0.45s var(--ease), opacity 0.45s var(--ease);
}
.card:hover,
.card:focus-within {
  transform: translateY(-6px);
}
.card:hover::after,
.card:focus-within::after {
  opacity: 1;
  transform: scale(1) translate(0, 0);
}


/* Viewpoints / notes */
.notes {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 28px;
}
.note {
  position: relative;
  padding: 32px 28px 28px;
  background: color-mix(in srgb, var(--paper) 70%, transparent);
  transition: transform 0.45s var(--ease);
}
.note-card-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  color: var(--ink);
  pointer-events: none;
  overflow: visible;
}
.note-card-frame .draw { stroke-width: 1.05; fill: none; }
.note h3 {
  margin: 10px 0 14px;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.45rem;
  line-height: 1.3;
}
.note p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.96rem;
}
.note:hover { transform: translateY(-6px); }
.notes .reveal:nth-child(2) { transition-delay: 0.08s; }
.notes .reveal:nth-child(3) { transition-delay: 0.16s; }

/* Contact */
.contact-lede {
  max-width: 28em;
  font-size: 1.2rem;
  margin: 0 0 36px;
}
html[lang="en"] .contact-lede {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.5rem;
  line-height: 1.4;
}

.contact-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 22px;
  max-width: 36em;
}
.contact-list li {
  display: grid;
  grid-template-columns: 5.5em 1fr;
  gap: 16px;
  align-items: baseline;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--hair);
}
.contact-label {
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}
html[lang="zh-CN"] .contact-label { letter-spacing: 0.22em; text-transform: none; }
.contact-list a {
  color: var(--ink);
  text-decoration: none;
  font-size: 1.15rem;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0 1px;
  background-repeat: no-repeat;
  background-position: 0 100%;
  transition: background-size 0.4s var(--ease);
}
.contact-list a:hover,
.contact-list a:focus-visible { background-size: 100% 1px; }

.contact-links {
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  margin-top: 40px;
}
.text-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  text-decoration: none;
  font-size: 1rem;
  letter-spacing: 0.06em;
}
.link-arrow {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.35s var(--ease);
}
.text-link:hover .link-arrow,
.text-link:focus-visible .link-arrow {
  transform: translate(3px, -3px);
}

/* Footer */
.site-footer {
  position: relative;
  z-index: 2;
  padding: 24px 80px 48px 96px;
  color: var(--ink-soft);
  font-size: 0.88rem;
}
.footer-line {
  width: 100%;
  height: 40px;
  color: var(--gold);
  margin-bottom: 8px;
}
.site-footer .sep { margin: 0 0.6em; }

/* ---------- Motion: draw + reveal + hover ---------- */
.draw {
  stroke-dasharray: var(--len, 800);
  stroke-dashoffset: var(--len, 800);
}
.draw.is-drawn {
  animation: draw-stroke 1.7s var(--ease) forwards;
}
.draw.is-drawn.delay-1 { animation-delay: 0.12s; }
.draw.is-drawn.delay-2 { animation-delay: 0.24s; }
.draw.is-drawn.delay-3 { animation-delay: 0.4s; }

@keyframes draw-stroke {
  to { stroke-dashoffset: 0; }
}

.reveal {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
}
.reveal.is-inview {
  opacity: 1;
  transform: none;
}
.cards .reveal:nth-child(2) { transition-delay: 0.08s; }
.cards .reveal:nth-child(3) { transition-delay: 0.16s; }
.cards .reveal:nth-child(4) { transition-delay: 0.24s; }
.contact-list .reveal:nth-child(2) { transition-delay: 0.08s; }
.contact-list .reveal:nth-child(3) { transition-delay: 0.16s; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .draw { stroke-dashoffset: 0 !important; }
  .reveal { opacity: 1 !important; transform: none !important; }
  main.is-lang-fading { opacity: 1; transform: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .site-header { padding: 0 20px; gap: 12px; }
  .nav { gap: 14px; }
  .nav a { letter-spacing: 0.06em; font-size: 0.8rem; }
  .hero,
  .section,
  .connector,
  .site-footer {
    padding-left: 28px;
    padding-right: 24px;
  }
  .hero {
    grid-template-columns: 1fr;
    min-height: auto;
    padding-top: 28px;
    padding-bottom: 24px;
    gap: 36px;
  }
  .portrait-wrap { margin: 0 auto; width: min(320px, 80%); }
  .hero-copy { padding-bottom: 0; }
  .scroll-cue { position: static; left: auto; bottom: auto; margin: 28px 0 8px; }
  .hero h1 { font-size: clamp(3.4rem, 16vw, 5.2rem); }
  .portrait-wrap { margin-bottom: 12px; }
  .about-grid,
  .cards,
  .notes { grid-template-columns: 1fr; }
  .spine { left: 4px; width: 24px; opacity: 0.6; }
  .contact-list li { grid-template-columns: 1fr; gap: 4px; }
}

@media (max-width: 560px) {
  .nav { display: none; }
  .logo-name { display: none; }
}
