/* ===== Blog Page Layout ===== */
.blog-page-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 2rem;
  width: min(1200px, 92vw);
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

/* ===== Blog Index — Terminal / Notebook aesthetic ===== */
.blog-index { padding: 0; min-width: 0; }

.mono {
  font-family: ui-monospace, "JetBrains Mono", "Fira Code", "SF Mono", Consolas, "Liberation Mono", monospace;
  font-feature-settings: "ss01", "cv02";
}

/* Hero: plain, no card, no gradient */
.blog-hero {
  margin: 0 0 1.6rem;
  padding: 0.4rem 0 1.4rem;
  border-bottom: 1px dashed var(--line);
  opacity: 1 !important; transform: none !important;
}
.blog-hero .eyebrow {
  margin: 0 0 0.8rem;
  font-size: 0.8rem;
  color: var(--ink-muted);
  letter-spacing: 0;
  text-transform: none;
}
.blog-hero .eyebrow .mono { color: var(--brand); font-weight: 600; }
.blog-hero .eyebrow .mono::before { content: "$ cd "; color: var(--ink-muted); }
.blog-hero h1 {
  margin: 0 0 0.6rem;
  font-family: "Playfair Display", serif;
  font-weight: 500;
  font-size: clamp(1.9rem, 3vw + 0.5rem, 2.6rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.blog-hero .lead {
  margin: 0 0 0.8rem;
  max-width: 62ch;
  font-size: 0.98rem;
  line-height: 1.6;
  color: var(--ink-muted);
}
.blog-hero-stats {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-muted);
  letter-spacing: 0.01em;
}

/* Controls: chips only */
.blog-controls {
  margin: 0 0 1.4rem;
  opacity: 1 !important; transform: none !important;
}
.blog-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.6rem;
  padding: 0.2rem 0;
  border-top: 1px dotted var(--line);
  border-bottom: 1px dotted var(--line);
  padding: 0.55rem 0;
}
.blog-chip {
  font-family: ui-monospace, "JetBrains Mono", "Fira Code", "SF Mono", Consolas, monospace;
  font-size: 0.82rem;
  font-weight: 500;
  border: none;
  background: none;
  color: var(--ink-muted);
  padding: 0.15rem 0.25rem;
  cursor: pointer;
  display: inline-flex;
  align-items: baseline;
  gap: 0.25rem;
  border-radius: 3px;
  transition: color 0.12s ease, background 0.12s ease;
}
.blog-chip::before { content: "["; color: var(--ink-muted); opacity: 0.35; }
.blog-chip::after  { content: "]"; color: var(--ink-muted); opacity: 0.35; }
.blog-chip:hover { color: var(--ink); }
.blog-chip:hover::before,
.blog-chip:hover::after { opacity: 0.7; }
.blog-chip[aria-pressed="true"] {
  color: var(--brand);
  background: color-mix(in srgb, var(--brand) 10%, transparent);
}
.blog-chip[aria-pressed="true"]::before,
.blog-chip[aria-pressed="true"]::after {
  color: var(--brand);
  opacity: 1;
}
.blog-chip-label { font-weight: 600; }
.blog-chip-count {
  font-size: 0.72rem;
  color: var(--ink-muted);
  opacity: 0.7;
}
.blog-chip[aria-pressed="true"] .blog-chip-count { color: var(--brand); opacity: 0.9; }

/* Grid root + categories */
.blog-grid-root {
  display: flex;
  flex-direction: column;
  gap: 2.4rem;
  opacity: 1 !important; transform: none !important;
}
.blog-category { display: flex; flex-direction: column; gap: 0.8rem; }
.blog-category.hidden { display: none; }
.blog-category-header {
  padding-bottom: 0.2rem;
  margin-bottom: 0.4rem;
}
.blog-category-title {
  margin: 0 0 0.25rem;
  font-family: "Syne", sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
}
.blog-category-hash {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--ink-muted);
  opacity: 0.55;
}
.blog-category-count {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-muted);
  opacity: 0.7;
  margin-left: auto;
}
.blog-category-blurb {
  margin: 0;
  font-size: 0.88rem;
  color: var(--ink-muted);
  max-width: 72ch;
}

/* Collapsible series — minimal, no card wrapper */
.blog-section {
  border-top: 1px solid var(--line);
  padding: 0;
}
.blog-section:last-child { border-bottom: 1px solid var(--line); }
.blog-section.hidden { display: none; }
.blog-section-header {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.65rem 0.2rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  color: var(--ink);
  transition: background 0.12s ease;
}
.blog-section-header::-webkit-details-marker { display: none; }
.blog-section-header:hover { background: color-mix(in srgb, var(--brand) 4%, transparent); }
.blog-section-chevron {
  color: var(--ink-muted);
  font-size: 0.75rem;
  transition: transform 0.18s ease;
  width: 0.9rem;
  display: inline-block;
  text-align: center;
  opacity: 0.7;
}
.blog-section[open] .blog-section-chevron { transform: rotate(90deg); color: var(--brand); opacity: 1; }
.blog-section-title {
  flex: 1;
  font-family: "Syne", sans-serif;
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.blog-section-count {
  font-size: 0.75rem;
  color: var(--ink-muted);
  opacity: 0.65;
}
.blog-section[open] .blog-section-count { opacity: 0.9; }
.blog-section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 0.6rem;
  padding: 0.2rem 0 0.8rem 1.3rem;
}

