/*
 * CJ的代码小站 — 全站样式
 * 无外部依赖、无网络字体；深浅色跟随系统。
 */

:root {
  color-scheme: light dark;
  --bg: #fbfaf7;
  --fg: #1f1f21;
  --muted: #5a5a62;
  --rule: #dedbd3;
  --accent: #7a4a1d;
  --mark: #f0e7d8;
  --width: 720px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181a;
    --fg: #e9e7e2;
    --muted: #a8a59e;
    --rule: #34363b;
    --accent: #e2b27c;
    --mark: #2a2620;
  }
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans CJK SC",
    "Source Han Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    sans-serif;
  font-size: 1.0625rem;
  line-height: 1.75;
}

.site-header,
main,
.site-footer {
  max-width: var(--width);
  margin-inline: auto;
  padding-inline: 1.25rem;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1;
  padding: 0.5rem 0.75rem;
  background: var(--fg);
  color: var(--bg);
  text-decoration: none;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.25rem 1.5rem;
  padding-block: 1.75rem 1rem;
  border-bottom: 1px solid var(--rule);
}

.site-title {
  color: var(--fg);
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
}

.site-header nav {
  display: flex;
  gap: 1.25rem;
  font-size: 0.9375rem;
}

main {
  padding-block: 2.5rem 3rem;
}

h1,
h2,
h3 {
  line-height: 1.35;
  letter-spacing: 0.005em;
}

h1 {
  margin: 0 0 0.6rem;
  font-size: clamp(1.65rem, 1.4rem + 1vw, 1.95rem);
  font-weight: 600;
}

h2 {
  margin: 2.4rem 0 0.6rem;
  font-size: 1.2rem;
  font-weight: 600;
}

h3 {
  margin: 1.8rem 0 0.4rem;
  font-size: 1.05rem;
}

p {
  margin: 0.85em 0;
}

ul,
ol {
  margin: 0.85em 0;
  padding-left: 1.5em;
}

li {
  margin: 0.35em 0;
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

a:hover {
  text-decoration-thickness: 2px;
}

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

.lead {
  font-size: 1.125rem;
}

.page-meta,
.note-date {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.note-list {
  margin: 2.25rem 0 0;
  padding: 0;
  list-style: none;
}

.note-list li {
  margin: 0;
  padding-block: 1.3rem;
  border-top: 1px solid var(--rule);
}

.note-list li:last-child {
  border-bottom: 1px solid var(--rule);
}

.note-title {
  font-size: 1.125rem;
  font-weight: 600;
}

.note-summary {
  margin: 0.3rem 0 0.25rem;
  color: var(--muted);
}

.note-date {
  font-size: 0.85rem;
}

blockquote {
  margin: 1.5rem 0;
  padding: 0.15rem 0 0.15rem 1.1rem;
  border-left: 3px solid var(--rule);
  color: var(--muted);
}

blockquote p {
  margin: 0.5em 0;
}

code {
  padding: 0.1em 0.3em;
  border-radius: 3px;
  background: var(--mark);
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  font-size: 0.9em;
}

hr {
  margin: 2.5rem 0;
  border: 0;
  border-top: 1px solid var(--rule);
}

.site-footer {
  margin-top: 3.5rem;
  padding-block: 1.5rem 2.5rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-size: 0.875rem;
}

.site-footer p {
  margin: 0.25rem 0;
}

.not-found {
  padding-block: 2rem 1rem;
}

.not-found h1 {
  font-size: clamp(2.5rem, 2rem + 2vw, 3.25rem);
  margin-bottom: 0.25rem;
}

@media (max-width: 480px) {
  body {
    font-size: 1rem;
  }

  .site-header {
    padding-block: 1.25rem 0.9rem;
  }

  .site-header nav {
    gap: 1rem;
  }

  main {
    padding-block: 2rem 2.5rem;
  }
}

@media print {
  :root {
    --bg: #fff;
    --fg: #000;
    --muted: #333;
    --rule: #999;
    --accent: #000;
    --mark: #eee;
  }

  body {
    font-size: 11pt;
    line-height: 1.6;
  }

  .skip-link,
  .site-header nav {
    display: none;
  }

  .site-header,
  main,
  .site-footer {
    max-width: none;
    padding-inline: 0;
  }

  a {
    text-decoration: none;
  }

  main a[href^="http"]::after {
    content: "（" attr(href) "）";
    font-size: 0.85em;
  }

  h2,
  h3 {
    break-after: avoid;
  }

  blockquote,
  li {
    break-inside: avoid;
  }
}
