/* ---------- Theme variables ---------- */
:root {
  --bg: #faf6ef;            /* cream */
  --card: #fdf8f0;
  --text: #1a1a1a;
  --muted: #444444;
  --nav: #0f304d;           /* navy */
  --nav-2: #082033;
  --border: #e1d4bf;
  --shadow: rgba(0, 0, 0, 0.12);
  --button: #0f304d;
  --button-hover: #082033;
  --pill: 999px;
  --radius: 12px;

  --ok: #166534;
  --bad: #b91c1c;
  --warn: #92400e;

  --progress-track: rgba(15, 48, 77, 0.14);
  --progress-fill: #0f304d;
}

html[data-theme="dark"] {
  --bg: #07121c;
  --card: #0b1b2a;
  --text: #f3f7ff;
  --muted: rgba(243, 247, 255, 0.82);
  --nav: #0a2236;
  --nav-2: #061524;
  --border: rgba(255, 255, 255, 0.12);
  --shadow: rgba(0, 0, 0, 0.4);
  --button: #113a5d;
  --button-hover: #0b2a44;

  --progress-track: rgba(255, 255, 255, 0.14);
  --progress-fill: rgba(243, 247, 255, 0.85);
}

/* ---------- Base reset ---------- */
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg);
  color: var(--text);
}

/* ---------- Top brand bar ---------- */
.topbar {
  background: var(--nav);
  color: #ffffff;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  max-width: 960px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
}

.brand-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.brand-tagline {
  font-size: 0.8rem;
  opacity: 0.9;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #ffffff;
  border-radius: var(--pill);
  padding: 8px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.icon-label {
  font-size: 0.85rem;
  opacity: 0.95;
}

/* ---------- Page container ---------- */
.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
}

/* ---------- Hero section ---------- */
.hero {
  text-align: center;
  margin-bottom: 24px;
}

.hero h1 {
  margin: 8px 0 4px;
  font-size: 1.8rem;
  color: var(--nav);
}

.hero-subtitle {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
}

/* ---------- Video section ---------- */
.video-section {
  text-align: center;
  margin-bottom: 32px;
}

.video-section h2 {
  margin-bottom: 10px;
  color: var(--nav);
}

.video-wrapper {
  max-width: 900px;
  margin: 0 auto;
  border-radius: 8px;
  background: #000000;
  box-shadow: 0 10px 26px var(--shadow);
}

.video-wrapper video {
  width: 100%;
  max-width: 900px;
  height: auto;
  display: block;
  border-radius: 8px;
}

/* ---------- Resources section ---------- */
.resources {
  text-align: center;
  margin-bottom: 32px;
}

.resources h2 {
  margin-bottom: 16px;
  color: var(--nav);
}

.button-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.button {
  display: inline-block;
  min-width: 190px;
  padding: 12px 20px;
  background: var(--button);
  color: #ffffff;
  text-decoration: none;
  border-radius: var(--pill);
  font-weight: 800;
  font-size: 0.9rem;
  transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
  text-align: center;
}

.button:hover {
  background: var(--button-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 14px var(--shadow);
}

/* ---------- Resourceful Tools ---------- */
.tools {
  margin-bottom: 40px;
  text-align: center;
}

.tools h2 {
  margin-bottom: 8px;
  color: var(--nav);
}

.tools-intro {
  max-width: 720px;
  margin: 0 auto 20px;
  font-size: 0.95rem;
  color: var(--muted);
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.tool-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  text-align: left;
  box-shadow: 0 6px 14px var(--shadow);
}

.tool-card h3 {
  margin: 0 0 6px;
  font-size: 1rem;
  color: var(--text);
}

.tool-use {
  margin: 0 0 10px;
  font-size: 0.88rem;
  color: var(--muted);
}

.tool-link {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--nav);
  text-decoration: none;
}

.tool-link:hover {
  text-decoration: underline;
}

.tools-note {
  margin-top: 16px;
  font-size: 0.82rem;
  color: var(--muted);
}

/* ---------- Quiz section ---------- */
.quiz-section {
  margin: 0 auto 40px;
  padding: 18px 14px 20px;
  background-color: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 10px 26px var(--shadow);
}

.quiz-card { width: 100%; }

.quiz-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.quiz-section h2 {
  margin-top: 0;
  margin-bottom: 6px;
  font-size: 1.4rem;
  color: var(--nav);
  text-align: left;
}

.quiz-intro {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: var(--muted);
  max-width: 680px;
}

.quiz-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--pill);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
}

.select-label {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 800;
}

select {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  padding: 6px 8px;
  font-weight: 800;
}

