/* The Routine Quiz (tools/routine-quiz.js), on /tools/routine-quiz and embedded on the home page (#routine-quiz).
   v3 "Dusk editorial" (docs/site-v3/README.md). The quiz is one self-contained paper card (.rq-shell, or the no-JS
   .rq-fallback), so it reads the same on whatever surface holds it, night or paper. Inside: hairline answer cards, a
   quest board you can tick, and the recommendation on a night panel. Lamplight marks what's done and what opens.
   Everything is scoped under .rq-*; the page frame (.quiz-*) is at the end. No inline styles (the CSP forbids them). */

.rq-wrap {
  --bg: var(--card-paper); --fg: var(--ink); --fg-2: var(--ink-2); --fg-3: var(--ink-3);
  --hair: var(--line); --hair-2: var(--line-2); --edge: #958670; --link: var(--ember-ink); --accent: var(--ember);
  --rq-tint: #FCEBD8; --rq-lit: #FFF4E6;
  color: var(--ink-2); text-align: left; color-scheme: light;
}

/* ------------------------------------------------------------------ the card */
.rq-shell, .rq-fallback { position: relative; max-width: 60rem; margin-inline: auto; padding: clamp(1.25rem, 3.6vw, 2.5rem); border-radius: var(--r-l);
  background: var(--card-paper); color: var(--ink-2);
  box-shadow: inset 0 0 0 1px rgba(27,24,34,.07), 0 1px 2px rgba(27,24,34,.06), 0 18px 36px -18px rgba(11,14,26,.28), 0 50px 90px -40px rgba(11,14,26,.45); }

/* progress: four segments across the card, the current one lit (the eyebrow says which question it is) */
.rq-bar { margin: 0 0 clamp(1.4rem, 3vw, 2rem); }
.rq-studs { display: flex; gap: .4rem; }
.rq-stud { flex: 1; height: .3rem; border-radius: 999px; background: var(--line); transition: background-color .3s; }
.rq-stud.done { background: var(--ember); }
.rq-stud.now { background: linear-gradient(90deg, var(--ember), var(--lamp)); }

.rq-kicker { margin: 0 0 .6rem; font: 600 1rem/1.3 var(--display); font-variant-caps: all-small-caps; letter-spacing: .09em; color: var(--ember-ink); }
.rq-title { margin: 0 0 .55rem; font: 700 clamp(1.6rem, 3.2vw, 2.25rem)/1.08 var(--display); letter-spacing: -.02em; color: var(--ink); text-wrap: pretty; max-width: 24em; }
.rq-title:focus { outline: none; }
.rq-title:focus-visible { outline: 2px solid var(--ember); outline-offset: 4px; border-radius: 4px; }
.rq-help { margin: 0 0 clamp(1.3rem, 2.6vw, 1.75rem); max-width: 56ch; font-size: 1.02rem; line-height: 1.55; color: var(--ink-3); }

/* the answers: hairline cards with an arrow that lights on hover */
.rq-opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
.rq-opt { position: relative; display: block; width: 100%; min-height: 4.6rem; margin: 0; padding: 1rem 3.4rem 1.05rem 1.15rem; border: 0; border-radius: 16px; cursor: pointer;
  text-align: left; color: var(--ink-2); background: #fff; box-shadow: inset 0 0 0 1px var(--edge), 0 1px 2px rgba(27,24,34,.04);
  transition: box-shadow .2s, transform .2s var(--settle), background-color .2s; }
.rq-opt::after { content: "→"; position: absolute; top: 50%; right: 1rem; display: grid; place-items: center; width: 1.9rem; height: 1.9rem; margin-top: -.95rem; border-radius: 50%;
  font: 400 1rem/1 var(--body); color: var(--ember-ink); background: var(--rq-tint); transition: transform .2s var(--settle), background-color .2s, color .2s; }
.rq-opt:hover { background: var(--rq-lit); box-shadow: inset 0 0 0 1px var(--ember), 0 12px 26px -16px rgba(200,100,42,.6); transform: translateY(-1px); }
.rq-opt:hover::after { color: #24140A; background: linear-gradient(180deg, var(--lamp-hi), var(--lamp)); transform: translateX(2px); }
.rq-opt:active { transform: translateY(1px); }
.rq-opt:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; }
.rq-opt strong { display: block; margin-bottom: .2rem; font: 700 1.06rem/1.3 var(--body); color: var(--ink); text-wrap: balance; }
.rq-opt span { display: block; font-size: .94rem; line-height: 1.4; color: var(--ink-3); }
.rq-opt:hover span { color: var(--ink-2); }

