/* ============================================
   HYA的赛博小屋 — 全局共用样式
   设计原则：克制、简洁、无紫色/粉色/霓虹色
   参考：GitHub / Notion / Apple 的灰色调美学
   由 build.py 自动生成页面时引用
   ============================================ */

/* ---------- CSS 变量（浅色/深色模式） ---------- */
:root {
  --bg: #ffffff;
  --bg-secondary: #f6f8fa;
  --text: #1f2328;
  --text-secondary: #656d76;
  --border: #d0d7de;
  --accent: #0969da;
  --accent-hover: #0550ae;
  --card-bg: #ffffff;
  --card-border: #d0d7de;
  --hover-bg: #f3f4f6;
  --code-bg: #f6f8fa;
  --tag-bg: #eef1f5;
  --shadow: 0 1px 2px rgba(31, 35, 40, 0.04);
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono-font: "SF Mono", "Cascadia Code", "Consolas", "Fira Code", monospace;
}

[data-theme="dark"] {
  --bg: #0d1117;
  --bg-secondary: #161b22;
  --text: #c9d1d9;
  --text-secondary: #8b949e;
  --border: #30363d;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --card-bg: #161b22;
  --card-border: #30363d;
  --hover-bg: #21262d;
  --code-bg: #1c2128;
  --tag-bg: #21262d;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  min-height: 100vh;
  transition: background-color 0.2s ease, color 0.2s ease;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* ---------- 顶部 Header ---------- */
.site-header {
  border-bottom: 1px solid var(--border);
  background-color: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.site-header-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.site-logo {
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.3px;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}

.site-logo:hover {
  color: var(--accent);
  text-decoration: none;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.site-nav a {
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: 6px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.site-nav a:hover {
  color: var(--text);
  background-color: var(--hover-bg);
  text-decoration: none;
}

.site-nav a.active {
  color: var(--accent);
  font-weight: 600;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px 9px;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1;
  transition: all 0.15s ease;
  flex-shrink: 0;
  margin-left: 4px;
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- 主内容区 ---------- */
.main-content {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 24px 48px;
  flex: 1;
}

/* ---------- 首页 Hero ---------- */
.page-title {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
  color: var(--text);
}

.page-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.site-intro {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 20px;
}

.divider {
  border: none;
  height: 1px;
  background-color: var(--border);
  margin: 24px 0;
}

.section-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

/* ---------- 首页模块卡片 ---------- */
.module-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.module-item {
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s ease, border-color 0.15s ease, background-color 0.2s ease;
  overflow: hidden;
}

.module-item:hover {
  box-shadow: 0 4px 12px rgba(31, 35, 40, 0.08);
  border-color: var(--accent);
}

[data-theme="dark"] .module-item:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.module-item-main {
  display: block;
  padding: 18px 24px;
  text-decoration: none;
  color: inherit;
  transition: background-color 0.15s ease;
}

.module-item-main:hover {
  text-decoration: none;
  color: inherit;
  background-color: var(--hover-bg);
}

.module-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.module-item-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.module-item-arrow {
  font-size: 14px;
  color: var(--text-secondary);
  transition: transform 0.15s ease, color 0.15s ease;
}

.module-item:hover .module-item-arrow {
  transform: translateX(2px);
  color: var(--accent);
}

.module-item-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* 模块最近链接 */
.module-recent {
  padding: 0 24px 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.recent-link {
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 4px 10px;
  background-color: var(--tag-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: all 0.15s ease;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-link:hover {
  color: var(--accent);
  background-color: var(--hover-bg);
  border-color: var(--accent);
  text-decoration: none;
}

/* ---------- 列表页 ---------- */
.content-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.content-list-item {
  display: block;
  background-color: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.2s ease;
}

.content-list-item:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(31, 35, 40, 0.08);
  text-decoration: none;
  color: inherit;
}

[data-theme="dark"] .content-list-item:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.content-list-item-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.4;
}

.content-list-item-meta {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.content-list-item-summary {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ---------- 空状态 ---------- */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-secondary);
  font-size: 15px;
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.empty-state-desc {
  font-size: 14px;
  color: var(--text-secondary);
}

/* ---------- 面包屑 ---------- */
.breadcrumb {
  margin-bottom: 20px;
  font-size: 14px;
  color: var(--text-secondary);
}

.breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* ---------- 文章详情页 ---------- */
.article-detail {
  max-width: 100%;
}

.back-link {
  display: inline-block;
  font-size: 14px;
  color: var(--text-secondary);
  text-decoration: none;
  margin-bottom: 20px;
  transition: color 0.15s ease;
}

.back-link:hover {
  color: var(--accent);
  text-decoration: none;
}

.article-title {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.article-date {
  color: var(--text-secondary);
}

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

.article-tag {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  background-color: var(--tag-bg);
  border-radius: 4px;
  color: var(--accent);
}

/* 文章正文排版 */
.article-body {
  font-size: 16px;
  line-height: 1.8;
  color: var(--text);
}

.article-body h1 {
  font-size: 26px;
  font-weight: 700;
  margin: 32px 0 16px;
  line-height: 1.3;
}

.article-body h2 {
  font-size: 22px;
  font-weight: 600;
  margin: 28px 0 12px;
  line-height: 1.4;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.article-body h3 {
  font-size: 18px;
  font-weight: 600;
  margin: 24px 0 10px;
  line-height: 1.4;
}

.article-body p {
  margin-bottom: 16px;
}

.article-body ul,
.article-body ol {
  margin-bottom: 16px;
  padding-left: 24px;
}

.article-body li {
  margin-bottom: 6px;
  line-height: 1.7;
}

.article-body blockquote {
  margin: 16px 0;
  padding: 12px 20px;
  border-left: 4px solid var(--accent);
  background-color: var(--bg-secondary);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--text-secondary);
}

.article-body blockquote p {
  margin-bottom: 0;
}

.article-body code {
  font-family: var(--mono-font);
  font-size: 0.875em;
  padding: 2px 6px;
  background-color: var(--code-bg);
  border-radius: 4px;
  border: 1px solid var(--border);
}

.article-body pre {
  margin: 16px 0;
  padding: 16px 20px;
  background-color: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  line-height: 1.5;
}

.article-body pre code {
  padding: 0;
  background: none;
  border: none;
  font-size: 14px;
}

.article-body hr {
  border: none;
  height: 1px;
  background-color: var(--border);
  margin: 32px 0;
}

.article-body img {
  max-width: 100%;
  border-radius: var(--radius);
  margin: 16px 0;
}

.article-body strong {
  font-weight: 600;
  color: var(--text);
}

.article-body a {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.article-body a:hover {
  color: var(--accent-hover);
}

/* ---------- 底部 Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  transition: border-color 0.2s ease;
}

.footer-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 24px;
  text-align: center;
}

.footer-text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.8;
}

.footer-text a {
  color: var(--text-secondary);
  text-decoration: none;
}

.footer-text a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.footer-build-info {
  font-size: 12px;
  margin-top: 2px;
  opacity: 0.7;
}

/* ---------- 响应式适配 ---------- */
@media (max-width: 640px) {
  .module-list {
    grid-template-columns: 1fr;
  }

  .site-header-inner {
    padding: 12px 16px;
  }

  .main-content {
    padding: 24px 16px 36px;
  }

  .footer-inner {
    padding: 16px;
  }

  .page-title {
    font-size: 26px;
  }

  .article-title {
    font-size: 24px;
  }

  .module-item-main {
    padding: 16px 20px;
  }

  .module-recent {
    padding: 0 20px 12px;
  }

  .content-list-item {
    padding: 16px 20px;
  }
}

@media (max-width: 400px) {
  .site-header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .site-nav {
    width: 100%;
  }
}
