/*
 * v2.6.3 Tutor LMS compact lesson width override.
 * Loaded late after Tutor LMS styles so lesson content uses the available width.
 */
body.cp-math-lms-theme {
  --cp-tutor-edge-gap: 6px;
  --cp-tutor-mobile-edge-gap: 4px;
}

/* Main Tutor LMS shells: remove desktop max-width and big side padding. */
body.cp-math-lms-theme .tutor-container,
body.cp-math-lms-theme .tutor-wrap,
body.cp-math-lms-theme .tutor-dashboard,
body.cp-math-lms-theme .tutor-course-details-page,
body.cp-math-lms-theme .tutor-course-archive-results-wrap,
body.cp-math-lms-theme .tutor-course-single-content-wrapper,
body.cp-math-lms-theme .tutor-single-course-content-wrapper,
body.cp-math-lms-theme .tutor-course-single-content,
body.cp-math-lms-theme .tutor-course-topic-single-wrapper,
body.cp-math-lms-theme .tutor-course-spotlight-wrapper,
body.cp-math-lms-theme .tutor-lesson-wrapper,
body.cp-math-lms-theme .tutor-quiz-wrapper,
body.cp-math-lms-theme .tutor-single-page-content,
body.cp-math-lms-theme .tutor-frontend-dashboard-maincontent,
body.cp-math-lms-theme .tutor-dashboard-content {
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* Actual lesson body: keep only a tiny edge gap. */
body.cp-math-lms-theme .tutor-course-single-content,
body.cp-math-lms-theme .tutor-course-topic-single-body,
body.cp-math-lms-theme .tutor-lesson-content,
body.cp-math-lms-theme .tutor-lesson-content-area,
body.cp-math-lms-theme .tutor-single-lesson-wrap,
body.cp-math-lms-theme .tutor-course-details-content,
body.cp-math-lms-theme .tutor-quiz-wrapper,
body.cp-math-lms-theme .tutor-single-page-top-bar,
body.cp-math-lms-theme .tutor-course-topic-single-header {
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding-left: var(--cp-tutor-edge-gap) !important;
  padding-right: var(--cp-tutor-edge-gap) !important;
}

/* WordPress/Gutenberg constrained layout often creates the blank left/right space. */
body.cp-math-lms-theme .tutor-lesson-content .entry-content,
body.cp-math-lms-theme .tutor-course-topic-single-body .entry-content,
body.cp-math-lms-theme .tutor-lesson-content .wp-block-post-content,
body.cp-math-lms-theme .tutor-course-topic-single-body .wp-block-post-content,
body.cp-math-lms-theme .tutor-lesson-content .wp-block-group,
body.cp-math-lms-theme .tutor-course-topic-single-body .wp-block-group,
body.cp-math-lms-theme .tutor-lesson-content .wp-block-group__inner-container,
body.cp-math-lms-theme .tutor-course-topic-single-body .wp-block-group__inner-container,
body.cp-math-lms-theme .tutor-lesson-content .is-layout-constrained,
body.cp-math-lms-theme .tutor-course-topic-single-body .is-layout-constrained,
body.cp-math-lms-theme .tutor-lesson-content .is-layout-flow,
body.cp-math-lms-theme .tutor-course-topic-single-body .is-layout-flow {
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

body.cp-math-lms-theme .tutor-lesson-content .is-layout-constrained > :where(:not(.alignleft):not(.alignright):not(.alignfull)),
body.cp-math-lms-theme .tutor-course-topic-single-body .is-layout-constrained > :where(:not(.alignleft):not(.alignright):not(.alignfull)),
body.cp-math-lms-theme .tutor-lesson-content .is-layout-flow > :where(:not(.alignleft):not(.alignright):not(.alignfull)),
body.cp-math-lms-theme .tutor-course-topic-single-body .is-layout-flow > :where(:not(.alignleft):not(.alignright):not(.alignfull)) {
  width: 100% !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* Custom HTML lesson pages/cards: let the user's Blogger-style HTML occupy the lesson width. */
body.cp-math-lms-theme .tutor-lesson-content .content-card,
body.cp-math-lms-theme .tutor-course-topic-single-body .content-card,
body.cp-math-lms-theme .tutor-lesson-content .math-exercise-card,
body.cp-math-lms-theme .tutor-course-topic-single-body .math-exercise-card,
body.cp-math-lms-theme .tutor-lesson-content .cp-lex-output,
body.cp-math-lms-theme .tutor-course-topic-single-body .cp-lex-output,
body.cp-math-lms-theme .tutor-lesson-content .paper,
body.cp-math-lms-theme .tutor-course-topic-single-body .paper,
body.cp-math-lms-theme .tutor-lesson-content .exam-paper,
body.cp-math-lms-theme .tutor-course-topic-single-body .exam-paper,
body.cp-math-lms-theme .tutor-lesson-content .worksheet,
body.cp-math-lms-theme .tutor-course-topic-single-body .worksheet,
body.cp-math-lms-theme .tutor-lesson-content .worksheet-page,
body.cp-math-lms-theme .tutor-course-topic-single-body .worksheet-page,
body.cp-math-lms-theme .tutor-lesson-content .question-paper,
body.cp-math-lms-theme .tutor-course-topic-single-body .question-paper,
body.cp-math-lms-theme .tutor-lesson-content .lesson-page,
body.cp-math-lms-theme .tutor-course-topic-single-body .lesson-page,
body.cp-math-lms-theme .tutor-lesson-content .latex-page,
body.cp-math-lms-theme .tutor-course-topic-single-body .latex-page,
body.cp-math-lms-theme .tutor-lesson-content .math-page,
body.cp-math-lms-theme .tutor-course-topic-single-body .math-page {
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* Tables, SVGs, and KaTeX should never force the whole mobile page wider. */
body.cp-math-lms-theme .tutor-lesson-content table,
body.cp-math-lms-theme .tutor-course-topic-single-body table,
body.cp-math-lms-theme .tutor-lesson-content svg,
body.cp-math-lms-theme .tutor-course-topic-single-body svg,
body.cp-math-lms-theme .tutor-lesson-content img,
body.cp-math-lms-theme .tutor-course-topic-single-body img,
body.cp-math-lms-theme .tutor-lesson-content .katex-display,
body.cp-math-lms-theme .tutor-course-topic-single-body .katex-display {
  max-width: 100% !important;
}

body.cp-math-lms-theme .tutor-lesson-content .katex-display,
body.cp-math-lms-theme .tutor-course-topic-single-body .katex-display,
body.cp-math-lms-theme .tutor-lesson-content .cp-lex-display,
body.cp-math-lms-theme .tutor-course-topic-single-body .cp-lex-display {
  overflow-x: auto !important;
  overflow-y: hidden !important;
}

@media (max-width: 782px) {
  body.cp-math-lms-theme .tutor-container,
  body.cp-math-lms-theme .tutor-wrap,
  body.cp-math-lms-theme .tutor-course-single-content-wrapper,
  body.cp-math-lms-theme .tutor-course-single-content,
  body.cp-math-lms-theme .tutor-course-topic-single-body,
  body.cp-math-lms-theme .tutor-lesson-content,
  body.cp-math-lms-theme .tutor-lesson-content-area,
  body.cp-math-lms-theme .tutor-single-lesson-wrap,
  body.cp-math-lms-theme .tutor-single-page-content,
  body.cp-math-lms-theme .tutor-single-page-top-bar,
  body.cp-math-lms-theme .tutor-course-topic-single-header {
    padding-left: var(--cp-tutor-mobile-edge-gap) !important;
    padding-right: var(--cp-tutor-mobile-edge-gap) !important;
  }

  body.cp-math-lms-theme .tutor-course-single-sidebar-wrapper,
  body.cp-math-lms-theme .tutor-sidebar,
  body.cp-math-lms-theme .tutor-course-single-sidebar {
    width: 100% !important;
    max-width: none !important;
  }
}

/*
 * v2.6.3 fixed 1cm lesson edge gap.
 * The previous build made Tutor wrappers full width, but many pasted Blogger/HTML
 * documents still carry their own centered max-width. In lesson pages, force those
 * custom document wrappers to use the available area, leaving the same small gap
 * on left/right as the top gap.
 */
body.cp-math-lms-theme {
  --cp-tutor-page-gap: 1cm;
  /* Keep very narrow phones usable while desktop/tablet gets the requested 1cm edge. */
  --cp-tutor-mobile-page-gap: clamp(8px, 2.7vw, 1cm);
}

/* Lesson viewport: keep one consistent edge gap instead of a centered desktop column. */
body.cp-math-lms-theme .tutor-course-spotlight-wrapper,
body.cp-math-lms-theme .tutor-course-single-content-wrapper,
body.cp-math-lms-theme .tutor-course-single-content,
body.cp-math-lms-theme .tutor-course-topic-single-wrapper,
body.cp-math-lms-theme .tutor-course-topic-single-body,
body.cp-math-lms-theme .tutor-lesson-wrapper,
body.cp-math-lms-theme .tutor-single-lesson-wrap,
body.cp-math-lms-theme .tutor-single-page-content,
body.cp-math-lms-theme .tutor-lesson-content-area,
body.cp-math-lms-theme .tutor-lesson-content {
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: none !important;
}

body.cp-math-lms-theme .tutor-course-topic-single-body,
body.cp-math-lms-theme .tutor-lesson-content-area,
body.cp-math-lms-theme .tutor-lesson-content,
body.cp-math-lms-theme .tutor-single-page-content {
  padding-left: var(--cp-tutor-page-gap) !important;
  padding-right: var(--cp-tutor-page-gap) !important;
}

/* Remove the centered max-width from the first wrappers produced by custom HTML. */
body.cp-math-lms-theme .tutor-lesson-content > *,
body.cp-math-lms-theme .tutor-course-topic-single-body > *,
body.cp-math-lms-theme .tutor-lesson-content .entry-content > *,
body.cp-math-lms-theme .tutor-course-topic-single-body .entry-content > *,
body.cp-math-lms-theme .tutor-lesson-content .wp-block-html > *,
body.cp-math-lms-theme .tutor-course-topic-single-body .wp-block-html > * {
  box-sizing: border-box !important;
  max-width: none !important;
}

/* Common custom document/container class names from pasted HTML editors. */
body.cp-math-lms-theme .tutor-lesson-content :is(.container, .wrapper, .wrap, .main, .content, .page, .sheet, .card, .document, .paper, .paper-wrapper, .paper-container, .exam, .exam-paper, .exam-page, .exam-container, .worksheet, .worksheet-page, .worksheet-container, .question-paper, .question-page, .question-container, .lesson-page, .latex-page, .math-page, .math-sheet, .content-card, .math-exercise-card, .cp-lex-output),
body.cp-math-lms-theme .tutor-course-topic-single-body :is(.container, .wrapper, .wrap, .main, .content, .page, .sheet, .card, .document, .paper, .paper-wrapper, .paper-container, .exam, .exam-paper, .exam-page, .exam-container, .worksheet, .worksheet-page, .worksheet-container, .question-paper, .question-page, .question-container, .lesson-page, .latex-page, .math-page, .math-sheet, .content-card, .math-exercise-card, .cp-lex-output) {
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* Inline max-width from pasted HTML is the usual reason for the huge red-arrow space. */
body.cp-math-lms-theme .tutor-lesson-content > [style*="max-width"],
body.cp-math-lms-theme .tutor-course-topic-single-body > [style*="max-width"],
body.cp-math-lms-theme .tutor-lesson-content .entry-content > [style*="max-width"],
body.cp-math-lms-theme .tutor-course-topic-single-body .entry-content > [style*="max-width"],
body.cp-math-lms-theme .tutor-lesson-content .wp-block-html > [style*="max-width"],
body.cp-math-lms-theme .tutor-course-topic-single-body .wp-block-html > [style*="max-width"] {
  width: 100% !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* Keep the actual paper/card border close to the edges, but still readable. */
body.cp-math-lms-theme .tutor-lesson-content :is(.content-card, .math-exercise-card, .paper, .exam-paper, .worksheet, .question-paper, .lesson-page, .latex-page, .math-page),
body.cp-math-lms-theme .tutor-course-topic-single-body :is(.content-card, .math-exercise-card, .paper, .exam-paper, .worksheet, .question-paper, .lesson-page, .latex-page, .math-page) {
  padding-left: clamp(12px, 2vw, 28px) !important;
  padding-right: clamp(12px, 2vw, 28px) !important;
}

@media (max-width: 782px) {
  body.cp-math-lms-theme .tutor-course-topic-single-body,
  body.cp-math-lms-theme .tutor-lesson-content-area,
  body.cp-math-lms-theme .tutor-lesson-content,
  body.cp-math-lms-theme .tutor-single-page-content {
    padding-left: var(--cp-tutor-mobile-page-gap) !important;
    padding-right: var(--cp-tutor-mobile-page-gap) !important;
  }

  body.cp-math-lms-theme .tutor-lesson-content :is(.content-card, .math-exercise-card, .paper, .exam-paper, .worksheet, .question-paper, .lesson-page, .latex-page, .math-page),
  body.cp-math-lms-theme .tutor-course-topic-single-body :is(.content-card, .math-exercise-card, .paper, .exam-paper, .worksheet, .question-paper, .lesson-page, .latex-page, .math-page) {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }
}


/* v2.6.3: requested fixed left/right lesson margin.
   The paper/card should sit about 1cm from both viewport edges on desktop/tablet. */
body.cp-math-lms-theme .tutor-course-topic-single-body > .tutor-container,
body.cp-math-lms-theme .tutor-lesson-content > .tutor-container,
body.cp-math-lms-theme .tutor-course-topic-single-body > .container,
body.cp-math-lms-theme .tutor-lesson-content > .container {
  width: 100% !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

@media (min-width: 783px) {
  body.cp-math-lms-theme .tutor-course-topic-single-body,
  body.cp-math-lms-theme .tutor-lesson-content-area,
  body.cp-math-lms-theme .tutor-lesson-content,
  body.cp-math-lms-theme .tutor-single-page-content {
    padding-left: 1cm !important;
    padding-right: 1cm !important;
  }
}

/* v2.6.3 final override: prevent nested Tutor wrappers from adding the 1cm more than once. */
@media (min-width: 783px) {
  body.cp-math-lms-theme .tutor-course-single-content,
  body.cp-math-lms-theme .tutor-course-topic-single-wrapper,
  body.cp-math-lms-theme .tutor-course-topic-single-body,
  body.cp-math-lms-theme .tutor-lesson-wrapper,
  body.cp-math-lms-theme .tutor-single-lesson-wrap,
  body.cp-math-lms-theme .tutor-single-page-content,
  body.cp-math-lms-theme .tutor-lesson-content-area {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  body.cp-math-lms-theme .tutor-lesson-content,
  body.cp-math-lms-theme .tutor-course-topic-single-body > .entry-content,
  body.cp-math-lms-theme .tutor-course-topic-single-body > .wp-block-post-content,
  body.cp-math-lms-theme .tutor-course-topic-single-body > .wp-block-html {
    padding-left: 1cm !important;
    padding-right: 1cm !important;
  }
}

@media (max-width: 782px) {
  body.cp-math-lms-theme .tutor-course-single-content,
  body.cp-math-lms-theme .tutor-course-topic-single-wrapper,
  body.cp-math-lms-theme .tutor-course-topic-single-body,
  body.cp-math-lms-theme .tutor-lesson-wrapper,
  body.cp-math-lms-theme .tutor-single-lesson-wrap,
  body.cp-math-lms-theme .tutor-single-page-content,
  body.cp-math-lms-theme .tutor-lesson-content-area {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }

  body.cp-math-lms-theme .tutor-lesson-content,
  body.cp-math-lms-theme .tutor-course-topic-single-body > .entry-content,
  body.cp-math-lms-theme .tutor-course-topic-single-body > .wp-block-post-content,
  body.cp-math-lms-theme .tutor-course-topic-single-body > .wp-block-html {
    padding-left: var(--cp-tutor-mobile-page-gap) !important;
    padding-right: var(--cp-tutor-mobile-page-gap) !important;
  }
}
