/* ============================================================
   MTP Practice Set  —  mtp-practice.css
   Version 2.2.0

   FONT SYSTEM
   ──────────────────────────────────────────────────────────
   Loaded via Google Fonts (enqueued by plugin on any page
   containing [mtp_practice] or [mtp_practice_header]):

     • Source Sans 3  — body text, choices, feedback, buttons
       Weights: 300, 400, 500, 600
       URL: https://fonts.googleapis.com/css2?family=Source+Sans+3

     • Lora  — practice header h2 only (serif display)
       Weights: 700 normal, 600 italic
       URL: https://fonts.googleapis.com/css2?family=Lora

     • DM Mono  — badges, labels, monospace UI elements
       Weights: 400, 500
       URL: https://fonts.googleapis.com/css2?family=DM+Mono

   All three bundled in one Google Fonts request in
   mtp_enqueue_styles() → handle 'mtp-google-fonts'.

   FONT SIZE FLOOR
   ──────────────────────────────────────────────────────────
   All text the student READS is >= 16px (12pt).
   Decorative UI labels (SOLUTION, ANSWER, step numbers,
   difficulty badges) use 12-13px — never primary content.

   MATH RENDERING
   ──────────────────────────────────────────────────────────
   MathJax 3 (tex-chtml) loaded via CDN on any page with
   [mtp_practice]. Config injected inline before CDN script
   to support \(...\) and $$...$$ delimiters.
   Bar titles receive inline-converted math from PHP
   ($$...$$ → \(...\)) so MathJax never creates block
   elements inside the flex header bar.
   ============================================================ */

/* ── CSS Variables ────────────────────────────────────────── */
.mtp-practice-set {
  --ps-bg:         #f8f7f4;
  --ps-white:      #ffffff;
  --ps-border:     #e6e2d8;
  --ps-border-mid: #d4cfc3;
  --ps-gold:       #b07d2a;
  --ps-gold-bg:    rgba(176,125,42,0.08);
  --ps-gold-mid:   rgba(176,125,42,0.18);
  --ps-red:        #c0402e;
  --ps-red-bg:     rgba(192,64,46,0.07);
  --ps-green:      #27835a;
  --ps-green-bg:   rgba(39,131,90,0.08);
  --ps-blue:       #2a6eb0;
  --ps-blue-bg:    rgba(42,110,176,0.08);
  --ps-text:       #1e1c17;
  --ps-soft:       #5c5447;
  --ps-muted:      #9e9788;
  --ps-font-size:  16px;        /* overridden per-set via inline style */
}

/* ── Wrapper ──────────────────────────────────────────────── */
.mtp-practice-set {
  font-family: 'Source Sans 3', sans-serif;
  font-size: var(--ps-font-size, 16px);
  line-height: 1.7;
  color: var(--ps-text);
  padding: 0;
}

/* ── Cards ────────────────────────────────────────────────── */
.mtp-ps-card {
  background: var(--ps-white);
  border: 1px solid var(--ps-border);
  border-radius: 12px;
  margin-bottom: 8px;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.mtp-ps-card.mtp-ps-active {
  border-color: var(--ps-border-mid);
  box-shadow: 0 2px 10px rgba(0,0,0,0.07);
}
.mtp-ps-card.mtp-ps-solved .mtp-ps-badge { background: var(--ps-green) !important; }
.mtp-ps-card.mtp-ps-solved .mtp-ps-bar   { background: #f5faf7; }

/* ── Accordion bar ────────────────────────────────────────── */
.mtp-ps-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--ps-white);
  user-select: none;
}
.mtp-ps-card.mtp-ps-locked .mtp-ps-bar   { background: #faf9f6; cursor: not-allowed; }
.mtp-ps-card.mtp-ps-locked .mtp-ps-title { color: var(--ps-muted); }

/* ── Badge (number) ───────────────────────────────────────── */
.mtp-ps-badge {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--ps-text);
  color: var(--ps-white);
  font-family: 'DM Mono', monospace;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.3s;
}
.mtp-ps-card.mtp-ps-locked .mtp-ps-badge { background: var(--ps-muted); }

