/* Site Serif = Noto Serif SC v2.003 (SIL OFL 1.1), subset to the characters on these pages. See README “字体”. */
@font-face {
  font-family: "Site Serif";
  src: url("/fonts/noto-serif-sc-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Site Serif";
  src: url("/fonts/noto-serif-sc-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --page: #f6f7f4; /* keep equal to preferences.js light theme-color */
  --surface: #fcfdfb;
  --ink: #212b28;
  --ink-soft: #3a4641;
  --muted: #5c6862;
  --line: #d9dfda;
  --line-strong: #b4bfb7;
  --accent: #34614c;
  --focus: #1a5cb3;
  --selection: #d6e6db;

  --font-serif: "Site Serif", Georgia, "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", STSong, SimSun, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;

  --step--1: 0.8125rem;
  --step-0: 1rem;
  --step-1: clamp(1.125rem, 1.02rem + 0.45vw, 1.375rem);
  --step-2: clamp(1.25rem, 1.15rem + 0.4vw, 1.5rem);
  --step-display: clamp(4.25rem, 2.6rem + 8vw, 8rem);

  --space-2xs: 0.25rem;
  --space-xs: 0.5rem;
  --space-s: 0.75rem;
  --space-m: 1rem;
  --space-l: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4.5rem;
  --space-4xl: 7rem;

  font-family: var(--font-sans);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-text-size-adjust: 100%;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #151d19; /* keep equal to preferences.js dark theme-color */
  --surface: #1d2922;
  --ink: #e2e9e4;
  --ink-soft: #c9d3cc;
  --muted: #b1bfb5;
  --line: #3a4a40;
  --line-strong: #557062;
  --accent: #a7d4b5;
  --focus: #94bfff;
  --selection: #2f4a3b;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --page: #151d19;
    --surface: #1d2922;
    --ink: #e2e9e4;
    --ink-soft: #c9d3cc;
    --muted: #b1bfb5;
    --line: #3a4a40;
    --line-strong: #557062;
    --accent: #a7d4b5;
    --focus: #94bfff;
    --selection: #2f4a3b;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-width: 0; }

body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--page);
  color: var(--ink);
  line-height: 1.7;
}

::selection { background: var(--selection); color: var(--ink); }

a { color: inherit; text-underline-offset: 0.2em; text-decoration-thickness: 1px; }

a:focus-visible, select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 4px;
  border-radius: 4px;
}

.wrap { width: min(100% - 3rem, 56rem); margin-inline: auto; }

.skip-link {
  position: absolute;
  z-index: 1;
  left: 1rem;
  top: 0;
  padding: 0.65rem 1rem;
  background: var(--surface);
  color: var(--ink);
  transform: translateY(-150%);
}

.skip-link:focus { transform: translateY(0.5rem); }

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2xs) var(--space-l);
  padding-top: clamp(1.25rem, 4vw, 2.5rem);
}

.wordmark {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: 0.005em;
  text-decoration: none;
}

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

.wordmark-mark {
  flex: none;
  width: 0;
  height: 0;
  border: 0.22em solid var(--accent);
  border-radius: 50%;
}

.header-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  min-width: 0;
  gap: var(--space-2xs) var(--space-m);
  margin-left: auto;
}

.header-tools > a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: 0.25rem;
  color: var(--muted);
  font-size: 0.875rem;
  text-decoration: none;
}

.header-tools > a:hover { color: var(--accent); text-decoration: underline; }

