/* ==========================================================================
   ALUX — 极简 Typecho 主题
   ========================================================================== */

/* ---------- 设计变量 ---------- */
:root {
  color-scheme: light dark;

  --bg: #ffffff;
  --bg-glass: rgba(255, 255, 255, .82);
  --bg-soft: #f5f6f8;
  --text: #1d1d1f;
  --text-muted: #6e6e73;
  --border: #e8e8ed;
  --accent: #0a66ff;
  --accent-soft: rgba(10, 102, 255, .08);
  --code-bg: #f5f6f8;

  --header-h: 60px;
  --content-w: 720px;
  --radius: 10px;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans CJK SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161618;
    --bg-glass: rgba(22, 22, 24, .82);
    --bg-soft: #1f1f23;
    --text: #ececf1;
    --text-muted: #9a9aa2;
    --border: #2c2c31;
    --accent: #5c94ff;
    --accent-soft: rgba(92, 148, 255, .14);
    --code-bg: #1c1c20;
  }
}

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

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

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

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

img,
video {
  max-width: 100%;
  height: auto;
}

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

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

.container {
  max-width: var(--content-w);
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- 顶部导航 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-glass);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.site-nav {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-h);
}

.site-brand {
  font-size: 1.0625rem;
  font-weight: 700;
  letter-spacing: -.01em;
  transition: color .15s ease;
}

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

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-links a {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: .9375rem;
  color: var(--text-muted);
  transition: color .15s ease, background-color .15s ease;
}

.nav-links a:hover {
  color: var(--text);
  background: var(--bg-soft);
}

/* 汉堡按钮 */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 9px;
  background: none;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.nav-toggle:hover {
  background: var(--bg-soft);
}

.nav-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--text);
  border-radius: 2px;
  transition: transform .25s ease, opacity .2s ease;
}

.nav-toggle.is-active span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle.is-active span:nth-child(2) {
  opacity: 0;
}

.nav-toggle.is-active span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

@media (max-width: 719px) {
  .nav-toggle {
    display: flex;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: var(--header-h);
    left: -20px;
    right: -20px;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 8px 20px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 12px 24px rgba(0, 0, 0, .06);
  }

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

  .nav-links a {
    padding: 10px 12px;
    font-size: 1rem;
  }
}

/* ---------- 搜索 ---------- */
.nav-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.search-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: 0;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color .15s ease, background-color .15s ease;
}

.search-toggle:hover,
.search-toggle.is-active {
  color: var(--text);
  background: var(--bg-soft);
}

.site-search {
  display: none;
  border-top: 1px solid var(--border);
  background: var(--bg-glass);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
}

.site-search.is-open {
  display: block;
  animation: search-in .22s ease;
}

@keyframes search-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: none; }
}

.search-form {
  padding-top: 14px;
  padding-bottom: 14px;
}

.search-input {
  width: 100%;
  padding: 10px 18px;
  font-family: var(--font-sans);
  font-size: 1rem;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}

.search-input:focus {
  background: var(--bg);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

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

/* ---------- 主体 ---------- */
.site-main {
  min-height: calc(100vh - var(--header-h) - 140px);
  padding: 48px 0 72px;
}

/* 首页简介 */
.home-intro {
  margin-bottom: 40px;
}

.home-intro h1 {
  margin: 0 0 6px;
  font-size: clamp(1.5rem, 4.5vw, 1.875rem);
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.3;
}

.home-intro p {
  margin: 0;
  color: var(--text-muted);
  font-size: .9375rem;
}

/* 归档页标题 */
.archive-heading {
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.archive-heading h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -.015em;
}

/* ---------- 文章列表 ---------- */
.post-list {
  margin: 0;
}

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

.post-item:first-child {
  padding-top: 4px;
}

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

.post-item-title {
  margin: 0 0 8px;
  font-size: 1.3125rem;
  font-weight: 650;
  line-height: 1.4;
  letter-spacing: -.015em;
}

.post-item-title a {
  transition: color .15s ease;
}

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

.post-item-excerpt {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: .9375rem;
  line-height: 1.75;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-item-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  font-size: .8125rem;
  color: var(--text-muted);
}

.post-item-meta a {
  color: var(--text-muted);
  border-bottom: 1px solid transparent;
  transition: color .15s ease, border-color .15s ease;
}

.post-item-meta a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---------- 分页 ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 36px;
  font-size: .875rem;
  color: var(--text-muted);
}

