/* ==========================================================================
   SSG — Style
   Order: Tokens → Reset → Base → Layout → Typography → Components → Utils
   ========================================================================== */

/* ==========================================================================
   1. Design Tokens
   ========================================================================== */

:root {
  /* Color — light */
  --color-bg: #ffffff;
  --color-bg-subtle: #f7f7f8;
  --color-bg-elevated: #ffffff;
  --color-fg: #111111;
  --color-fg-muted: #666666;
  --color-fg-subtle: #767676;
  --color-border: rgba(0, 0, 0, 0.08);
  --color-border-strong: rgba(0, 0, 0, 0.16);
  --color-accent: #2563eb;
  --color-accent-hover: #1d4ed8;
  --color-accent-fg: #ffffff;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI Variable",
               "Segoe UI", "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei UI", "Microsoft YaHei", "Source Han Sans SC",
               "Noto Sans CJK SC", "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Source Serif Pro", Georgia,
                "Songti SC", "STSong", "Noto Serif CJK SC", "SimSun", serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo,
               "Cascadia Code", "JetBrains Mono", Consolas,
               "Liberation Mono", "Courier New", monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 2rem;
  --text-4xl: 2.5rem;

  --leading-tight: 1.3;
  --leading-normal: 1.6;
  --leading-relaxed: 1.75;

  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  /* Shadow */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08);

  /* Motion */
  --duration-fast: 150ms;
  --duration-base: 250ms;
  --duration-slow: 400ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  /* Layout */
  /* Breakpoints (used in media queries): 640 / 768 / 1024 / 1280 */
  --content-width: 720px;
  --wide-width: 1080px;
  --page-padding: 1.25rem;
  --header-height: 60px;

  /* Motion — extended */
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-emphasized: cubic-bezier(0.2, 0, 0, 1);
  --duration-instant: 80ms;
}

[data-theme="dark"] {
  --color-bg: #0e0e10;
  --color-bg-subtle: #1a1a1c;
  --color-bg-elevated: #1f1f22;
  --color-fg: #e6e6e6;
  --color-fg-muted: #a0a0a0;
  --color-fg-subtle: #8a8a8a;
  --color-border: rgba(255, 255, 255, 0.08);
  --color-border-strong: rgba(255, 255, 255, 0.16);
  --color-accent: #60a5fa;
  --color-accent-hover: #93c5fd;
  --color-accent-fg: #0e0e10;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);
}

@media (min-width: 768px) {
  :root { --page-padding: 2rem; }
}

/* ==========================================================================
   2. Reset
   ========================================================================== */

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

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

body, h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd {
  margin: 0;
}

img, picture, svg, video {
  display: block;
  max-width: 100%;
  height: auto;
}

button, input, select, textarea { font: inherit; }

a { color: inherit; }

input, textarea, button {
  -webkit-appearance: none;
  appearance: none;
}

/* ==========================================================================
   3. Base
   ========================================================================== */

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  color: var(--color-fg);
  background: var(--color-bg);
  font-feature-settings: "kern", "liga", "calt", "ss01";
  font-kerning: normal;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--duration-base) var(--ease-out),
              color var(--duration-base) var(--ease-out);
}

/* ==========================================================================
   4. Layout — Containers
   ========================================================================== */

.container {
  width: 100%;
  max-width: var(--wide-width);
  margin: 0 auto;
  padding-left: var(--page-padding);
  padding-right: var(--page-padding);
}

.container--narrow { max-width: var(--content-width); }
.container--wide   { max-width: var(--wide-width); }
.container--full   { max-width: none; padding-left: 0; padding-right: 0; }

/* ==========================================================================
   5. Layout — Page
   ========================================================================== */

.site-header { flex: 0 0 auto; }
.site-footer { flex: 0 0 auto; }

main {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: var(--space-8) var(--page-padding) var(--space-16);
}

main > * + * { margin-top: var(--space-8); }

@media (min-width: 768px) {
  main {
    padding-top: var(--space-10);
  }
}

@media (min-width: 1024px) {
  main {
    padding-top: var(--space-12);
  }
}