/* ── Bar title & right side ───────────────────────────────── */
.mtp-ps-title {
  flex: 1;
  font-size: var(--ps-font-size, 16px);
  font-weight: 500;
  color: var(--ps-text);
  line-height: 1.45;
}
.mtp-ps-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Difficulty badges ────────────────────────────────────── */
.mtp-ps-diff {
  font-size: 13px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.mtp-ps-diff::before { content: '●'; font-size: 8px; }
.mtp-ps-diff.easy   { background: var(--ps-green-bg); color: var(--ps-green); }
.mtp-ps-diff.medium { background: var(--ps-gold-bg);  color: var(--ps-gold);  }
.mtp-ps-diff.hard   { background: var(--ps-red-bg);   color: var(--ps-red);   }

/* ── Chevron / lock icon ──────────────────────────────────── */
.mtp-ps-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--ps-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--ps-muted);
  transition: all 0.25s;
  flex-shrink: 0;
}
.mtp-ps-card.mtp-ps-active .mtp-ps-icon {
  transform: rotate(180deg);
  border-color: var(--ps-gold);
  color: var(--ps-gold);
  background: var(--ps-gold-bg);
}
.mtp-ps-card.mtp-ps-solved .mtp-ps-icon {
  transform: none;
  border-color: var(--ps-green);
  color: var(--ps-green);
  background: var(--ps-green-bg);
  font-size: 14px;
}

/* ── Accordion body ───────────────────────────────────────── */
.mtp-ps-body   { display: none; }
.mtp-ps-inner  { border-top: 1px solid var(--ps-border); }
.mtp-ps-card.mtp-ps-active .mtp-ps-body {
  display: block;
  animation: mtpPsSlideDown 0.28s ease both;
}

/* ── Question text ────────────────────────────────────────── */
.mtp-ps-qtext {
  padding: 18px 22px 6px 64px;
  font-size: var(--ps-font-size, 16px);
  font-weight: 500;
  color: var(--ps-text);
  line-height: 1.65;
}