.pagination-links {
  display: flex;
  gap: 8px;
}

.pagination a {
  display: inline-block;
  padding: 7px 14px;
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color .15s ease, background-color .15s ease;
}

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

/* ---------- 文章详情 ---------- */
.post-header {
  margin-bottom: 36px;
}

.post-title {
  margin: 0 0 14px;
  font-size: clamp(1.625rem, 5vw, 2.125rem);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -.02em;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  font-size: .875rem;
  color: var(--text-muted);
}

.post-meta .sep {
  opacity: .5;
}

.post-meta a {
  padding: 2px 10px;
  background: var(--bg-soft);
  border-radius: 999px;
  font-size: .8125rem;
  transition: color .15s ease, background-color .15s ease;
}

.post-meta a:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- 正文排版 ---------- */
.post-content {
  font-size: 1rem;
  line-height: 1.85;
  word-break: break-word;
}

.post-content > *:first-child {
  margin-top: 0;
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4 {
  margin: 1.8em 0 .7em;
  font-weight: 650;
  line-height: 1.4;
  letter-spacing: -.01em;
}

.post-content h1 { font-size: 1.5rem; }
.post-content h2 { font-size: 1.3125rem; }
.post-content h3 { font-size: 1.125rem; }
.post-content h4 { font-size: 1rem; }

.post-content p {
  margin: 0 0 1.25em;
}

.post-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  transition: text-decoration-thickness .15s ease;
}

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

.post-content img {
  display: block;
  margin: 1.5em auto;
  border-radius: var(--radius);
}

.post-content blockquote {
  margin: 1.5em 0;
  padding: .75em 1.25em;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: var(--bg-soft);
  color: var(--text-muted);
}

.post-content blockquote > *:last-child {
  margin-bottom: 0;
}

.post-content code {
  font-family: var(--font-mono);
  font-size: .875em;
  padding: .15em .4em;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 5px;
}

.post-content pre {
  margin: 1.5em 0;
  padding: 16px 18px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  line-height: 1.65;
  -webkit-overflow-scrolling: touch;
}

.post-content pre code {
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  font-size: .875rem;
}

/* 代码块：黑色主题 + 复制栏（JS 将 pre 包裹为 .code-block） */
.code-block {
  margin: 1.75em 0;
  border-radius: 12px;
  overflow: hidden;
  background: #0d1017;
  border: 1px solid #20242e;
  box-shadow: 0 10px 30px -12px rgba(8, 10, 16, .35);
}

.code-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 8px 7px 16px;
  background: #151923;
  border-bottom: 1px solid #20242e;
}

.code-lang {
  font-family: var(--font-mono);
  font-size: .71875rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: #7d8598;
  -webkit-user-select: none;
  user-select: none;
}

.code-copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #8b93a7;
  font-family: var(--font-sans);
  font-size: .75rem;
  line-height: 1;
  cursor: pointer;
  transition: color .15s ease, background-color .15s ease,
    border-color .15s ease, transform .1s ease;
}

.code-copy:hover {
  color: #e6e9f0;
  background: rgba(255, 255, 255, .07);
  border-color: rgba(255, 255, 255, .14);
}

.code-copy:active {
  transform: scale(.95);
}

.code-copy .icon-check {
  display: none;
}

.code-copy.is-copied {
  color: #3fb950;
}

.code-copy.is-copied .icon-copy {
  display: none;
}

.code-copy.is-copied .icon-check {
  display: block;
}

