/* ============================================================
   ToolNest – blog.css
   Blog listing page, single post, and blog-specific components
   ============================================================ */

/* ────────────────────────────────────────────────────────────
   1. BLOG LISTING PAGE LAYOUT
──────────────────────────────────────────────────────────── */
.blog-page {
  padding: var(--sp-4) 0 var(--sp-6);
}

.blog-page__layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: var(--sp-4);
  align-items: start;
}

@media (max-width: 1023px) {
  .blog-page__layout {
    grid-template-columns: 1fr;
  }
}

/* ────────────────────────────────────────────────────────────
   2. BLOG LISTING GRID
──────────────────────────────────────────────────────────── */
.blog-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-3);
}

.blog-grid--single {
  grid-template-columns: 1fr;
}

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

/* Featured / hero post card */
.post-card--featured {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: stretch;
}

.post-card--featured .post-card__img,
.post-card--featured .post-card__img-placeholder {
  width: 45%;
  height: auto;
  min-height: 220px;
  flex-shrink: 0;
}

.post-card--featured .post-card__title {
  font-size: var(--text-xl);
  -webkit-line-clamp: 3;
}

.post-card--featured .post-card__excerpt {
  -webkit-line-clamp: 4;
}

@media (max-width: 767px) {
  .post-card--featured {
    flex-direction: column;
  }
  .post-card--featured .post-card__img,
  .post-card--featured .post-card__img-placeholder {
    width: 100%;
    height: 200px;
  }
}

/* ────────────────────────────────────────────────────────────
   3. BLOG SIDEBAR
──────────────────────────────────────────────────────────── */
.blog-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  position: sticky;
  top: calc(var(--nav-height) + var(--sp-2));
}

.blog-sidebar__widget {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.blog-sidebar__widget-header {
  padding: 14px var(--sp-2);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
  font-weight: var(--font-semi);
  color: var(--text-primary);
  background: var(--bg-input);
}

.blog-sidebar__widget-body {
  padding: var(--sp-2);
}

/* Category list in sidebar */
.sidebar-category-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-category-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
}

.sidebar-category-item:hover {
  background: var(--bg-input);
  color: var(--primary);
}

.sidebar-category-item.is-active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: var(--font-medium);
}

.sidebar-category-item__count {
  background: var(--bg-input);
  border-radius: var(--radius-full);
  padding: 1px 7px;
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--text-muted);
}

/* Recent posts in sidebar */
.sidebar-recent-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.sidebar-recent-item {
  display: flex;
  gap: 12px;
  text-decoration: none;
  align-items: flex-start;
}

.sidebar-recent-item__img {
  width: 64px;
  height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--primary-light);
}

.sidebar-recent-item__title {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  line-height: var(--leading-tight);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
  transition: color var(--transition);
}

.sidebar-recent-item:hover .sidebar-recent-item__title {
  color: var(--primary);
}

.sidebar-recent-item__date {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Tag cloud */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-cloud__tag {
  display: inline-flex;
  padding: 4px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition);
}

.tag-cloud__tag:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

/* ────────────────────────────────────────────────────────────
   4. SINGLE POST LAYOUT
──────────────────────────────────────────────────────────── */
.post-layout {
  padding: var(--sp-4) 0 var(--sp-6);
}

.post-layout__inner {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: var(--sp-5);
  align-items: start;
}

@media (max-width: 1023px) {
  .post-layout__inner {
    grid-template-columns: 1fr;
  }
}

/* Content wrapper */
.post-content-wrap {
  min-width: 0;
}

/* Post hero image */
.post-hero-img {
  width: 100%;
  max-height: 440px;
  object-fit: cover;
  border-radius: var(--radius-lg);
  margin-bottom: var(--sp-3);
  box-shadow: var(--shadow-md);
}

/* Post title */
.post-title {
  font-size: clamp(1.5rem, 3.5vw, 2.25rem);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin-bottom: var(--sp-2);
}

