/* Classivo Coding — Lesson page typography & structure */

.lesson-layout {
  display: grid;
  grid-template-columns: minmax(0, var(--content-max-width)) 220px;
  gap: var(--space-8);
  align-items: start;
}

/* Grid items default to min-width: auto (content-based), which overrides
   the track's minmax(0, ...) and lets a wide child (e.g. a code block's
   header bar) force this column past its track — pushing straight into
   the "On this page" sidebar. min-width: 0 lets it actually shrink to the
   track's computed width, so overflowing children scroll/clip internally
   (code-block already has overflow:hidden, pre has overflow-x:auto)
   instead of blowing out the grid. */
.lesson-layout > *:first-child {
  min-width: 0;
}

@media (max-width: 1200px) {
  .lesson-layout { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}

.lesson-header {
  margin-bottom: var(--space-7);
}

.lesson-header__eyebrow {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.lesson-header h1 {
  font-size: var(--text-4xl);
  margin-bottom: var(--space-3);
}

.lesson-header__summary {
  font-size: var(--text-lg);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  max-width: 65ch;
}

.lesson-header__actions {
  display: flex;
  flex-wrap: wrap; /* phones: wrap the buttons instead of widening the page */
  gap: var(--space-2);
  margin-top: var(--space-5);
}

.lesson-section {
  margin-bottom: var(--space-8);
  scroll-margin-top: calc(var(--header-height) + var(--space-4));
}

.lesson-section h2 {
  font-size: var(--text-2xl);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-4);
}

.lesson-section h3 {
  font-size: var(--text-lg);
  margin: var(--space-5) 0 var(--space-3);
}

.lesson-section p {
  font-size: var(--text-base);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-4);
  max-width: 72ch;
}

.lesson-section ul,
.lesson-section ol {
  margin: 0 0 var(--space-4);
  padding-inline-start: var(--space-6);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

.lesson-section li { margin-bottom: var(--space-2); }
.lesson-section li::marker { color: var(--brand); }

.table-scroll {
  margin: var(--space-5) 0;
  overflow-x: auto;
}

.ref-table {
  width: 100%;
  min-width: 460px;
  border-collapse: collapse;
  font-size: var(--text-sm);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.ref-table th, .ref-table td {
  text-align: start;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.ref-table th {
  background: var(--bg-surface-alt);
  font-weight: 700;
  color: var(--text-primary);
}

.ref-table td { color: var(--text-secondary); }
.ref-table tr:last-child td { border-bottom: none; }
.ref-table code { white-space: nowrap; }

.example-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
  margin: var(--space-5) 0;
}

.example-card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  background: var(--bg-surface);
}

.example-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.example-card__video-badge {
  flex-shrink: 0;
}

.example-card__video-badge svg {
  flex-shrink: 0;
}

.example-card__label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--brand-strong);
}

.compat-row {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin: var(--space-4) 0;
}

.compat-chip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
  font-weight: 600;
}

.lesson-footer-nav {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-9);
  padding-top: var(--space-6);
  border-top: 1px solid var(--border-subtle);
}

.lesson-footer-nav__link {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  max-width: 320px;
}

.lesson-footer-nav__link.next { text-align: end; margin-inline-start: auto; }
.lesson-footer-nav__label { display: block; font-size: var(--text-xs); color: var(--text-muted); margin-bottom: 4px; }
.lesson-footer-nav__title { font-weight: 700; color: var(--text-primary); }
.lesson-footer-nav__link:hover { border-color: var(--brand-300); text-decoration: none; }

.lesson-diagram {
  margin: var(--space-6) 0;
}

.lesson-diagram__canvas {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: var(--space-5);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

.lesson-diagram__canvas svg {
  max-width: 100%;
  height: auto;
}

.lesson-diagram figcaption {
  text-align: center;
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: var(--space-2);
}

.lesson-video {
  margin: var(--space-5) 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-surface);
  /* Video titles/thumbnails are sourced content, not lesson prose — keep
     the whole embed LTR regardless of page direction, same as code. */
  direction: ltr;
}

.lesson-video__play {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: none;
  padding: 0;
  cursor: pointer;
  background: #000;
}

.lesson-video__thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.85;
}

.lesson-video__play-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff;
  background: rgba(0, 0, 0, 0.35);
  transition: background var(--duration-base) var(--ease);
}

.lesson-video__play:hover .lesson-video__play-icon { background: rgba(0, 0, 0, 0.5); }

.lesson-video__frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  border: none;
  display: block;
}

.lesson-video__meta {
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lesson-video__title { font-weight: 600; font-size: var(--text-sm); color: var(--text-primary); }
.lesson-video__channel { font-size: var(--text-xs); color: var(--text-muted); }

.related-topics {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

/* Keyboard keys in lesson prose (Developer Essentials' IDE module and any
   future course). Shortcuts are LTR sequences even inside Arabic text. */
#lesson-content kbd {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.82em;
  line-height: 1.4;
  padding: 0.05em 0.45em;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-alt);
  color: var(--text-primary);
  white-space: nowrap;
}

/* Track mode (?track=<slug>, assets/js/pages/lesson.js): the track's name,
   position and progress above the lesson. */
.track-banner {
  margin-bottom: var(--space-5);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
}
.track-banner__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2); margin-bottom: var(--space-2); font-size: var(--text-sm); }
.track-banner__label { font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; font-size: var(--text-xs); color: var(--brand-strong); }
.track-banner__title { font-weight: 600; }
.track-banner__count { margin-inline-start: auto; color: var(--text-secondary); }
.track-banner__note { margin: var(--space-2) 0 0; font-size: var(--text-sm); color: var(--text-secondary); }