.code-block pre {
  margin: 0;
  padding: 16px 18px;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: #c9d1d9;
}

.code-block pre code {
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  color: inherit;
  font-size: .875rem;
}

@media (prefers-color-scheme: dark) {
  .code-block {
    border-color: #272c38;
    box-shadow: none;
  }
}

.post-content ul,
.post-content ol {
  margin: 0 0 1.25em;
  padding-left: 1.5em;
}

.post-content li {
  margin-bottom: .35em;
}

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

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

.post-content table {
  width: 100%;
  margin: 1.5em 0;
  border-collapse: collapse;
  font-size: .9375rem;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.post-content th,
.post-content td {
  padding: 8px 14px;
  border: 1px solid var(--border);
  text-align: left;
}

.post-content th {
  background: var(--bg-soft);
  font-weight: 600;
}

/* 锚点跳转时为吸顶导航预留空间 */
.post-content h2,
.post-content h3,
.post-content h4 {
  scroll-margin-top: calc(var(--header-h) + 24px);
}

/* ---------- 文章目录 ---------- */
.toc {
  margin: 0 0 2.25rem;
  padding: 14px 18px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.toc-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: .1em;
  color: var(--text-muted);
  cursor: pointer;
  list-style: none;
  -webkit-user-select: none;
  user-select: none;
}

.toc-title::-webkit-details-marker {
  display: none;
}

.toc-title::before {
  content: "";
  width: 0;
  height: 0;
  border-left: 5px solid var(--text-muted);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform .2s ease;
}

.toc[open] .toc-title::before {
  transform: rotate(90deg);
}

.toc-list {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  border-left: 1px solid var(--border);
}

.toc-item a {
  display: block;
  margin-left: -1px;
  padding: 4px 0 4px 14px;
  font-size: .875rem;
  line-height: 1.5;
  color: var(--text-muted);
  border-left: 2px solid transparent;
  transition: color .15s ease, border-color .15s ease;
}

.toc-item a:hover {
  color: var(--text);
}

.toc-item a.is-active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}

.toc-item.toc-h3 a {
  padding-left: 30px;
  font-size: .8125rem;
}

/* 宽屏：目录悬浮在正文右侧留白区 */
@media (min-width: 1280px) {
  .toc {
    position: fixed;
    top: calc(var(--header-h) + 40px);
    left: calc(50% + 400px);
    width: 220px;
    max-height: calc(100vh - var(--header-h) - 80px);
    margin: 0;
    padding: 0;
    overflow-y: auto;
    background: transparent;
    border: 0;
    border-radius: 0;
  }

  .toc-list {
    margin-top: 10px;
  }
}

/* ---------- 评论 ---------- */
.comments {
  margin-top: 4rem;
  padding-top: 2.5rem;
  border-top: 1px solid var(--border);
}

.comments-title,
.respond-title {
  margin: 0 0 1.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -.01em;
}

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

.comment-body {
  display: flex;
  gap: 14px;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
}

.comment-avatar img {
  display: block;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-soft);
  box-shadow: 0 0 0 1px var(--border);
}

.comment-main {
  flex: 1;
  min-width: 0;
}

.comment-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}

.comment-name {
  font-style: normal;
  font-size: .9375rem;
  font-weight: 600;
}

.comment-name a {
  color: inherit;
  transition: color .15s ease;
}

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

.comment-badge {
  padding: 1px 8px;
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 999px;
}

.comment-date {
  font-size: .75rem;
  color: var(--text-muted);
}

.comment-text {
  font-size: .9375rem;
  line-height: 1.7;
  word-break: break-word;
}

.comment-text p {
  margin: 0 0 .5em;
}

.comment-text p:last-child {
  margin-bottom: 0;
}

.comment-actions {
  margin-top: 6px;
}

.comment-actions a {
  font-size: .75rem;
  color: var(--text-muted);
  transition: color .15s ease;
}

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

