/* quest-mode — the rules that only ever match inside this engine, moved out of
   core/styles.css so other pages don't download them. Loaded by core/app.js after
   core/styles.css (the ENGINES table's css). */

body.quest-mode #questRoot {
  display: block;
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(1200px 800px at 50% -10%, var(--bg-haze) 0%, var(--bg-1) 45%, var(--bg-0) 100%);
  color: var(--text);
  /* The status colors as text. Drawn for a dark page; on a light page their
     tinted boxes (the green feedback box, the meters) took them under 4.5:1
     ("✓ Correct" 3.95:1, the streak 4.05:1), so light mode deepens them below. */
  --q-good-ink: var(--good); --q-bad-ink: var(--bad); --q-warn-ink: var(--warn);
  /* Scrollbars (the rail, a long scene) follow the page's mode, not the
     browser's default white track. */
  color-scheme: dark;
}

:root[data-mode="light"] body.quest-mode #questRoot {
  --q-good-ink: color-mix(in srgb, var(--good) 72%, #000);
  --q-bad-ink: color-mix(in srgb, var(--bad) 80%, #000);
  --q-warn-ink: color-mix(in srgb, var(--warn) 72%, #000);
  color-scheme: light;
}

#questRail { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--text-dim) 50%, transparent) transparent; }

.quest-focus-portrait {
  width: clamp(96px, 18vw, 160px); height: clamp(96px, 18vw, 160px);
  object-fit: cover; border-radius: 50%;
  border: 3px solid var(--accent);
}

.quest-reading-item { margin: 4px 0; }

.quest-meter {
  display: flex; flex-direction: column; align-items: center;
  min-width: 60px; padding: 6px 12px;
  background: rgba(var(--accent-rgb), 0.08);
  border: 1px solid var(--card-border); border-radius: 10px;
}

.quest-meter__val { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }

.quest-meter__label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-dim); }

.quest-meter.is-streak .quest-meter__val { color: var(--q-warn-ink); }

.quest-meter.is-lives .quest-meter__val { color: var(--q-bad-ink); }

.quest-mile {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin: 2px 0; border-radius: 9px;
  font-size: 13px; color: var(--text-dim);
  cursor: default; transition: background 0.18s ease, color 0.18s ease;
}

.quest-mile__mark {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 11px;
  background: var(--card-border); color: var(--text-dim);
}

.quest-mile__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.quest-mile.is-active { background: rgba(var(--accent-rgb), 0.16); color: var(--text); }

.quest-mile.is-active .quest-mile__mark { background: var(--accent); color: var(--on-accent); }

.quest-mile.is-done { color: var(--text); cursor: pointer; }

.quest-mile.is-done:hover { background: rgba(var(--accent-rgb), 0.1); }

.quest-mile.is-clean .quest-mile__mark { background: var(--good); color: var(--on-status); font-size: 0; }

.quest-mile.is-clean .quest-mile__mark::after { content: "✓"; font-size: 12px; }

.quest-mile.is-flawed .quest-mile__mark { background: var(--warn); color: var(--on-status); }

.quest-mile.is-locked { opacity: 0.5; }

.quest-mile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Scene headings receive focus on navigation (for screen readers) but are not
   interactive controls, so suppress the ring there. */
.quest-choice__prompt:focus, .quest-narr__title:focus, .quest-outcome__title:focus { outline: none; }

.quest-scene {
  position: absolute; inset: 0;
  padding: inherit;
  display: grid; place-items: center;
  overflow-y: auto;
}

.quest-scene__bg { position: absolute; inset: 0; z-index: 0; background-position: center; background-size: cover; }

.quest-scene__wash { position: absolute; inset: 0; z-index: 1; background: var(--bg-0); }

/* Authored scene colours and gradients are dark-palette art (saul-quest's are near-black
   browns); in light mode the page's own light backdrop shows instead. Photos stay. */
:root[data-mode="light"] .quest-scene__bg--tint:not([style*="url("]) { background: none !important; }

.quest-scene > .quest-narr,
.quest-scene > .quest-choice,
.quest-scene > .quest-outcome { position: relative; z-index: 2; }

/* ---- Narration scene ------------------------------------------------- */
.quest-narr { width: min(720px, 100%); text-align: center; }

