/* Blog-only styles (notes listing, search UI, and post template)
  Depends on shared variables/layout in css/style.css */

/* ACTIVE NAV LINK (Blog) */
.page-blog .nav-links a[href="/blog/"] {
  color: var(--accent);
  font-weight: 700;
  text-shadow: 0 0 6px var(--accent-glow);
}

.page-blog .nav-links a[href="/blog/"]::after {
  width: 100%;
}

/* Blog layout: keep a comfortable reading width without huge empty sides */
.page-blog .page {
  margin-left: auto;
  margin-right: auto;
  max-width: 1280px;
  /* Override base .page padding (80px 8%) to reduce side whitespace */
  padding-left: clamp(16px, 4vw, 48px);
  padding-right: clamp(16px, 4vw, 48px);
}

/* Tags page: use the full page width on large screens */
.page-blog [data-tags-root] {
  width: min(1600px, 100%);
  margin-left: auto;
  margin-right: auto;
  padding-left: clamp(16px, 3vw, 36px);
  padding-right: clamp(16px, 3vw, 36px);
}

/* Wider intro copy on blog landing/category pages */
.page-blog .about-intro {
  max-width: 980px;
  line-height: 1.7;
}

/* NOTES / BLOG LANDING */
.notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  margin-top: 40px;
}

/* Tags index: more, smaller tiles on large screens */
.page-blog [data-tags-root] .notes-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

@media (min-width: 1200px) {
  .page-blog [data-tags-root] .notes-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
}

.notes-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  padding: 22px;
  border-radius: 6px;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

/* Ensure anchor cards keep the site's theme (no blue/purple underlines) */
.notes-card {
  text-decoration: none;
  color: inherit;
  display: block;
}

.notes-card:visited {
  color: inherit;
}

.notes-card h2 {
  color: var(--heading);
  margin-bottom: 8px;
}

.notes-card p {
  color: var(--text-muted-2);
  line-height: 1.5;
  font-size: 15px;
}

.notes-meta {
  display: inline-block;
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-subtle);
}

.notes-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 0 18px rgba(var(--accent-rgb), 0.12);
}

/* BLOG SEARCH */
.blog-search {
  margin: 18px 0 24px;
  padding: 14px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.blog-search-label {
  display: block;
  font-size: 13px;
  color: var(--text-muted-2);
  margin-bottom: 8px;
}

.blog-search-input {
  width: 100%;
  padding: 12px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  outline: none;
}

.blog-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.15);
}

.blog-search-results {
  margin-top: 12px;
}

.blog-search-hint {
  padding: 10px 2px 2px;
  color: var(--text-subtle);
  font-size: 13px;
}

.blog-search-results ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.blog-search-results a {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 12px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.blog-search-results a:hover {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(var(--accent-rgb), 0.12);
}

.blog-search-results .result-title {
  color: var(--heading);
  font-weight: 700;
  margin-bottom: 4px;
}

.blog-search-results .result-meta {
  color: var(--text-subtle);
  font-size: 12px;
}

/* BLOG INDEX: LATEST NOTES */
.blog-latest {
  margin: 28px 0 36px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elev);
}

.blog-latest-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.blog-latest-header h2 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--heading);
}

.blog-latest-link {
  color: var(--text-muted-2);
  text-decoration: none;
  font-size: 13px;
  border-bottom: 1px solid transparent;
}

.blog-latest-link:hover {
  color: var(--accent);
  border-bottom-color: rgba(var(--accent-rgb), 0.4);
}

.blog-latest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.blog-latest-card {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.blog-latest-card:hover {
  transform: translateY(-2px);
  border-color: rgba(var(--accent-rgb), 0.35);
  box-shadow: 0 0 14px rgba(var(--accent-rgb), 0.12);
}

.blog-latest-meta {
  display: block;
  font-size: 12px;
  color: var(--text-subtle);
  margin-bottom: 6px;
}

.blog-latest-card h3 {
  margin: 0 0 6px;
  font-size: 15px;
  color: var(--heading);
  line-height: 1.35;
}

.blog-latest-card p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted-2);
  line-height: 1.5;
}

