@import url("../../../assets/css/theme.css");

/* ---------- quiz header ---------- */
.quiz-head { margin: 12px 0 28px; }
.quiz-head h1 { font-size: 28px; line-height: 1.25; margin: 0 0 4px; letter-spacing: -0.01em; }
.quiz-path { margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.quiz-intro { color: var(--muted); font-size: 15px; }
.quiz-intro p { margin: 0 0 8px; }
.quiz-summary { font-size: 14px; font-weight: 600; margin: 12px 0 0; }

/* ---------- markdown content ---------- */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 12px; }
.md ul, .md ol { margin: 0 0 12px; padding-left: 24px; }
.md li { margin: 4px 0; }
.md blockquote { margin: 0 0 12px; padding: 4px 14px; border-left: 3px solid var(--border); color: var(--muted); }
.md table { border-collapse: collapse; margin: 0 0 12px; font-size: 14px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-2); }
.md h1, .md h2, .md h3, .md h4 { font-size: 16px; margin: 16px 0 8px; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.md pre { background: var(--surface-2); padding: 10px 12px; border-radius: 8px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md details > summary { cursor: pointer; }

/* ---------- question cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin: 0 0 22px;
  scroll-margin-top: calc(var(--bar-h) + 16px);
  transition: opacity 0.25s, border-color 0.25s, box-shadow 0.25s;
}
.running .card:not(.active) { opacity: 0.5; }
.running .card:not(.active):hover,
.running .card:not(.active):focus-within { opacity: 1; }
.card.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.card.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 6px var(--warn-soft); border-color: var(--warn); } 100% { box-shadow: var(--shadow); } }

.card-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.badge {
  flex: none;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 9px;
  border-radius: 999px;
  margin-top: 2px;
}
.card-title { flex: 1; font-size: 18px; line-height: 1.35; margin: 0; letter-spacing: -0.005em; }
.chip {
  flex: none;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  background: var(--surface-2);
  padding: 3px 9px;
  border-radius: 999px;
  margin-top: 3px;
  white-space: nowrap;
}
.card.active .chip { color: var(--accent); background: var(--accent-soft); }
.card[data-status="done"] .chip { color: var(--ok); background: var(--ok-soft); }
.card[data-status="timeup"] .chip { color: var(--warn); background: var(--warn-soft); }
.start-here {
  flex: none;
  appearance: none;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  padding: 3px 4px;
  margin-top: 3px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
.card:hover .start-here, .start-here:focus-visible { opacity: 1; }
.start-here:hover { color: var(--accent); }
.card.active .start-here { display: none; }
@media (hover: none) { .start-here { opacity: 1; } }

.prompt { font-size: 16.5px; margin-bottom: 16px; }

.response textarea {
  display: block;
  width: 100%;
  min-height: 120px;
  resize: vertical;
  font: inherit;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  transition: border-color 0.15s, background 0.15s;
}
.response textarea:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.response-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin: 6px 2px 0; }
.saved-note { opacity: 0; transition: opacity 0.3s; }
.saved-note.show { opacity: 1; }

details.answer { margin-top: 14px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
details.answer > summary {
  list-style: none;
  cursor: pointer;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}
details.answer > summary::-webkit-details-marker { display: none; }
details.answer > summary::before {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s;
}
details.answer > summary:hover { color: var(--accent); }
details.answer[open] { border-color: var(--answer-border); background: var(--answer-bg); }
details.answer[open] > summary { color: var(--accent); }
details.answer[open] > summary::before { transform: rotate(45deg); }
.answer-body { padding: 2px 16px 14px; font-size: 15px; }
.answer-actions { padding: 12px 16px 14px; border-top: 1px solid var(--answer-border); }
.answer-actions .btn { white-space: normal; text-align: left; }
.answer-actions p { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.no-answer { font-size: 13px; color: var(--muted); margin: 12px 0 0; }

/* ---------- section notes (study-guide headings) ---------- */
.note { margin: 34px 0 16px; }
.note h2 { font-size: 22px; margin: 0 0 6px; }
.note h3 { font-size: 17px; margin: 0 0 6px; color: var(--muted); }
.note .md { color: var(--muted); font-size: 15px; }

/* ---------- end of quiz ---------- */
.quiz-end { text-align: center; padding: 28px 0 0; border-top: 1px solid var(--border); margin-top: 36px; }
.end-summary { font-size: 18px; font-weight: 650; margin: 0 0 16px; }
.end-summary:empty { display: none; }
.end-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.end-note { font-size: 13px; color: var(--muted); margin-top: 14px; }

/* ---------- home ---------- */
.home-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 24px 0 4px; }
.home h1 { font-size: 30px; margin: 0; }
.lede { color: var(--muted); margin: 0 0 28px; }
.quiz-group h2 { font-size: 13px; letter-spacing: 0.02em; color: var(--muted); margin: 26px 0 8px; font-weight: 650; }
.quiz-group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.quiz-group a {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 16px;
  transition: border-color 0.15s, transform 0.15s;
}
.quiz-group a:hover { border-color: var(--accent); }
.qz-title { font-weight: 600; }
.qz-meta { font-size: 13px; color: var(--muted); }
.local-open { margin-top: 32px; }

.error { background: var(--danger-soft); color: var(--danger); padding: 12px 16px; border-radius: 10px; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  max-width: calc(100% - 32px);
  background: var(--text);
  color: var(--bg);
  font-size: 14px;
  font-weight: 550;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- study landing ---------- */
.topic-group h2 { font-size: 13px; letter-spacing: 0.02em; color: var(--muted); margin: 26px 0 8px; font-weight: 650; }

/* Quiz 2 scope overlay. The header stays visible while the outline scrolls. */
body:has(.scope-dialog[open]) { overflow: hidden; }
.scope-dialog {
  width: min(760px, calc(100% - 32px));
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.scope-dialog[open] { display: flex; flex-direction: column; }
.scope-dialog::backdrop { background: rgb(0 0 0 / 0.6); }
.scope-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.scope-header h2 { margin: 0; font-size: 20px; }
.scope-header .icon-btn { padding: 12px; }
.scope-content { padding: 0 20px 24px; overflow-y: auto; overscroll-behavior: contain; }
.scope-content section + section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.scope-content h3 { margin: 20px 0 8px; font-size: 18px; }
.scope-content h4 { margin: 16px 0 8px; font-size: 15px; }
.scope-content p { margin: 16px 0; }
.scope-content ul { margin: 0; padding-left: 24px; }
.scope-content li + li { margin-top: 4px; }
.topic-list { display: grid; gap: 8px; }
.upcoming { margin-top: 28px; }
.topic {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 11px 16px;
}
.topic-title { display: flex; flex-direction: column; min-width: 200px; flex: 1; }
.topic-num { font-size: 13px; color: var(--muted); }
.topic-name { font-weight: 600; }
.topic-links { display: flex; gap: 8px; }
.topic-links .btn { text-decoration: none; display: inline-block; }
a.btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }
a.btn { text-decoration: none; display: inline-block; text-align: center; }
button.topic-title { appearance: none; background: none; border: 0; padding: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.topic-details { flex-basis: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 14px; color: var(--muted); }
.topic-details[hidden] { display: none; }
.topic-details .btn { font-size: 13px; padding: 4px 12px; }
.feedback { margin-top: 48px; text-align: center; font-size: 14px; font-style: italic; font-weight: 300; color: var(--muted); }
.study-resources { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.credited-resource { position: relative; display: flex; width: fit-content; }
.credit-ref { position: absolute; top: 0; right: 0; transform: translate(50%, -50%); display: inline-flex; align-items: center; justify-content: center; min-width: 24px; min-height: 24px; border: 2px solid var(--bg); border-radius: 50%; color: var(--on-accent); background: var(--accent); text-decoration: none; }
.credit-ref sup { font-size: 11px; font-weight: 650; line-height: 1; }
.credit-ref:hover, .credit-ref:focus-visible { filter: brightness(1.15); }
/* smaller badge for the compact buttons under a lesson or reading; its ring matches the row behind it */
.credited-resource.small .credit-ref { min-width: 18px; min-height: 18px; border-color: var(--surface); }
.credited-resource.small .credit-ref sup { font-size: 10px; }
.topic:hover .credited-resource.small .credit-ref { border-color: var(--surface-2); }
.credits { margin-bottom: 24px; font-size: 13px; font-style: normal; font-weight: 400; }
.credits h2 { margin: 0 0 6px; font-size: 13px; font-weight: 650; }
.credits p { margin: 0; padding: 6px 8px; border-radius: 6px; }
.credits p:target { color: var(--text); background: var(--accent-soft); }
.privacy-note { margin: 12px 0 0; font-size: 12px; font-style: normal; }
button.topic-title { flex-direction: row; align-items: center; gap: 10px; }
.topic-quiz-bottom .topic-title { min-width: 0; }
.topic-quiz-bottom .topic-title .chev { order: 1; margin-left: auto; }
.topic-text { display: flex; flex-direction: column; }
.chev { flex: none; width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.15s, stroke 0.15s; }
.topic { transition: border-color 0.15s, background 0.15s; }
.topic:hover { border-color: var(--accent); background: var(--surface-2); }
.topic:hover .chev { stroke: var(--accent); }
.topic-title[aria-expanded="true"] .chev { transform: rotate(90deg); stroke: var(--accent); }
.topic:has(.topic-title[aria-expanded="true"]) { border-color: var(--accent); }

/* ---------- lesson notes ---------- */
.notes-bar { grid-template-columns: 1fr auto; }
.file-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 20px; }
.file-tabs[hidden] { display: none; }
.file-tabs .btn[aria-selected="true"] { border-color: var(--accent); color: var(--accent); }
.note-card { margin-bottom: 28px; }
.note-card .card-title { margin: 0 0 12px; font-weight: 600; }
.notes-md { font-size: 15.5px; overflow-wrap: anywhere; }
.notes-md img { max-width: 100%; height: auto; }
.notes-table-scroll { max-width: 100%; overflow-x: auto; margin: 0 0 12px; }
.notes-md .notes-table-scroll table {
  display: table;
  width: 100%;
  min-width: 600px;
  margin: 0;
  overflow-wrap: normal;
}
.notes-md pre { max-width: 100%; overflow-wrap: normal; margin: 0 0 12px; }
.notes-md :is(h1, h2, h3, h4, h5, h6) {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.35;
  margin: 22px 0 12px;
  color: var(--text);
}
.notes-md ul ul, .notes-md ol ul, .notes-md ul ol { margin-bottom: 0; }
.notes-md em { color: var(--muted); }
.notes-md > :first-child { margin-top: 0; }
.notes-md .recall-footer { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); }
/* Questions without preceding notes use the same card without a notes divider. */
.notes-md > .recall-footer:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.questions-hidden .recall-footer { display: none; }
.notes-md .recall-question { margin: 0 0 16px; font-weight: 400; }
.notes-md .recall-answer > summary {
  display: list-item;
  cursor: pointer;
  color: var(--accent);
  font-weight: 600;
}
.notes-md .recall-answer > summary:hover { text-decoration: underline; }
.notes-md .recall-answer > summary:focus-visible,
.notes-table-scroll:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 2px;
}
.notes-md .recall-answer[open] > summary { margin-bottom: 12px; }
.notes-md .recall-answer > :last-child:not(summary) { margin-bottom: 0; }

/* ---------- flash cards ---------- */
.fc-score { display: flex; flex-direction: column; align-items: center; font-variant-numeric: tabular-nums; }
.fc-score[hidden] { display: none; }
.fc-score strong { font-size: 20px; }
.fc-score-counts { font-size: 12px; color: var(--muted); white-space: nowrap; }
.flashcard { padding: 16px 20px; margin-bottom: 14px; }
.flashcard .card-head { align-items: center; margin-bottom: 0; }
.flashcard .badge { margin-top: 0; min-width: 30px; text-align: center; }
.flashcard .answer-body p { margin: 0; }
.fc-label { font-size: 13px; font-weight: 650; color: var(--muted); margin: 12px 0 2px; }
.fc-label:first-child { margin-top: 4px; }
.fc-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 20px; border-top: 0; }
.fc-actions .fc-got-it[aria-pressed="true"] { color: var(--ok-soft); border-color: var(--ok); background: var(--ok); }
.fc-actions .fc-not-yet[aria-pressed="true"] { color: var(--danger-soft); border-color: var(--danger); background: var(--danger); }
