/* assets/css/article.css — Editorial Typography & Technical Article Styling */
.article-header {
  padding: 4rem 0 2.5rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 3rem;
}

.article-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.article-breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}

.article-title {
  font-size: clamp(2.2rem, 4vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 1.25rem;
}

.article-lead {
  font-size: 1.2rem;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 820px;
  margin-bottom: 1.75rem;
}

.article-author-bar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.author-pill {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.author-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
}

.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 3.5rem;
  align-items: start;
}

.article-content {
  font-size: 1.05rem;
  line-height: 1.75;
  color: #e2e8f0;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

[data-theme="light"] .article-content {
  color: #334155;
}

.article-content h2 {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 2.75rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  scroll-margin-top: 5.5rem;
}

.article-content h3 {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
  color: var(--text-main);
  scroll-margin-top: 5.5rem;
}

.article-content p {
  margin-bottom: 1.5rem;
}

.article-content ul,
.article-content ol {
  margin: 1rem 0 1.5rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.article-content li {
  padding-left: 0.25rem;
}

.article-content strong {
  color: #fff;
}

[data-theme="light"] .article-content strong {
  color: #0f172a;
}

/* Dual-Tier Educational Callouts */
.callout {
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin: 2rem 0;
  border: 1px solid;
}

.callout-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 0.75rem;
}

.callout-novice {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.3);
  color: #fef3c7;
}

[data-theme="light"] .callout-novice {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.3);
  color: #78350f;
}

.callout-novice .callout-header {
  color: var(--accent-amber);
}

.callout-deepdive {
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(56, 189, 248, 0.3);
  color: #e0f2fe;
}

[data-theme="light"] .callout-deepdive {
  background: rgba(2, 132, 199, 0.08);
  border-color: rgba(2, 132, 199, 0.3);
  color: #0c4a6e;
}

.callout-deepdive .callout-header {
  color: var(--accent);
}

.callout-warning {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fee2e2;
}

[data-theme="light"] .callout-warning {
  color: #7f1d1d;
}

.callout-warning .callout-header {
  color: #ef4444;
}

/* Article Container with Optimal Typographic Column Width */
.article-container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 1.5rem;
  width: 100%;
}

/* Reading Progress Indicator */
#reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-emerald));
  z-index: 9999;
  transition: width 0.1s ease-out;
}

/* Executive Summary & Key Takeaways Card */
.executive-summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-emerald);
  border-radius: var(--radius-md);
  padding: 1.5rem 1.75rem;
  margin: 2rem 0 2.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.executive-summary-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent-emerald);
  margin-bottom: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.executive-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
}

.summary-item-label {
  font-size: 0.78rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 0.3rem;
}

.summary-item-text {
  font-size: 0.94rem;
  line-height: 1.5;
  color: var(--text-primary);
}

/* Step-by-Step Numerical Walkthrough Box */
.step-walkthrough {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem 1.5rem;
  margin: 1.75rem 0;
}

[data-theme="light"] .step-walkthrough {
  background: #f8fafc;
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.step-walkthrough-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Math & Equation Blocks with KaTeX Integration & Fallback */
.math-block {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent);
  padding: 1.25rem 1.75rem;
  border-radius: var(--radius-md);
  margin: 2rem 0;
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  text-align: center;
  font-size: 1.12rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  color: #bae6fd;
}

.katex-display {
  margin: 0.5rem 0 !important;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  padding: 0.25rem 0;
}

[data-theme="light"] .math-block {
  background: #ffffff;
  color: #0369a1;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

/* Code Blocks & Real IDE Syntax Highlighting */
.code-wrapper {
  background: #0b1120;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin: 2rem 0;
  overflow: hidden;
  max-width: 100%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] .code-wrapper {
  background: #f8fafc;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 1.2rem;
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid var(--border-color);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-dim);
}

[data-theme="light"] .code-header {
  background: #f1f5f9;
  border-bottom-color: rgba(0, 0, 0, 0.08);
  color: #475569;
}

.copy-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 0.25rem 0.65rem;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font-mono);
}

[data-theme="light"] .copy-btn {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.12);
  color: #475569;
}

[data-theme="light"] .copy-btn:hover {
  background: #f8fafc;
  color: #0284c7;
  border-color: #0284c7;
}

.copy-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.1);
}

pre {
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.65;
}

pre code {
  color: #e2e8f0;
}

[data-theme="light"] pre code {
  color: #1e293b;
}

