/* ---------------------------------------------------------------
   Shiyang Pan — research hub
   Quiet paper tones in daylight, deep pine at night.
   --------------------------------------------------------------- */

:root {
  --bg: #f6f4ee;
  --bg-soft: #efece3;
  --text: #2f3531;
  --muted: #6c746e;
  --faint: #9aa19b;
  --rule: #e1ddd2;
  --accent: #5b7d68;
  --accent-soft: #e3ebe2;
  --tag-bg: #ece9df;
  --shadow: 0 1px 2px rgba(47, 53, 49, 0.06), 0 8px 24px rgba(47, 53, 49, 0.05);

  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161b19;
    --bg-soft: #1c2320;
    --text: #dde2dc;
    --muted: #9ba49d;
    --faint: #6f7872;
    --rule: #2a322e;
    --accent: #9dbda8;
    --accent-soft: #23302a;
    --tag-bg: #222a26;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #161b19;
  --bg-soft: #1c2320;
  --text: #dde2dc;
  --muted: #9ba49d;
  --faint: #6f7872;
  --rule: #2a322e;
  --accent: #9dbda8;
  --accent-soft: #23302a;
  --tag-bg: #222a26;
  --shadow: none;
  color-scheme: dark;
}

/* ---------- base ---------- */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  font-size: 1.1875rem;
  line-height: 1.7;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.4s ease, color 0.4s ease;
}

.wrap {
  max-width: 44rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 55%, transparent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  transition: color 0.2s ease, text-decoration-color 0.2s ease;
}

a:hover {
  color: var(--accent);
  text-decoration-color: var(--accent);
}

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

p {
  margin: 0 0 1.1em;
}

h1,
h2,
h3 {
  font-weight: 400;
  line-height: 1.25;
  margin: 0;
}

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

::selection {
  background: var(--accent-soft);
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.75rem 0 0;
  font-family: var(--sans);
  font-size: 0.8125rem;
  letter-spacing: 0.02em;
}

.topbar .home {
  white-space: nowrap;
  text-decoration: none;
  color: var(--muted);
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  align-items: center;
}

.topbar nav a {
  color: var(--muted);
  text-decoration: none;
}

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

@media (max-width: 600px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
  }
  .topbar {
    position: relative;
  }
  .topbar nav {
    gap: 0.25rem 1rem;
  }
  .topbar .theme-toggle {
    position: absolute;
    top: 1.75rem;
    right: 0.25rem;
  }
}

.theme-toggle {
  appearance: none;
  border: 0;
  background: none;
  padding: 0.25rem;
  margin: -0.25rem;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  border-radius: 999px;
}

.theme-toggle:hover {
  color: var(--accent);
}

.theme-toggle svg {
  width: 1rem;
  height: 1rem;
}

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

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

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

/* ---------- intro ---------- */

.intro {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2.5rem;
  align-items: start;
  padding: 4.5rem 0 1rem;
}

.intro h1 {
  font-size: 2.6rem;
  letter-spacing: -0.01em;
  margin-bottom: 0.35rem;
}

.intro .role {
  font-family: var(--sans);
  font-size: 0.875rem;
  color: var(--muted);
  margin: 0 0 1.75rem;
  line-height: 1.6;
}

.intro .portrait {
  width: 9.5rem;
  height: auto;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  object-position: 50% 20%;
  border-radius: 1.25rem;
  box-shadow: var(--shadow);
  margin-top: 0.5rem;
}

.intro .keywords {
  margin: -0.75rem 0 1.75rem;
}

.intro .keywords li {
  background: var(--accent-soft);
  color: var(--accent);
}

.wave {
  display: block;
  width: 7rem;
  height: 0.75rem;
  margin: 0 0 1.75rem;
  color: var(--accent);
  opacity: 0.55;
}

.lede {
  font-size: 1.25rem;
}

@media (max-width: 600px) {
  .intro {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding-top: 3rem;
  }
  .intro .portrait {
    width: 7rem;
    order: -1;
    margin-top: 0;
  }
  .intro h1 {
    font-size: 2.2rem;
  }
}

.interests {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
}

.interests li {
  position: relative;
  padding-left: 1.4rem;
  margin-bottom: 0.25rem;
}

.interests li::before {
  content: "";
  position: absolute;
  left: 0.15rem;
  top: 0.78em;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.5;
}

/* ---------- sections ---------- */

section {
  padding: 3.5rem 0 0.5rem;
  scroll-margin-top: 1rem;
}

.section-title {
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}

.subhead {
  font-family: var(--sans);
  font-size: 0.8125rem;
  color: var(--faint);
  margin: 2.5rem 0 1.25rem;
  letter-spacing: 0.02em;
}

.section-note {
  color: var(--muted);
  font-size: 1.0625rem;
  margin-top: -0.75rem;
  margin-bottom: 2rem;
}

/* ---------- projects ---------- */

.project {
  position: relative;
  padding: 0 0 2.25rem 1.5rem;
  border-left: 1px solid var(--rule);
  margin-left: 0.3rem;
}

.project:last-child {
  padding-bottom: 0.5rem;
}

