/* ==========================================================================
   sections.css — Content sections, interstitials, cards, code, tabs
   ========================================================================== */

/* --- Content Section --- */
.content-section {
  padding: 2.5rem 0;
  max-width: var(--max-prose-width);
  margin: 0 auto;
}

.content-section + .content-section {
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

/* --- Chapter Interstitial --- */
.chapter-interstitial {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 2rem;
  max-width: none;
}

.chapter-interstitial .chapter-number {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-primary);
  margin-bottom: 1rem;
}

.chapter-interstitial .chapter-heading {
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 0.75rem;
  max-width: 20ch;
}

.chapter-interstitial .chapter-subtitle {
  font-size: 1.125rem;
  color: var(--text-secondary);
  max-width: 50ch;
  line-height: 1.6;
  margin-bottom: 1.25rem;
}

.chapter-interstitial .reading-time-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.04);
  padding: 0.35rem 0.75rem;
  border-radius: 100px;
}

.reading-time-badge svg,
.reading-time-badge .icon {
  width: 14px;
  height: 14px;
  opacity: 0.6;
}

/* --- "Builds on" Breadcrumb --- */
.builds-on {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
  padding: 0.3rem 0.6rem;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.builds-on a {
  color: var(--accent-primary);
  font-weight: 500;
}

.builds-on .separator {
  opacity: 0.4;
}

/* --- Section Heading with Anchor --- */
.section-heading {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-heading .anchor-link {
  opacity: 0;
  font-size: 0.875em;
  color: var(--text-secondary);
  text-decoration: none;
  transition: opacity var(--transition-fast);
  padding: 0.1em 0.25em;
}

.section-heading:hover .anchor-link {
  opacity: 1;
}

.section-heading .anchor-link:hover {
  color: var(--accent-primary);
}

/* --- Section Intro --- */
.section-intro {
  font-size: 1.125rem;
  line-height: 1.7;
  color: var(--text-primary);
  max-width: var(--max-prose-width);
  margin-bottom: 1.5rem;
}

/* --- "Build It" Section --- */
.build-it {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 1.75rem 2rem;
  margin: 2rem 0;
  max-width: none;
}

.build-it .build-it-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-highlight);
  margin-bottom: 0.75rem;
}

.build-it h3 {
  margin-top: 0;
}

/* --- "Under the Hood" Section --- */
.under-the-hood {
  border-left: 3px solid rgba(255, 255, 255, 0.08);
  padding-left: 1.5rem;
  margin: 2rem 0;
}

.under-the-hood .under-the-hood-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}

/* --- Key Takeaway Card --- */
.key-takeaway {
  border-left: 4px solid var(--accent-primary);
  background: rgba(129, 140, 248, 0.04);
  padding: 1.25rem 1.5rem;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin: 2rem 0;
  max-width: none;
}

.key-takeaway .takeaway-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-primary);
  margin-bottom: 0.5rem;
}

.key-takeaway p:last-child {
  margin-bottom: 0;
}

/* ==========================================================================
   Math / Code Tabs
   ========================================================================== */
.tab-group {
  margin: 1.5rem 0;
  max-width: var(--max-code-width);
}

.tab-buttons {
  display: flex;
  gap: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 0;
}

.tab-btn {
  padding: 0.5rem 1rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--transition-fast),
              border-color var(--transition-fast);
  margin-bottom: -1px;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

.tab-btn:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: -2px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.tab-content {
  display: none;
  min-height: 200px;
  padding-top: 1rem;
}

.tab-content.active {
  display: block;
}

/* ==========================================================================
   Code Blocks
   ========================================================================== */
.code-block {
  position: relative;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  margin: 1.25rem 0;
  max-width: var(--max-code-width);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.code-block pre {
  padding: 1.25rem 1.5rem;
  margin: 0;
  overflow-x: auto;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem 0.5rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.code-block-lang {
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  opacity: 0.6;
}

.copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.3rem 0.55rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background var(--transition-fast),
              color var(--transition-fast);
  z-index: 2;
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.copy-btn.copied {
  color: var(--accent-highlight);
}

/* When code block has a header, move copy button into header area */
.code-block-header + .copy-btn,
.code-block-header ~ pre .copy-btn {
  top: 0.4rem;
}

/* ==========================================================================
   Collapsible Details (e.g., CNNs, RNNs)
   ========================================================================== */
details {
  margin: 1.5rem 0;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  overflow: hidden;
  max-width: var(--max-prose-width);
}

details summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.25rem;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9375rem;
  color: var(--text-primary);
  list-style: none;
  transition: background var(--transition-fast);
}

details summary::-webkit-details-marker {
  display: none;
}

details summary::before {
  content: '\25B6';
  font-size: 0.6em;
  transition: transform var(--transition-base);
  flex-shrink: 0;
  color: var(--text-secondary);
}

details[open] summary::before {
  transform: rotate(90deg);
}

details summary:hover {
  background: rgba(255, 255, 255, 0.04);
}

details summary:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: -2px;
}

details .details-content {
  padding: 1rem 1.25rem 1.25rem;
}

/* ==========================================================================
   Spacing & Flow
   ========================================================================== */
.content-section > * + * {
  margin-top: 1rem;
}

.content-section > h2 + * {
  margin-top: 0.5rem;
}

.content-section > h3 + * {
  margin-top: 0.35rem;
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 1024px) {
  .content-section {
    padding: 2rem 0;
  }

  .chapter-interstitial {
    min-height: 50vh;
    padding: 3rem 1rem;
  }

  .build-it {
    padding: 1.25rem 1.25rem;
  }

  .code-block pre {
    padding: 1rem 1.25rem;
  }
}

@media (max-width: 600px) {
  .chapter-interstitial {
    min-height: 40vh;
    padding: 2rem 0.75rem;
  }

  .build-it {
    padding: 1rem;
    border-radius: var(--radius-md);
  }

  .tab-btn {
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
  }
}
