:root {
  color-scheme: light;
  --paper: #f7f8f4;
  --paper-soft: #eef2ed;
  --ink: #1b211f;
  --muted: #65706b;
  --line: #c9d0cb;
  --pine: #173d32;
  --pine-light: #2f6252;
  --cinnabar: #a53f32;
  --white: #ffffff;
  --page-width: 1180px;
  --reading-width: 760px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --paper: #171b19;
  --paper-soft: #202622;
  --ink: #edf0eb;
  --muted: #a8b1ac;
  --line: #3a443f;
  --pine: #102c25;
  --pine-light: #7aa391;
  --cinnabar: #d26d5c;
  --white: #f6f8f4;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Noto Serif SC", "Source Han Serif SC", "Songti SC", SimSun, serif;
  font-size: 16px;
  line-height: 1.8;
  text-rendering: optimizeLegibility;
  transition: background-color 240ms ease, color 240ms ease;
}

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

button {
  font: inherit;
}

.reading-progress {
  position: fixed;
  inset: 0 auto auto 0;
  z-index: 30;
  width: 0;
  height: 3px;
  background: var(--cinnabar);
  transition: width 80ms linear;
}

.hero {
  position: relative;
  min-height: 88svh;
  overflow: hidden;
  background-image: url("assets/hero-landscape.jpg");
  background-position: center 58%;
  background-size: cover;
  color: var(--white);
  isolation: isolate;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(12, 24, 20, 0.5);
}

.site-nav {
  position: relative;
  z-index: 3;
  width: min(calc(100% - 48px), var(--page-width));
  height: 88px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.38);
}

.wordmark {
  justify-self: start;
  font-size: 18px;
  font-weight: 700;
}

.nav-links {
  display: flex;
  gap: 36px;
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

.nav-links a {
  position: relative;
  padding: 10px 0;
}

.nav-links a::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 4px;
  left: 0;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform 180ms ease;
}

.nav-links a:hover::after,
.nav-links a:focus-visible::after {
  transform: scaleX(1);
  transform-origin: left;
}

.theme-toggle {
  justify-self: end;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  background: rgba(10, 22, 18, 0.16);
  color: inherit;
  cursor: pointer;
  transition: background 180ms ease, border-color 180ms ease, transform 180ms ease;
}

.theme-toggle:hover {
  background: rgba(10, 22, 18, 0.42);
  border-color: rgba(255, 255, 255, 0.92);
  transform: translateY(-2px);
}

.hero-content {
  position: relative;
  z-index: 2;
  width: min(calc(100% - 48px), var(--page-width));
  margin: 0 auto;
  padding: clamp(72px, 11vh, 132px) 0 112px;
}

.kicker,
.section-label,
.dynasty,
.author,
.art-credit,
.site-footer,
.opening-line span,
.read-on {
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

.kicker {
  margin: 0 0 22px;
  font-size: 13px;
  opacity: 0.86;
}

.hero h1 {
  max-width: 7em;
  margin: 0;
  font-size: clamp(54px, 8vw, 108px);
  font-weight: 600;
  line-height: 1.02;
  letter-spacing: 0;
}

.hero-lead {
  margin: 28px 0 10px;
  font-size: clamp(20px, 2.3vw, 30px);
  line-height: 1.5;
}

.hero-note {
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 15px;
  line-height: 1.9;
}

.read-on {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  margin-top: 42px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.68);
  font-size: 13px;
}

.read-on span:last-child {
  font-size: 20px;
  line-height: 1;
  transition: transform 180ms ease;
}

.read-on:hover span:last-child {
  transform: translateY(4px);
}

.art-credit {
  position: absolute;
  z-index: 2;
  right: max(24px, calc((100vw - var(--page-width)) / 2));
  bottom: 24px;
  margin: 0;
  font-size: 11px;
  opacity: 0.68;
}

.opening-line {
  width: min(calc(100% - 48px), var(--page-width));
  min-height: 176px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  border-bottom: 1px solid var(--line);
}

.opening-line p {
  margin: 0;
  color: var(--pine-light);
  font-size: clamp(21px, 3vw, 34px);
}

.opening-line span {
  flex: none;
  color: var(--muted);
  font-size: 12px;
}

.section-inner {
  width: min(calc(100% - 48px), var(--page-width));
  margin: 0 auto;
}

.poems-section {
  padding: 110px 0 132px;
}

.section-heading {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) minmax(250px, 0.7fr);
  align-items: end;
  gap: 32px;
  margin-bottom: 70px;
}

