/* ============================================================
   Guanqi’s blog
   A quiet, text-first personal blog
   ============================================================ */

:root {
  color-scheme: light;

  --bg: #ffffff;
  --text: #615b5b;
  --text-strong: #121111;
  --text-muted: #7f7978;
  --border: #ecebea;
  --border-strong: #d8d4d3;
  --code-bg: #faf9f9;
  --code-text: #c7254e;
  --icon: #393636;
  --quote-border: #615b5b;
  --selection-bg: #121111;
  --selection-text: #ffffff;

  --sans: "Lato", -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --serif: "Cormorant Garamond", "Baskerville", "Iowan Old Style", "Songti SC",
    "Noto Serif CJK SC", Georgia, "Times New Roman", serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;

  --ease: cubic-bezier(0.22, 0.7, 0.24, 1);
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #121212;
  --text: #b3adac;
  --text-strong: #f1eeee;
  --text-muted: #8f8988;
  --border: #2a2929;
  --border-strong: #3a3838;
  --code-bg: #1b1a1a;
  --code-text: #e39ab0;
  --icon: #c9c3c2;
  --quote-border: #8a8483;
  --selection-bg: #f1eeee;
  --selection-text: #121212;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  background: var(--bg);
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.8;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.2s linear, color 0.2s linear;
}

main {
  flex: 1 0 auto;
}

::selection {
  color: var(--selection-text);
  background: var(--selection-bg);
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color 0.2s linear;
}

a:hover {
  color: var(--text-strong);
}

button {
  font: inherit;
}

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

.skip-link {
  position: absolute;
  top: -100px;
  left: 20px;
  z-index: 100;
  padding: 10px 16px;
  font-family: var(--mono);
  font-size: 12px;
  text-decoration: none;
  color: var(--bg);
  background: var(--text-strong);
  transition: top 0.2s linear;
}

.skip-link:focus {
  top: 12px;
}

.wrap {
  width: 100%;
  max-width: 650px;
  margin: 0 auto;
  padding: 0 20px;
}

.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;
}

/* ---------- 顶部 ---------- */

.site-header {
  padding-top: 72px;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-block;
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text-strong);
  text-decoration: none;
  white-space: nowrap;
}

.brand:hover {
  color: var(--text-strong);
}

.brand-suffix {
  margin-left: 0.08em;
  font-size: 0.84em;
  font-weight: 400;
  letter-spacing: 0;
}

.header-links {
  display: flex;
  align-items: center;
  gap: 22px;
  flex: none;
}

.icon-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  color: var(--icon);
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.2s linear, transform 0.2s var(--ease);
}

.icon-link::after {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 50%;
}

.icon-link:hover {
  color: var(--text-strong);
}

.icon-link svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- 首页 ---------- */

.intro {
  margin: 44px 0 0;
  font-size: 15px;
  line-height: 1.9;
  color: var(--text);
}

.year-group {
  margin: 0;
}

.year-label {
  margin: 52px 0 0;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.6;
  letter-spacing: 0.18em;
  color: var(--text-muted);
}

.year-group:first-of-type .year-label {
  margin-top: 52px;
}

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

.post {
  border-bottom: 1px solid var(--border);
}

.year-group:last-child .post:last-child {
  border-bottom: 0;
}

.post a {
  display: block;
  padding: 38px 0 34px;
  color: inherit;
  text-decoration: none;
}

.post-title {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font-size: 18.5px;
  font-weight: 500;
  line-height: 1.55;
  letter-spacing: 0.005em;
  color: var(--text-strong);
}

.post-arrow {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.2s linear, transform 0.2s var(--ease);
}

.post a:hover .post-arrow,
.post a:focus-visible .post-arrow {
  opacity: 1;
  transform: none;
}

.post-excerpt {
  margin: 11px 0 0;
  font-size: 15px;
  line-height: 1.9;
  color: var(--text);
}

.post-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
  margin: 13px 0 0;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.meta-dot {
  width: 3px;
  height: 3px;
  flex: none;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.65;
}

/* ---------- 文章 ---------- */

.article-head {
  padding: 62px 0 30px;
  border-bottom: 1px solid var(--border);
}

.article-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.article-meta .sep {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.65;
}

.article-head h1 {
  margin: 18px 0 0;
  font-family: var(--sans);
  font-weight: 500;
  font-size: clamp(26px, 4.5vw, 32px);
  line-height: 1.45;
  letter-spacing: -0.01em;
  color: var(--text-strong);
}

