/* ==========================================================================
   saltyleo.blog — 站点样式
   纯静态：所有样式都作用在预先写好的 HTML 上，没有运行时模板注入。
   ========================================================================== */

/* ---------- 设计变量 ---------- */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-serif: "Noto Serif SC", "Songti SC", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --bg: #faf8f4;
  --bg-soft: #f2efe8;
  --surface: #ffffff;
  --header-bg: rgba(250, 248, 244, 0.82);
  --text: #1c1f24;
  --text-soft: #4b5563;
  --muted: #8a8f98;
  --border: #e6e1d7;
  --accent: #0f766e;
  --accent-ink: #0b5f59;
  --accent-soft: rgba(15, 118, 110, 0.1);
  --shadow: 0 1px 2px rgba(20, 20, 20, 0.04), 0 10px 30px -14px rgba(20, 20, 20, 0.18);
  --radius: 14px;
  --content: 720px;
  --wide: 1080px;
  --header-h: 64px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0e1113;
  --bg-soft: #151a1d;
  --surface: #14191c;
  --header-bg: rgba(14, 17, 19, 0.82);
  --text: #e8ecef;
  --text-soft: #b6bfc6;
  --muted: #818b93;
  --border: #242b30;
  --accent: #2dd4bf;
  --accent-ink: #5eead4;
  --accent-soft: rgba(45, 212, 191, 0.12);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px -16px rgba(0, 0, 0, 0.8);
  color-scheme: dark;
}

/* ---------- 基础重置 ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

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

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

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

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

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

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

.skip-link {
  position: absolute;
  left: 16px;
  top: -60px;
  z-index: 100;
  padding: 8px 14px;
  border-radius: 8px;
  background: var(--text);
  color: var(--bg);
  transition: top 0.2s ease;
}
.skip-link:focus { top: 12px; }

/* ---------- 布局容器 ---------- */
.wrap {
  width: 100%;
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0 24px;
}

main { flex: 1 0 auto; }

/* ---------- 顶栏 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  border-bottom: 1px solid transparent;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  transition: border-color 0.2s ease;
}
.site-header.is-scrolled { border-bottom-color: var(--border); }

.header-inner {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 24px;
}

.brand {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.brand span {
  color: var(--accent);
  display: inline-block;
  font-size: 1.5em;
  line-height: 0.8;
  margin-left: -0.02em;
  transform: translateY(0.06em);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.site-nav a {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 14.5px;
  color: var(--text-soft);
  transition: background-color 0.2s ease, color 0.2s ease;
}
.site-nav a:hover { background: var(--bg-soft); color: var(--text); }
.site-nav a[aria-current="page"] { color: var(--accent-ink); background: var(--accent-soft); }

.header-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: var(--text-soft);
  transition: background-color 0.2s ease, color 0.2s ease;
}
.icon-btn:hover { background: var(--bg-soft); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

/* 主题图标显隐 */
html[data-theme="light"] .icon-moon { display: block; }
html[data-theme="light"] .icon-sun { display: none; }
html[data-theme="dark"] .icon-moon { display: none; }
html[data-theme="dark"] .icon-sun { display: block; }

.menu-toggle { display: none; }

/* ---------- 首页 Hero ---------- */
.hero {
  padding: 72px 0 56px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 22px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}
.eyebrow::before {
  content: "";
  width: 28px;
  height: 1px;
  background: var(--accent);
}

.hero h1 {
  margin: 0 0 20px;
  max-width: 16em;
  font-family: var(--font-serif);
  font-size: clamp(30px, 7.4vw, 58px);
  line-height: 1.18;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.hero h1 em {
  font-style: normal;
  color: var(--accent);
}

.hero .lede {
  max-width: 34em;
  margin: 0;
  font-size: 17px;
  color: var(--text-soft);
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-top: 30px;
  font-size: 13.5px;
  color: var(--muted);
}
.hero-meta span { display: inline-flex; align-items: center; gap: 7px; }
.hero-meta .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

/* ---------- 区块标题 ---------- */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 14px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.section-head h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.section-head a {
  font-size: 13.5px;
  color: var(--muted);
  transition: color 0.2s ease;
}
.section-head a:hover { color: var(--accent-ink); }

/* ---------- 文章列表 ---------- */
.post-list { padding-bottom: 88px; }

.post-item {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 28px;
  padding: 26px 4px;
  border-bottom: 1px solid var(--border);
  transition: transform 0.25s ease;
}
.post-item:hover { transform: translateX(3px); }

.post-date {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--muted);
  padding-top: 5px;
  letter-spacing: 0.02em;
}

