/* ==========================================================================
   拾光 · 静态博客样式表
   全部用 CSS 变量驱动，改顶部这几个值就能换掉整站配色。
   ========================================================================== */

:root {
  /* 配色：暖白纸感 */
  --bg: #fbf9f5;
  --bg-soft: #f3efe7;
  --text: #1d1b18;
  --muted: #6d6760;
  --line: #e4ded3;
  --accent: #b0532c;
  --accent-soft: #f7e9e1;
  --shadow: 0 1px 2px rgba(29, 27, 24, 0.04), 0 10px 28px rgba(29, 27, 24, 0.06);

  /* 版式 */
  --wrap: 42rem;
  --radius: 14px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-serif: Georgia, "Songti SC", "Noto Serif SC", "Source Han Serif SC",
    "SimSun", serif;
  --font-mono: ui-monospace, SFMono-Regular, "Cascadia Code", Consolas,
    "Liberation Mono", monospace;
}

/* 深色（手动切换） */
[data-theme="dark"] {
  --bg: #161513;
  --bg-soft: #201e1a;
  --text: #e9e4da;
  --muted: #a29b90;
  --line: #2f2c27;
  --accent: #e08d61;
  --accent-soft: #33241c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px rgba(0, 0, 0, 0.35);
}

/* 深色（跟随系统，且用户没手动选过） */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161513;
    --bg-soft: #201e1a;
    --text: #e9e4da;
    --muted: #a29b90;
    --line: #2f2c27;
    --accent: #e08d61;
    --accent-soft: #33241c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px rgba(0, 0, 0, 0.35);
  }
}

/* ---------- 基础 ---------- */

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1 0 auto;
}

.wrap {
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: 1.25rem;
}

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

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

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

img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

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

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

/* 跳过导航（无障碍） */
.skip {
  position: absolute;
  left: -9999px;
}

.skip:focus {
  left: 1rem;
  top: 1rem;
  z-index: 100;
  background: var(--bg);
  padding: 0.5rem 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
}

/* ---------- 阅读进度条 ---------- */

.progress {
  position: fixed;
  inset: 0 auto auto 0;
  height: 3px;
  width: 0;
  background: var(--accent);
  z-index: 60;
  transition: width 0.08s linear;
}

/* ---------- 页头 ---------- */

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

@supports (background: color-mix(in srgb, red 50%, transparent)) {
  .site-header {
    background: color-mix(in srgb, var(--bg) 84%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
  }
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 60px;
}

.brand {
  font-family: var(--font-serif);
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

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

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9375rem;
}

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

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 15px;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--muted);
  background: var(--bg-soft);
}

/* ---------- 首页英雄区 ---------- */

.hero {
  padding: 4rem 0 2.5rem;
}