/* ==========================================================================
   6. Layout — Header
   ========================================================================== */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--color-bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-bottom: 1px solid var(--color-border);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  height: var(--header-height);
}

.site-header__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: var(--weight-semibold);
  font-size: var(--text-base);
  color: var(--color-fg);
  text-decoration: none;
  letter-spacing: -0.01em;
  white-space: nowrap;
  transition: color var(--duration-fast) var(--ease-out);
}

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

.site-header__mark {
  display: inline-block;
  width: 22px;
  height: 22px;
  max-width: none;
  flex-shrink: 0;
  color: var(--color-accent);
}

.site-header__name { line-height: 1; }

.site-header__nav {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  margin-left: auto;
}

.site-header__nav a {
  color: var(--color-fg-muted);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  padding: var(--space-1) 0;
  transition: color var(--duration-fast) var(--ease-out);
}

.site-header__nav a:hover,
.site-header__nav a[aria-current="page"] { color: var(--color-fg); }

.site-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ==========================================================================
   7. Layout — Mobile Nav
   ========================================================================== */

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-fg-muted);
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}

.nav-toggle:hover {
  color: var(--color-fg);
  border-color: var(--color-border-strong);
}

.nav-toggle:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.nav-toggle__icon { width: 18px; height: 18px; }

@media (max-width: 639px) {
  .nav-toggle { display: inline-flex; }

  .site-header__nav {
    position: fixed;
    inset: var(--header-height) 0 auto 0;
    margin: 0;
    padding: var(--space-4) var(--page-padding) var(--space-6);
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration-base) var(--ease-out),
                transform var(--duration-base) var(--ease-out);
    box-shadow: var(--shadow-md);
    visibility: hidden;
    transition: opacity var(--duration-base) var(--ease-out),
                transform var(--duration-base) var(--ease-out),
                visibility 0s linear var(--duration-base);
  }

  .site-header__nav[data-open="true"] {
    visibility: visible;
    transition: opacity var(--duration-base) var(--ease-out),
                transform var(--duration-base) var(--ease-out),
                visibility 0s;
  }

  .site-header__nav a {
    padding: var(--space-3) 0;
    font-size: var(--text-base);
    border-bottom: 1px solid var(--color-border);
  }

  .site-header__nav a:last-child { border-bottom: none; }
}

/* ==========================================================================
   8. Layout — Hero
   ========================================================================== */

.hero {
  padding: var(--space-12) 0 var(--space-8);
  text-align: left;
}

.hero__eyebrow {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-3);
}

.hero h1 {
  font-size: clamp(2rem, 5vw + 1rem, 2.75rem);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  letter-spacing: -0.025em;
  margin: 0 0 var(--space-4);
  text-wrap: balance;
}

.hero p {
  color: var(--color-fg-muted);
  font-size: clamp(1rem, 1.5vw + 0.75rem, 1.125rem);
  line-height: var(--leading-relaxed);
  margin: 0 0 var(--space-6);
  max-width: 44ch;
}

.hero .actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

@media (min-width: 768px) {
  .hero { padding: var(--space-16) 0 var(--space-12); }
  .hero--centered { text-align: center; }
  .hero--centered p { margin-left: auto; margin-right: auto; }
  .hero--centered .actions { justify-content: center; }
}

/* ==========================================================================
   9. Layout — Post List
   ========================================================================== */

.latest { margin-top: var(--space-8); }

.post-list {
  display: grid;
  gap: var(--space-2);
  list-style: none;
  padding: 0;
  margin: 0;
}

.post-list--cards {
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 768px) {
  .post-list--cards {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

/* ==========================================================================
   10. Layout — Footer
   ========================================================================== */

.site-footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-8) 0;
  margin-top: var(--space-16);
  color: var(--color-fg-muted);
  font-size: var(--text-sm);
}

.site-footer__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  text-align: center;
}

.site-footer p { margin: 0; }

.site-footer__links {
  display: flex;
  gap: var(--space-5);
  flex-wrap: wrap;
  justify-content: center;
}

.site-footer__links a {
  color: var(--color-fg-muted);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out);
}

