/* 
  tech-blog.css - Styling specific to technical blogs 
  Supports light and dark themes.
*/

:root {
  /* Default Light Theme Variables */
  --tech-bg: #ffffff;
  --tech-text: #1a1a1a;
  --tech-heading: #111111;
  --tech-accent: #f59e0b; /* primary color */
  --tech-muted: #6b7280;
  --tech-border: rgba(0, 0, 0, 0.1);
  --tech-code-bg: #1e1e2e;
  --tech-code-text: #cdd6f4;
  --tech-code-header-bg: #151521;
  --tech-callout-bg: #fffbeb;
  --tech-callout-border: #f59e0b;
  --tech-callout-text: #333333;
  --tech-toc-bg: rgba(255, 255, 255, 0.75);
  --tech-card-bg: #ffffff;
  --tech-card-hover: #f9fafb;
}

[data-theme="dark"] {
  /* Dark Theme Variables */
  --tech-bg: #121212;
  --tech-text: #e0e0e0;
  --tech-heading: #ffffff;
  --tech-accent: #fbb117; /* slightly brighter for dark mode */
  --tech-muted: #9ca3af;
  --tech-border: rgba(255, 255, 255, 0.1);
  --tech-code-bg: #1e1e2e; /* keep code block same */
  --tech-code-text: #cdd6f4;
  --tech-code-header-bg: #151521;
  --tech-callout-bg: rgba(245, 158, 11, 0.1);
  --tech-callout-border: #fbb117;
  --tech-callout-text: #e0e0e0;
  --tech-toc-bg: rgba(18, 18, 18, 0.85);
  --tech-card-bg: #1e1e1e;
  --tech-card-hover: #2d2d2d;
}

body.tech-blog-body {
  background-color: var(--tech-bg);
  color: var(--tech-text);
  transition: background-color 0.3s ease, color 0.3s ease;
  font-family: 'Geist', sans-serif;
  line-height: 1.8;
  margin: 0;
  scroll-padding-top: 100px;
}

/* Desktop pane scrolling model (similar to tutorials pages) */
@media (min-width: 901px) {
  body.tech-blog-body {
    height: 100vh !important;
    overflow: hidden !important;
    padding-top: 80px;
  }

  .tech-blog-body .blog-container {
    height: calc(100vh - 80px);
    overflow: hidden;
    padding-top: 1.25rem;
    padding-bottom: 1.25rem;
  }

  .tech-blog-body .blog-sidebar {
    position: static;
    top: auto;
    max-height: 100%;
    overflow-y: auto;
  }

  .tech-blog-body .blog-main {
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0.5rem;
  }
}

html,
body {
  overflow-y: scroll !important;
  overflow-x: hidden !important;
  height: auto !important;
  max-width: 100%;
}

/* Guard against shared scripts/styles accidentally disabling page scroll */
@media (max-width: 900px) {
  html.tech-blog-body,
  body.tech-blog-body,
  body.tech-blog-body.menu-open,
  body.tech-blog-body.modal-open,
  body.tech-blog-body.focus-mode {
    overflow-y: auto !important;
    height: auto !important;
    min-height: 100%;
  }
}

/* Theme Toggle Button */
.theme-toggle-btn {
  background: transparent;
  border: 1px solid var(--tech-border);
  color: var(--tech-text);
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-family: 'Geist', sans-serif;
  margin-bottom: 1.5rem;
  transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
  background: var(--tech-border);
}

/* Base structural overrides for tech blog */
.tech-blog-body .blog-container,
.tech-blog-body .blog-main,
.tech-blog-body .blog-sidebar,
.tech-blog-body .blog-author-image,
.tech-blog-body .related-articles,
.tech-blog-body .article-card {
  background-color: var(--tech-bg);
  color: var(--tech-text);
}

/* Headings */
.tech-blog-body .blog-content h1,
.tech-blog-body .blog-content h2,
.tech-blog-body .blog-content h3,
.tech-blog-body .blog-content h4,
.tech-blog-body .blog-content h5,
.tech-blog-body .blog-content h6 {
  color: var(--tech-heading);
  text-align: left; /* Left align for technical docs */
  font-family: 'Geist', sans-serif;
  font-weight: 700;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  scroll-margin-top: 120px;
}

.tech-blog-body .blog-content h2 { font-size: 1.75rem; border-bottom: 1px solid var(--tech-border); padding-bottom: 0.5rem; }
.tech-blog-body .blog-content h3 { font-size: 1.5rem; }
.tech-blog-body .blog-content h4 { font-size: 1.25rem; }

.tech-blog-body .blog-content {
  max-width: 72ch;
}

.tech-blog-body .blog-content p {
  margin-bottom: 1rem;
}

.tech-blog-body .blog-content ul,
.tech-blog-body .blog-content ol {
  margin: 0.75rem 0 1.25rem 1.25rem;
  padding-left: 0.5rem;
}

.tech-blog-body .blog-content li {
  margin-bottom: 0.5rem;
}

