/* ==========================================================================
   Shan Tang — personal site
   Hand-written. No framework, no build step.
   ========================================================================== */

/* ---------- tokens ---------- */
:root {
  --bg:            #faf8f5;
  --surface:       #ffffff;
  --surface-2:     #f2ede5;
  --text:          #17212b;
  --muted:         #5d6b78;
  --subtle:        #8a94a0;
  --border:        #e7e1d7;
  --border-strong: #d5ccbe;
  --accent:        #12314f;
  --accent-soft:   #e8eef4;
  --on-accent:     #ffffff;
  --gold:          #b0762a;

  --shadow-sm: 0 1px 2px rgba(23, 33, 43, .05);
  --shadow-md: 0 6px 18px rgba(23, 33, 43, .07), 0 2px 4px rgba(23, 33, 43, .04);
  --shadow-lg: 0 18px 48px rgba(23, 33, 43, .12);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-xl: 26px;

  --container: 1120px;
  --nav-h: 64px;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
          Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

[data-theme="dark"] {
  --bg:            #121110;
  --surface:       #1a1816;
  --surface-2:     #24211d;
  --text:          #f3efe8;
  --muted:         #a9a299;
  --subtle:        #7d766d;
  --border:        #2e2a24;
  --border-strong: #423b33;
  --accent:        #9dc3e2;
  --accent-soft:   #1c2a36;
  --on-accent:     #0d1a24;
  --gold:          #e0a64c;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, .45);
  --shadow-lg: 0 18px 48px rgba(0, 0, 0, .6);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html { scroll-behavior: smooth; scroll-padding-top: 96px; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background-color .2s ease, color .2s ease;
}

img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; padding: 0; }
button { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: 24px;
}

/* ---------- type ---------- */
.eyebrow {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--gold);
}

.h2 {
  font-size: clamp(1.7rem, 1.2rem + 1.8vw, 2.6rem);
  line-height: 1.12;
  letter-spacing: -.022em;
  font-weight: 700;
  text-wrap: balance;
}

.lead {
  font-size: 1.075rem;
  line-height: 1.7;
  color: var(--muted);
  text-wrap: pretty;
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: .92rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, border-color .15s ease, box-shadow .15s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: none; }

.btn--primary {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-sm);
}
.btn--primary:hover { box-shadow: var(--shadow-md); }

.btn--secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn--secondary:hover { border-color: var(--accent); }

.btn--ghost { background: transparent; color: var(--text); }
.btn--ghost:hover { background: var(--surface-2); }

.btn--sm { padding: 8px 13px; font-size: .84rem; border-radius: 8px; }

/* ---------- chips ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chips li {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: .82rem;
  font-weight: 500;
  color: var(--muted);
}
.chips--static li { color: var(--text); }

/* ---------- progress bar ---------- */
.progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--gold);
  transform: scaleX(0);
  transform-origin: 0 50%;
  z-index: 60;
  opacity: 0;
  transition: opacity .2s ease;
}
.progress.is-on { opacity: 1; }

/* ---------- nav ---------- */
.nav-wrap {
  position: fixed;
  top: 14px;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  justify-content: center;
  padding-inline: 20px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: opacity .25s ease, transform .25s ease, visibility .25s;
}
.nav-wrap.is-shown { opacity: 1; transform: none; pointer-events: auto; visibility: visible; }

.nav {
  pointer-events: auto;
  width: 100%;
  max-width: var(--container);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 10px 8px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  box-shadow: var(--shadow-sm);
}

.nav__brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  letter-spacing: -.01em;
  font-size: .95rem;
}
.nav__mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .02em;
}

.nav__links { display: flex; gap: 2px; }
.nav__links a {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: .87rem;
  font-weight: 500;
  color: var(--muted);
  transition: color .12s ease, background .12s ease;
}
.nav__links a:hover { color: var(--text); background: var(--surface-2); }
.nav__links a.is-active { color: var(--text); background: var(--surface-2); }

.nav__actions { display: flex; align-items: center; gap: 8px; }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  transition: color .12s ease, background .12s ease, border-color .12s ease;
}
.theme-toggle:hover { color: var(--text); background: var(--surface-2); }
.theme-toggle svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

@media (max-width: 900px) {
  .nav__links { display: none; }
}

/* ---------- hero ---------- */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding: 120px 0 80px;
  overflow: hidden;
}

.hero__wash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(58% 50% at 82% 12%, var(--accent-soft), transparent 72%),
    radial-gradient(45% 45% at 4% 88%, var(--accent-soft), transparent 70%);
}

.hero__grid {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, .75fr);
  gap: clamp(32px, 5vw, 72px);
  align-items: center;
}

.hero__title {
  font-size: clamp(2.6rem, 1.2rem + 5.4vw, 4.5rem);
  line-height: 1.02;
  letter-spacing: -.035em;
  font-weight: 750;
  margin: 14px 0 18px;
  text-wrap: balance;
}
.hero__title span { color: var(--muted); font-weight: 400; }

.hero__lead {
  font-size: clamp(1.02rem, .95rem + .35vw, 1.2rem);
  line-height: 1.65;
  color: var(--muted);
  max-width: 54ch;
  text-wrap: pretty;
}
.hero__lead strong { color: var(--text); font-weight: 650; }