.site-footer__links a:hover { color: var(--color-fg); }

@media (min-width: 640px) {
  .site-footer__inner {
    flex-direction: row;
    justify-content: space-between;
    text-align: left;
  }
}

/* ==========================================================================
   11. Typography — Headings
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  color: var(--color-fg);
  line-height: var(--leading-tight);
  letter-spacing: -0.01em;
  font-weight: var(--weight-semibold);
  text-wrap: balance;
}

h1 {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.02em;
}

h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }

h5, h6 {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-fg-muted);
}

h1 + *, h2 + *, h3 + *, h4 + * { margin-top: var(--space-3); }

main > h1 {
  margin: var(--space-8) 0 var(--space-6);
  letter-spacing: -0.02em;
}

/* ==========================================================================
   12. Typography — Body
   ========================================================================== */

p {
  margin: 0;
  line-height: var(--leading-relaxed);
}

.content {
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  text-autospace: normal;
}

.content > * + * { margin-top: 1.1em; }

.content p {
  text-align: justify;
  text-justify: inter-ideograph;
}

.content > p:first-of-type {
  font-size: 1.05em;
  color: var(--color-fg);
}

@supports not (text-autospace: normal) {
  .content p, .content li { word-spacing: 0.02em; }
}

.content strong {
  font-weight: var(--weight-semibold);
  color: var(--color-fg);
}

.content em { font-style: italic; }

.content del {
  color: var(--color-fg-subtle);
  text-decoration: line-through;
}

.content mark {
  background: color-mix(in srgb, var(--color-accent) 25%, transparent);
  color: var(--color-fg);
  padding: 0.05em 0.25em;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   13. Typography — Headings in content
   ========================================================================== */

.content h2 { margin-top: var(--space-12); margin-bottom: var(--space-3); }
.content h3 { margin-top: var(--space-10); margin-bottom: var(--space-2); }
.content h4 { margin-top: var(--space-8);  margin-bottom: var(--space-2); }
.content h5,
.content h6 { margin-top: var(--space-6);  margin-bottom: var(--space-2); }

.content h2:first-child,
.content h3:first-child,
.content h4:first-child { margin-top: 0; }

/* ==========================================================================
   14. Typography — Lists
   ========================================================================== */

.content ul,
.content ol {
  padding-left: 1.6em;
  margin: 1.1em 0;
}

.content li { margin: 0.4em 0; line-height: var(--leading-relaxed); }
.content li > p { margin: 0.4em 0; }

.content li::marker { color: var(--color-fg-subtle); }

.content ul ul,
.content ol ol,
.content ul ol,
.content ol ul { margin: 0.3em 0; }

.content input[type="checkbox"] {
  margin-right: 0.4em;
  vertical-align: middle;
}

.content li:has(> input[type="checkbox"]) {
  list-style: none;
  margin-left: -1.4em;
}

/* ==========================================================================
   15. Typography — Blockquote
   ========================================================================== */

.content blockquote {
  margin: 1.5em 0;
  padding: var(--space-3) var(--space-5);
  border-left: 3px solid var(--color-accent);
  background: var(--color-bg-subtle);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--color-fg-muted);
  font-style: normal;
}

.content blockquote p {
  margin: 0.4em 0;
  line-height: var(--leading-relaxed);
}

.content blockquote p:first-child { margin-top: 0; }
.content blockquote p:last-child  { margin-bottom: 0; }

.content blockquote cite {
  display: block;
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-fg-subtle);
  font-style: normal;
}

.content blockquote cite::before { content: "— "; }

/* ==========================================================================
   16. Typography — Code
   ========================================================================== */

.content code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
  word-break: break-word;
}

.content a code { color: inherit; }

.content pre {
  margin: 1.5em 0;
  padding: var(--space-4) var(--space-5);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  -webkit-overflow-scrolling: touch;
}

.content pre code {
  background: transparent;
  border: none;
  padding: 0;
  font-size: inherit;
  color: inherit;
  white-space: pre;
}

.content pre code .chroma { background: transparent; }

.content pre[data-line-numbers] { counter-reset: line; }