.tech-blog-body .blog-content img {
  margin: 1.25rem auto;
}

/* Callouts / Info Boxes */
.tech-callout {
  background: var(--tech-callout-bg);
  border-left: 4px solid var(--tech-callout-border);
  color: var(--tech-callout-text);
  padding: 1rem 1.25rem;
  border-radius: 0 8px 8px 0;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}

.tech-callout strong {
  color: var(--tech-callout-border);
}

/* Tags / Badges */
.blog-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.blog-tags span {
  background-color: rgba(245, 158, 11, 0.1);
  color: var(--tech-accent);
  padding: 0.2rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

/* Code Blocks */
.code-container {
  position: relative;
  background: var(--tech-code-bg);
  border-radius: 12px;
  margin: 2rem 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.25rem;
  background: var(--tech-code-header-bg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.code-lang {
  font-family: 'Geist', monospace;
  font-size: 0.8rem;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--tech-accent);
  letter-spacing: 0.05em;
}

.copy-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #a6adc8;
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-family: 'Geist', sans-serif;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}

.copy-btn.copied {
  background: rgba(46, 213, 115, 0.15);
  color: #2ed573;
  border-color: #2ed573;
}

.code-container pre {
  margin: 0;
  padding: 1.25rem;
  background: transparent;
  overflow-x: auto;
}

.code-container pre code {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.875rem;
  color: var(--tech-code-text);
  line-height: 1.6;
}

/* Table of Contents */
.tech-blog-body .blog-toc {
  background: var(--tech-toc-bg) !important;
  border: 1px solid var(--tech-border) !important;
  color: var(--tech-text);
}

.tech-blog-body .blog-toc h4 {
  color: var(--tech-heading);
}

.tech-blog-body .blog-toc a {
  color: var(--tech-muted);
}

.tech-blog-body .blog-toc li.active > a {
  color: var(--tech-text) !important;
  background: rgba(245, 158, 11, 0.14);
  font-weight: 700;
}

/* Sidebar author */
.tech-blog-body .blog-author-image h3 {
  color: var(--tech-heading);
}
.tech-blog-body .blog-author-image p {
  color: var(--tech-muted);
}

/* Related articles */
.tech-blog-body .related-articles h2 {
  color: var(--tech-heading);
}

.tech-blog-body .article-card {
  background-color: var(--tech-card-bg) !important;
  border: 1px solid var(--tech-border);
}

.tech-blog-body .article-card:hover {
  background-color: var(--tech-card-hover) !important;
}

.tech-blog-body .article-info h3 {
  color: var(--tech-heading);
}

.tech-blog-body .article-meta {
  color: var(--tech-muted);
}

/* Layout from original BlogDetails */
.blog-container {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 3rem 2.5rem;
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start;
  gap: 4rem;
}

.blog-sidebar {
  flex: 0 0 320px;
  align-self: flex-start;
  position: -webkit-sticky;
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 96px);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--tech-accent) transparent;
}

.blog-sidebar::-webkit-scrollbar { width: 4px; }
.blog-sidebar::-webkit-scrollbar-track { background: transparent; }
.blog-sidebar::-webkit-scrollbar-thumb { background: var(--tech-accent); border-radius: 10px; }

.blog-main {
  flex: 1;
  max-width: 820px;
  margin: 0 auto;
}

.blog-header {
  margin-bottom: 2rem;
  text-align: left; /* Left align header for tech blog */
}

.blog-title {
  font-size: 2.35rem;
  color: var(--tech-heading);
  margin-bottom: 0.5rem;
  line-height: 1.25;
}

.blog-meta {
  color: var(--tech-muted);
  font-size: 0.95rem;
  margin-top: 0.5rem;
}

.blog-hero-image {
  width: 100%;
  height: auto;
  border-radius: 16px;
  margin: 2rem 0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.blog-card-img {
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
    border-radius: 10px;
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1rem auto;
}

/* Colab Button link styling */
.colab-button-wrapper {
  display: flex;
  justify-content: center;
  margin: 2.5rem 0;
}

.colab-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #ffffff !important;
  font-weight: 600;
  padding: 0.85rem 1.75rem;
  border-radius: 50px;
  text-decoration: none;
  box-shadow: 0 4px 15px rgba(245, 158, 11, 0.3);
  transition: all 0.3s ease;
  border: none;
  font-size: 1rem;
}

.colab-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
  background: linear-gradient(135deg, #fbbf24 0%, #ea580c 100%);
}

.colab-btn img {
  height: 20px;
  width: auto;
  box-shadow: none !important;
  border-radius: 0 !important;
}

/* Footer / Back link */
.blog-footer {
  margin-top: 4rem;
  text-align: center;
}

.back-link {
  text-decoration: none;
  color: var(--tech-accent);
  font-weight: 600;
  transition: color 0.2s ease-in-out;
}

.back-link:hover {
  color: #ffa074;
}