/* ────────────────────────────────────────────────────────────
   5. POST METADATA BAR
──────────────────────────────────────────────────────────── */
.post-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  padding: var(--sp-2) 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-3);
}

.post-meta__item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.post-meta__item svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.post-meta__sep {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--border);
}

.post-meta__author-img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--primary-light);
}

.post-meta__author-name {
  font-weight: var(--font-medium);
  color: var(--text-secondary);
}

/* ────────────────────────────────────────────────────────────
   6. ARTICLE BODY TYPOGRAPHY
──────────────────────────────────────────────────────────── */
.post-body {
  max-width: 720px;
  font-size: var(--text-base);
  line-height: var(--leading-loose);
  color: var(--text-secondary);
}

.post-body > * + * {
  margin-top: var(--sp-2);
}

.post-body p {
  color: var(--text-secondary);
  line-height: var(--leading-loose);
}

/* Headings inside article */
.post-body h2 {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  margin-top: var(--sp-4);
  margin-bottom: var(--sp-1);
  padding-bottom: 10px;
  border-bottom: 2px solid var(--primary-light);
  line-height: var(--leading-tight);
}

.post-body h3 {
  font-size: var(--text-lg);
  font-weight: var(--font-semi);
  color: var(--text-primary);
  margin-top: var(--sp-3);
  margin-bottom: var(--sp-1);
}

.post-body h4 {
  font-size: var(--text-base);
  font-weight: var(--font-semi);
  color: var(--text-primary);
  margin-top: var(--sp-2);
  margin-bottom: 8px;
}

.post-body a {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.post-body a:hover {
  color: var(--primary-dark);
}

.post-body ul,
.post-body ol {
  padding-left: var(--sp-3);
}

.post-body ul { list-style: disc; }
.post-body ol { list-style: decimal; }

.post-body li {
  color: var(--text-secondary);
  line-height: var(--leading-loose);
  margin-bottom: 6px;
}

.post-body strong {
  font-weight: var(--font-semi);
  color: var(--text-primary);
}

.post-body em {
  font-style: italic;
}

/* Blockquote */
.post-body blockquote {
  border-left: 4px solid var(--primary);
  background: var(--primary-light);
  padding: var(--sp-2) var(--sp-3);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin: var(--sp-3) 0;
}

.post-body blockquote p {
  font-size: var(--text-md);
  font-style: italic;
  color: var(--text-primary);
  margin: 0;
}

.post-body blockquote cite {
  display: block;
  margin-top: 8px;
  font-size: var(--text-sm);
  color: var(--text-muted);
  font-style: normal;
}

/* Code inline */
.post-body code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  color: var(--cat-dev);
}

/* Code block */
.post-body pre {
  background: #1E2235;
  border-radius: var(--radius-md);
  padding: var(--sp-3);
  overflow-x: auto;
  margin: var(--sp-3) 0;
  border: 1px solid rgba(255,255,255,0.06);
}

.post-body pre code {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: none;
  border: none;
  padding: 0;
  color: #E2E8F0;
  line-height: 1.7;
}