.content pre[data-line-numbers] code > .line::before {
  counter-increment: line;
  content: counter(line);
  display: inline-block;
  width: 2em;
  margin-right: 1em;
  color: var(--color-fg-subtle);
  text-align: right;
  user-select: none;
}

/* ==========================================================================
   17. Typography — Tables
   ========================================================================== */

.content table {
  width: 100%;
  margin: 1.5em 0;
  border-collapse: collapse;
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  display: block;
  overflow-x: auto;
}

.content thead { border-bottom: 2px solid var(--color-border-strong); }

.content th,
.content td {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

.content th {
  font-weight: var(--weight-semibold);
  color: var(--color-fg);
  white-space: nowrap;
}

.content tbody tr:hover { background: var(--color-bg-subtle); }
.content td code { white-space: nowrap; }

/* ==========================================================================
   18. Typography — Links
   ========================================================================== */

.content a {
  color: var(--color-accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--color-accent) 35%, transparent);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
  transition: color var(--duration-fast) var(--ease-out),
              text-decoration-color var(--duration-fast) var(--ease-out);
}

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

/* ==========================================================================
   19. Typography — Media
   ========================================================================== */

.content img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1.8em auto;
  border-radius: var(--radius-md);
}

.content p > em:only-child {
  display: block;
  margin-top: -1em;
  margin-bottom: 1.5em;
  font-size: var(--text-sm);
  color: var(--color-fg-subtle);
  text-align: center;
  font-style: normal;
}

.content figure { margin: 1.8em 0; }
.content figure img { margin: 0 auto; }

.content figcaption {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-fg-subtle);
  text-align: center;
}

.content hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-10) auto;
  width: 40%;
}

/* ==========================================================================
   20. Typography — Details
   ========================================================================== */

.content kbd {
  font-family: var(--font-mono);
  font-size: 0.8em;
  padding: 0.15em 0.4em;
  border: 1px solid var(--color-border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  background: var(--color-bg-subtle);
  color: var(--color-fg);
}

.content abbr[title] {
  text-decoration: underline dotted;
  text-underline-offset: 0.2em;
  cursor: help;
}

.content .footnotes {
  margin-top: var(--space-12);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border);
  font-size: var(--text-sm);
  color: var(--color-fg-muted);
}

.content .footnotes ol { padding-left: 1.2em; }

.content sup a {
  text-decoration: none;
  font-size: 0.75em;
  padding: 0 0.15em;
}

/* ==========================================================================
   21. Components — Button
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-accent);
  color: var(--color-accent-fg);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  transition: background-color var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}

.btn:hover { background: var(--color-accent-hover); }
.btn:active { transform: translateY(1px); }

.btn.ghost {
  background: transparent;
  color: var(--color-fg);
  border: 1px solid var(--color-border-strong);
}

.btn.ghost:hover {
  background: var(--color-bg-subtle);
  border-color: var(--color-fg-muted);
}

/* ==========================================================================
   22. Components — Theme Toggle
   ========================================================================== */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-fg-muted);
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              background-color var(--duration-fast) var(--ease-out);
}

.theme-toggle:hover {
  color: var(--color-fg);
  border-color: var(--color-border-strong);
  background: var(--color-bg-subtle);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.theme-toggle__icon { display: none; width: 18px; height: 18px; }
.theme-toggle__icon svg { width: 100%; height: 100%; }

html[data-theme-preference="auto"] .theme-toggle__icon[data-theme-icon="auto"],
html[data-theme-preference="light"] .theme-toggle__icon[data-theme-icon="light"],
html[data-theme-preference="dark"] .theme-toggle__icon[data-theme-icon="dark"] {
  display: block;
}

/* ==========================================================================
   23. Components — Post Card
   ========================================================================== */

.post-card {
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-5) 0;
}

.post-card:last-child { border-bottom: none; }

.post-card a {
  display: block;
  text-decoration: none;
  color: inherit;
}

.post-card h2 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  margin: 0 0 var(--space-1);
  color: var(--color-fg);
  line-height: var(--leading-tight);
  transition: color var(--duration-fast) var(--ease-out);
}

