/* ==========================================================================
   开源手记 · 样式
   改配色：改 :root 里的变量就够了
   ========================================================================== */

:root {
  --bg: #fafaf7;
  --surface: #ffffff;
  --ink: #15181b;
  --muted: #5d6570;
  --line: #e2e2db;
  --line-strong: #c8c8be;
  --accent: #c2410c;
  --accent-soft: #f7e9e1;
  --hover: #f1f1ea;
  --code-bg: #f4f4ef;
  --max: 1180px;
  --font: "Inter", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei",
    "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "Cascadia Mono", Consolas,
    "Liberation Mono", monospace;
}

:root[data-theme="dark"] {
  --bg: #0e1012;
  --surface: #14171a;
  --ink: #e8e9ea;
  --muted: #99a1ab;
  --line: #262a2e;
  --line-strong: #3b4147;
  --accent: #f08a5d;
  --accent-soft: #2a1a12;
  --hover: #171a1d;
  --code-bg: #171a1d;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 84px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.25s ease, color 0.25s ease;
}

img,
svg { display: block; max-width: 100%; }

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

button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

::selection {
  background: var(--accent);
  color: #fff;
}

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

.skip {
  position: absolute;
  left: -999px;
  top: 8px;
  z-index: 100;
  padding: 8px 14px;
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  text-decoration: none;
}

.skip:focus { left: 12px; }

.wrap {
  width: min(100% - 48px, var(--max));
  margin-inline: auto;
}

/* ---------- 顶栏 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 30px;
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  color: var(--ink);
}

.brand-mark { color: var(--ink); }

.brand-text {
  display: flex;
  flex-direction: column;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.brand-text small {
  margin-top: 3px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.16em;
}

.nav {
  display: flex;
  gap: 26px;
}

.nav a {
  position: relative;
  padding: 3px 0;
  color: var(--muted);
  font-size: 14px;
  transition: color 0.15s ease;
}

.nav a:hover { color: var(--ink); }
.nav a.is-active { color: var(--ink); }

.nav a.is-active::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -2px;
  left: 0;
  height: 1.5px;
  background: var(--ink);
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.search {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  transition: border-color 0.15s ease;
}

.search:focus-within { border-color: var(--line-strong); }

.search-icon {
  width: 14px;
  height: 14px;
  color: var(--muted);
}

.search input {
  width: 112px;
  border: 0;
  outline: 0;
  background: none;
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
}

.search input::placeholder { color: var(--muted); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 4px;
  color: var(--muted);
  transition: color 0.15s ease, background-color 0.15s ease;
}

.icon-btn:hover {
  background: var(--hover);
  color: var(--ink);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.nav-toggle { display: none; }

[data-theme="light"] .i-sun { display: none; }
[data-theme="dark"] .i-moon { display: none; }

/* ---------- 头条 ---------- */
.lead {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
  gap: 64px;
  padding: 48px 0 56px;
  border-bottom: 1px solid var(--line);
}

.cover {
  display: block;
  overflow: hidden;
  border: 1px solid var(--line);
}

