/* ════════════════════════════════════════════════════════════════
   IMMERSIVE LEARNING MODE — Dark, distraction-free
   Only used inside the full-screen course player
   ════════════════════════════════════════════════════════════════ */

.immersive {
  background: #1D1D1F;
  color: #FFFFFF;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-family);
}

.immersive-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.immersive-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #FFFFFF;
}

.immersive-progress-text {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
}

.immersive-exit {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.4);
  text-decoration: none;
  padding: 6px 14px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  transition: all 0.2s;
}
.immersive-exit:hover {
  color: #FFFFFF;
  border-color: rgba(255,255,255,0.3);
}

.immersive-body {
  flex: 1;
  display: flex;
  max-width: min(95%, 56rem);
  margin: 0 auto;
  width: 100%;
  padding: 40px 24px;
  padding-right: calc(clamp(200px, 20vw, 280px) + 24px);
  overflow-y: auto;
}
.sidebar-collapsed .immersive-body {
  padding-right: 24px;
}

/* Full-width mode for activity/read segments with rich HTML */
.immersive-body.full-width {
  max-width: none;
  margin: 0;
  padding: 20px;
  padding-right: calc(clamp(200px, 20vw, 280px) + 20px);
}
.sidebar-collapsed .immersive-body.full-width {
  padding-right: 20px;
}

/* Override design system containers inside immersive full-width */
.immersive-body.full-width .tsf-container,
.immersive-body.full-width .tsf-container-narrow {
  max-width: 100%;
}

/* Reading page — offset from left, not centered */
.immersive-body.full-width .tsf-reading-content {
  max-width: 100%;
  margin-left: 5%;
  margin-right: 5%;
}

/* Let activity game content use full width */
.immersive-body.full-width .game-header,
.immersive-body.full-width .game-area,
.immersive-body.full-width .stage-container {
  max-width: 100%;
  width: 100%;
}

/* Override body-like styles when injected into immersive view */
.segment-activity {
  width: 100%;
  display: flex;
  flex-direction: column;
}

/* ── Segment Content ─────────────────────────────────────────── */
.segment-content {
  flex: 1;
}

/* Activity segments render their own layout */
.segment-activity {
  width: 100%;
}

.segment-type-badge {
  display: inline-block;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #E2670C;
  margin-bottom: 12px;
}

.segment-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #FFFFFF;
  margin-bottom: 20px;
}

.segment-text {
  font-size: 1rem;
  line-height: 1.8;
  color: rgba(255,255,255,0.7);
}

.segment-text strong { color: #FFFFFF; }
.segment-text a { color: #E2670C; }

/* ── Video Player Container ──────────────────────────────────── */
.video-container {
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 20px;
}

/* ── Immersive Progress Bar ──────────────────────────────────── */
.immersive-progress {
  background: rgba(255,255,255,0.08);
  height: 3px;
  width: 100%;
}

.immersive-progress-fill {
  background: #E2670C;
  height: 100%;
  transition: width 0.4s ease;
}

/* ── Segment Navigation ──────────────────────────────────────── */
.immersive-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 24px;
  border-top: 1px solid rgba(255,255,255,0.06);
  position: sticky;
  bottom: 0;
  background: #1D1D1F;
  z-index: 10;
}

.immersive-nav .btn-primary {
  background: #E2670C;
  color: #FFFFFF;
}

.immersive-nav .btn-ghost {
  background: transparent;
  color: rgba(255,255,255,0.6);
  border: 1px solid rgba(255,255,255,0.15);
}
.immersive-nav .btn-ghost:hover {
  color: #FFFFFF;
  border-color: rgba(255,255,255,0.3);
}

/* ── Sidebar (segment list) ──────────────────────────────────── */
/* ── Sidebar Toggle Button ───────────────────────────────────── */
.sidebar-toggle {
  position: fixed;
  right: clamp(200px, 20vw, 280px);
  top: 50%;
  transform: translateY(-50%);
  width: 1.5rem;
  height: 3rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-right: none;
  border-radius: 6px 0 0 6px;
  color: rgba(255,255,255,0.4);
  font-size: 1rem;
  cursor: pointer;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.1); color: #FFFFFF; }
.sidebar-collapsed .sidebar-toggle { right: 0; }
.sidebar-collapsed .sidebar-toggle::after { content: '›'; }
.sidebar-collapsed .immersive-sidebar { display: none; }

/* ── Sidebar ────────────────────────────────────────────────── */
.immersive-sidebar {
  width: clamp(200px, 20vw, 280px);
  flex-shrink: 0;
  border-left: 1px solid rgba(255,255,255,0.06);
  padding: 12px;
  overflow-y: auto;
  position: fixed;
  right: 0;
  top: 50px;
  bottom: 50px;
  z-index: 15;
  background: #1D1D1F;
  transition: all 0.3s;
}

/* ── Collapsible Chapter Headers ────────────────────────────── */
.sidebar-module-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 6px;
  cursor: pointer;
  border-radius: 6px;
  margin-top: 8px;
  transition: background 0.15s;
}
.sidebar-module-header:first-child { margin-top: 0; }
.sidebar-module-header:hover { background: rgba(255,255,255,0.04); }

.sidebar-module-arrow {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.3);
  transition: transform 0.2s;
  width: 12px;
}
.sidebar-module-header.expanded .sidebar-module-arrow {
  transform: rotate(90deg);
}

.sidebar-module-title {
  font-size: 0.6875rem;
  font-weight: 600;
  color: rgba(255,255,255,0.3);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: 0;
}
.sidebar-module-header.expanded .sidebar-module-title {
  color: rgba(255,255,255,0.6);
}

.sidebar-module-segments {
  display: none;
  padding-left: 18px;
}
.sidebar-module-segments.expanded {
  display: block;
}

.sidebar-segment {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 0.8125rem;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 2px;
}

.sidebar-segment:hover { background: rgba(255,255,255,0.04); }
.sidebar-segment.active { background: rgba(10,132,255,0.12); color: #FFFFFF; }
.sidebar-segment.completed { color: rgba(255,255,255,0.3); }

.sidebar-segment-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.75rem;
  position: relative;
}

.sidebar-segment.completed {
  opacity: 0.7;
}
.sidebar-segment.completed .sidebar-segment-icon {
  position: relative;
}
.completed-check {
  position: absolute;
  bottom: -2px;
  right: -4px;
  font-size: 0.5rem;
  background: #34C759;
  color: #FFFFFF;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.sidebar-segment.active .sidebar-segment-icon {
  background: rgba(10, 132, 255, 0.2);
  color: #E2670C;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .immersive-sidebar { display: none; }
  .sidebar-toggle { display: none; }
  .immersive-body { padding: 24px 16px !important; }
  .immersive-body.full-width { padding: 12px !important; }
  .segment-title { font-size: 1.25rem; }
}
