/* AQ Kids - Shared Stylesheet */
:root {
  --bg: #F0F4F8;
  --card: #FAFCFF;
  --ink: #0A1628;
  --text: #0A1628;       /* alias for --ink */
  --muted: #5A7090;
  --line: #C8D8E8;
  --accent: #1B4F9C;
  --accent-bg: #EBF1FB;
  --purple: #7B2FBE;
  --purple-bg: #F4EEFB;
  --gold: #D97706;
  --gold-bg: #FEF3C7;
  --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Consolas, monospace;
  --r: 14px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--sans); background: var(--bg); color: var(--ink);
  line-height: 1.7; -webkit-tap-highlight-color: transparent; padding-bottom: 80px;
}

/* --- Typography --- */
h1 { font-family: var(--serif); font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; margin-bottom: 16px; }
h2 { font-size: 20px; font-weight: 700; margin-bottom: 12px; }
h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 8px; }
p { font-size: 16px; color: #2A4060; line-height: 1.8; margin-bottom: 16px; }
p:last-child { margin-bottom: 0; }

/* --- Layout --- */
.wrap { max-width: 700px; margin: 0 auto; padding: 0 18px; }

/* --- Topbar --- */
.topbar, .top-nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(240,244,248,.93); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 11px 18px; display: flex; align-items: center; justify-content: space-between;
}
.nav-brand {
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
  text-decoration: none;
}
.nav-links { display: flex; align-items: center; gap: 14px; }
.nav-link  { font-size: 13px; color: var(--muted); text-decoration: none; }
.nav-link:hover { color: var(--accent); }
.topbar-brand { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-step { font-family: var(--mono); font-size: 11px; color: var(--accent); font-weight: 700; }

/* --- Cards --- */
.card {
  background: var(--card); border: 1.5px solid var(--line);
  border-radius: var(--r); padding: 26px; margin-bottom: 20px;
  animation: fadeIn .35s ease;
}
.card-flush { padding: 0; overflow: hidden; }

/* --- Buttons --- */
.btn {
  appearance: none; cursor: pointer; border: none;
  background: var(--accent); color: #fff;
  font-family: var(--sans); font-weight: 700; font-size: 15px;
  padding: 14px 20px; border-radius: 10px;
  width: 100%; display: block; text-align: center;
  transition: filter .15s, transform .08s;
  margin-bottom: 10px; text-decoration: none; line-height: 1;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: scale(.99); }
.btn-outline { background: transparent; border: 2px solid var(--accent); color: var(--accent); }
.btn-outline:hover { background: var(--accent-bg); }
.btn-ghost { background: transparent; border: 1.5px solid var(--line); color: var(--muted); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-gold { background: var(--gold); }
.btn-dark { background: #0A1628; }
.btn-sm { padding: 10px 16px; font-size: 14px; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-grid .btn { margin-bottom: 0; }
.btn-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.btn-grid-3 .btn { margin-bottom: 0; padding: 11px 8px; font-size: 13px; }

/* --- Form --- */
label { font-weight: 700; font-size: 14px; display: block; margin-bottom: 6px; color: var(--ink); }
.label-hint { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 6px; }
input[type="text"], input[type="email"], textarea {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--line); border-radius: 8px;
  font-family: var(--sans); font-size: 15px;
  background: var(--bg); color: var(--ink);
  transition: border-color .2s; margin-bottom: 18px;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { height: 76px; resize: vertical; }

/* --- Hero / Landing --- */
.hero {
  padding: 52px 18px 36px;
  max-width: 700px; margin: 0 auto;
}
.hero-eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--accent); font-weight: 700; margin-bottom: 16px; }
.hero h1 { font-size: 34px; margin-bottom: 18px; }
.hero p { font-size: 17px; line-height: 1.85; }

/* --- Character Grid --- */
.char-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 24px 0;
}
@media (min-width: 480px) { .char-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 640px) { .char-grid { grid-template-columns: repeat(4, 1fr); } }

.char-card {
  background: var(--card); border: 2px solid var(--line); border-radius: 12px;
  padding: 20px 14px 16px; text-align: center; cursor: pointer;
  transition: all .2s; position: relative; overflow: hidden;
}
.char-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--char-color, var(--accent));
}
.char-card:hover { border-color: var(--char-color, var(--accent)); transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.07); }
.char-card.selected { border-color: var(--char-color, var(--accent)); background: var(--accent-bg); }
.char-card.selected .char-check { display: flex; }
.char-check {
  display: none; position: absolute; top: 8px; right: 8px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--char-color, var(--accent)); color: #fff;
  align-items: center; justify-content: center; font-size: 11px; font-weight: 700;
}
.char-card.disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }
.char-emoji { font-size: 30px; margin-bottom: 8px; display: block; }
.char-name { font-size: 13px; font-weight: 700; color: var(--ink); line-height: 1.3; }
.char-short { font-size: 11px; color: var(--muted); margin-top: 4px; line-height: 1.3; }