.theme-control { display: inline-flex; align-items: center; }
.theme-control select {
  min-height: 44px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.35rem 0.6rem;
  background: var(--page);
  color: var(--muted);
  font: inherit;
  font-size: 0.875rem;
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

main { flex: 1; }

/* Intro */
.intro { padding-block: clamp(3.5rem, 9vw, 7rem) clamp(3rem, 6vw, 4.5rem); }

.eyebrow {
  margin: 0 0 var(--space-m);
  color: var(--muted);
  font-size: var(--step--1);
  font-weight: 500;
  letter-spacing: 0.14em;
}

h1 {
  margin: 0 0 0 -0.035em;
  font-family: var(--font-serif);
  font-size: var(--step-display);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.title-dot { color: var(--accent); }

.intro-copy {
  max-width: 32em;
  margin: var(--space-l) 0 0;
  color: var(--ink-soft);
  font-family: var(--font-serif);
  font-size: var(--step-1);
  line-height: 1.75;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}

/* Projects */
.links-section { padding-bottom: clamp(3rem, 6vw, 5rem); }

h2 {
  display: flex;
  align-items: center;
  gap: var(--space-m);
  margin: 0 0 var(--space-l);
  color: var(--muted);
  font-size: var(--step--1);
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.14em;
}

h2::after {
  content: "";
  flex: 1;
  min-width: var(--space-xl);
  border-top: 1px solid var(--line);
}

:lang(en) .eyebrow, :lang(en) h2 { text-transform: uppercase; letter-spacing: 0.12em; }

/* Noto Serif CJK maps curly quotes to full-width glyphs; use its proportional (pwid) forms in English. */
:lang(en) { font-variant-east-asian: proportional-width; }

.link-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-m); }

.link-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: clamp(1.25rem, 2.5vw, 1.5rem);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--surface);
  transition: border-color 160ms ease;
}

.link-card::before {
  content: "";
  width: 1.5rem;
  margin-bottom: var(--space-l);
  border-top: 2px solid var(--accent);
}

.link-card:focus-within { border-color: var(--accent); }

.card-heading { margin-bottom: var(--space-xl); }

h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: var(--step-2);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.01em;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.card-actions { display: flex; flex-direction: column; margin-top: auto; }

.action-link {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  min-width: 0;
  min-height: 44px;
  column-gap: 0.3rem;
  padding-block: var(--space-xs);
  border-top: 1px solid var(--line);
  color: var(--accent);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.5;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.action-link > span:last-child {
  margin-left: auto;
  padding-left: 0.5rem;
  transition: transform 160ms ease;
}

.action-link:hover { text-decoration: underline; }
.action-link:focus-visible { outline-offset: 2px; }

.link-note { color: var(--muted); font-size: 0.85em; }

.action-link.secondary { color: var(--muted); }

@media (hover: hover) {
  .link-card:hover { border-color: var(--line-strong); }
  .action-link:hover > span:last-child { transform: translate(2px, -2px); }
  .action-link[href^="/"]:hover > span:last-child { transform: translateX(2px); }
}

@media (min-width: 40em) {
  .link-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .link-card:first-child { grid-column: 1 / -1; }
}

@media (min-width: 60em) {
  .link-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .link-card:first-child { grid-column: auto; }
}

/* Footer */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-xs) var(--space-m);
  padding-block: var(--space-l) var(--space-xl);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: var(--step--1);
}

.site-footer > span:first-child {
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 0.9375rem;
  font-weight: 600;
}

/* 404 */
.not-found { padding-block: clamp(4rem, 12vw, 8rem); }
.not-found h1 { font-size: clamp(4rem, 3rem + 8vw, 7rem); }
.not-found p {
  margin: var(--space-l) 0 var(--space-s);
  color: var(--ink-soft);
  font-family: var(--font-serif);
  font-size: var(--step-1);
}
.back-link { display: inline-flex; align-items: center; min-height: 44px; color: var(--accent); font-weight: 500; }

@media (max-width: 36rem) {
  .wrap { width: calc(100% - 2.5rem); }
  .header-tools { flex-basis: 100%; justify-content: flex-start; margin-left: -0.25rem; gap: var(--space-2xs) var(--space-s); }
  .theme-control select { font-size: 1rem; }
  .card-heading { margin-bottom: var(--space-l); }
  .link-card::before { margin-bottom: var(--space-m); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  .action-link:hover > span:last-child { transform: none !important; }
}

@media (forced-colors: active) {
  .link-card { border-color: CanvasText; }
}
