/* ============================================================
   Ziyue Zhang — personal site
   Minimalist, neutral-purple. Vanilla CSS.
   ============================================================ */

:root {
  /* Neutral, muted purple palette — dusty, low-saturation */
  --bg:            #faf9fc;
  --bg-2:          #f3f1f7;
  --surface:       #ffffff;
  --text:          #211d2b;   /* near-black with a faint purple cast */
  --text-soft:     #4a4456;
  --muted:         #877f95;   /* secondary text */
  --border:        #e7e3ee;
  --accent:        #7a6a99;    /* muted dusty purple (was bright #934ec8) */
  --accent-deep:   #564a6e;
  --accent-soft:   #efeaf6;
  --accent-tint:   rgba(122, 106, 153, 0.10);

  --maxw: 1080px;
  --pad: clamp(1.25rem, 5vw, 4rem);

  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Newsreader", Georgia, "Times New Roman", serif;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --shadow: 0 1px 2px rgba(33, 29, 43, 0.04), 0 12px 32px rgba(33, 29, 43, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #14121a;
    --bg-2:        #1b1822;
    --surface:     #1c1926;
    --text:        #ece9f2;
    --text-soft:   #c3bcd0;
    --muted:       #8b8499;
    --border:      #2c2838;
    --accent:      #b3a3cf;
    --accent-deep: #cdc1e3;
    --accent-soft: #241f31;
    --accent-tint: rgba(179, 163, 207, 0.12);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 14px 40px rgba(0, 0, 0, 0.4);
  }
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 1.0625rem;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.02em; line-height: 1.1; }
strong { font-weight: 600; color: var(--text); }
em { font-style: italic; }

/* ---------- Preloader ---------- */
.preloader {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition: opacity 0.6s var(--ease), visibility 0.6s var(--ease);
}
.preloader.is-done { opacity: 0; visibility: hidden; }
.preloader__ring {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 190;
  stroke-dashoffset: 190;
  transform-origin: center;
  animation: ringSpin 1.4s linear infinite, ringDraw 1.4s var(--ease) infinite alternate;
}
.preloader__initials {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 600;
  fill: var(--accent-deep);
}
@keyframes ringSpin { to { transform: rotate(360deg); } }
@keyframes ringDraw {
  from { stroke-dashoffset: 190; }
  to   { stroke-dashoffset: 60; }
}

/* ---------- Scroll progress ---------- */
.scroll-progress {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-deep));
  z-index: 120;
  transition: width 0.1s linear;
}

