/* ============================================================
   EngMats — Blog Styles  (blog.css)
   ============================================================ */

/* Reading progress bar */
.reading-progress {
  position: fixed; top: 0; left: 0; z-index: 9999;
  height: 3px; width: 0;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width .1s linear;
  pointer-events: none;
}

/* ── Blog listing layout ─────────────────────────────────── */
.blog-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 32px;
  padding: 32px 0 64px;
  position: relative; z-index: 1;
  align-items: start;
}
.blog-main  { min-width: 0; }
.blog-sidebar { position: sticky; top: 88px; }

/* Search form */
.blog-search-form {
  display: flex; max-width: 460px; margin-top: 18px;
  background: var(--surface2);
  border: 1px solid var(--border-s); border-radius: var(--r);
  overflow: hidden;
}
.blog-search-form input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); padding: 10px 14px; font-size: .9rem;
}
.blog-search-form button {
  background: var(--primary); border: none; color: #000;
  padding: 10px 16px; cursor: pointer; font-size: .9rem;
  transition: background .2s;
}
.blog-search-form button:hover { background: #ffc048; }

/* Category pills */
.blog-cat-bar {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 22px;
}
.blog-cat-pill {
  display: inline-flex; align-items: center;
  padding: 5px 14px; border-radius: 99px;
  font-size: .78rem; font-weight: 500;
  background: var(--surface2); border: 1px solid var(--border-s);
  color: var(--text-dim); text-decoration: none;
  transition: all .18s;
}
.blog-cat-pill:hover { border-color: var(--primary); color: var(--primary); }
.blog-cat-pill.active { background: var(--primary); color: #000; border-color: var(--primary); font-weight: 700; }

/* Results info */
.blog-results-info {
  display: flex; align-items: center; gap: 8px;
  font-size: .875rem; color: var(--text-dim); margin-bottom: 18px;
}
.blog-count { color: var(--primary); font-weight: 700; font-size: 1.1rem; }
.blog-clear {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface3); color: var(--text-muted);
  text-decoration: none; font-size: .75rem;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.blog-clear:hover { background: var(--danger); color: #fff; }

/* Blog grid */
.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 20px;
}

/* Blog card */
.blog-card {
  background: var(--surface);
  border: 1px solid var(--border-s);
  border-radius: var(--rl);
  overflow: hidden;
  display: flex; flex-direction: column;
  transition: all .22s;
}
.blog-card:hover {
  border-color: var(--primary);
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(0,0,0,.4);
}
.blog-card-featured {
  grid-column: 1 / -1;
  flex-direction: row;
}
.blog-card-featured .blog-card-img-wrap { width: 40%; flex-shrink: 0; }
.blog-card-featured .blog-card-img-wrap img { height: 100%; }

.blog-card-img-wrap {
  display: block; overflow: hidden; position: relative;
  height: 190px; background: var(--surface2);
}
.blog-card-img-wrap img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .4s;
}
.blog-card:hover .blog-card-img-wrap img { transform: scale(1.04); }

.blog-card-img-placeholder {
  height: 160px; display: flex; align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, color-mix(in srgb, var(--cat-color,var(--primary)) 20%, var(--surface2)), var(--surface2));
  font-size: 2.5rem; color: var(--cat-color, var(--primary)); opacity: .5;
}

.blog-featured-badge {
  position: absolute; top: 10px; left: 10px;
  background: var(--primary); color: #000;
  font-size: .7rem; font-weight: 700; padding: 3px 8px;
  border-radius: 4px;
}

.blog-card-body { padding: 16px 18px; display: flex; flex-direction: column; flex: 1; }

.blog-card-cat {
  font-size: .7rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--cat-color, var(--primary));
  text-decoration: none; margin-bottom: 7px; display: block;
}
.blog-card-title {
  font-family: var(--fh); font-size: 1.05rem; font-weight: 700;
  color: #fff; margin: 0 0 9px; line-height: 1.3;
}
.blog-card-title a { color: inherit; text-decoration: none; }
.blog-card-title a:hover { color: var(--primary); }
.blog-card-excerpt {
  font-size: .85rem; color: var(--text-dim); line-height: 1.6;
  flex: 1; margin-bottom: 12px;
}
.blog-card-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; border-top: 1px solid var(--border-s); padding-top: 10px;
}
.blog-card-meta {
  display: flex; flex-wrap: wrap; gap: 8px;
  font-size: .72rem; color: var(--text-muted);
}
.blog-card-meta span { display: flex; align-items: center; gap: 3px; }
.blog-read-more {
  font-size: .78rem; font-weight: 600; color: var(--primary);
  text-decoration: none; white-space: nowrap; transition: color .15s;
}
.blog-read-more:hover { color: var(--accent); }