.post-body h3 {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 650;
  line-height: 1.45;
  letter-spacing: -0.01em;
}
.post-item:hover h3 { color: var(--accent-ink); }

.post-body p {
  margin: 0 0 12px;
  font-size: 14.5px;
  color: var(--text-soft);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 11.5px;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.post-arrow {
  display: inline-block;
  margin-left: 6px;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  color: var(--accent);
}
.post-item:hover .post-arrow { opacity: 1; transform: translateX(0); }

/* ---------- 文章页 ---------- */
.article-layout {
  display: grid;
  gap: 56px;
  max-width: 1040px;
  margin: 0 auto;
  padding: 56px 24px 96px;
}
.article-layout > article {
  width: 100%;
  max-width: var(--content);
  min-width: 0;
  margin: 0 auto;
}
@media (min-width: 1024px) {
  .article-layout {
    grid-template-columns: minmax(0, var(--content)) 200px;
    justify-content: center;
  }
  .article-layout > article { margin: 0; }
}

.article-header {
  padding-bottom: 30px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 36px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 22px;
  font-size: 13px;
  color: var(--muted);
}
.breadcrumb a:hover { color: var(--accent-ink); }
.breadcrumb .sep { opacity: 0.5; }

.article-header h1 {
  margin: 0 0 16px;
  font-family: var(--font-serif);
  font-size: clamp(28px, 4.4vw, 40px);
  line-height: 1.28;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  font-size: 13.5px;
  color: var(--muted);
}
.article-meta time { font-family: var(--font-mono); }
.article-meta .read-time { display: inline-flex; align-items: center; gap: 6px; }

/* 正文排版 */
.prose {
  font-size: 16.5px;
  line-height: 1.85;
  color: var(--text);
}
.prose > *:first-child { margin-top: 0; }
.prose p { margin: 0 0 1.35em; }
.prose h2,
.prose h3,
.prose h4 {
  margin: 2.2em 0 0.7em;
  font-family: var(--font-serif);
  line-height: 1.4;
  letter-spacing: -0.01em;
  scroll-margin-top: calc(var(--header-h) + 24px);
}
.prose h2 { font-size: 25px; }
.prose h3 { font-size: 20px; }
.prose h4 { font-size: 17px; }
.prose a {
  color: var(--accent-ink);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
.prose a:hover { text-decoration-color: var(--accent); }

.prose ul,
.prose ol { margin: 0 0 1.35em; padding-left: 1.4em; }
.prose li { margin: 0.35em 0; }
.prose li::marker { color: var(--accent); }

.prose blockquote {
  margin: 1.8em 0;
  padding: 4px 0 4px 22px;
  border-left: 3px solid var(--accent);
  color: var(--text-soft);
  font-family: var(--font-serif);
}
.prose blockquote p:last-child { margin-bottom: 0; }

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

.prose code {
  padding: 0.15em 0.42em;
  border-radius: 5px;
  background: var(--bg-soft);
  font-family: var(--font-mono);
  font-size: 0.86em;
  color: var(--accent-ink);
}

.prose pre {
  position: relative;
  margin: 1.8em 0;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  overflow: auto;
  box-shadow: var(--shadow);
}
.prose pre code {
  padding: 0;
  background: none;
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.7;
}

.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  font-size: 11.5px;
  font-family: var(--font-mono);
  opacity: 0;
  transition: opacity 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.prose pre:hover .copy-btn,
.copy-btn:focus-visible { opacity: 1; }
.copy-btn:hover { color: var(--accent-ink); border-color: var(--accent); }

.prose img {
  margin: 1.8em auto;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.prose table {
  width: 100%;
  margin: 1.8em 0;
  border-collapse: collapse;
  font-size: 14.5px;
}
.prose th,
.prose td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.prose th {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  background: var(--bg-soft);
}

/* 目录 */
.toc {
  align-self: start;
  position: sticky;
  top: calc(var(--header-h) + 28px);
  font-size: 13px;
}
.toc-title {
  margin: 0 0 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.toc ol {
  list-style: none;
  margin: 0;
  padding: 0 0 0 12px;
  border-left: 1px solid var(--border);
}
.toc li { margin: 0; }
.toc a {
  display: block;
  padding: 5px 0 5px 2px;
  color: var(--muted);
  line-height: 1.5;
  transition: color 0.2s ease;
}
.toc a:hover,
.toc a.is-active { color: var(--accent-ink); }
.toc a.is-active { font-weight: 600; }

/* 上下篇 / 文末 */
.post-footer {
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}
.post-nav {
  display: grid;
  gap: 12px;
}
@media (min-width: 640px) {
  .post-nav { grid-template-columns: 1fr 1fr; }
}
.post-nav a {
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.post-nav a:hover { border-color: var(--accent); transform: translateY(-2px); }
.post-nav .label {
  display: block;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.post-nav .title { font-size: 14.5px; font-weight: 600; }
.post-nav .next { text-align: right; }

/* 页面（about / archive / 404） */
.page {
  max-width: var(--content);
  margin: 0 auto;
  padding: 64px 24px 96px;
}
.page h1 {
  margin: 0 0 10px;
  font-family: var(--font-serif);
  font-size: clamp(30px, 5vw, 42px);
  letter-spacing: -0.02em;
}
.page .page-lede {
  margin: 0 0 44px;
  padding-bottom: 30px;
  border-bottom: 1px solid var(--border);
  font-size: 16.5px;
  color: var(--text-soft);
}

/* 归档列表 */
.archive-year {
  margin: 40px 0 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--muted);
}
.archive-year:first-of-type { margin-top: 0; }
.archive-list { list-style: none; margin: 0; padding: 0; }
.archive-list li { border-bottom: 1px solid var(--border); }
.archive-list a {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 16px;
  align-items: baseline;
  padding: 13px 2px;
  transition: padding-left 0.2s ease, color 0.2s ease;
}
.archive-list a:hover { padding-left: 8px; color: var(--accent-ink); }
.archive-list time {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--muted);
}

/* 空状态 */
.empty-state {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 46px 24px;
  margin-top: 18px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  color: var(--muted);
  font-size: 15px;
}
.empty-state p { margin: 0; }
.empty-state .dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

/* 关于页 */
.about-grid {
  display: grid;
  gap: 28px;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: start;
  margin-bottom: 8px;
}
.about-grid .avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}
.about-grid h2 {
  margin: 4px 0 6px;
  font-family: var(--font-serif);
  font-size: 22px;
}
.about-grid p { margin: 0; color: var(--text-soft); }
@media (max-width: 520px) {
  .about-grid { grid-template-columns: 1fr; }
  .about-grid .avatar { width: 72px; height: 72px; }
}

/* ---------- 页脚 ---------- */
.site-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-top: 30px;
  padding-bottom: 30px;
  font-size: 13px;
  color: var(--muted);
}
.footer-inner a:hover { color: var(--accent-ink); }
.footer-links { display: flex; flex-wrap: wrap; gap: 6px 18px; }

/* ---------- 阅读进度条 ---------- */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  width: var(--progress, 0%);
  height: 2px;
  background: var(--accent);
  transition: width 0.1s linear;
  pointer-events: none;
}

/* ---------- 入场动画（可关闭） ---------- */
/* 只有 JS 可用时才隐藏待入场元素，保证无 JS 时内容完整可见 */
.js .reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.js .reveal.is-visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .js .reveal,
  .reveal { opacity: 1; transform: none; }
}

/* ---------- 移动端 ---------- */
@media (max-width: 760px) {
  .wrap { padding: 0 18px; }

  .menu-toggle { display: grid; }
  .header-tools { margin-left: auto; }

  .site-nav {
    position: absolute;
    top: var(--header-h);
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    margin: 0;
    padding: 10px 18px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    box-shadow: var(--shadow);
  }
  .site-nav.is-open { display: flex; }
  .site-nav a { padding: 10px 12px; border-radius: 8px; }

  .hero { padding: 48px 0 40px; }
  .hero .lede { font-size: 16px; }

  .post-item {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 22px 2px;
  }
  .post-date { padding-top: 0; }

  .article-layout { padding-top: 36px; gap: 40px; }
  .toc { display: none; }
  .prose { font-size: 16px; }
  .prose pre { margin-left: -18px; margin-right: -18px; border-radius: 0; }

  .footer-inner { flex-direction: column; align-items: flex-start; }
}

/* ---------- 打印 ---------- */
@media print {
  .site-header,
  .site-footer,
  .toc,
  .progress-bar,
  .post-nav,
  .copy-btn { display: none !important; }
  body { background: #fff; color: #000; }
  .article-layout { display: block; padding: 0; }
  .prose a { color: #000; }
}
