@import url('https://fonts.googleapis.com/css2?family=Cormorant:wght@400;500;600;700&family=Montserrat:wght@300;400;500;600;700&display=swap');

/* ── 变量 ─────────────────────────────────────────── */
:root {
  --bg: #0d0d0d;
  --bg-1: #111118;
  --bg-2: #16161e;
  --primary: #8000ff;
  --accent: #ff00ff;
  --primary-dim: rgba(128,0,255,0.18);
  --accent-dim: rgba(255,0,255,0.12);
  --text: #e8e0f0;
  --text-dim: #9988bb;
  --text-muted: #554466;
  --border: rgba(128,0,255,0.28);
  --border-accent: rgba(255,0,255,0.3);
  --glow: 0 0 10px rgba(128,0,255,0.7), 0 0 20px rgba(128,0,255,0.3);
  --glow-accent: 0 0 10px rgba(255,0,255,0.7), 0 0 20px rgba(255,0,255,0.3);
  --radius: 18px;
  --sidenav-w: 220px;
  --font-head: 'Cormorant', Georgia, serif;
  --font-body: 'Montserrat', system-ui, sans-serif;
  --font-mono: 'Courier New', Courier, monospace;
}

/* ── 重置 ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 17px; scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.7;
  overflow-x: hidden;
  position: relative;
}

/* Scanlines overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0,0,0,0.18) 3px,
    rgba(0,0,0,0.18) 4px
  );
  pointer-events: none;
  z-index: 1000;
}

a { color: var(--accent); text-decoration: none; transition: color 0.2s, text-shadow 0.2s; }
a:hover { color: #fff; text-shadow: var(--glow-accent); }
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }

/* ── 布局骨架 ────────────────────────────────────── */
.page-wrapper {
  display: flex;
  min-height: 100vh;
}

.page-main {
  flex: 1;
  margin-left: var(--sidenav-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  padding: 2rem 2rem 3rem;
  max-width: 900px;
}

/* ── 侧边导航 ────────────────────────────────────── */
.sidenav {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sidenav-w);
  height: 100vh;
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0;
  z-index: 100;
  overflow-y: auto;
  padding-bottom: 1.5rem;
}

/* Neon left edge */
.sidenav::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  width: 1px;
  height: 100%;
  background: var(--primary);
  box-shadow: var(--glow);
  pointer-events: none;
}

.sidenav__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem 1rem;
  border-bottom: 1px solid var(--border);
}

.sidenav__brand-icon {
  font-size: 2rem;
  color: var(--primary);
  text-shadow: var(--glow);
  font-family: var(--font-mono);
}

.sidenav__logo-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.sidenav ol {
  flex: 1;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.sidenav ol li a {
  display: block;
  padding: 0.6rem 0.9rem;
  border-radius: 999px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-dim);
  font-size: 0.78rem;
  font-family: var(--font-mono);
  letter-spacing: 0.03em;
  transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 40px;
  line-height: 1.2;
  display: flex;
  align-items: center;
}

.sidenav ol li a:hover,
.sidenav ol li a[aria-current="page"] {
  background: var(--primary-dim);
  border-color: var(--primary);
  color: #fff;
  text-shadow: var(--glow);
  box-shadow: inset 0 0 8px rgba(128,0,255,0.2);
}

.sidenav__contact {
  padding: 1rem 0.75rem;
  border-top: 1px solid var(--border);
}

/* ── 药丸按钮 ────────────────────────────────────── */
.pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1.1rem;
  min-height: 40px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-size: 0.78rem;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  transition: background 0.2s, box-shadow 0.2s, color 0.2s;
  width: 100%;
  text-align: center;
}

.pill-btn:hover {
  background: var(--accent-dim);
  box-shadow: var(--glow-accent);
  color: #fff;
  text-shadow: none;
}

/* ── Section 通用 ───────────────────────────────── */
article {
  margin-bottom: 2.5rem;
}

