/*
Theme Name: Lingyu Butterfly
Theme URI: https://www.lingyu.mom
Author: Lingyu
Description: 深色调、卡片化的技术博客主题，参考 Hexo Butterfly 主题的视觉语言重新实现，不依赖 Elementor。
Version: 1.0.0
Requires PHP: 7.4
Text Domain: lingyu-butterfly
*/

/* ==========================================================================
   Design tokens
   ========================================================================== */
:root {
  --bg: #0d0d12;
  --bg-elevate: #15151d;
  --card: #191922;
  --card-2: #1f1f2b;
  --border: #2a2a38;
  --text: #eceef2;
  --text-muted: #9a9db0;
  --text-faint: #676a7c;
  --accent: #ff4d94;        /* magenta, 呼应贡献热力图配色 */
  --accent-soft: rgba(255,77,148,0.14);
  --cyan: #4fd8e0;          /* TOC 高亮/链接次色 */
  --cyan-soft: rgba(79,216,224,0.14);
  --warn-bg: rgba(255,90,110,0.12);
  --warn-border: rgba(255,90,110,0.4);
  --radius: 12px;
  --radius-sm: 8px;
  --maxw: 1180px;
  --font-display: 'Sora', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-body: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.75;
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--cyan); text-decoration: none; }
a:hover { color: var(--accent); }
img { max-width: 100%; display: block; border-radius: var(--radius-sm); }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.3;
  margin: 0 0 .6em;
  color: var(--text);
}