/* Progress */
.progress-row {
  margin: 10px 0 14px;
}

.progress-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.88rem;
}

.progress-bar {
  margin-top: 8px;
  width: 100%;
  height: 12px;
  border-radius: var(--pill);
  background: var(--progress-track);
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--progress-fill);
  border-radius: var(--pill);
  transition: width 0.2s ease;
}

/* Question blocks */
.quiz-question {
  margin: 0 0 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(227, 216, 197, 0.7);
}

html[data-theme="dark"] .quiz-question {
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}

.quiz-question:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}

.quiz-question h3 {
  margin: 0 0 10px;
  font-size: 1.02rem;
  color: var(--text);
}

/* =========================================================
   ✅ READABILITY UPGRADE (matches your JS-generated markup)
   - Your JS creates: fieldset.q-card > legend.q-title + div.q-choices > label.choice > span.choice-text
   - This block fixes the “hard to read” problem without changing HTML/JS.
   ========================================================= */

fieldset.q-card {
  /* remove default fieldset box + weird inset */
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 16px 14px;
  margin: 0 0 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.16), rgba(255,255,255,0.06));
  box-shadow: 0 8px 22px var(--shadow);
}

html[data-theme="dark"] fieldset.q-card {
  background: rgba(255,255,255,0.03);
  border-color: rgba(255,255,255,0.12);
}

/* legend styling is the #1 readability lever */
legend.q-title {
  /* legend defaults can be brutal: this fixes it */
  float: none;
  width: 100%;
  padding: 0;
  margin: 0 0 12px;
  font-weight: 950;
  font-size: 1.12rem;
  line-height: 1.45;
  color: var(--text);
  letter-spacing: 0.1px;
}

html[data-theme="dark"] legend.q-title {
  color: rgba(243, 247, 255, 0.95);
}

/* choice list spacing */
.q-choices {
  display: grid;
  gap: 10px;
}

/* answer option “cards” */
label.choice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.10);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.18s ease, background 0.18s ease;
}

label.choice:hover {
  box-shadow: 0 8px 18px var(--shadow);
  transform: translateY(-1px);
}

html[data-theme="dark"] label.choice {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.12);
}

/* radio alignment */
label.choice input[type="radio"] {
  margin-top: 3px;
}

/* answer text: bump size + line-height */
.choice-text {
  font-size: 0.98rem;
  line-height: 1.48;
  color: var(--text);
}

html[data-theme="dark"] .choice-text {
  color: rgba(243, 247, 255, 0.92);
}

/* selected / correct / wrong signals (high-contrast but not neon) */
label.choice.selected {
  background: rgba(15, 48, 77, 0.10);
  border-color: rgba(15, 48, 77, 0.45);
}

html[data-theme="dark"] label.choice.selected {
  background: rgba(243, 247, 255, 0.08);
  border-color: rgba(243, 247, 255, 0.28);
}

label.choice.correct {
  background: rgba(22, 101, 52, 0.10);
  border-color: rgba(22, 101, 52, 0.55);
}

label.choice.wrong {
  background: rgba(185, 28, 28, 0.10);
  border-color: rgba(185, 28, 28, 0.55);
}

/* explanation box (JS creates div.explain) */
.explain {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.10);
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--muted);
}

html[data-theme="dark"] .explain {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.12);
  color: rgba(243, 247, 255, 0.82);
}

/* make the red pulse jump-to animation visible on the full card */
fieldset.q-card.pulse {
  animation: pulse 0.8s ease-out;
}

/* =========================================================
   END READABILITY UPGRADE
   ========================================================= */

.quiz-options {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.quiz-option-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
}

.quiz-option-label:hover {
  box-shadow: 0 6px 14px var(--shadow);
}

.quiz-option-label input[type="radio"] {
  margin-top: 2px;
}

.quiz-feedback {
  margin-top: 10px;
  font-size: 0.92rem;
  line-height: 1.35;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
}

.quiz-feedback.correct { border-color: rgba(22, 101, 52, 0.45); }
.quiz-feedback.incorrect { border-color: rgba(185, 28, 28, 0.45); }
.quiz-feedback.neutral { border-color: rgba(146, 64, 14, 0.45); }

.quiz-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

button.primary,
button.secondary {
  border: none;
  border-radius: var(--pill);
  padding: 12px 16px;
  font-weight: 900;
  cursor: pointer;
}

button.primary {
  background: var(--button);
  color: #ffffff;
}

button.primary:hover { background: var(--button-hover); }

button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

