/* Quiz demo section + hero "App testen" button.
   Everything is scoped under #demo / .hero-demo-btn so it can't leak into the
   rest of the landing page. App UI values mirror the Flutter theme
   (lib/core/theme/app_colors.dart, app_text_styles.dart, app_spacing.dart). */

/* ── Hero button ─────────────────────────────────────── */
/* Sits in the sticky hero frame (bottom right), so it stays put across all
   four hero cards. Right edge lines up with the hero content (max 1080px). */
.hero-demo-btn {
  position: absolute; z-index: 2;
  right: max(64px, calc((100% - 1080px) / 2 + 64px));
  bottom: 34px;
  display: inline-flex; align-items: center; gap: 8px;
  background: #fff; color: var(--brand);
  font-family: var(--font-ui); font-size: 16px; font-weight: 600;
  padding: 14px 28px; border-radius: 100px;
  text-decoration: none;
  box-shadow: 0 8px 28px rgba(10, 13, 18, .18);
  transition: transform .2s, box-shadow .2s;
}
.hero-demo-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 32px rgba(10, 13, 18, .24); }
.hero-demo-btn:focus-visible { outline: 3px solid rgba(255,255,255,.6); outline-offset: 3px; }
@media (max-width: 860px) {
  .hero-demo-btn { right: 20px; bottom: 14px; font-size: 15px; padding: 11px 20px; }
}

/* ── Section layout ──────────────────────────────────── */
#demo {
  /* Phone size follows the window height, leaving room for the floating nav,
     so the whole phone is visible once the hero button scrolls here. */
  --phone-w: min(380px, calc((100svh - 196px) * .4736));
  /* Light brand tint so the section stands apart from the grey Grootbos
     section above and the white Partners section below. */
  background: #F2FAF6;
  padding: 96px 64px;
  overflow: hidden;
  scroll-margin-top: 0;
}
#demo .qd-layout {
  max-width: 1040px; margin: 0 auto;
  display: grid; grid-template-columns: minmax(0, 1fr) var(--phone-w);
  gap: 72px; align-items: center;
}
#demo .qd-layout > * { min-width: 0; }
#demo .qd-copy p { margin-top: 18px; font-size: 17px; line-height: 1.65; color: var(--text-tertiary); max-width: 44ch; }
#demo .qd-steps { margin-top: 28px; display: grid; gap: 12px; list-style: none; padding: 0; }
#demo .qd-steps li { display: flex; gap: 12px; align-items: center; font-size: 15px; color: var(--text-secondary); line-height: 1.5; }
#demo .qd-steps b { flex: none; width: 28px; height: 28px; border-radius: 50%; background: #fff; border: 1px solid #D4EDE1; color: var(--brand); display: grid; place-items: center; font-size: 13px; }
@media (max-width: 860px) {
  #demo { padding: 72px 20px; }
  #demo .qd-layout { grid-template-columns: minmax(0, 1fr); gap: 36px; justify-items: center; }
  #demo .qd-copy { text-align: center; }
  #demo .qd-copy p { margin-inline: auto; }
  #demo .qd-steps { display: none; }
}

/* ── Phone frame ─────────────────────────────────────── */
/* The phone is drawn once at true iPhone 15 proportions (393×852 pt screen,
   thin bezel + metal rim) and scaled as a whole by quiz-demo.js, so it looks
   like a real phone at every size instead of squeezing its insides. */