/* Pagination */
.blog-pagination {
  display: flex; gap: 6px; justify-content: center; margin-top: 32px;
}
.pag-btn {
  width: 36px; height: 36px; display: flex; align-items: center;
  justify-content: center; border-radius: var(--r);
  background: var(--surface2); border: 1px solid var(--border-s);
  color: var(--text-dim); text-decoration: none; font-size: .875rem;
  transition: all .15s;
}
.pag-btn:hover, .pag-btn.active {
  background: var(--primary); border-color: var(--primary);
  color: #000; font-weight: 700;
}

/* Empty state */
.blog-empty {
  text-align: center; padding: 64px 24px; color: var(--text-muted);
}
.blog-empty i { font-size: 3rem; margin-bottom: 14px; opacity: .2; display: block; }

/* ── Sidebar widgets ─────────────────────────────────────── */
.blog-widget {
  background: var(--surface);
  border: 1px solid var(--border-s);
  border-radius: var(--rl);
  padding: 16px 18px;
  margin-bottom: 18px;
}
.blog-widget-title {
  font-family: var(--fh); font-size: .82rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .8px;
  color: var(--text-dim); margin-bottom: 12px;
  display: flex; align-items: center; gap: 6px;
}
.blog-widget-title i { color: var(--primary); }

.blog-cat-list { list-style: none; margin: 0; padding: 0; }
.blog-cat-list li { border-bottom: 1px solid var(--border-s); }
.blog-cat-list li:last-child { border-bottom: none; }
.blog-cat-list a {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 2px; color: var(--text-dim);
  text-decoration: none; font-size: .875rem; transition: color .15s;
}
.blog-cat-list a:hover, .blog-cat-list a.active { color: var(--primary); }
.cat-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.blog-widget-post {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 9px 0; border-bottom: 1px solid var(--border-s);
  text-decoration: none; transition: opacity .15s;
}
.blog-widget-post:last-child { border-bottom: none; padding-bottom: 0; }
.blog-widget-post:hover { opacity: .75; }
.blog-widget-post img { width: 50px; height: 38px; object-fit: cover; border-radius: 4px; flex-shrink: 0; }
.blog-widget-post-title { font-size: .8rem; color: var(--text); line-height: 1.4; font-weight: 500; }
.blog-widget-post-date { font-size: .7rem; color: var(--text-muted); margin-top: 2px; }

/* ── POST PAGE ───────────────────────────────────────────── */
.post-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 40px;
  padding: 32px 0 64px;
  position: relative; z-index: 1;
  align-items: start;
}
.post-article { min-width: 0; }
.post-sidebar  { position: sticky; top: 88px; }

.post-cat-badge {
  display: inline-block; padding: 3px 12px; border-radius: 4px;
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .8px; color: var(--cat-color, var(--primary));
  background: color-mix(in srgb, var(--cat-color, var(--primary)) 18%, transparent);
  text-decoration: none; margin-bottom: 10px;
}
.post-title {
  font-family: var(--fh); font-size: 2.2rem; font-weight: 800;
  color: #fff; line-height: 1.2; margin: 0 0 14px;
}
.post-excerpt {
  font-size: 1.05rem; color: var(--text-dim); line-height: 1.7;
  margin-bottom: 18px; font-style: italic;
  padding-bottom: 16px; border-bottom: 1px solid var(--border-s);
}
.post-meta {
  display: flex; flex-wrap: wrap; gap: 14px;
  font-size: .8rem; color: var(--text-muted); margin-bottom: 24px;
}
.post-meta-item { display: flex; align-items: center; gap: 5px; }
.post-meta-item i { color: var(--primary); width: 12px; }

