/* ====================================================================
 * Hangliang Ding — homepage stylesheet
 * Single source of truth. Link this from every page.
 * Palette: neutral grayscale (no chromatic accent).
 * Type:   EB Garamond (serif body+headings) + JetBrains Mono (labels).
 * ==================================================================== */

:root {
  --bg:          #fafaf9;
  --text:        #0a0a0a;
  --muted:       #737373;
  --rule:        #e5e5e4;
  --link:        #0a0a0a;
  --link-hover:  #404040;
  --avatar-bd:   #e5e5e4;

  --serif:       'EB Garamond', 'Source Serif Pro', Georgia, serif;
  --mono:        'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

[data-theme="dark"] {
  --bg:          #0a0a0a;
  --text:        #fafafa;
  --muted:       #a3a3a3;
  --rule:        #262626;
  --link:        #fafafa;
  --link-hover:  #d4d4d4;
  --avatar-bd:   #262626;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #0a0a0a;
    --text:        #fafafa;
    --muted:       #a3a3a3;
    --rule:        #262626;
    --link:        #fafafa;
    --link-hover:  #d4d4d4;
    --avatar-bd:   #262626;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 20px;
  line-height: 1.7;
  font-feature-settings: "tnum";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.page {
  max-width: 880px;
  margin: 0 auto;
  padding: 72px 40px 96px;
}

/* ---------- Header ---------- */
header { margin-bottom: 36px; }

h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 3.4rem;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 0 0 14px;
  color: var(--text);
}

.subtitle {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--muted);
  margin: 0;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}
.subtitle .sep { margin: 0 0.5em; opacity: 0.55; }

/* ---------- Section dividers (homepage only) ---------- */
.home-section {
  border-top: 1px solid var(--rule);
  padding-top: 36px;
  margin-top: 48px;
}
.home-section.about-section { margin-top: 0; }

.label {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 28px;
}

/* ---------- About row ---------- */
.about-row {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 36px;
  align-items: start;
}
.avatar {
  width: 132px;
  height: 132px;
  object-fit: cover;
  border: 1px solid var(--avatar-bd);
  border-radius: 2px;
}
.bio p { margin: 0 0 18px; }
.bio p:last-child { margin-bottom: 0; }

/* ---------- Icon links row ---------- */
.links-row {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  align-items: center;
  margin: 28px 0 0;
  padding: 24px 0 0;
  list-style: none;
  border-top: 1px solid var(--rule);
}
.links-row li { margin: 0; }
.icon-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  text-decoration: none;
  font-family: var(--mono);
  font-size: 0.92rem;
  letter-spacing: 0.02em;
  transition: color 0.15s ease;
}
.icon-link:hover, .icon-link:focus-visible { color: var(--text); }
.icon-link svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex-shrink: 0;
}

/* ---------- Links ---------- */
a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: var(--muted);
  transition: color 0.15s ease, text-decoration-color 0.15s ease;
}
a:hover, a:focus-visible {
  color: var(--link-hover);
  text-decoration-color: var(--text);
}
a:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ---------- News ---------- */
.news {
  display: grid;
  grid-template-columns: 110px 1fr;
  row-gap: 18px;
  column-gap: 28px;
  margin: 0;
}
.news dt {
  font-family: var(--mono);
  font-size: 0.88rem;
  color: var(--muted);
  letter-spacing: 0.02em;
  padding-top: 4px;
  font-variant-numeric: tabular-nums;
}
.news dd { margin: 0; color: var(--text); }

/* ---------- Projects ---------- */
.project {
  margin-bottom: 38px;
}
.project:last-child { margin-bottom: 0; }
.project h3 {
  font-family: var(--serif);
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0 0 8px;
  letter-spacing: -0.005em;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.project h3 .stars-badge { display: inline-flex; align-items: center; height: 20px; }
.project h3 .stars-badge img { height: 20px; display: block; }
.project .meta {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 12px;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.project .meta a { color: inherit; }
.project ul { margin: 8px 0 0; padding-left: 1.15rem; }
.project li { margin-bottom: 6px; font-size: 1.02rem; line-height: 1.65; color: var(--text); }

/* ---------- Hobbies ---------- */
.hobbies { list-style: none; padding: 0; margin: 0; }
.hobbies li { margin-bottom: 12px; }
.hobbies li:last-child { margin-bottom: 0; }
.hobbies strong { font-weight: 600; }

/* ---------- Theme toggle ---------- */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 34px;
  height: 34px;
  background: transparent;
  border: 1px solid var(--rule);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color 0.15s ease, border-color 0.15s ease;
  z-index: 10;
}
.theme-toggle:hover, .theme-toggle:focus-visible {
  color: var(--text);
  border-color: var(--text);
}
.theme-toggle:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}
.theme-toggle svg {
  width: 16px; height: 16px;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: 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 (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: block; }
}

/* ---------- Article / blog (for future subpages) ---------- */
.article-header {
  margin-bottom: 36px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--rule);
}
.article-header .back {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
  display: inline-block;
  margin-bottom: 16px;
}
.article-header .back:hover { color: var(--text); }
.article-header h1 { font-size: 2rem; margin-bottom: 8px; }
.article-header .date {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--muted);
}
.prose h2 { font-size: 1.35rem; font-weight: 600; margin-top: 36px; letter-spacing: -0.01em; }
.prose h3 { font-size: 1.1rem; font-weight: 600; margin-top: 28px; }
.prose pre {
  background: var(--rule);
  padding: 14px 18px;
  border-radius: 4px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.88rem;
}
.prose code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--rule);
  padding: 1px 5px;
  border-radius: 3px;
}
.prose pre code { background: transparent; padding: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  .page { padding: 56px 22px 72px; }
  body { font-size: 16px; }
  h1 { font-size: 2rem; }
  .subtitle { font-size: 0.82rem; }
  .about-row { grid-template-columns: 1fr; gap: 20px; }
  .avatar { width: 108px; height: 108px; }
  .news { grid-template-columns: 1fr; row-gap: 18px; }
  .news dt { padding-top: 0; margin-bottom: -8px; }
  .theme-toggle { top: 14px; right: 14px; }
}

@media print {
  .theme-toggle { display: none; }
  body { background: white; color: black; }
}
