/* =========================================================
   个人门户站 · 全站样式
   结构：变量与主题 → 基础布局 → 页头/页脚 → 首页区块 → 子页通用 → 响应式
   ========================================================= */

/* ---------- 变量与主题（浅色默认，深色跟随系统 + 可手动切换） ---------- */
:root {
  --bg: #fafafa;
  --bg-soft: #f2f2f2;
  --surface: #ffffff;
  --border: #e4e4e4;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --accent: #3b82f6;
  --accent-strong: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.12);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 8px 24px rgba(0, 0, 0, 0.06);
  --radius: 14px;
  --max-width: 960px;
}

html[data-theme="dark"] {
  --bg: #121417;
  --bg-soft: #171a1f;
  --surface: #1c2027;
  --border: #2b303a;
  --text: #e8eaed;
  --text-muted: #9aa1ac;
  --accent: #60a5fa;
  --accent-strong: #93c5fd;
  --accent-soft: rgba(96, 165, 250, 0.14);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
}

/* 首帧防闪烁：在 CSS 加载前按系统/偏好设定主题（内联于各页 <head>） */

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

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

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  transition: background-color 0.25s ease, color 0.25s ease;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

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

a:hover {
  color: var(--accent-strong);
}

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

.container {
  width: 100%;
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: 20px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  border-radius: 0 0 8px 0;
  z-index: 100;
}

.skip-link:focus {
  left: 0;
}

/* ---------- 页头 ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 60px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 17px;
  color: var(--text);
}

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

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 20px;
  line-height: 1;
}

.site-nav {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.site-nav a {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 15px;
}

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

.site-nav a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 600;
}

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font-size: 15px;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.theme-toggle:hover {
  background: var(--bg-soft);
  transform: translateY(-1px);
}

/* 浅色下只显示月亮（点击切到深色），深色下只显示太阳 */
.theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-sun { display: inline; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: inline; }

/* ---------- 首页问候区 ---------- */
.hero {
  padding: 88px 20px 56px;
  text-align: center;
}

.hero-greeting {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 15px;
  letter-spacing: 0.12em;
}

.hero-title {
  margin: 0 0 14px;
  font-size: clamp(30px, 6vw, 46px);
  line-height: 1.25;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.hero-title .accent {
  color: var(--accent);
}

.hero-sub {
  margin: 0 auto 28px;
  max-width: 34em;
  color: var(--text-muted);
  font-size: 17px;
}

.hero-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-strong);
  color: #fff;
  box-shadow: 0 6px 18px var(--accent-soft);
}

.btn-ghost {
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--surface);
}

.btn-ghost:hover {
  background: var(--bg-soft);
}

/* ---------- 门户导航卡片 ---------- */
.portal {
  padding-bottom: 72px;
}

.section-title {
  margin: 0 0 20px;
  font-size: 20px;
  font-weight: 700;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.card {
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}

.card-icon {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-bottom: 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 14px;
}

.card-title {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 700;
}

.card-title a {
  color: var(--text);
}

.card-title a::after {
  /* 让整张卡片可点击 */
  content: "";
  position: absolute;
  inset: 0;
}

.card {
  position: relative;
}

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

.card-desc {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

/* 卡片内直达链接 */
.card-links {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 2px;
}

.card-links a {
  display: block;
  padding: 5px 8px;
  margin-inline: -8px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 14px;
  /* 提到整卡点击覆盖层之上，否则点不到 */
  position: relative;
  z-index: 1;
}

.card-links a:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.card-more {
  display: inline-block;
  margin-top: 10px;
  color: var(--accent);
  font-size: 13px;
  position: relative;
  z-index: 1;
}

/* ---------- 页脚 ---------- */
.site-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  background: var(--bg-soft);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 20px;
  align-items: center;
  justify-content: space-between;
  padding-block: 18px;
}

.footer-line {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.footer-line .icp {
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.footer-line .icp:hover {
  color: var(--accent);
}

/* ---------- 子页通用（blog / tools / links / about） ---------- */
.page-head {
  padding: 56px 20px 8px;
}

.page-head h1 {
  margin: 0 0 8px;
  font-size: clamp(26px, 5vw, 34px);
  font-weight: 800;
}

.page-head p {
  margin: 0;
  color: var(--text-muted);
}

.page-body {
  padding: 28px 20px 72px;
}

.panel {
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.panel p {
  margin: 0 0 10px;
  color: var(--text-muted);
}

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

.link-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.link-list a {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.link-list a:hover {
  border-color: var(--accent);
  transform: translateX(2px);
}

.link-list .link-name {
  font-weight: 600;
  white-space: nowrap;
}

.link-list .link-note {
  color: var(--text-muted);
  font-size: 14px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .header-inner {
    flex-wrap: wrap;
    height: auto;
    padding-block: 10px;
    row-gap: 4px;
  }

  .site-nav {
    width: 100%;
    margin-left: 0;
    order: 3;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .theme-toggle {
    margin-left: auto;
  }

  .hero {
    padding: 56px 20px 40px;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

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

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
