/* The old CourseViewer's inline styles (frontend/src/components/CourseViewer.tsx) as classes, plus the new
   components (<bl-code>). Loaded after assets/legacy/*.css (old base, buttons, tables, CourseViewer, Quiz)
   and the course's own CSS. Values are copied from the old code; comments name the old element. */

[hidden] { display: none !important; }
body { background-color: #f5f5f5; }

/* Top bar (old TopNav height 60px; the viewer is calc(100vh - 60px)) */
.bl-top { height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 1.5rem; background: #fff;
  border-bottom: 1px solid #e5e7eb; position: sticky; top: 0; z-index: 1000; }
.bl-brand { display: inline-flex; align-items: center; gap: 8px; color: #1e293b; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.bl-brand b { color: #667eea; }
/* account menu (filled by pages.js): links and the Create account button look the same as in the top menu of
   the home and site pages (TopNav.css .top-nav-links a, topnav-extra.css) */
.bl-nav { margin-left: auto; display: flex; align-items: center; gap: 1.5rem; }
.bl-nav > a { font-family: inherit; font-size: .95rem; font-weight: 500; line-height: normal; color: #475569; padding: .5rem 1rem;
  border-radius: 6px; background: none; text-decoration: none; white-space: nowrap; }
.bl-brand { white-space: nowrap; }
.bl-nav > a:hover { color: #667eea; background: rgba(102, 126, 234, .08); }
.bl-nav > a.bl-nav-cta { background: #667eea; color: #fff; font-weight: 600; }
.bl-nav > a.bl-nav-cta:hover { background: #5568d3; color: #fff; }
.bl-nav button { color: #475569; font: inherit; background: none; border: 0; cursor: pointer; }
@media (max-width: 1024px) { .bl-nav { gap: 1rem; } .bl-nav > a { font-size: .9rem; } }
@media (max-width: 600px) { .bl-top { padding: 0 1rem; } .bl-nav { gap: .25rem; } .bl-nav > a { padding: .45rem .7rem; font-size: .88rem; }
  .bl-nav a[href="/pricing/"] { display: none; } }
.bl-review-banner { background: #fff7e6; color: #8a5a00; text-align: center; font-size: 13px; padding: 4px 16px; border-bottom: 1px solid #f3dfb5; }
body:has(.bl-review-banner) .course-viewer { height: calc(100vh - 60px - 27px); }

/* Sidebar: "← Back to Courses" button */
.cv-back { display: block; width: 100%; padding: 0.75rem; background-color: #667eea; color: #fff; border: none;
  border-radius: 6px; margin-bottom: 1rem; font-size: 0.9rem; font-weight: 600; text-align: center; text-decoration: none; }
.cv-back:hover { background-color: #5568d3; }
/* course title (h3) */
.cv-course-title { margin-bottom: 0.75rem; color: #495057; font-size: 1rem; font-weight: 600; }
/* progress box */
.cv-progress { font-size: 0.85rem; color: #6b7280; margin-bottom: 0.75rem; padding: 0.5rem; background-color: #f8f9fa; border-radius: 4px; }
.cv-progress-row { display: flex; gap: 1.5rem; align-items: center; flex-wrap: wrap; }
.cv-progress-score { color: #667eea; font-weight: 500; }
/* search */
.cv-search { margin-top: 1.5rem; margin-bottom: 1.5rem; }
.cv-search-row { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.cv-search-box { flex: 1; position: relative; }
.cv-search-box input { width: 100%; padding: 0.5rem; border: 1px solid #dee2e6; border-radius: 4px; font-size: 0.85rem; outline: none; }
.cv-search-box input.has-clear { padding-right: 2rem; }
.cv-search-clear { position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%); background: none; border: none;
  cursor: pointer; padding: 0.25rem; display: flex; align-items: center; justify-content: center; color: #6c757d;
  font-size: 1.2rem; line-height: 1; width: 20px; height: 20px; }
.cv-search-clear:hover { color: #495057; }
.cv-search-btn { padding: 0.5rem 1rem; background-color: #667eea; color: #fff; border: none; border-radius: 4px; cursor: pointer;
  font-size: 0.85rem; font-weight: 600; white-space: nowrap; }
/* "📚 Course Overview" row and topic rows */
.cv-overview-wrap { margin-top: 1.5rem; margin-bottom: 1.5rem; }
.cv-row { padding: 0.75rem; border-radius: 6px; background-color: #fff; border: 1px solid #dee2e6; transition: all 0.2s;
  display: flex; align-items: center; gap: 0.5rem; }
.cv-overview { margin-bottom: 0.5rem; }
.cv-row.cv-selected { background-color: #667eea; border-color: #667eea; }
.cv-row-title { flex: 1; cursor: pointer; font-weight: 600; font-size: 0.9rem; color: #495057; text-decoration: none; transition: color 0.2s; }
.cv-row.cv-selected .cv-row-title, .cv-row.cv-selected .cv-toggle { color: #fff; }
.cv-toggle { font-size: 0.85rem; cursor: pointer; padding: 0.25rem; display: flex; align-items: center; justify-content: center;
  min-width: 1.2rem; user-select: none; color: #495057; transition: color 0.2s; line-height: 1; }
.cv-toggle-spacer { width: 1rem; display: inline-block; }
.cv-topics { margin-top: 1.5rem; }
.cv-topic { margin-bottom: 0.5rem; }
.cv-tick { color: #10b981; font-size: 1rem; }
.cv-row.cv-selected .cv-tick { color: #fff; }
/* lessons under a topic (only when expanded) */
.cv-lessons { display: none; margin-left: 1.5rem; margin-top: 0.5rem; }
.cv-topic.cv-expanded .cv-lessons { display: block; }
.cv-lesson, .cv-quiz { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.75rem; border-radius: 4px; cursor: pointer;
  background-color: transparent; color: #6c757d; border: 1px solid transparent; font-size: 0.85rem; transition: all 0.2s;
  text-decoration: none; margin-bottom: 0.25rem; }
.cv-lesson-title { flex: 1; }
.cv-lesson .cv-tick, .cv-quiz .cv-tick { font-size: 0.9rem; margin-left: 0.5rem; }
.cv-lesson.cv-selected { background-color: #e0e7ff; color: #667eea; border-color: #667eea; }
/* "📝 Final Quiz" row: last item of the topic's list */
.cv-quiz { font-weight: 600; }
.cv-quiz-icon { font-size: 0.9rem; }
.cv-quiz.cv-selected { background-color: #fff3cd; color: #856404; border-color: #ffc107; }
.cv-search-hidden { display: none !important; }

/* Main content: page header (title + description) */
.cv-page-head { border-bottom: 1px solid #dee2e6; background-color: #fff; }
.cv-page-head h1 { margin: 0; font-size: 1.25rem; color: #1f2937; font-weight: 600; line-height: 1.4; }
.cv-page-head p { color: #6b7280; font-size: 0.875rem; line-height: 1.4; margin-top: 0.25rem; margin-bottom: 0; }

/* Course Roadmap Tracker (overview page) */
.cv-roadmap { margin-top: 3rem; max-width: 100%; }
.cv-roadmap h2 { font-size: 1.5rem; font-weight: 600; color: #1f2937; margin-bottom: 1.5rem; }
.cv-roadmap-box { margin-bottom: 2rem; overflow-x: auto; border: 1px solid #d1d5db; border-radius: 12px; background-color: #fff;
  box-shadow: 0 1px 3px 0 rgba(0,0,0,.1), 0 1px 2px 0 rgba(0,0,0,.06); }
.cv-roadmap table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.cv-roadmap thead tr { background-color: #f8fafc; border-bottom: 2px solid #e2e8f0; }
.cv-roadmap th { padding: 1rem 1.25rem; text-align: left; font-weight: 700; color: #1e293b; border-right: 1px solid #e2e8f0;
  font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.05em; }
.cv-roadmap th.cv-rm-view { text-align: center; min-width: 80px; }
.cv-roadmap th.cv-rm-title-h { min-width: 250px; }
.cv-roadmap th.cv-rm-q, .cv-roadmap th.cv-rm-score { text-align: center; min-width: 120px; }
.cv-roadmap th:last-child { border-right: none; }
.cv-roadmap td { padding: 1rem 1.25rem; border-right: 1px solid #e2e8f0; vertical-align: middle; }
.cv-roadmap td:last-child { border-right: none; }
.cv-rm-view { text-align: center; }
.cv-rm-view-btn { display: inline-block; padding: 0.35rem 0.75rem; font-size: 0.8rem; font-weight: 600; border: 1px solid #e2e8f0;
  border-radius: 6px; background-color: #667eea; color: #fff; text-decoration: none; }
.cv-rm-title a { color: #4f46e5; text-decoration: none; transition: color 0.15s ease; }
.cv-rm-title a:hover { color: #4338ca; text-decoration: underline; }
.cv-rm-q, .cv-rm-score { text-align: center; color: #475569; font-weight: 500; }
/* topic rows are highlighted (owner, 3 Nov 2026); final quiz rows stay plain */
.cv-rm-topic { border-bottom: 1px solid #e2e8f0; background-color: #fef3c7; }
.cv-rm-topic:hover { background-color: #fde68a; }
.cv-rm-topic .cv-rm-index { font-weight: 600; color: #92400e; font-size: 0.95rem; }
.cv-rm-topic .cv-rm-title a { font-weight: 600; font-size: 1rem; }
.cv-rm-topic .cv-rm-q, .cv-rm-topic .cv-rm-score { font-size: 0.95rem; }
.cv-rm-lesson { border-bottom: 1px solid #f1f5f9; background-color: #f8fafc; }
.cv-rm-lesson.cv-rm-last { border-bottom-color: #e2e8f0; }
.cv-rm-lesson:hover { background-color: #f1f5f9; }
.cv-rm-lesson td { padding: 0.875rem 1.25rem; }
.cv-rm-lesson .cv-rm-index { padding-left: 2.5rem; color: #64748b; font-size: 0.9rem; font-weight: 500; }
.cv-rm-lesson .cv-rm-title a { font-size: 0.95rem; }
.cv-rm-lesson .cv-rm-q, .cv-rm-lesson .cv-rm-score { font-size: 0.9rem; }
.cv-rm-quiz { border-bottom: 1px solid #e2e8f0; background-color: #fff; }
.cv-rm-quiz:hover { background-color: #f8fafc; }
.cv-rm-quiz .cv-rm-index { font-weight: 600; color: #1e293b; font-size: 0.95rem; }
.cv-rm-quiz .cv-rm-title a { font-weight: 600; font-size: 1rem; }
.cv-rm-total { border-top: 3px solid #1e293b; background-color: #f1f5f9; font-weight: 700; }
.cv-rm-total td { padding: 1.25rem; border-right: 1px solid #cbd5e1; color: #0f172a; font-size: 1rem; }

/* Bottom navigation: "← Previous" | "Course Roadmap" | "Next →" */
.cv-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 3rem; gap: 1rem; }
.course-content > .cv-nav { border-top: 1px solid #e5e7eb; }
.cv-nav-center { flex: 1; display: flex; justify-content: center; }
.cv-nav-btn { padding: 0.75rem 1.5rem; background-color: #667eea; color: #fff; border: none; border-radius: 8px; cursor: pointer;
  font-size: 0.95rem; font-weight: 600; transition: all 0.2s; display: flex; align-items: center; gap: 0.5rem; text-decoration: none; }
.cv-nav-btn:hover { background-color: #5568d3; }
.cv-nav-btn.cv-disabled { background-color: #e5e7eb; color: #9ca3af; cursor: not-allowed; }
.cv-roadmap-btn { background-color: #475569; }
.cv-roadmap-btn:hover { background-color: #334155; }

/* Mobile: floating sidebar tab (old inline styles) */
.mobile-sidebar-toggle-floating { left: 0; top: calc(60px + 1rem); width: 36px; height: 36px; background-color: #667eea; color: #fff;
  border: none; border-top-right-radius: 8px; border-bottom-right-radius: 8px; cursor: pointer; align-items: center;
  justify-content: center; box-shadow: 2px 2px 8px rgba(0,0,0,.2); transition: left 0.3s ease-in-out, background-color 0.2s; padding: 0; }
.mobile-sidebar-toggle-floating svg { transition: transform 0.3s ease-in-out; }
.mobile-sidebar-toggle-floating[aria-expanded="true"] { left: 280px; }
.mobile-sidebar-toggle-floating[aria-expanded="true"] svg { transform: rotate(180deg); }
@media (max-width: 768px) {
  .course-sidebar { top: 60px; height: calc(100vh - 60px); }
  .course-viewer .mobile-overlay { top: 60px; }
  .course-content { margin-top: 0 !important; }
  .cv-nav { flex-wrap: wrap; }
  .cv-nav-center { order: 3; flex-basis: 100%; }
}

/* ---- new components ---- */
/* collapsible practice steps (old React toggles, now <details>): the old .step-header styles apply to <summary> */
details.learning-step > summary { list-style: none; cursor: pointer; }
details.learning-step > summary::-webkit-details-marker { display: none; }
details.learning-step > summary::after { content: "+"; margin-left: auto; font-size: 1.4rem; line-height: 1; padding-left: 1rem; }
details.learning-step[open] > summary::after { content: "−"; }
details.learning-step > summary { display: flex; align-items: center; }
@media (prefers-reduced-motion: no-preference) {
  /* the old pages' framer-motion open effect (height/opacity, 0.3 s) */
  details.learning-step[open] > :not(summary),
  [data-bl-revealed-by]:not([hidden]),
  [data-bl-card] > [data-bl-card-content]:not([hidden]),
  [data-bl-collapses]:not([hidden]) { animation: bl-reveal .3s ease-out; }
}
@keyframes bl-reveal { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
/* code inside <pre>: the old course CSS gave every `code` a border, which drew a box around each line of
   multi-line code; inline code keeps its look */
pre code { border: 0 !important; }
/* buttons rebuilt by widgets.js */
[data-bl-card] .step-card-header { cursor: pointer; }
/* topic pages: lesson cards became links */
/* Compact cards: the card body reuses the page wrapper's class (.subtopic-content), so the wrapper's
   padding, flex gap and background are reset here; number badge beside the title. */
.subtopics-grid { gap: 0.875rem; }
a.subtopic-card { display: flex; align-items: flex-start; gap: 0.875rem; padding: 1rem 1.125rem; text-decoration: none; color: inherit; }
a.subtopic-card .subtopic-number { margin: 0.1rem 0 0; width: 1.875rem; height: 1.875rem; font-size: 0.8125rem; flex-shrink: 0; }
a.subtopic-card .subtopic-content { display: block; padding: 0 !important; margin: 0; gap: 0; max-width: none; width: auto;
  background: none; border-radius: 0; min-width: 0; }
a.subtopic-card .subtopic-content h3 { margin: 0 0 0.3rem; font-size: 1rem; line-height: 1.35; }
a.subtopic-card .subtopic-content p { font-size: 0.875rem; line-height: 1.5; }

/* <bl-code> */
bl-code { display: block; margin: 12px 0; border: 1px solid #e2e8f0; border-radius: 10px; background: #fff; overflow: hidden; }
.bl-code-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between;
  padding: 6px 8px; border-bottom: 1px solid #e2e8f0; background: #f8fafc; }
.bl-code-tabs { display: flex; gap: 4px; }
.bl-code-tabs button { font: 500 13px system-ui, sans-serif; border: 1px solid transparent; background: none; border-radius: 6px;
  padding: 4px 10px; cursor: pointer; color: #475569; }
.bl-code-tabs button[aria-selected="true"] { background: #fff; border-color: #e2e8f0; color: #1e293b; }
.bl-code-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.bl-btn { font: 500 13px system-ui, sans-serif; padding: 6px 12px; border-radius: 6px; border: 1px solid #e2e8f0; background: #fff;
  color: #1e293b; cursor: pointer; }
.bl-btn:hover:not(:disabled) { border-color: #667eea; }
.bl-btn:disabled { opacity: .55; cursor: not-allowed; }
.bl-btn-run { border-color: #15803d; color: #15803d; }
.bl-code-editor .cm-editor { font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", monospace; font-size: 14px; max-height: 520px; }
.bl-code-editor .cm-scroller { overflow: auto; }
/* AI hints (bl-code.js): button and the hint panel above the editor */
.bl-btn-hint { border-color: #c7d2fe; color: #4f46e5; }
.bl-code-hint { margin: 8px 10px; padding: 10px 14px 10px; background: linear-gradient(135deg, #eef2ff 0%, #f5f3ff 100%);
  border: 1.5px solid #a5b4fc; border-radius: 10px; box-shadow: 0 6px 18px rgba(102, 126, 234, .18); animation: bl-ask-in .18s ease-out; }
.bl-code-hint[hidden] { display: none; }
.bl-code-hint-head { display: flex; align-items: center; gap: 8px; }
.bl-code-hint-title { font: 600 13px system-ui, sans-serif; color: #4338ca; flex: 1; }
.bl-code-hint-nav { display: inline-flex; gap: 4px; }
.bl-code-hint-nav button, .bl-code-hint-close { border: 1px solid #c7d2fe; background: #fff; color: #4338ca; border-radius: 6px;
  width: 26px; height: 26px; cursor: pointer; font-size: 15px; line-height: 1; }
.bl-code-hint-nav button:disabled { opacity: .4; cursor: default; }
.bl-code-hint-body ul { margin: 8px 0 6px; padding-left: 20px; color: #1e293b; font: 14px/1.55 system-ui, sans-serif; }
.bl-code-hint-body li { margin: 3px 0; }
.bl-code-hint-body code { background: #fff; border: 1px solid #e0e7ff; border-radius: 4px; padding: 0 4px; font-size: 12.5px; }
.bl-code-hint-note { margin: 6px 0; font: 12px system-ui, sans-serif; color: #64748b; }
.bl-code-hint-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
/* input(): the popup shown when the program asks for a value (bl-code.js askInput) */
.bl-code-ask { position: relative; margin: 10px 12px 8px; padding: 12px 14px; background: #fffbeb; border: 2px solid #f59e0b;
  border-radius: 10px; box-shadow: 0 8px 24px rgba(245, 158, 11, .25); animation: bl-ask-in .18s ease-out; }
.bl-code-ask[hidden] { display: none; }
.bl-code-ask::before { content: ""; position: absolute; top: -9px; left: 22px; width: 14px; height: 14px; background: #fffbeb;
  border-left: 2px solid #f59e0b; border-top: 2px solid #f59e0b; transform: rotate(45deg); }
.bl-code-ask-head { font: 600 12px system-ui, sans-serif; color: #b45309; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.bl-code-ask-q { display: block; font: 600 14px/1.4 source-code-pro, Menlo, Monaco, Consolas, monospace; color: #1e293b;
  white-space: pre-wrap; margin-bottom: 8px; }
.bl-code-ask-row { display: flex; gap: 8px; }
.bl-code-ask-row input { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid #d97706; border-radius: 6px;
  font: 14px source-code-pro, Menlo, Monaco, Consolas, monospace; background: #fff; }
.bl-code-ask-row input:focus { outline: 3px solid rgba(245, 158, 11, .35); }
@keyframes bl-ask-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.bl-code-output { margin: 0; padding: 10px 12px; border-top: 1px solid #e2e8f0; background: #0f172a; color: #e2e8f0;
  font: 13px/1.5 source-code-pro, Menlo, Monaco, Consolas, monospace; white-space: pre-wrap; max-height: 320px; overflow: auto; }
.bl-code-output.bl-error { color: #fecaca; }
.bl-code-status { font-size: 12px; color: #475569; padding: 2px 12px 6px; min-height: 1em; }
bl-quiz { display: block; }

/* site-wide announcement (admin panel > Settings > banner) */
.bl-site-banner { background: #fef3c7; color: #92400e; text-align: center; padding: .5rem 1rem; font-size: .9rem; border-bottom: 1px solid #fde68a; }

/* Phones: the old course CSS stacks the page's padding, the lesson wrapper's and the cards' (20-32px each),
   up to 80-100px of empty space on each side. Cut to about 40% (owner's request, 3 Nov 2026): 16px page, then
   12px inside each card. Left/right only; list indents and the topic pages' lesson cards are kept. */
@media (max-width: 600px) {
  .course-content .cv-page-body .subtopic-page,
  .course-content .cv-page-body .topic-page { padding-left: 0; padding-right: 0; }
  /* DSA: .subtopic-content is the white card holding the text; DSA Fundamentals: a plain wrapper around cards */
  .course-content .cv-page-body .subtopic-page .subtopic-content { padding-left: 16px; padding-right: 16px; }
  [data-course="dsa-fundamentals"] .course-content .cv-page-body .subtopic-page .subtopic-content { padding-left: 0; padding-right: 0; }
  .course-content .cv-page-body :is(.step-header, .step-content, .step-card-header,
    .subtopic-introduction, .concept-section, .learning-steps-section, .code-example-box, .quiz-section, .quiz-header,
    .quiz-container, .quiz-question, .topic-summary, .topic-importance, .subtopics-list, pre.code-block, pre.bl-code-output) {
    padding-left: 12px !important; padding-right: 12px !important; }   /* some set it inline or with !important */
  /* DSA: these two are plain text blocks inside the white card, not cards of their own */
  [data-course="data-structures-algorithms"] .course-content .cv-page-body :is(.subtopic-introduction, .concept-section) {
    padding-left: 0 !important; padding-right: 0 !important; }
}
