/* Blog pages minimal responsive UI (inherits global variables from style.css) */
html, body { overflow-x: hidden; }

.hero {
  background: var(--light-bg);
  padding: 40px 0;
}
.hero h2 { margin: 0 0 8px 0; }
.hero p { color: var(--text-muted); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}
.card {
  display: flex;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 16px;
  background: var(--white);
  text-decoration: none;
  color: var(--text-dark);
  transition: box-shadow .2s ease, transform .2s ease;
}
.card:hover { box-shadow: 0 8px 30px rgba(0,0,0,0.08); transform: translateY(-2px); }
.card-icon { width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; background: var(--light-bg); color: var(--primary-color); border-radius: 10px; font-size: 1.1rem; }
.card-content h4 { margin: 0; font-size: 1.05rem; }
.card-content p { margin: 4px 0 0 0; color: var(--text-muted); font-size: .92rem; }

.post-card {
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 18px;
  background: var(--white);
  margin: 16px auto;
  max-width: 860px;
  box-shadow: 0 6px 24px rgba(2, 6, 23, 0.06);
}
.reading-wide .post-card { max-width: 1020px; }
.post-card h4 { margin: 0 0 8px 0; }
.post-content { font-size: 1.02rem; line-height: 1.7; overflow-wrap: anywhere; }
.post-content p { margin-bottom: 10px; }
.post-content pre {
  background: #f8fafc; /* light background */
  color: #0f172a; /* dark text */
  padding: 16px 18px;
  border-radius: 10px;
  overflow: auto;
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--primary-color);
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
  position: relative;
}
.post-content pre code {
  display: block;
  white-space: pre;
  font-size: .95rem;
  line-height: 1.55;
}
.post-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}
.post-content p code, .post-content li code {
  background: #f1f5f9; /* slate-100 */
  color: #0f172a;
  border: 1px solid #e2e8f0;
  padding: 2px 6px;
  border-radius: 6px;
}