.quest-narr__emblem { font-size: clamp(40px, 8vw, 72px); line-height: 1; margin-bottom: 10px; }

.quest-eyebrow {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.18em;
  color: var(--accent-ink); margin-bottom: 10px;
}

.quest-narr__title {
  font-family: var(--font-display, inherit);
  font-size: clamp(26px, 5vw, 42px); margin: 0 0 14px;
}

.quest-narr__body { color: var(--text); font-size: clamp(15px, 2.2vw, 18px); line-height: 1.6; }

.quest-narr__body p { margin: 10px 0; }

/* ---- Verse blocks ---------------------------------------------------- */
.quest-verse {
  margin: 18px auto 0; max-width: 60ch;
  border-left: 3px solid var(--accent);
  padding: 8px 16px; text-align: left;
  background: rgba(var(--accent-rgb), 0.06); border-radius: 0 10px 10px 0;
}

.quest-verse--ctx { margin: 10px auto 18px; }

.quest-verse__text { font-style: italic; color: var(--text); }

.quest-verse__ref { display: block; margin-top: 6px; font-size: 13px; color: var(--accent-soft); font-style: normal; }

/* ---- Choice scene ---------------------------------------------------- */
.quest-choice { width: min(860px, 100%); text-align: center; }

.quest-choice__prompt {
  font-family: var(--font-display, inherit);
  font-size: clamp(20px, 3.6vw, 30px); margin: 0 0 18px;
}

.quest-options { display: grid; gap: 16px; margin: 8px 0; }

