/* ============================================================
   Bible Quiz — styles
   Mobile-first, responsive, light + dark themes.
   ============================================================ */

:root {
  --bg: #f4f1ea;
  --bg-card: #ffffff;
  --bg-elev: #faf8f3;
  --text: #24303b;
  --text-soft: #5c6b78;
  --border: #e2ddd1;
  --brand: #7b5e3b;        /* warm scripture-brown */
  --brand-2: #b08a52;      /* gold accent */
  --accent: #2f6f6b;       /* teal for actions */
  --accent-dark: #245652;
  --correct: #2e8b57;
  --correct-bg: #e3f4e9;
  --wrong: #c0392b;
  --wrong-bg: #fbe6e3;
  --shadow: 0 6px 20px rgba(40, 44, 40, 0.08);
  --radius: 16px;
}

:root[data-theme="dark"] {
  --bg: #171a1f;
  --bg-card: #1f242b;
  --bg-elev: #262c34;
  --text: #e8eaed;
  --text-soft: #a2abb5;
  --border: #333b45;
  --brand: #cda877;
  --brand-2: #d9b477;
  --accent: #3fa39a;
  --accent-dark: #348a82;
  --correct: #4cc47f;
  --correct-bg: #1d3a2a;
  --wrong: #e57368;
  --wrong-bg: #3a2320;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Header / footer ---------- */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; max-width: 820px; margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.25rem; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; font-size: 1.1rem;
}
.brand-name { letter-spacing: .2px; }

.icon-btn {
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text);
  width: 40px; height: 40px; border-radius: 10px; font-size: 1.15rem; cursor: pointer;
  transition: transform .1s ease, background .2s ease;
}
.icon-btn:hover { transform: translateY(-1px); }

.site-footer {
  max-width: 820px; margin: 30px auto; padding: 0 20px 40px;
  text-align: center; color: var(--text-soft); font-size: .85rem;
}
.site-footer p { margin: 4px 0; }
.muted { opacity: .8; }
code { background: var(--bg-elev); padding: 1px 6px; border-radius: 6px; font-size: .82rem; }

.container { max-width: 820px; margin: 0 auto; padding: 8px 20px; }

/* ---------- Book-specific landing content & cross-links ---------- */
.sample-q {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px; margin: 0 0 18px; box-shadow: var(--shadow);
}
.sample-q-head { margin: 0 0 8px; font-weight: 700; font-size: .95rem; }
.sample-q ul { margin: 0; padding-left: 20px; color: var(--text-soft); }
.sample-q li { margin: 4px 0; }
.book-links { margin: 8px 0 18px; text-align: left; }
.book-links h2 { font-size: 1rem; margin: 0 0 10px; color: var(--text); }
.book-links-list { display: flex; flex-wrap: wrap; gap: 8px 14px; justify-content: center; }
.book-links-list a {
  color: var(--accent); text-decoration: none; font-size: .9rem; font-weight: 600;
}
.book-links-list a:hover { text-decoration: underline; }

/* ---------- Ads ---------- */
.ad-slot {
  max-width: 820px; margin: 10px auto; padding: 0 20px;
  display: flex; align-items: center; justify-content: center;
}
.ad-placeholder {
  width: 100%; min-height: 90px;
  display: grid; place-items: center;
  border: 1px dashed var(--border); border-radius: 12px;
  color: var(--text-soft); font-size: .8rem; letter-spacing: .1em; text-transform: uppercase;
  background: repeating-linear-gradient(45deg, transparent, transparent 12px,
              rgba(120,120,120,.04) 12px, rgba(120,120,120,.04) 24px);
}
.ad-rect .ad-placeholder { min-height: 120px; }

/* ---------- Screens & panels ---------- */
.screen { animation: fade .35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none; } }

.title { font-size: 1.8rem; margin: 10px 0 6px; }
.perks {
  list-style: none; margin: 0 0 14px; padding: 0;
  display: flex; flex-wrap: wrap; gap: 6px 18px;
}
.perks li { display: flex; align-items: center; gap: 7px; font-weight: 600; font-size: .95rem; }
.perks li::before { content: "✔"; color: var(--correct); font-weight: 800; }
.welcome { color: var(--text-soft); margin: 0 0 16px; font-size: 1.02rem; line-height: 1.55; }
.welcome strong { color: var(--brand); }
.stat-line {
  margin: 0 0 12px; padding: 10px 14px; border-radius: 12px;
  background: color-mix(in srgb, var(--brand-2) 12%, var(--bg-card));
  border: 1px solid var(--border); color: var(--text);
  font-size: .95rem; line-height: 1.45;
}
.stat-line strong { color: var(--brand); font-weight: 800; }