.post-card a:hover h2 { color: var(--color-accent); }

.post-card time {
  display: block;
  color: var(--color-fg-subtle);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
  margin-bottom: var(--space-1);
}

.post-card p {
  color: var(--color-fg-muted);
  margin: 0;
  font-size: var(--text-sm);
}

.post-list--cards .post-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  background: var(--color-bg-elevated);
  transition: border-color var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out),
              box-shadow var(--duration-base) var(--ease-out);
}

.post-list--cards .post-card:hover {
  border-color: var(--color-border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ==========================================================================
   24. Components — Article
   ========================================================================== */

.post h1,
.page h1 {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  margin: 0 0 var(--space-3);
  letter-spacing: -0.02em;
}

.post time {
  display: block;
  color: var(--color-fg-subtle);
  font-size: var(--text-sm);
  margin-bottom: var(--space-8);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   24a. Components — Tag
   ========================================================================== */

.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.15em 0.6em;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--color-fg-muted);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              background-color var(--duration-fast) var(--ease-out);
}

a.tag:hover {
  color: var(--color-fg);
  border-color: var(--color-border-strong);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  list-style: none;
  padding: 0;
  margin: 0;
}

/* ==========================================================================
   24b. Components — Post Meta
   ========================================================================== */

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-fg-subtle);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.post-meta__item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  white-space: nowrap;
  flex-shrink: 0;
}

.post-meta__item svg {
  display: inline-block;
  width: 14px;
  height: 14px;
  max-width: none;
  flex-shrink: 0;
  opacity: 0.8;
}

.post-meta__item time {
  display: inline;
  white-space: nowrap;
}

.post-meta__sep {
  color: var(--color-border-strong);
}

.post-meta .tag {
  flex-shrink: 0;
}

/* ==========================================================================
   24c. Components — Pagination
   ========================================================================== */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-12);
  flex-wrap: wrap;
}

.pagination__link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  color: var(--color-fg-muted);
  text-decoration: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              background-color var(--duration-fast) var(--ease-out);
}

.pagination__link:hover {
  color: var(--color-fg);
  border-color: var(--color-border-strong);
  background: var(--color-bg-subtle);
}

.pagination__link[aria-current="page"] {
  color: var(--color-accent-fg);
  background: var(--color-accent);
  border-color: var(--color-accent);
}

.pagination__link[aria-disabled="true"] {
  color: var(--color-fg-subtle);
  pointer-events: none;
  opacity: 0.5;
}

.pagination__ellipsis {
  color: var(--color-fg-subtle);
  padding: 0 var(--space-1);
}

/* ==========================================================================
   24d. Components — TOC
   ========================================================================== */

.toc {
  margin: 0 0 var(--space-8);
  padding: var(--space-4) var(--space-5);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}

.toc__title {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-fg-muted);
  margin: 0 0 var(--space-3);
}

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

.toc__list .toc__list {
  margin-left: var(--space-4);
  margin-top: var(--space-1);
}

.toc__item { margin: var(--space-1) 0; }

.toc__link {
  color: var(--color-fg-muted);
  text-decoration: none;
  line-height: var(--leading-normal);
  transition: color var(--duration-fast) var(--ease-out);
}

.toc__link:hover { color: var(--color-fg); }

.toc__link.is-active {
  color: var(--color-accent);
  font-weight: var(--weight-medium);
}

/* 阅读进度条（配合 TOC 使用，可选） */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: var(--color-accent);
  z-index: 100;
  transition: width 100ms linear;
}

/* ==========================================================================
   24e. Components — Callout
   ========================================================================== */

.callout {
  display: block;
  margin: 1.5em 0;
  padding: var(--space-3) var(--space-5);
  border-left: 3px solid var(--color-accent);
  background: var(--color-bg-subtle);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--color-fg);
  font-style: normal;
}

.callout > *:first-child { margin-top: 0; }
.callout > *:last-child  { margin-bottom: 0; }

.callout__title {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-2);
  color: var(--color-accent);
}