/* BLOG POST TEMPLATE */
.post {
  max-width: 100%;
}

.post-header {
  margin-bottom: 36px;
}

.post-title {
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  color: var(--accent);
  margin-bottom: 10px;
}

.post-meta {
  font-size: 13px;
  color: var(--text-subtle);
}

.post-type {
  color: var(--accent);
  font-weight: 600;
}

.post-tags {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0;
  list-style: none;
}

.post-tag {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(var(--accent-rgb), 0.06);
  color: var(--text-muted-2);
  font-size: 12px;
  letter-spacing: 0.2px;
}

/* Tag links should look like pills, not underlined links */
.post-tags a.post-tag {
  text-decoration: none;
}

.post-tags a.post-tag:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.post-intent {
  background: var(--bg-elev);
  border-left: 3px solid var(--accent);
  padding: 16px 18px;
  margin-bottom: 28px;
  color: var(--text-muted);
  font-size: 15px;
}

.post-content h2 {
  margin-top: 34px;
  margin-bottom: 10px;
  color: var(--heading);
}

/* Defer heavy blog content rendering below the fold */
.post-content,
.post-related,
.notes-grid {
  content-visibility: auto;
  contain-intrinsic-size: 800px;
}

.post-content p {
  font-size: 1.08rem;
  line-height: 1.75;
  color: var(--text-muted);
  margin-bottom: 16px;
}

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

.post-content a:hover {
  color: var(--accent);
}

.post-content code {
  font-family: var(--font-mono);
  font-size: 0.95em;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(var(--accent-rgb), 0.12);
  padding: 0.12em 0.35em;
  border-radius: 6px;
}

html[data-theme="light"] .post-content code {
  background: rgba(15, 23, 42, 0.06);
  border-color: rgba(15, 23, 42, 0.12);
}

.post-content pre {
  margin: 18px 0;
  padding: 14px 14px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(var(--accent-rgb), 0.18);
  border-radius: 10px;
  overflow: auto;
}

.post-content figure {
  margin: 24px auto;
  max-width: 900px;
}

.blog-img {
  width: 100%;
  height: auto;
  display: block;
  margin: 0;
  border-radius: 6px;
}

.post-content figcaption {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-subtle);
  text-align: center;
}

html[data-theme="light"] .post-content pre {
  background: rgba(15, 23, 42, 0.05);
  border-color: rgba(15, 23, 42, 0.12);
}

.post-content pre code {
  background: transparent;
  border: 0;
  padding: 0;
  border-radius: 0;
  display: block;
  font-size: 0.95rem;
  line-height: 1.6;
  white-space: pre;
}

.post-content blockquote {
  margin: 18px 0;
  padding: 12px 14px;
  background: var(--bg-elev);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  color: var(--text-muted);
}

.post-content ul {
  margin-left: 18px;
  margin-bottom: 20px;
}

.post-content ul li {
  margin-bottom: 10px;
  color: var(--text-muted);
}

.post-content ol {
  margin-left: 18px;
  margin-bottom: 20px;
}

.post-content ol li {
  margin-bottom: 10px;
  color: var(--text-muted);
}

.post-content hr {
  border: 0;
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

/* Related notes block (rendered by JS on post pages) */
.post-related {
  margin-top: 38px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.post-related h2 {
  margin: 0 0 14px;
  color: var(--heading);
}

.post-related .notes-grid {
  margin-top: 14px;
}

/* Mobile blog post */
@media (max-width: 768px) {
  .post-title {
    font-size: 28px;
  }

  .post {
    max-width: 100%;
  }

  .post-content p {
    font-size: 1.04rem;
    line-height: 1.72;
  }
}
