/* ==================================================================
   纯静态个人博客 - 基础样式与亮色主题
   ================================================================== */

/* ---------- 主题变量（亮色默认值 + 暗色取值，供 dark.css 引用） ---------- */
:root {
  color-scheme: light;

  /* 亮色主题 */
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --surface-3: rgba(0, 0, 0, 0.05);
  --text: #1f2430;
  --text-muted: #5c6672;
  --border: #e2e6ec;
  --accent: #4f6ef7;
  --accent-soft: rgba(79, 110, 247, 0.12);
  --accent-2: #8b5cf6;
  --navbar-bg: rgba(255, 255, 255, 0.82);
  --overlay-bg: rgba(245, 247, 250, 0.72);
  --shadow-sm: 0 1px 3px rgba(17, 24, 39, 0.06);
  --shadow-md: 0 6px 24px rgba(17, 24, 39, 0.08);

  /* 暗色取值（由 dark.css 映射） */
  --bg-dark: #0d1117;
  --surface-dark: #161b22;
  --surface-2-dark: #1f2630;
  --surface-3-dark: rgba(255, 255, 255, 0.07);
  --text-dark: #e6edf3;
  --text-muted-dark: #8b949e;
  --border-dark: #30363d;
  --accent-dark: #58a6ff;
  --accent-soft-dark: rgba(88, 166, 255, 0.14);
  --accent-2-dark: #bc8cff;
  --navbar-bg-dark: rgba(13, 17, 23, 0.85);
  --overlay-bg-dark: rgba(13, 17, 23, 0.72);
  --shadow-sm-dark: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md-dark: 0 8px 26px rgba(0, 0, 0, 0.55);

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --navbar-h: 62px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-family);
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  transition: background-color .3s ease, color .3s ease;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 { margin: 0; line-height: 1.3; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }

.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.container-narrow { max-width: 820px; }
[hidden] { display: none !important; }

.main { flex: 1; }
.page { min-height: calc(100vh - 80px); }

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

/* 细滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 导航栏 ---------- */
/* 固定悬浮在页面顶部，Hero 背景图从页面最顶部开始显示，不再被导航栏占位下压 */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: var(--navbar-h);
  background: transparent;                 /* 页面在最顶部时全透明 */
  border-bottom: 1px solid transparent;
  transition: background-color .3s ease,
              border-color .3s ease,
              transform .5s var(--ease),
              box-shadow .3s ease;
}

/* 滚动后：恢复原来的半透明毛玻璃背景 */
.navbar.scrolled {
  background: var(--navbar-bg);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom-color: var(--border);
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.05);
}

/* 下滑时平滑收起隐藏，上滑时显示（transform 过渡由 .hidden 控制） */
.navbar.hidden { transform: translateY(-100%); }

/* 首页 Hero 顶部：透明导航栏上的 Logo 与图标使用白色，保证在深色背景图上可读 */
body.on-hero .navbar:not(.scrolled) .logo,
body.on-hero .navbar:not(.scrolled) .icon-btn { color: #fff; }
body.on-hero .navbar:not(.scrolled) .icon-btn:hover { background: rgba(255, 255, 255, 0.16); color: #fff; }

.navbar-inner { display: flex; align-items: center; justify-content: space-between; height: 100%; }

.logo { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 18px; transition: color .2s; }
.logo:hover { color: var(--accent); }
.logo-icon { width:28px;height:28px;border-radius:4px; }
.nav-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border: none; border-radius: 10px;
  background: transparent; color: var(--text-muted);
  transition: background-color .2s, color .2s;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }

/* 主题按钮：暗色显示太阳、亮色显示月亮（CSS 由 data-theme 控制） */
#themeIconSun { display: none; }
[data-theme="dark"] #themeIconMoon { display: none; }
[data-theme="dark"] #themeIconSun { display: block; }

/* ---------- Hero 全屏首屏 ---------- */
.hero {
  position: relative;
  height: 100vh;
  min-height: 540px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.hero-bg {
  position: absolute; inset: 0;
  background: url("../images/bg.png") center / cover no-repeat;
}
.hero-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(10, 10, 24, 0.35) 0%, rgba(10, 10, 24, 0.55) 100%);
}
.hero-content {
  position: relative; z-index: 2;
  text-align: center; color: #fff;
  padding: 0 20px; max-width: 720px;
  animation: fadeUp .9s var(--ease) both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
.hero-avatar {
  width: 160px; height: 160px; border-radius: 50%;
  margin: 0 auto 22px; object-fit: cover;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}
.hero-name { font-size: 30px; letter-spacing: 3px; font-weight: 700; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.4); }
.hero-hitokoto {
  margin-top: 14px; font-size: 16px; min-height: 24px; opacity: .95;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.4);
}

