/* ============ 主题变量 ============ */
:root {
  --bg: #07070d;
  --fg: #e8e8f0;
  --muted: #9093a8;
  --line: rgba(255, 255, 255, .08);
  --glass: rgba(20, 20, 34, .55);
  --glass-hi: rgba(255, 255, 255, .06);
  --c1: #7c5cff;
  --c2: #00d4ff;
  --c3: #ff4fd8;
  --accent: #8f7bff;
  --code-bg: rgba(0, 0, 0, .45);
  --shadow: 0 10px 40px rgba(0, 0, 0, .45);
  --grid: rgba(255, 255, 255, .035);
  --aurora-op: .55;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f5fb;
  --fg: #1c1d2b;
  --muted: #646880;
  --line: rgba(20, 20, 60, .1);
  --glass: rgba(255, 255, 255, .62);
  --glass-hi: rgba(255, 255, 255, .8);
  --accent: #5b3ff0;
  --code-bg: #171827;
  --shadow: 0 10px 40px rgba(60, 60, 120, .12);
  --grid: rgba(20, 20, 80, .04);
  --aurora-op: .35;
  color-scheme: light;
}

/* ============ 基础 ============ */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 84px; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--fg);
  font: 16px/1.85 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  overflow-x: hidden;
  transition: background-color .4s, color .4s;
}
::selection { background: var(--c1); color: #fff; }
a { color: var(--accent); text-decoration: none; }
main { flex: 1; position: relative; z-index: 1; }
.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 20px; }
.wrap.narrow { max-width: 800px; }
.muted, .empty { color: var(--muted); }
.glass {
  background: var(--glass);
  border: 1px solid var(--line);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: var(--shadow);
  border-radius: 18px;
}

/* ============ 动态背景 ============ */
.bg { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.aurora { position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%; filter: blur(90px); opacity: var(--aurora-op); will-change: transform; }
.a1 { background: radial-gradient(circle, var(--c1), transparent 65%); top: -25vmax; left: -15vmax; animation: float1 22s ease-in-out infinite alternate; }
.a2 { background: radial-gradient(circle, var(--c2), transparent 65%); top: -10vmax; right: -25vmax; animation: float2 26s ease-in-out infinite alternate; }
.a3 { background: radial-gradient(circle, var(--c3), transparent 65%); bottom: -35vmax; left: 20vmax; opacity: calc(var(--aurora-op) * .6); animation: float3 30s ease-in-out infinite alternate; }
@keyframes float1 { to { transform: translate(18vmax, 12vmax) scale(1.15); } }
@keyframes float2 { to { transform: translate(-16vmax, 18vmax) scale(.9); } }
@keyframes float3 { to { transform: translate(-12vmax, -10vmax) scale(1.2); } }
.grid {
  position: absolute; inset: 0;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at 50% 0%, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at 50% 0%, #000 30%, transparent 75%);
}
#stars { position: absolute; inset: 0; width: 100%; height: 100%; }

/* ============ 阅读进度条 ============ */
.progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 60; }
.progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--c1), var(--c2), var(--c3)); box-shadow: 0 0 12px var(--c2); }

/* ============ 顶部导航 ============ */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 16px; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--fg); font-weight: 700; font-size: 17px; }
.logo-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; font-size: 16px;
  background: linear-gradient(135deg, var(--c1), var(--c2)); box-shadow: 0 0 20px rgba(124, 92, 255, .5);
}
.site-header nav { display: flex; align-items: center; gap: 4px; }
.site-header nav a { color: var(--muted); font-size: 15px; padding: 6px 14px; border-radius: 999px; transition: .25s; }
.site-header nav a:hover { color: var(--fg); background: var(--glass-hi); }
.site-header nav a.active { color: var(--fg); background: var(--glass-hi); box-shadow: inset 0 0 0 1px var(--line); }
.theme { margin-left: 6px; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--glass-hi); color: var(--fg); cursor: pointer; display: grid; place-items: center; transition: transform .4s; }
.theme:hover { transform: rotate(30deg); }
.theme svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.theme .i-moon { display: none; }
:root[data-theme="light"] .theme .i-sun { display: none; }
:root[data-theme="light"] .theme .i-moon { display: block; }