.callout__title svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.callout--note    { border-left-color: #3b82f6; }
.callout--tip     { border-left-color: #10b981; }
.callout--warning { border-left-color: #f59e0b; }
.callout--danger  { border-left-color: #ef4444; }

.callout--note    .callout__title { color: #3b82f6; }
.callout--tip     .callout__title { color: #047857; } /* 4.6:1 */
.callout--warning .callout__title { color: #b45309; } /* 4.7:1 */
.callout--danger  .callout__title { color: #ef4444; }

[data-theme="dark"] .callout--note    .callout__title { color: #60a5fa; }
[data-theme="dark"] .callout--tip     .callout__title { color: #047857; } /* 4.6:1 */
[data-theme="dark"] .callout--warning .callout__title { color: #b45309; } /* 4.7:1 */
[data-theme="dark"] .callout--danger  .callout__title { color: #f87171; }

/* ==========================================================================
   24f. Components — Code Block (with copy)
   ========================================================================== */

.code-block {
  position: relative;
  margin: 1.5em 0;
}

.code-block pre {
  margin: 0;
  padding-right: calc(var(--space-5) + 44px);
}

.code-block__copy {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-fg-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--duration-fast) var(--ease-out),
              color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out);
}

.code-block:hover .code-block__copy,
.code-block__copy:focus-visible {
  opacity: 1;
}

.code-block__copy:hover {
  color: var(--color-fg);
  border-color: var(--color-border-strong);
}

.code-block__copy svg { width: 16px; height: 16px; }

.code-block__copy.is-copied {
  color: #10b981;
  border-color: #10b981;
}

/* 移动端始终显示复制按钮 */
@media (hover: none) and (pointer: coarse) {
  .code-block__copy { opacity: 1; }
}

/* ==========================================================================
   24g. Components — Empty State
   ========================================================================== */

.empty {
  padding: var(--space-12) var(--space-5);
  text-align: center;
  color: var(--color-fg-muted);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  background: var(--color-bg-subtle);
}

.empty__icon {
  width: 64px;
  height: 64px;
  margin: 0 auto var(--space-4);
  color: var(--color-fg-subtle);
  opacity: 0.5;
}

.empty__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--color-fg);
  margin: 0 0 var(--space-2);
}

.empty__desc {
  margin: 0;
  font-size: var(--text-sm);
}

/* ==========================================================================
   24h. Components — 404
   ========================================================================== */

.page-404 {
  text-align: center;
  padding: var(--space-16) 0;
}

.page-404__code {
  font-size: clamp(4rem, 12vw, 8rem);
  font-weight: var(--weight-bold);
  line-height: 1;
  letter-spacing: -0.04em;
  color: var(--color-fg-subtle);
  margin: 0 0 var(--space-4);
  user-select: none;
}

.page-404__title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  margin: 0 0 var(--space-3);
}

.page-404__desc {
  color: var(--color-fg-muted);
  margin: 0 auto var(--space-8);
  max-width: 44ch;
}

.page-404 .actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
}

/* ==========================================================================
   25. Utils — Focus
   ========================================================================== */

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

/* ==========================================================================
   26. Utils — Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  /* 关闭 View Transitions */
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none !important;
  }

  /* 关闭滚动进入，直接显示 */
  .js [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
  }

  /* 关闭 hover 位移 */
  .post-list--cards .post-card:hover,
  a.tag:hover,
  .btn:active,
  .theme-toggle:active {
    transform: none !important;
  }
}

/* ==========================================================================
   27. Utils — Touch
   ========================================================================== */

@media (hover: none) and (pointer: coarse) {
  .site-header__nav a,
  .site-footer__links a,
  .btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  .post-list--cards .post-card:hover {
    transform: none;
    box-shadow: none;
  }
}

/* ==========================================================================
   28. Print
   ========================================================================== */

@media print {
  :root {
    --color-bg: #fff;
    --color-fg: #000;
    --color-fg-muted: #333;
    --color-border: #ccc;
    --color-accent: #000;
  }

  .site-header,
  .site-footer,
  .theme-toggle,
  .nav-toggle,
  .actions { display: none !important; }

  body { display: block; }
  main { max-width: none; padding: 0; }

  .content a {
    color: #000;
    text-decoration: underline;
  }

  .content a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    color: #555;
  }

  .content pre {
    border: 1px solid #ccc;
    page-break-inside: avoid;
    white-space: pre-wrap;
    word-break: break-word;
  }

  .content h1, .content h2, .content h3 { page-break-after: avoid; }
  .content img { page-break-inside: avoid; }
}

/* ==========================================================================
   29. Motion — View Transitions
   ========================================================================== */

@view-transition {
  navigation: auto;
}

/* 默认：整个页面淡入淡出 + 轻微上移 */
::view-transition-old(root) {
  animation: vt-fade-out var(--duration-base) var(--ease-emphasized);
}

::view-transition-new(root) {
  animation: vt-fade-in var(--duration-slow) var(--ease-emphasized);
}

@keyframes vt-fade-out {
  to { opacity: 0; }
}

@keyframes vt-fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 主题切换：圆形扩散（只在支持 View Transitions 的浏览器生效） */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: var(--duration-slow);
}

/* Header 保持固定，不参与过渡 */
.site-header {
  view-transition-name: site-header;
}

::view-transition-old(site-header),
::view-transition-new(site-header) {
  animation: none;
}

/* ==========================================================================
   30. Motion — Entrance
   ========================================================================== */

@keyframes enter-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes enter-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* 由 JS 加上 .is-entering，避免无 JS 时内容不可见 */
.enter {
  opacity: 1;
}

.js .enter {
  opacity: 0;
}

.js .enter.is-entering {
  animation: enter-up var(--duration-slow) var(--ease-out) both;
}

/* 依次延迟，最多到第 6 个 */
.js .enter[data-enter-delay="1"] { animation-delay: 60ms; }
.js .enter[data-enter-delay="2"] { animation-delay: 120ms; }
.js .enter[data-enter-delay="3"] { animation-delay: 180ms; }
.js .enter[data-enter-delay="4"] { animation-delay: 240ms; }
.js .enter[data-enter-delay="5"] { animation-delay: 300ms; }
.js .enter[data-enter-delay="6"] { animation-delay: 360ms; }


/* ==========================================================================
   31. Motion — Scroll Reveal
   ========================================================================== */

.js [data-reveal] {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
  will-change: opacity, transform;
}

.js [data-reveal].is-revealed {
  opacity: 1;
  transform: translateY(0);
  will-change: auto;
}

/* 卡片依次延迟 */
.js [data-reveal][data-reveal-delay="1"] { transition-delay: 60ms; }
.js [data-reveal][data-reveal-delay="2"] { transition-delay: 120ms; }
.js [data-reveal][data-reveal-delay="3"] { transition-delay: 180ms; }
.js [data-reveal][data-reveal-delay="4"] { transition-delay: 240ms; }

/* ==========================================================================
   32. Motion — Micro Interactions
   ========================================================================== */

/* 链接下划线从右滑入 */
.content a {
  background-image: linear-gradient(currentColor, currentColor);
  background-repeat: no-repeat;
  background-position: 0 100%;
  background-size: 100% 1px;
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-out),
              background-size var(--duration-fast) var(--ease-out),
              background-position var(--duration-fast) var(--ease-out);
}

.content a:hover {
  background-size: 0% 1px;
  background-position: 100% 100%;
}

/* 按钮按下 */
.btn:active {
  transform: translateY(1px) scale(0.99);
}

/* 导航链接下划线 */
.site-header__nav a {
  position: relative;
}

.site-header__nav a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: right;
  transition: transform var(--duration-base) var(--ease-out);
}

