/* Long math + wide tables get their own horizontal scrollbar inside the
   problem box instead of overflowing the page. */
mjx-container[display="true"] {
  display: block !important;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}
.exam-question table,
.result-question table {
  display: block; max-width: 100%; overflow-x: auto;
}

/* Practice F=ma exam */
.exam-wrap { max-width: 820px; margin: 1.5rem auto 4rem; padding: 0 1.25rem; }

/* Gray back button (mirrors pset.css for pages that don't load pset.css). */
a.pset-back,
a.pset-back:link, a.pset-back:visited,
a.pset-back:hover, a.pset-back:active, a.pset-back:focus {
  display: inline-block;
  padding: .35rem .7rem;
  font-size: .85rem;
  font-weight: 500;
  background: #e5e7eb;
  color: #333;
  border: 0; border-radius: 4px;
  text-decoration: none !important;
  line-height: 1.2;
}
a.pset-back:hover { background: #d1d5db; }

/* Rules screen */
.exam-rules { padding: 2rem; border: 1px solid #ddd; border-radius: 8px; background: #fff; }
.exam-rules h1 { margin-top: 0; }
.exam-rules ul { line-height: 1.6; padding-left: 1.2rem; }
.exam-begin-btn {
  display: block; margin: 2rem auto 0; padding: 1rem 2.5rem;
  background: #1b6b34; color: #fff; border: 0; border-radius: 6px;
  font-size: 1.15rem; font-weight: 700; cursor: pointer;
}
.exam-begin-btn:hover { background: #155227; }

/* Active exam */
.exam-topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 1rem;
  padding: .75rem 1rem; margin: -1.5rem -1.25rem 1.5rem;
  background: #2f5d8c; color: #fff; flex-wrap: wrap;
}
.exam-topbar h2 { margin: 0; flex: 1; font-size: 1.1rem; }
.exam-timer {
  font-variant-numeric: tabular-nums; font-weight: 700;
  font-size: 1.2rem; padding: .25rem .75rem; background: rgba(0,0,0,.25);
  border-radius: 4px;
}
.exam-timer.urgent { background: #b00020; }
.exit-btn, .finish-btn {
  padding: .45rem .9rem; border: 0; border-radius: 4px;
  font-weight: 600; cursor: pointer;
}
.exit-btn { background: #fff; color: #b00020; }
.finish-btn { background: #fff3cd; color: #8a6d00; }

/* Group wrapping a shared preamble + the pair of problems it applies to.
   Looks like a single white card; the inner question subdivisions don't
   get their own border so the whole thing reads as one container. */
.exam-group {
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  background: #fff;
}
.exam-group .exam-preamble {
  line-height: 1.55;
  padding-bottom: .85rem;
  margin-bottom: .75rem;
  border-bottom: 1px dashed #ccc;
}
.exam-group .exam-preamble strong { color: #2f5d8c; }
.exam-group .exam-preamble img { display: block; margin: .75em auto; max-width: 100%; height: auto; }
/* Inner problem subdivisions: no border, just spacing between them. */
.exam-group .exam-question,
.exam-group .result-question {
  border: 0;
  padding: 0;
  background: transparent;
  margin: 0 0 1rem 0;
}
.exam-group .exam-question:last-child,
.exam-group .result-question:last-child {
  margin-bottom: 0;
}
/* Subtle divider between the two paired problems */
.exam-group .exam-question + .exam-question,
.exam-group .result-question + .result-question {
  padding-top: 1rem;
  border-top: 1px dashed #ccc;
}
/* Keep the wrong/right colored-border indicator visible on results.
   We do this by re-applying it to the GROUP only when both inner
   problems are wrong, OR — simpler — re-apply per-question on the LEFT. */
.exam-group .result-question.right { border-left: 5px solid #1b6b34; padding-left: .75rem; }
.exam-group .result-question.wrong { border-left: 5px solid #b00020; padding-left: .75rem; }

.exam-question {
  border: 1px solid #ddd; border-radius: 6px; padding: 1.25rem;
  margin-bottom: 1.25rem; background: #fff;
}
.exam-question .qnum { font-weight: 700; color: #2f5d8c; margin-right: .35rem; }
.exam-question .stem { line-height: 1.6; }
.exam-question .choices { margin-top: .85rem; display: flex; flex-direction: column; gap: .4rem; }
.exam-question .choices label {
  display: flex; align-items: flex-start; gap: .55rem;
  padding: .55rem .8rem; border: 1px solid #d4d4d8; border-radius: 5px;
  cursor: pointer;
}
.exam-question .choices label:hover { background: #f6f8fa; }
.exam-question .choices input[type=radio] { margin-top: .25rem; }
.exam-question .choices .letter { font-weight: 700; min-width: 1.5em; color: #2f5d8c; }

/* Images embedded in multiple-choice options (e.g. graph A/B/C answer images)
   render smaller than full-width so they don't dominate. Applies to both
   the exam view and the results view. */
.exam-question .choices img,
.result-question .choices img {
  max-width: 50%;
  height: auto;
}

.exam-bottom { display: flex; justify-content: center; margin-top: 2rem; }
.finish-exam-btn {
  padding: 1rem 2.5rem; background: #1b6b34; color: #fff;
  border: 0; border-radius: 6px; font-size: 1.05rem; font-weight: 700; cursor: pointer;
}
.finish-exam-btn:hover { background: #155227; }

/* Results screen */
.exam-score {
  text-align: center; padding: 2rem 1rem;
  background: #e6f4ea; border-radius: 8px; margin-bottom: 1.5rem;
}

/* Small left-aligned green header used for the USAPhO mock solutions view */
.mock-results-header {
  display: inline-block;
  padding: .45rem 1rem;
  background: #e6f4ea;
  color: #1b6b34;
  font-weight: 700;
  font-size: 1.05rem;
  border-radius: 6px;
}
.exam-score h2 { margin: 0; font-size: 2rem; color: #1b6b34; }
.exam-score .sub { color: #555; margin-top: .35rem; }

.result-question {
  border: 1px solid #ddd; border-radius: 6px; padding: 1.25rem;
  margin-bottom: 1.25rem; background: #fff;
}
.result-question.right { border-left: 5px solid #1b6b34; }
.result-question.wrong { border-left: 5px solid #b00020; }
.result-question .choices label.correct {
  background: #e6f4ea; border-color: #1b6b34;
}
.result-question .choices label.user-wrong {
  background: #fde7e9; border-color: #b00020;
}
.result-question .choices label { pointer-events: none; }
.result-question .choices input[type=radio] { display: none; }
.result-question .solution-box {
  margin-top: 1rem; padding: .9rem 1.1rem;
  background: #f6f8fa; border-left: 4px solid #2f5d8c;
  border-radius: 4px; line-height: 1.55;
}
.result-question .solution-box h4 { margin: 0 0 .35rem; color: #2f5d8c; }

/* Force the exam page to stay white even if a global stylesheet (e.g. courses.css)
   set a tinted body background. */
body:has(.exam-wrap) { background: #fff !important; }

.results-top-actions {
  display: flex; align-items: center; justify-content: center;
  gap: 1rem;
  margin: 0 0 1rem;
}
.retake-btn {
  padding: .35rem .7rem;
  background: #2f5d8c; color: #fff; border: 0; border-radius: 4px;
  font-size: .85rem; font-weight: 600; cursor: pointer;
  line-height: 1.2;
}
.retake-btn:hover { background: #244a70; }

/* FRQ-specific styling: no choice list, just stems + a paper-work reminder. */
.exam-paper-reminder {
  background: #fff7e6; border: 1px solid #f0c674; border-radius: 6px;
  padding: .75rem 1rem; margin: 1rem 0 1.5rem;
  font-size: .95rem; color: #5a4500;
}
.exam-question.frq, .result-question.frq { padding-bottom: 1rem; }

/* Bookmark + problem-navigator drawer (in-exam). */
.exam-question { position: relative; padding-right: 3rem; }
.exam-group .exam-question { padding-right: 2.5rem; }
.exam-bm-btn {
  position: absolute; top: .85rem; right: .85rem;
  background: transparent; border: 0; cursor: pointer;
  font-size: 1.35rem; color: #b8a05a; line-height: 1;
  padding: .15rem .35rem; border-radius: 4px;
}
.exam-bm-btn:hover { background: rgba(0,0,0,.05); }
.exam-bm-btn.bookmarked { color: #d4a017; }
.exam-bm-btn:hover { color: #8a6d00; }

.exam-topbar .pset-mini.compact {
  padding: .3rem .6rem; font-size: .85rem; line-height: 1.2;
  background: #e5e7eb; color: #333; border: 0; border-radius: 4px;
  cursor: pointer;
}
.exam-topbar .pset-mini.compact:hover { background: #d1d5db; }

.exam-drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(320px, 90vw);
  background: #fff; border-left: 1px solid #ddd;
  box-shadow: -2px 0 12px rgba(0,0,0,0.08);
  transform: translateX(100%);
  transition: transform .2s ease;
  z-index: 100;
  display: flex; flex-direction: column;
}
.exam-drawer.open { transform: translateX(0); }
.exam-drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .9rem 1rem; border-bottom: 1px solid #eee;
}
.exam-drawer-close {
  background: transparent; border: 0; font-size: 1.4rem;
  color: #666; cursor: pointer; line-height: 1;
}
.exam-drawer-close:hover { color: #000; }
.exam-drawer-list {
  list-style: none; padding: 0; margin: 0;
  overflow-y: auto; flex: 1;
}
.exam-drawer-list li { margin: 0; }
.exam-drawer-list button {
  width: 100%; display: flex; align-items: center; gap: .5rem;
  padding: .5rem 1rem; background: transparent; border: 0;
  border-bottom: 1px solid #f1f2f4; cursor: pointer;
  font-size: .95rem; text-align: left;
}
.exam-drawer-list button:hover { background: #f6f8fa; }
.exam-drawer-list .drawer-num {
  display: inline-block; min-width: 1.8em; font-weight: 600;
}
.exam-drawer-list .drawer-bm {
  margin-left: auto; color: #d4a017; font-weight: 700;
}

/* Custom confirm modal (no "website says" browser chrome). */
.exam-confirm-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 2000; padding: 1rem;
}
.exam-confirm {
  background: #fff; border-radius: 8px;
  padding: 1.5rem 1.75rem 1.25rem;
  max-width: 420px; width: 100%;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.exam-confirm h3 { margin: 0 0 .5rem; font-size: 1.15rem; }
.exam-confirm p  { margin: 0 0 1.25rem; color: #555; font-size: .95rem; line-height: 1.5; }
.exam-confirm-actions { display: flex; gap: .5rem; justify-content: flex-end; }
.exam-confirm-cancel, .exam-confirm-ok {
  padding: .5rem 1rem; border: 0; border-radius: 4px;
  font-size: .95rem; cursor: pointer;
}
.exam-confirm-cancel { background: #e5e7eb; color: #333; }
.exam-confirm-cancel:hover { background: #d1d5db; }
.exam-confirm-ok { background: #2f5d8c; color: #fff; }
.exam-confirm-ok:hover { background: #244a70; }

/* Back-to-course link on the rules (begin) screen — lets users escape on
   tablets/iPads without having to start the exam first. */
.rules-back { display: inline-block; margin-bottom: 1.25rem; }