.article-lede {
  margin: 14px 0 0;
  font-size: 16px;
  line-height: 1.9;
  color: var(--text);
}

.prose {
  padding: 42px 0 0;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.95;
  letter-spacing: 0.01em;
  color: var(--text);
}

.prose p {
  margin: 0 0 1.6em;
}

.prose h2 {
  margin: 2.5em 0 0.85em;
  font-family: var(--sans);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.6;
  letter-spacing: 0.005em;
  color: var(--text-strong);
}

.prose h2::before {
  display: none;
}

.prose blockquote {
  margin: 2.1em 0;
  padding: 0 0 4px 18px;
  font-size: 17px;
  font-style: italic;
  line-height: 1.8;
  color: var(--text-muted);
  border-left: 2px solid var(--quote-border);
}

.prose blockquote p {
  margin: 0;
  font-size: inherit;
}

.prose ul,
.prose ol {
  margin: 0 0 1.6em;
  padding-left: 1.5em;
}

.prose li {
  margin: 0 0 0.4em;
}

.prose li::marker {
  color: var(--text-muted);
}

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

.prose strong {
  font-weight: 600;
  color: var(--text-strong);
}

.prose em {
  font-style: italic;
}

.prose code {
  padding: 1px 4px;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--code-text);
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 2px;
}

.prose pre {
  margin: 2em 0;
  padding: 22px 24px;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text);
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
}

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

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

.prose a:hover {
  text-decoration-color: var(--text-strong);
}

.article-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px 24px;
  margin-top: 56px;
  padding-top: 26px;
  border-top: 1px solid var(--border);
}

.back-link {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s linear;
}

.back-link:hover {
  color: var(--text-strong);
}

.article-foot-note {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.6;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ---------- 页脚 ---------- */

.site-footer {
  flex: none;
  margin-top: 100px;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 24px;
  padding: 28px 0 72px;
  border-top: 1px solid var(--border);
}

.footer-note {
  margin: 0;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-muted);
}

/* ---------- 载入动效 ---------- */

@keyframes rise {
  from {
    transform: translateY(8px);
  }
  to {
    transform: none;
  }
}

.js [data-reveal] {
  animation: rise 0.6s var(--ease) both;
}

.js .intro {
  animation-delay: 0.04s;
}

.js .post {
  animation-delay: 0.1s;
}

/* ---------- 响应式 ---------- */

@media (max-width: 560px) {
  .site-header {
    padding-top: 42px;
  }

  .header-inner {
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding-bottom: 20px;
  }

  .brand {
    font-size: 30px;
  }

  .header-links {
    gap: 26px;
  }

  .intro {
    margin-top: 34px;
    font-size: 14.5px;
  }

  .year-label,
  .year-group:first-of-type .year-label {
    margin-top: 42px;
  }

  .post a {
    padding: 30px 0 27px;
  }

  .post-title {
    font-size: 18px;
  }

  .post-excerpt {
    font-size: 14.5px;
  }

  .article-head {
    padding: 40px 0 26px;
  }

  .prose {
    padding-top: 34px;
    font-size: 15.5px;
    line-height: 1.95;
  }

  .prose blockquote {
    font-size: 16px;
    padding-left: 15px;
  }

  .prose pre {
    padding: 18px;
    font-size: 12.5px;
  }

  .article-foot {
    margin-top: 44px;
  }

  .site-footer {
    margin-top: 72px;
  }

  .footer-inner {
    padding-bottom: 48px;
  }
}

/* ---------- 打印 ---------- */

@media print {
  :root,
  [data-theme="dark"] {
    --bg: #ffffff;
    --text: #000000;
    --text-strong: #000000;
    --text-muted: #555555;
    --border: #dddddd;
    --border-strong: #bbbbbb;
    --code-bg: #f5f5f5;
    --code-text: #000000;
  }

  .site-header,
  .site-footer,
  .article-foot,
  .skip-link {
    display: none;
  }

  .wrap {
    max-width: none;
    padding: 0;
  }

  .article-head {
    padding-top: 0;
  }

  .prose {
    padding-top: 24px;
    font-size: 11.5pt;
    line-height: 1.9;
  }

  .js [data-reveal] {
    animation: none !important;
    transform: none !important;
  }

  a {
    color: #000;
    text-decoration: none;
  }
}

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

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

  .js [data-reveal] {
    animation: none !important;
    transform: none;
  }
}
