:root,
:root[data-theme="light"] {
  --bg: #faf8f3;
  --ink: #1c1a17;
  --muted: #6f6a61;
  --line: #e3ddd1;
  --red: #c3272b;
  --card: #fffdf9;
  --header-bg: rgba(250, 248, 243, 0.82);
  --grain-blend: multiply;
  --serif: "Noto Serif SC", serif;
  --sans: "Space Grotesk", "Noto Serif SC", sans-serif;
}

:root[data-theme="dark"] {
  --bg: #14110d;
  --ink: #f2ede3;
  --muted: #a79e90;
  --line: #322c24;
  --red: #e0555a;
  --card: #1e1a14;
  --header-bg: rgba(20, 17, 13, 0.82);
  --grain-blend: screen;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  color-scheme: light dark;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color .4s ease, color .4s ease;
}

/* 细微颗粒质感 */
.grain {
  position: fixed;
  inset: 0;
  z-index: 999;
  pointer-events: none;
  opacity: 0.035;
  mix-blend-mode: var(--grain-blend);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem clamp(1.2rem, 5vw, 4rem);
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  font-family: var(--serif);
  font-weight: 900;
  font-size: 1.25rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: .02em;
}

.site-header nav {
  display: flex;
  gap: clamp(1rem, 3vw, 2.2rem);
}

.site-header nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: .92rem;
  transition: color .25s;
}

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

/* Header actions: language + theme */
.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.languages {
  display: flex;
  gap: .15rem;
}

.languages button {
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-size: .85rem;
  color: var(--muted);
  padding: .25rem .5rem;
  border-radius: 8px;
  line-height: 1;
  transition: color .2s, background-color .2s;
}

.languages button:hover {
  color: var(--ink);
}

.languages button.active {
  color: var(--red);
  font-weight: 700;
  background: color-mix(in srgb, var(--red) 12%, transparent);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--line);
  border-radius: 100px;
  width: 34px;
  height: 34px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  transition: border-color .2s, color .2s;
}

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

.theme-icon {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: currentColor;
  position: relative;
  transition: box-shadow .3s, transform .3s;
}

/* light: sun (rays via box-shadow ring is heavy; use a filled dot) */
:root[data-theme="dark"] .theme-icon {
  /* moon: crescent via offset shadow cut-out */
  background: transparent;
  box-shadow: inset -5px -1px 0 0 currentColor;
  transform: rotate(-20deg);
}

main {
  padding: 0 clamp(1.2rem, 5vw, 4rem);
}

/* Hero */
.hero {
  min-height: 78vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 1000px;
  margin: 0 auto;
}

.eyebrow {
  font-size: .82rem;
  letter-spacing: .28em;
  color: var(--muted);
  margin-bottom: 1.6rem;
}

.hero h1 {
  font-family: var(--serif);
  font-weight: 900;
  font-size: clamp(2.6rem, 8vw, 5.5rem);
  line-height: 1.12;
  letter-spacing: .01em;
}

.hero h1 em {
  color: var(--red);
  font-style: normal;
}

.hero .lead {
  margin-top: 1.8rem;
  max-width: 34ch;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.15rem);
}

.scroll-cue {
  margin-top: 3rem;
  display: inline-flex;
  align-items: center;
  gap: .7rem;
  color: var(--ink);
  text-decoration: none;
  font-size: .85rem;
  letter-spacing: .1em;
}

.scroll-cue i {
  width: 2.4rem;
  height: 1px;
  background: var(--ink);
  position: relative;
}

.scroll-cue i::after {
  content: "";
  position: absolute;
  right: 0;
  top: -3px;
  width: 7px;
  height: 7px;
  border-right: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  transform: rotate(-45deg);
}

.scroll-cue:hover i {
  animation: nudge 1s infinite;
}

@keyframes nudge {
  50% {
    transform: translateX(6px);
  }
}

/* Section head */
.section-head {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  padding-top: 4rem;
  margin-bottom: 2.5rem;
  border-top: 1px solid var(--line);
}

.section-index {
  font-size: .8rem;
  letter-spacing: .2em;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: .6rem;
}

.section-index i {
  width: 2rem;
  height: 1px;
  background: var(--line);
}

.section-head h2 {
  font-family: var(--serif);
  font-weight: 900;
  font-size: clamp(1.8rem, 5vw, 2.8rem);
}

/* Work grid */
.work-grid {
  display: grid;
  gap: 2rem;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  padding-bottom: 2rem;
}

.work-card {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform .4s cubic-bezier(.2, .8, .2, 1), box-shadow .4s, border-color .4s;
  animation: rise .7s both;
  animation-delay: calc(var(--i) * .08s);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
}

.work-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 20px 45px -25px rgba(28, 26, 23, .4);
  border-color: var(--red);
}

.work-cover {
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #ece7dd;
}

.work-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .6s cubic-bezier(.2, .8, .2, 1);
}

.work-card:hover .work-cover img {
  transform: scale(1.05);
}

.work-meta {
  padding: 1.4rem 1.5rem 1.6rem;
}

.work-year {
  font-size: .78rem;
  letter-spacing: .15em;
  color: var(--muted);
}

.work-meta h3 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.3rem;
  margin: .35rem 0 .6rem;
}

.work-meta p {
  color: var(--muted);
  font-size: .92rem;
}

.work-tags {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.work-tags span {
  font-size: .74rem;
  letter-spacing: .05em;
  color: var(--muted);
  padding: .2rem .6rem;
  border: 1px solid var(--line);
  border-radius: 100px;
}

/* About */
.about-body {
  max-width: 52ch;
  color: var(--muted);
  font-size: 1.05rem;
  padding-bottom: 4rem;
}

.about-body a {
  color: var(--red);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

/* Footer */
footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 2rem clamp(1.2rem, 5vw, 4rem);
  border-top: 1px solid var(--line);
  font-size: .85rem;
  color: var(--muted);
}

footer button {
  background: none;
  border: 1px solid var(--line);
  border-radius: 100px;
  padding: .4rem 1rem;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: .82rem;
  transition: border-color .25s, color .25s;
}

footer button:hover {
  border-color: var(--red);
  color: var(--red);
}

@media (max-width: 720px) {
  .site-header {
    flex-wrap: wrap;
    gap: .6rem 1rem;
    padding: .8rem clamp(1rem, 5vw, 4rem);
  }

  .site-header nav {
    gap: 1rem;
    order: 3;
    width: 100%;
  }

  .header-actions {
    margin-left: auto;
  }

  .section-head {
    flex-direction: column;
    gap: .6rem;
  }
}