.project::before {
  content: "";
  position: absolute;
  left: -0.34rem;
  top: 0.55rem;
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 50%;
  background: var(--bg);
  border: 1.5px solid var(--faint);
}

.project.ongoing::before {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.project .meta {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 0.6rem;
  margin-bottom: 0.3rem;
}

.project .meta .status {
  color: var(--accent);
  font-weight: 500;
}

.project h3 {
  font-size: 1.45rem;
  margin-bottom: 0.4rem;
}

.project h3 a {
  text-decoration: none;
}

.project p {
  margin-bottom: 0.7rem;
}

.project .more {
  font-family: var(--sans);
  font-size: 0.8125rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.1rem;
}

.project .more a {
  text-decoration: none;
  color: var(--accent);
}

.project .more a:hover {
  text-decoration: underline;
}

.tags {
  list-style: none;
  padding: 0;
  margin: 0 0 0.8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tags li {
  font-family: var(--sans);
  font-size: 0.72rem;
  color: var(--muted);
  background: var(--tag-bg);
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
}

/* compact list for smaller projects */
.quiet-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.quiet-list li {
  padding: 1rem 0;
  border-top: 1px solid var(--rule);
}

.quiet-list li:last-child {
  border-bottom: 1px solid var(--rule);
}

.quiet-list .row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
}

.quiet-list .name {
  font-size: 1.15rem;
}

.quiet-list .side {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--faint);
  white-space: nowrap;
}

.quiet-list .desc {
  color: var(--muted);
  font-size: 1rem;
  margin: 0.2rem 0 0;
  line-height: 1.6;
}

/* ---------- publications ---------- */

.pub {
  padding: 0;
  margin: 0;
  list-style: none;
}

.pub li {
  margin-bottom: 1.5rem;
}

.pub .title {
  font-size: 1.15rem;
  display: block;
  margin-bottom: 0.25rem;
}

.pub .authors,
.pub .venue {
  display: block;
  font-size: 1rem;
  color: var(--muted);
  line-height: 1.55;
}

.pub .venue em {
  color: var(--text);
}

.pub .me {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 0.2em;
}

/* ---------- background (two-column timeline) ---------- */

.timeline {
  list-style: none;
  padding: 0;
  margin: 0;
}

.timeline li {
  display: grid;
  grid-template-columns: 8rem 1fr;
  gap: 1.5rem;
  padding: 0.55rem 0;
}

.timeline .when {
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--faint);
  padding-top: 0.3rem;
  font-variant-numeric: tabular-nums;
}

.timeline .what {
  font-size: 1.05rem;
  line-height: 1.55;
}

.timeline .where {
  display: block;
  color: var(--muted);
  font-size: 0.97rem;
}

@media (max-width: 600px) {
  .timeline li {
    grid-template-columns: 1fr;
    gap: 0.1rem;
  }
  .timeline .when {
    padding-top: 0;
  }
}

/* ---------- contact ---------- */

.contact {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.contact a {
  display: flex;
  flex-direction: column;
  padding: 1rem 1.15rem;
  border: 1px solid var(--rule);
  border-radius: 0.9rem;
  text-decoration: none;
  transition: border-color 0.25s ease, background-color 0.25s ease;
}

.contact a:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: inherit;
}

.contact .label {
  font-family: var(--sans);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.contact .value {
  font-size: 1.02rem;
  overflow-wrap: anywhere;
}

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

/* ---------- footer ---------- */

footer {
  padding: 5rem 0 3rem;
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--faint);
  text-align: center;
}

footer .wave {
  margin: 0 auto 1.25rem;
  opacity: 0.35;
}

/* ---------- project pages ---------- */

.article-head {
  padding: 4rem 0 0.5rem;
}

.article-head .meta {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem 0.75rem;
  margin-bottom: 0.75rem;
}

.article-head .meta .status {
  color: var(--accent);
  font-weight: 500;
}

.article-head h1 {
  font-size: 2.6rem;
  margin-bottom: 0.6rem;
}

.article-head .summary {
  font-size: 1.3rem;
  color: var(--muted);
  line-height: 1.5;
  font-style: italic;
  margin-bottom: 1.25rem;
}

.article {
  padding-top: 1.5rem;
}

.article h2 {
  font-size: 1.5rem;
  margin: 2.5rem 0 0.75rem;
}

figure {
  margin: 2.5rem 0;
}

figure img {
  border-radius: 0.75rem;
  background: #fff;
  padding: 0.75rem;
  border: 1px solid var(--rule);
}

figcaption {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.6;
  margin-top: 0.85rem;
}

.back {
  font-family: var(--sans);
  font-size: 0.8125rem;
  color: var(--accent);
  text-decoration: none;
}

/* ---------- gentle arrival ---------- */

@media (prefers-reduced-motion: no-preference) {
  .rise {
    animation: rise 0.9s ease both;
  }
  .rise:nth-child(2) {
    animation-delay: 0.08s;
  }
  .rise:nth-child(3) {
    animation-delay: 0.16s;
  }
  @keyframes rise {
    from {
      opacity: 0;
      transform: translateY(6px);
    }
    to {
      opacity: 1;
      transform: none;
    }
  }
}