/* Cards: flat, hairline, editorial */
.blog-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.75rem 0.85rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.blog-card:hover {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 4%, transparent);
}
.blog-card.hidden { display: none; }
.blog-card-path {
  font-size: 0.7rem;
  color: var(--ink-muted);
  opacity: 0.65;
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.blog-card:hover .blog-card-path { color: var(--brand); opacity: 0.85; }
.blog-card h3 {
  margin: 0;
  font-family: "Syne", sans-serif;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.005em;
  color: var(--ink);
}
.blog-card p {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.86rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.blog-card-foot {
  margin-top: auto;
  padding-top: 0.3rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.74rem;
  color: var(--ink-muted);
}
.blog-card-meta { flex: 1; opacity: 0.8; }
.blog-card-part {
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--ink-muted);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.blog-card:hover .blog-card-part {
  border-color: color-mix(in srgb, var(--brand) 60%, var(--line));
  color: var(--brand);
}
/* ===== Blog Post ===== */
.blog-post-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 2rem;
  width: min(1200px, 92vw);
  margin: 0 auto;
  padding: 2rem 0 4rem;
  transition: grid-template-columns 0.2s ease;
}
.blog-post-layout.sidebar-collapsed {
  grid-template-columns: 36px 1fr;
  gap: 1rem;
}

/* Blog Sidebar (Nav + TOC) */
.blog-sidebar {
  position: sticky;
  top: 5rem;
  align-self: start;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
  padding-right: 0.5rem;
}

/* Sidebar collapse toggle */
.sidebar-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-muted);
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
  margin-bottom: 0.6rem;
  width: 100%;
  justify-content: flex-start;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.sidebar-toggle:hover { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
.sidebar-toggle .st-icon { font-weight: 700; }
.blog-post-layout.sidebar-collapsed .sidebar-toggle {
  width: 32px;
  padding: 0.3rem 0;
  justify-content: center;
}
.blog-post-layout.sidebar-collapsed .sidebar-toggle .st-label { display: none; }
.blog-post-layout.sidebar-collapsed .blog-sidebar-body { display: none; }

/* Code-Editor File Tree Navigation */
.blog-nav h4 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
  margin: 0 0 0.5rem;
  padding: 0.3rem 0.5rem;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
}