/* Syntax highlight colours (minimal) */
.post-body pre .keyword  { color: #93C5FD; }
.post-body pre .string   { color: #86EFAC; }
.post-body pre .comment  { color: #94A3B8; font-style: italic; }
.post-body pre .number   { color: #FCA5A5; }
.post-body pre .function { color: #FDE68A; }

/* Tables in articles */
.post-body table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--sp-3) 0;
  font-size: var(--text-sm);
}

.post-body th {
  background: var(--bg-input);
  color: var(--text-primary);
  font-weight: var(--font-semi);
  text-align: left;
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
}

.post-body td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

.post-body tr:hover td {
  background: var(--bg-input);
}

/* Image captions */
.post-body figure {
  margin: var(--sp-3) 0;
}

.post-body figure img {
  border-radius: var(--radius-md);
  width: 100%;
}

.post-body figcaption {
  text-align: center;
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: 8px;
  font-style: italic;
}

/* Horizontal rule inside article */
.post-body hr {
  border: none;
  border-top: 2px solid var(--border);
  margin: var(--sp-4) 0;
}

/* ────────────────────────────────────────────────────────────
   7. ADSENSE IN ARTICLES
──────────────────────────────────────────────────────────── */
.post-ad {
  margin: var(--sp-4) 0;
  display: flex;
  justify-content: center;
}

.post-ad--sidebar {
  margin: 0;
  width: 100%;
  min-height: 250px;
}

/* ────────────────────────────────────────────────────────────
   8. POST SHARE BAR
──────────────────────────────────────────────────────────── */
.post-share {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  flex-wrap: wrap;
  padding: var(--sp-2) 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin: var(--sp-3) 0;
}

.post-share__label {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  margin-right: 4px;
}

.post-share__btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  font-size: var(--text-sm);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
}

.post-share__btn:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ────────────────────────────────────────────────────────────
   9. RELATED POSTS GRID
──────────────────────────────────────────────────────────── */
.related-posts {
  padding: var(--sp-4) 0;
  border-top: 1px solid var(--border);
}

.related-posts__title {
  font-size: var(--text-xl);
  font-weight: var(--font-semi);
  color: var(--text-primary);
  margin-bottom: var(--sp-3);
}

.related-posts__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-2);
}

@media (max-width: 1023px) {
  .related-posts__grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 639px) {
  .related-posts__grid { grid-template-columns: 1fr; }
}

/* ────────────────────────────────────────────────────────────
   10. CATEGORY HEADER (listing page)
──────────────────────────────────────────────────────────── */
.blog-category-header {
  padding: var(--sp-3) 0 var(--sp-2);
  margin-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border);
}

.blog-category-header__title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  margin-bottom: 4px;
}

.blog-category-header__desc {
  font-size: var(--text-base);
  color: var(--text-secondary);
}

/* ────────────────────────────────────────────────────────────
   11. BLOG PAGINATION
──────────────────────────────────────────────────────────── */
.blog-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) 0;
  border-top: 1px solid var(--border);
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.blog-pagination__info {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.blog-pagination__btns {
  display: flex;
  gap: 6px;
}

/* ────────────────────────────────────────────────────────────
   12. POST STUB / SKELETON
──────────────────────────────────────────────────────────── */
.post-card-skeleton {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.post-card-skeleton__img  { height: 180px; }
.post-card-skeleton__body { padding: var(--sp-2) var(--sp-3); }
.post-card-skeleton__line {
  height: 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}
.post-card-skeleton__line--short { width: 55%; }
.post-card-skeleton__line--title { height: 20px; margin-bottom: 12px; }

/* ────────────────────────────────────────────────────────────
   13. TABLE OF CONTENTS (post sidebar)
──────────────────────────────────────────────────────────── */
.toc {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  position: sticky;
  top: calc(var(--nav-height) + var(--sp-2));
  max-height: calc(100vh - var(--nav-height) - var(--sp-4));
  overflow-y: auto;
}

.toc__header {
  padding: 14px var(--sp-2);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
  font-weight: var(--font-semi);
  color: var(--text-primary);
  background: var(--bg-input);
  position: sticky;
  top: 0;
}

.toc__list {
  padding: var(--sp-1) var(--sp-2);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.toc__item {
  display: block;
  padding: 5px 8px;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  transition: all var(--transition);
  line-height: var(--leading-normal);
}

.toc__item:hover {
  color: var(--primary);
  background: var(--primary-light);
}

.toc__item.is-active {
  color: var(--primary);
  border-left-color: var(--primary);
  background: var(--primary-light);
  font-weight: var(--font-medium);
}

.toc__item--h3 {
  padding-left: 20px;
  font-size: var(--text-xs);
}