#demo .qd-phone-wrap { position: relative; width: min(var(--phone-w), 100%); aspect-ratio: 413 / 872; }
#demo .qd-phone {
  position: absolute; top: 0; left: 0;
  width: 413px; height: 872px;
  transform-origin: 0 0; transform: scale(var(--qd-scale, 1));
  padding: 3px; border-radius: 68px;
  background: linear-gradient(150deg, #6e6e73 0%, #2c2c2e 22%, #1c1c1e 60%, #5a5a5f 100%);
  box-shadow: 0 50px 90px -40px rgba(13,27,62,.55), 0 18px 36px -24px rgba(13,27,62,.35);
}
/* side buttons */
#demo .qd-phone::before, #demo .qd-phone::after { content: ""; position: absolute; width: 4px; border-radius: 2px; background: #3a3a3c; }
#demo .qd-phone::before { left: -3px; top: 170px; height: 64px; box-shadow: 0 86px 0 #3a3a3c; }
#demo .qd-phone::after { right: -3px; top: 220px; height: 100px; }
#demo .qd-bezel { height: 100%; padding: 7px; border-radius: 65px; background: #000; }
#demo .qd-screen { position: relative; height: 100%; border-radius: 58px; overflow: hidden; background: #F8F5F0; display: flex; flex-direction: column; }
#demo .qd-island { position: absolute; top: 11px; left: 50%; transform: translateX(-50%); width: 124px; height: 36px; border-radius: 20px; background: #000; z-index: 5; }
#demo .qd-statusbar { flex: none; height: 54px; display: flex; justify-content: space-between; align-items: center; padding: 6px 34px 0 46px; font: 600 17px -apple-system, 'SF Pro Text', system-ui, sans-serif; letter-spacing: -.2px; color: #000; }
#demo .qd-statusbar svg { display: block; }

/* ── App UI ──────────────────────────────────────────── */
#demo .qd-app { flex: 1; display: flex; flex-direction: column; min-height: 0; font-family: 'Nunito', sans-serif; color: #1A1A2E; }
#demo .qd-appbar { flex: none; height: 52px; display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; padding: 0 8px; }
#demo .qd-appbar h3 { grid-column: 2; text-align: center; font-size: 18px; font-weight: 800; color: #16213E; margin: 0; }
#demo .qd-progress { flex: none; margin: 8px 16px 0; height: 6px; border-radius: 12px; background: #E8E0D8; overflow: hidden; }
#demo .qd-progress span { display: block; height: 100%; background: #2D8653; transition: width .35s ease; }
#demo .qd-scroll { flex: 1; overflow-y: auto; padding: 16px; min-height: 0; scrollbar-width: none; overscroll-behavior: contain; }
#demo .qd-scroll::-webkit-scrollbar { display: none; }
#demo .qd-card-tinted { background: #F2FAF6; border: 1px solid #D4EDE1; border-radius: 20px; padding: 20px; }
#demo .qd-q { font-size: 18px; font-weight: 800; line-height: 1.5; color: #1B5E3B; margin: 0; }
#demo .qd-answers { margin-top: 16px; display: grid; gap: 12px; }
#demo .qd-answer { width: 100%; text-align: left; display: flex; align-items: center; gap: 8px; background: #fff; border: 1.5px solid #E8E0D8; border-radius: 16px; padding: 16px; font: 400 17px/1.5 'Nunito', sans-serif; color: #1A1A2E; box-shadow: 0 2px 8px rgba(26,26,46,.024); transition: background .25s ease, border-color .25s ease, transform .1s ease; }
#demo .qd-answer span { flex: 1; }
#demo .qd-answer:active:not(:disabled) { transform: scale(.98); }
#demo .qd-answer:disabled { box-shadow: none; }
#demo .qd-answer.is-correct { background: #D4EDE1; border: 2px solid #2D8653; color: #1B5E3B; padding: 15.5px; }
#demo .qd-answer.is-wrong { background: #FED7D7; border: 2px solid #E53E3E; color: #E53E3E; padding: 15.5px; }
#demo .qd-answer svg { flex: none; }
#demo .qd-card-flat { margin-top: 8px; background: #FDFAF5; border: 1px solid #E8E0D8; border-radius: 20px; padding: 16px; animation: qd-fade .3s ease; }
#demo .qd-fb-head { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; }
#demo .qd-fb-text { margin: 8px 0 0; font-size: 15px; line-height: 1.5; color: #718096; }
#demo .qd-bottom { flex: none; padding: 12px 16px 28px; }
#demo .qd-btn { width: 100%; height: 56px; border: 0; border-radius: 16px; background: linear-gradient(135deg, #3A9E63, #1B5E3B); box-shadow: 0 6px 16px rgba(45,134,83,.27); color: #fff; font: 700 17px/1.2 'Nunito', sans-serif; letter-spacing: .2px; display: flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; transition: transform .1s ease, opacity .2s; }
#demo .qd-btn:active { transform: scale(.97); }
#demo .qd-btn:disabled { opacity: .5; }
#demo .qd-ghost { width: 100%; height: 48px; border: 0; background: none; color: #2D8653; font: 700 17px 'Nunito', sans-serif; }
#demo .qd-btn:focus-visible, #demo .qd-ghost:focus-visible, #demo .qd-answer:focus-visible { outline: 3px solid rgba(45,134,83,.45); outline-offset: 2px; }

