/* Shared styling for MATH36001 weekly quizzes. Based on the look of examplequiz.html. */

:root {
  color-scheme: light;
  --background: #f4f6f8;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #52606d;
  --border: #cbd2d9;
  --primary: #005eb8;
  --primary-dark: #004785;
  --correct-bg: #e7f6ec;
  --correct-border: #218739;
  --incorrect-bg: #fff0f0;
  --incorrect-border: #c62828;
  --best-bg: #eef4fb;
  --best-border: #005eb8;
  --focus-ring: #b35900;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 24px;
  background: var(--background);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 32px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

h1 {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 2rem;
}

h2 {
  margin-top: 32px;
  margin-bottom: 8px;
  font-size: 1.45rem;
}

h3 {
  margin-top: 0;
  margin-bottom: 8px;
}

a {
  color: var(--primary);
}

a:hover {
  color: var(--primary-dark);
}

a:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

.page-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 20px;
  margin: -8px 0 24px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.page-nav a {
  padding: 4px 0;
  font-weight: 700;
}

.page-nav-bottom {
  margin: 32px 0 -8px;
  padding-top: 14px;
  padding-bottom: 0;
  border-top: 1px solid var(--border);
  border-bottom: 0;
}

.introduction {
  margin-top: 0;
  color: var(--muted);
}

.best-score {
  margin: 0 0 24px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--best-bg);
  border: 1px solid var(--best-border);
  color: var(--text);
  font-size: 0.95rem;
}

.best-score:empty {
  display: none;
}

.quiz-list {
  margin: 16px 0 24px;
  padding-left: 32px;
}

.quiz-list li {
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.quiz-list a {
  font-weight: 700;
  scroll-margin-top: 1rem;
}

.quiz-list-score {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.9rem;
}

.revision-section {
  margin-top: 32px;
  padding-top: 1px;
  border-top: 1px solid var(--border);
}

.revision-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.revision-card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafbfc;
}

.revision-link {
  display: inline-block;
  padding: 9px 12px;
  border: 2px solid var(--primary);
  border-radius: 6px;
  font-weight: 700;
}

.quiz-options {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 32px;
  align-items: center;
  margin: 0 0 24px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fafbfc;
  font-size: 0.9rem;
}

.quiz-options-help {
  flex-basis: 100%;
  margin: 4px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

.option-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
}

.option-group-label {
  font-weight: 700;
  color: var(--muted);
}

.option-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: 6px;
}

.option-inline:hover {
  background: #eef1f4;
}

.option-inline input {
  margin: 0;
}

.quiz-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 8px 0 4px;
}

.quiz-nav[hidden] {
  display: none;
}

.nav-position {
  min-width: 130px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
}

.quiz-nav button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.question-hidden {
  display: none;
}

/* The "Show feedback" toggle only gates the detail (which answer was right, and why) — the
   correct/incorrect colouring and the plain "Correct."/"Incorrect." verdict stay visible either
   way, so a student always knows whether they got a question right. */
.hide-feedback .answer-reveal,
.hide-feedback .explanation {
  display: none;
}

.check-answer {
  display: none;
  margin-top: 12px;
}

.per-question-submit .check-answer {
  display: inline-block;
}

fieldset {
  min-inline-size: 0;
  margin: 24px 0;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

legend {
  max-width: 100%;
  padding: 0 8px;
  font-weight: 700;
  font-size: 1.1rem;
}

/* Let inline maths wrap with the prose. Scroll only when a matrix or
   other indivisible expression is wider than the available line. */
.introduction,
legend,
#quiz-form label,
.explanation,
.feedback {
  overflow-x: auto;
}

label {
  display: block;
  margin: 10px 0;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
}

label:hover {
  background: #f0f4f8;
}

input[type="radio"] {
  margin-right: 8px;
}

.feedback {
  margin: 12px 0 0;
  font-weight: 700;
}

.explanation {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.explanation:empty {
  display: none;
}

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

.incorrect {
  background: var(--incorrect-bg);
  border-color: var(--incorrect-border);
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

button {
  padding: 11px 18px;
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button[type="submit"] {
  background: var(--primary);
  color: white;
}

button[type="submit"]:hover,
button[type="submit"]:focus-visible {
  background: var(--primary-dark);
}

button[type="button"] {
  background: #e4e7eb;
  color: var(--text);
}

button:focus-visible,
input:focus-visible + span {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

#result {
  margin-top: 24px;
  padding: 16px;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 700;
}

#result:empty {
  display: none;
}

@media (max-width: 600px) {
  body {
    padding: 12px;
  }

  main {
    padding: 20px;
  }

  h1 {
    font-size: 1.6rem;
  }

  .revision-options {
    grid-template-columns: 1fr;
  }
}
