/* Meridian Training Institute — demo quiz
   Palette: deep pine teal + warm paper neutrals + amber accent.
   Type: Source Serif 4 (headings) / Public Sans (UI + body). */

:root {
  --bg: #f5f3ec;
  --surface: #ffffff;
  --surface-2: #efece2;
  --ink: #1d2a28;
  --ink-soft: #55635f;
  --border: #e0dccd;
  --primary: #0e5a52;
  --primary-hover: #0b4a44;
  --primary-soft: #e2efec;
  --on-primary: #f7f5f0;
  --accent: #b7791f;
  --good: #1a7f4b;
  --good-soft: #e3f2e9;
  --bad: #b3352c;
  --bad-soft: #f9e9e7;
  --ring-track: #e6e2d4;
  --shadow: 0 1px 2px rgba(29, 42, 40, .06), 0 8px 24px rgba(29, 42, 40, .07);
  --font-head: "Source Serif 4", Georgia, serif;
  --font-body: "Public Sans", -apple-system, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10201d;
    --surface: #182a27;
    --surface-2: #14231f;
    --ink: #e9e5d8;
    --ink-soft: #a3b0a9;
    --border: #26403a;
    --primary: #53c2ae;
    --primary-hover: #6fd4c1;
    --primary-soft: #1b3a34;
    --on-primary: #0c1f1c;
    --accent: #d9a441;
    --good: #4fc785;
    --good-soft: #16332a;
    --bad: #e57368;
    --bad-soft: #3a201d;
    --ring-track: #24382f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, .brand-name { font-family: var(--font-head); font-weight: 600; line-height: 1.25; }

button { font: inherit; cursor: pointer; }
input { font: inherit; }

/* ---------- top bar ---------- */

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: .8rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand { display: flex; align-items: center; gap: .7rem; }
.brand-mark {
  width: 38px; height: 38px;
  border-radius: 9px;
  background: var(--primary);
  color: var(--on-primary);
  font-family: var(--font-head);
  font-size: 1.25rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  flex: none;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-size: 1.02rem; }
.brand-sub {
  font-size: .68rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.demo-badge {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid currentColor;
  border-radius: 99px;
  padding: .2rem .65rem;
  flex: none;
}
.topbar-right { display: flex; align-items: center; gap: .6rem; flex: none; }
.lang-toggle {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: .26rem .8rem;
  font-size: .78rem;
  font-weight: 600;
  color: var(--ink);
  flex: none;
  transition: border-color .15s ease, color .15s ease;
}
.lang-toggle:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- layout ---------- */

#app { flex: 1; width: 100%; max-width: 880px; margin: 0 auto; padding: 2.25rem 1.25rem 3.5rem; }
.view[hidden] { display: none; }

.eyebrow {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .4rem;
}
.page-head h1 { font-size: 1.9rem; margin-bottom: .5rem; }
.lede { color: var(--ink-soft); max-width: 52ch; margin-bottom: 1.75rem; }

/* ---------- buttons ---------- */

.btn {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: .62rem 1.35rem;
  font-weight: 600;
  font-size: .92rem;
  transition: background .15s ease, color .15s ease, border-color .15s ease, transform .1s ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface); border-color: var(--ink-soft); }
.btn-sm { padding: .4rem .85rem; font-size: .82rem; }

/* ---------- gate ---------- */

/* :not([hidden]) keeps this ID rule from outranking .view[hidden]
   (specificity 1-0-0 vs 0-2-0), which previously kept the gate visible
   after a successful unlock. */
#view-gate:not([hidden]) { display: flex; justify-content: center; padding-top: 3vh; }
.gate-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 2.5rem 2.25rem 2.25rem;
  max-width: 460px;
  width: 100%;
  text-align: center;
}
.gate-lock {
  width: 58px; height: 58px;
  margin: 0 auto 1.1rem;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
}
.gate-title { font-size: 1.45rem; margin-bottom: .25rem; }
.gate-desc {
  font-size: .78rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 1rem;
}
.gate-note { font-size: .88rem; color: var(--ink-soft); margin-bottom: 1.5rem; }
.field-label {
  display: block;
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: .4rem;
}
.gate-row { display: flex; gap: .6rem; }
.gate-row input {
  flex: 1;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: .62rem .9rem;
  color: var(--ink);
}
.gate-row input:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent; }
.gate-error { color: var(--bad); font-size: .85rem; margin-top: .8rem; text-align: left; }

.gate-card.shake { animation: shake .35s ease; }
@keyframes shake {
  20% { transform: translateX(-7px); }
  45% { transform: translateX(6px); }
  70% { transform: translateX(-4px); }
  90% { transform: translateX(2px); }
}

/* ---------- module select ---------- */

