/* Quantum Disciple web app — shared theme and components.
   Colors are the app's design tokens (QDDesignTokens/Tokens.swift). Dark is the default. */

:root, [data-theme="dark"] {
  --bg: #050F1E; --surface: #0A192F; --raised: #112441; --text: #E6F1FF; --text-2: #A9BCD5;
  --accent: #00CCFF; --on-accent: #03101F; --gold: #C0A062; --live: #00FF99; --live-surface: #12382E;
  --sep: #1E3558; --verse-num: #8FA4C0; --selection: #0D3A57; --disabled: #7D8CA3; --warning: #FFB547; --danger: #FF7A7A;
  --hl-keyVerse: #3A3220; --hl-promise: #123B2E; --hl-command: #16305A; --hl-insight: #3D3312; --hl-question: #2E2448; --hl-prayer: #40202E;
  --gold-grad: linear-gradient(rgb(242, 204, 122), #C0A062, rgb(158, 120, 56));
  --on-gold: #050F1E;
  --glow: 0 0 18px rgba(0, 204, 255, 0.18);
  --gold-glow: 0 0 16px rgba(192, 160, 98, 0.35);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #F6F8FB; --surface: #FFFFFF; --raised: #E9EFF6; --text: #0B1B30; --text-2: #4A5A70;
  --accent: #006A8A; --on-accent: #FFFFFF; --gold: #7A5B1C; --live: #00704A; --live-surface: #DDF3E8;
  --sep: #D3DCE8; --verse-num: #56667C; --selection: #D3ECF6; --disabled: #6B778A; --warning: #8A5A00; --danger: #B3261E;
  --hl-keyVerse: #F4E4B5; --hl-promise: #D3F0E0; --hl-command: #DAE5F8; --hl-insight: #FFF0B3; --hl-question: #E7DEF6; --hl-prayer: #F8DCE5;
  --gold-grad: #7A5B1C; --on-gold: #FFFFFF; --glow: none; --gold-glow: none;
  color-scheme: light;
}
[data-theme="warm"] {
  --bg: #F4ECD8; --surface: #FBF6EA; --raised: #EADFC6; --text: #2E2213; --text-2: #5C4A32;
  --accent: #00667A; --on-accent: #FFFFFF; --gold: #74561A; --live: #2B6637; --live-surface: #DCE9CF;
  --sep: #DCCFB2; --verse-num: #6A563C; --selection: #D8E8E2; --disabled: #72654F; --warning: #7F5200; --danger: #A1281F;
  --hl-keyVerse: #EBD6A0; --hl-promise: #D2E4C5; --hl-command: #D3DCEA; --hl-insight: #F1E09C; --hl-question: #DFD4E9; --hl-prayer: #EDD0D0;
  --gold-grad: #74561A; --on-gold: #FFFFFF; --glow: none; --gold-glow: none;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif; font-size: 16px; line-height: 1.55;
  overflow-x: hidden;
}
h1, h2, h3, h4, .serif { font-family: Georgia, 'Iowan Old Style', 'Times New Roman', serif; font-weight: 600; line-height: 1.25; margin: 0 0 .4em; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.1rem; }
p { margin: 0 0 .8em; }
a { color: var(--accent); }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip { position: absolute; left: -9999px; top: 0; z-index: 1000; background: var(--surface); padding: 8px 12px; }
.skip:focus { left: 8px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Shell ---- */
.app-top {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 94%, transparent); border-bottom: 1px solid var(--sep);
  backdrop-filter: blur(8px);
}
.wordmark { display: inline-flex; flex-direction: column; align-items: center; text-decoration: none; color: var(--gold); font-family: Georgia, serif; line-height: 1.05; }
.wm-the { display: inline-flex; align-items: center; gap: 6px; font-size: .62rem; letter-spacing: .2em; }
.wm-the i { display: inline-block; width: 18px; height: 1px; background: var(--gold); }
.wm-name { font-size: 1.05rem; font-weight: 700; letter-spacing: .04em; }
.site-link { margin-left: 8px; font-size: .78rem; color: var(--text-2); text-decoration: none; border: 1px solid var(--sep); padding: 4px 10px; border-radius: 999px; }
.site-link:hover { color: var(--text); border-color: var(--gold); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.top-btn { background: var(--raised); border: 1px solid var(--sep); border-radius: 999px; padding: 6px 14px; cursor: pointer; font-size: .85rem; font-weight: 600; display: inline-flex; gap: 6px; align-items: center; }
.top-btn:hover { border-color: var(--gold); }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: var(--raised); border: 1px solid var(--sep); color: var(--text); cursor: pointer; text-decoration: none; }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.tabbar { display: grid; grid-template-columns: repeat(6, 1fr); background: var(--surface); border-bottom: 1px solid var(--sep); position: sticky; top: 61px; z-index: 40; }
.tab { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 6px; min-height: 49px; color: var(--text-2); text-decoration: none; font-size: .72rem; font-weight: 600; border-bottom: 2px solid transparent; }
.tab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tab.active { color: var(--gold); border-bottom-color: var(--gold); }
.tab:hover { color: var(--text); }
@media (max-width: 720px) {
  .site-link { display: none; }
  .tabbar { position: fixed; bottom: 0; left: 0; right: 0; top: auto; border-bottom: 0; border-top: 1px solid var(--sep); padding-bottom: env(safe-area-inset-bottom); }
  .tab { border-bottom: 0; border-top: 2px solid transparent; font-size: .66rem; padding: 6px 2px; }
  .tab.active { border-top-color: var(--gold); }
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  body.keyboard-open .tabbar { display: none; }
}

.outlet { max-width: 860px; margin: 0 auto; padding: 20px 16px 40px; outline: none; min-height: 60vh; }
.outlet.wide { max-width: 1100px; }
.app-foot { max-width: 860px; margin: 0 auto; padding: 16px 16px 32px; border-top: 1px solid var(--sep); color: var(--text-2); }
.foot-links { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 10px; }
.foot-links a { color: var(--text-2); font-size: .85rem; }

/* ---- Typography helpers ---- */
.page-head { margin-bottom: 18px; }
.page-head .sub { color: var(--text-2); }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.eyebrow, .sec-label { color: var(--gold); font-family: 'Montserrat', sans-serif; font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; margin: 0 0 6px; }
.sec { margin: 26px 0; }
.sec-label { font-size: .75rem; margin-bottom: 10px; }
.fine { font-size: .78rem; color: var(--text-2); }
.muted { color: var(--text-2); }
.form-error { color: var(--danger); min-height: 1.2em; margin: 0; }

/* ---- Cards ---- */
.card { display: block; background: var(--surface); border: 1px solid var(--sep); border-radius: 14px; padding: 16px; margin: 0 0 12px; color: var(--text); text-align: left; width: 100%; }
.card.glow { border-color: color-mix(in srgb, var(--accent) 45%, transparent); box-shadow: var(--glow); }
.card.gold { border-color: var(--gold); box-shadow: var(--gold-glow); }
.card-link { text-decoration: none; cursor: pointer; font: inherit; transition: border-color .15s, transform .15s; }
.card-link:hover { border-color: var(--accent); }
.card h3 { margin-bottom: .3em; }
.card.premium { border-style: dashed; border-color: var(--gold); }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.grid > .card { margin: 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .9rem; }

/* ---- Buttons & controls ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 18px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; font-weight: 700; font-size: .92rem; text-decoration: none; text-align: center; }
.btn-primary { background: var(--gold-grad); color: var(--on-gold); border-radius: 999px; box-shadow: var(--gold-glow); }
.btn-secondary { background: var(--raised); color: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--sep); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.chip { border: 1px solid var(--sep); background: var(--raised); color: var(--text-2); border-radius: 999px; padding: 5px 12px; font-size: .84rem; cursor: pointer; }
.chip.active { background: var(--gold); color: var(--on-gold); border-color: var(--gold); font-weight: 700; }
.pill { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: .7rem; font-weight: 700; letter-spacing: .04em; vertical-align: middle; }
.tone-gold { background: color-mix(in srgb, var(--gold) 22%, transparent); color: var(--gold); }
.tone-accent { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.tone-live { background: var(--live-surface); color: var(--live); }
.tone-warning { background: color-mix(in srgb, var(--warning) 20%, transparent); color: var(--warning); }
.tone-muted { background: var(--raised); color: var(--text-2); }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], input[type=time], input[type=number], select, textarea {
  width: 100%; background: var(--raised); border: 1px solid var(--sep); border-radius: 10px; padding: 10px 12px; color: var(--text); min-height: 44px;
}
textarea { min-height: 140px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--sep); }
.toggle input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--gold); }

.progress { height: 8px; background: var(--raised); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--gold); border-radius: 999px; }
.stat { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; flex: 1; min-width: 90px; }
.stat strong { font-size: 1.6rem; font-family: Georgia, serif; color: var(--gold); line-height: 1.1; }
.stat span { font-size: .75rem; color: var(--text-2); }

.empty { text-align: center; padding: 28px 16px; color: var(--text-2); border: 1px dashed var(--sep); border-radius: 14px; margin: 12px 0; }
.empty h3 { color: var(--text); }
.empty .row { justify-content: center; }
.error-panel { border: 1px solid var(--warning); background: color-mix(in srgb, var(--warning) 8%, transparent); border-radius: 12px; padding: 14px; margin: 12px 0; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--text-2); padding: 18px 0; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--sep); border-top-color: var(--gold); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } * { transition: none !important; } }

.art { display: grid; place-items: center; border-radius: 12px; flex: none; font-size: 1.6rem; overflow: hidden; }

/* ---- Scripture ---- */
.scripture { font-family: Georgia, 'Iowan Old Style', serif; font-size: 1.08rem; line-height: 1.75; }
.scripture sup, .verse-num { color: var(--verse-num); font-size: .7em; font-family: 'Montserrat', sans-serif; margin-right: 3px; }
.esv-tag { display: inline-block; font-size: .65rem; font-weight: 800; letter-spacing: .08em; color: var(--text-2); border: 1px solid var(--sep); border-radius: 4px; padding: 0 5px; margin-left: 6px; vertical-align: middle; }
.esv-attr { font-size: .74rem; color: var(--text-2); margin-top: 8px; }

/* ---- Sheets & toast ---- */
.sheet-wrap { position: fixed; inset: 0; background: rgba(2, 8, 18, .62); z-index: 200; display: grid; place-items: center; padding: 16px; }
.sheet { background: var(--surface); border: 1px solid var(--sep); border-radius: 16px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; outline: none; box-shadow: 0 20px 60px rgba(0,0,0,.45); }
.sheet.wide { width: min(900px, 100%); }
.sheet-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; background: var(--surface); border-bottom: 1px solid var(--sep); z-index: 1; }
.sheet-head h2 { margin: 0; font-size: 1.15rem; }
.sheet-body { padding: 16px; }
body.sheet-open { overflow: hidden; }
@media (max-width: 720px) { .sheet-wrap { place-items: end center; padding: 0; } .sheet { border-radius: 16px 16px 0 0; max-height: 92vh; } }
#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%) translateY(20px); background: var(--raised); color: var(--text); border: 1px solid var(--gold); border-radius: 999px; padding: 10px 18px; opacity: 0; pointer-events: none; transition: .2s; z-index: 300; max-width: calc(100vw - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%); }

/* ---- Scored quiz (core/quiz.js) ---- */
.quiz-q { border: 1px solid var(--sep); border-radius: 12px; padding: 12px 14px; margin: 0 0 12px; }
.quiz-q legend { font-weight: 600; padding: 0 4px; }
.quiz-opt { display: flex; gap: 10px; align-items: flex-start; padding: 8px; border-radius: 8px; cursor: pointer; }
.quiz-opt:hover { background: var(--raised); }
.quiz-opt input { margin-top: 5px; accent-color: var(--gold); }
.quiz-opt .letter { font-weight: 800; color: var(--gold); min-width: 1.2em; }
.quiz-review .ok { color: var(--live); font-weight: 700; }
.quiz-review .bad { color: var(--danger); font-weight: 700; }
