/* ── Theme variables ──────────────────────────────── */
:root {
  --card-bg: rgba(255, 255, 255, 0.72);
  --card-border: rgba(255, 255, 255, 0.45);
  --card-header-bg: rgba(255, 255, 255, 0.5);
  --post-card-bg: rgba(255, 255, 255, 0.82);
  --auth-card-bg: rgba(255, 255, 255, 0.82);
  --navbar-bg: rgba(20, 20, 20, 0.75);
  --footer-bg: rgba(20, 20, 20, 0.7);
  --body-color: #212529;
  --muted-color: #6c757d;
  --border-subtle: rgba(0, 0, 0, 0.08);
  --pre-bg: rgba(0, 0, 0, 0.05);
  --code-bg: rgba(0, 0, 0, 0.06);
  --blockquote-bg: rgba(13, 110, 253, 0.06);
  --page-link-bg: rgba(255, 255, 255, 0.7);
  --dropdown-bg: rgba(255, 255, 255, 0.92);
  --dropdown-color: #212529;
}

[data-theme="dark"] {
  --card-bg: rgba(30, 32, 44, 0.78);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-header-bg: rgba(255, 255, 255, 0.05);
  --post-card-bg: rgba(25, 27, 38, 0.88);
  --auth-card-bg: rgba(25, 27, 38, 0.88);
  --navbar-bg: rgba(10, 10, 16, 0.85);
  --footer-bg: rgba(10, 10, 16, 0.8);
  --body-color: #e2e4f0;
  --muted-color: #8b8fa8;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --pre-bg: rgba(0, 0, 0, 0.3);
  --code-bg: rgba(255, 255, 255, 0.08);
  --blockquote-bg: rgba(13, 110, 253, 0.12);
  --page-link-bg: rgba(30, 32, 44, 0.7);
  --dropdown-bg: rgba(30, 32, 44, 0.96);
  --dropdown-color: #e2e4f0;
}

/* ── Base ─────────────────────────────────────────── */
body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.4s ease, color 0.3s ease;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  color: var(--body-color);
}

main.container { flex: 1; }

/* ── Acrylic / Frosted-glass utility ─────────────── */
.acrylic {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.45);
}

/* ── Card overrides ───────────────────────────────── */
.card {
  background: var(--card-bg) !important;
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid var(--card-border) !important;
  border-radius: 14px !important;
  transition: box-shadow 0.25s ease, transform 0.25s ease;
  color: var(--body-color);
}

.card:hover {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18) !important;
  transform: translateY(-2px);
}

.card-header {
  background: var(--card-header-bg) !important;
  border-bottom: 1px solid var(--border-subtle) !important;
  color: var(--body-color);
}

