/* styles.css — look and feel for the exam simulator.
   Arabic RTL, calm and readable, works on a phone too. */

:root {
  --color-primary: #1f6feb;
  --color-correct: #1a7f37;
  --color-correct-bg: #dafbe1;
  --color-wrong: #cf222e;
  --color-wrong-bg: #ffebe9;
  --color-flag: #d4a72c;
  --color-border: #d0d7de;
  --color-text: #1f2328;
  --color-muted: #57606a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, "Geeza Pro", Arial, sans-serif;
  font-size: 18px;
  color: var(--color-text);
  background: #f6f8fa;
  line-height: 1.6;
}

#app {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px;
}

h1, h2, h3 {
  margin: 0 0 12px 0;
}

/* ---- Big home buttons ---- */
.home-title {
  text-align: center;
  font-size: 24px;
  margin-bottom: 24px;
}

.big-button {
  display: block;
  width: 100%;
  min-height: 64px;
  margin-bottom: 12px;
  padding: 10px 16px;
  font-size: 20px;
  font-family: inherit;
  color: #fff;
  background: var(--color-primary);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  text-align: center;
}

.big-button:disabled {
  background: #8c959f;
  cursor: not-allowed;
}

.big-button-sub {
  display: block;
  font-size: 14px;
  font-weight: normal;
  opacity: 0.9;
  margin-top: 4px;
}

/* ---- Stats box on home screen ---- */
.stats-box {
  margin-top: 20px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  font-size: 15px;
  color: var(--color-muted);
}

/* ---- Option buttons (answer choices) ---- */
.option-button {
  display: block;
  width: 100%;
  min-height: 52px;
  margin-bottom: 10px;
  padding: 10px 16px;
  font-size: 18px;
  font-family: inherit;
  text-align: right;
  background: #fff;
  border: 2px solid var(--color-border);
  border-radius: 10px;
  cursor: pointer;
}

.option-button.selected {
  border-color: var(--color-primary);
  background: #eef5ff;
}

.option-button.correct {
  border-color: var(--color-correct);
  background: var(--color-correct-bg);
  color: var(--color-correct);
}

.option-button.wrong {
  border-color: var(--color-wrong);
  background: var(--color-wrong-bg);
  color: var(--color-wrong);
}

.option-button:disabled {
  cursor: default;
}

/* Picture options render as a 2x2 grid. */
.option-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.option-grid .option-button {
  padding: 8px;
}

.option-image {
  display: block;
  max-width: 100%;
  max-height: 120px;
  margin: 0 auto;
  object-fit: contain;
  background: #fff;
}

/* ---- Question card ---- */
.question-card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}

.question-image {
  display: block;
  max-height: 180px;
  max-width: 100%;
  margin: 0 auto 16px auto;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 6px;
}

.sign-image-missing {
  text-align: center;
  color: var(--color-muted);
  padding: 24px;
  border: 1px dashed var(--color-border);
  border-radius: 6px;
  margin-bottom: 16px;
}

/* ---- Top bar (exam + practice) ---- */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 16px;
}

.timer {
  font-weight: bold;
}

.timer.low-time {
  color: var(--color-wrong);
}

.small-button {
  padding: 8px 14px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  border: 2px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
}

.small-button.flagged {
  border-color: var(--color-flag);
  color: var(--color-flag);
}

/* ---- Nav row (previous / next) ---- */
.nav-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.nav-row .small-button {
  flex: 1;
}

/* ---- Question number grid (jump to any question) ---- */
.number-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 16px;
}

.number-cell {
  min-height: 36px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  border: 2px solid var(--color-border);
  border-radius: 6px;
  cursor: pointer;
}

.number-cell.answered {
  background: #eef5ff;
  border-color: var(--color-primary);
}

.number-cell.flagged {
  border-color: var(--color-flag);
}

.number-cell.current {
  font-weight: bold;
  border-width: 3px;
}

/* ---- Result screen ---- */
.result-percent {
  font-size: 48px;
  text-align: center;
  margin-bottom: 8px;
}

.result-status {
  font-size: 22px;
  text-align: center;
  margin-bottom: 8px;
}

.result-status.pass {
  color: var(--color-correct);
}

.result-status.fail {
  color: var(--color-wrong);
}

.result-fraction {
  text-align: center;
  color: var(--color-muted);
  margin-bottom: 24px;
}

.review-item {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}

.review-answer-line {
  margin: 4px 0;
}

.review-answer-line.correct {
  color: var(--color-correct);
}

.review-answer-line.wrong {
  color: var(--color-wrong);
}

.explain-box {
  margin-top: 8px;
  padding: 10px;
  background: #f6f8fa;
  border-radius: 6px;
  font-size: 15px;
  color: var(--color-muted);
}

/* ---- Practice feedback bar ---- */
.practice-score {
  text-align: center;
  margin-bottom: 16px;
  font-size: 16px;
  color: var(--color-muted);
}

/* ---- Chapter picker (practice) ---- */
.chapter-button {
  display: flex;
  justify-content: space-between;
  width: 100%;
  min-height: 52px;
  margin-bottom: 10px;
  padding: 10px 16px;
  font-size: 17px;
  font-family: inherit;
  background: #fff;
  border: 2px solid var(--color-border);
  border-radius: 10px;
  cursor: pointer;
  text-align: right;
}

.chapter-count {
  color: var(--color-muted);
  font-size: 14px;
}

/* ---- Summary cards ---- */
.summary-card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
}

.summary-card ul {
  margin: 8px 0 0 0;
  padding-inline-start: 20px;
}

.back-button {
  margin-top: 16px;
}

/* Title and legend above the question number grid in the mock exam. */
.grid-title { margin-top: 18px; font-weight: bold; font-size: 16px; }
.grid-legend { margin: 4px 0 8px; font-size: 14px; color: #57606a; }

/* Simple exam: live score line and the big right/wrong message. */
.exam-score-line { margin: 10px 0; font-size: 16px; font-weight: bold; text-align: center; }
.exam-verdict { margin: 12px 0; padding: 12px; border-radius: 10px; font-size: 22px; font-weight: bold; text-align: center; }
.exam-verdict.pass { background: #dafbe1; color: #1a7f37; }
.exam-verdict.fail { background: #ffebe9; color: #cf222e; }

/* ---- Small phones (under 480px wide) ---- */
@media (max-width: 480px) {
  body { font-size: 16px; }
  #app { padding: 10px; }
  .home-title { font-size: 20px; margin-bottom: 16px; }
  .big-button { min-height: 56px; font-size: 18px; }
  .option-button { font-size: 16px; padding: 10px 12px; }
  .option-image { max-height: 90px; }
  .question-card { padding: 12px; }
  .question-image { max-height: 140px; }
  .top-bar { flex-wrap: wrap; gap: 8px; font-size: 14px; }
  .number-grid { grid-template-columns: repeat(6, 1fr); }
  .number-cell { min-height: 40px; }
  .result-percent { font-size: 40px; }
}

/* Stop iOS from zooming text after rotating the phone. */
html { -webkit-text-size-adjust: 100%; }
button { touch-action: manipulation; }