.quest-option {
  position: relative; display: flex; align-items: center; gap: 12px;
  text-align: left; font: inherit; color: var(--text);
  background: var(--card-bg, rgba(255, 255, 255, 0.04));
  border: 2px solid var(--card-border); border-radius: 14px;
  padding: 18px 20px; cursor: pointer; min-height: 64px;
  transition: transform 0.14s ease, border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.quest-option:hover:not(:disabled) {
  transform: translateY(-2px); border-color: var(--accent);
  box-shadow: 0 14px 36px rgba(var(--accent-rgb), 0.22);
}

.quest-option__key {
  flex: none; width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center; font-weight: 800; font-size: 15px;
  background: rgba(var(--accent-rgb), 0.16); color: var(--accent-ink);
}

.quest-option__text { font-size: clamp(15px, 2vw, 17px); line-height: 1.4; }

.quest-option:disabled { cursor: default; }

.quest-option.is-locked:not(.is-correct):not(.is-wrong) { opacity: 0.5; }

.quest-option.is-correct {
  border-color: var(--good); background: rgba(var(--good-rgb), 0.16);
}

.quest-option.is-correct .quest-option__key { background: var(--good); color: var(--on-status); }

.quest-option.is-wrong {
  border-color: var(--bad); background: rgba(var(--bad-rgb), 0.14); opacity: 0.85;
}

.quest-option.is-wrong .quest-option__key { background: var(--bad); color: var(--on-status); }

/* ---- Hint + feedback ------------------------------------------------- */
.quest-hint { margin: 14px auto 0; max-width: 60ch; text-align: center; font-size: 14px; color: var(--text-dim); }

.quest-hint__summary { display: inline-block; cursor: pointer; color: var(--accent-soft); list-style: none; }

.quest-hint__summary::-webkit-details-marker { display: none; }

.quest-hint__summary::before { content: "💡 "; }

.quest-hint__body { margin-top: 8px; text-align: center; }

.quest-feedback {
  margin: 18px auto 0; max-width: 64ch; text-align: left;
  border-radius: 12px; padding: 14px 18px; border: 1px solid var(--card-border);
}

.quest-feedback.is-good { background: rgba(var(--good-rgb), 0.12); border-color: rgba(var(--good-rgb), 0.5); }

.quest-feedback.is-bad { background: rgba(var(--bad-rgb), 0.1); border-color: rgba(var(--bad-rgb), 0.5); }

.quest-feedback__head { font-weight: 800; margin-bottom: 6px; }

.quest-feedback.is-good .quest-feedback__head { color: var(--q-good-ink); }

.quest-feedback.is-bad .quest-feedback__head { color: var(--q-bad-ink); }

.quest-feedback__body p { margin: 6px 0; }

.quest-feedback__ref { display: block; margin-top: 6px; font-size: 13px; color: var(--accent-soft); }

.quest-feedback__pts { margin-top: 8px; font-weight: 800; color: var(--q-good-ink); }

/* ---- Outcome / end screen -------------------------------------------- */
.quest-outcome { width: min(680px, 100%); text-align: center; }

.quest-outcome__title { font-family: var(--font-display, inherit); font-size: clamp(26px, 5vw, 40px); margin: 0 0 14px; }

.quest-outcome__stats { display: flex; gap: 16px; justify-content: center; margin: 24px 0 0; flex-wrap: wrap; }

.quest-outcome__body { color: var(--text-dim); margin: 0 auto; max-width: 56ch; }

.quest-outcome__actions { display: flex; gap: 14px; justify-content: center; align-items: center; margin-top: 24px; }

.quest-outcome__lib { color: var(--text-dim); text-decoration: none; padding: 12px 18px; }

.quest-outcome__lib:hover { color: var(--text); }

/* ---- Confetti -------------------------------------------------------- */
.quest-confetti { position: absolute; top: 30%; left: 50%; width: 0; height: 0; z-index: 5; pointer-events: none; }

.quest-confetti__bit { position: absolute; width: 9px; height: 9px; border-radius: 2px; }

@media (min-width: 1001px) {
  body.quest-mode.hl-immersive { --quest-u: clamp(16px, min(1.35vw, 2.2vh), 32px); }
  
  /* The rail widens a little with the screen; the stage and bar follow it. */
  body.quest-mode.hl-immersive #questRail { width: clamp(220px, 16vw, 340px); }
  
  body.quest-mode.hl-immersive #questStage { padding-left: calc(clamp(220px, 16vw, 340px) + 40px); font-size: var(--quest-u); }
  
  body.quest-mode.hl-immersive #questControls { left: calc(clamp(220px, 16vw, 340px) + 40px); }
  
  body.quest-mode.hl-immersive .quest-mile { font-size: clamp(13px, 1vw, 18px); }
  
  body.quest-mode.hl-immersive .quest-meter__val { font-size: clamp(18px, 1.5vw, 30px); }
  
  body.quest-mode.hl-immersive .quest-meter__label { font-size: clamp(10px, 0.8vw, 14px); }
  

  body.quest-mode.hl-immersive .quest-narr { width: min(44em, 100%); }
  
  body.quest-mode.hl-immersive .quest-choice { width: min(58em, 100%); }
  
  body.quest-mode.hl-immersive .quest-outcome { width: min(42em, 100%); }
  
  body.quest-mode.hl-immersive .quest-narr__emblem { font-size: 3.4em; }
  
  body.quest-mode.hl-immersive .quest-eyebrow { font-size: 0.72em; }
  
  body.quest-mode.hl-immersive .quest-narr__title { font-size: 2.4em; }
  
  body.quest-mode.hl-immersive .quest-narr__body { font-size: 1.15em; }
  
  body.quest-mode.hl-immersive .quest-verse__ref,
  body.quest-mode.hl-immersive .quest-feedback__ref { font-size: 0.75em; }
  
  body.quest-mode.hl-immersive .quest-choice__prompt { font-size: 1.9em; }
  
  body.quest-mode.hl-immersive .quest-options { gap: 0.85em; }
  
  body.quest-mode.hl-immersive .quest-option { padding: 0.9em 1.05em; min-height: 3.3em; gap: 0.65em; }
  
  body.quest-mode.hl-immersive .quest-option__key { width: 1.6em; height: 1.6em; font-size: 0.85em; }
  
  body.quest-mode.hl-immersive .quest-option__text { font-size: 1.1em; }
  
  body.quest-mode.hl-immersive .quest-hint { font-size: 0.8em; }
  
  body.quest-mode.hl-immersive .quest-outcome__title { font-size: 2.3em; }
  
  body.quest-mode.hl-immersive .quest-outcome .quest-meter__val { font-size: 1.4em; }
  
  body.quest-mode.hl-immersive .quest-outcome .quest-meter__label { font-size: 0.62em; }
  
  body.quest-mode.hl-immersive .quest-outcome .quest-begin { font-size: 1.05em; }
  

  body.quest-mode.hl-immersive .quest-briefing-card { font-size: var(--quest-u); width: min(46em, 100%); }
  
  body.quest-mode.hl-immersive .quest-focus-name { font-size: 2.5em; }
  
  body.quest-mode.hl-immersive .quest-focus-epithet { font-size: 1.1em; }
  
  body.quest-mode.hl-immersive .quest-reading-title,
  body.quest-mode.hl-immersive .quest-howto-title { font-size: 0.72em; }
  
  body.quest-mode.hl-immersive .quest-howto-body { font-size: 0.92em; }
  
  body.quest-mode.hl-immersive .quest-begin { font-size: 1.1em; }
}

@media (max-width: 1000px) {
  .quest-mile { flex: none; }
  
  .quest-mile__text { display: none; }
}

/* The light/dark button sits beside ⌂ Library (core/app.js): the HUD's title
   starts past both pills, not just the one (it ran under "Dark"). */
#questHud { padding-left: 224px; }

/* ---- Phones and tablets: one column, in flow ---------------------------------
   Under 1000 px the rail moves above the stage (core/styles.css), but the HUD
   stayed absolute: its title and meters ran over the rail. Here the quest is a
   column in flow — HUD (below the ⌂ Library and light/dark pills), rail, stage,
   bar — so nothing overlaps at any height. The meters sit in one compact row. */
@media (max-width: 1000px) {
  body.quest-mode #questRoot { display: flex; flex-direction: column; }

  #questHud { position: relative; flex: none; gap: 8px; padding: 52px 14px 6px; }

  #questTitle { font-size: 18px; line-height: 1.2; }

  #questSubtitle { font-size: 12px; }

  .quest-meters { flex-wrap: nowrap; gap: 6px; }

  .quest-meter { flex-direction: row; align-items: baseline; gap: 6px; min-width: 0; padding: 4px 10px; }

  .quest-meter__val { font-size: 15px; }

  .quest-meter__label { font-size: 11px; letter-spacing: 0.08em; }

  #questRail { position: relative; inset: auto; flex: none; margin: 4px 14px 0; max-height: none; padding: 6px 8px; }

  .quest-rail-list { scrollbar-width: none; }
  
  /* The desktop rail's dark glass reads as a grey slab on the light themes. */
  #questRail { background: rgba(var(--accent-rgb), 0.06); }

  #questStage { position: relative; inset: auto; flex: 1 1 auto; min-height: 0; padding: 14px 16px 12px; }

  #questCredit { display: none; }   /* it sat on the ⛶ button */
  
  #questControls { position: relative; inset: auto; flex: none; padding: 8px 12px max(10px, env(safe-area-inset-bottom)); }

  /* A scene taller than the stage scrolls from its top (plain centre clipped the
     top of a long end screen out of reach). */
  .quest-scene { place-items: safe center; }
  
  .quest-options { gap: 10px; }

  .quest-option { padding: 12px 14px; min-height: 56px; }
}

@media (max-width: 640px) {
  .quest-narr__title { font-size: 26px; }

  .quest-choice__prompt { font-size: 20px; }

  #questBriefing { padding: 56px 12px 24px; place-items: start center; }

  .quest-briefing-card { padding: 22px 16px; }

  .quest-reading, .quest-howto { padding: 12px 14px; }
}

/* A phone on its side: title and meters share one line beside the pills. */
@media (max-height: 500px) and (max-width: 1000px) {
  #questHud { flex-direction: row; align-items: center; padding: 8px 14px 4px 230px; }

  #questRail { margin-top: 2px; padding: 4px 8px; }

  #questStage { padding-top: 8px; }

  #questControls { padding-top: 4px; padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  
  #questCredit { display: none; }
  
  .quest-narr__title { font-size: 24px; margin-bottom: 8px; }
  
  .quest-narr__emblem { font-size: 36px; }
  
  .quest-choice__prompt { font-size: 20px; margin-bottom: 10px; }
  
  .quest-outcome__title { font-size: 24px; margin-bottom: 8px; }
  
  .quest-options--n2, .quest-options--n4 { grid-template-columns: 1fr 1fr; }
}