.site-header__nav a:hover::after,
.site-header__nav a[aria-current="page"]::after {
  transform: scaleX(1);
  transform-origin: left;
}

/* 主题切换按钮按下回弹 */
.theme-toggle:active {
  transform: scale(0.94);
  transition: transform var(--duration-instant) var(--ease-spring);
}

/* Tag hover 轻微上浮 */
.tag {
  transition: color var(--duration-fast) var(--ease-out),
              border-color var(--duration-fast) var(--ease-out),
              transform var(--duration-fast) var(--ease-out);
}

a.tag:hover {
  transform: translateY(-1px);
}

/* 代码复制按钮出现 */
.code-block__copy {
  transform: translateY(-2px);
}

.code-block:hover .code-block__copy,
.code-block__copy:focus-visible {
  transform: translateY(0);
}

/* ==========================================================================
   33. Motion — Theme Transition
   ========================================================================== */

::view-transition-old(root),
::view-transition-new(root) {
  mix-blend-mode: normal;
}

/* 主题切换时，用 JS 设置 CSS 变量控制扩散中心 */
html.theme-transition::view-transition-old(root),
html.theme-transition::view-transition-new(root) {
  animation-duration: 400ms;
  animation-timing-function: var(--ease-emphasized);
}

html.theme-transition::view-transition-new(root) {
  animation-name: theme-circle-in;
  clip-path: circle(0% at var(--theme-x, 50%) var(--theme-y, 50%));
}