button.secondary:hover {
  box-shadow: 0 6px 14px var(--shadow);
}

button.small {
  padding: 10px 12px;
  font-weight: 900;
  font-size: 0.88rem;
}

.quiz-summary {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  font-weight: 900;
}

/* Missed questions summary */
.missed-block {
  margin-top: 10px;
}

.missed-title {
  font-weight: 900;
  margin-bottom: 6px;
}

.missed-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.missed-chip {
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 900;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  cursor: pointer;
}

.missed-chip:hover {
  box-shadow: 0 6px 14px var(--shadow);
}

/* Subtle attention pulse */
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(185,28,28,0.6); }
  100% { box-shadow: 0 0 0 14px rgba(185,28,28,0); }
}

.pulse {
  animation: pulse 0.8s ease-out;
}

.quiz-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---------- Footer ---------- */
footer {
  text-align: center;
  padding: 14px 10px 18px;
  font-size: 0.8rem;
  color: var(--muted);
  background-color: var(--bg);
}

footer a {
  color: var(--nav);
  text-decoration: none;
  font-weight: 900;
}

footer a:hover { text-decoration: underline; }

/* ---------- Responsive tweaks ---------- */
@media (max-width: 900px) {
  .hero h1 { font-size: 1.6rem; }
  .page { padding: 12px; }
}

@media (max-width: 600px) {
  .brand { justify-content: flex-start; }

  .brand-logo { width: 32px; height: 32px; }
  .brand-name { font-size: 0.9rem; }
  .brand-tagline { font-size: 0.75rem; }

  .hero h1 { font-size: 1.35rem; }

  .button-row {
    flex-direction: column;
    align-items: stretch;
  }

  .button {
    width: 100%;
    max-width: 320px;
    margin: 4px auto;
  }

  .quiz-section { padding: 16px 12px 18px; }

  /* mobile readability bump */
  legend.q-title {
    font-size: 1.05rem;
    line-height: 1.5;
  }
  .choice-text {
    font-size: 0.98rem;
    line-height: 1.5;
  }
}

/* ---------- Dark mode readability fixes ---------- */
html[data-theme="dark"] .hero h1,
html[data-theme="dark"] .video-section h2,
html[data-theme="dark"] .resources h2,
html[data-theme="dark"] .tools h2,
html[data-theme="dark"] .quiz-section h2,
html[data-theme="dark"] footer a,
html[data-theme="dark"] .tool-link {
  color: rgba(243, 247, 255, 0.92);
}

html[data-theme="dark"] .select-label,
html[data-theme="dark"] .progress-meta,
html[data-theme="dark"] .hero-subtitle,
html[data-theme="dark"] .tools-intro,
html[data-theme="dark"] .tools-note,
html[data-theme="dark"] .quiz-intro,
html[data-theme="dark"] footer {
  color: rgba(243, 247, 255, 0.82);
}

/* Dropdown readability in dark mode */
html[data-theme="dark"] select {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

html[data-theme="dark"] option {
  background: #0b1b2a;
  color: #f3f7ff;
}

/* ---------- Print styles (for "Download PDF Results") ---------- */
@media print {
  .topbar,
  .video-section,
  .resources,
  .tools,
  .quiz-actions,
  .quiz-controls,
  .quiz-note,
  footer {
    display: none !important;
  }

  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  .quiz-section {
    box-shadow: none !important;
    border: 1px solid #cccccc !important;
    background: #ffffff !important;
  }

  .quiz-feedback,
  .explain,
  fieldset.q-card {
    border: 1px solid #dddddd !important;
    background: #ffffff !important;
    box-shadow: none !important;
    color: #000 !important;
  }

  legend.q-title {
    color: #000 !important;
  }
}

/* ---------- Consultation CTA ---------- */
.consult-btn {
  background: var(--button);
  color: #ffffff;
  padding: 8px 14px;
  border-radius: var(--pill);
  font-weight: 800;
  font-size: 0.85rem;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.25);
  transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
}

.consult-btn:hover {
  background: var(--button-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* Dark mode clarity */
html[data-theme="dark"] .consult-btn {
  color: #ffffff;
}

/* ---------- Collapsible sections (Tools + Quiz) ---------- */
.collapsible[hidden] {
  display: none !important;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.section-close {
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 10px;
  cursor: pointer;
  font-weight: 900;
}

.section-close:hover {
  box-shadow: 0 6px 14px var(--shadow);
}

/* Make button elements look like your .button links */
button.button {
  border: none;
  cursor: pointer;
}

/* Prevent iOS zoom weirdness on selects */
select {
  font-size: 16px;
}