.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.article-card {
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  transition: transform 0.2s ease-in-out;
}

.article-card:hover {
  transform: translateY(-5px);
}

.article-image {
  width: 100%;
  height: 120px;
  object-fit: cover;
}

.article-info {
  padding: 1rem;
}

.article-info h3 {
  font-size: 1rem;
  margin: 0 0 0.5rem;
}

.article-meta {
  font-size: 0.75rem;
  margin: 0;
}

/* TOC structures from shared */
.blog-toc {
  padding: 0.7rem 0.65rem !important;
  border-radius: 12px !important;
  position: relative;
  margin-top: 0.6rem;
  max-height: calc(100vh - 245px);
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--tech-toc-bg) !important;
  border: 1px solid var(--tech-border) !important;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08);
}

.blog-toc h4 {
  position: sticky;
  top: 0;
  z-index: 2;
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.7rem;
  padding: 0.25rem 0.45rem 0.5rem 0.45rem;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--tech-toc-bg);
  border-bottom: 1px solid var(--tech-border);
}

.blog-toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
  position: relative;
}

.blog-toc ul ul {
  padding-left: 1rem;
  display: none;
}

.blog-toc ul ul.expanded {
  display: block;
}

.blog-toc > ul::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 6px;
  width: 1px;
  background: rgba(107, 114, 128, 0.35);
  border-radius: 2px;
}

.blog-toc li {
  margin-bottom: 0;
  border-left: none;
  margin-left: 0;
  transition: all 0.2s ease;
  position: relative;
}

.blog-toc li::before {
  content: '';
  position: absolute;
  top: 13px;
  left: 6px;
  width: 8px;
  height: 2px;
  background: var(--tech-border);
  border-radius: 0 2px 2px 0;
  z-index: -1;
}

.blog-toc > ul > li::before {
  display: none;
}

.blog-toc a {
  display: flex;
  align-items: center;
  padding: 0.45rem 0.55rem 0.45rem 0.9rem;
  text-decoration: none;
  font-size: 0.8rem;
  transition: all 0.2s ease-in-out;
  line-height: 1.35;
  border-radius: 8px;
  color: var(--tech-muted);
  font-weight: 500;
}

.blog-toc li.active {
  border-left: none !important;
  background: transparent !important;
}

.blog-toc li.active > a {
  font-weight: 700;
  border-radius: 6px;
  background: rgba(245, 158, 11, 0.12);
  color: var(--tech-heading);
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.2);
}

.blog-toc li.active > a::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 16px;
  background: var(--tech-accent);
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(245, 158, 11, 0.2);
}

.blog-toc > ul > li.active > a::after {
  left: 5px;
}

.toc-toggle {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--tech-muted);
  transition: transform 0.2s;
}

.toc-toggle.open {
  transform: rotate(90deg);
}

/* Sidebar structure */
.blog-author-image {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "img name"
    "img date";
  align-items: center;
  text-align: left !important;
  column-gap: 1rem;
  margin-bottom: 1.1rem;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  border-bottom: 1px solid var(--tech-border);
  padding-bottom: 1.5rem !important;
}

.blog-author-image img {
  grid-area: img;
  width: 65px;
  height: 65px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 0;
}

.blog-author-image h3 {
  grid-area: name;
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  align-self: end;
}

.blog-author-image p {
  grid-area: date;
  margin: 0;
  font-size: 0.9rem;
  text-align: left !important;
  font-weight: 500;
  align-self: start;
}

[data-theme="dark"] .blog-toc {
  background: var(--tech-toc-bg) !important;
  border: 1px solid rgba(255, 255, 255, 0.16) !important;
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .blog-toc h4 {
  background: var(--tech-toc-bg);
}

/* Mobile TOC */
.mobile-toc-wrapper {
  margin-bottom: 1rem;
}

.mobile-toc-toggle {
  width: 100%;
  border: 1px solid var(--tech-border);
  color: var(--tech-text);
  background: var(--tech-card-bg);
  border-radius: 10px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.mobile-toc-toggle:hover,
.mobile-toc-toggle:focus {
  color: var(--tech-heading);
  background: var(--tech-card-hover);
}

.mobile-toc-card {
  border: 1px solid var(--tech-border);
  border-radius: 12px;
  padding: 0.8rem;
  background: var(--tech-toc-bg);
}

.mobile-toc-card h4 {
  margin: 0 0 0.6rem 0;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--tech-heading);
}

.mobile-toc-list a {
  color: var(--tech-text) !important;
  font-size: 0.92rem;
}

/* Responsive */
@media (max-width: 900px) {
  .blog-container {
    flex-direction: column;
    padding: 1.5rem 1.5rem;
  }
  .blog-sidebar {
    display: none !important;
  }
  .blog-main {
    max-width: 100%;
    margin: 0 auto;
  }
}

/* Specific body override for navbar text */
.tech-blog-body .navbar .nav-link {
  color: #fff; /* kept dark navbar for consistency */
}