.section-heading {
  font-family: var(--font-head);
  font-size: 1.55rem;
  font-weight: 600;
  color: var(--primary);
  text-shadow: var(--glow);
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

p.subtitle, .subtitle {
  color: var(--text-dim);
  font-size: 0.88rem;
  margin-bottom: 1.2rem;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

/* ── Hero (首页) ─────────────────────────────────── */
.hero-section {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  gap: 1rem 1.5rem;
  align-items: start;
  min-height: 45vh;
  padding-top: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2.5rem;
}

.hero-aside {
  grid-column: 1;
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 90px;
}

.hero-figure {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.hero-icon {
  font-size: 3.5rem;
  color: var(--primary);
  text-shadow: var(--glow);
  font-family: var(--font-mono);
  animation: pulse-glow 2.5s ease-in-out infinite;
}

.hero-copy {
  grid-column: 2;
  grid-row: 2;
  text-align: right;
}

.hero-h1 {
  font-family: var(--font-head);
  font-size: clamp(1.4rem, 3vw, 2.2rem);
  font-weight: 700;
  color: #fff;
  line-height: 1.25;
  margin-bottom: 0.5rem;
  letter-spacing: 0.02em;
}

.hero-lead {
  margin-bottom: 0;
}

/* ── 分类网格（首页） ────────────────────────────── */
.cats-section {
  margin-bottom: 2.5rem;
}

.cats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.cat-card {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-bottom: 3px solid var(--primary);
  background: var(--bg-1);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.cat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 24px rgba(128,0,255,0.25);
}

.cat-card__link {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 1.1rem 1rem;
  color: var(--text);
  text-shadow: none;
}

.cat-card__link:hover { color: var(--text); text-shadow: none; }

.cat-card__title {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  text-shadow: var(--glow-accent);
  display: block;
}

.cat-card__count {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--primary);
  letter-spacing: 0.05em;
}

.cat-card__desc {
  font-size: 0.8rem;
  color: var(--text-dim);
  display: block;
}

/* ── 页面头部（分类/条目/标签/about/privacy） ─── */
.page-header-section,
.entry-hero-section,
.tag-header-section,
.about-header-section,
.privacy-header-section {
  display: grid;
  grid-template-columns: 140px 1fr;
  grid-template-rows: auto auto;
  gap: 1rem 1.5rem;
  align-items: start;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2rem;
}

.page-header-aside,
.entry-aside,
.tag-aside,
.about-aside,
.privacy-aside {
  grid-column: 1;
  grid-row: 1 / 3;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.page-header-figure,
.entry-hero-figure,
.tag-figure,
.about-figure,
.privacy-figure {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.page-header-copy,
.entry-hero-copy,
.tag-header-copy,
.about-copy,
.privacy-copy {
  grid-column: 2;
  grid-row: 2;
}

.page-header-copy h1,
.entry-hero-copy h1,
.tag-header-copy h1,
.about-copy h1,
.privacy-copy h1 {
  font-family: var(--font-head);
  font-size: clamp(1.3rem, 2.5vw, 2rem);
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
  margin-bottom: 0.4rem;
  letter-spacing: 0.02em;
}

.cat-icon, .entry-icon, .tag-icon, .about-icon, .privacy-icon {
  font-size: 2.5rem;
  color: var(--primary);
  text-shadow: var(--glow);
  font-family: var(--font-mono);
}

/* ── 侧边 aside ─────────────────────────────────── */
.aside-heading {
  font-family: var(--font-head);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent);
  text-shadow: var(--glow-accent);
  margin-bottom: 0.2rem;
}

.related-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.related-list li a {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
  display: block;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  border-left: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.related-list li a:hover {
  color: #fff;
  border-left-color: var(--primary);
  background: var(--primary-dim);
  text-shadow: none;
}

.parent-link {
  margin-top: 1rem;
}

.children-aside,
.tags-aside,
.about-links-aside {
  margin-top: 1.5rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
}

/* ── content-section ────────────────────────────── */
.content-section {
  position: relative;
}

.content-figure {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  position: relative;
  overflow: hidden;
}

.content-figure::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 3px;
  height: 100%;
  background: linear-gradient(180deg, var(--primary), var(--accent));
  border-radius: 2px 0 0 2px;
}

.content-body {
  font-size: 1rem;
  line-height: 1.8;
  color: var(--text);
}

.content-body h2,
.content-body h3 {
  font-family: var(--font-head);
  color: var(--primary);
  text-shadow: var(--glow);
  margin: 1.5rem 0 0.5rem;
}

.content-body p { margin-bottom: 1rem; }
.content-body a { color: var(--accent); }
.content-body a:hover { color: #fff; text-shadow: var(--glow-accent); }
.content-body ul, .content-body ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
  list-style: disc;
}
.content-body code {
  font-family: var(--font-mono);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.35em;
  font-size: 0.88em;
  color: var(--accent);
}

/* ── DL 条目列表 ─────────────────────────────────── */
.entry-dl {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.entry-dl dt {
  margin-top: 0.9rem;
}

.entry-dl dt a {
  font-family: var(--font-head);
  font-size: 1.05rem;
  font-weight: 600;
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  transition: color 0.2s, text-shadow 0.2s;
}

.entry-dl dt a::before {
  content: '▶';
  font-size: 0.6em;
  color: var(--primary);
  text-shadow: var(--glow);
}

.entry-dl dt a:hover {
  color: var(--accent);
  text-shadow: var(--glow-accent);
}

.entry-dl dd {
  font-size: 0.83rem;
  color: var(--text-dim);
  padding-left: 1.2rem;
  margin-top: 0.2rem;
  font-family: var(--font-mono);
  border-left: 2px solid var(--border);
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

/* ── children-dl (首页) ─────────────────────────── */
.children-dl {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.children-dl dt { margin-top: 0.7rem; }
.children-dl dt a {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  color: var(--accent);
}
.children-dl dd {
  font-size: 0.78rem;
  color: var(--text-dim);
  padding-left: 1rem;
  margin-top: 0.15rem;
  border-left: 1px solid var(--border);
}

/* ── 标签 pills ─────────────────────────────────── */
.tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--primary);
  color: var(--primary);
  font-size: 0.72rem;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  transition: background 0.2s, box-shadow 0.2s, color 0.2s;
  min-height: 28px;
}

.tag-pill:hover,
a.tag-pill:hover {
  background: var(--primary-dim);
  box-shadow: var(--glow);
  color: #fff;
  text-shadow: none;
}

.tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.5rem;
}

/* ── 日期 ────────────────────────────────────────── */
.entry-date {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-left: 0.5rem;
}

.entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* ── entry-list-figure ──────────────────────────── */
.entry-list-figure {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.5rem;
}

/* ── 空提示 ─────────────────────────────────────── */
.empty-note {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-family: var(--font-mono);
}

/* ── hero image ─────────────────────────────────── */
.hero-img {
  border-radius: var(--radius);
  width: 100%;
  height: auto;
  display: block;
}

/* ── 页脚 ────────────────────────────────────────── */
.site-footer {
  padding: 1.5rem 2rem;
  border-top: 1px solid var(--border);
  text-align: center;
  background: var(--bg-1);
}

.footer-copy {
  font-size: 0.82rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
  margin-bottom: 0.4rem;
}

.footer-copy a {
  color: var(--primary);
  margin: 0 0.25rem;
}

.footer-copy a:hover {
  color: var(--accent);
  text-shadow: var(--glow-accent);
}

.site-footer small {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  line-height: 1.6;
}

/* ── 动效 ────────────────────────────────────────── */
@keyframes pulse-glow {
  0%, 100% { text-shadow: 0 0 8px rgba(128,0,255,0.7), 0 0 20px rgba(128,0,255,0.3); }
  50% { text-shadow: 0 0 18px rgba(128,0,255,1), 0 0 40px rgba(128,0,255,0.6), 0 0 60px rgba(255,0,255,0.2); }
}

@keyframes glitch {
  0%, 92%, 100% { transform: none; }
  93% { transform: skewX(-4deg) translateX(3px); }
  95% { transform: skewX(3deg) translateX(-3px); }
  97% { transform: skewX(-2deg); }
}

.hero-h1,
.page-header-copy h1,
.entry-hero-copy h1,
.tag-header-copy h1,
.about-copy h1,
.privacy-copy h1 {
  animation: glitch 8s ease-in-out infinite;
}

/* Scroll reveal */
.cat-card,
.entry-dl dt,
.content-figure {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.cat-card.is-visible,
.entry-dl dt.is-visible,
.content-figure.is-visible {
  opacity: 1;
  transform: none;
}

/* ── prefers-reduced-motion ─────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
  .cat-card,
  .entry-dl dt,
  .content-figure {
    opacity: 1;
    transform: none;
  }
}

/* ── 移动端断点 ─────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidenav-w: 0px; }

  .sidenav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 56px;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 0.75rem;
    border-right: none;
    border-bottom: 1px solid var(--border);
    z-index: 200;
  }

  .sidenav::after {
    width: 100%;
    height: 1px;
    top: auto;
    bottom: 0;
    right: 0;
  }

  .sidenav__brand {
    padding: 0 0.75rem 0 0;
    border-bottom: none;
    border-right: 1px solid var(--border);
    margin-right: 0.5rem;
    height: 100%;
    flex-shrink: 0;
  }

  .sidenav ol {
    flex-direction: row;
    padding: 0;
    gap: 0.3rem;
    align-items: center;
    overflow-x: auto;
    flex-wrap: nowrap;
    flex: 1;
  }

  .sidenav ol li a {
    white-space: nowrap;
    padding: 0.4rem 0.7rem;
    min-height: 40px;
    font-size: 0.72rem;
  }

  .sidenav__contact {
    padding: 0 0 0 0.5rem;
    border-top: none;
    border-left: 1px solid var(--border);
    flex-shrink: 0;
  }

  .pill-btn {
    width: auto;
    font-size: 0.72rem;
    padding: 0.4rem 0.8rem;
    min-height: 40px;
    white-space: nowrap;
  }

  .page-main {
    margin-left: 0;
    padding-top: 56px;
  }

  .main-content {
    padding: 1.5rem 1rem 2rem;
  }

  .hero-section,
  .page-header-section,
  .entry-hero-section,
  .tag-header-section,
  .about-header-section,
  .privacy-header-section {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .hero-aside,
  .page-header-aside,
  .entry-aside,
  .tag-aside,
  .about-aside,
  .privacy-aside {
    grid-column: 1;
    grid-row: auto;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .hero-figure,
  .page-header-figure,
  .entry-hero-figure,
  .tag-figure,
  .about-figure,
  .privacy-figure {
    grid-column: 1;
    grid-row: auto;
    justify-content: flex-start;
  }

  .hero-copy,
  .page-header-copy,
  .entry-hero-copy,
  .tag-header-copy,
  .about-copy,
  .privacy-copy {
    grid-column: 1;
    grid-row: auto;
    text-align: left;
  }

  .hero-section {
    min-height: auto;
    padding-top: 1rem;
  }

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

  .hero-h1,
  .page-header-copy h1,
  .entry-hero-copy h1,
  .tag-header-copy h1,
  .about-copy h1,
  .privacy-copy h1 {
    font-size: clamp(1.2rem, 5vw, 1.7rem);
  }
}

@media (max-width: 400px) {
  .cats-grid {
    grid-template-columns: 1fr;
  }

  .content-figure {
    padding: 1rem;
  }
}
