/* ──────────────────────────────
   Variables
──────────────────────────────── */
:root {
  --brand: #1e40af;
  --brand-2: #3f87a6;
  --yellow: #ffd24d;
  --yellow-light: #ffea70;
  --red: #ef4444;
  --blue-text: #1e40af;
  --white: #ffffff;
  --body-light: #e6f0ff;
}

/* ──────────────────────────────
   Base Layout
──────────────────────────────── */
body.practice-room {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--body-light);
  color: var(--blue-text);
  margin: 0;
  padding: 0;
}

.form-content {
  max-width: 800px;
  margin: 2rem auto;
  padding: 2rem;
  background-color: var(--brand);
  color: var(--yellow);
  border-radius: 1rem;
  border: 2px solid var(--brand-2);
  box-shadow: 0 8px 20px rgba(30,64,175,0.3);
}

/* ──────────────────────────────
   Hero & Progress
──────────────────────────────── */
.step-quiz-hero {
  background-color: var(--brand);
  color: var(--white);
  border-bottom: 2px solid var(--yellow);
  padding: 1rem 1.5rem;
  text-align: center;
}

.quiz-title {
  font-size: 1.6rem;
  font-weight: 600;
  margin: 0;
  color: var(--white);
}

.progress-bar-wrapper {
  max-width: 800px;
  margin: 1rem auto;
  padding: 0 1rem;
}

.progress-label {
  color: var(--blue-dark);  /* contrasts with yellow/light bar */
  font-weight: bold;
  margin-bottom: 0.25rem;
}

@media (max-width: 640px) {
  .progress-label {
    font-size: 0.85rem;
  }
}


.progress-bar.multi {
  display: flex;
  height: 12px;
  border-radius: 10px;
  overflow: hidden;
  background: #ddd;
  margin-top: 0.3rem;
}