/* ============ 首页 Hero ============ */
.hero { min-height: calc(100vh - 64px); display: flex; align-items: center; text-align: center; position: relative; padding: 60px 0 100px; }
.hello {
  display: inline-block; margin: 0 0 18px; padding: 6px 16px; border-radius: 999px; font-size: 14px; letter-spacing: .5px;
  background: var(--glass-hi); border: 1px solid var(--line); color: var(--muted);
}
.hello::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #2ee59d; margin-right: 8px; box-shadow: 0 0 10px #2ee59d; animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.hero-title, .glow-title {
  margin: 0; font-weight: 800; letter-spacing: -1px; line-height: 1.15;
  background: linear-gradient(110deg, var(--fg) 20%, var(--c2) 40%, var(--c1) 55%, var(--c3) 70%, var(--fg) 90%);
  background-size: 250% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shine 8s linear infinite;
}
.hero-title { font-size: clamp(44px, 9vw, 96px); filter: drop-shadow(0 0 40px rgba(124, 92, 255, .35)); }
@keyframes shine { to { background-position: -250% 0; } }
.typing { font-size: clamp(18px, 2.6vw, 24px); color: var(--muted); margin: 22px 0 40px; min-height: 1.6em; font-family: SFMono-Regular, Consolas, Menlo, "PingFang SC", monospace; }
.caret { display: inline-block; width: 2px; height: 1.1em; vertical-align: -0.15em; margin-left: 4px; background: var(--c2); box-shadow: 0 0 8px var(--c2); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.stats { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; }
.stat { min-width: 120px; padding: 16px 22px; display: flex; flex-direction: column; align-items: center; }
.stat b { font-size: 30px; line-height: 1.2; background: linear-gradient(135deg, var(--c2), var(--c1)); -webkit-background-clip: text; background-clip: text; color: transparent; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }
.scroll-hint { position: absolute; left: 50%; bottom: 28px; transform: translateX(-50%); width: 26px; height: 42px; border: 2px solid var(--line); border-radius: 14px; }
.scroll-hint span { position: absolute; left: 50%; top: 8px; width: 4px; height: 8px; margin-left: -2px; border-radius: 2px; background: var(--c2); animation: wheel 1.8s infinite; }
@keyframes wheel { 0% { opacity: 1; transform: translateY(0); } 100% { opacity: 0; transform: translateY(14px); } }

/* ============ 文章卡片 ============ */
.section-title { font-size: 26px; margin: 20px 0 28px; display: flex; align-items: center; gap: 12px; }
.section-title::before { content: ""; width: 6px; height: 26px; border-radius: 3px; background: linear-gradient(var(--c2), var(--c1)); box-shadow: 0 0 12px var(--c1); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 24px; padding-bottom: 60px; }
.card {
  position: relative; display: flex; flex-direction: column; color: var(--fg); border-radius: 20px; overflow: hidden;
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  transition: transform .35s cubic-bezier(.2, .8, .2, 1), box-shadow .35s, border-color .35s;
  transform: perspective(900px) rotateX(var(--rx, 0)) rotateY(var(--ry, 0));
}
.card::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .35s;
  background: radial-gradient(400px circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, .12), transparent 45%);
}
.card:hover { border-color: rgba(143, 123, 255, .55); box-shadow: 0 20px 60px rgba(124, 92, 255, .25); }
.card:hover::after { opacity: 1; }
.cover {
  --h: 260; position: relative; height: 150px; overflow: hidden;
  background:
    radial-gradient(circle at 20% 30%, hsl(var(--h) 95% 65% / .9), transparent 55%),
    radial-gradient(circle at 80% 70%, hsl(calc(var(--h) + 60) 95% 60% / .85), transparent 55%),
    linear-gradient(135deg, hsl(calc(var(--h) + 200) 70% 18%), hsl(var(--h) 60% 12%));
}
.cover::before {
  content: ""; position: absolute; inset: 0;
  background-image: linear-gradient(rgba(255,255,255,.08) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.08) 1px, transparent 1px);
  background-size: 22px 22px;
}
.glyph { position: absolute; right: 18px; bottom: -22px; font-size: 120px; font-weight: 900; line-height: 1; color: rgba(255, 255, 255, .18); transition: transform .5s; }
.card:hover .glyph { transform: translateY(-8px) scale(1.06); }
.card-body { padding: 18px 22px 22px; display: flex; flex-direction: column; flex: 1; }
.card h2 { margin: 6px 0 8px; font-size: 20px; line-height: 1.45; }
.summary { margin: 0 0 14px; color: var(--muted); font-size: 14.5px; line-height: 1.75; flex: 1; }
.arrow { margin-top: 14px; font-size: 14px; color: var(--accent); transition: transform .3s; }
.card:hover .arrow { transform: translateX(6px); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; color: var(--muted); font-size: 13.5px; }
.tags { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.tag { padding: 1px 10px; border-radius: 999px; font-size: 12.5px; color: var(--accent); background: rgba(124, 92, 255, .12); border: 1px solid rgba(124, 92, 255, .25); }
.more { text-align: center; margin: 0 0 60px; }
.btn {
  display: inline-block; padding: 10px 26px; border-radius: 999px; color: #fff; font-weight: 600;
  background: linear-gradient(135deg, var(--c1), var(--c2)); box-shadow: 0 8px 30px rgba(124, 92, 255, .4); transition: transform .25s, box-shadow .25s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 12px 40px rgba(0, 212, 255, .45); }

/* ============ 文章页 ============ */
.post-hero, .page-hero { padding: 70px 0 40px; text-align: center; }
.post-hero .meta { justify-content: center; margin-bottom: 14px; }
.post-hero .glow-title, .page-hero .glow-title { font-size: clamp(30px, 5vw, 50px); margin-bottom: 18px; }
.post-hero .tags { justify-content: center; }
.post-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 28px; align-items: start; }
.post-layout.has-toc { grid-template-columns: minmax(0, 1fr) 230px; }
.post { padding: 36px 44px; margin-bottom: 30px; }
.toc { position: sticky; top: 90px; padding: 18px 16px; font-size: 14px; }
.toc-title { font-weight: 700; margin-bottom: 8px; padding-left: 10px; }
.toc a { display: block; color: var(--muted); padding: 5px 10px; border-left: 2px solid transparent; border-radius: 0 6px 6px 0; transition: .2s; line-height: 1.5; }
.toc a.lv3 { padding-left: 24px; font-size: 13px; }
.toc a:hover { color: var(--fg); }
.toc a.on { color: var(--fg); border-left-color: var(--c2); background: var(--glass-hi); }