/* ---------- Library growth tracker ---------- */
.library {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; margin: 0 0 20px; box-shadow: var(--shadow);
}
.library-head {
  display: flex; align-items: baseline; justify-content: space-between;
  flex-wrap: wrap; gap: 4px 12px; margin-bottom: 10px;
}
.library-title { font-weight: 700; font-size: 1.02rem; }
.library-count { font-size: .95rem; color: var(--text-soft); white-space: nowrap; }
.library-count strong { color: var(--brand); font-weight: 800; }
.library-track {
  height: 14px; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: 999px; overflow: hidden;
}
.library-fill {
  height: 100%; width: 0;
  background: linear-gradient(90deg, var(--brand-2), var(--accent));
  border-radius: 999px; transition: width 1s ease;
  min-width: 6px;
}
.library-note { margin: 10px 0 0; font-size: .8rem; color: var(--text-soft); }

.subtitle { color: var(--text-soft); margin: 0 0 20px; }

.panel {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.panel h2 { font-size: 1.05rem; margin: 0 0 12px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }
.mini-actions { display: flex; gap: 12px; }
.link-btn {
  background: none; border: none; color: var(--accent); cursor: pointer;
  font-size: .85rem; font-weight: 600; padding: 0;
}
.link-btn:hover { text-decoration: underline; }
.hint { color: var(--text-soft); font-size: .82rem; margin: 10px 0 0; }

/* ---------- Book checkboxes ---------- */
.book-groups { display: flex; flex-direction: column; gap: 16px; }
.book-group-title {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--brand-2); font-weight: 700; margin-bottom: 8px;
}
.book-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px;
}
.book-check {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-elev); font-size: .92rem; transition: border-color .15s, background .15s;
  user-select: none;
}
.book-check:hover { border-color: var(--brand-2); }
.book-check input { accent-color: var(--accent); width: 17px; height: 17px; cursor: pointer; }
.book-check.checked { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--bg-elev)); }
.book-count { margin-left: auto; color: var(--text-soft); font-size: .78rem; white-space: nowrap; }
.book-count.complete { color: var(--correct); font-weight: 700; }

/* ---------- Chips (difficulty / amount) ---------- */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--border); background: var(--bg-elev); color: var(--text);
  padding: 9px 16px; border-radius: 999px; cursor: pointer; font-size: .92rem; font-weight: 500;
  transition: all .15s ease;
}
.chip:hover { border-color: var(--brand-2); }
.chip.is-active {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}

/* ---------- Timer toggle ---------- */
.switch { position: relative; display: inline-block; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  display: block; width: 50px; height: 28px; border-radius: 999px;
  background: var(--border); transition: background .2s ease; position: relative;
}
.switch-thumb {
  position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; transition: transform .2s ease; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track .switch-thumb { transform: translateX(22px); }

.timer-controls { margin-top: 14px; transition: opacity .2s ease; }
.timer-controls.is-off { opacity: .4; pointer-events: none; }
.timer-controls label { display: block; font-size: .9rem; margin-bottom: 10px; }
#timerValue { font-weight: 700; color: var(--accent); }
input[type="range"] { width: 100%; accent-color: var(--accent); }

/* ---------- Buttons ---------- */
.primary-btn {
  width: 100%; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark)); color: #fff;
  padding: 15px; border-radius: 12px; font-size: 1.05rem; font-weight: 700;
  box-shadow: var(--shadow); transition: transform .1s ease, filter .2s ease;
}
.primary-btn:hover { filter: brightness(1.06); }
.primary-btn:active { transform: translateY(1px); }
.ghost-btn {
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text);
  padding: 14px 20px; border-radius: 12px; font-size: .98rem; font-weight: 600; cursor: pointer;
  transition: border-color .15s;
}
.ghost-btn:hover { border-color: var(--wrong); color: var(--wrong); }

