/* ==========================================================
   Zilu Yi — personal site
   Plain CSS, no build step. Light + dark themes via tokens.
   ========================================================== */

:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #efece4;
  --text: #1d2321;
  --muted: #5c6662;
  --line: #ddd8cc;
  --accent: #2f6f5e;        /* forest / topo green */
  --accent-2: #b5643c;      /* terracotta, used sparingly */
  --accent-soft: #e2eee9;
  --contour: rgba(47, 111, 94, 0.16);
  --shadow: 0 1px 2px rgba(20, 30, 25, .04), 0 8px 24px rgba(20, 30, 25, .06);

  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;

  --wrap: 1040px;
  --radius: 14px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121615;
    --surface: #1a201e;
    --surface-2: #222a27;
    --text: #e8ece9;
    --muted: #9aa6a1;
    --line: #2e3734;
    --accent: #7cc4ad;
    --accent-2: #e09a74;
    --accent-soft: #1f3530;
    --contour: rgba(124, 196, 173, 0.14);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121615;
  --surface: #1a201e;
  --surface-2: #222a27;
  --text: #e8ece9;
  --muted: #9aa6a1;
  --line: #2e3734;
  --accent: #7cc4ad;
  --accent-2: #e09a74;
  --accent-soft: #1f3530;
  --contour: rgba(124, 196, 173, 0.14);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

img, svg { max-width: 100%; display: block; }

a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }

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

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(2.3rem, 6vw, 3.6rem); }
h2 { font-size: clamp(1.55rem, 3.4vw, 2rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1em; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
@media (max-width: 600px) { .wrap { padding: 0 16px; } }

.skip-link {
  position: absolute; left: -9999px; top: 8px;
  background: var(--accent); color: var(--bg); padding: 8px 14px; border-radius: 8px; z-index: 100;
}
.skip-link:focus { left: 8px; }

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 64px; }
.brand {
  font-family: var(--serif); font-weight: 600; font-size: 1.2rem; color: var(--text); text-decoration: none;
  display: inline-flex; align-items: center; gap: 10px; white-space: nowrap;
}
.brand-mark {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: var(--bg);
  display: grid; place-items: center; font-size: .85rem; font-family: var(--sans); font-weight: 700;
}
.nav-links { display: flex; align-items: center; gap: 4px; list-style: none; margin: 0; padding: 0; }
.nav-links a {
  display: block; padding: 6px 12px; border-radius: 999px;
  color: var(--muted); text-decoration: none; font-size: .95rem; font-weight: 500;
}
.nav-links a:hover { color: var(--text); background: var(--surface-2); }
.nav-links a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

.theme-toggle {
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  width: 36px; height: 36px; border-radius: 50%; cursor: pointer; display: grid; place-items: center;
  margin-left: 6px;
}
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

@media (max-width: 560px) {
  .brand-name { display: none; }
  .nav-links a { padding: 6px 9px; font-size: .9rem; }
}

/* ---------- Hero ---------- */
.hero { position: relative; padding: 88px 0 72px; overflow: hidden; border-bottom: 1px solid var(--line); }
.hero .contours {
  position: absolute; right: -120px; top: -60px; width: 720px; height: 560px;
  color: var(--contour); pointer-events: none;
}
@media (max-width: 760px) { .hero .contours { right: -260px; opacity: .7; } .hero { padding: 56px 0 48px; } }
.hero-inner { position: relative; }
.eyebrow {
  font-family: var(--mono); font-size: .8rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 14px; display: block;
}
.hero h1 { max-width: 16ch; }
.hero h1 em { font-style: italic; color: var(--accent); font-weight: 500; }
.lede { font-size: 1.18rem; color: var(--muted); max-width: 58ch; margin: 22px 0 30px; }
.coords { font-family: var(--mono); font-size: .8rem; color: var(--muted); margin-top: 28px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px; border-radius: 999px; font-weight: 600; font-size: .95rem;
  text-decoration: none; border: 1px solid transparent; transition: transform .15s ease, background .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--accent); color: var(--bg); }
.btn-ghost { border-color: var(--line); color: var(--text); background: var(--surface); }
.btn-ghost:hover { border-color: var(--accent); }

/* ---------- Sections ---------- */
.section { padding: 72px 0; }
.section + .section { border-top: 1px solid var(--line); }
@media (max-width: 600px) { .section { padding: 52px 0; } }
.section-head { margin-bottom: 32px; }
.section-head p { color: var(--muted); margin: 10px 0 0; max-width: 60ch; }

.grid-2 { display: grid; grid-template-columns: 1.1fr .9fr; gap: 48px; align-items: start; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; gap: 32px; } }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px; box-shadow: var(--shadow);
}

.facts { list-style: none; margin: 0; padding: 0; }
.facts li { display: grid; grid-template-columns: 110px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.facts li:last-child { border-bottom: 0; }
.facts .k { font-family: var(--mono); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding-top: 3px; }
@media (max-width: 420px) { .facts li { grid-template-columns: 1fr; gap: 2px; } }

.interest-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 820px) { .interest-grid { grid-template-columns: 1fr; } }
.interest .icon {
  width: 42px; height: 42px; border-radius: 10px; background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; margin-bottom: 16px;
}
.interest .icon svg { width: 22px; height: 22px; }
.interest h3 { margin-bottom: 8px; }
.interest p { color: var(--muted); margin: 0; font-size: .97rem; }

.tags { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; }
.tags li {
  font-size: .82rem; padding: 4px 11px; border-radius: 999px;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--line);
}

.goal { border-left: 3px solid var(--accent); padding: 4px 0 4px 22px; }
.goal p:last-child { margin-bottom: 0; }