/* 嵌套回复：缩进 + 线程线 */
.comment-children {
  margin: 0 0 0 20px;
  padding: 0 0 0 22px;
  list-style: none;
  border-left: 2px solid var(--border);
}

.comment-pager {
  margin-top: 1.5rem;
}

.comment-pager .page-navigator {
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.comment-pager a {
  display: inline-block;
  padding: 6px 14px;
  font-size: .875rem;
  color: var(--accent);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color .15s ease, background-color .15s ease;
}

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

/* 评论表单 */
.respond {
  margin-top: 3rem;
}

.cancel-reply {
  margin-bottom: 12px;
  font-size: .8125rem;
}

.cancel-reply a {
  color: var(--text-muted);
  transition: color .15s ease;
}

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

.respond-logged {
  margin-bottom: 14px;
  font-size: .875rem;
  color: var(--text-muted);
}

.respond-logged a {
  color: var(--accent);
}

.respond-logout {
  margin-left: 8px;
}

.respond-fields {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}

.respond-field label,
.respond-textarea label {
  display: block;
  margin-bottom: 3px;
  font-size: .78125rem;
  font-weight: 500;
  color: var(--text-muted);
}

.respond-field label em,
.respond-textarea label em {
  font-style: normal;
  color: var(--accent);
}

.respond .text,
.respond .textarea {
  width: 100%;
  padding: 7px 11px;
  font-family: var(--font-sans);
  font-size: .9375rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.respond .text:focus,
.respond .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.respond .textarea {
  min-height: 96px;
  line-height: 1.6;
  resize: vertical;
}

.respond-textarea {
  margin-bottom: 12px;
}

.respond-submit {
  margin: 0;
}

.submit {
  display: inline-flex;
  align-items: center;
  padding: 9px 26px;
  font-family: var(--font-sans);
  font-size: .9375rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}

.submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px -6px var(--accent);
}

.submit:active {
  transform: translateY(0);
  box-shadow: none;
}

.comments-closed {
  font-size: .9375rem;
  color: var(--text-muted);
}

@media (max-width: 719px) {
  .respond-fields {
    grid-template-columns: 1fr;
  }

  .comment-children {
    margin-left: 8px;
    padding-left: 14px;
  }
}

/* ---------- 页脚 ---------- */
.site-footer {
  padding: 32px 0;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: .8125rem;
  color: var(--text-muted);
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: var(--text-muted);
  border-bottom: 1px solid transparent;
  transition: color .15s ease, border-color .15s ease;
}

.site-footer a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.footer-beian {
  margin: 6px 0 0;
  font-size: .75rem;
  opacity: .85;
}

.footer-police {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.footer-police svg {
  flex-shrink: 0;
}

.footer-signature {
  margin: 16px 0 0;
  font-size: .8125rem;
  letter-spacing: .02em;
  opacity: .65;
}

/* ---------- 404 ---------- */
.error-404 {
  padding: 72px 0;
  text-align: center;
}

.error-404 .error-code {
  font-size: clamp(4rem, 14vw, 6rem);
  font-weight: 800;
  letter-spacing: -.04em;
  line-height: 1;
  background: linear-gradient(180deg, var(--text) 30%, var(--text-muted));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.error-404 p {
  margin: 16px 0 28px;
  color: var(--text-muted);
}

.error-404 .btn {
  display: inline-block;
  padding: 9px 22px;
  background: var(--text);
  color: var(--bg);
  border-radius: 999px;
  font-size: .9375rem;
  font-weight: 500;
  transition: opacity .15s ease, transform .15s ease;
}

.error-404 .btn:hover {
  opacity: .85;
  transform: translateY(-1px);
}

/* ---------- 小屏微调 ---------- */
@media (max-width: 719px) {
  .site-main {
    padding: 32px 0 56px;
  }

  .post-item {
    padding: 22px 0;
  }

  .post-item-title {
    font-size: 1.1875rem;
  }

  .pagination {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .pagination-links {
    justify-content: center;
  }
}

/* ---------- 动效偏好 ---------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

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