/* ==========================================================================
   Stylish English — Dedicated Lesson View (css/lesson-view.css)
   When a lesson is opened, <body> gets .lesson-view and the lesson card
   (.lesson-card.rm-open) is shown alone, full width, with a sticky
   "Back to Curriculum" bar on top and Previous / Next buttons at the bottom.
   The bar and buttons are created by app.js (lvEnsureNav) and are hidden
   in the normal curriculum grid.
   Load order: app.min.css -> tokens.css -> voice-ui.css -> curriculum.css -> lesson-view.css
   ========================================================================== */

/* The injected bars never show inside the grid */
.lv-topbar,
.lv-bottom { display: none; }

/* 1. Hide the whole curriculum screen except the open lesson --------------- */
body.lesson-view #dashboard-header-bar,
body.lesson-view #se-breadcrumb-bar,
body.lesson-view #hero-welcome,
body.lesson-view #hero-banner,
body.lesson-view .month-view-title,
body.lesson-view .rm-zone-header,
body.lesson-view .rm-boss-gate,
body.lesson-view .rm-gate-content,
body.lesson-view .rm-path .lesson-card:not(.rm-open),
body.lesson-view .site-footer,
body.lesson-view .landing-footer { display: none !important; }

/* app.min.css gives <body> overflow-x:hidden, which turns <body> into its own
   (non-scrolling) scroll container and breaks position:sticky. <html> already
   clips horizontal overflow, so the lesson view can safely release <body>. */
body.lesson-view { overflow: visible !important; margin: 0; }

/* 2. Single-column, centered reading layout --------------------------------- */
body.lesson-view .main-container {
  max-width: 920px;
  margin-inline: auto;
  padding: 0 0 40px;
}
/* the grid screen reserves space for the fixed header bar — not needed here */
body.lesson-view .view-platform { padding-top: 0 !important; }

body.lesson-view .rm-months-grid,
body.lesson-view .rm-zone.zone-active .rm-zone-body,
body.lesson-view .rm-path {
  display: block !important;
  padding: 0 !important;
  margin: 0 !important;
  gap: 0;
}

/* 3. The lesson itself: full width, no tile chrome --------------------------- */
body.lesson-view .rm-path .lesson-card.rm-open {
  display: block;
  /* overflow must be visible, otherwise the sticky top bar cannot stick
     (app.min.css sets .lesson-card { overflow: hidden !important }) */
  overflow: visible !important;
  animation: none;
  transform: none;
  border: 0;
  border-radius: 0;
  background: var(--vf-bg);
  min-height: 100vh;
  min-height: 100dvh;
  /* keeps the last buttons clear of the floating voice bar */
  padding-bottom: 110px;
}
body.lesson-view .lesson-card.rm-open .rm-toggle { display: none !important; }
body.lesson-view .lesson-card.rm-open .lesson-header {
  cursor: default;
  padding: 26px 20px 22px;
  border-radius: 0;
}
body.lesson-view .lesson-card.rm-open .lesson-title-ar {
  font-family: var(--vf-font-head);
  font-size: clamp(22px, 5vw, 28px);
  line-height: 1.5;
}
body.lesson-view .lesson-card.rm-open .lesson-goal {
  font-size: 15px;
  line-height: 1.8;
}
body.lesson-view .lesson-card.rm-open .lesson-body {
  padding: 22px 16px 10px;
  animation: none;
}
@media (min-width: 720px) {
  body.lesson-view .rm-path .lesson-card.rm-open {
    margin-top: 12px !important;
    border: 1px solid var(--vf-border);
    border-radius: var(--vf-radius-lg);
    min-height: calc(100vh - 24px);
  }
  body.lesson-view .lesson-card.rm-open .lesson-header { padding: 30px 32px 24px; }
  body.lesson-view .lesson-card.rm-open .lesson-body { padding: 26px 32px 10px; }
}

/* 4. Top bar: Back to Curriculum + position -------------------------------- */
body.lesson-view .lesson-card.rm-open .lv-topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 10px 16px 0;
  background: rgba(11, 11, 20, 0.96);
  border-bottom: 1px solid var(--vf-border);
}
@media (min-width: 720px) {
  body.lesson-view .lesson-card.rm-open .lv-topbar {
    padding: 12px 24px 0;
    border-radius: var(--vf-radius-lg) var(--vf-radius-lg) 0 0;
  }
}
.lv-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1.5px solid var(--vf-border-strong);
  background: rgba(139, 92, 246, 0.16);
  color: #f1e5ff;
  font-family: var(--vf-font-ar);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--vf-fast) var(--vf-ease), transform var(--vf-fast) var(--vf-ease);
}
.lv-back:hover { background: rgba(139, 92, 246, 0.3); }
.lv-back:active { transform: scale(0.97); }
.lv-arrow { font-size: 18px; line-height: 1; }
.lv-count {
  margin-inline-start: auto;
  color: var(--vf-text-2);
  font-family: var(--vf-font-ar);
  font-size: 14px;
  font-weight: 700;
}
.lv-track {
  flex-basis: 100%;
  height: 3px;
  margin: 2px -16px 0;
  background: rgba(255, 255, 255, 0.06);
}
.lv-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--vf-accent), var(--vf-listen));
  border-radius: 0 3px 3px 0;
}

/* 5. Bottom bar: Previous / Next lesson ------------------------------------- */
body.lesson-view .lesson-card.rm-open .lv-bottom {
  display: flex;
  align-items: stretch;
  gap: 12px;
  padding: 20px 16px 0;
}
@media (min-width: 720px) {
  body.lesson-view .lesson-card.rm-open .lv-bottom { padding: 24px 32px 0; }
}
.lv-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 56px;
  padding: 10px 18px;
  border-radius: 16px;
  font-family: var(--vf-font-ar);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.4;
  cursor: pointer;
  transition: transform var(--vf-fast) var(--vf-ease), background var(--vf-fast) var(--vf-ease);
}
.lv-btn:active { transform: scale(0.98); }
.lv-prev {
  flex: 0 0 auto;
  border: 1.5px solid var(--vf-border-strong);
  background: transparent;
  color: var(--vf-text-2);
}
.lv-prev:hover { background: rgba(255, 255, 255, 0.05); }
.lv-next {
  flex: 1 1 auto;
  justify-content: space-between;
  border: 0;
  background: linear-gradient(135deg, #7c3aed, var(--vf-accent));
  color: #fff;
  box-shadow: 0 10px 28px -12px var(--vf-accent-glow);
}
.lv-next:hover { background: linear-gradient(135deg, #8b5cf6, #a78bfa); }
.lv-next-text { display: flex; flex-direction: column; align-items: flex-start; text-align: start; min-width: 0; }
.lv-next-text small {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 500;
  opacity: 0.85;
}
.lv-finish { justify-content: center; }
.lv-finish .lv-next-text { align-items: center; text-align: center; }
@media (max-width: 420px) {
  body.lesson-view .lesson-card.rm-open .lv-bottom { flex-direction: column-reverse; }
  .lv-prev { justify-content: center; min-height: 48px; }
}

/* 6. Clear focus ring for keyboard users ------------------------------------ */
.lv-back:focus-visible,
.lv-btn:focus-visible { outline: 2px solid var(--vf-listen); outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  .lv-back, .lv-btn { transition: none; }
}