.rq-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .4rem 1rem; margin-top: clamp(1.2rem, 2.6vw, 1.6rem); padding-top: .9rem;
  border-top: 1px solid var(--line); font-size: .92rem; color: var(--ink-3); }
.rq-link-btn { display: inline-flex; align-items: center; min-height: 2.75rem; margin: 0; padding: .35rem 0; border: 0; background: none; cursor: pointer;
  color: var(--ember-ink); font: 700 .95rem/1.2 var(--body); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .22em; text-decoration-color: rgba(154,67,20,.4); }
.rq-link-btn:hover { color: #6B2F0E; text-decoration-color: currentColor; }
.rq-link-btn:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; border-radius: 4px; }
.rq-foot-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0 1.4rem; }

/* ------------------------------------------------------------------ the result */
/* .paper is also site.css's document column: undo its width and clip here */
.rq-badge { width: auto; clip-path: none; display: inline-flex; align-items: center; gap: .5rem; margin: 0 0 .9rem; padding: .32rem .8rem .34rem .7rem; border-radius: 999px; font: 700 .88rem/1.2 var(--body); }
.rq-badge::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; }
.rq-badge.fit { color: #235C3B; background: #E2F0E6; box-shadow: inset 0 0 0 1px rgba(46,122,78,.28); }
.rq-badge.paper { color: #8A3B10; background: var(--rq-tint); box-shadow: inset 0 0 0 1px rgba(200,100,42,.3); }
.rq-res-grid { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, .92fr); gap: clamp(.9rem, 2vw, 1.25rem); align-items: start; }

/* the quest board: tick the three and the apps open */
.rq-board { padding: clamp(1rem, 2.2vw, 1.35rem); border-radius: 20px; background: var(--paper); box-shadow: inset 0 0 0 1px var(--line); }
.rq-board-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .9rem; }
.rq-board-head strong { font: 700 1.15rem/1.2 var(--display); letter-spacing: -.01em; color: var(--ink); }
.rq-lock-pill { position: relative; display: inline-flex; align-items: center; min-height: 1.9rem; padding: .3rem .8rem .3rem 1.85rem; border-radius: 999px;
  font: 700 .84rem/1.2 var(--body); color: var(--bone); background: var(--ink); transition: background-color .3s, color .3s; }