.module-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(245px, 1fr)); gap: 1rem; }
.module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 1.4rem 1.4rem 1.25rem;
  text-align: left;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: .35rem;
  transition: border-color .15s ease, transform .12s ease;
}
.module-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.module-kicker {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--primary);
}
.module-card h2 { font-size: 1.12rem; }
.module-card .module-sub { font-size: .85rem; color: var(--ink-soft); flex: 1; }
.module-foot {
  margin-top: .8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .78rem;
  color: var(--ink-soft);
}
.best-score { font-weight: 700; }
.best-score.pass { color: var(--good); }
.best-score.fail { color: var(--bad); }
.module-card.final { border-style: dashed; border-color: var(--accent); }
.module-card.final .module-kicker { color: var(--accent); }
.module-card.final:hover { border-style: solid; }

/* ---------- quiz ---------- */

.quiz-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; }
.quiz-meta { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.3; }
.quiz-module-title { font-size: .82rem; font-weight: 600; }
.quiz-counter { font-size: .75rem; color: var(--ink-soft); }

.progress-track { height: 6px; border-radius: 99px; background: var(--ring-track); overflow: hidden; margin-bottom: 1.5rem; }
.progress-fill { height: 100%; width: 0; background: var(--primary); border-radius: 99px; transition: width .25s ease; }

.quiz-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 2rem 2rem 1.75rem;
}
.q-number {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .5rem;
}
.q-text { font-size: 1.28rem; margin-bottom: 1.4rem; }

.choices { display: flex; flex-direction: column; gap: .6rem; }
.choice {
  display: flex;
  align-items: flex-start;
  gap: .8rem;
  width: 100%;
  text-align: left;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 11px;
  padding: .8rem 1rem;
  color: var(--ink);
  font-size: .94rem;
  line-height: 1.5;
  transition: border-color .12s ease, background .12s ease;
}
.choice:hover { border-color: var(--primary); }
.choice .choice-key {
  flex: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--ink-soft);
  color: var(--ink-soft);
  font-size: .78rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  margin-top: .05rem;
}
.choice[aria-checked="true"] {
  border-color: var(--primary);
  background: var(--primary-soft);
}
.choice[aria-checked="true"] .choice-key {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

.quiz-nav { display: flex; justify-content: space-between; margin-top: 1.4rem; }

/* ---------- results ---------- */

.results-hero {
  display: flex;
  align-items: center;
  gap: 2.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 2rem 2.25rem;
  margin-bottom: 2.25rem;
  flex-wrap: wrap;
}
.score-ring-wrap { position: relative; width: 148px; height: 148px; flex: none; }
.score-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg, .ring-val { fill: none; stroke-width: 10; }
.ring-bg { stroke: var(--ring-track); }
.ring-val {
  stroke: var(--primary);
  stroke-linecap: round;
  stroke-dasharray: 326.7;
  stroke-dashoffset: 326.7;
  transition: stroke-dashoffset .9s cubic-bezier(.22, .8, .35, 1);
}
.ring-val.fail { stroke: var(--bad); }
.score-ring-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.score-pct { font-family: var(--font-head); font-size: 2rem; font-weight: 700; }
.score-frac { font-size: .78rem; color: var(--ink-soft); }

.results-summary { flex: 1; min-width: 230px; }
.results-summary h1 { font-size: 1.7rem; margin-bottom: .4rem; }
.results-verdict { color: var(--ink-soft); margin-bottom: 1.2rem; max-width: 44ch; }
.results-verdict strong.pass { color: var(--good); }
.results-verdict strong.fail { color: var(--bad); }
.results-actions { display: flex; gap: .7rem; flex-wrap: wrap; }

.review-heading { font-size: 1.3rem; margin-bottom: 1rem; }
.review-list { display: flex; flex-direction: column; gap: .9rem; }
.review-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--good);
  border-radius: 12px;
  padding: 1.2rem 1.4rem;
}
.review-item.wrong { border-left-color: var(--bad); }
.review-top { display: flex; gap: .75rem; align-items: baseline; margin-bottom: .55rem; }
.review-status {
  flex: none;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  border-radius: 99px;
  padding: .18rem .6rem;
  background: var(--good-soft);
  color: var(--good);
}
.review-item.wrong .review-status { background: var(--bad-soft); color: var(--bad); }
.review-q { font-weight: 600; font-size: .96rem; }
.review-line { font-size: .88rem; margin-top: .2rem; }
.review-line .tag { font-weight: 700; }
.review-line.yours .tag { color: var(--bad); }
.review-line.correct .tag { color: var(--good); }
.review-explain {
  margin-top: .7rem;
  font-size: .87rem;
  color: var(--ink-soft);
  background: var(--surface-2);
  border-radius: 8px;
  padding: .7rem .9rem;
}

/* ---------- footer ---------- */

.footer {
  border-top: 1px solid var(--border);
  padding: 1.1rem 1.25rem 1.4rem;
  text-align: center;
}
.footer p { font-size: .74rem; color: var(--ink-soft); max-width: 640px; margin: 0 auto; }

/* ---------- small screens ---------- */

@media (max-width: 560px) {
  #app { padding-top: 1.5rem; }
  .gate-card, .quiz-card { padding: 1.6rem 1.3rem; }
  .results-hero { padding: 1.6rem 1.3rem; gap: 1.4rem; justify-content: center; text-align: center; }
  .results-summary { text-align: center; }
  .results-actions { justify-content: center; }
  .brand-sub { display: none; }
}
