/* =========================================================
   Xiaoyu Yang — personal site
   Style: warm, minimal, typographic (Claude / OpenAI vibe)
   ========================================================= */

:root {
  /* Colors — light (default) */
  --bg: #faf9f6;
  --bg-elevated: #f5f3ee;
  --text: #1a1a1a;
  --text-muted: #6b6b68;
  --text-subtle: #8a8a86;
  --border: #e7e4dc;
  --border-strong: #d9d5cb;
  --accent: #c2410c; /* warm burnt orange */
  --accent-hover: #9a3412;
  --link: #1a1a1a;
  --link-underline: #c9c5b8;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);

  /* Typography */
  --font-display: "Instrument Serif", "Times New Roman", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Layout */
  --content-max: 720px;
  --content-pad: 1.5rem;
  --nav-height: 60px;
  --radius: 8px;
}

:root[data-theme="dark"] {
  --bg: #0f0f0e;
  --bg-elevated: #1a1a18;
  --text: #f3f1ea;
  --text-muted: #a8a69c;
  --text-subtle: #7a7870;
  --border: #27261f;
  --border-strong: #35342c;
  --accent: #fb923c;
  --accent-hover: #fdba74;
  --link: #f3f1ea;
  --link-underline: #3a3830;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Respect OS preference when the user hasn't explicitly set a theme */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0f0f0e;
    --bg-elevated: #1a1a18;
    --text: #f3f1ea;
    --text-muted: #a8a69c;
    --text-subtle: #7a7870;
    --border: #27261f;
    --border-strong: #35342c;
    --accent: #fb923c;
    --accent-hover: #fdba74;
    --link: #f3f1ea;
    --link-underline: #3a3830;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  }
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-height) + 16px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.25s ease, color 0.25s ease;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

a {
  color: var(--link);
  text-decoration: none;
  border-bottom: 1px solid var(--link-underline);
  transition: border-color 0.15s ease, color 0.15s ease;
}

a:hover {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

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

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

/* ---------- Navigation ---------- */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-height);
  background-color: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: var(--content-max);
  height: 100%;
  margin: 0 auto;
  padding: 0 var(--content-pad);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.nav-brand {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-style: italic;
  border: none;
  letter-spacing: 0.01em;
}

.nav-brand:hover {
  color: var(--accent);
}

.theme-toggle {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  color: var(--text-muted);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.theme-toggle:hover {
  background-color: var(--bg-elevated);
  color: var(--text);
}

.theme-toggle .icon-moon {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-toggle .icon-sun {
    display: none;
  }
  :root:not([data-theme]) .theme-toggle .icon-moon {
    display: block;
  }
}

/* ---------- Main container ---------- */
main {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 3.5rem var(--content-pad) 4rem;
}

/* ---------- Hero ---------- */
.hero {
  margin-bottom: 4rem;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2.5rem;
  align-items: center;
}

.display {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(3rem, 7vw, 4.75rem);
  line-height: 1.02;
  letter-spacing: -0.01em;
  margin: 0 0 0.5rem;
}

.subtitle {
  margin: 0 0 1.25rem;
  font-size: 0.975rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.subtitle .role {
  color: var(--text);
  font-weight: 500;
}

.subtitle .dot {
  color: var(--text-subtle);
}

.contact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.5rem;
}

.contact-row li a {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  background-color: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: all 0.15s ease;
}

.contact-row li a:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background-color: var(--bg);
  transform: translateY(-1px);
}

.contact-row svg {
  flex-shrink: 0;
  opacity: 0.8;
}

.hero-photo {
  width: 156px;
  height: 156px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow:
    0 1px 2px rgba(24, 20, 14, 0.06),
    0 8px 24px -8px rgba(24, 20, 14, 0.12);
  flex-shrink: 0;
  transition: transform 0.35s ease, box-shadow 0.35s ease;
}

.hero-photo:hover {
  transform: translateY(-2px);
  box-shadow:
    0 1px 2px rgba(24, 20, 14, 0.06),
    0 14px 32px -10px rgba(24, 20, 14, 0.18);
}

.hero-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

:root[data-theme="dark"] .hero-photo {
  border-color: var(--border-strong);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.4),
    0 10px 28px -10px rgba(0, 0, 0, 0.6);
}

:root[data-theme="dark"] .hero-photo:hover {
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.4),
    0 16px 36px -12px rgba(0, 0, 0, 0.7);
}

/* ---------- Section base ---------- */
.section {
  padding-top: 4rem;
  padding-bottom: 0.5rem;
  border-top: 1px solid var(--border);
  scroll-margin-top: calc(var(--nav-height) + 1rem);
}

.section-title {
  font-family: var(--font-display);
  font-size: clamp(1.875rem, 4vw, 2.375rem);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.015em;
  color: var(--text);
  margin: 0 0 2rem;
}

/* ---------- Prose (About) ---------- */
.prose p {
  margin: 0 0 1rem;
  font-size: 1.0625rem;
  line-height: 1.7;
  color: var(--text);
}

.prose p:last-child {
  margin-bottom: 0;
}

.prose a {
  border-bottom-color: var(--border-strong);
}

/* ---------- Experience timeline ---------- */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 2.25rem;
}

.timeline-item {
  /* stacked layout — no column grid */
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

.timeline-role {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.005em;
}

.timeline-date {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-subtle);
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.01em;
}