.hero__cta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 30px 0 26px;
}

.hero__portrait {
  position: relative;
}
.hero__portrait img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  object-position: 50% 22%;
  border-radius: var(--r-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

@media (max-width: 860px) {
  .hero { min-height: auto; padding: 120px 0 64px; }
  .hero__grid { grid-template-columns: 1fr; }
  .hero__portrait { order: -1; max-width: 300px; }
  .hero__title { margin-top: 10px; }
}

/* ---------- sections ---------- */
.section { padding: clamp(64px, 9vw, 112px) 0; }
.section--sunken { background: var(--surface-2); }

.section__head { margin-bottom: clamp(32px, 4vw, 52px); }
.section__head .h2 { margin-top: 12px; max-width: 22ch; }

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  gap: clamp(28px, 5vw, 72px);
  align-items: start;
}
.grid-2 .h2 { margin-top: 12px; max-width: 16ch; }

.about__body p + p { margin-top: 16px; }
.about__body p { color: var(--muted); }
.about__body .lead { color: var(--text); }

@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* ---------- cards ---------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.card {
  padding: 26px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.card__date {
  font-family: var(--mono);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--subtle);
  margin-bottom: 8px;
}
.card__metric {
  font-family: var(--mono);
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--gold);
  margin: 0 0 10px;
}
.card__title {
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -.01em;
  margin-bottom: 4px;
}
.card p:last-child {
  font-size: .92rem;
  line-height: 1.6;
  color: var(--muted);
}

/* ---------- timeline ---------- */
.timeline { display: grid; gap: 40px; }

.tl-item {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: clamp(20px, 3vw, 48px);
}

.tl-period {
  font-family: var(--mono);
  font-size: .82rem;
  font-weight: 600;
  color: var(--text);
}
.tl-place { font-size: .82rem; color: var(--subtle); margin-top: 2px; }

.tl-body {
  padding-left: 26px;
  border-left: 1px solid var(--border-strong);
  position: relative;
}
.tl-body::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 8px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 4px var(--bg);
}
.section--sunken .tl-body::before { box-shadow: 0 0 0 4px var(--surface-2); }

.tl-role {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -.015em;
  margin-bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}
.tl-org {
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--gold);
}

.role + .role { margin-top: 22px; }

.role__title {
  font-size: .97rem;
  font-weight: 650;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}
.role__when {
  font-family: var(--mono);
  font-size: .76rem;
  font-weight: 500;
  color: var(--subtle);
}

.role__list { display: grid; gap: 7px; }
.role__list li {
  position: relative;
  padding-left: 16px;
  font-size: .94rem;
  line-height: 1.6;
  color: var(--muted);
}
.role__list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .68em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--border-strong);
}

@media (max-width: 760px) {
  .tl-item { grid-template-columns: 1fr; gap: 12px; }
  .tl-body { padding-left: 20px; }
}

/* ---------- skills ---------- */
.skills {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--border);
}
.skill-row {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 24px;
  align-items: center;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}
.skill-row h3 {
  font-size: .84rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--subtle);
}

@media (max-width: 700px) {
  .skill-row { grid-template-columns: 1fr; gap: 10px; }
}

/* ---------- education ---------- */
.edu { display: grid; gap: 0; border-top: 1px solid var(--border); }
.edu li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr) 80px;
  gap: 20px;
  align-items: baseline;
  padding: 18px 0;
  border-bottom: 1px solid var(--border);
}
.edu__school { font-weight: 650; letter-spacing: -.01em; }
.edu__degree { font-size: .92rem; color: var(--muted); }
.edu__year { font-family: var(--mono); font-size: .82rem; color: var(--subtle); text-align: right; }

@media (max-width: 700px) {
  .edu li { grid-template-columns: 1fr; gap: 4px; }
  .edu__year { text-align: left; }
}

/* ---------- contact ---------- */
.section--contact { border-top: 1px solid var(--border); }
.contact { max-width: 760px; }
.contact .h2 { margin: 12px 0 16px; }
.contact__lead { max-width: 52ch; }

.contact__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 28px 0 30px;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.links a {
  font-size: .9rem;
  font-weight: 550;
  color: var(--muted);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-underline-offset: 4px;
  transition: color .12s ease, text-decoration-color .12s ease;
}
.links a:hover { color: var(--text); text-decoration-color: var(--gold); }

/* ---------- footer ---------- */
.footer {
  padding: 26px 0 34px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.footer__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  justify-content: space-between;
  font-size: .82rem;
  color: var(--subtle);
}

/* ---------- reveal ---------- */
[data-reveal] {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity .6s cubic-bezier(.16, 1, .3, 1),
              transform .6s cubic-bezier(.16, 1, .3, 1);
  transition-delay: var(--d, 0ms);
}
[data-reveal="scale"] { transform: scale(.97); }
[data-reveal].is-in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  [data-reveal] { opacity: 1; transform: none; }
}

/* ---------- print ---------- */
@media print {
  .nav-wrap, .progress, .hero__portrait::after { display: none; }
  body { background: #fff; }
}
