/**
 * lesson-stylish-base.css — shared layout, MCQ chrome, overlays, and extras for chapter lessons.
 * Loaded on all lesson pages after course.css (header/index.php → course_assets.php).
 * Part-grouped article nav: add lesson-articles-by-part.js in $GLOBALS['COURSE_PAGE_SCRIPTS'].
 */

main.chapter-main.stylish-chapter {
  width: 100%;
  max-width: none;
  box-sizing: border-box;
  padding-left: min(1.25rem, 4vw);
  padding-right: min(1.25rem, 4vw);
}

/* Intro follows the global .hero from header (no second in-page hero). */
.stylish-chapter .chapter-intro {
  margin-bottom: 1.75rem;
}

.stylish-chapter .stylish-teacher {
  border-left: 4px solid var(--accent, #0d9488);
  background: rgba(13, 148, 136, 0.08);
  border-radius: 8px;
  padding: 1rem 1.15rem;
}

/* Article picker */
.stylish-chapter .stylish-articles-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 0 0 2rem;
}

.stylish-chapter .article-btn.big-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 10px;
  background: var(--card, #fff);
  color: var(--text, #0f172a);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}

.stylish-chapter .article-btn.big-btn:hover {
  border-color: var(--primary, #1d4ed8);
  box-shadow: 0 4px 14px rgba(29, 78, 216, 0.12);
}

.stylish-chapter .article-btn.big-btn:focus-visible {
  outline: 2px solid var(--primary, #1d4ed8);
  outline-offset: 2px;
}

.stylish-chapter .article-btn .icon {
  font-size: 1.15rem;
  line-height: 1;
}

/* Overlays */
.stylish-chapter .overlay.stylish-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1200;
  align-items: center;
  justify-content: center;
  padding: min(1.25rem, 4vw);
  background: rgba(15, 23, 42, 0.55);
  box-sizing: border-box;
}

.stylish-chapter .overlay.stylish-overlay.is-open {
  display: flex;
}

.stylish-chapter .overlay-content {
  position: relative;
  width: min(42rem, 100%);
  max-height: min(85vh, 100%);
  overflow: auto;
  padding: 1.35rem 1.35rem 1.5rem;
  border-radius: 12px;
  background: var(--card, #fff);
  color: var(--text, #0f172a);
  border: 1px solid var(--border, #e2e8f0);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
}

.stylish-chapter .overlay-content .close-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.55rem;
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  border-radius: 8px;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  background: #f1f5f9;
  color: #334155;
}

.stylish-chapter .overlay-content .close-btn:hover {
  background: #e2e8f0;
}

.stylish-chapter .overlay-content h3 {
  margin: 0 0 0.75rem;
  padding-right: 2.5rem;
  font-family: var(--font-heading, Georgia, serif);
}

/* Auto-emphasised constitutional terms (lesson-constitution-emphasis.js) */
.stylish-chapter .constitution-emphasis {
  font-weight: 700;
  color: #0f172a;
}

/* Chapter + schedule overlay titles (markup from lesson-article-overlays.js) */
.stylish-chapter .overlay.stylish-overlay[id^="article-"] .overlay-content > h3.overlay-article-title,
.stylish-chapter .overlay.stylish-overlay[id^="article-"] .overlay-content > header > h3.overlay-article-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 0.9rem;
  line-height: 1.28;
  font-size: clamp(1.05rem, 2.5vw, 1.28rem);
}

.stylish-chapter .overlay-article-title__badge {
  flex-shrink: 0;
  min-width: 2.35rem;
  min-height: 2.35rem;
  padding: 0 0.5rem;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, sans-serif;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  color: #fff;
  background: linear-gradient(135deg, var(--primary, #1d4ed8) 0%, var(--accent, #0d9488) 100%);
  box-shadow: 0 2px 10px rgba(29, 78, 216, 0.28);
}

.stylish-chapter .overlay-article-title__badge--long {
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.15;
  white-space: normal;
  text-align: center;
  max-width: 7.75rem;
  min-height: auto;
  padding: 0.35rem 0.45rem;
}

.stylish-chapter .overlay-article-title__text {
  flex: 1 1 10rem;
  min-width: 0;
  font-weight: 700;
  font-family: var(--font-heading, Georgia, serif);
  color: var(--text, #0f172a);
  padding-bottom: 0.2rem;
  border-bottom: 3px solid rgba(13, 148, 136, 0.38);
}

.stylish-chapter h3.overlay-article-title.overlay-article-title--plain .overlay-article-title__text,
.stylish-chapter header h3.overlay-article-title.overlay-article-title--plain .overlay-article-title__text {
  border-bottom: none;
  padding-bottom: 0;
}

.stylish-chapter .overlay-content ol {
  margin: 0;
  padding-left: 1.25rem;
}

.stylish-chapter .overlay-content li + li {
  margin-top: 0.5rem;
}

/* Article overlays: main numbered items vs indented lettered sub-lists */
.stylish-chapter .overlay-content .constitution-article-content > ol {
  padding-left: 1.35rem;
}
.stylish-chapter .overlay-content > ol {
  padding-left: 1.35rem;
}

.stylish-chapter .overlay-content .constitution-article-content > ol > li {
  color: var(--text, #0f172a);
}

.stylish-chapter .overlay-content > ol > li {
  color: var(--text, #0f172a);
}

.stylish-chapter .overlay-content .constitution-article-content li > ol,
.stylish-chapter .overlay-content > ol li > ol {
  margin-top: 0.55rem;
  margin-bottom: 0;
  margin-left: 0;
  padding: 0.65rem 0.9rem 0.75rem 1.85rem;
  border-left: 3px solid var(--accent, #0d9488);
  border-radius: 0 10px 10px 0;
  background: rgba(13, 148, 136, 0.1);
  list-style-type: lower-alpha;
  color: #0f766e;
}

.stylish-chapter .overlay-content .constitution-article-content li > ol > li {
  color: #115e59;
}
.stylish-chapter .overlay-content > ol li > ol > li {
  color: #115e59;
}

.stylish-chapter .overlay-content .constitution-article-content li > ol > li + li {
  margin-top: 0.4rem;
}
.stylish-chapter .overlay-content > ol li > ol > li + li {
  margin-top: 0.4rem;
}

/* Third-level numbering keeps the green hierarchy, slightly lighter. */
.stylish-chapter .overlay-content .constitution-article-content li > ol > li > ol,
.stylish-chapter .overlay-content > ol li > ol > li > ol {
  margin-top: 0.5rem;
  margin-bottom: 0;
  margin-left: 0;
  padding: 0.55rem 0.8rem 0.65rem 1.65rem;
  border-left: 3px solid rgba(59, 130, 246, 0.65);
  border-radius: 0 9px 9px 0;
  background: rgba(59, 130, 246, 0.09);
  list-style-type: lower-roman;
  color: #1d4ed8;
}

.stylish-chapter .overlay-content .constitution-article-content li > ol > li > ol > li {
  color: #1e40af;
}
.stylish-chapter .overlay-content > ol li > ol > li > ol > li {
  color: #1e40af;
}

/* MCQ section */
.stylish-chapter .stylish-mcq {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border, #e2e8f0);
}

.stylish-chapter .stylish-mcq h2 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stylish-chapter .mcq-icon {
  font-size: 1.25rem;
}

.stylish-chapter .stylish-mcq-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stylish-chapter .stylish-mcq-block {
  padding: 1rem 1.1rem;
  border-radius: 10px;
  border: 1px solid var(--border, #e2e8f0);
  background: var(--card, #fff);
}

.stylish-chapter .mcq-block-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.stylish-chapter .mcq-block-head .mcq-q {
  margin: 0;
  flex: 1 1 auto;
}

.stylish-chapter .mcq-clue-btn {
  flex: 0 0 auto;
  margin: 0;
  padding: 0.35rem 0.65rem;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--primary, #1d4ed8);
  border-radius: 8px;
  color: var(--primary, #1d4ed8);
  background: #eff6ff;
  white-space: nowrap;
}

.stylish-chapter .mcq-clue-btn:hover:not(:disabled) {
  background: #dbeafe;
}

.stylish-chapter .mcq-clue-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.stylish-chapter .mcq-clue-body {
  margin: 0;
  font-size: 1rem;
  line-height: 1.65;
  color: var(--text, #0f172a);
}

.stylish-chapter .overlay-content--wide {
  width: min(52rem, 100%);
}

.stylish-chapter .mcq-quiz-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding: 1rem 1.1rem;
  border-radius: 10px;
  border: 1px solid var(--border, #e2e8f0);
  background: #f8fafc;
}

.stylish-chapter .mcq-progress {
  margin: 0;
  font-weight: 600;
  color: var(--text, #0f172a);
}

.stylish-chapter .mcq-results-btn {
  margin: 0;
  padding: 0.55rem 1.1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  color: #fff;
  background: var(--primary, #1d4ed8);
}

.stylish-chapter .mcq-results-btn:hover:not(:disabled) {
  filter: brightness(1.05);
}

.stylish-chapter .mcq-results-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.stylish-chapter .mcq-completed .mcq-results-btn:disabled {
  opacity: 0.35;
}

.stylish-chapter .mcq-results-body {
  margin-top: 0.75rem;
  max-height: min(70vh, 32rem);
  overflow-y: auto;
  padding-right: 0.25rem;
}

.stylish-chapter .mcq-result-summary {
  margin: 0 0 1rem;
  font-size: 1.1rem;
}

.stylish-chapter .mcq-result-row {
  margin: 0 0 1rem;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border, #e2e8f0);
  background: var(--card, #fff);
}

.stylish-chapter .mcq-result-row--ok {
  border-color: #a7f3d0;
  background: #ecfdf5;
}

.stylish-chapter .mcq-result-row--bad {
  border-color: #fecaca;
  background: #fef2f2;
}

.stylish-chapter .mcq-result-q {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
}

.stylish-chapter .mcq-result-meta {
  margin: 0 0 0.35rem;
  font-size: 0.9rem;
  color: var(--muted, #64748b);
}

.stylish-chapter .mcq-result-mark {
  font-weight: 700;
  color: var(--text, #0f172a);
}

.stylish-chapter .mcq-result-row--ok .mcq-result-mark {
  color: var(--success, #059669);
}

.stylish-chapter .mcq-result-row--bad .mcq-result-mark {
  color: #b91c1c;
}

.stylish-chapter .mcq-result-exp {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.55;
}

.stylish-chapter .mcq-save-status {
  margin: 1rem 0 0;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.95rem;
  line-height: 1.45;
}

.stylish-chapter .mcq-save-status--pending {
  background: #f1f5f9;
  border: 1px solid var(--border, #e2e8f0);
  color: var(--text, #0f172a);
}

.stylish-chapter .mcq-save-status--ok {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.stylish-chapter .mcq-save-status--err {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.stylish-chapter .mcq-save-status--note {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.stylish-chapter .stylish-mcq-options {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.5rem 0 0;
}

.stylish-chapter .stylish-mcq-opt {
  padding: 0.35rem 0.25rem;
  border-radius: 6px;
  cursor: pointer;
}

.stylish-chapter .stylish-mcq-opt:hover {
  background: #f8fafc;
}

/* Bottom nav */
.stylish-chapter .stylish-page-nav {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border, #e2e8f0);
}

/* Chapter article text pre-format defaults (used before JS conversion) */
.stylish-chapter .constitution-article-content .constitution-chapter-plain {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.45;
  margin: 0;
}

/* Paragraph fallback produced by numbering converter */
.stylish-chapter .constitution-article-content .constitution-numbered > p {
  margin: 0 0 0.6rem;
  line-height: 1.45;
}

/* Saved quiz banner + reset */
.stylish-chapter .mcq-saved-banner {
  margin: 0 0 1.25rem;
  padding: 1rem 1.1rem;
  border-radius: 10px;
  border: 1px solid var(--border, #e2e8f0);
  background: #f0fdfa;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.stylish-chapter .mcq-saved-banner__text {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text, #0f172a);
}

.stylish-chapter .mcq-reset-progress-btn {
  align-self: flex-start;
}

.stylish-chapter .mcq-result-actions {
  margin-top: 1rem;
}

/* Article overlay: previous / next card */
.overlay.stylish-overlay .article-overlay-card-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border, #e2e8f0);
  flex-wrap: wrap;
}

.overlay.stylish-overlay .article-overlay-nav-btn {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--primary, #1d4ed8);
  color: var(--primary, #1d4ed8);
  background: #eff6ff;
}

.overlay.stylish-overlay .article-overlay-nav-btn:hover:not(:disabled) {
  background: #dbeafe;
}

.overlay.stylish-overlay .article-overlay-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.overlay.stylish-overlay .article-overlay-nav-pos {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted, #64748b);
}