/* Result screen */
#demo .qd-result { display: flex; flex-direction: column; align-items: center; text-align: center; }
#demo .qd-res-icon { width: 80px; height: 80px; border-radius: 50%; display: grid; place-items: center; margin-top: 8px; }
#demo .qd-res-title { margin: 16px 0 0; font-size: 28px; font-weight: 800; line-height: 1.2; }
#demo .qd-res-text { margin: 8px 0 0; font-size: 17px; line-height: 1.6; color: #4A5568; }
#demo .qd-card-elev { width: 100%; margin-top: 20px; background: #fff; border: 1px solid #E8E0D8; border-radius: 20px; padding: 20px; box-shadow: 0 4px 16px rgba(26,26,46,.03), 0 1px 4px rgba(26,26,46,.016); }
#demo .qd-card-elev + .qd-card-elev { margin-top: 16px; }
#demo .qd-res-pct { font-size: 38px; font-weight: 800; line-height: 1.15; color: #2D8653; font-variant-numeric: tabular-nums; }
#demo .qd-res-sub { font-size: 15px; line-height: 1.5; color: #718096; margin: 0; }
#demo .qd-impact { text-align: left; }
#demo .qd-impact h4 { font-size: 22px; font-weight: 800; color: #16213E; margin: 0; }
#demo .qd-meals { margin-top: 12px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
#demo .qd-meals i { height: 8px; border-radius: 8px; background: #E8E0D8; }
#demo .qd-meals i.on { background: #2D8653; }

/* Knowie overlay (mirrors KnowieOverlay) */
#demo .qd-knowie { position: absolute; inset: 0; z-index: 4; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; padding: 0 16px 24px; animation: qd-fade .3s ease; }
#demo .qd-knowie-box { display: flex; flex-direction: column; align-items: center; width: 100%; animation: qd-slide .4s cubic-bezier(.2,.8,.2,1); }
#demo .qd-knowie-box img { height: 150px; width: auto; }
#demo .qd-bubble { margin-top: 12px; width: 100%; padding: 16px; border-radius: 24px; border: 2px solid #2D8653; background: #D4EDE1; font: 400 16px/1.5 'Nunito', sans-serif; color: #1A1A2E; text-align: left; }
#demo .qd-bubble.is-motivation { background: #FED7D7; border-color: #E53E3E; }
#demo .qd-bubble small { display: block; margin-top: 6px; text-align: right; font-size: 12px; font-weight: 600; color: #2D8653; }
#demo .qd-bubble.is-motivation small { color: #E53E3E; }
#demo canvas.qd-confetti { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
@keyframes qd-fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes qd-slide { from { transform: translateY(40px); opacity: 0 } to { transform: none; opacity: 1 } }

@media (prefers-reduced-motion: reduce) {
  #demo *, .hero-demo-btn { animation: none !important; transition: none !important; }
}

/* "try it here" hint under the phone, styled like the step list */
#demo .qd-hint { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); white-space: nowrap; margin-top: 18px; text-align: center; font-size: 15px; color: var(--text-secondary); line-height: 1.5; }
@media (max-width: 860px) { #demo .qd-hint { margin-top: 14px; white-space: normal; width: 100%; } }