.timeline-org {
  margin-top: 0.2rem;
  font-size: 0.9375rem;
  color: var(--text-muted);
}

.timeline-desc {
  margin: 0.65rem 0 0;
  font-size: 0.9375rem;
  color: var(--text);
  line-height: 1.65;
}

.timeline-highlights {
  margin-top: 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.timeline-highlights li {
  position: relative;
  padding-left: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.55;
}

.timeline-highlights li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.6em;
  width: 4px;
  height: 4px;
  background-color: var(--text-subtle);
  border-radius: 50%;
}

.timeline-highlights strong {
  color: var(--text);
  font-weight: 600;
}

/* ---------- Publications ---------- */

/* Sort tabs (segmented control) */
.pub-sort {
  display: inline-flex;
  gap: 0;
  margin-bottom: 2rem;
  padding: 3px;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.pub-sort-btn {
  padding: 0.4rem 0.95rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 999px;
  transition: all 0.15s ease;
}

.pub-sort-btn:hover {
  color: var(--text);
}

.pub-sort-btn.active {
  color: var(--text);
  background-color: var(--bg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

:root[data-theme="dark"] .pub-sort-btn.active {
  background-color: var(--border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Pub groups (year or topic) */
.pub-list {
  display: flex;
  flex-direction: column;
  gap: 2.25rem;
}

.pub-group-title {
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px dashed var(--border);
  letter-spacing: 0.01em;
}

.pub-items {
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

.pub {
  /* reset list style */
}

.pub-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

.pub-tag {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--accent);
  background-color: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 999px;
  vertical-align: middle;
  letter-spacing: 0.01em;
}

.pub-authors {
  margin-top: 0.3rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.pub-authors .me {
  color: var(--text);
  font-weight: 500;
}

.pub-venue {
  margin-top: 0.3rem;
  font-size: 0.8125rem;
  color: var(--text-subtle);
  font-style: italic;
}

.pub-venue a {
  font-style: normal;
  color: var(--text-muted);
  border-bottom-color: var(--border);
}

.pub-venue a:hover {
  color: var(--accent);
}

.see-more {
  margin-top: 2rem;
  font-size: 0.875rem;
  color: var(--text-subtle);
}

/* ---------- Education ---------- */
.edu-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.edu-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

.edu-degree {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.edu-date {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-subtle);
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.01em;
}

.edu-school {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.edu-detail {
  font-size: 0.8125rem;
  color: var(--text-subtle);
  margin-top: 0.3rem;
  font-style: italic;
}

.edu-detail a {
  font-style: normal;
}

/* ---------- Honors ---------- */
.honors-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.honor {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1.5rem;
  padding: 0.7rem 0;
  font-size: 0.9375rem;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.honor:first-child {
  border-top: 1px solid var(--border);
}

.honor-text {
  flex: 1;
}

.honor-text a {
  color: var(--text-muted);
  border-bottom-color: var(--border);
}

.honor-date {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-subtle);
  white-space: nowrap;
  flex-shrink: 0;
  letter-spacing: 0.01em;
}

/* ---------- TOC sidebar (desktop only) ---------- */
.toc {
  display: none;
}

@media (min-width: 1180px) {
  .toc {
    display: block;
    position: fixed;
    top: calc(var(--nav-height) + 7rem);
    left: calc(50% + (var(--content-max) / 2) + 2.5rem);
    width: 180px;
    font-size: 0.8125rem;
    z-index: 20;
  }

  .toc-label {
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-subtle);
    margin-bottom: 0.9rem;
    padding-left: 1rem;
  }

  .toc nav ul {
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
  }

  .toc nav a {
    display: block;
    padding: 0.4rem 1rem;
    color: var(--text-muted);
    border: none;
    border-left: 2px solid transparent;
    margin-left: -1px;
    font-weight: 500;
    transition: color 0.15s ease, border-left-color 0.15s ease;
  }

  .toc nav a:hover {
    color: var(--text);
  }

  .toc nav a.active {
    color: var(--text);
    border-left-color: var(--accent);
  }
}

/* ---------- Visitor Map ---------- */
.visitor-map summary {
  display: inline;
  font-size: 0.8125rem;
  color: var(--text-subtle);
  cursor: pointer;
  list-style: none;
  transition: color 0.15s ease;
}

.visitor-map summary::-webkit-details-marker {
  display: none;
}

.visitor-map summary:hover {
  color: var(--text-muted);
}

.visitor-map-content {
  margin-top: 1.25rem;
  display: flex;
  justify-content: center;
  padding: 1rem;
  background-color: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--text-subtle);
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  main {
    padding-top: 2.25rem;
  }

  .hero-grid {
    grid-template-columns: 1fr;
    gap: 1.75rem;
  }

  .hero-photo {
    width: 104px;
    height: 104px;
    border-radius: 12px;
    order: -1;
  }

  .hero {
    margin-bottom: 3rem;
  }

  .display {
    font-size: 3rem;
  }

  .honor {
    flex-direction: column;
    gap: 0.15rem;
    align-items: flex-start;
  }
}

/* ---------- Selection ---------- */
::selection {
  background-color: color-mix(in srgb, var(--accent) 25%, transparent);
  color: var(--text);
}
