/* === Blog shared (extends main style.css) === */

/* Blog list page */
.blog-list {
  min-height: 80vh; padding: 7rem 2rem 4rem;
}
.blog-list-inner { max-width: 860px; margin: 0 auto; }
.blog-page-title {
  font-family: 'Noto Serif CJK SC', 'Source Han Serif SC', 'STSong', 'SimSun', 'Songti SC', serif; font-size: 2.2rem; font-weight: 900;
  color: var(--accent); margin-bottom: 0.5rem;
}
.blog-page-desc { color: var(--accent-fade); font-size: 0.95rem; margin-bottom: 3rem; }

.blog-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; padding: 1.8rem; margin-bottom: 1.2rem;
  transition: border-color 0.3s, transform 0.25s ease, box-shadow 0.3s, background 0.3s;
  position: relative; cursor: pointer; user-select: none;
  opacity: 0; transform: translateY(18px);
  animation: cardIn 0.5s ease forwards;
}
.blog-card:nth-child(1) { animation-delay: 0ms; }
.blog-card:nth-child(2) { animation-delay: 60ms; }
.blog-card:nth-child(3) { animation-delay: 120ms; }
.blog-card:nth-child(4) { animation-delay: 180ms; }
.blog-card:nth-child(5) { animation-delay: 240ms; }
.blog-card:nth-child(6) { animation-delay: 300ms; }
.blog-card:nth-child(n+7) { animation-delay: 340ms; }
.blog-card:hover {
  border-color: var(--accent-glow-dim); transform: translateX(6px);
  background: var(--bg-card-hover); box-shadow: 4px 4px 20px var(--shadow-xs);
}
.blog-card:active { transform: scale(0.985); transition: transform 0.1s ease; }
.blog-card h2 { font-size: 1.2rem; margin-bottom: 0.5rem; }
.blog-card h2 a { color: var(--accent); transition: opacity 0.3s; outline: none; -webkit-tap-highlight-color: transparent; }
.blog-card h2 a:hover { opacity: 1; }
.blog-card h2 a:focus-visible { outline: none; }
.blog-card h2 a::after {
  content: ''; position: absolute; inset: 0;
}
.blog-card-meta {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  margin-bottom: 0.6rem;
}
.blog-card-meta time { color: var(--text-subtle); font-size: 0.82rem; }
.blog-card-summary { color: var(--accent-dim); font-size: 0.9rem; line-height: 1.7; }
.post-tags { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* Single post page */
.post { padding: 7rem 2rem 4rem; }

/* === Three-column layout === */
.post-layout {
  display: flex;
  gap: 2.5rem;
  max-width: 1360px;
  margin: 0 auto;
}
.post-toc {
  flex: 0 0 200px;
  /* no sticky here — child .toc-sticky is sticky */
}
.post-toc--spacer {
  /* empty spacer to preserve three-column layout balance */
  min-width: 0;
}
.post-body {
  flex: 1;
  min-width: 0;
  max-width: 860px;
}
.post-meta-sidebar {
  flex: 0 0 240px;
  /* no sticky here — child .meta-sticky is sticky */
}

/* --- TOC --- */
.toc-sticky {
  position: sticky;
  top: 6rem;
  padding: 0.5rem 0;
}
.toc-title {
  font-family: 'Noto Serif CJK SC', 'Source Han Serif SC', 'STSong', 'SimSun', 'Songti SC', serif; font-size: 0.8rem; font-weight: 700;
  color: var(--accent); margin-bottom: 0.8rem; letter-spacing: 0.06em;
}
.toc-nav { display: flex; flex-direction: column; gap: 1px; }
.toc-link {
  display: block; padding: 0.3rem 0.7rem; margin-left: -0.7rem;
  border-radius: 6px;
  color: var(--text-muted); font-size: 0.8rem; line-height: 1.5;
  transition: all 0.25s ease;
  border-left: 2px solid transparent;
}
.toc-link:hover {
  color: var(--accent); background: var(--bg-card-hover);
}
.toc-link.active {
  color: var(--accent); background: var(--bg-stat-liked);
  border-left-color: var(--accent);
}
.toc-link.toc-h2 { padding-left: 0.7rem; font-weight: 500; }
.toc-link.toc-h3 { padding-left: 1.5rem; font-size: 0.76rem; }

/* --- Right sidebar: notes + stats + comments --- */
.meta-sticky { position: sticky; top: 6rem; display: flex; flex-direction: column; gap: 1.5rem; }

.post-widget {
  padding: 1rem; border-radius: 10px;
  background: var(--bg-widget);
  border: 1px solid rgba(255,255,255,0.05);
}
.widget-title {
  font-family: 'Noto Serif CJK SC', 'Source Han Serif SC', 'STSong', 'SimSun', 'Songti SC', serif; font-size: 0.78rem; font-weight: 700;
  color: var(--accent); margin-bottom: 0.6rem; letter-spacing: 0.05em;
}
.post-notes .notes-text {
  color: var(--accent-dim); font-size: 0.8rem; line-height: 1.6;
}
.post-stats { display: flex; gap: 0.4rem; }
.stat-item {
  flex: 1; display: flex; align-items: center; justify-content: center;
  gap: 0.35rem; padding: 0.5rem;
  border-radius: 8px; border: 1px solid var(--border);
  background: transparent; cursor: default; transition: all 0.3s;
}
.stat-like {
  cursor: pointer; color: var(--text-muted); font-family: inherit;
}
.stat-like:hover {
  border-color: var(--accent-glow-dim); color: var(--accent);
}
.stat-like.liked {
  border-color: var(--accent-glow-dim); color: var(--accent);
  background: var(--bg-stat-liked);
}
.stat-like.liked .stat-icon { fill: var(--accent-glow-dim); }
.stat-like:active { transform: scale(0.9); transition: transform 0.12s; }
.stat-icon { width: 16px; height: 16px; flex-shrink: 0; }
.stat-num {
  font-family: 'JetBrains Mono', monospace; font-size: 0.75rem; color: var(--text-dim);
}
.stat-like.liked .stat-num { color: var(--accent); }
.stat-views .stat-icon { color: var(--text-subtle); }

/* Comments widget */
.comment-count {
  font-family: 'JetBrains Mono', monospace; font-size: 0.72rem; color: var(--text-muted);
}
.comment-list {
  display: flex; flex-direction: column; gap: 0.6rem;
  margin-bottom: 0.8rem; max-height: 320px; overflow-y: auto;
}
.comment-item {
  padding: 0.5rem 0.6rem; border-radius: 6px;
  background: var(--bg-card);
}
.comment-item .comment-nick {
  font-size: 0.72rem; color: var(--accent); font-weight: 600; margin-bottom: 0.15rem;
}
.comment-item .comment-time {
  display: inline-block; font-size: 0.6rem; color: var(--text-faint);
  font-family: 'JetBrains Mono', monospace; margin-left: 0.4rem;
}
.comment-item .comment-body {
  font-size: 0.78rem; color: var(--accent-fade); line-height: 1.5;
}
.comment-item .comment-del {
  float: right; font-size: 0.6rem; color: var(--text-faint);
  background: none; border: none; cursor: pointer;
  padding: 0 2px; transition: color 0.2s;
}
.comment-item .comment-del:hover { color: var(--comment-del-hover); }
.comment-form { display: flex; flex-direction: column; gap: 0.4rem; }
.comment-form input, .comment-form textarea {
  padding: 0.4rem 0.6rem; border-radius: 6px;
  background: var(--bg-bubble); border: 1px solid var(--border-light);
  color: var(--accent-text); font-size: 0.78rem; font-family: inherit;
  outline: none; transition: border-color 0.3s;
}
.comment-form input::placeholder, .comment-form textarea::placeholder { color: var(--text-faint); }
.comment-form input:focus, .comment-form textarea:focus {
  border-color: var(--accent-glow-dim);
}
.comment-form textarea { resize: vertical; }
.comment-form button {
  align-self: flex-end; padding: 0.3rem 0.8rem; border-radius: 6px;
  background: var(--accent-glow-nano); border: 1px solid var(--accent-glow-subtle);
  color: var(--accent); font-size: 0.76rem; cursor: pointer;
  font-family: inherit; transition: all 0.3s;
}
.comment-form button:hover {
  background: var(--bg-comment-btn-hover); border-color: var(--scrollbar-thumb-hover);
}

/* ----- Responsive: mobile & tablet ----- */

/* Mobile (< 1024px): single column, sticky off */
@media (max-width: 1024px) {
  .post-layout {
    flex-direction: column;
    gap: 1.2rem;
  }
  .post-toc, .post-meta-sidebar {
    flex: none;
  }
  .post-body { max-width: none; }
  .toc-sticky, .meta-sticky {
    position: static;
  }
  .meta-sticky { flex-direction: row; flex-wrap: wrap; gap: 0.6rem; }
  .post-widget { flex: 1; min-width: 140px; }
  .post-stats { flex: 1; }
  .comment-list { max-height: 200px; }
  .toc-sticky { padding: 0 0 0.6rem; border-bottom: 1px solid var(--border); }
  .toc-nav { flex-direction: row; flex-wrap: wrap; gap: 0.3rem; }
  .toc-link {
    padding: 0.2rem 0.5rem; margin-left: 0;
    font-size: 0.76rem; border-left: none; border-radius: 20px;
    border: 1px solid var(--border);
  }
  .toc-link.toc-h2, .toc-link.toc-h3 { padding-left: 0.5rem; }
  .toc-link.active { border-left-color: transparent; border-color: var(--accent-glow-dim); }
}

/* Tablet (769-1200px): hide right sidebar */
@media (min-width: 769px) and (max-width: 1200px) {
  .post-toc { flex: 0 0 180px; }
  .post-meta-sidebar { display: none; }
}

.post-header {
  max-width: none; margin: 0 0 3rem; padding-bottom: 2rem;
  border-bottom: 1px solid var(--border-light);
  animation: postHeaderIn 0.6s ease both;
}
@keyframes postHeaderIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.post-header h1 {
  font-family: 'Noto Serif CJK SC', 'Source Han Serif SC', 'STSong', 'SimSun', 'Songti SC', serif; font-size: 2rem; font-weight: 900;
  color: var(--accent); line-height: 1.4; margin-bottom: 1rem;
}
.post-meta { display: flex; align-items: center; gap: 1.2rem; flex-wrap: wrap; }
.post-meta time { color: var(--text-subtle); font-size: 0.9rem; }

.post-content {
  max-width: none; font-size: 0.95rem; color: var(--accent-text); line-height: 2;
  animation: postContentIn 0.7s 0.2s ease both;
}
@keyframes postContentIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.post-content h1, .post-content h2, .post-content h3,
.post-content h4, .post-content h5, .post-content h6 {
  color: var(--accent); margin-top: 2.5rem; margin-bottom: 1rem; font-family: 'Noto Serif CJK SC', 'Source Han Serif SC', 'STSong', 'SimSun', 'Songti SC', serif;
}
.post-content h1 { font-size: 1.8rem; }
.post-content h2 { font-size: 1.4rem; scroll-margin-top: 5rem; }
.post-content h3 { font-size: 1.15rem; scroll-margin-top: 5rem; }
.post-content h4 { font-size: 1rem; }

.post-content p { margin-bottom: 1.2rem; color: var(--accent-text); }
.post-content strong { color: var(--text); }

.post-content a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.post-content a:hover { opacity: 0.7; }

.post-content code {
  font-family: 'JetBrains Mono', monospace; font-size: 0.85em;
  background: var(--bg-stat-liked); color: var(--accent-text);
  padding: 2px 6px; border-radius: 4px;
}
.post-content pre {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 1.2rem; margin: 1.5rem 0; overflow-x: auto;
  line-height: 1.6;
}
.post-content pre code {
  background: none; color: var(--text); padding: 0;
}

.post-content blockquote {
  border-left: 3px solid var(--accent-glow-soft); padding: 0.5rem 0 0.5rem 1.2rem;
  margin: 1.5rem 0; color: var(--accent-dim); font-style: italic;
}
.post-content blockquote p { margin-bottom: 0; }

.post-content ul, .post-content ol { margin: 0.8rem 0 1.2rem 1.5rem; }
.post-content li { margin-bottom: 0.4rem; color: var(--accent-text); }

.post-content table {
  width: 100%; border-collapse: collapse; margin: 1.5rem 0;
  font-size: 0.9rem; color: var(--accent-text);
}
.post-content thead th {
  border-bottom: 2px solid var(--accent-glow-dim);
  padding: 0.6rem 0.8rem; text-align: left;
  color: var(--accent); font-weight: 700;
}
.post-content tbody td {
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0.8rem;
}
.post-content tbody tr:hover {
  background: var(--bg-card-hover);
}

.post-content hr {
  border: none; border-top: 1px solid var(--border-light); margin: 2rem 0;
}

.post-content img {
  max-width: 100%; border-radius: 8px; margin: 1rem 0;
}

.post-content del { color: var(--text-subtle); }

.post-back {
  max-width: none; margin: 3rem 0 0; padding-top: 2rem;
  border-top: 1px solid var(--border-light);
}
.post-back a { color: var(--accent); font-size: 0.9rem; transition: opacity 0.3s; }
.post-back a:hover { opacity: 0.7; }

/* Tag styling reused */
.tag {
  font-size: 0.7rem; padding: 2px 10px; border-radius: 20px;
  background: var(--accent-glow-nano); color: var(--accent-dim);
  border: 1px solid var(--accent-glow-micro);
  font-family: 'JetBrains Mono', monospace;
}

/* === Blog card entrance animation === */
@keyframes cardIn {
  to { opacity: 1; transform: translateY(0); }
}

/* Responsive */
@media (max-width: 768px) {
  .post { padding: 5rem 1.2rem 3rem; }
  .blog-list { padding: 5rem 1.2rem 3rem; }
  .post-header h1 { font-size: 1.5rem; }
}

/* Blog page uses nav styles from main style.css — both loaded */

/* === Blog Toolbar (search, sort, tag filter) === */
.blog-toolbar { margin-bottom: 2rem; }
.blog-search { margin-bottom: 1.2rem; }
.blog-search input {
  width: 100%; padding: 0.7rem 1rem; border-radius: 10px;
  background: var(--bg-bubble); border: 1px solid var(--border-light);
  color: var(--accent); font-size: 0.92rem; font-family: inherit;
  outline: none; transition: border-color 0.3s;
}
.blog-search input::placeholder { color: var(--text-faint); }
.blog-search input:focus { border-color: var(--scrollbar-thumb-hover); }

.blog-controls { display: flex; flex-direction: column; gap: 0.8rem; }

.blog-sort { display: flex; align-items: center; gap: 0.5rem; }
.blog-sort label { color: var(--text-muted); font-size: 0.82rem; }
.blog-sort select {
  padding: 0.4rem 0.8rem; border-radius: 8px;
  background: var(--bg-bubble); border: 1px solid var(--border-light);
  color: var(--accent); font-size: 0.82rem; font-family: inherit;
  outline: none; cursor: pointer;
}

.blog-tag-filter { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.tag-filter-btn {
  padding: 0.3rem 0.8rem; border-radius: 20px; font-size: 0.75rem;
  background: transparent; border: 1px solid var(--border-light);
  color: var(--text-muted); cursor: pointer; transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  font-family: 'JetBrains Mono', monospace;
}
.tag-filter-btn:hover {
  border-color: var(--accent-glow-soft); color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--bg-stat-liked);
}
.tag-filter-btn:active { transform: scale(0.95); transition: transform 0.1s; }
.tag-filter-btn.active {
  background: var(--bg-tag); border-color: var(--scrollbar-thumb-hover);
  color: var(--accent);
}

.blog-no-results { color: var(--text-subtle); text-align: center; padding: 3rem 0; font-size: 0.95rem; }

/* === Blog Sidebar + Layout === */
.blog-layout {
  display: flex; gap: 3rem; max-width: 1200px; margin: 0 auto; align-items: flex-start;
}
.blog-sidebar {
  flex: 0 0 200px; position: sticky; top: 5rem;
  padding: 1.5rem 0;
}
.blog-main { flex: 1; min-width: 0; }

.sidebar-section { margin-bottom: 2rem; }
.sidebar-title {
  font-family: 'Noto Serif CJK SC', 'Source Han Serif SC', 'STSong', 'SimSun', 'Songti SC', serif; font-size: 0.85rem; font-weight: 700;
  color: var(--accent); margin-bottom: 0.8rem; letter-spacing: 0.05em;
}
.sidebar-nav { list-style: none; padding: 0; margin: 0; }
.sidebar-nav li { margin-bottom: 2px; }
.sidebar-cat-link {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.4rem 0.7rem; border-radius: 8px;
  color: var(--text-dim); font-size: 0.85rem;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.sidebar-cat-link:hover {
  color: var(--accent); background: var(--bg-sidebar-hover);
  transform: translateX(4px);
}
.sidebar-cat-link.active {
  color: var(--accent); background: var(--accent-glow-nano);
  font-weight: 500;
}
.sidebar-cat-count {
  font-size: 0.72rem; color: var(--text-faint);
  font-family: 'JetBrains Mono', monospace;
}
.sidebar-cat-link.active .sidebar-cat-count { color: var(--accent-dim); }

.sidebar-tag-list { display: flex; flex-wrap: wrap; gap: 0.3rem; }
/* === Hierarchical tag sidebar === */
.tag-group {
  margin-bottom: 0.5rem;
}
.tag-parent-btn {
  display: flex; align-items: center; gap: 0.35rem;
  width: 100%; padding: 0.35rem 0.4rem; border-radius: 8px;
  background: transparent; border: none; cursor: pointer;
  color: var(--text-dim); font-size: 0.82rem;
  font-family: inherit; transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.tag-parent-btn:hover {
  color: var(--accent); background: var(--bg-sidebar-hover);
  transform: translateX(3px);
}
.tag-parent-btn.active {
  color: var(--accent); background: var(--accent-glow-nano);
  font-weight: 500;
}
.tag-parent-icon {
  display: inline-block; font-size: 0.55rem; width: 12px;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  color: var(--text-faint); flex-shrink: 0;
}
.tag-parent-btn:hover .tag-parent-icon { color: var(--accent-dim); }
.tag-parent-btn.expanded .tag-parent-icon {
  transform: rotate(90deg);
}
.tag-parent-name { flex: 1; text-align: left; }
.tag-parent-count {
  font-size: 0.68rem; color: var(--text-faint);
  font-family: 'JetBrains Mono', monospace; min-width: 18px; text-align: right;
}
.tag-parent-btn.active .tag-parent-count { color: var(--accent-dim); }

.tag-children {
  display: flex; flex-wrap: wrap; gap: 0.25rem;
  padding: 0.3rem 0 0.3rem 1rem;
  margin-bottom: 0.2rem;
  border-left: 2px solid var(--accent-glow-nano);
  margin-left: 6px;
}
.tag-child-btn {
  font-size: 0.7rem !important; padding: 0.2rem 0.55rem !important;
}
.tag-child-btn.active {
  background: var(--bg-tag) !important;
  border-color: var(--scrollbar-thumb-hover) !important;
  color: var(--accent) !important;
}

.tag-standalone {
  margin-bottom: 0.15rem;
}

/* Mobile: compact parent buttons */
@media (max-width: 768px) {
  .tag-group { margin-bottom: 0.2rem; }
  .tag-parent-btn { width: auto; padding: 0.2rem 0.5rem; font-size: 0.75rem; }
  .tag-children { padding: 0.2rem 0 0.2rem 0.5rem; margin-left: 3px; }
  .tag-parent-btn .tag-parent-icon { display: none; }
  .tag-parent-btn .tag-parent-count { display: none; }
}


.cat-tag {
  background: var(--bg-sidebar-hover) !important;
  border-color: var(--accent-glow-nano) !important;
  color: var(--accent-fade) !important;
}

/* Blog list inner — no extra title when in layout */
.blog-layout .blog-list-inner { max-width: none; }

/* Mobile: stack sidebar on top */
@media (max-width: 768px) {
  .blog-layout { flex-direction: column; gap: 1rem; }
  .blog-sidebar { flex: none; position: static; padding: 0; }
  .sidebar-nav { display: flex; flex-wrap: wrap; gap: 0.3rem; }
  .sidebar-nav li { margin-bottom: 0; }
  .sidebar-cat-link { padding: 0.25rem 0.6rem; font-size: 0.8rem; border-radius: 20px; border: 1px solid var(--border); }
  .sidebar-cat-link .sidebar-cat-count { display: none; }
  .sidebar-section:last-child { display: none; }
}

/* === Mermaid diagrams === */
pre.mermaid {
  background: var(--bg-mermaid);
  border: 1px solid var(--accent-glow-micro);
  border-radius: 10px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  overflow-x: auto;
  text-align: center;
}
pre.mermaid svg {
  max-width: 100%;
  height: auto;
}