.progress-bar.multi .step {
  flex: 1;
  transition: background-color 0.3s ease;
}
.progress-bar.multi .step.correct { background-color: var(--yellow); }
.progress-bar.multi .step.partial { background-color: #fff59d; }
.progress-bar.multi .step.incorrect { background-color: var(--red); }
.progress-bar.multi .step.unanswered { background-color: #ccc; }

/* ──────────────────────────────
   Question, Options & Fields
──────────────────────────────── */
.question-block { margin-bottom: 1.5rem; }

.question-text {
  background-color: var(--yellow);
  color: var(--blue-text);
  border: 1px solid var(--brand-2);
  border-radius: 12px;
  padding: 1rem 1.5rem;
  margin-bottom: 1.2rem;
  box-shadow: 0 2px 6px rgba(30,64,175,0.1);
}

.option-label {
  display: block;
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.75rem;
  background-color: var(--white);
  color: var(--blue-text);
  border: 1px solid var(--brand-2);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.option-label:hover { background-color: var(--yellow-light); }
.option-label input { margin-right: 0.5rem; }

.text-input,
.input-help-box,
.hint-box {
  background-color: var(--yellow);
  color: var(--blue-text);
  border: 1px solid var(--brand-2);
  border-radius: 6px;
  padding: 0.5rem;
}
.text-input:focus,
.input-help-box:focus { border-color: #0d2b66; }

/* ──────────────────────────────
   Feedback & Worked Solution
──────────────────────────────── */
.final-feedback {
    max-width: 800px;           /* match quiz container width */
    margin: 2rem auto;          /* center horizontally with spacing */
    padding: 2rem;              /* generous padding */
    background-color: var(--body-light); /* or white/light color */
    border-radius: 1rem;
    border: 2px solid var(--brand-2);
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
    text-align: center;
    color: var(--blue-text);
}

.final-feedback h3 {
    font-size: 1.6rem;
    margin-bottom: 1rem;
}

.final-feedback p {
    font-size: 1.2rem;
    margin: 0.5rem 0;
}

.final-feedback .button-wrapper {
    margin-top: 1.5rem;
}

.feedback-block {
  border-radius: 12px;
  padding: 1.2rem 1.5rem;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 500;
  margin: 1.5rem 0;
  border: 2px solid transparent;
  box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

.feedback-block.correct { background-color: #fff9e6; border-color: var(--yellow); color: #256029; }
.feedback-block.partial { background-color: #fffbe6; border-color: #facc15; color: #7a6000; }
.feedback-block.incorrect { background-color: #ffe6e6; border-color: var(--red); color: #8e2e2e; }

.explanation-box {
  margin-top: 1rem;
  padding: 1rem;
  background-color: var(--white);
  border-left: 4px solid var(--brand);
  border-radius: 0.5rem;
  color: var(--blue-text);
}

/* ──────────────────────────────
   Buttons & Navigation
──────────────────────────────── */
.button {
  border-radius: 8px;
  font-weight: bold;
  padding: 0.6rem 1rem;
  transition: background-color 0.2s ease;
  border: none;
}

.button.submit-btn,
.button.primary { background-color: var(--brand); color: var(--yellow); }
.button.submit-btn:hover,
.button.primary:hover { background-color: #2549c7; }

.button.finish-button,
.button.back-button { background-color: var(--yellow); color: var(--blue-text); }
.button.finish-button:hover,
.button.back-button:hover { background-color: var(--yellow-light); }

.bottom-buttons {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 2px solid #eee;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
}

.bottom-buttons a.button {
  background-color: var(--yellow);
  color: var(--blue-text);
  padding: 0.6rem 1rem;
  border-radius: 8px;
  font-weight: bold;
  text-decoration: none;
  display: inline-block;
  transition: background-color 0.2s ease;
}

.bottom-buttons a.button:hover {
  background-color: var(--yellow-light);
  color: var(--blue-text);
}


.hint-left { display: flex; align-items: center; gap: 0.75rem; margin-right: auto; }
.hint-icon { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #ffc107; }
.hint-icon:hover { color: #444; }

/* ──────────────────────────────
   Images & Modals
──────────────────────────────── */
.question-image { text-align: center; margin-top: 1rem; }
.question-image img,
.image-preview { max-width: 100%; border-radius: 8px; }

.modal { display: none; position: fixed; z-index: 9999; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5); justify-content: center; align-items: center; }
.modal-content { max-width: 80%; max-height: 80%; margin: auto; display: block; }
.modal .close { position: absolute; top: 20px; right: 30px; font-size: 36px; color: #fff; cursor: pointer; }

/* ──────────────────────────────
   Related Links
──────────────────────────────── */
.related-links {
  margin: 3rem auto 2rem;
  padding: 1.5rem 2rem;
  max-width: 800px;
  background: var(--yellow);
  border: 1px solid var(--brand-2);
  border-radius: 0.75rem;
  box-shadow: 0 2px 6px rgba(30,64,175,0.1);
}
.related-links h3 { margin: 0 0 1rem; font-size: 1.25rem; font-weight: 600; color: var(--brand); text-align: center; }
.related-links a { display: block; padding: 0.75rem 1rem; background: var(--body-light); color: var(--brand); text-decoration: none; border-radius: 0.5rem; transition: all 0.2s ease-in-out; }
.related-links a:hover { background: var(--brand); color: var(--yellow); transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0,0,0,0.08); }

/* ──────────────────────────────
   Responsive
──────────────────────────────── */
@media (max-width: 640px) {
  .bottom-buttons .button,
  .bottom-buttons a.button { width: 100%; max-width: 280px; margin: 0 auto; text-align: center; }
  .hint-left { flex: 1 1 100%; margin-right: 0; margin-bottom: 0.75rem; }
  .hint-left .hint-box { max-width: 100%; }
  .quick-filters { flex-direction: column; align-items: stretch; gap: 0.5rem; }
  .quick-filters label { font-size: 0.85rem; }
  .quick-filters select { width: 100%; }
}

/* ──────────────────────────────
   Dark Mode
──────────────────────────────── */
html.dark-mode body.practice-room { background: #0f172a; color: #e5e7eb; }
html.dark-mode .form-content,
html.dark-mode .question-block { background: #0f172a; color: #e5e7eb; border: 1px solid rgba(255,255,255,0.1); box-shadow: 0 10px 30px rgba(0,0,0,0.45); }
html.dark-mode .question-text { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1); color: #e5e7eb; }
html.dark-mode .option-label { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); color: #e5e7eb; }
html.dark-mode .text-input,
html.dark-mode .input-help-box { background: #0b1220; border: 1px solid rgba(255,255,255,0.15); color: #e5e7eb; }
html.dark-mode .hint-box { background: #0b1220; border: 1px solid rgba(255,255,255,0.12); color: #e5e7eb; }
html.dark-mode .button { background: var(--brand-2, #3f87a6); color: #ffd24d; }
html.dark-mode .button.finish-button,
html.dark-mode .button.back-button { background: var(--yellow); color: var(--blue-text); }

.progress-total-label {
    text-align: right;
    font-size: 0.85rem;
    color: var(--blue-text);  /* white may be invisible on some backgrounds */
    margin-top: 0.25rem;
}

.total-questions {
    font-weight: bold;
    font-size: 0.9rem;
    color: var(--blue-dark);   /* choose a color that contrasts with background */
    margin-top: 4px;           /* spacing below the progress label */
}

.question-intro {
    max-width: 800px;      /* limits width */
    margin: 2rem auto;     /* centers the box */
    padding: 1rem 1.5rem;  /* inner spacing */
    background: #f0f4ff;   /* optional highlight */
    border-left: 4px solid #1e40af;
    border-radius: 8px;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
    display: block;        /* ensures it behaves like a block */
}


.question-text {
    background: #ffd24d;   /* yellow */
    padding: 1rem 1.5rem;
    border-radius: 8px;
    border-left: 4px solid #1e40af;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ──────────────────────────────
   Tips Container
──────────────────────────────── */
.tips-container {
    max-width: 800px;                /* match quiz card width */
    margin: 1rem auto;               /* spacing above & below */
}

.tip-box {
    background-color: #fffbe6;       /* light yellow */
    border-left: 6px solid #ffd24d;  /* accent line */
    border-radius: 8px;
    padding: 1rem 1.5rem;            /* inner spacing */
    color: #7a6000;                  /* text color */
    font-size: 0.95rem;
    line-height: 1.4;
    box-shadow: 0 4px 10px rgba(30,64,175,0.1);
}

/* ──────────────────────────────
   Extra Content / Mini Tutorial
──────────────────────────────── */
.extra-content-container {
    max-width: 800px;       /* align with quiz card width */
    margin: 1rem auto 2rem auto;  /* spacing from tips above & next section below */
}

.extra-content-box {
    background-color: #f0f4ff;  /* light blue background */
    border-left: 6px solid var(--brand);  /* accent line */
    border-radius: 8px;
    padding: 1rem 1.5rem;
    color: var(--blue-text);
    line-height: 1.5;
    font-size: 1rem;
    box-shadow: 0 4px 10px rgba(30,64,175,0.1);
}

/* ──────────────────────────────
   Worked Solution Card
──────────────────────────────── */
.worked-content-container {
    max-width: 800px;                /* same width as quiz card for alignment */
    margin: 1.5rem auto 2rem auto;   /* spacing above and below */
}

.worked-content-box {
    background-color: #e6ffed;       /* light green background to indicate "solution" */
    border-left: 6px solid #22c55e;  /* bold accent line */
    border-radius: 8px;
    padding: 1.25rem 1.5rem;         /* internal spacing */
    font-size: 1rem;
    line-height: 1.6;
    box-shadow: 0 4px 10px rgba(30, 64, 175, 0.1); /* subtle shadow */
}

.worked-content-box h3 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: #166534;                  /* dark green heading */
    font-weight: 600;
    font-size: 1.25rem;
}

.worked-content-body p {
    margin-bottom: 0.75rem;
}

.worked-content-video {
    margin: 1rem 0;
    border-radius: 6px;
    overflow: hidden;
}

.worked-content-related {
    margin-top: 1rem;
}

.worked-content-related h4 {
    margin-bottom: 0.5rem;
    font-size: 1rem;
    color: #166534;
}

.worked-content-related ul {
    padding-left: 1.2rem;
}

.worked-content-related a {
    color: #166534;
    text-decoration: underline;
}

.worked-content-body span,
.worked-content-body p {
    font-size: 0.98rem;
}

/* Optional: subtle hover effect on links */
.worked-content-related a:hover {
    color: #115e30;
}


.user-answer-box li {
    color: black !important;       /* force visibility */
    background-color: yellow !important;
    font-weight: bold;
}

/* ──────────────────────────────
   Worked solution safe for long formulas
──────────────────────────────── */
/* Outer worked solution box */
.explanation-box {
    background-color: #e6ffed;      /* green */
    border-left: 6px solid #22c55e;
    border-radius: 8px;
    padding: 1.5rem 1.75rem;
    min-height: 180px;
    max-width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    overflow: visible;             /* let inner scroll handle overflow */
}

/* Inner scrollable wrapper */
.scroll-wrapper {
    flex: 1;
    display: flex;
    align-items: flex-start;       /* stick content to top */
    overflow-x: auto;              /* horizontal scroll */
    overflow-y: hidden;
    padding-bottom: 4.5rem;        /* space between text and scrollbar */
}

/* Inner content */
.scroll-content {
    white-space: nowrap;           /* keep long formulas on one line */
}
.corner-nav {
    position: absolute;
    top: 0;                   /* move to top of wrapper */
    margin-top: -5px;           /* add space from question box */
    width: 50px;
    height: 50px;
    background-color: var(--yellow);
    color: var(--blue-text);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.2rem;
    font-weight: bold;
    text-decoration: none;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    transition: background 0.2s ease, transform 0.2s ease;
}

/* Hover effect */
.corner-nav:hover {
    background-color: var(--yellow-light);
    transform: scale(1.05);
}

/* Positioning */
.corner-nav.left { left: 0px; }
.corner-nav.right { right: 0px; }

/* Mobile adjustments */
@media (max-width: 640px) {
    .corner-nav {
        width: 40px;
        height: 40px;
        font-size: 1.8rem;
        margin-top: 6px;      /* smaller space for mobile */
    }
}

@media (max-width: 640px) {
    .question-text {
        overflow-x: auto;         /* allow horizontal scrolling */
        -webkit-overflow-scrolling: touch; /* smooth scrolling on iOS */
        white-space: nowrap;      /* keep LaTeX inline on one line */
        max-width: 100%;          /* prevent overflow outside container */
        padding: 1rem;            /* optional: adjust padding for mobile */
        box-sizing: border-box;
    }

    /* Optional: show a subtle scrollbar */
    .question-text::-webkit-scrollbar {
        height: 6px;
    }
    .question-text::-webkit-scrollbar-thumb {
        background-color: rgba(30,64,175,0.5);
        border-radius: 3px;
    }
}

  .video-wrap{
    position: relative; margin: 1rem auto; max-width: 800px;
    border-radius: 12px; overflow: hidden; box-shadow: 0 10px 28px rgba(2,6,23,.12);
    background: #000;
  }
  .video-wrap::before{ content:""; display:block; padding-top:56.25%; } /* 16:9 */
  .video-wrap iframe{
    position:absolute; top:0; left:0; width:100%; height:100%; border:0;
  }
  .video-caption{ margin:.5rem 0 0; color:var(--muted-ink, #667084); text-align:center; font-size:.95rem; }
  details.explanation-box .scroll-wrapper{ margin-top:1rem; }

  .examples {
  background: var(--surface-2, #f8fafc);
  border-left: 5px solid var(--brand-color, #1f6feb);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}
.examples h4 {
  margin-top: 0;
  color: var(--brand-color, #1f6feb);
  font-weight: 600;
}
.examples ol {
  margin: 0.5rem 0 1rem 1.25rem;
  padding: 0;
}
.examples p {
  margin: 0.4rem 0;
}
@media (prefers-color-scheme: dark) {
  .examples {
    background: var(--card, #0f172a);
    border-left-color: var(--brand-color, #60a5fa);
    color: var(--ink, #e6ebf5);
  }
  .examples h4 {
    color: var(--brand-color, #60a5fa);
  }
}


/* =========================================================
   Practice Room — Dark Mode fixes (drop-in overrides)
   ========================================================= */
html.dark-mode {
  /* a consistent dark token set */
  --ink: #e6e7eb;
  --muted-ink: #b4bfd4;
  --surface-0: #0b1220;   /* page */
  --surface-1: #0f172a;   /* cards */
  --surface-2: #111a30;   /* subtle panels */
  --border-d: rgba(255,255,255,.12);

  /* keep your brand/yellow but slightly toned for dark */
  --brand: #3b82f6;       /* readable on dark */
  --brand-2: #60a5fa;
  --yellow: #ffd24d;
  --yellow-light: #ffe37f;
}

/* page + main card */
html.dark-mode body.practice-room { background: var(--surface-0); color: var(--ink); }
html.dark-mode .form-content { background: var(--surface-1); color: var(--ink);
  border: 1px solid var(--border-d); box-shadow: 0 12px 36px rgba(0,0,0,.45); }

/* progress header + bar */
html.dark-mode .step-quiz-hero { background: var(--surface-1); color: var(--ink); border-bottom: 1px solid var(--border-d); }
html.dark-mode .progress-bar.multi { background: #1f2a44; }
html.dark-mode .progress-bar.multi .step.unanswered { background: #223153; }
html.dark-mode .progress-label,
html.dark-mode .progress-total-label,
html.dark-mode .total-questions { color: var(--muted-ink); }

/* question text panel */
html.dark-mode .question-text {
  background: rgba(255,255,255,.06);
  color: var(--ink);
  border: 1px solid var(--border-d);
  border-left-color: var(--brand-2);
}

/* options (radio list) */
html.dark-mode .option-label{
  background: rgba(255,255,255,.06);
  color: var(--ink);
  border: 1px solid var(--border-d);
}
html.dark-mode .option-label:hover{ background: rgba(255,255,255,.12); }
html.dark-mode .option-label input{
  accent-color: var(--yellow);
}
html.dark-mode .option-label:focus-within{
  outline: 2px solid var(--brand-2); outline-offset: 2px;
}

/* text inputs / hint */
html.dark-mode .text-input,
html.dark-mode .input-help-box,
html.dark-mode .hint-box{
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--border-d);
}

/* feedback (correct/partial/incorrect) */
html.dark-mode .feedback-block.correct{ background:#1d2a18; border-color:#65a30d; color:#a7f3d0; }
html.dark-mode .feedback-block.partial{ background:#2a240f; border-color:#eab308; color:#fde68a; }
html.dark-mode .feedback-block.incorrect{ background:#31191b; border-color:#ef4444; color:#fecaca; }

/* “Common mistake”/tips */
html.dark-mode .tip-box{
  background: #2a240f;
  border-left-color: var(--yellow);
  color: #f8f5d2;
  box-shadow: 0 6px 16px rgba(0,0,0,.3);
}

/* intro panel above the question */
html.dark-mode .question-intro{
  background: #12203a;
  border-left-color: var(--brand-2);
  color: var(--ink);
}

/* extra mini-tutorial */
html.dark-mode .extra-content-box{
  background: #0f1b33;
  border-left-color: var(--brand-2);
  color: var(--ink);
}

/* worked solution (green theme retained, muted) */
html.dark-mode .worked-content-box{
  background:#0e2016;
  border-left-color:#22c55e;
  color:#c6f6d5;
}
html.dark-mode .worked-content-box h3{ color:#86efac; }

/* generic explanation box + long-formulas scroller */
html.dark-mode .explanation-box{
  background:#0e2016; border-left-color:#22c55e; color:#c6f6d5;
}
html.dark-mode .scroll-wrapper::-webkit-scrollbar-thumb{ background: rgba(134,239,172,.5); }

/* related links */
html.dark-mode .related-links{
  background: var(--surface-2);
  border-color: var(--border-d);
  box-shadow: 0 6px 16px rgba(0,0,0,.3);
}
html.dark-mode .related-links h3{ color: var(--ink); }
html.dark-mode .related-links a{
  background: #0e1729; color: var(--brand-2);
}
html.dark-mode .related-links a:hover{
  background: var(--brand-2); color:#0b1220;
}

/* buttons */
html.dark-mode .button{
  background: var(--brand-2);
  color: #0b1220;
  border: 1px solid transparent;
}
html.dark-mode .button:hover{ background: var(--brand); }
html.dark-mode .button.finish-button,
html.dark-mode .button.back-button{
  background: var(--yellow); color:#0b1220;
}

/* examples block (your new .examples) */
html.dark-mode .examples{
  background: var(--surface-1);
  border-left-color: var(--brand-2);
  color: var(--ink);
}
html.dark-mode .examples h4{ color: var(--brand-2); }

/* corner nav arrows stay yellow but ensure contrast on dark */
html.dark-mode .corner-nav{
  background: var(--yellow); color:#0b1220; box-shadow: 0 4px 12px rgba(0,0,0,.4);
}

/* mobile horizontal LaTeX scroll thumb on dark */
html.dark-mode .question-text::-webkit-scrollbar-thumb{
  background-color: rgba(96,165,250,.6);
}

/* final summary card */
html.dark-mode .final-feedback{
  background: var(--surface-1);
  border: 1px solid var(--border-d);
  color: var(--ink);
}