/* Syntax Highlighting Tokens */
.hl-k { color: #c084fc; font-weight: 600; }   /* keywords: def, return, import, class */
.hl-s { color: #34d399; }                     /* strings: "..." */
.hl-f { color: #38bdf8; font-weight: 600; }   /* functions/methods */
.hl-c { color: #64748b; font-style: italic; } /* comments */
.hl-n { color: #fbbf24; }                     /* numbers */
.hl-t { color: #f472b6; }                     /* types: int, float, list, dict */
.hl-v { color: #e2e8f0; }                     /* variables */

[data-theme="light"] .hl-k { color: #7c3aed; }
[data-theme="light"] .hl-s { color: #059669; }
[data-theme="light"] .hl-f { color: #0284c7; }
[data-theme="light"] .hl-c { color: #94a3b8; }
[data-theme="light"] .hl-n { color: #d97706; }
[data-theme="light"] .hl-t { color: #db2777; }
[data-theme="light"] .hl-v { color: #334155; }

code {
  font-family: var(--font-mono);
}

p code, li code {
  background: rgba(255, 255, 255, 0.08);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.86em;
  color: var(--accent);
}

[data-theme="light"] p code, [data-theme="light"] li code {
  background: rgba(0, 0, 0, 0.06);
  color: var(--accent);
}

/* Tables in Articles */
.table-responsive {
  overflow-x: auto;
  margin: 2rem 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.article-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  text-align: left;
}

.article-table th {
  background: var(--bg-secondary);
  padding: 0.85rem 1.2rem;
  font-weight: 700;
  border-bottom: 1px solid var(--border-color);
}

.article-table td {
  padding: 0.85rem 1.2rem;
  border-bottom: 1px solid var(--border-color);
}

.article-table tr:last-child td {
  border-bottom: none;
}

/* Sidebar TOC */
.sidebar-toc {
  position: sticky;
  top: 5.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
}

.toc-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 1rem;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  font-size: 0.88rem;
}

.toc-list a {
  color: var(--text-muted);
  text-decoration: none;
  transition: var(--transition);
  display: block;
  line-height: 1.4;
}

.toc-list a:hover {
  color: var(--accent);
  padding-left: 4px;
}

/* Article Navigation footer */
.article-nav-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
}

.nav-article-card {
  padding: 1.25rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  transition: var(--transition);
  background: var(--bg-card);
  display: flex;
  flex-direction: column;
}

.nav-article-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.nav-article-label {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
  margin-bottom: 0.35rem;
}

.nav-article-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-main);
}

@media (max-width: 992px) {
  .article-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar-toc {
    display: none;
  }
  .article-nav-footer {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .article-container {
    padding: 0 1rem;
  }
  .article-header {
    padding: 2.25rem 0 1.5rem;
    margin-bottom: 2rem;
  }
  .article-title {
    font-size: clamp(1.7rem, 6vw, 2.4rem);
    line-height: 1.25;
  }
  .article-lead {
    font-size: 1.05rem;
    line-height: 1.55;
    margin-bottom: 1.25rem;
  }
  .article-author-bar {
    gap: 0.75rem;
    font-size: 0.8rem;
  }
  .executive-summary-card {
    padding: 1.25rem;
    margin: 1.5rem 0 2rem;
  }
  .executive-summary-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  .article-content {
    font-size: 0.98rem;
    line-height: 1.7;
  }
  .article-content h2 {
    font-size: 1.45rem;
    margin: 2rem 0 0.85rem;
  }
  .article-content h3 {
    font-size: 1.18rem;
    margin: 1.5rem 0 0.65rem;
  }
  .math-block {
    padding: 1rem 0.85rem;
    font-size: 0.95rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  pre {
    padding: 1rem 0.85rem;
    font-size: 0.82rem;
    -webkit-overflow-scrolling: touch;
  }
  .code-header {
    padding: 0.5rem 0.85rem;
  }
  .callout {
    padding: 1.15rem;
    margin: 1.5rem 0;
  }
  .article-diagram-wrapper {
    margin: 1.75rem 0;
  }
  .article-diagram-caption {
    font-size: 0.78rem;
    padding: 0.6rem 0.85rem;
  }
  .step-walkthrough {
    padding: 1rem 0.85rem;
  }
}

/* Article Hero Banner & Media Containers */
.article-hero-banner {
  margin: 1.5rem 0 2.5rem;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  background: var(--bg-card);
}

.article-hero-banner img {
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 480px;
  object-fit: cover;
  display: block;
}

.article-diagram-wrapper {
  margin: 2.25rem 0;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  background: #0b1120;
}

[data-theme="light"] .article-diagram-wrapper {
  background: #ffffff;
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.article-diagram-wrapper img {
  width: 100%;
  max-width: 100%;
  height: auto;
  display: block;
}

.article-diagram-caption {
  padding: 0.75rem 1.25rem;
  font-size: 0.84rem;
  color: var(--text-secondary);
  background: rgba(15, 23, 42, 0.75);
  border-top: 1px solid var(--border-color);
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

[data-theme="light"] .article-diagram-caption {
  background: #f8fafc;
  color: #475569;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .article-hero-banner {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .sidebar-toc {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .executive-summary-card {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .nav-article-card {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .nav-article-card:hover {
  background: #f8fafc;
}

pre code {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.55;
}

/* Interactive Playground Widget Styles */
.widget-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  margin: 2.25rem 0;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

[data-theme="light"] .widget-box {
  background: #ffffff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.widget-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.widget-desc {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.calc-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
  background: var(--bg-card-subtle);
  padding: 1.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

[data-theme="light"] .calc-controls {
  background: #f8fafc;
}

.control-group label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.control-group input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  text-align: left;
}

.results-table th {
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-weight: 600;
  padding: 0.75rem 1rem;
  border-bottom: 2px solid var(--border-color);
}

.results-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.results-table tr:hover td {
  background: var(--bg-card-hover);
}