/* ---------- 跳动的向下箭头（简洁优雅） ---------- */
.scroll-down {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(8px);
  padding: 12px;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  transition: background 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
  animation: float 3.6s ease-in-out infinite;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.scroll-down:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateX(-50%) scale(1.08);
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.3);
}

.scroll-down:active {
  transform: translateX(-50%) scale(0.95);
}

.arrow-icon {
  width: 26px;
  height: 26px;
  display: block;
  stroke: #fff;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

@keyframes float {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50%      { transform: translateX(-50%) translateY(8px); }
}

/* ---------- 文章列表 ---------- */
.post-list-section {
  position: relative;
  padding: 56px 0 72px;
  background: var(--bg);
}
.section-title {
  font-size: 24px; font-weight: 700; margin-bottom: 26px;
  display: flex; align-items: center; gap: 12px;
}
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.post-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}
/* 文章卡片 */
.post-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s;
  color: var(--text);
  text-decoration: none;
}

.post-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}
.post-card-image {
  position: relative;
  width: 100%;
  height: 220px;                /* 可根据喜好调整 */
  background-color: var(--surface-2);
  overflow: hidden;
  flex-shrink: 0;
}

/* 涟漪占位（环） */
.ripple-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 48px;
  height: 48px;
  margin: -24px 0 0 -24px;
  border-radius: 50%;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 实际图片 */
.post-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;               /* 默认隐藏，加载后显示 */
}
.post-card-date-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 12px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 5px;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  z-index: 2;
  pointer-events: none;
}
.post-card-title-tag {
  position: absolute;
  bottom: 5px;
  left: 12px;
  right: 12px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.80);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 1px;
  color: #444;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.4;
  z-index: 2;
  pointer-events: none;
  /* 限制最多两行 */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-card-title { font-size: 18px; font-weight: 600; line-height: 1.45; }
.post-card:hover .post-card-title { color: var(--accent); }
.post-card-date { font-size: 13px; color: var(--text-muted); }
.post-card-body {
  padding: 14px 18px 18px;
  flex: 1;
}

.post-card-summary {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
  /* 限制最多 3 行 */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.empty { text-align: center; color: var(--text-muted); padding: 60px 0; }

/* ---------- 分页 ---------- */
.pagination {
  display: flex; align-items: center; justify-content: center;
  flex-wrap: wrap; gap: 8px; margin-top: 32px;
}
.pagination button {
  min-width: 38px; height: 38px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text-muted);
  font-size: 14px; transition: all .2s;
}
.pagination button:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.pagination button.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }
.page-dots { color: var(--text-muted); padding: 0 2px; }

/* ---------- 文章详情 ---------- */
.post-page { padding: calc(var(--navbar-h) + 36px) 0 72px; }
.post-detail-title { font-size: 32px; font-weight: 700; line-height: 1.35; }
.post-detail-meta { margin: 14px 0 6px; color: var(--text-muted); font-size: 14px; display: flex; align-items: center; gap: 6px; }

.post-content {
  margin-top: 22px;
  font-size: 16.5px; line-height: 1.85; color: var(--text);
  word-wrap: break-word;
}
.post-content p { margin: 0 0 1.1em; }
.post-content h1, .post-content h2, .post-content h3, .post-content h4 { margin: 1.4em 0 .6em; }
.post-content h1 { font-size: 1.7em; }
.post-content h2 { font-size: 1.45em; padding-bottom: .3em; border-bottom: 1px solid var(--border); }
.post-content h3 { font-size: 1.25em; }
.post-content a { text-decoration: underline; text-underline-offset: 3px; }
.post-content ul, .post-content ol { margin: 0 0 1.1em; padding-left: 1.4em; }
.post-content ul { list-style: disc; }
.post-content ol { list-style: decimal; }
.post-content blockquote {
  margin: 1.2em 0; padding: .6em 1em;
  border-left: 4px solid var(--accent);
  background: var(--surface-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-muted);
}
.post-content code {
  font-family: var(--font-mono); font-size: .9em;
  background: var(--surface-3); padding: .15em .4em; border-radius: 6px;
}
.post-content pre {
  background: #0d1117; color: #e6edf3;
  padding: 16px 18px; border-radius: 12px; overflow: auto;
  line-height: 1.6; margin: 1.2em 0;
}
.post-content pre code { background: none; padding: 0; color: inherit; font-size: .9em; }
.post-content img { border-radius: 12px; margin: 1em 0; }
.post-content table { border-collapse: collapse; width: 100%; margin: 1em 0; }
.post-content th, .post-content td { border: 1px solid var(--border); padding: 8px 12px; }
.post-content th { background: var(--surface-2); }

