/* ============================================================
   Chaoda Zheng — Research Homepage
   Cartesian design system: warm stone + Playfair Display + 1px lines
   ============================================================ */

:root {
  /* Stone & ink palette */
  --bg-primary: #ede8e0;
  --bg-secondary: #e2dbd1;
  --text-primary: #1a1a1a;
  --text-secondary: #5a5a5a;
  --accent: #8a8178;
  --line: #b8b0a4;
  --white-overlay: rgba(255, 255, 255, 0.3);

  /* Layout */
  --max: 1100px;
  --edge: clamp(22px, 5vw, 72px);
  --header-h: 64px;

  /* Transitions */
  --ease: 280ms ease;
}

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: var(--header-h);
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: "Inter", sans-serif;
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--line);
  color: var(--text-primary);
}

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

a {
  color: inherit;
  text-decoration: none;
}

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

.shell {
  width: min(calc(100% - (var(--edge) * 2)), var(--max));
  margin-inline: auto;
}

/* ---- Typography ------------------------------------------ */
h1, h2, h3, h4 {
  font-family: "Playfair Display", serif;
  font-weight: 400;
  line-height: 1.1;
  color: var(--text-primary);
}

h1 {
  font-size: clamp(2.5rem, 5vw, 4.5rem);
}

h2 {
  font-size: clamp(1.8rem, 3.5vw, 3rem);
}

h3 {
  font-size: clamp(1.2rem, 2vw, 1.6rem);
}

p, li {
  color: var(--text-secondary);
  line-height: 1.6;
}

.label {
  font-family: "Inter", sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--accent);
}

/* ---- Header ---------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-h);
  padding: 0 var(--edge);
  border-bottom: 1px solid var(--line);
  background: rgba(237, 232, 224, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.wordmark {
  font-family: "Playfair Display", serif;
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  transition: color var(--ease);
}

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

.site-header nav {
  display: flex;
  gap: 28px;
}

.site-header nav a {
  font-family: "Inter", sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent);
  transition: color var(--ease);
  position: relative;
}

.site-header nav a::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 0;
  height: 1px;
  background: var(--text-primary);
  transition: width var(--ease);
}

.site-header nav a:hover {
  color: var(--text-primary);
}

.site-header nav a:hover::after {
  width: 100%;
}

/* ---- Hero (Cartesian title slide aesthetic) -------------- */
.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100vh - var(--header-h));
  padding: clamp(60px, 10vh, 120px) 0;
  overflow: hidden;
}

.hero .shell {
  position: relative;
  z-index: 1;
}

.hero .label {
  margin-bottom: 2vh;
  animation: fadeUp 700ms ease both;
}

.hero h1 {
  font-size: clamp(3rem, 6vw, 5.5rem);
  margin-bottom: 2vh;
  animation: fadeUp 700ms 100ms ease both;
}

.hero .subtitle {
  font-family: "Inter", sans-serif;
  font-size: clamp(1rem, 1.5vw, 1.3rem);
  color: var(--text-secondary);
  max-width: 520px;
  line-height: 1.5;
  animation: fadeUp 700ms 200ms ease both;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 4vh;
  animation: fadeUp 700ms 300ms ease both;
}

.hero-links a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: "Inter", sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent);
  padding: 8px 0;
  border-bottom: 1px solid transparent;
  transition: color var(--ease), border-color var(--ease);
}

.hero-links a:hover {
  color: var(--text-primary);
  border-color: var(--text-primary);
}

.scholar-icon,
.github-icon,
.email-icon {
  width: 1.05em;
  height: 1.05em;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
  flex-shrink: 0;
}

/* Geo-decoration — title slide ring */
.hero .geo-decoration {
  position: absolute;
  right: 5vw;
  bottom: 8vh;
  width: 28vw;
  height: 28vw;
  max-width: 400px;
  max-height: 400px;
  border: 1px solid var(--line);
  border-radius: 50%;
  opacity: 0.4;
  pointer-events: none;
  z-index: 0;
}

.hero .geo-decoration::before {
  content: "";
  position: absolute;
  top: 10%;
  left: 10%;
  width: 80%;
  height: 80%;
  border: 1px dashed var(--line);
  border-radius: 50%;
}

/* Vertical line decoration */
.hero .vertical-line {
  position: absolute;
  left: 8vw;
  top: 0;
  width: 1px;
  height: 100%;
  background: var(--line);
  opacity: 0.25;
  z-index: 0;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Sections — shared ----------------------------------- */
.section {
  padding-block: clamp(80px, 12vh, 140px);
  border-top: 1px solid var(--line);
  position: relative;
}

.section-header {
  margin-bottom: clamp(40px, 6vh, 64px);
}

.section-header .label {
  margin-bottom: 1.5vh;
}

.section-header h2 {
  margin-bottom: 2vh;
}

.section-header p {
  max-width: 480px;
}

/* ---- About ----------------------------------------------- */
.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(40px, 6vw, 80px);
  align-items: start;
}