.error-msg { color: var(--wrong); font-weight: 600; text-align: center; margin-top: 12px; }

/* ---------- Quiz screen ---------- */
.quiz-topbar { display: flex; align-items: center; gap: 16px; margin: 6px 0 18px; }
.progress-wrap { flex: 1; }
.progress-meta { display: flex; justify-content: space-between; font-size: .85rem; color: var(--text-soft); margin-bottom: 6px; font-weight: 600; }
#scoreLabel { color: var(--accent); }
.progress-track { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--brand-2), var(--accent)); border-radius: 999px; transition: width .4s ease; }

.timer-ring { position: relative; width: 44px; height: 44px; flex-shrink: 0; }
.timer-ring svg { transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--border); stroke-width: 4; }
.ring-fg { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round;
  stroke-dasharray: 119.4; stroke-dashoffset: 0; transition: stroke-dashoffset 1s linear, stroke .3s; }
.timer-ring.low .ring-fg { stroke: var(--wrong); }
.timer-num { position: absolute; inset: 0; display: grid; place-items: center; font-size: .85rem; font-weight: 700; }
.timer-ring.low .timer-num { color: var(--wrong); }

.question-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
}
.q-meta {
  display: inline-block; font-size: .72rem; text-transform: uppercase; letter-spacing: .1em;
  font-weight: 700; color: var(--brand-2); background: var(--bg-elev);
  padding: 4px 10px; border-radius: 999px; margin-bottom: 12px;
}
.question-text { font-size: 1.3rem; line-height: 1.4; margin: 0 0 20px; }

.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  text-align: left; border: 1.5px solid var(--border); background: var(--bg-elev);
  color: var(--text); padding: 15px 16px; border-radius: 12px; cursor: pointer;
  font-size: 1rem; display: flex; align-items: center; gap: 12px;
  transition: border-color .12s, background .12s, transform .06s;
}
.option:hover:not(:disabled) { border-color: var(--accent); transform: translateX(2px); }
.option:disabled { cursor: default; }
.option .opt-letter {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
  background: var(--bg-card); border: 1px solid var(--border); font-weight: 700; font-size: .8rem;
}
.option.correct { border-color: var(--correct); background: var(--correct-bg); color: var(--correct); font-weight: 600; }
.option.correct .opt-letter { background: var(--correct); border-color: var(--correct); color: #fff; }
.option.wrong { border-color: var(--wrong); background: var(--wrong-bg); color: var(--wrong); font-weight: 600; }
.option.wrong .opt-letter { background: var(--wrong); border-color: var(--wrong); color: #fff; }

.feedback {
  margin-top: 18px; padding: 15px 16px; border-radius: 12px;
  background: var(--bg-elev); border: 1px solid var(--border);
  animation: fade .3s ease;
}
.feedback-verdict { font-weight: 700; margin: 0 0 4px; }
.feedback.ok .feedback-verdict { color: var(--correct); }
.feedback.no .feedback-verdict { color: var(--wrong); }
.feedback-ref { font-weight: 600; color: var(--brand); margin: 0 0 4px; font-size: .92rem; }
.feedback-note { color: var(--text-soft); margin: 0; font-style: italic; font-size: .95rem; }
.feedback-ref:empty, .feedback-note:empty { display: none; }

.quiz-actions { display: flex; gap: 12px; margin-top: 18px; }
.quiz-actions .ghost-btn { flex-shrink: 0; }
.quiz-actions .primary-btn { flex: 1; }

/* ---------- Results ---------- */
.results-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 30px 24px; box-shadow: var(--shadow); text-align: center;
}
.results-emoji { font-size: 3.2rem; line-height: 1; }
.results-card .title { margin: 10px 0 16px; }
.score-big { font-size: 3.4rem; font-weight: 800; color: var(--accent); line-height: 1; }
.score-total { font-size: 1.6rem; color: var(--text-soft); font-weight: 600; }
.score-ring-pct { font-size: 1.1rem; font-weight: 700; color: var(--brand-2); margin-top: 4px; }
.results-message { color: var(--text-soft); margin: 14px auto 20px; max-width: 440px; }
.results-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }

@media (min-width: 560px) {
  .title { font-size: 2.1rem; }
  .results-actions { flex-direction: row; }
  .results-actions .primary-btn { flex: 1; }
}