.back-home {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 40px; font-size: 14px; color: var(--text-muted);
  transition: color .2s;
}
.back-home:hover { color: var(--accent); }

/* ---------- 关于页 ---------- */
.about-page { padding: calc(var(--navbar-h) + 36px) 0 72px; }
.about-content {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 30px;
}
.about-content h2 { font-size: 20px; margin: 0 0 10px; }
.about-content p { margin-bottom: 1em; color: var(--text-muted); }
.about-content ul { list-style: disc; padding-left: 1.4em; margin-bottom: 1em; }
.about-content li { margin-bottom: 6px; color: var(--text-muted); }
.about-content code { font-family: var(--font-mono); background: var(--surface-3); padding: .15em .4em; border-radius: 6px; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 200;
  width: 300px; max-width: 85vw;
  background: var(--surface);
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.12);
  transform: translateX(100%);
  transition: transform .35s var(--ease);
}
.sidebar.open { transform: translateX(0); }
.sidebar-inner { display: flex; flex-direction: column; height: 100%; padding: 28px 24px; }
.sidebar-profile { text-align: center; padding-bottom: 22px; border-bottom: 1px solid var(--border); }
.sidebar-profile img {
  width: 84px; height: 84px; border-radius: 50%;
  margin: 0 auto 12px; object-fit: cover;
  border: 2px solid var(--accent);
}
.sidebar-profile h3 { font-size: 18px; }
.sidebar-profile p { color: var(--text-muted); font-size: 13px; margin-top: 6px; }
.sidebar-nav { flex: 1; padding-top: 18px; display: flex; flex-direction: column; gap: 4px; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 10px;
  color: var(--text); font-size: 15px;
  transition: background .2s, color .2s;
}
.sidebar-link:hover { background: var(--surface-3); }
.sidebar-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.sidebar-link svg { width: 19px; height: 19px; }
.sidebar-footer { padding-top: 16px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 13px; text-align: center; }
.sidebar-mask {
  position: fixed; inset: 0; z-index: 190;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

/* ---------- 搜索浮层 ---------- */
.search-overlay {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 12vh 20px 20px;
  animation: fadeIn .25s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.search-box {
  width: 100%; max-width: 620px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  animation: popIn .3s var(--ease);
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(-12px) scale(.98); }
  to   { opacity: 1; transform: none; }
}
.search-input-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.search-icon { width: 20px; height: 20px; color: var(--text-muted); flex-shrink: 0; }
.search-input-wrap input {
  flex: 1; border: none; outline: none;
  font-size: 16px; background: transparent; color: var(--text);
}
.search-input-wrap input::placeholder { color: var(--text-muted); }
.search-clear { border: none; background: none; font-size: 24px; line-height: 1; color: var(--text-muted); }
.search-clear:hover { color: var(--text); }
.search-results { max-height: 46vh; overflow: auto; padding: 8px; }
.search-hint, .search-empty { padding: 18px; text-align: center; color: var(--text-muted); font-size: 14px; }
.search-item { display: block; padding: 12px 14px; border-radius: 10px; color: var(--text); transition: background .2s; }
.search-item:hover { background: var(--surface-2); }
.search-item-title { font-size: 15px; font-weight: 600; }
.search-item-date { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ---------- 加载遮罩 ---------- */
.loading-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: var(--overlay-bg);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
}
.spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 提示气泡 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 20px);
  z-index: 600;
  padding: 12px 20px; border-radius: 12px;
  background: var(--text); color: var(--bg);
  font-size: 14px; box-shadow: var(--shadow-md);
  opacity: 0; transition: opacity .3s, transform .3s;
  pointer-events: none; max-width: 86vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #e5484d; color: #fff; }
.toast.success { background: #30a46c; color: #fff; }

/* ---------- 页脚 ---------- */
.footer {
  padding: 26px 0;
  border-top: 1px solid var(--border);
  background: var(--surface);
  text-align: center; color: var(--text-muted); font-size: 13px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 768px) {
  .hero-name { font-size: 24px; }
  .hero-avatar { width: 130px; height: 130px; }
  .post-grid { grid-template-columns: 1fr; }
  .post-list-section { padding: 40px 0 56px; }
  .post-detail-title { font-size: 24px; }
}
@media (max-width: 480px) {
  .container { padding: 0 16px; }
  .navbar-inner { padding: 0 12px; }
}