.about-grid p {
  font-size: clamp(0.9rem, 1.1vw, 1.05rem);
}

/* Stats cluster */
.stats-cluster {
  display: flex;
  gap: clamp(24px, 3vw, 48px);
  padding-top: 3vh;
  border-top: 1px solid var(--line);
}

.stat-item h4 {
  font-family: "Playfair Display", serif;
  font-weight: 400;
  font-size: 2rem;
  margin-bottom: 0.3vh;
  color: var(--text-primary);
}

.stat-item span {
  font-size: 0.75rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 2px;
}

/* ---- Research interests (cards) -------------------------- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2vw;
}

.card {
  border: 1px solid var(--line);
  padding: clamp(24px, 4vh, 40px) clamp(20px, 2vw, 28px);
  background: var(--white-overlay);
  transition: background var(--ease), border-color var(--ease);
}

.card:hover {
  background: rgba(255, 255, 255, 0.5);
  border-color: var(--accent);
}

.card-icon {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 3vh;
  font-family: "Playfair Display", serif;
  font-size: 1rem;
  color: var(--accent);
  transition: border-color var(--ease), color var(--ease);
}

.card:hover .card-icon {
  border-color: var(--accent);
  color: var(--text-primary);
}

.card h3 {
  font-size: 1.3rem;
  margin-bottom: 1.5vh;
}

.card p {
  font-size: 0.9rem;
  margin-bottom: 2vh;
}

.card .meta {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent);
}

/* ---- Featured work (two-column) -------------------------- */
.featured-work {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(32px, 5vw, 64px);
  align-items: center;
}

.featured-image,
.featured-gallery {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg-secondary);
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--ease);
}

.featured-gallery {
  margin-bottom: clamp(52px, 6vw, 68px);
  overflow: visible;
}

.featured-image:hover,
.featured-gallery:hover {
  border-color: var(--accent);
}

.featured-image img,
.featured-image video,
.featured-gallery video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  position: relative;
  z-index: 1;
}

.featured-image video,
.featured-gallery video {
  display: block;
  filter: saturate(0.92) contrast(1.04);
}

.gallery-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  background:
    linear-gradient(135deg, rgba(237, 232, 224, 0.94), rgba(237, 232, 224, 0.78)),
    repeating-linear-gradient(90deg, transparent 0 32px, rgba(29, 27, 23, 0.04) 32px 33px);
  color: var(--text-primary);
  pointer-events: none;
  opacity: 1;
  transition: opacity 360ms var(--ease), visibility 360ms var(--ease);
}

.featured-gallery.is-ready .gallery-loading {
  opacity: 0;
  visibility: hidden;
}

.gallery-loading span {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 2.4px;
  text-transform: uppercase;
}

.gallery-loading small {
  color: var(--text-secondary);
  font-size: 0.72rem;
  letter-spacing: 1.4px;
  text-transform: uppercase;
}