/* Rich content blocks */
.post-content .content-block {
  border: 1px solid var(--card-border);
  border-left: 4px solid var(--primary-color);
  background: #f9fafb;
  border-radius: 10px;
  padding: 12px 14px;
  margin: 12px 0;
}
.post-content .content-block .block-title {
  font-weight: 600;
  color: var(--text-dark);
  margin: 0 0 8px 0;
}
.post-content .content-block.syntax { border-left-color: var(--primary-color); }
.post-content .content-block.example { border-left-color: var(--success); }
.post-content .content-block.output { border-left-color: #64748b; background: #f8fafc; }
.post-content .content-block.note { border-left-color: var(--warning); background: #fff8db; }
.post-content .content-block.tip { border-left-color: var(--success); background: #ecfdf5; }
.post-content .content-block.warning { border-left-color: var(--danger); background: #fee2e2; }

/* Output block specific code style */
.post-content .content-block.output pre {
  background: #f3f4f6;
  color: #0f172a;
  border: 1px solid var(--border-color);
  border-left: 4px solid #64748b;
  box-shadow: none;
}

/* Tables and images in blog content */
.post-content figure { margin: 16px 0; }
.post-content figure.table { margin: 16px 0; }
.post-content figcaption { color: var(--text-muted); font-size: .9rem; margin-top: 6px; }
.post-content img { max-width: 100%; height: auto; display: block; margin: 10px auto; }
.post-content table { width: 100%; border-collapse: collapse; margin: 12px 0; display: block; overflow-x: auto; max-width: 100%; }
.post-content th, .post-content td { border: 1px solid var(--border-color); padding: 8px; text-align: left; word-break: break-word; overflow-wrap: anywhere; }
.post-content thead th { background: var(--light-bg); }

/* Table wrapper helper for long tables */
.post-content .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; scrollbar-width: thin; scrollbar-color: var(--primary-color) rgba(0,0,0,0.08); padding-bottom: 8px; margin: 12px 0; border-radius: 8px; position: relative; }
.post-content .table-responsive::-webkit-scrollbar { height: 10px; }
.post-content .table-responsive::-webkit-scrollbar-track { background: #eef2f7; border-radius: 10px; }
.post-content .table-responsive::-webkit-scrollbar-thumb { background: #c7d2fe; border-radius: 10px; }
.post-content .table-responsive:hover::-webkit-scrollbar-thumb { background: #a5b4fc; }
.post-content .table-responsive::before { content: ""; position: absolute; left: 0; top: 0; bottom: 10px; width: 24px; background: linear-gradient(to right, rgba(255,255,255,0.95), rgba(255,255,255,0)); pointer-events: none; border-top-left-radius: 8px; border-bottom-left-radius: 8px; }
.post-content .table-responsive::after { content: ""; position: absolute; right: 0; top: 0; bottom: 10px; width: 24px; background: linear-gradient(to left, rgba(255,255,255,0.95), rgba(255,255,255,0)); pointer-events: none; border-top-right-radius: 8px; border-bottom-right-radius: 8px; }

/* Make table headers sticky within the scrollable table wrapper to avoid overlap */
.post-content .table-responsive thead th {
  position: sticky;
  top: 0;
  background: var(--light-bg);
  z-index: 2;
}

/* Ensure wide tables layout gracefully */
.post-content table { table-layout: auto; }

/* Table of contents (auto-generated in blog-topic) */
.post-toc {
  border: 1px dashed var(--card-border);
  border-radius: 10px;
  background: #fafafa;
  padding: 12px 14px;
  margin: 10px 0 16px 0;
}
.post-toc h5 { margin: 0 0 8px 0; font-size: .95rem; color: var(--text-light); }
.post-toc ul { list-style: none; padding: 0; margin: 0; }
.post-toc li { margin: 6px 0; }
.post-toc a { color: var(--primary-color); text-decoration: none; }
.post-toc a:hover { text-decoration: underline; }

/* Post actions wrap nicely on small widths to prevent overflow */
.post-actions { flex-wrap: wrap; }

/* Reading controls */
.reading-controls {
  position: sticky;
  top: 80px;
  z-index: 5;
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  background: var(--white);
  box-shadow: 0 4px 16px rgba(2,6,23,0.06);
  margin: 16px 0;
}
.reading-controls .btn { padding: 8px 10px; }

/* Copy button for code blocks */
.copy-btn {
  position: absolute;
  top: 8px; right: 8px;
  font-size: .85rem;
  background: #eef2ff;
  color: #1e3a8a;
  border: 1px solid #c7d2fe;
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
}
.copy-btn:hover { background: #e0e7ff; }

.alert { padding: 12px 14px; border-radius: 8px; background: #eef2ff; color: #1e3a8a; display: flex; align-items: center; gap: 8px; }
.alert-error { background: #fee2e2; color: #7f1d1d; }
.alert-info { background: #eff6ff; color: #1e40af; }

@media (max-width: 768px) {
  .hero { padding: 28px 0; }
  .post-card { padding: 16px; }
  .post-content pre { font-size: .92rem; }
  /* Prevent page-level horizontal scrollbars on small screens */
  .post-content pre code { white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; }
  .post-content th, .post-content td { word-break: break-word; overflow-wrap: anywhere; }
  .post-content table { display: block; overflow-x: auto; }
}

/* Subtle scrollbars inside code blocks */
.post-content pre::-webkit-scrollbar { height: 10px; width: 10px; }
.post-content pre::-webkit-scrollbar-track { background: #eef2f7; border-radius: 10px; }
.post-content pre::-webkit-scrollbar-thumb { background: #c7d2fe; border-radius: 10px; }
.post-content pre:hover::-webkit-scrollbar-thumb { background: #a5b4fc; }

/* Dark theme readability overrides */
[data-theme="dark"] .post-content pre {
  background: #0b1322;
  color: #e2e8f0;
  border-color: var(--border-color);
}
[data-theme="dark"] .post-content .content-block.output {
  background: rgba(15,23,42,0.55);
}
[data-theme="dark"] .post-content .content-block.output pre {
  background: #0b1322;
  color: #e2e8f0;
  border-color: var(--border-color);
}
[data-theme="dark"] .post-content .content-block.output pre code {
  color: inherit;
}
[data-theme="dark"] .post-content .table-responsive::-webkit-scrollbar-track { background: #1f2937; }
[data-theme="dark"] .post-content .table-responsive::-webkit-scrollbar-thumb { background: #64748b; }
[data-theme="dark"] .post-content .table-responsive:hover::-webkit-scrollbar-thumb { background: #94a3b8; }
[data-theme="dark"] .post-content .table-responsive::before { background: linear-gradient(to right, rgba(15,23,42,0.9), rgba(15,23,42,0)); }
[data-theme="dark"] .post-content .table-responsive::after { background: linear-gradient(to left, rgba(15,23,42,0.9), rgba(15,23,42,0)); }
[data-theme="dark"] .post-toc {
  background: rgba(15,23,42,0.8);
}
[data-theme="dark"] .copy-btn {
  background: #1f2937;
  color: #e5e7eb;
  border-color: #374151;
}
[data-theme="dark"] .reading-controls {
  background: var(--white);
  border-color: var(--card-border);
  box-shadow: 0 8px 28px rgba(0,0,0,0.35);
}
