/* ============================================================
   [Your Name] — Portfolio
   White editorial / Swiss design · GSAP-driven
   ============================================================ */

:root {
  --bg: #fbfbfa;
  --bg-soft: #f4f4f2;
  --ink: #0a0a0a;
  --ink-soft: #555550;
  --ink-faint: #9b9b94;
  --line: #e6e6e1;
  --accent: #ef5a2a;        /* warm coral */
  --accent-soft: #ffe9e0;
  /* warm multi-accent palette for section / project identity */
  --c-coral:  #ef5a2a;
  --c-rose:   #e84a8a;
  --c-amber:  #f2960f;
  --c-orange: #e2761a;
  --c-berry:  #d6336c;
  --c-peach:  #ff8a5c;
  --radius: 18px;
  --maxw: 1320px;
  --pad: clamp(20px, 5vw, 80px);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

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

html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; background: var(--bg); }

body {
  background: transparent;
  color: var(--ink);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.6;
  overflow-x: hidden;
}

/* full-page animated warm noise background (WebGL) */
.noise-bg {
  position: fixed; inset: 0; z-index: -1;
  width: 100%; height: 100%; display: block; pointer-events: none;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

::selection { background: var(--accent); color: #fff; }

/* ---------- Grain ---------- */
.grain {
  position: fixed; inset: 0; z-index: 9998; pointer-events: none;
  opacity: 0.035; mix-blend-mode: multiply;
  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='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- Layout helpers ---------- */
section { padding-left: var(--pad); padding-right: var(--pad); }

.section-head { max-width: var(--maxw); margin: 0 auto; }
.section-head__index {
  display: inline-block; font-family: "JetBrains Mono", monospace;
  font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 28px;
}
.section-head__title {
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(34px, 6vw, 76px); line-height: 1.02;
  letter-spacing: -0.03em; font-weight: 600;
}

/* ---------- NAV ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px var(--pad);
  color: var(--ink); transition: color .4s ease;
}
.nav.is-dark { color: #fff; }
.nav__logo {
  font-family: "Space Grotesk", sans-serif; font-weight: 700;
  font-size: 18px; letter-spacing: -0.02em; display: flex; gap: 8px; align-items: center;
}
.nav__mark { color: var(--accent); }
.nav__links { display: flex; align-items: center; gap: 30px; font-size: 15px; font-weight: 500; }
.nav__links a { position: relative; }
.nav__links a:not(.nav__cta)::after {
  content: ""; position: absolute; left: 0; bottom: -4px; width: 0; height: 1px;
  background: currentColor; transition: width .3s var(--ease);
}
.nav__links a:not(.nav__cta):hover::after { width: 100%; }
.nav__cta {
  border: 1px solid currentColor; padding: 8px 18px; border-radius: 100px;
  transition: background .3s, color .3s;
}
.lang-toggle {
  font: inherit; font-size: 13px; font-weight: 600; letter-spacing: 0.02em;
  min-width: 46px; height: 32px; padding: 0 12px; cursor: pointer;
  background: transparent; color: currentColor;
  border: 1px solid currentColor; border-radius: 100px;
  transition: opacity .3s;
}
.lang-toggle:hover { opacity: 0.55; }
@media (max-width: 720px) { .nav__links a:not(.nav__cta) { display: none; } }

/* ---------- Chinese typography fallback ---------- */
html[lang="zh"] body,
html[lang="zh"] .hero__title,
html[lang="zh"] .section-head__title,
html[lang="zh"] .contact__title {
  font-family: "Space Grotesk", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}
html[lang="zh"] body { font-family: "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif; }
html[lang="zh"] .hero__title { letter-spacing: -0.02em; line-height: 1.04; }
html[lang="zh"] .contact__title { letter-spacing: -0.01em; line-height: 1.1; }

/* ---------- HERO ---------- */
.hero {
  position: relative; min-height: 100vh; overflow: hidden;
  display: flex; align-items: center;
  padding-top: 120px; padding-bottom: 60px;
}
.hero__inner {
  position: relative; z-index: 2;
  max-width: var(--maxw); margin: 0 auto; width: 100%;
  display: grid; grid-template-columns: 1.05fr 0.95fr;
  gap: clamp(30px, 5vw, 80px); align-items: center;
}
.hero__col { pointer-events: none; }
.hero__col a { pointer-events: auto; }

.hero__meta {
  display: flex; align-items: center; gap: 14px;
  font-family: "JetBrains Mono", monospace; font-size: 13px;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft);
  margin-bottom: 32px;
}
.hero__meta-dot { color: var(--accent); }

.hero__title {
  font-family: "Space Grotesk", sans-serif; font-weight: 600;
  font-size: clamp(44px, 7.2vw, 108px); line-height: 0.92;
  letter-spacing: -0.045em; margin-bottom: 34px;
}
.hero__title .line { display: block; overflow: hidden; }
.hero__title .word { display: inline-block; will-change: transform; }
.word.accent {
  font-family: "Space Grotesk", sans-serif; font-style: italic;
  color: var(--accent);
}

.hero__lead {
  max-width: 480px; font-size: clamp(17px, 2vw, 20px);
  color: var(--ink-soft); margin-bottom: 40px;
}
.hero__actions { display: flex; gap: 16px; flex-wrap: wrap; }

/* ---------- HERO SHOWCASE (auto-cycling 3D card stack) ---------- */
.hero__showcase { perspective: 1400px; }
.showcase {
  position: relative; width: 100%; aspect-ratio: 4 / 3.1;
  transform-style: preserve-3d;
}
.showcase__card {
  position: absolute; inset: 0; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); background: #fff;
  box-shadow: 0 50px 90px -45px rgba(20, 20, 50, 0.35); opacity: 0;
}
.showcase__card img { width: 100%; height: 100%; object-fit: cover; }
.showcase__tag {
  position: absolute; top: 16px; left: 16px; z-index: 3;
  font-family: "JetBrains Mono", monospace; font-size: 12px;
  background: var(--ink); color: #fff; padding: 6px 12px; border-radius: 100px;
}
.showcase__tag--mine { background: var(--accent); }
.showcase__label {
  position: absolute; left: 16px; bottom: 16px; z-index: 3;
  background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px;
}
.showcase__label h3 { font-family: "Space Grotesk", sans-serif; font-size: 19px; letter-spacing: -0.02em; }
.showcase__label p { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.showcase__dots { display: flex; gap: 9px; margin-top: 22px; justify-content: flex-end; }
.showcase__dots button {
  width: 30px; height: 4px; border-radius: 4px; border: 0; background: var(--line);
  cursor: pointer; padding: 0; transition: background 0.3s;
}
.showcase__dots button.on { background: var(--accent); }

@media (max-width: 920px) {
  .hero { padding-top: 110px; }
  .hero__inner { grid-template-columns: 1fr; gap: 50px; }
  .hero__showcase { order: 2; max-width: 560px; }
  .hero__title { font-size: clamp(44px, 11vw, 92px); }
}

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 16px 30px; border-radius: 100px; font-weight: 600; font-size: 16px;
  transition: transform .3s var(--ease), background .3s, color .3s, box-shadow .3s;
}
.btn--primary { background: var(--ink); color: #fff; }
.btn--primary:hover { background: var(--accent); box-shadow: 0 16px 40px -12px rgba(239,90,42,.5); }
.btn--ghost { border: 1px solid var(--line); color: var(--ink); }
.btn--ghost:hover { border-color: var(--ink); }

.hero__scroll {
  position: absolute; bottom: 40px; right: 0;
  display: flex; align-items: center; gap: 14px;
  font-family: "JetBrains Mono", monospace; font-size: 12px;
  letter-spacing: 0.15em; text-transform: uppercase; color: var(--ink-faint);
}
.hero__scroll-line { width: 60px; height: 1px; background: var(--ink-faint); transform-origin: left; animation: scrollLine 2s var(--ease) infinite; }
@keyframes scrollLine { 0%,100%{transform:scaleX(.3);opacity:.4} 50%{transform:scaleX(1);opacity:1} }

/* ---------- STATS ---------- */
.stats { padding-top: 80px; padding-bottom: 80px; border-top: 1px solid var(--line); }
.stats__grid {
  max-width: var(--maxw); margin: 0 auto;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 40px;
}
.stat__num {
  font-family: "Space Grotesk", sans-serif; font-weight: 600;
  font-size: clamp(44px, 6vw, 84px); letter-spacing: -0.04em; line-height: 1;
}
.stat__label { margin-top: 12px; color: var(--ink-soft); font-size: 15px; max-width: 220px; }
@media (max-width: 820px) { .stats__grid { grid-template-columns: repeat(2, 1fr); gap: 36px; } }

/* ---------- WORK ---------- */
.work { padding-top: 120px; padding-bottom: 60px; }
.work .section-head { margin-bottom: 90px; }

.project {
  max-width: var(--maxw); margin: 0 auto 160px;
  display: grid; grid-template-columns: 1.1fr 1fr; gap: clamp(40px, 6vw, 100px);
  align-items: center;
}
.project:nth-child(even) .project__media { order: 2; }

.project__media { position: relative; will-change: transform; }
.project__frame {
  border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 40px 80px -40px rgba(20,20,40,.25);
  transform-style: preserve-3d;
}
.project__frame img { width: 100%; transition: transform .8s var(--ease); display: block; }
.project__frame > img { }
.project__media:hover .project__frame > img { transform: scale(1.04); }

/* Project image carousel */
.carousel { position: relative; overflow: hidden; line-height: 0; aspect-ratio: 16/9; }
.carousel__track { display: flex; height: 100%; transition: transform 0.45s cubic-bezier(0.4,0,0.2,1); }
.carousel__slide { min-width: 100%; width: 100%; flex-shrink: 0; height: 100%; object-fit: cover; }
.project__media:hover .carousel__slide { transform: scale(1.03); transition: transform .8s var(--ease); }
.carousel__btn {
  position: absolute; top: 50%; transform: translateY(-50%);
  background: rgba(10,10,20,.5); backdrop-filter: blur(6px);
  color: #fff; border: none; border-radius: 50%;
  width: 40px; height: 40px; cursor: pointer; font-size: 26px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .2s, background .2s; z-index: 4;
}
.project__frame:hover .carousel__btn { opacity: 1; }
.carousel__btn:hover { background: rgba(10,10,20,.8); }
.carousel__btn--prev { left: 12px; }
.carousel__btn--next { right: 12px; }
.carousel__dots {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 7px; z-index: 4;
}
.carousel__dot {
  width: 6px; height: 6px; border-radius: 50%; padding: 0; border: none; cursor: pointer;
  background: rgba(255,255,255,.45); transition: background .2s, transform .2s;
}
.carousel__dot.on { background: #fff; transform: scale(1.4); }

.project__badge {
  position: absolute; top: 18px; left: 18px; z-index: 2;
  background: rgba(255,255,255,.85); backdrop-filter: blur(8px);
  padding: 7px 14px; border-radius: 100px; font-size: 12px; font-weight: 600;
  letter-spacing: 0.04em; border: 1px solid var(--line); color: var(--ink-soft);
}
.project__badge--own { background: var(--ink); color: #fff; border-color: var(--ink); }

.project__num {
  font-family: "JetBrains Mono", monospace; color: var(--accent);
  font-size: 14px; letter-spacing: 0.1em; margin-bottom: 18px;
}
.project__title {
  font-family: "Space Grotesk", sans-serif; font-weight: 600;
  font-size: clamp(32px, 4.5vw, 56px); letter-spacing: -0.03em; line-height: 1;
}
.project__title-sub { color: var(--ink-faint); font-weight: 500; font-size: 0.5em; letter-spacing: 0; }
.project__tag { color: var(--accent); font-weight: 500; margin: 16px 0 20px; font-size: 17px; }
.project__desc { color: var(--ink-soft); margin-bottom: 26px; max-width: 520px; }

.project__highlights { list-style: none; margin-bottom: 28px; display: grid; gap: 12px; }
.project__highlights li {
  position: relative; padding-left: 24px; color: var(--ink-soft); font-size: 15px;
}
.project__highlights li::before {
  content: "→"; position: absolute; left: 0; color: var(--accent); font-weight: 700;
}
.project__highlights strong { color: var(--ink); font-weight: 600; }

.project__stack { display: flex; flex-wrap: wrap; gap: 8px; }
.project__stack span {
  font-family: "JetBrains Mono", monospace; font-size: 12.5px;
  padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg-soft); color: var(--ink-soft);
}

@media (max-width: 880px) {
  .project { grid-template-columns: 1fr; gap: 36px; margin-bottom: 110px; }
  .project:nth-child(even) .project__media { order: 0; }
}

/* ---------- ABOUT ---------- */
.about { padding-top: 100px; padding-bottom: 120px; border-top: 1px solid var(--line); }
.about__grid {
  max-width: var(--maxw); margin: 50px auto 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: clamp(40px, 6vw, 90px);
}
.about__lead p {
  font-family: "Space Grotesk", sans-serif; font-weight: 500;
  font-size: clamp(24px, 3vw, 38px); line-height: 1.25; letter-spacing: -0.02em;
}
.about__lead strong { color: var(--accent); }
.about__body p { color: var(--ink-soft); margin-bottom: 22px; }
.about__body strong { color: var(--ink); font-weight: 600; }
@media (max-width: 820px) { .about__grid { grid-template-columns: 1fr; } }

/* ---------- STACK MARQUEE ---------- */
.stack { padding-top: 90px; padding-bottom: 90px; }
.marquee { overflow: hidden; margin-top: 40px; border-block: 1px solid var(--line); padding: 28px 0; }
.marquee__track {
  display: flex; gap: 30px; white-space: nowrap; width: max-content;
  font-family: "Space Grotesk", sans-serif; font-weight: 600;
  font-size: clamp(28px, 4vw, 52px); letter-spacing: -0.02em; color: var(--ink);
  animation: marquee 32s linear infinite;
}
.marquee__track span:nth-child(even) { color: var(--accent); }
@keyframes marquee { to { transform: translateX(-50%); } }

/* ---------- CONTACT ---------- */
.contact {
  min-height: 90vh; display: flex; flex-direction: column; justify-content: center;
  border-top: 1px solid var(--line); padding-top: 100px; padding-bottom: 40px;
  background: var(--ink); color: #fff;
}
.contact .section-head__index { color: #ff9e7a; }
.contact__inner { max-width: var(--maxw); margin: 0 auto; width: 100%; flex: 1; display: flex; flex-direction: column; justify-content: center; }
.contact__title {
  font-family: "Space Grotesk", sans-serif; font-weight: 600;
  font-size: clamp(44px, 9vw, 130px); line-height: 0.95; letter-spacing: -0.04em;
  margin: 24px 0 50px;
}
.contact__title .line { display: block; overflow: hidden; }
.contact__title .word { display: inline-block; }
.contact .word.accent { color: #ff9e7a; }
.contact__email {
  font-size: clamp(22px, 3.4vw, 44px); font-weight: 500;
  border-bottom: 2px solid rgba(255,255,255,.25); padding-bottom: 6px;
  transition: border-color .3s, color .3s; align-self: flex-start;
}
.contact__email:hover { border-color: #ff9e7a; color: #ff9e7a; }
.contact__links { display: flex; gap: 32px; margin-top: 48px; flex-wrap: wrap; }
.contact__links a {
  font-family: "JetBrains Mono", monospace; font-size: 15px; color: #c9c9c9;
  transition: color .3s; position: relative;
}
.contact__links a:hover { color: #fff; }
.contact__wechat {
  font-family: "JetBrains Mono", monospace; font-size: 15px; color: #c9c9c9;
  cursor: default; user-select: all;
}

.footer {
  max-width: var(--maxw); margin: 60px auto 0; width: 100%;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px;
  font-family: "JetBrains Mono", monospace; font-size: 13px; color: #888;
  padding-top: 28px; border-top: 1px solid rgba(255,255,255,.12);
}

/* ---------- Reveal init states (set by JS too) ---------- */
.reveal-line { will-change: transform, opacity; }

/* ============================================================
   COLOR ENRICHMENTS — warm identity over the live noise backdrop
   ============================================================ */

/* sections stay transparent so the warm noise shows through */
.stats, .work, .about, .stack { background: transparent; }
.hero__inner, .hero__scroll { z-index: 2; }

/* warm gradient on the italic accent word */
.hero .word.accent {
  background: linear-gradient(120deg, var(--c-coral), var(--c-amber) 55%, var(--c-rose));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/* ----- Per-project color identity (all warm) ----- */
.project { --c: var(--accent); }
.project:nth-of-type(1) { --c: var(--c-coral); }
.project:nth-of-type(2) { --c: var(--c-rose); }
.project:nth-of-type(3) { --c: var(--c-amber); }
.project:nth-of-type(4) { --c: var(--c-orange); }
.project:nth-of-type(5) { --c: var(--c-berry); }

.project__num { color: var(--c); }
.project__tag { color: var(--c); }
.project__highlights li::before { color: var(--c); }
.project__frame {
  background: #fff;
  box-shadow: 0 40px 80px -38px color-mix(in srgb, var(--c) 40%, transparent);
}
.project__media:hover .project__frame { border-color: color-mix(in srgb, var(--c) 45%, var(--line)); }
.project__badge--own { background: var(--c); border-color: var(--c); }
.project__stack span { transition: border-color .25s, color .25s, background .25s; }
.project__stack span:hover { border-color: var(--c); color: var(--c); background: #fff; }

/* ----- Stats: warm gradient-filled numbers ----- */
.stat__num {
  -webkit-background-clip: text; background-clip: text; color: transparent;
  background-image: linear-gradient(135deg, var(--c-coral), var(--c-amber));
}
.stat:nth-child(2) .stat__num { background-image: linear-gradient(135deg, var(--c-rose), var(--c-coral)); }
.stat:nth-child(3) .stat__num { background-image: linear-gradient(135deg, var(--c-amber), var(--c-orange)); }
.stat:nth-child(4) .stat__num { background-image: linear-gradient(135deg, var(--c-berry), var(--c-rose)); }

/* ----- Section index labels: varied warm hues ----- */
.work .section-head__index  { color: var(--c-coral); }
.about .section-head__index { color: var(--c-rose); }
.stack .section-head__index { color: var(--c-amber); }

/* ----- Marquee: cycle warm palette across tech words, fade the dots ----- */
.marquee__track span:nth-child(even) { color: var(--ink-faint); opacity: .5; }
.marquee__track span:nth-child(8n+1) { color: var(--c-coral); }
.marquee__track span:nth-child(8n+3) { color: var(--c-rose); }
.marquee__track span:nth-child(8n+5) { color: var(--c-amber); }
.marquee__track span:nth-child(8n+7) { color: var(--c-orange); }

/* ----- Buttons: warm accent on the ghost variant ----- */
.btn--ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ----- Contact: warm glow behind the dark panel ----- */
.contact { position: relative; overflow: hidden; }
.contact::before {
  content: ""; position: absolute; z-index: 0; top: -18%; left: 28%;
  width: 52vw; height: 52vw; border-radius: 50%; filter: blur(110px); opacity: .5;
  background: radial-gradient(circle, rgba(239,90,42,.5), rgba(232,74,138,.3) 50%, transparent 72%);
  pointer-events: none;
}
.contact__inner, .contact .footer { position: relative; z-index: 1; }

/* ============================================================
   RESPONSIVE — touch & mobile refinements
   ============================================================ */

/* Touch devices have no hover: surface carousel arrows permanently. */
@media (hover: none) {
  .carousel__btn {
    opacity: 1; background: rgba(10, 10, 20, .42);
    width: 38px; height: 38px; font-size: 23px;
  }
}

/* Tablet / large phone: trim oversized vertical rhythm. */
@media (max-width: 768px) {
  .hero__scroll { display: none; }
  .stats { padding-top: 64px; padding-bottom: 64px; }
  .work { padding-top: 90px; }
  .work .section-head { margin-bottom: 56px; }
  .about { padding-top: 80px; padding-bottom: 90px; }
  .stack { padding-top: 64px; padding-bottom: 64px; }
}

/* Phone */
@media (max-width: 560px) {
  body { font-size: 16px; }

  .nav { padding-top: 16px; padding-bottom: 16px; }
  .nav__links { gap: 14px; }
  .nav__cta { padding: 7px 14px; }
  .lang-toggle { min-width: 42px; height: 30px; }

  .hero {
    min-height: auto;
    padding-top: 96px; padding-bottom: 48px;
  }
  .hero__inner { gap: 40px; }
  .hero__meta { flex-wrap: wrap; gap: 8px 12px; margin-bottom: 22px; }
  .hero__title { margin-bottom: 26px; }
  .hero__lead { margin-bottom: 30px; }
  .hero__actions { gap: 12px; }
  .hero__actions .btn { flex: 1 1 auto; justify-content: center; padding: 15px 22px; }
  .hero__showcase { max-width: 100%; }
  .showcase__dots { justify-content: center; }

  .stats { padding-top: 52px; padding-bottom: 52px; }
  .stats__grid { gap: 28px 24px; }
  .stat__label { font-size: 14px; }

  .work { padding-top: 68px; }
  .work .section-head { margin-bottom: 44px; }
  .project { gap: 26px; margin-bottom: 80px; }
  .project__tag { font-size: 16px; margin: 12px 0 16px; }
  .project__desc { font-size: 15.5px; margin-bottom: 22px; }

  .about { padding-top: 60px; padding-bottom: 72px; }
  .about__grid { margin-top: 32px; gap: 32px; }

  .stack { padding-top: 50px; padding-bottom: 50px; }
  .marquee { margin-top: 28px; padding: 20px 0; }

  .contact { min-height: auto; padding-top: 76px; padding-bottom: 36px; }
  .contact__title { margin: 18px 0 36px; }
  .contact__email { align-self: stretch; word-break: break-all; }
  .contact__links { gap: 18px 24px; margin-top: 34px; }
  .footer { flex-direction: column; align-items: flex-start; gap: 8px; }
}