.post-featured-img {
  margin: 0 0 32px;
  border-radius: var(--rl); overflow: hidden;
  border: 1px solid var(--border-s);
}
.post-featured-img img { width: 100%; display: block; max-height: 480px; object-fit: cover; }

/* Table of Contents */
.post-toc {
  background: var(--surface2);
  border: 1px solid var(--border-s);
  border-left: 3px solid var(--primary);
  border-radius: var(--r);
  padding: 14px 18px;
  margin-bottom: 28px;
}
.toc-title {
  display: flex; align-items: center; justify-content: space-between;
  font-family: var(--fh); font-size: .8rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .8px;
  color: var(--primary); margin-bottom: 10px;
}
.toc-toggle {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 0; font-size: .8rem;
}
.toc-list { margin: 0; padding-left: 18px; list-style: decimal; }
.toc-list.hidden { display: none; }
.toc-list a {
  color: var(--text-dim); text-decoration: none;
  font-size: .85rem; line-height: 1.8; transition: color .15s;
}
.toc-list a:hover, .toc-list a.toc-active { color: var(--primary); }
.toc-level-3 { padding-left: 14px; }
.toc-sidebar { padding-left: 16px; font-size: .8rem; }

/* Post content */
.post-content {
  font-size: .975rem; line-height: 1.82; color: var(--text-dim);
}
.post-content h2 {
  font-family: var(--fh); font-size: 1.6rem; font-weight: 700;
  color: #fff; margin: 36px 0 14px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border-s);
}
.post-content h3 {
  font-family: var(--fh); font-size: 1.25rem; font-weight: 700;
  color: var(--text); margin: 26px 0 10px;
}
.post-content h4 {
  font-size: 1rem; font-weight: 700; color: var(--primary); margin: 18px 0 6px;
}
.post-content p { margin: 0 0 16px; }
.post-content ul, .post-content ol { margin: 0 0 16px 22px; line-height: 1.8; }
.post-content li { margin-bottom: 4px; }
.post-content strong { color: var(--text); font-weight: 700; }
.post-content a { color: var(--primary); text-decoration: underline; }
.post-content a:hover { color: var(--accent); }
.post-content blockquote {
  border-left: 3px solid var(--primary);
  margin: 18px 0; padding: 12px 18px;
  background: var(--surface2); border-radius: 0 var(--r) var(--r) 0;
  color: var(--text-dim); font-style: italic;
}
.post-content pre {
  background: #0d1117; border: 1px solid var(--border);
  border-radius: var(--r); padding: 14px 18px; overflow-x: auto;
  margin: 0 0 16px; font-family: var(--fm); font-size: .875rem;
}
.post-content code {
  font-family: var(--fm); font-size: .875rem;
  background: var(--surface3); padding: 2px 5px;
  border-radius: 3px; color: var(--accent);
}
.post-content pre code { background: none; padding: 0; color: inherit; }
.post-content img {
  max-width: 100%; border-radius: var(--r);
  border: 1px solid var(--border-s); display: block; margin: 8px auto;
}
.post-content figure { margin: 20px 0; text-align: center; }
.post-content figcaption { font-size: .77rem; color: var(--text-muted); margin-top: 5px; }
.post-content table {
  width: 100%; border-collapse: collapse; margin: 0 0 18px;
  font-size: .875rem; display: block; overflow-x: auto;
}
.post-content table th {
  background: var(--surface2); color: var(--text); font-weight: 700;
  padding: 8px 12px; text-align: left; border: 1px solid var(--border);
}
.post-content table td {
  padding: 7px 12px; border: 1px solid var(--border-s); color: var(--text-dim);
}
.post-content table tr:hover td { background: var(--surface2); }
.post-content hr { border: none; border-top: 1px solid var(--border-s); margin: 28px 0; }