/* the padlock: a body and a shackle, which lifts when the apps open */
.rq-lock-pill::before, .rq-lock-pill::after { content: ""; position: absolute; left: .78rem; top: 50%; }
.rq-lock-pill::before { width: .64rem; height: .5rem; margin-top: -.1rem; border-radius: 2px; background: currentColor; }
.rq-lock-pill::after { left: .87rem; width: .46rem; height: .5rem; margin-top: -.52rem; border: 1.5px solid currentColor; border-bottom: 0; border-radius: .3rem .3rem 0 0; transition: transform .3s var(--spring); }
.rq-lock-pill.open { color: #2A1608; background: linear-gradient(180deg, var(--lamp-hi), var(--lamp)); box-shadow: 0 6px 16px -6px rgba(244,169,97,.8); }
.rq-lock-pill.open::after { transform: translate(.28rem, -.14rem); }
.rq-quests { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.rq-quest-btn { display: flex; align-items: center; justify-content: space-between; gap: .75rem; width: 100%; min-height: 3.4rem; margin: 0; padding: .65rem .85rem .65rem .75rem; border: 0; border-radius: 14px; cursor: pointer;
  text-align: left; color: var(--ink); background: #fff; box-shadow: inset 0 0 0 1px var(--edge), 0 1px 2px rgba(27,24,34,.04); transition: background-color .2s, box-shadow .2s; }
.rq-quest-btn:hover { box-shadow: inset 0 0 0 1px var(--ink-3), 0 6px 14px -10px rgba(27,24,34,.3); }
.rq-quest-btn:focus-visible { outline: 2px solid var(--ember); outline-offset: 2px; }
.rq-quest-btn[aria-pressed="true"] { background: var(--rq-lit); box-shadow: inset 0 0 0 1px rgba(200,100,42,.55); }
.rq-quest-left { display: flex; align-items: center; gap: .75rem; font: 700 1rem/1.3 var(--body); }
.rq-box { flex: none; display: grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 7px; background: #fff; box-shadow: inset 0 0 0 1.5px var(--ink-3);
  font: 700 .85rem/1 var(--body); color: #2A1608; transition: background-color .2s, box-shadow .2s, transform .25s var(--spring); }
.rq-quest-btn[aria-pressed="true"] .rq-box { background: linear-gradient(180deg, var(--lamp-hi), var(--lamp)); box-shadow: inset 0 0 0 1px rgba(154,67,20,.5); transform: scale(1.06); }
.rq-quest-btn[aria-pressed="true"] .rq-quest-left { color: var(--ink-2); }
.rq-proof { flex: none; padding: .18rem .6rem .2rem; border-radius: 999px; font: 600 .8rem/1.3 var(--body); color: var(--ink-3); background: var(--paper); box-shadow: inset 0 0 0 1px var(--line); white-space: nowrap; }
.rq-board-hint { margin: .85rem 0 0; font-size: .9rem; line-height: 1.45; color: var(--ink-3); }
.rq-cheer { display: flex; align-items: center; gap: .9rem; margin-top: .9rem; padding: .85rem 1rem; border-radius: 16px; font-size: .94rem; line-height: 1.45; color: var(--bone-2);
  background: radial-gradient(60% 120% at 0% 100%, rgba(244,169,97,.3), rgba(244,169,97,0) 70%), linear-gradient(160deg, #1A1F3D, var(--night));
  box-shadow: inset 0 0 0 1px rgba(214,208,255,.12); animation: rq-rise .5s var(--settle) both; }
.rq-cheer[hidden] { display: none; }
.rq-cheer img { flex: none; width: 3.4rem; height: 3.4rem; object-fit: contain; filter: drop-shadow(0 6px 10px rgba(0,0,0,.4)); }
.rq-cheer strong { display: block; margin-bottom: .1rem; font: 700 1.08rem/1.25 var(--display); color: var(--lamp-hi); }
@keyframes rq-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* the recommendation: a night panel inside the paper card */
.rq-setup { --edge: rgba(214,208,255,.45); display: flex; flex-direction: column; padding: clamp(1.2rem, 2.4vw, 1.6rem); border-radius: 20px; color: var(--bone-2);
  background: radial-gradient(80% 50% at 100% 0%, rgba(157,148,224,.16), rgba(157,148,224,0) 70%), radial-gradient(70% 45% at 0% 100%, rgba(244,169,97,.14), rgba(244,169,97,0) 70%), linear-gradient(170deg, #1A1F3D, var(--night) 75%);
  box-shadow: inset 0 0 0 1px rgba(214,208,255,.12); }
.rq-setup-title { margin: 0 0 .5rem; font: 700 1.45rem/1.12 var(--display); letter-spacing: -.015em; color: var(--bone); }
.rq-setup p { margin: 0 0 1rem; font-size: .97rem; line-height: 1.5; }
.rq-setup ul { list-style: none; margin: 0 0 1.35rem; padding: 1rem 0 0; display: grid; gap: .55rem; border-top: 1px solid rgba(214,208,255,.12); font-size: .93rem; line-height: 1.45; }
.rq-setup li { display: grid; grid-template-columns: 1.1rem 1fr; gap: .55rem; }
.rq-setup li::before { content: ""; width: .58rem; height: .3rem; margin: .45rem 0 0 .15rem; border-left: 1.75px solid var(--lamp); border-bottom: 1.75px solid var(--lamp); transform: rotate(-45deg); }
.rq-actions { display: grid; gap: .6rem; margin-top: auto; }
.rq-cta-primary, .rq-cta-sec { display: inline-flex; align-items: center; justify-content: center; min-height: 3rem; padding: .75rem 1.2rem; border-radius: 999px; text-align: center; text-decoration: none; font: 700 1rem/1.2 var(--body); transition: transform .18s var(--settle), filter .18s, background-color .18s, box-shadow .18s; }
.rq-cta-primary { color: #24140A; background: linear-gradient(180deg, var(--lamp-hi), var(--lamp));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.55), inset 0 -1px 0 rgba(150,70,20,.25), 0 10px 26px -12px rgba(244,169,97,.75); }
.rq-cta-primary:hover { color: #24140A; filter: brightness(1.05); transform: translateY(-1px); }
.rq-cta-sec { color: var(--bone); background: transparent; box-shadow: inset 0 0 0 1px var(--edge); font-size: .96rem; }
.rq-cta-sec:hover { color: #fff; background: rgba(255,255,255,.07); box-shadow: inset 0 0 0 1px rgba(244,237,226,.45); }
.rq-cta-store { display: inline-flex; align-items: center; justify-content: center; min-height: 3rem; border-radius: 12px; text-decoration: none; transition: transform .18s var(--settle), filter .18s; }
.rq-cta-store img { width: auto; height: 3rem; }
.rq-cta-store:hover { transform: translateY(-1px); filter: brightness(1.12); }
.rq-cta-primary:focus-visible, .rq-cta-sec:focus-visible, .rq-cta-store:focus-visible, .rq-trial-note a:focus-visible { outline: 2px solid var(--lamp); outline-offset: 3px; }
.rq-trial-note { margin: .9rem 0 0; font-size: .85rem; line-height: 1.45; color: var(--bone-3); }
.rq-trial-note a { color: var(--lamp-hi); }

/* ------------------------------------------------------------------ without JavaScript: the age, then the chart maker */
.rq-fallback fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.rq-fallback legend { padding: 0; margin-bottom: 1rem; font: 700 clamp(1.4rem, 2.8vw, 1.9rem)/1.15 var(--display); letter-spacing: -.015em; color: var(--ink); }
.rq-fallback-row { display: flex; flex-wrap: wrap; gap: .5rem; }
.rq-fallback label { position: relative; display: inline-flex; align-items: center; gap: .5rem; min-height: 2.75rem; padding: .4rem 1rem .4rem .8rem; border-radius: 999px; cursor: pointer;
  font: 600 .98rem/1.2 var(--body); color: var(--ink); background: #fff; box-shadow: inset 0 0 0 1px var(--edge); }
.rq-fallback label:has(:checked) { background: var(--rq-lit); box-shadow: inset 0 0 0 2px var(--ember); }
.rq-fallback input[type="radio"] { width: 1.05rem; height: 1.05rem; margin: 0; accent-color: var(--ember); }
.rq-fallback p { margin: 1.5rem 0 0; }

/* ------------------------------------------------------------------ the quiz's own page: the tools' band and title (forge.css), the
   card rising onto the band like the chart makers' workshop, then two notes on paper */
.quiz-page .page-title h1 { max-width: 20ch; }
.quiz-page h1 span { display: block; color: var(--lamp-hi); }
.quiz-page .up-link { margin: .9rem 0 0; max-width: 36rem; font-size: .95rem; color: var(--fg-2); }
.quiz-hero { padding-bottom: clamp(4.5rem, 8vw, 7rem); }
.quiz-stage .rq-shell, .quiz-stage .rq-fallback { max-width: none; }
.quiz-guide { padding: 0 0 clamp(4.5rem, 9vw, 7.5rem); }
.quiz-guide-inner { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(1.75rem, 4vw, 3.5rem); }
.quiz-guide-card { padding-top: 1.4rem; border-top: 1px solid var(--hair-2); }
.quiz-guide-card h2 { margin-bottom: .8rem; font-size: clamp(1.45rem, 2.4vw, 1.75rem); line-height: 1.15; letter-spacing: -.015em; }
.quiz-guide-card p, .quiz-guide-card li { font-size: 1.02rem; line-height: 1.6; color: var(--fg-2); }
.quiz-guide-card ul { margin: .4rem 0 0; padding-left: 1.15rem; display: grid; gap: .5rem; }
.quiz-guide-card li::marker { color: var(--accent); }

/* ------------------------------------------------------------------ narrower screens */
@media (width < 47.5625em) {
  .rq-opts, .rq-res-grid, .quiz-guide-inner { grid-template-columns: minmax(0, 1fr); }
  .rq-shell, .rq-fallback { border-radius: 20px; }
}
@media (max-width: 26.25em) {
  .rq-shell, .rq-fallback { padding: 1.15rem 1rem 1rem; }
  .rq-opt { min-height: 4.25rem; padding: .9rem 3.1rem .95rem 1rem; }
  .rq-opt::after { right: .8rem; }
  .rq-quest-btn { flex-wrap: wrap; gap: .35rem .75rem; }
  .rq-proof { margin-left: 2.25rem; }
}
@media (prefers-reduced-motion: reduce) {
  .rq-stud, .rq-opt, .rq-opt::after, .rq-quest-btn, .rq-box, .rq-lock-pill::after { transition: none; }
  .rq-cheer { animation: none; }
}

/* forced colours: answer cards and quest buttons keep an edge, a done quest is outlined in Highlight */
@media (forced-colors: active) {
  .rq-opt, .rq-quest-btn, .rq-fallback label, .rq-cta-primary, .rq-cta-sec { border: 1px solid ButtonText; }
  /* done or chosen: a thick Highlight border; focus: a Highlight outline set off from it */
  .rq-quest-btn[aria-pressed="true"], .rq-fallback label:has(:checked) { border: 3px solid Highlight; }
  .rq-opt:focus-visible, .rq-quest-btn:focus-visible, .rq-fallback label:has(:focus-visible), .rq-cta-primary:focus-visible, .rq-cta-sec:focus-visible { outline: 2px solid Highlight; outline-offset: 4px; }
}