.eyebrow {
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero h1 {
  margin: 0 0 1rem;
  font-family: var(--font-serif);
  font-size: clamp(2.1rem, 6vw, 3rem);
  line-height: 1.2;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.lede {
  margin: 0;
  font-size: 1.125rem;
  color: var(--muted);
  max-width: 34rem;
}

.hero-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1.75rem 0 0;
  padding: 0;
  list-style: none;
}

.hero-links a {
  display: inline-block;
  padding: 0.35rem 0.85rem;
  font-size: 0.875rem;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.hero-links a:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- 分节标题 ---------- */

.section-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* ---------- 文章列表 ---------- */

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

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

.post-link {
  display: block;
  padding: 1.5rem 0;
  color: inherit;
  text-decoration: none;
}

.post-link:hover .post-title {
  color: var(--accent);
}

.post-link:hover .post-excerpt {
  color: var(--text);
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.dot {
  opacity: 0.5;
}

.post-title {
  margin: 0.4rem 0 0.35rem;
  font-family: var(--font-serif);
  font-size: 1.3125rem;
  font-weight: 600;
  line-height: 1.45;
  transition: color 0.15s;
}

.post-excerpt {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--muted);
  transition: color 0.15s;
}

.tag {
  display: inline-block;
  margin-top: 0.75rem;
  padding: 0.15rem 0.6rem;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
}

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

.article {
  padding: 3rem 0 4rem;
}

.back {
  display: inline-block;
  margin-bottom: 2rem;
  font-size: 0.875rem;
  color: var(--muted);
  text-decoration: none;
}

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

.article header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}

.article h1 {
  margin: 0.5rem 0 1rem;
  font-family: var(--font-serif);
  font-size: clamp(1.75rem, 5vw, 2.35rem);
  line-height: 1.3;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.prose {
  font-size: 1.0625rem;
}

.prose > * + * {
  margin-top: 1.35em;
}

.prose h2 {
  margin-top: 2.75rem;
  font-family: var(--font-serif);
  font-size: 1.375rem;
  font-weight: 600;
  line-height: 1.4;
}

.prose h3 {
  margin-top: 2rem;
  font-size: 1.0625rem;
  font-weight: 600;
}

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

.prose li + li {
  margin-top: 0.4em;
}

.prose blockquote {
  margin: 1.75rem 0;
  padding: 0.25rem 0 0.25rem 1.25rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}

.prose blockquote p {
  margin: 0;
}

.prose code {
  padding: 0.15em 0.4em;
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 5px;
}

.prose pre {
  padding: 1.1rem 1.25rem;
  overflow-x: auto;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.875rem;
  line-height: 1.65;
}

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

.prose kbd {
  padding: 0.1em 0.45em;
  font-family: var(--font-mono);
  font-size: 0.8125em;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
}

/* ---------- 图片与图注 ---------- */

.prose > img {
  margin: 2rem 0;
}

.prose figure {
  margin: 2.25rem 0;
}

.prose figure img,
.cover img {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
  border-radius: var(--radius);
}

.prose figcaption,
.cover figcaption {
  margin-top: 0.7rem;
  font-size: 0.8125rem;
  line-height: 1.65;
  color: var(--muted);
  text-align: center;
}

/* 可点开放大的图片 */
.prose img,
.cover img {
  cursor: zoom-in;
}

/* 通栏大图：在宽屏上突破正文宽度 */
@media (min-width: 52rem) {
  .prose .wide {
    position: relative;
    left: 50%;
    width: min(50rem, calc(100vw - 4rem));
    max-width: none;
    transform: translateX(-50%);
  }
}

/* 并排组图 */
.prose .gallery {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  align-items: start;
}

.prose .gallery img {
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.prose .gallery figcaption {
  grid-column: 1 / -1;
}

/* 文章封面图 */
.cover {
  margin: 0 0 2.5rem;
}

.cover img {
  aspect-ratio: 16 / 7;
  object-fit: cover;
}

.prose hr {
  margin: 2.5rem 0;
}

/* 文章末尾的下一站 / 署名 */
.article-footer {
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
  font-size: 0.875rem;
  color: var(--muted);
}

/* ---------- 关于页 ---------- */

.page {
  padding: 3rem 0 4rem;
}

.page h1 {
  margin: 0 0 2rem;
  font-family: var(--font-serif);
  font-size: clamp(1.9rem, 5vw, 2.5rem);
  line-height: 1.25;
  font-weight: 600;
}

/* ---------- 图片放大（lightbox） ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 3vmin;
  background: rgba(18, 16, 14, 0.92);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.lightbox[hidden] {
  display: none;
}

.lightbox.is-open {
  opacity: 1;
}

.lightbox figure {
  margin: 0;
  max-width: 100%;
  text-align: center;
}

.lightbox img {
  display: block;
  width: auto;
  height: auto;
  max-width: 94vw;
  max-height: 82vh;
  margin-inline: auto;
  border-radius: 6px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.lightbox figcaption {
  margin-top: 0.85rem;
  font-size: 0.8125rem;
  color: rgba(255, 255, 255, 0.75);
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.26);
}

/* ---------- 404 ---------- */

.center {
  display: grid;
  place-items: center;
  min-height: 62vh;
  text-align: center;
}

.center .code {
  margin: 0;
  font-family: var(--font-serif);
  font-size: clamp(4rem, 18vw, 7rem);
  line-height: 1;
  color: var(--line);
}

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

.site-footer {
  flex-shrink: 0;
  padding: 2rem 0 3rem;
  border-top: 1px solid var(--line);
  font-size: 0.8125rem;
  color: var(--muted);
}

.site-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  justify-content: space-between;
}

/* ---------- 小屏 ---------- */

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

  .hero {
    padding-top: 2.75rem;
  }

  .site-nav {
    gap: 0.9rem;
  }

  .site-footer .wrap {
    justify-content: flex-start;
  }
}

/* ---------- 动画偏好 ---------- */

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

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

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

@media print {
  .site-header,
  .site-footer,
  .progress,
  .back,
  .lightbox {
    display: none;
  }

  body {
    background: #fff;
    color: #000;
  }
}