.content { word-wrap: break-word; }
.content > :first-child { margin-top: 0; }
.content h2 { font-size: 23px; margin: 2em 0 .7em; display: flex; align-items: center; gap: 10px; }
.content h2::before { content: "#"; color: var(--c2); font-weight: 400; text-shadow: 0 0 12px var(--c2); }
.content h3 { font-size: 18.5px; margin: 1.6em 0 .5em; }
.content a { border-bottom: 1px dashed currentColor; }
.content img { max-width: 100%; height: auto; border-radius: 12px; display: block; margin: 1.4em auto; box-shadow: var(--shadow); }
.content blockquote { margin: 1.4em 0; padding: .6em 1.2em; border-radius: 0 12px 12px 0; border-left: 4px solid; border-image: linear-gradient(var(--c2), var(--c1)) 1; background: var(--glass-hi); color: var(--muted); }
.content blockquote p { margin: .4em 0; }
.content code { background: rgba(124, 92, 255, .14); color: var(--accent); padding: .15em .45em; border-radius: 6px; font-size: .88em; font-family: SFMono-Regular, Consolas, Menlo, monospace; }
.content hr { border: 0; height: 1px; margin: 2.4em 0; background: linear-gradient(90deg, transparent, var(--c1), var(--c2), transparent); }
.content ul, .content ol { padding-left: 1.5em; }
.content li::marker { color: var(--c2); }
.code { margin: 1.4em 0; border-radius: 14px; overflow: hidden; background: var(--code-bg); border: 1px solid var(--line); box-shadow: 0 8px 30px rgba(0, 0, 0, .3); }
.code-bar { display: flex; align-items: center; gap: 7px; padding: 10px 14px; background: rgba(255, 255, 255, .04); border-bottom: 1px solid rgba(255, 255, 255, .06); }
.code-bar i { width: 11px; height: 11px; border-radius: 50%; background: #ff5f57; }
.code-bar i:nth-child(2) { background: #febc2e; }
.code-bar i:nth-child(3) { background: #28c840; }
.code-bar span { margin-left: 8px; font-size: 12px; color: #8a8ca3; font-family: monospace; flex: 1; }
.copy { font-size: 12px; color: #b9bbd0; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .1); border-radius: 6px; padding: 2px 10px; cursor: pointer; }
.copy:hover { color: #fff; }
.code pre { margin: 0; padding: 16px 18px; overflow-x: auto; line-height: 1.65; }
.code pre code { background: none; padding: 0; color: #d6d8ee; font-size: 13.5px; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 10px 0 60px; }
.pager a { padding: 16px 20px; color: var(--fg); transition: transform .25s, border-color .25s; }
.pager a:hover { transform: translateY(-3px); border-color: rgba(143, 123, 255, .5); }
.pager small { display: block; color: var(--muted); font-size: 12px; }
.pager .next { text-align: right; }

/* ============ 归档时间线 ============ */
.timeline { max-width: 760px; margin: 0 auto 60px; position: relative; padding-left: 28px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 8px; bottom: 8px; width: 2px; background: linear-gradient(var(--c2), var(--c1), transparent); }
.year h2 { position: relative; font-size: 24px; margin: 18px 0 10px; }
.year h2::before { content: ""; position: absolute; left: -28px; top: 50%; width: 14px; height: 14px; margin-top: -7px; border-radius: 50%; background: var(--bg); border: 3px solid var(--c2); box-shadow: 0 0 14px var(--c2); }
.year h2 small { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 10px; }
.year ul { list-style: none; margin: 0 0 20px; padding: 0; }
.year li { display: flex; gap: 18px; padding: 10px 16px; border-radius: 12px; transition: background .25s, transform .25s; }
.year li:hover { background: var(--glass); transform: translateX(6px); }
.year time { color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; font-family: monospace; padding-top: 1px; }
.year a { color: var(--fg); }
.year li:hover a { color: var(--accent); }

/* ============ 404 ============ */
.notfound { text-align: center; padding: 120px 0; }
.glitch { position: relative; font-size: clamp(90px, 18vw, 180px); margin: 0; font-weight: 900; line-height: 1; color: var(--fg); }
.glitch::before, .glitch::after { content: attr(data-text); position: absolute; inset: 0; }
.glitch::before { color: var(--c2); animation: glitch 2.5s infinite; clip-path: inset(0 0 55% 0); }
.glitch::after { color: var(--c3); animation: glitch 2s infinite reverse; clip-path: inset(55% 0 0 0); }
@keyframes glitch { 0%, 90%, 100% { transform: none; } 92% { transform: translate(-6px, 2px); } 94% { transform: translate(6px, -2px); } 96% { transform: translate(-3px, 0); } }
.notfound p { color: var(--muted); }

/* ============ 页脚 ============ */
.site-footer { position: relative; z-index: 1; border-top: 1px solid var(--line); padding: 28px 0; color: var(--muted); font-size: 13px; text-align: center; background: color-mix(in srgb, var(--bg) 70%, transparent); }
.site-footer p { margin: 4px 0; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--fg); }
.beian { display: flex; justify-content: center; flex-wrap: wrap; gap: 4px 18px; }
.police { display: inline-flex; align-items: center; gap: 4px; }
.police img { width: 16px; height: 16px; }

.totop {
  position: fixed; right: 22px; bottom: 26px; z-index: 40; width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  color: #fff; font-size: 18px; background: linear-gradient(135deg, var(--c1), var(--c2)); box-shadow: 0 8px 26px rgba(124, 92, 255, .5);
  opacity: 0; transform: translateY(20px); pointer-events: none; transition: .3s;
}
.totop.show { opacity: 1; transform: none; pointer-events: auto; }

/* ============ 滚动渐入 ============ */
.js .reveal { opacity: 0; transform: translateY(28px); transition: opacity .8s ease, transform .8s cubic-bezier(.2, .8, .2, 1); transition-delay: var(--d, 0ms); }
.js .reveal.in { opacity: 1; transform: none; }
.js .card.reveal.in { transform: perspective(900px) rotateX(var(--rx, 0)) rotateY(var(--ry, 0)); transition: opacity .8s ease var(--d, 0ms), transform .35s cubic-bezier(.2, .8, .2, 1), box-shadow .35s, border-color .35s; }

/* ============ 响应式 ============ */
@media (max-width: 900px) {
  .post-layout.has-toc { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 600px) {
  .logo-text { display: none; }
  .site-header nav a { padding: 6px 10px; }
  .post { padding: 24px 20px; border-radius: 14px; }
  .cards { grid-template-columns: 1fr; }
  .pager { grid-template-columns: 1fr; }
  .stat { min-width: 96px; padding: 12px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .reveal { opacity: 1; transform: none; }
}