@keyframes theme-circle-in {
  to {
    clip-path: circle(150% at var(--theme-x, 50%) var(--theme-y, 50%));
  }
}

/* ==========================================================================
   34. A11y — Skip Link
   ========================================================================== */

.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-4);
  z-index: 1000;
  padding: var(--space-2) var(--space-4);
  background: var(--color-accent);
  color: var(--color-accent-fg);
  border-radius: var(--radius-md);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  transition: top var(--duration-fast) var(--ease-out);
}

.skip-link:focus,
.skip-link:focus-visible {
  top: var(--space-4);
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ==========================================================================
   35. Home — Fullscreen Hero
   ========================================================================== */

.home-main {
  max-width: none;
  padding: 0;
  margin: 0;
  display: block;
}

.home-main > * + * { margin-top: 0; }

.hero-fullscreen {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--color-bg);
}

.hero-fullscreen__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  transition: opacity 200ms var(--ease-out);
}

.hero-fullscreen__content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 960px;
  padding: 0 var(--page-padding);
  text-align: center;
  pointer-events: none;
  transition: opacity 200ms var(--ease-out);
}

.hero-fullscreen__title {
  font-size: clamp(3rem, 13vw, 9rem);
  font-weight: var(--weight-bold);
  line-height: 0.95;
  letter-spacing: -0.045em;
  margin: 0 0 var(--space-8);
  color: var(--color-fg);
  text-wrap: balance;
}

/* .hero-fullscreen__subtitle {
  font-size: clamp(1rem, 2vw, 1.25rem);
  line-height: var(--leading-relaxed);
  color: var(--color-fg-muted);
  margin: 0 0 var(--space-8);
  text-wrap: balance;
} */

/* canvas 接管后隐藏 DOM 文本 */
.js.hero-ready .hero-fullscreen__title {
  color: transparent;
  user-select: none;
}
/* .js.hero-ready .hero-fullscreen__title,
.js.hero-ready .hero-fullscreen__subtitle {
  color: transparent;
  user-select: none;
} */


.hero-fullscreen__actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
  pointer-events: auto;
}

.hero-fullscreen__scroll-hint {
  position: absolute;
  bottom: var(--space-8);
  left: 50%;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-fg-subtle);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
  animation: scroll-hint 2.4s var(--ease-in-out) infinite;
}

.hero-fullscreen__scroll-hint svg {
  display: block;
  width: 16px;
  height: 16px;
}

@keyframes scroll-hint {
  0%, 100% { transform: translate(-50%, 0); opacity: 0.5; }
  50%      { transform: translate(-50%, 6px); opacity: 1; }
}

/* 内容区 */
.home-latest {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: var(--space-16) var(--page-padding) var(--space-16);
}

.home-latest h2 {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  margin: 0 0 var(--space-4);
}

@media (prefers-reduced-motion: reduce) {
  .hero-fullscreen__scroll-hint { animation: none; }
}

/* 吃豆人 canvas 光标 */
.hero-fullscreen__canvas[data-hero-pacman] {
  cursor: none;
}

@media (hover: none) and (pointer: coarse) {
  .hero-fullscreen__canvas[data-hero-pacman] {
    cursor: auto;
  }
}