/* Folder toggle button */
.file-tree-toggle {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  width: 100%;
  border: none;
  background: none;
  padding: 0.28rem 0.4rem;
  cursor: pointer;
  font-family: "Manrope", sans-serif;
  font-size: 0.82rem;
  color: var(--ink);
  border-radius: 4px;
  transition: background 0.12s ease;
  text-align: left;
}
.file-tree-toggle:hover { background: rgba(10,143,106,0.06); }
.file-tree-toggle .ft-chevron {
  display: inline-block;
  font-size: 0.55rem;
  color: var(--ink-muted);
  transition: transform 0.2s ease;
  width: 10px;
  text-align: center;
  flex-shrink: 0;
}
.file-tree-toggle.open .ft-chevron { transform: rotate(90deg); }
.file-tree-toggle .ft-icon { font-size: 0.85rem; flex-shrink: 0; }
.file-tree-toggle .ft-label { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Collapsible children container */
.file-tree-children {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.file-tree-children.open { max-height: 800px; }

/* File (leaf) links */
.file-tree-file {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.4rem;
  text-decoration: none;
  color: var(--ink-muted);
  font-size: 0.8rem;
  border-radius: 4px;
  transition: all 0.12s ease;
  border-left: 2px solid transparent;
  line-height: 1.35;
}
.file-tree-file:hover { color: var(--ink); background: rgba(10,143,106,0.05); }
.file-tree-file.active {
  color: var(--brand);
  background: rgba(10,143,106,0.08);
  border-left-color: var(--brand);
  font-weight: 600;
}
.file-tree-file .ft-icon { font-size: 0.78rem; flex-shrink: 0; opacity: 0.7; }
.file-tree-file .ft-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Table of Contents (within sidebar) */
.toc-section {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

/* Spoiler / Solution blocks */
details.spoiler {
  margin: 1rem 0;
  border: 1px solid var(--line, #d9cfba);
  border-radius: 10px;
  overflow: hidden;
}
details.spoiler summary {
  padding: 0.75rem 1rem;
  background: var(--card, #fffdf9);
  cursor: pointer;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--brand, #0a8f6a);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
  list-style: none;
}
details.spoiler summary::-webkit-details-marker { display: none; }
details.spoiler summary::before {
  content: '\25B6';
  font-size: 0.7rem;
  transition: transform 0.2s;
}
details.spoiler[open] summary::before {
  transform: rotate(90deg);
}
details.spoiler summary:hover {
  background: #e8f5ee;
}
details.spoiler .spoiler-content {
  padding: 1rem;
  border-top: 1px solid var(--line, #d9cfba);
  background: var(--bg, #fffdf9);
}
details.spoiler .spoiler-content pre {
  margin: 0.8rem 0;
}

/* Problem card styling */
.problem-card {
  border: 1px solid var(--line, #d9cfba);
  border-radius: 10px;
  padding: 1.2rem;
  margin: 1.5rem 0;
  background: var(--card, #fffdf9);
}
.problem-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
}
.problem-difficulty {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.5rem;
}
.problem-difficulty.easy { background: #d4edda; color: #155724; }
.problem-difficulty.medium { background: #fff3cd; color: #856404; }
.problem-difficulty.hard { background: #f8d7da; color: #721c24; }
.problem-desc { font-size: 0.92rem; color: var(--ink-muted, #4a5a53); margin: 0.3rem 0 0.7rem; }
.problem-card details.spoiler { margin-top: 0.5rem; }


.toc-section h4 {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand);
  margin: 0 0 0.6rem;
}
.toc-section ul { list-style: none; padding: 0; margin: 0; }
.toc-section li { margin-bottom: 0.35rem; }
.toc-section a {
  display: block;
  font-size: 0.85rem;
  color: var(--ink-muted);
  text-decoration: none;
  padding: 0.2rem 0 0.2rem 0.6rem;
  border-left: 2px solid transparent;
  transition: all 0.15s ease;
}
.toc-section a:hover { color: var(--ink); }
.toc-section a.active { color: var(--brand); border-left-color: var(--brand); font-weight: 600; }
.toc-section li.depth-3 a { padding-left: 1.2rem; font-size: 0.82rem; }

/* Post content area */
.blog-post-content {
  max-width: 780px;
  opacity: 1 !important;
  transform: none !important;
}
.blog-post-content .post-series-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}
.post-series-nav a {
  font-size: 0.82rem;
  color: var(--brand);
  text-decoration: none;
  font-weight: 600;
}
.post-series-nav span { color: var(--ink-muted); font-size: 0.82rem; }

.blog-post-content h1 { font-size: clamp(1.6rem, 3.5vw, 2.6rem); max-width: 24ch; margin-bottom: 0.3rem; }
.blog-post-content .post-meta { color: var(--ink-muted); font-size: 0.9rem; margin-bottom: 1.4rem; }
.blog-post-content h2 { font-family: "Syne", sans-serif; font-size: 1.35rem; margin: 2rem 0 0.6rem; padding-top: 0.8rem; border-top: 1px solid var(--line); }
.blog-post-content h3 { font-size: 1.1rem; margin: 1.4rem 0 0.4rem; }

.blog-post-content p { line-height: 1.7; margin: 0.6rem 0; }
.blog-post-content img,
.blog-post-content video { max-width: 100%; border-radius: 10px; margin: 1rem 0; }
.blog-post-content .gif-container { text-align: center; margin: 1.2rem 0; }
.blog-post-content .gif-container img { border: 1px solid var(--line); }
.blog-post-content .gif-caption { font-size: 0.82rem; color: var(--ink-muted); margin-top: 0.3rem; }

/* Code blocks */
.blog-post-content pre {
  background: #1a2b22;
  color: #d4e8dc;
  border-radius: 10px;
  padding: 1rem 1.2rem;
  overflow-x: auto;
  font-size: 0.88rem;
  line-height: 1.55;
  margin: 1rem 0;
}
.blog-post-content code {
  font-family: "Consolas", "Fira Code", monospace;
  font-size: 0.88em;
}
.blog-post-content p code,
.blog-post-content li code {
  background: rgba(10,143,106,0.08);
  color: var(--brand);
  padding: 0.12rem 0.35rem;
  border-radius: 4px;
}

/* Callout / info box */
.callout {
  background: linear-gradient(135deg, rgba(10,143,106,0.06), rgba(255,107,53,0.04));
  border-left: 3px solid var(--brand);
  border-radius: 0 10px 10px 0;
  padding: 0.8rem 1rem;
  margin: 1rem 0;
}
.callout strong { color: var(--brand); }

/* Prev / Next navigation */
.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--line);
}
.post-nav a {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  text-decoration: none;
  color: var(--ink);
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  transition: border-color 0.2s ease;
  max-width: 48%;
}
.post-nav a:hover { border-color: var(--brand); }
.post-nav a span:first-child { font-size: 0.78rem; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.post-nav a span:last-child { font-weight: 700; font-size: 0.95rem; }
.post-nav .next { margin-left: auto; text-align: right; }

/* Back to blog link */
.back-to-blog { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--brand); text-decoration: none; font-weight: 600; font-size: 0.9rem; margin-bottom: 1rem; }
.back-to-blog:hover { text-decoration: underline; }

@media (max-width: 900px) {
  .blog-section-grid { grid-template-columns: 1fr; padding-left: 0.3rem; }
  .blog-page-layout { grid-template-columns: 1fr; }
  .blog-post-layout { grid-template-columns: 1fr; }
  .blog-sidebar { position: static; max-height: none; border: 1px solid var(--line); border-radius: 12px; padding: 0.8rem; margin-bottom: 1rem; background: var(--card); }
}