.cta-band {
  background: var(--accent-soft); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 32px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 20px;
}
.cta-band h2 { font-size: 1.5rem; }
.cta-band p { margin: 6px 0 0; color: var(--muted); }

/* ---------- Resume page ---------- */
.page-head { padding: 64px 0 36px; border-bottom: 1px solid var(--line); }
.page-head p { color: var(--muted); margin: 12px 0 0; max-width: 60ch; }
.page-head .btn-row { margin-top: 24px; }

.resume { display: grid; grid-template-columns: 220px 1fr; gap: 48px; padding-top: 56px; padding-bottom: 80px; }
@media (max-width: 820px) { .resume { grid-template-columns: 1fr; gap: 24px; padding-top: 36px; } }
.resume-aside { position: sticky; top: 96px; align-self: start; }
@media (max-width: 820px) { .resume-aside { position: static; } }
.toc { list-style: none; padding: 0; margin: 0; border-left: 1px solid var(--line); }
.toc a { display: block; padding: 6px 16px; color: var(--muted); text-decoration: none; font-size: .95rem; margin-left: -1px; border-left: 2px solid transparent; }
.toc a:hover { color: var(--accent); border-left-color: var(--accent); }
@media (max-width: 820px) {
  .toc { display: flex; flex-wrap: wrap; gap: 6px; border: 0; }
  .toc a { border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; margin: 0; font-size: .88rem; }
}
.contact-mini { margin-top: 28px; font-size: .92rem; color: var(--muted); }
.contact-mini a { display: block; margin-bottom: 4px; word-break: break-word; }
@media (max-width: 820px) { .contact-mini { display: none; } }

.r-section { margin-bottom: 52px; scroll-margin-top: 90px; }
.r-section:last-child { margin-bottom: 0; }
.r-section > h2 {
  font-size: 1.05rem; font-family: var(--mono); font-weight: 500; text-transform: uppercase; letter-spacing: .1em;
  color: var(--accent); padding-bottom: 10px; border-bottom: 1px solid var(--line); margin-bottom: 24px;
}
.entry { margin-bottom: 30px; }
.entry:last-child { margin-bottom: 0; }
.entry-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px 16px; flex-wrap: wrap; }
.entry h3 { font-family: var(--sans); font-size: 1.08rem; font-weight: 650; }
.entry .when { font-family: var(--mono); font-size: .82rem; color: var(--muted); white-space: nowrap; }
.entry .sub { color: var(--muted); font-style: italic; margin: 2px 0 10px; }
.entry ul { margin: 8px 0 0; padding-left: 1.15em; }
.entry li { margin-bottom: 6px; }
.entry li::marker { color: var(--accent); }
.course-list { margin: 10px 0 0; }
.course-list div { margin-bottom: 6px; }
.course-list b { font-weight: 600; }

.skill-rows { display: grid; gap: 18px; }
.skill-row { display: grid; grid-template-columns: 130px 1fr; gap: 12px; align-items: start; }
.skill-row .k { font-weight: 600; padding-top: 3px; }
@media (max-width: 520px) { .skill-row { grid-template-columns: 1fr; gap: 8px; } }

/* ---------- Projects page ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.filter {
  font: inherit; font-size: .9rem; padding: 6px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
}
.filter:hover { color: var(--text); border-color: var(--accent); }
.filter[aria-pressed="true"] { background: var(--accent); color: var(--bg); border-color: var(--accent); }

.projects { display: grid; gap: 28px; padding-top: 48px; padding-bottom: 80px; }
.project {
  display: grid; grid-template-columns: 260px 1fr; gap: 0; overflow: hidden; padding: 0;
}
.project[hidden] { display: none; }
@media (max-width: 820px) { .project { grid-template-columns: 1fr; } }
.project-visual {
  background: var(--surface-2); border-right: 1px solid var(--line);
  display: grid; place-items: center; padding: 24px; min-height: 200px; color: var(--accent);
}
@media (max-width: 820px) { .project-visual { border-right: 0; border-bottom: 1px solid var(--line); min-height: 160px; } }
.project-visual svg { width: 100%; max-width: 210px; height: auto; }
.project-body { padding: 28px 30px 30px; }
@media (max-width: 600px) { .project-body { padding: 22px 18px 24px; } }
.project-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font-family: var(--mono); font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }
.project h2 { font-size: 1.5rem; margin-bottom: 12px; }
.project .summary { color: var(--muted); }
.project h3 { font-family: var(--sans); font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text); margin: 18px 0 8px; font-weight: 700; }
.project ul.points { margin: 0; padding-left: 1.15em; }
.project ul.points li { margin-bottom: 6px; }
.project ul.points li::marker { color: var(--accent); }

.stats { display: flex; flex-wrap: wrap; gap: 12px; margin: 18px 0 4px; }
.stat { background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; min-width: 110px; }
.stat b { display: block; font-family: var(--serif); font-size: 1.35rem; color: var(--accent); line-height: 1.1; }
.stat span { font-size: .8rem; color: var(--muted); }
.project .tags { margin-top: 18px; }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 36px 0 44px; color: var(--muted); font-size: .92rem; }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; }
.social { display: flex; gap: 10px; list-style: none; margin: 0; padding: 0; }
.social a {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--line); color: var(--text); background: var(--surface);
}
.social a:hover { color: var(--accent); border-color: var(--accent); }
.social svg { width: 18px; height: 18px; }

/* ---------- Print (resume prints cleanly) ---------- */
@media print {
  .site-header, .site-footer, .page-head .btn-row, .resume-aside, .theme-toggle { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .resume { grid-template-columns: 1fr; padding-top: 0; padding-bottom: 0; }
  .page-head { padding: 0 0 12px; }
  a { color: #000; text-decoration: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