/* --- Parent Config: Question Nodes --- */
.char-section-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; background: var(--card);
  border: 1.5px solid var(--line); border-radius: 12px 12px 0 0;
  border-bottom: none; margin-bottom: 0;
}
.char-section-body { border: 1.5px solid var(--line); border-radius: 0 0 12px 12px; padding: 0 0 8px; margin-bottom: 24px; }

.node-wrap { padding: 20px 20px 24px; border-bottom: 1px solid var(--line); }
.node-wrap:last-child { border-bottom: none; }
.node-label { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); font-weight: 700; margin-bottom: 12px; }
.node-story {
  font-family: var(--serif); font-size: 14px; line-height: 1.85;
  color: var(--ink); background: var(--bg); border-radius: 8px;
  padding: 14px 16px; margin-bottom: 14px;
  border-left: 3px solid var(--accent);
}

/* --- Image Selector --- */
.img-selector { display: flex; gap: 10px; margin-bottom: 14px; }
.img-opt {
  flex: 1; border: 2px solid var(--line); border-radius: 8px;
  overflow: hidden; cursor: pointer; transition: all .2s;
  height: 70px; position: relative;
}
.img-opt img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-opt-label {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(10,22,40,.6); color: #fff;
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  padding: 3px 6px; text-align: center;
}
.img-opt.selected { border-color: var(--accent); }
.img-opt.selected::after {
  content: '✓'; position: absolute; top: 4px; right: 4px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* --- Answer Option (Parent) --- */
.answer-opt {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 14px; border-radius: 8px;
  background: #fff; border: 1px solid var(--line);
  margin-bottom: 8px; cursor: pointer; transition: all .2s;
  font-size: 14px; line-height: 1.5; color: var(--ink);
}
.answer-opt:hover { border-color: var(--accent); }
.answer-opt input[type="checkbox"] { margin-top: 2px; cursor: pointer; accent-color: var(--accent); }
.answer-opt.locked { background: var(--purple-bg); border-color: var(--purple); cursor: default; }
.answer-opt.locked input { accent-color: var(--purple); }
.answer-opt-meta { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.score-pill { font-family: var(--mono); font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 20px; white-space: nowrap; }
.score-pill.locked { background: var(--purple-bg); color: var(--purple); }
.score-pill.normal { background: var(--bg); color: var(--muted); }

/* --- Validation warning --- */
.val-warn { color: #C0392B; font-size: 13px; margin-top: 6px; display: none; }

/* --- Link/Share Panel --- */
.share-panel {
  background: var(--accent-bg); border: 1.5px solid var(--accent);
  border-radius: 12px; padding: 22px; margin-top: 24px;
  animation: fadeIn .4s ease;
}
.share-panel h3 { color: var(--accent); }
.link-box {
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 14px; font-family: var(--mono); font-size: 11px;
  word-break: break-all; color: var(--muted); margin-bottom: 16px;
  max-height: 72px; overflow: hidden;
}
.qr-img { display: block; width: 120px; height: 120px; margin: 0 auto 16px; border-radius: 8px; border: 1px solid var(--line); }

/* --- Child Test View --- */
.story-img {
  width: 100%; height: 200px; object-fit: cover; border-radius: 12px;
  margin-bottom: 20px; background: var(--line); display: block;
}
.story-text {
  font-family: var(--serif); font-size: 16px; line-height: 1.9;
  color: var(--ink); margin-bottom: 24px;
}
.q-block {
  background: var(--card); border: 1.5px solid var(--accent);
  border-radius: 12px; overflow: hidden; margin-bottom: 24px;
}
.q-header {
  background: var(--accent); color: #fff;
  font-family: var(--mono); font-size: 11px; letter-spacing: .1em;
  text-transform: uppercase; padding: 9px 16px;
  display: flex; justify-content: space-between; align-items: center;
}
.q-body { padding: 20px; }
.q-text { font-family: var(--serif); font-size: 17px; line-height: 1.5; margin-bottom: 18px; color: var(--ink); }
.choice {
  display: block; width: 100%; text-align: left; appearance: none;
  background: var(--bg); border: 1.5px solid var(--line);
  padding: 14px 16px; border-radius: 10px; margin-bottom: 10px;
  cursor: pointer; font-family: var(--sans); font-size: 15px;
  line-height: 1.5; color: var(--ink); transition: all .2s;
}
.choice:hover { border-color: var(--accent); background: #fff; transform: translateX(4px); }
.choice.chosen { background: var(--accent); color: #fff; border-color: var(--accent); pointer-events: none; }
.choice:disabled { pointer-events: none; }

/* --- Progress Bar --- */
.progress-wrap { margin: 16px 0 24px; }
.progress-label { font-family: var(--mono); font-size: 11px; color: var(--muted); margin-bottom: 6px; text-align: right; }
.progress-track { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width .5s ease; }

/* --- Results --- */
.result-hero { text-align: center; padding: 36px 0 24px; }
.result-score { font-family: var(--serif); font-size: 80px; font-weight: 700; line-height: 1; color: var(--ink); }
.result-score-label { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-top: 6px; }
.result-level { font-size: 22px; font-weight: 700; margin-top: 12px; color: var(--accent); }
.aq-bar-bg { height: 10px; background: var(--line); border-radius: 5px; overflow: hidden; margin: 16px 0 28px; }
.aq-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent) 0%, var(--purple) 100%); width: 0; transition: width 1.6s cubic-bezier(.22,1,.36,1); }

.parent-msg {
  background: var(--purple-bg); border: 1.5px solid var(--purple);
  border-radius: 12px; padding: 24px; margin: 24px 0;
}
.parent-msg-from { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--purple); margin-bottom: 10px; }
.parent-msg-text { font-family: var(--serif); font-size: 18px; line-height: 1.7; color: var(--ink); font-style: italic; }

.aq-tips { background: var(--accent-bg); border: 1px solid var(--line); border-radius: 12px; padding: 22px; margin-bottom: 20px; }
.aq-tips ul { padding-left: 20px; font-size: 15px; color: #2A4060; line-height: 1.9; }

.coffee-box {
  background: var(--gold-bg); border: 1.5px solid var(--gold);
  border-radius: 12px; padding: 22px; text-align: center; margin: 24px 0;
}
.coffee-box p { color: #92400E; font-size: 14px; line-height: 1.7; margin-bottom: 14px; }
.coffee-emoji { font-size: 40px; display: block; margin-bottom: 10px; }

/* --- Modal --- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(10,22,40,.5);
  z-index: 200; display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal {
  background: var(--card); border: 1.5px solid var(--line); border-radius: 16px;
  padding: 28px; max-width: 400px; width: 100%;
  animation: fadeIn .2s ease;
}
.modal h2 { margin-bottom: 10px; }
.modal p { font-size: 15px; margin-bottom: 20px; }

/* --- Utility --- */
.hidden { display: none !important; }
.anim-fade { animation: fadeIn .4s ease; }
.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 13px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0 !important; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.divider { height: 1px; background: var(--line); margin: 24px 0; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (max-width: 480px) {
  h1 { font-size: 24px; }
  .hero h1 { font-size: 28px; }
  .result-score { font-size: 64px; }
  .story-img { height: 160px; }
}