/* 暗色模式下 Bootstrap 文字颜色修正 */
[data-theme="dark"] .text-dark { color: var(--body-color) !important; }
[data-theme="dark"] .text-muted { color: var(--muted-color) !important; }
[data-theme="dark"] .border-bottom { border-color: var(--border-subtle) !important; }
[data-theme="dark"] .table { color: var(--body-color); }
[data-theme="dark"] .table-light { background: var(--card-header-bg) !important; color: var(--muted-color); }
[data-theme="dark"] .form-control, [data-theme="dark"] .form-select {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.15);
  color: var(--body-color);
}
[data-theme="dark"] .form-control::placeholder { color: var(--muted-color); }
[data-theme="dark"] .btn-outline-secondary { color: var(--muted-color); border-color: var(--muted-color); }
[data-theme="dark"] .alert-success { background: rgba(25,135,84,0.2); border-color: rgba(25,135,84,0.4); color: #75c79e; }
[data-theme="dark"] .alert-danger  { background: rgba(220,53,69,0.2); border-color: rgba(220,53,69,0.4); color: #f08080; }

/* ── Navbar ───────────────────────────────────────── */
.navbar {
  background: var(--navbar-bg) !important;
  backdrop-filter: blur(20px) saturate(200%);
  -webkit-backdrop-filter: blur(20px) saturate(200%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
  z-index: 1100;
}

/* 下拉菜单亚克力 */
.dropdown-menu {
  background: var(--dropdown-bg) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--card-border) !important;
  border-radius: 12px !important;
  color: var(--dropdown-color);
}
.dropdown-item { color: var(--dropdown-color) !important; }
.dropdown-item:hover { background: rgba(128,128,128,0.15) !important; }
.dropdown-divider { border-color: var(--border-subtle) !important; }
.dropdown-item-text { color: var(--muted-color) !important; }

/* ── Footer ───────────────────────────────────────── */
footer {
  background: var(--footer-bg) !important;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* ── Post article card ────────────────────────────── */
.post-card {
  background: var(--post-card-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 2.5rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  color: var(--body-color);
}

.post-card .post-meta {
  color: var(--muted-color);
  font-size: 0.875rem;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

/* ── Post content typography ─────────────────────── */
.post-content {
  line-height: 1.85;
  font-size: 1.05rem;
  color: var(--body-color);
}

.post-content h1, .post-content h2, .post-content h3 {
  margin-top: 1.8rem;
  margin-bottom: 0.8rem;
  font-weight: 700;
}

.post-content img {
  max-width: 100%;
  border-radius: 10px;
  margin: 1rem 0;
}

.post-content pre {
  background: var(--pre-bg);
  border: 1px solid var(--border-subtle);
  padding: 1.2rem;
  border-radius: 10px;
  overflow-x: auto;
  font-size: 0.9rem;
}

.post-content code {
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.88em;
}

.post-content pre code {
  background: none;
  padding: 0;
}

.post-content blockquote {
  border-left: 4px solid #0d6efd;
  padding: 0.5rem 1rem;
  margin: 1rem 0;
  background: var(--blockquote-bg);
  border-radius: 0 8px 8px 0;
  color: var(--muted-color);
  font-style: italic;
}

/* ── Pagination ───────────────────────────────────── */
.page-link {
  background: var(--page-link-bg);
  backdrop-filter: blur(8px);
  border-color: var(--border-subtle);
  color: var(--body-color);
}

/* ── Auth / Profile forms ─────────────────────────── */
.auth-card {
  background: var(--auth-card-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--card-border);
  border-radius: 18px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  color: var(--body-color);
}

/* ── Mac-style code window ───────────────────────── */
.code-window {
  border-radius: 10px;
  overflow: hidden;
  margin: 1.4rem 0;
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.3);
  font-size: 0.88rem;
}

.code-window-header {
  background: #3a3a3a;
  padding: 9px 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid rgba(0,0,0,0.4);
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-red    { background: #ff5f57; box-shadow: 0 0 0 1px rgba(0,0,0,0.15); }
.dot-yellow { background: #febc2e; box-shadow: 0 0 0 1px rgba(0,0,0,0.15); }
.dot-green  { background: #28c840; box-shadow: 0 0 0 1px rgba(0,0,0,0.15); }

.code-lang {
  color: #888;
  font-size: 0.75rem;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  letter-spacing: 0.04em;
  flex: 1;
}

.code-copy-btn {
  margin-left: auto;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 5px;
  color: #999;
  padding: 2px 9px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  line-height: 1.6;
}
.code-copy-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #ddd;
  border-color: rgba(255, 255, 255, 0.35);
}
.code-copy-btn.copied {
  color: #28c840;
  border-color: #28c840;
}

.code-window pre {
  background: #1e1e2e;
  margin: 0;
  padding: 1.1rem 1.3rem;
  overflow-x: auto;
  border-radius: 0;
}

.code-window pre::-webkit-scrollbar { height: 6px; }
.code-window pre::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }

.code-window pre code.hljs {
  background: transparent;
  padding: 0;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.88rem;
  line-height: 1.65;
  tab-size: 4;
  -moz-tab-size: 4;
}

/* 行内代码保持原有风格 */
.post-content :not(.code-window) > code {
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  font-size: 0.88em;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

/* ── Hero Section ─────────────────────────────────── */
.hero-section {
  height: calc(100vh - 56px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 2rem 1rem;
}

.hero-card {
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 24px;
  padding: 3.5rem 4.5rem;
  max-width: 620px;
  width: 100%;
  text-align: center;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.08);
  animation: heroFadeIn 0.9s cubic-bezier(.22,1,.36,1) both;
}

[data-theme="dark"] .hero-card {
  background: rgba(0, 0, 0, 0.5);
  border-color: rgba(255, 255, 255, 0.08);
}

.hero-title {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #111;
  margin: 0 0 0.6rem;
  min-height: 1.25em;
  line-height: 1.2;
}

[data-theme="dark"] .hero-title { color: #fff; }

.hero-cursor {
  display: inline-block;
  width: 3px;
  height: 0.85em;
  background: #111;
  vertical-align: middle;
  margin-left: 3px;
  border-radius: 2px;
}

[data-theme="dark"] .hero-cursor { background: #fff; }

.hero-subtitle {
  color: rgba(0, 0, 0, 0.6);
  font-size: 1.05rem;
  margin: 0;
  line-height: 1.6;
}

[data-theme="dark"] .hero-subtitle { color: rgba(255, 255, 255, 0.7); }

.hero-scroll {
  position: absolute;
  bottom: 2.2rem;
  color: var(--muted-color);
  font-size: 1.4rem;
  text-decoration: none;
  animation: heroBounce 2.2s ease-in-out infinite;
  opacity: 0.8;
  transition: opacity 0.2s;
}
.hero-scroll:hover { opacity: 1; color: var(--body-color); }

@keyframes heroFadeIn {
  from { opacity: 0; transform: translateY(28px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

@keyframes heroBounce {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(9px); }
}

@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

@media (max-width: 576px) {
  .hero-card { padding: 2.5rem 1.8rem; }
}

/* ── TOC Sidebar ──────────────────────────────────── */
#tocNav {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.toc-link {
  display: block;
  padding: 4px 8px;
  font-size: 0.82rem;
  color: var(--muted-color);
  text-decoration: none;
  border-left: 2px solid transparent;
  border-radius: 0 4px 4px 0;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.toc-link:hover {
  color: var(--body-color);
  background: rgba(128,128,128,0.08);
  border-left-color: rgba(128,128,128,0.3);
}
.toc-link.active {
  color: #0d6efd;
  border-left-color: #0d6efd;
  font-weight: 500;
}

.toc-num {
  color: #0d6efd;
  font-weight: 600;
  font-size: 0.82em;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  flex-shrink: 0;
  margin-right: 1px;
}
.toc-link.active .toc-num { color: #0d6efd; }

/* 缩进层级 */
.toc-h1 { padding-left: 8px; }
.toc-h2 { padding-left: 8px; }
.toc-h3 { padding-left: 20px; font-size: 0.79rem; }
.toc-h4 { padding-left: 32px; font-size: 0.76rem; }

/* ── Lightbox ─────────────────────────────────────── */
#lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  align-items: center;
  justify-content: center;
}
#lightbox.active { display: flex; }

.lb-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: lbFadeIn 0.22s ease both;
}

.lb-img {
  position: relative;
  max-width: 88vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 12px 60px rgba(0, 0, 0, 0.6);
  animation: lbZoomIn 0.25s cubic-bezier(.22,1,.36,1) both;
  cursor: zoom-out;
}

.lb-close {
  position: absolute;
  top: 1.2rem;
  right: 1.2rem;
  z-index: 1;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.15s;
}
.lb-close:hover { background: rgba(255, 255, 255, 0.28); }

@keyframes lbFadeIn {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes lbZoomIn {
  from { opacity: 0; transform: scale(0.88); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── Comments ─────────────────────────────────────── */
.comment-item + .comment-item {
  border-top: 1px solid var(--border-subtle);
  padding-top: 1rem;
}
.comment-item p { word-break: break-word; }

/* ── KaTeX math ───────────────────────────────────── */
.post-content .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.4rem 0;
}
.post-content .katex { font-size: 1.05em; }

/* ── Navbar search ────────────────────────────────── */
.navbar-search input::placeholder { color: rgba(255,255,255,0.5) !important; }
.navbar-search input:focus {
  background: rgba(255,255,255,0.18) !important;
  border-color: rgba(255,255,255,0.4) !important;
  color: #fff !important;
  box-shadow: none !important;
}
.navbar-search-btn {
  background: rgba(255,255,255,0.1) !important;
  border: 1px solid rgba(255,255,255,0.2) !important;
  border-left: none !important;
  color: rgba(255,255,255,0.85) !important;
  border-radius: 0 4px 4px 0 !important;
}
.navbar-search-btn:hover, .navbar-search-btn:focus {
  background: rgba(255,255,255,0.22) !important;
  color: #fff !important;
  box-shadow: none !important;
}

/* ── Tag color-dot picker (admin) ─────────────────── */
.color-dot {
  display: inline-block;
  width: 22px; height: 22px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.15s, border-color 0.15s;
}
.color-dot:hover { transform: scale(1.2); }
input[type="radio"]:checked + .color-dot {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.35);
  transform: scale(1.15);
}

/* ── Slideshow background ─────────────────────────── */
#bg-slideshow {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}

#bg-slideshow .bg-layer {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 1.5s ease-in-out;
  will-change: opacity;
}

#bg-slideshow .bg-layer.active {
  opacity: 1;
}

/* ── Dark mode toggle button ─────────────────────── */
#themeToggle {
  background: none;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 20px;
  color: rgba(255,255,255,0.85);
  padding: 4px 10px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s ease;
}
#themeToggle:hover { background: rgba(255,255,255,0.15); }