.section-heading > div {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.section-index {
  color: var(--cinnabar);
  font-size: 24px;
}

.section-label {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(32px, 4vw, 52px);
  font-weight: 500;
  line-height: 1.25;
}

.section-heading > p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.poem-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.poem {
  min-height: 460px;
  padding: 38px 34px 46px;
}

.poem + .poem {
  border-left: 1px solid var(--line);
}

.poem header {
  min-height: 142px;
}

.dynasty {
  margin: 0 0 8px;
  color: var(--cinnabar);
  font-size: 12px;
}

.poem h3 {
  margin: 0;
  font-size: 27px;
  font-weight: 500;
}

.author {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.poem-lines {
  font-size: 17px;
  line-height: 2.05;
}

.poem-lines p {
  margin: 0 0 10px;
}

.prose-section {
  padding: 116px 0 124px;
  background: var(--pine);
  color: #edf2ee;
}

.section-heading-light .section-label,
.section-heading-light > p {
  color: rgba(237, 242, 238, 0.63);
}

.section-heading-light .section-index {
  color: #d57968;
}

.prose-list {
  border-top: 1px solid rgba(255, 255, 255, 0.22);
}

.prose-entry {
  display: grid;
  grid-template-columns: 190px minmax(0, var(--reading-width));
  gap: 48px;
  justify-content: space-between;
  padding: 66px 0 72px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.22);
}

.prose-entry aside {
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  color: rgba(237, 242, 238, 0.58);
  font-size: 12px;
}

.prose-entry aside p {
  margin: 0 0 12px;
}

.prose-entry .prose-number {
  color: #d57968;
  font-size: 26px;
}

.prose-entry h3 {
  margin: 0 0 28px;
  font-size: clamp(28px, 3.2vw, 42px);
  font-weight: 500;
}

.prose-entry > div > p {
  margin: 0 0 1.1em;
  color: rgba(237, 242, 238, 0.86);
  font-size: 17px;
  line-height: 2.05;
  text-align: justify;
}

.about-section {
  padding: 112px 0;
  background: var(--paper-soft);
}

.about-inner {
  width: min(calc(100% - 48px), 960px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 48px;
  align-items: start;
  gap: 48px;
}

.seal {
  width: 72px;
  height: 72px;
  border: 2px solid var(--cinnabar);
  color: var(--cinnabar);
  display: grid;
  place-items: center;
  font-size: 36px;
  font-weight: 700;
}

.about-copy h2 {
  margin: 10px 0 24px;
  font-size: clamp(30px, 4vw, 48px);
  font-weight: 500;
  line-height: 1.35;
}

.about-copy > p:last-child {
  max-width: 660px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
}

.back-top {
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: sans-serif;
  font-size: 22px;
  transition: background 180ms ease, color 180ms ease, transform 180ms ease;
}

.back-top:hover {
  background: var(--ink);
  color: var(--paper);
  transform: translateY(-3px);
}

.site-footer {
  min-height: 92px;
  padding: 24px max(24px, calc((100vw - var(--page-width)) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: inherit;
  opacity: 0.72;
}

.site-footer a:hover {
  opacity: 1;
}

.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 560ms ease, transform 560ms ease;
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

:focus-visible {
  outline: 2px solid var(--cinnabar);
  outline-offset: 4px;
}

@media (max-width: 900px) {
  .section-heading {
    grid-template-columns: 90px 1fr;
  }

  .section-heading > p {
    grid-column: 2;
  }

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

  .poem {
    min-height: auto;
    padding-right: 0;
    padding-left: 0;
  }

  .poem + .poem {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .poem header {
    min-height: 126px;
  }

  .prose-entry {
    grid-template-columns: 130px minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .site-nav {
    width: min(calc(100% - 32px), var(--page-width));
    height: 72px;
    grid-template-columns: 1fr auto;
  }

  .nav-links {
    display: none;
  }

  .theme-toggle {
    width: 40px;
    height: 40px;
  }

  .hero {
    min-height: 88svh;
    background-position: 62% center;
  }

  .hero-content {
    width: min(calc(100% - 32px), var(--page-width));
    padding-top: clamp(64px, 10vh, 96px);
    padding-bottom: 100px;
  }

  .hero h1 {
    font-size: clamp(50px, 17vw, 74px);
  }

  .hero-note br {
    display: none;
  }

  .art-credit {
    right: 16px;
    bottom: 16px;
    left: 16px;
    text-align: right;
  }

  .opening-line {
    width: min(calc(100% - 32px), var(--page-width));
    min-height: 150px;
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
  }

  .section-inner {
    width: min(calc(100% - 32px), var(--page-width));
  }

  .poems-section,
  .prose-section {
    padding: 78px 0 88px;
  }

  .section-heading {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 48px;
  }

  .section-heading > p {
    grid-column: 1;
    margin-top: 6px;
  }

  .poem {
    padding-top: 32px;
    padding-bottom: 38px;
  }

  .poem-lines {
    font-size: 16px;
  }

  .prose-entry {
    grid-template-columns: 1fr;
    gap: 22px;
    padding: 48px 0 54px;
  }

  .prose-entry aside {
    display: flex;
    align-items: baseline;
    gap: 14px;
  }

  .prose-entry .prose-number,
  .prose-entry aside p {
    margin: 0;
  }

  .prose-entry > div > p {
    font-size: 16px;
    text-align: left;
  }

  .about-section {
    padding: 76px 0;
  }

  .about-inner {
    width: min(calc(100% - 32px), 960px);
    grid-template-columns: 64px 1fr;
    gap: 24px;
  }

  .seal {
    width: 56px;
    height: 56px;
    font-size: 28px;
  }

  .about-copy h2 {
    font-size: 30px;
  }

  .back-top {
    grid-column: 2;
    margin-top: 12px;
  }

  .site-footer {
    padding: 26px 16px;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    text-align: center;
  }
}

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

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

  .reveal {
    opacity: 1;
    transform: none;
  }
}