/* ---------- Nav ---------- */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 110;
  transition: background 0.4s var(--ease), border-color 0.4s var(--ease), backdrop-filter 0.4s var(--ease);
  border-bottom: 1px solid transparent;
}
.nav.is-scrolled {
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom-color: var(--border);
}
.nav__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.1rem var(--pad);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
}
.nav__links { display: flex; gap: clamp(1rem, 3vw, 2.25rem); }
.nav__links a {
  position: relative;
  font-size: 0.9rem;
  color: var(--text-soft);
  transition: color 0.25s var(--ease);
}
.nav__links a::after {
  content: "";
  position: absolute;
  left: 0; bottom: -4px;
  width: 100%; height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s var(--ease);
}
.nav__links a:hover,
.nav__links a.is-active { color: var(--text); }
.nav__links a:hover::after,
.nav__links a.is-active::after { transform: scaleX(1); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.72rem 1.4rem;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.25s var(--ease), background 0.25s var(--ease),
              border-color 0.25s var(--ease), box-shadow 0.25s var(--ease), color 0.25s var(--ease);
}
.btn:hover { transform: translateY(-2px); }
.btn--primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 20px var(--accent-tint);
}
.btn--primary:hover { background: var(--accent-deep); box-shadow: 0 12px 26px var(--accent-tint); }
.btn--soft {
  background: var(--accent-soft);
  color: var(--accent-deep);
  border-color: color-mix(in srgb, var(--accent) 38%, transparent);
}
.btn--soft:hover {
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  border-color: var(--accent);
}
@media (prefers-color-scheme: dark) { .btn--primary { color: #14121a; } }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding: 7rem var(--pad) 5rem;
  overflow: hidden;
}
.hero__bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.hero__wash {
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg, #f5f2fa, #efe7f6, #f7f4fb);
  background-size: 240% 240%;
  animation: heroWash 20s ease infinite;
}
.hero__bloom {
  position: absolute;
  border-radius: 50%;
  filter: blur(64px);
}
.hero__bloom--1 {
  width: 60vw; height: 52vw;
  max-width: 820px; max-height: 700px;
  top: -16%; left: -12%;
  background: radial-gradient(circle, #c2b4e8 0%, rgba(194, 180, 232, 0) 68%);
  opacity: 0.6;
  animation: heroBloom1 19s ease-in-out infinite alternate;
}
.hero__bloom--2 {
  width: 54vw; height: 48vw;
  max-width: 720px; max-height: 620px;
  bottom: -18%; right: -12%;
  background: radial-gradient(circle, #d8cff0 0%, rgba(216, 207, 240, 0) 70%);
  opacity: 0.5;
  animation: heroBloom2 23s ease-in-out infinite alternate;
}
@keyframes heroWash {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes heroBloom1 { to { transform: translate(18%, 12%) scale(1.15); } }
@keyframes heroBloom2 { to { transform: translate(-16%, -10%) scale(1.2); } }

@media (prefers-color-scheme: dark) {
  .hero__wash {
    background: linear-gradient(115deg, #16131d, #1e1929, #161320);
    background-size: 240% 240%;
  }
  .hero__bloom--1 {
    background: radial-gradient(circle, #4a3f63 0%, rgba(74, 63, 99, 0) 68%);
    opacity: 0.5;
  }
  .hero__bloom--2 {
    background: radial-gradient(circle, #3a3350 0%, rgba(58, 51, 80, 0) 70%);
    opacity: 0.45;
  }
}
.hero__content {
  position: relative;
  z-index: 2;
  max-width: var(--maxw);
  margin: 0 auto;
  width: 100%;
}
.hero__eyebrow {
  font-size: 0.85rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-deep);
  margin: 0 0 1.4rem;
  font-weight: 600;
}
.hero__title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(2.6rem, 7vw, 5rem);
  letter-spacing: -0.025em;
  line-height: 1.04;
  margin: 0 0 1.6rem;
}
.hero__title-accent {
  font-style: italic;
  color: var(--accent);
}
.hero__lede {
  max-width: 46ch;
  font-size: clamp(1.05rem, 2vw, 1.25rem);
  color: var(--text-soft);
  margin: 0 0 2.4rem;
}
.hero__actions { display: flex; flex-wrap: wrap; gap: 0.9rem; }
.hero__scroll {
  position: absolute;
  left: 50%; bottom: 2.2rem;
  transform: translateX(-50%);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.hero__chev {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  animation: scrollChev 1.8s ease-in-out infinite;
}
.hero__chev--2 { animation-delay: 0.25s; }
@keyframes scrollChev {
  0% { opacity: 0.15; }
  30% { opacity: 1; }
  60%, 100% { opacity: 0.15; }
}

/* ---------- Sections ---------- */
.section {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(4rem, 10vw, 8rem) var(--pad);
}
.section__head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 3rem;
  padding-bottom: 1.2rem;
  border-bottom: 1px solid var(--border);
}
.section__title { font-size: clamp(1.6rem, 4vw, 2.2rem); }

/* ---------- About ---------- */
.about { max-width: 62ch; }
.about p { margin: 0 0 1.25rem; color: var(--text-soft); }
.about__lead {
  font-family: var(--font-serif);
  font-size: clamp(1.3rem, 3vw, 1.7rem);
  line-height: 1.4;
  color: var(--text) !important;
}
.about__footnote {
  margin: 2.6rem 0 0;
  font-size: 0.92rem;
  color: var(--muted);
  max-width: 62ch;
}
.about__footnote a {
  color: var(--accent);
  border-bottom: 1px solid var(--accent-soft);
  transition: border-color 0.25s var(--ease);
}
.about__footnote a:hover { border-bottom-color: var(--accent); }

/* ---------- Stat band ---------- */
.stats {
  margin: 3.4rem 0 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}
.stat {
  margin: 0;
  background: var(--surface);
  padding: 1.7rem 1.4rem;
  transition: background 0.3s var(--ease);
}
.stat:hover { background: var(--accent-soft); }
.stat__num {
  font-family: var(--font-serif);
  font-size: clamp(1.7rem, 3.4vw, 2.3rem);
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--accent);
  line-height: 1.05;
}
.stat__label {
  margin: 0.7rem 0 0;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--text-soft);
}
@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 420px) {
  .stats { grid-template-columns: 1fr; }
}

/* ---------- Contact ---------- */
.section--contact {
  text-align: center;
  max-width: 760px;
}
.contact__eyebrow {
  font-size: 0.85rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 1rem;
  font-weight: 600;
}
.contact__title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: clamp(1.9rem, 5vw, 3rem);
  margin: 0 0 1rem;
}
.contact__lede { color: var(--text-soft); margin: 0 0 2.2rem; }
.contact__links { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.9rem; }

/* ---------- Footer ---------- */
.footer {
  border-top: 1px solid var(--border);
  padding: 2rem var(--pad);
  text-align: center;
}
.footer p { margin: 0; font-size: 0.85rem; color: var(--muted); }

/* ---------- Reveal animation ---------- */
.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
  will-change: opacity, transform;
}
.reveal.is-visible { opacity: 1; transform: none; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}