/* Callout blocks */
.post-content .blog-callout {
  padding: 12px 16px; border-radius: var(--r); margin: 18px 0;
  border-left: 4px solid var(--primary); background: var(--primary-d);
  font-size: .9rem; line-height: 1.6;
}
.post-content .blog-callout.info    { border-color: var(--accent); background: var(--accent-d); }
.post-content .blog-callout.warning { border-color: var(--danger); background: rgba(231,76,60,.1); }
.post-content .blog-callout.tip     { border-color: #27c785; background: rgba(39,199,133,.1); }
.post-content .blog-callout strong  { color: var(--text); }

/* Comparison table */
.post-content .compare-table th { background: var(--primary); color: #000; }
.post-content .compare-table td:first-child { font-weight: 600; color: var(--text); }

/* Post tags */
.post-tags {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: 28px 0 18px; padding-top: 18px; border-top: 1px solid var(--border-s);
}
.post-tags-label {
  font-size: .78rem; color: var(--text-muted);
  display: flex; align-items: center; gap: 5px;
}
.post-tag {
  background: var(--surface2); border: 1px solid var(--border-s);
  border-radius: 4px; padding: 2px 9px; font-size: .77rem; color: var(--text-dim);
}

/* Share */
.post-share {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border-s);
}
.post-share-label { font-size: .8rem; color: var(--text-muted); }
.share-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: var(--r);
  font-size: .8rem; font-weight: 600; text-decoration: none;
  cursor: pointer; border: none; transition: all .18s;
}
.share-linkedin { background: #0077b5; color: #fff; }
.share-linkedin:hover { background: #005f93; }
.share-twitter  { background: #000; color: #fff; }
.share-twitter:hover  { background: #333; }
.share-copy { background: var(--surface2); color: var(--text); border: 1px solid var(--border-s); }
.share-copy:hover { background: var(--surface3); }

/* ── Admin blog editor ───────────────────────────────────── */
.editor-toolbar {
  display: flex; flex-wrap: wrap; gap: 3px;
  padding: 8px 10px;
  background: var(--admin-surface2, var(--surface2));
  border: 1px solid var(--admin-border, var(--border-s));
  border-bottom: none;
  border-radius: var(--r) var(--r) 0 0;
}
.editor-btn {
  background: none; border: 1px solid transparent;
  border-radius: 3px; color: var(--admin-text, var(--text));
  padding: 4px 8px; cursor: pointer; font-size: .8rem;
  transition: all .15s; display: inline-flex; align-items: center; gap: 4px;
}
.editor-btn:hover { background: var(--surface3); }
.editor-sep { width: 1px; background: var(--border-s); margin: 2px 3px; }
.blog-editor {
  width: 100%; min-height: 480px;
  background: var(--admin-surface, var(--surface));
  border: 1px solid var(--admin-border, var(--border-s));
  border-radius: 0 0 var(--r) var(--r);
  color: var(--admin-text, var(--text));
  font-family: var(--fm); font-size: .88rem; line-height: 1.7;
  padding: 14px 16px; resize: vertical; outline: none;
  box-sizing: border-box;
}
.blog-editor:focus { border-color: var(--primary); }

.img-gallery {
  display: grid; grid-template-columns: repeat(auto-fill,minmax(90px,1fr));
  gap: 6px; max-height: 280px; overflow-y: auto;
  padding: 8px;
  background: var(--surface2);
  border: 1px solid var(--border-s);
  border-radius: 0 0 var(--r) var(--r);
}
.img-gallery-item {
  position: relative; cursor: pointer;
  border: 2px solid transparent; border-radius: 4px; overflow: hidden;
  transition: border-color .15s;
}
.img-gallery-item:hover { border-color: var(--primary); }
.img-gallery-item img { width: 100%; height: 70px; object-fit: cover; display: block; }
.img-gallery-item .img-ins-btn {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: var(--primary); color: #000;
  font-size: .65rem; font-weight: 700; text-align: center;
  padding: 2px; opacity: 0; transition: opacity .15s;
}
.img-gallery-item:hover .img-ins-btn { opacity: 1; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 960px) {
  .blog-layout, .post-layout {
    grid-template-columns: 1fr;
  }
  .blog-sidebar, .post-sidebar {
    position: static; order: -1;
  }
  .blog-card-featured { flex-direction: column; }
  .blog-card-featured .blog-card-img-wrap { width: 100%; }
  .post-title { font-size: 1.75rem; }
  .post-sidebar-toc { display: none; }
}
@media (max-width: 600px) {
  .blog-grid { grid-template-columns: 1fr; }
  .post-title { font-size: 1.5rem; }
  .post-content h2 { font-size: 1.35rem; }
  .blog-cat-bar { gap: 6px; }
  .blog-cat-pill { font-size: .72rem; padding: 4px 10px; }
}