.container { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.mono { font-family: var(--font-mono); }

/* ==========================================================================
   Header / nav
   ========================================================================== */
.site-header {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 50;
  padding: 20px 0;
  transition: background .25s ease, box-shadow .25s ease;
}
.site-header.is-solid {
  position: fixed;
  background: rgba(13,13,18,0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap {
  max-width: var(--maxw); margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { font-family: var(--font-display); font-weight: 700; font-size: 19px; color: var(--text); }
.main-nav ul { list-style: none; display: flex; gap: 26px; margin: 0; padding: 0; flex-wrap: wrap; }
.main-nav a { color: var(--text-muted); font-size: 14.5px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.main-nav a:hover { color: var(--text); }
.nav-toggle { display: none; background: none; border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 6px 10px; }
@media (max-width: 900px) {
  .main-nav { display: none; }
  .nav-toggle { display: inline-flex; }
}

/* ==========================================================================
   Hero
   ========================================================================== */
.hero {
  position: relative;
  min-height: 62vh;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  overflow: hidden;
  background:
    radial-gradient(ellipse 900px 500px at 20% 10%, rgba(255,77,148,0.16), transparent 60%),
    radial-gradient(ellipse 800px 600px at 85% 30%, rgba(79,216,224,0.12), transparent 55%),
    linear-gradient(160deg, #101018 0%, #0a0a10 60%, #0d0d12 100%);
}
.hero::before {
  content: '';
  position: absolute; inset: 0;
  background-image: repeating-linear-gradient(0deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 42px),
                     repeating-linear-gradient(90deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 42px);
  mask-image: radial-gradient(ellipse 70% 70% at 50% 40%, black, transparent);
}
.hero-inner { position: relative; z-index: 2; }
.hero .eyebrow { font-family: var(--font-mono); color: var(--cyan); font-size: 13px; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 18px; }
.hero h1 { font-size: 46px; margin-bottom: 10px; }
.hero .tagline { color: var(--text-muted); font-size: 16px; max-width: 46ch; margin: 0 auto; }
.hero-scroll { position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%); color: var(--text-faint); animation: bob 2s ease-in-out infinite; }
@keyframes bob { 0%,100%{ transform: translate(-50%,0);} 50%{ transform: translate(-50%,6px);} }

@media (max-width: 760px) {
  .hero h1 { font-size: 32px; }
  .hero { min-height: 46vh; }
}

/* ==========================================================================
   Layout: sidebar + main
   ========================================================================== */
.layout { display: grid; grid-template-columns: 280px 1fr; gap: 28px; padding: 40px 0 70px; }
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { order: 2; }
}

.widget {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
}
.widget h4 { font-size: 13px; font-family: var(--font-mono); color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 14px; }

/* Author card */
.author-card { text-align: center; }
.author-card img.avatar {
  width: 76px; height: 76px; border-radius: 50%; margin: 0 auto 12px;
  border: 2px solid var(--border);
}
.author-card .name { font-family: var(--font-display); font-weight: 700; font-size: 18px; }
.author-card .bio { color: var(--text-muted); font-size: 13.5px; margin: 6px 0 16px; }
.author-stats { display: flex; justify-content: space-around; border-top: 1px dashed var(--border); padding-top: 14px; margin-top: 4px; }
.author-stats div { text-align: center; }
.author-stats b { display: block; font-family: var(--font-mono); font-size: 17px; color: var(--text); }
.author-stats span { font-size: 11.5px; color: var(--text-faint); }
.social-row { display: flex; justify-content: center; gap: 12px; margin-top: 14px; }
.social-row a {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 14px;
}
.social-row a:hover { border-color: var(--accent); color: var(--accent); }

/* Announcement */
.announcement p { margin: 0 0 10px; color: var(--text-muted); font-size: 14px; }

/* Category widget */
.cat-list { list-style: none; margin: 0; padding: 0; }
.cat-list li { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.cat-list li:last-child { border-bottom: none; }
.cat-list a { color: var(--text-muted); }
.cat-list a:hover { color: var(--cyan); }
.cat-list .count { font-family: var(--font-mono); color: var(--text-faint); font-size: 12.5px; }

/* Info stats widget */
.info-list { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.info-list li { display: flex; justify-content: space-between; padding: 6px 0; color: var(--text-muted); }
.info-list b { color: var(--text); font-family: var(--font-mono); font-weight: 500; }

/* ==========================================================================
   Heatmap widget (post-publish activity, GitHub-style)
   ========================================================================== */
.heatmap-widget { grid-column: 1 / -1; }
.heatmap-scroll { overflow-x: auto; padding-bottom: 6px; }
.heatmap-grid { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 12px); gap: 3px; width: max-content; }
.heatmap-cell { width: 12px; height: 12px; border-radius: 3px; background: var(--card-2); }
.heatmap-legend { display: flex; align-items: center; gap: 6px; justify-content: flex-end; margin-top: 10px; font-size: 12px; color: var(--text-faint); }
.heatmap-legend .sw { width: 11px; height: 11px; border-radius: 3px; }
.heatmap-stats { display: flex; gap: 30px; margin-top: 16px; flex-wrap: wrap; }
.heatmap-stats div b { display: block; font-family: var(--font-mono); font-size: 20px; color: var(--text); }
.heatmap-stats div span { font-size: 12px; color: var(--text-faint); }

/* ==========================================================================
   Post cards (list)
   ========================================================================== */
.post-grid { display: flex; flex-direction: column; gap: 20px; }
.post-card {
  display: grid; grid-template-columns: 1fr 240px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; transition: border-color .15s ease, transform .15s ease;
}
.post-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.post-card .body { padding: 22px 24px; display: flex; flex-direction: column; }
.post-card .thumb { background-size: cover; background-position: center; min-height: 100%; }
.post-card .thumb-fallback {
  background: linear-gradient(135deg, rgba(255,77,148,0.18), rgba(79,216,224,0.10));
  width: 100%; height: 100%; min-height: 150px;
}
.badge-sticky {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 11.5px; font-family: var(--font-mono); padding: 2px 8px; border-radius: 5px;
  width: fit-content; margin-bottom: 8px;
}
.post-card h2 { font-size: 19px; margin-bottom: 8px; }
.post-card h2 a { color: var(--text); }
.post-card h2 a:hover { color: var(--accent); }
.post-meta {
  display: flex; flex-wrap: wrap; gap: 14px;
  font-family: var(--font-mono); font-size: 12px; color: var(--text-faint);
  margin-bottom: 10px;
}
.post-card .excerpt { color: var(--text-muted); font-size: 14px; margin: 0; flex: 1; }

@media (max-width: 700px) {
  .post-card { grid-template-columns: 1fr; }
  .post-card .thumb { min-height: 160px; order: -1; }
}

.pagination { display: flex; gap: 10px; justify-content: center; margin-top: 40px; }
.pagination a, .pagination span {
  padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px;
  font-family: var(--font-mono); font-size: 13px; color: var(--text-muted);
}
.pagination .current { border-color: var(--accent); color: var(--accent); }

/* ==========================================================================
   Single post
   ========================================================================== */
.post-banner {
  position: relative; padding: 110px 0 46px; text-align: center;
  background: linear-gradient(120deg, #3a0d2b 0%, #1c1030 55%, #0d0d12 100%);
  background-size: cover; background-position: center;
}
.post-banner.has-image { background-blend-mode: overlay; background-color: rgba(10,10,15,0.55); }
.post-banner h1 { font-size: 32px; max-width: 900px; margin: 0 auto 16px; }
.post-banner .meta-row { color: rgba(255,255,255,0.75); font-size: 13.5px; font-family: var(--font-mono); margin-bottom: 6px; }
.post-banner .meta-row a { color: rgba(255,255,255,0.85); }

.stale-notice {
  background: var(--warn-bg); border: 1px solid var(--warn-border); color: #ffb3bd;
  border-radius: var(--radius-sm); padding: 12px 16px; font-size: 13.5px; margin: 24px 0;
}
.ai-notice { color: var(--text-faint); font-size: 13px; margin: 0 0 24px; font-style: italic; }

.post-layout { display: grid; grid-template-columns: 260px 1fr; gap: 32px; padding: 40px 0 80px; align-items: start; }
@media (max-width: 980px) { .post-layout { grid-template-columns: 1fr; } .toc-widget { display: none; } }

.toc-widget { position: sticky; top: 100px; }
.toc-widget .count { float: right; color: var(--text-faint); font-family: var(--font-mono); font-size: 12px; }
.toc-list, .toc-list ul { list-style: none; margin: 0; padding: 0; }
.toc-list ul { padding-left: 14px; }
.toc-list a {
  display: block; padding: 5px 0; font-size: 13.5px; color: var(--text-muted);
  border-left: 2px solid transparent; padding-left: 10px; margin-left: -1px;
}
.toc-list a.active { color: var(--cyan); border-left-color: var(--cyan); }

.post-content { font-size: 16.5px; color: var(--text); max-width: 780px; }
.post-content p { margin: 0 0 1.2em; }
.post-content h2, .post-content h3, .post-content h4 { margin-top: 1.8em; scroll-margin-top: 100px; }
.post-content h2::before, .post-content h3::before { content: '🔗 '; opacity: .5; font-size: .8em; }
.post-content .divider {
  border: none; text-align: center; color: var(--text-faint); margin: 2.4em 0;
  border-top: 1px dashed var(--border); position: relative;
}
.post-content ul, .post-content ol { margin: 0 0 1.2em 1.3em; padding: 0; }
.post-content table { width: 100%; border-collapse: collapse; margin: 1.4em 0; font-size: 14.5px; }
.post-content th, .post-content td { border: 1px solid var(--border); padding: 10px 14px; text-align: left; }
.post-content th { background: var(--card-2); font-family: var(--font-mono); font-size: 12.5px; color: var(--text-faint); }
.post-content blockquote {
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  margin: 1.6em 0; padding: 12px 18px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-muted);
}
.post-content img { margin: 1.4em 0; border: 1px solid var(--border); }

/* Code blocks: mac-terminal styling */
.post-content pre {
  background: #0a0a0f; border: 1px solid var(--border); border-radius: var(--radius-sm);
  margin: 1.4em 0; padding: 0; overflow: hidden; position: relative;
}
.post-content pre .code-head {
  display: flex; align-items: center; gap: 8px; padding: 9px 14px;
  background: var(--card-2); border-bottom: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 12px; color: var(--text-faint);
}
.post-content pre .dots { display: flex; gap: 6px; }
.post-content pre .dots span { width: 10px; height: 10px; border-radius: 50%; }
.post-content pre .dots span:nth-child(1) { background: #ff5f57; }
.post-content pre .dots span:nth-child(2) { background: #febc2e; }
.post-content pre .dots span:nth-child(3) { background: #28c840; }
.post-content pre .copy-btn {
  margin-left: auto; background: none; border: 1px solid var(--border); color: var(--text-faint);
  border-radius: 6px; padding: 2px 8px; font-size: 11px; cursor: pointer; font-family: var(--font-mono);
}
.post-content pre .copy-btn:hover { color: var(--cyan); border-color: var(--cyan); }
.post-content pre code {
  display: block; padding: 16px 18px; overflow-x: auto;
  font-family: var(--font-mono); font-size: 13.5px; line-height: 1.7; color: #d6e2ff;
}
.post-content :not(pre) > code {
  background: var(--card-2); border: 1px solid var(--border); border-radius: 4px;
  padding: 2px 6px; font-family: var(--font-mono); font-size: .9em;
}

/* Copyright / author box */
.post-copyright {
  margin-top: 48px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--card); padding: 18px 22px; font-size: 13px; color: var(--text-muted);
}
.post-copyright div { margin-bottom: 4px; }
.post-copyright b { color: var(--text); }

/* Tags */
.tag-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0; }
.tag-row a {
  border: 1px solid var(--border); border-radius: 999px; padding: 5px 14px;
  font-size: 12.5px; color: var(--text-muted);
}
.tag-row a:hover { border-color: var(--accent); color: var(--accent); }

/* Prev/next nav */
.post-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 30px; }
.post-nav a {
  display: block; border-radius: var(--radius); border: 1px solid var(--border);
  padding: 18px 20px; background: var(--card); color: var(--text-muted); font-size: 13px;
}
.post-nav a:hover { border-color: var(--accent); }
.post-nav .label { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); display: block; margin-bottom: 6px; }
.post-nav .title { color: var(--text); font-size: 14.5px; font-weight: 600; }
.post-nav .next { text-align: right; }

/* Related */
.related-heading { margin-top: 50px; font-size: 13px; font-family: var(--font-mono); color: var(--text-faint); text-transform: uppercase; letter-spacing: .06em; }
.related-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 14px; }
.related-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; background: var(--card); }
.related-card a { color: var(--text); font-size: 13.5px; font-weight: 600; }
@media (max-width: 760px) { .related-grid { grid-template-columns: 1fr; } }

/* ==========================================================================
   Mascot + floating buttons
   ========================================================================== */
.mascot {
  position: fixed; left: 16px; bottom: 0; z-index: 60; width: 130px; pointer-events: none;
}
.mascot img { pointer-events: auto; }
.float-actions { position: fixed; right: 18px; bottom: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 60; }
.float-actions button {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--card); color: var(--text-muted); cursor: pointer; font-size: 15px;
}
.float-actions button:hover { border-color: var(--accent); color: var(--accent); }

@media (max-width: 700px) { .mascot { display: none; } }

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer { border-top: 1px solid var(--border); padding: 36px 0; text-align: center; color: var(--text-faint); font-size: 13px; }
.site-footer a { color: var(--text-muted); }

/* Page (non-post) */
.page-content { max-width: 780px; margin: 0 auto; padding: 60px 24px 90px; }
.page-content h1 { font-size: 30px; margin-bottom: 24px; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}