.cover img {
  width: 100%;
  height: auto;
  object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.featured .cover:hover img { transform: scale(1.015); }

.kicker {
  margin: 18px 0 0;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.featured h1 {
  margin: 10px 0 0;
  text-wrap: balance;
  font-size: clamp(26px, 3.1vw, 34px);
  font-weight: 700;
  line-height: 1.32;
  letter-spacing: -0.015em;
}

.featured h1 a { transition: color 0.15s ease; }
.featured h1 a:hover { color: var(--accent); }

.dek {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 15.5px;
  line-height: 1.75;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin: 18px 0 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

/* ---------- 最近更新 ---------- */
.recent { padding-top: 2px; }

.recent-title {
  margin: 0 0 14px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.recent-list {
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
  list-style: none;
}

.recent-list li { border-bottom: 1px solid var(--line); }

.recent-list a {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 14px;
  padding: 13px 0;
  font-size: 14px;
  line-height: 1.55;
  transition: color 0.15s ease;
}

.recent-list a:hover { color: var(--accent); }

.recent-list time {
  padding-top: 3px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11.5px;
}

/* ---------- 文章列表 ---------- */
.posts { padding-top: 56px; }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.section-head h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.count {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  margin: 22px 0 34px;
  border-bottom: 1px solid var(--line);
}

.filter {
  position: relative;
  padding: 0 0 12px;
  color: var(--muted);
  font-size: 13.5px;
  transition: color 0.15s ease;
}

.filter:hover { color: var(--ink); }
.filter.is-active { color: var(--ink); }

.filter.is-active::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: var(--ink);
}

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 44px 32px;
}

.post {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.post[hidden] { display: none; }

.post-cover {
  display: block;
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.post-cover img {
  width: 100%;
  height: auto;
  object-fit: cover;
  transition: transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.post:hover .post-cover img { transform: scale(1.02); }

.post-tag {
  align-self: flex-start;
  margin-bottom: 8px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.post-tag:hover { text-decoration: underline; }

.post h3 {
  margin: 0;
  font-size: 17.5px;
  text-wrap: balance;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

.post h3 a { transition: color 0.15s ease; }
.post h3 a:hover { color: var(--accent); }

.post p {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.7;
}

.post h3 + p {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.post .meta {
  margin-top: auto;
  padding-top: 12px;
  gap: 14px;
  font-size: 11px;
}

.empty {
  margin: 40px 0 0;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- 合集 ---------- */
.series { padding-top: 72px; }

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

.series-item {
  display: block;
  padding: 26px 28px 28px 0;
  transition: background-color 0.2s ease;
}

.series-item + .series-item {
  padding-left: 28px;
  border-left: 1px solid var(--line);
}

.series-item:hover { background: var(--hover); }

.series-num {
  display: block;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
}

.series-item h3 {
  margin: 10px 0 0;
  font-size: 16.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.series-item p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.65;
}

.series-count {
  display: inline-block;
  margin-top: 14px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
}

/* ---------- 关于 ---------- */
.about {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 64px;
  margin-top: 72px;
  padding: 64px 0 72px;
  border-top: 1px solid var(--line);
}

.about h2 {
  margin: 10px 0 0;
  font-size: 24px;
  letter-spacing: -0.01em;
}

.about p {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.8;
}

.about-side h3 {
  margin: 0 0 10px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.about-side h3 + * { margin-bottom: 30px; }

.links {
  margin: 0 0 30px;
  padding: 0;
  border-top: 1px solid var(--line);
  list-style: none;
}

.links li { border-bottom: 1px solid var(--line); }

.links a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  font-size: 14px;
  transition: color 0.15s ease;
}

.links a::after {
  content: "↗";
  color: var(--muted);
  font-size: 12px;
}

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

.tagcloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tagcloud button {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--muted);
  font-size: 12.5px;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.tagcloud button:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

/* ---------- 页脚 ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 30px 0 40px;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.footer-brand {
  display: flex;
  flex-direction: column;
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

.footer-brand small {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.16em;
}

.footer-nav {
  display: flex;
  gap: 20px;
  color: var(--muted);
  font-size: 13px;
}

.footer-nav a:hover { color: var(--ink); }

.footer-note {
  margin: 0;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11.5px;
}

/* ---------- 文章页 ---------- */
.article {
  max-width: 760px;
  margin-inline: auto;
  padding-top: 44px;
}

.article .kicker { margin-top: 0; }

.article h1 {
  margin: 12px 0 0;
  text-wrap: balance;
  font-size: clamp(28px, 4vw, 38px);
  font-weight: 700;
  line-height: 1.32;
  letter-spacing: -0.02em;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 18px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.article-cover {
  margin-top: 32px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.article-cover img {
  width: 100%;
  height: auto;
}

.prose {
  font-size: 16.5px;
  line-height: 1.9;
}

.prose > :first-child { margin-top: 36px; }
.prose p { margin: 0 0 22px; }

.prose h2 {
  margin: 44px 0 14px;
  font-size: 22px;
  letter-spacing: -0.01em;
}

.prose h3 {
  margin: 32px 0 10px;
  font-size: 17.5px;
}

.prose ul,
.prose ol {
  margin: 0 0 22px;
  padding-left: 22px;
}

.prose li { margin: 6px 0; }

.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.prose blockquote {
  margin: 28px 0;
  padding: 2px 0 2px 20px;
  border-left: 2px solid var(--accent);
  color: var(--muted);
}

.prose blockquote p:last-child { margin-bottom: 0; }

.prose code {
  padding: 2px 5px;
  border-radius: 3px;
  background: var(--code-bg);
  font-family: var(--mono);
  font-size: 0.88em;
}

.prose pre {
  margin: 0 0 24px;
  padding: 18px 20px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--code-bg);
  font-size: 13px;
  line-height: 1.75;
}

.prose pre code {
  padding: 0;
  background: none;
  font-size: inherit;
}

.prose figure { margin: 32px 0; }

.prose figure img {
  width: 100%;
  border: 1px solid var(--line);
}

.prose figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
}

.prose hr {
  margin: 36px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.prose table {
  width: 100%;
  margin: 0 0 24px;
  border-collapse: collapse;
  font-size: 14px;
}

.prose th,
.prose td {
  padding: 8px 12px;
  border: 1px solid var(--line);
  text-align: left;
}

.prose th {
  background: var(--code-bg);
  font-weight: 600;
}

.article-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  font-size: 14px;
}

.article-footer a { color: var(--muted); }
.article-footer a:hover { color: var(--accent); }

/* ---------- 响应式 ---------- */
@media (max-width: 1000px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lead { gap: 44px; }
}

@media (max-width: 820px) {
  .nav {
    position: absolute;
    top: 64px;
    right: 0;
    left: 0;
    display: none;
    flex-direction: column;
    gap: 0;
    padding: 6px 24px 12px;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
  }

  .nav.is-open { display: flex; }

  .nav a {
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
    font-size: 15px;
  }

  .nav a:last-child { border-bottom: 0; }
  .nav a.is-active::after { display: none; }

  .nav-toggle { display: grid; }

  .lead {
    grid-template-columns: minmax(0, 1fr);
    padding-top: 32px;
  }

  .about {
    grid-template-columns: minmax(0, 1fr);
    gap: 36px;
    margin-top: 56px;
    padding: 48px 0 56px;
  }

  .series-grid { grid-template-columns: minmax(0, 1fr); }

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

@media (max-width: 600px) {
  .wrap { width: calc(100% - 32px); }
  .posts { padding-top: 40px; }
  .search { display: none; }
  .grid { grid-template-columns: minmax(0, 1fr); gap: 36px; }
  .filters { gap: 18px; }
  .site-footer { padding-bottom: 32px; }
  .footer-inner { align-items: flex-start; }
}

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

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