.featured-gallery .x-pattern {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.gallery-slide {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  transform: scale(0.985);
  transition: opacity 700ms var(--ease), transform 700ms var(--ease);
  pointer-events: none;
}

.gallery-slide.is-active {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.gallery-controls {
  position: absolute;
  left: clamp(14px, 1.8vw, 22px);
  right: clamp(14px, 1.8vw, 22px);
  top: calc(100% + 12px);
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 8px;
  background: rgba(237, 232, 224, 0.82);
  border: 1px solid rgba(237, 232, 224, 0.72);
  backdrop-filter: blur(14px);
}

.gallery-controls button {
  appearance: none;
  border: 0;
  border-bottom: 1px solid transparent;
  background: transparent;
  color: rgba(29, 27, 23, 0.62);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 1.1px;
  line-height: 1.2;
  padding: 6px 2px;
  text-transform: uppercase;
  transition: color var(--ease), border-color var(--ease);
}

.gallery-controls button:hover,
.gallery-controls button.is-active {
  border-color: var(--accent);
  color: var(--text-primary);
}

.featured-image .x-pattern::before,
.featured-image .x-pattern::after,
.featured-gallery .x-pattern::before,
.featured-gallery .x-pattern::after {
  content: "";
  position: absolute;
  width: 150%;
  height: 1px;
  background: var(--line);
  z-index: 0;
}

.featured-image .x-pattern::before,
.featured-gallery .x-pattern::before {
  transform: rotate(-30deg);
}

.featured-image .x-pattern::after,
.featured-gallery .x-pattern::after {
  transform: rotate(30deg);
}

.featured-copy .label {
  margin-bottom: 1.5vh;
}

.featured-copy h2 {
  font-size: clamp(2.5rem, 5vw, 4rem);
  margin-bottom: 1.5vh;
}

.featured-copy h3 {
  margin-bottom: 2vh;
  color: var(--text-secondary);
  font-weight: 400;
}

.featured-copy > p {
  font-size: clamp(0.9rem, 1vw, 1rem);
  margin-bottom: 2vh;
}

/* Key facts — agenda-style list */
.facts-list {
  list-style: none;
  margin-top: 3vh;
}

.facts-list li {
  padding: 1.5vh 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  gap: 1.5vw;
  font-size: 0.95rem;
}

.facts-list .fact-num {
  font-family: "Playfair Display", serif;
  font-size: 1.2rem;
  color: var(--accent);
  min-width: 2.5vw;
}

.facts-list strong {
  color: var(--text-primary);
  font-weight: 400;
  font-family: "Playfair Display", serif;
  font-size: 1.3rem;
}

.inline-links {
  display: flex;
  gap: 24px;
  margin-top: 3vh;
}

.inline-links a {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent);
  border-bottom: 1px solid transparent;
  transition: color var(--ease), border-color var(--ease);
}

.inline-links a:hover {
  color: var(--text-primary);
  border-color: var(--text-primary);
}

/* ---- Work grid ------------------------------------------- */
.work-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: clamp(18px, 1.8vw, 28px);
}

.work-card {
  border: 1px solid var(--line);
  background: var(--white-overlay);
  display: flex;
  flex-direction: column;
  transition: background var(--ease), border-color var(--ease), transform var(--ease);
}

.work-card:hover {
  background: rgba(255, 255, 255, 0.5);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.work-card .card-image {
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
  position: relative;
}

.work-card .card-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 12px;
}

.work-card .card-body {
  padding: clamp(16px, 2.5vh, 24px) clamp(16px, 1.8vw, 22px);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.work-card .label {
  font-size: 0.65rem;
  letter-spacing: 2px;
  margin-bottom: 1vh;
}

.work-card h3 {
  font-size: 1.2rem;
  margin-bottom: 1vh;
}

.work-card p {
  font-size: 0.85rem;
  flex: 1;
}

.work-card .inline-links {
  margin-top: 2vh;
}

/* ---- Publications (agenda-style) ------------------------- */
.pub-list {
  list-style: none;
}

.pub-list li {
  padding: 2vh 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: baseline;
  gap: 2vw;
  transition: background var(--ease);
}

.pub-list li:hover {
  background: rgba(255, 255, 255, 0.2);
  padding-left: 8px;
}

.pub-list .pub-year {
  font-family: "Inter", sans-serif;
  font-size: 0.75rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 2px;
  min-width: 50px;
}

.pub-list .pub-content {
  flex: 1;
}

.pub-list strong {
  font-family: "Playfair Display", serif;
  font-weight: 400;
  font-size: clamp(1.1rem, 1.5vw, 1.3rem);
  color: var(--text-primary);
  display: block;
  margin-bottom: 0.3vh;
  transition: color var(--ease);
}

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

.pub-list .pub-venue {
  font-size: 0.75rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.pub-list .pub-link {
  font-size: 0.8rem;
  color: var(--accent);
  transition: color var(--ease);
}

.pub-list li:hover .pub-link {
  color: var(--text-primary);
}

.scholar-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: min(100%, 720px);
  margin-top: clamp(28px, 4vh, 42px);
  padding: clamp(18px, 2.4vh, 24px) clamp(20px, 3vw, 32px);
  border: 1px solid var(--line);
  background: var(--white-overlay);
  font-size: 0.78rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent);
  transition:
    background var(--ease),
    border-color var(--ease),
    color var(--ease),
    transform var(--ease);
}

.scholar-link span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.scholar-link .scholar-icon {
  width: 1.25em;
  height: 1.25em;
}

.scholar-link-meta {
  color: var(--text-secondary);
  font-size: 0.68rem;
  white-space: nowrap;
}

.scholar-link:hover {
  background: rgba(255, 255, 255, 0.5);
  color: var(--text-primary);
  border-color: var(--accent);
  transform: translateY(-2px);
}

.scholar-link:hover .scholar-link-meta {
  color: var(--accent);
}

/* ---- Experience (timeline) ------------------------------- */
.timeline {
  display: flex;
  gap: 2vw;
  position: relative;
  padding-top: 3vh;
}

.timeline::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--line);
}