/* ── Show Solution button ─────────────────────────────────── */
.mtp-ps-sol-row {
  display: flex;
  justify-content: flex-end;
  padding: 4px 22px 6px;
}
.mtp-ps-reveal {
  font-family: 'Source Sans 3', sans-serif;
  font-size: 14px;
  font-weight: 500;
  padding: 7px 16px;
  border-radius: 6px;
  border: 1.5px solid var(--ps-border-mid);
  background: var(--ps-white);
  color: var(--ps-soft);
  cursor: pointer;
  transition: all 0.2s;
}
.mtp-ps-reveal:hover  { border-color: var(--ps-gold); color: var(--ps-gold); }
.mtp-ps-reveal.active { border-color: var(--ps-text); color: var(--ps-text); background: #f0ede6; }

/* ── Choices ──────────────────────────────────────────────── */
.mtp-ps-choices {
  padding: 0 22px 14px 64px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mtp-ps-choice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1.5px solid var(--ps-border);
  cursor: pointer;
  transition: all 0.18s;
  background: var(--ps-white);
  text-align: left;
  width: 100%;
  font-family: 'Source Sans 3', sans-serif;
  font-size: var(--ps-font-size, 16px);
  color: var(--ps-soft);
  line-height: 1.55;
}
.mtp-ps-choice:hover:not(:disabled) {
  border-color: var(--ps-gold);
  background: var(--ps-gold-bg);
  color: var(--ps-text);
}
.mtp-ps-choice.mtp-correct  { border-color: var(--ps-green); background: var(--ps-green-bg); color: var(--ps-green); }
.mtp-ps-choice.mtp-wrong    { border-color: var(--ps-red);   background: var(--ps-red-bg);   color: var(--ps-red);   }
.mtp-ps-choice.mtp-revealed { border-color: var(--ps-green); background: var(--ps-green-bg); color: var(--ps-green); opacity: 0.6; }
.mtp-ps-choice-letter {
  font-family: 'DM Mono', monospace;
  font-size: 13px;
  opacity: 0.45;
  min-width: 16px;
  padding-top: 2px;
  flex-shrink: 0;
}
.mtp-ps-choice-text { flex: 1; line-height: 1.55; }

/* ── Inline feedback ──────────────────────────────────────── */
.mtp-ps-feedback {
  margin: 0 22px 12px 64px;
  padding: 11px 16px;
  border-radius: 8px;
  font-size: var(--ps-font-size, 16px);
  line-height: 1.65;
  display: none;
}
.mtp-ps-feedback.show    { display: block; }
.mtp-ps-feedback.correct { background: var(--ps-green-bg); color: #1a6645; border: 1px solid rgba(39,131,90,0.2); }
.mtp-ps-feedback.wrong   { background: var(--ps-red-bg);   color: #9a3020; border: 1px solid rgba(192,64,46,0.2); }

/* ── Try again row ────────────────────────────────────────── */
.mtp-ps-footer { padding: 2px 22px 14px 64px; display: none; }
.mtp-ps-footer.show { display: flex; gap: 8px; }
.mtp-ps-reset {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 7px 14px;
  background: transparent;
  border: 1px solid var(--ps-border-mid);
  color: var(--ps-muted);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}
.mtp-ps-reset:hover { border-color: var(--ps-gold); color: var(--ps-gold); }

/* ── Solution panel ───────────────────────────────────────── */
.mtp-ps-solution { border-top: 1px solid var(--ps-border); display: none; background: #fdfcf9; }
.mtp-ps-solution.show { display: block; animation: mtpPsFadeIn 0.2s ease both; }
.mtp-ps-sol-label {
  font-family: 'DM Mono', monospace;
  font-size: 12px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--ps-gold);
  padding: 10px 22px 7px;
  background: #faf8f4;
  border-bottom: 1px solid var(--ps-border);
}
.mtp-ps-sol-body { padding: 18px 22px 22px; }

/* ── Next Problem button ──────────────────────────────────── */
.mtp-ps-next-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 14px 22px 4px;
  border-top: 1px solid var(--ps-border);
  margin-top: 6px;
  gap: 12px;
}
.mtp-ps-next-label {
  font-size: 12px;
  font-family: 'DM Mono', monospace;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--ps-muted);
}
.mtp-ps-next-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: 'Source Sans 3', sans-serif;
  font-size: var(--ps-font-size, 16px);
  font-weight: 600;
  padding: 11px 22px;
  border-radius: 8px;
  background: #1e1c17;
  color: var(--ps-gold);
  border: 2px solid var(--ps-gold);
  cursor: pointer;
  transition: all 0.2s;
}
.mtp-ps-next-btn:hover { background: var(--ps-gold); color: #fff; }
.mtp-ps-next-arrow { font-size: 18px; transition: transform 0.2s; display: inline-block; }
.mtp-ps-next-btn:hover .mtp-ps-next-arrow { transform: translateX(4px); }

/* ── Solution steps (PHP builder output) ─────────────────── */
.mtp-ps-steps { display: flex; flex-direction: column; }
.mtp-ps-sol-step { display: flex; gap: 14px; padding-bottom: 18px; }
.mtp-ps-sol-step:last-child { padding-bottom: 0; }
.mtp-ps-sol-step-num {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--ps-gold-bg); border: 1px solid rgba(176,125,42,0.25);
  font-family: 'DM Mono', monospace; font-size: 12px; color: var(--ps-gold);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 2px;
}
.mtp-ps-sol-step-body strong { font-size: var(--ps-font-size, 16px); font-weight: 600; color: var(--ps-text); display: block; margin-bottom: 4px; }
.mtp-ps-sol-step-body p      { font-size: var(--ps-font-size, 16px); color: var(--ps-soft); line-height: 1.75; margin: 0 0 6px; }
.mtp-ps-sol-math {
  background: #f4f2ec; border: 1px solid var(--ps-border); border-left: 3px solid var(--ps-gold);
  border-radius: 6px; padding: 10px 16px; margin: 8px 0; font-size: var(--ps-font-size, 16px); color: #6a5010; line-height: 2; overflow-x: auto;
}
.mtp-ps-answer {
  background: #1e1c17; color: var(--ps-gold); border-radius: 8px;
  padding: 14px 18px; margin-top: 14px; font-family: 'DM Mono', monospace; font-size: var(--ps-font-size, 16px); line-height: 1.9;
}
.mtp-ps-ans-label { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: #7a6a40; display: block; margin-bottom: 4px; }

/* ── Legacy solution helpers (HTML-imported sets) ─────────── */
.mtp-ps-sol-body .sol-steps   { display: flex; flex-direction: column; }
.mtp-ps-sol-body .sol-step    { display: flex; gap: 14px; padding-bottom: 18px; }
.mtp-ps-sol-body .sol-step:last-child { padding-bottom: 0; }
.mtp-ps-sol-body .sol-step-num {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--ps-gold-bg); border: 1px solid rgba(176,125,42,0.25);
  font-family: 'DM Mono', monospace; font-size: 12px; color: var(--ps-gold);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 2px;
}
.mtp-ps-sol-body .sol-step-body strong { font-size: var(--ps-font-size, 16px); font-weight: 600; color: var(--ps-text); display: block; margin-bottom: 4px; }
.mtp-ps-sol-body .sol-step-body p      { font-size: var(--ps-font-size, 16px); color: var(--ps-soft); line-height: 1.75; margin-bottom: 6px; }
.mtp-ps-sol-body .sol-math {
  background: #f4f2ec; border: 1px solid var(--ps-border); border-left: 3px solid var(--ps-gold);
  border-radius: 6px; padding: 10px 16px; margin: 8px 0; font-size: var(--ps-font-size, 16px); color: #6a5010; line-height: 2; overflow-x: auto;
}
.mtp-ps-sol-body .sol-answer {
  background: #1e1c17; color: var(--ps-gold); border-radius: 8px;
  padding: 14px 18px; margin-top: 14px; font-family: 'DM Mono', monospace; font-size: var(--ps-font-size, 16px); line-height: 1.9;
}
.mtp-ps-sol-body .sol-answer .ans-label { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: #7a6a40; display: block; margin-bottom: 4px; }
.mtp-ps-sol-body .sol-table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 15px; font-family: 'DM Mono', monospace; }
.mtp-ps-sol-body .sol-table th { background: #f4f2ec; color: var(--ps-gold); font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; padding: 8px 12px; border: 1px solid var(--ps-border); text-align: center; font-weight: 600; }
.mtp-ps-sol-body .sol-table td { padding: 8px 12px; border: 1px solid var(--ps-border); text-align: center; color: var(--ps-soft); font-size: 15px; }
.mtp-ps-sol-body .sol-table tr:nth-child(even) td { background: #faf9f6; }
.mtp-ps-sol-body .keypts { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.mtp-ps-sol-body .kpt { flex: 1; min-width: 120px; border-radius: 7px; padding: 9px 12px; font-family: 'DM Mono', monospace; font-size: 14px; line-height: 1.6; }
.mtp-ps-sol-body .kpt.gold  { background: var(--ps-gold-bg);  border: 1px solid rgba(176,125,42,0.2); color: var(--ps-gold);  }
.mtp-ps-sol-body .kpt.green { background: var(--ps-green-bg); border: 1px solid rgba(39,131,90,0.2);  color: var(--ps-green); }
.mtp-ps-sol-body .kpt.blue  { background: var(--ps-blue-bg);  border: 1px solid rgba(42,110,176,0.2); color: var(--ps-blue);  }
.mtp-ps-sol-body .kpt.red   { background: var(--ps-red-bg);   border: 1px solid rgba(192,64,46,0.2);  color: var(--ps-red);   }
.mtp-ps-sol-body .kpt span  { display: block; font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; opacity: 0.7; margin-bottom: 2px; }
.mtp-ps-sol-body .tag-inc { color: var(--ps-green); font-weight: 600; }
.mtp-ps-sol-body .tag-dec { color: var(--ps-red);   font-weight: 600; }
.mtp-ps-sol-body .tag-cu  { color: var(--ps-blue);  font-weight: 600; }
.mtp-ps-sol-body .tag-cd  { color: var(--ps-gold);  font-weight: 600; }

/* ── Animations ───────────────────────────────────────────── */
@keyframes mtpPsSlideDown { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes mtpPsFadeIn    { from { opacity: 0; }                              to { opacity: 1; }                            }

/* ── MathJax rendering fixes ──────────────────────────────── */
/* Bar title: PHP pre-converts $$...$$ → \(...\), this is a safety net */
.mtp-ps-title mjx-container[display="true"],
.mtp-ps-title mjx-container[display] { display: inline !important; margin: 0 0.12em; }

/* Question body: display math as centered block */
.mtp-ps-qtext mjx-container[display="true"],
.mtp-ps-qtext mjx-container[display] { display: block !important; text-align: center; overflow-x: auto; margin: 0.6em 0; }

/* Solution math blocks */
.mtp-ps-sol-math mjx-container[display="true"],
.mtp-ps-sol-math mjx-container[display],
.mtp-ps-sol-body .sol-math mjx-container[display="true"],
.mtp-ps-sol-body .sol-math mjx-container[display] { display: block !important; text-align: center; overflow-x: auto; margin: 0.25em 0; }

/* Inline math everywhere */
.mtp-practice-set mjx-container:not([display]) { display: inline !important; vertical-align: middle; }
.mtp-practice-set mjx-container { max-width: 100%; }