.timeline-item {
  flex: 1;
  padding-right: 2vw;
}

.timeline-item .year {
  font-size: 0.75rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 1vh;
}

.timeline-item h4 {
  font-family: "Playfair Display", serif;
  font-weight: 400;
  font-size: 1.2rem;
  margin: 2vh 0 1vh;
  color: var(--text-primary);
}

.timeline-item p {
  font-size: 0.85rem;
}

/* ---- Service --------------------------------------------- */
.service-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2vw;
}

.service-featured {
  border: 1px solid var(--line);
  background: var(--white-overlay);
  padding: clamp(28px, 5vh, 48px) clamp(24px, 3vw, 36px);
  display: flex;
  gap: clamp(18px, 2.5vw, 28px);
  align-items: flex-start;
  transition: border-color var(--ease), background var(--ease);
}

.service-featured:hover {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.5);
}

.service-accent {
  width: 2px;
  min-height: 60px;
  background: var(--text-primary);
  flex-shrink: 0;
  align-self: stretch;
}

.service-featured .label {
  margin-bottom: 1vh;
}

.service-role {
  font-family: "Playfair Display", serif;
  font-weight: 400;
  font-size: clamp(2rem, 3vw, 2.8rem);
  color: var(--text-primary);
  line-height: 1.1;
}

.service-item {
  border: 1px solid var(--line);
  background: var(--white-overlay);
  padding: clamp(24px, 4vh, 40px) clamp(20px, 2.5vw, 28px);
  transition: border-color var(--ease), background var(--ease);
}

.service-item:hover {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.5);
}

.service-item dt {
  font-family: "Playfair Display", serif;
  font-weight: 400;
  font-size: 1.3rem;
  margin-bottom: 0.5vh;
}

.service-item dd {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

/* ---- Contact --------------------------------------------- */
.contact {
  text-align: center;
  position: relative;
  overflow: hidden;
  padding-block: clamp(100px, 16vh, 180px);
}

.contact .shell {
  position: relative;
  z-index: 1;
}

.contact .label {
  margin-bottom: 2vh;
}

.contact h2 {
  font-size: clamp(2.5rem, 5vw, 4rem);
  margin-bottom: 3vh;
}

.contact > .shell > p {
  max-width: 520px;
  margin: 0 auto 4vh;
  font-size: clamp(0.95rem, 1.1vw, 1.1rem);
}

.contact-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 24px;
}

.contact-links a {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent);
  padding: 8px 18px;
  border: 1px solid var(--line);
  transition: color var(--ease), border-color var(--ease), background var(--ease);
}

.contact-links a:hover {
  color: var(--text-primary);
  border-color: var(--text-primary);
  background: var(--white-overlay);
}

/* Geo-ring — closing slide */
.contact .geo-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(50vw, 600px);
  height: min(50vw, 600px);
  border: 1px solid var(--line);
  border-radius: 50%;
  opacity: 0.25;
  pointer-events: none;
  z-index: 0;
}

.contact .geo-ring::before {
  content: "";
  position: absolute;
  top: 15%;
  left: 15%;
  width: 70%;
  height: 70%;
  border: 1px dashed var(--line);
  border-radius: 50%;
}

/* ---- Footer ---------------------------------------------- */
footer {
  display: flex;
  justify-content: space-between;
  padding: 24px var(--edge);
  border-top: 1px solid var(--line);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent);
}

/* ---- Responsive — ≤ 900px ------------------------------- */
@media (max-width: 900px) {
  .site-header nav {
    display: none;
  }

  .about-grid,
  .featured-work {
    grid-template-columns: 1fr;
    gap: 40px;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }

  .work-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .timeline {
    flex-direction: column;
    gap: 3vh;
  }

  .timeline::before {
    display: none;
  }

  .service-layout {
    grid-template-columns: 1fr;
  }
}

/* ---- Responsive — ≤ 600px ------------------------------- */
@media (max-width: 600px) {
  :root {
    --edge: 18px;
    --header-h: 56px;
  }

  .hero h1 {
    font-size: clamp(2.5rem, 12vw, 3.5rem);
  }

  .hero .geo-decoration {
    right: -10vw;
    bottom: 4vh;
    width: 40vw;
    height: 40vw;
    opacity: 0.2;
  }

  .hero .vertical-line {
    display: none;
  }

  .work-grid {
    grid-template-columns: 1fr;
  }

  .stats-cluster {
    flex-wrap: wrap;
    gap: 20px;
  }

  .pub-list li {
    flex-direction: column;
    gap: 0.5vh;
  }

  .scholar-link {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .pub-list .pub-year {
    min-width: auto;
  }

  footer {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
}

/* ---- Reduced motion -------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
