/* =========================================================================
   Question Navigation Shell — scoped styles
   All rules are nested under `.qa-nav-shell` so they cannot leak into any
   host page (learner-revision.html, prototypes, etc.). The shell owns only
   the chrome (sticky header, pips, bottom nav, loader, modals, toast).
   The actual question card is rendered by question-attempt.js into
   `.qa-nav-shell #attemptContainer` and is intentionally NOT styled here.
   ========================================================================= */

.qa-nav-shell {
  --qans-brand: #059669;
  --qans-brand-dark: #047857;
  --qans-ink: #0f172a;
  --qans-muted: #64748b;
  --qans-line: #e5e7eb;
  --qans-bg: #f8fafc;

  position: fixed;
  inset: 0;
  z-index: 9000;
  background: var(--qans-bg);
  color: var(--qans-ink);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}

/* When the shell is mounted we hide host page scroll to avoid double scrollbars */
body.qa-nav-shell-open { overflow: hidden; }

/* ---------- Header ---------- */
.qa-nav-shell .qans-header {
  background: white;
  border-bottom: 1px solid var(--qans-line);
  position: sticky;
  top: 0;
  z-index: 30;
}
.qa-nav-shell .qans-header-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
}
.qa-nav-shell .qans-back {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 44px; padding: .5rem .75rem; border-radius: 12px;
  background: transparent; color: var(--qans-muted);
  font-weight: 600; font-size: .9375rem; border: 1px solid transparent;
  -webkit-tap-highlight-color: transparent;
}
.qa-nav-shell .qans-back:active { transform: scale(.98); }
.qa-nav-shell .qans-title-wrap { flex: 1; min-width: 0; }
.qa-nav-shell .qans-eyebrow { font-size: .75rem; color: var(--qans-muted); font-weight: 600; }
.qa-nav-shell .qans-title {
  font-size: 1rem; font-weight: 700; color: var(--qans-ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Progress pips ---------- */
.qa-nav-shell .qans-pips-wrap {
  max-width: 880px; margin: 0 auto; padding: 0 1rem .75rem;
}
.qa-nav-shell .qans-pips {
  display: flex; align-items: center; gap: .375rem;
  overflow-x: auto; scrollbar-width: none;
}
.qa-nav-shell .qans-pips::-webkit-scrollbar { display: none; }
.qa-nav-shell .qans-pip {
  width: 28px; height: 6px; border-radius: 9999px;
  background: #e2e8f0; transition: background .2s, height .2s;
  flex: 0 0 auto; border: 0; padding: 0; cursor: pointer;
}
.qa-nav-shell .qans-pip.active   { background: var(--qans-brand); height: 8px; }
.qa-nav-shell .qans-pip.done     { background: #34d399; }
.qa-nav-shell .qans-pip.attempted{ background: #fbbf24; }

/* ---------- Main content (sibling context banner + engine container) ---------- */
.qa-nav-shell .qans-main {
  max-width: 880px; margin: 0 auto; padding: 1rem;
}
.qa-nav-shell .qans-context {
  background: white; border: 1px solid var(--qans-line); border-radius: 14px;
  padding: .875rem 1rem; margin-bottom: .875rem;
}
.qa-nav-shell .qans-context-label {
  font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--qans-muted); margin-bottom: .375rem;
}

/* ---------- Bottom nav ---------- */
.qa-nav-shell .qans-navbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: white; border-top: 1px solid var(--qans-line);
  padding: .625rem .75rem calc(.625rem + env(safe-area-inset-bottom));
  z-index: 9040; box-shadow: 0 -4px 16px rgba(15,23,42,.06);
}
.qa-nav-shell .qans-navbar-inner {
  max-width: 880px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .5rem;
}
.qa-nav-shell .qans-nav-counter {
  text-align: center; font-size: .8125rem; color: var(--qans-muted); font-weight: 600; line-height: 1.2;
}
.qa-nav-shell .qans-nav-counter b {
  color: var(--qans-ink); font-size: .9375rem; display: block;
}
.qa-nav-shell .qans-nav-btn {
  min-height: 48px; padding: 0 .75rem; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: .375rem;
  font-weight: 600; font-size: .9375rem; background: #f1f5f9; color: var(--qans-ink);
  border: 1px solid transparent; -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
.qa-nav-shell .qans-nav-btn:active { transform: scale(.98); }
.qa-nav-shell .qans-nav-btn.primary { background: var(--qans-brand); color: white; }
.qa-nav-shell .qans-nav-btn[disabled] { opacity: .35; pointer-events: none; }
.qa-nav-shell .qans-nav-btn .lbl { display: none; }
@media (min-width: 480px) {
  .qa-nav-shell .qans-nav-btn .lbl { display: inline; }
}

/* ---------- Modal (pending-2nd-attempt confirmation) ---------- */
.qa-nav-shell .qans-modal-overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.55);
  display: flex; align-items: flex-end; justify-content: center; z-index: 9060;
  padding: 1rem;
}
.qa-nav-shell .qans-modal-overlay.hidden { display: none; }
.qa-nav-shell .qans-modal-card {
  background: white; border-radius: 20px; width: 100%; max-width: 440px;
  padding: 1.25rem; box-shadow: 0 24px 48px rgba(0,0,0,.25);
  animation: qansSlideUp .2s ease-out;
}
@keyframes qansSlideUp { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 480px) {
  .qa-nav-shell .qans-modal-overlay { align-items: center; }
}
.qa-nav-shell .qans-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 44px; padding: .625rem 1rem; border-radius: 12px;
  font-weight: 600; font-size: .9375rem; border: 1px solid transparent; cursor: pointer;
}
.qa-nav-shell .qans-btn-primary { background: var(--qans-brand); color: white; }
.qa-nav-shell .qans-btn-outline { background: white; color: var(--qans-ink); border-color: var(--qans-line); }

/* ---------- Toast ---------- */
.qa-nav-shell .qans-toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(110px + env(safe-area-inset-bottom));
  background: #0f172a; color: white; padding: .625rem 1rem; border-radius: 10px;
  font-size: .875rem; z-index: 9055; opacity: 0; pointer-events: none; transition: opacity .2s;
}
.qa-nav-shell .qans-toast.show { opacity: 1; }

/* ---------- Loading placeholder ---------- */
.qa-nav-shell .qans-loading {
  position: fixed; inset: 0; z-index: 9045; background: var(--qans-bg);
  display: flex; flex-direction: column; gap: .875rem;
  padding: calc(88px + env(safe-area-inset-top)) 1rem calc(96px + env(safe-area-inset-bottom));
  opacity: 0; pointer-events: none; transition: opacity .18s ease-out;
}
.qa-nav-shell .qans-loading.active { opacity: 1; pointer-events: auto; }
.qa-nav-shell .qans-loading-inner {
  max-width: 880px; margin: 0 auto; padding: 0 1rem; width: 100%;
  display: flex; flex-direction: column; gap: .875rem;
}
.qa-nav-shell .qans-shimmer {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  border-radius: 12px;
  animation: qansShimmer 1s infinite linear;
}
@keyframes qansShimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.qa-nav-shell .qans-s-title { height: 28px; width: 55%; max-width: 220px; }
.qa-nav-shell .qans-s-meta  { height: 16px; width: 40%; max-width: 160px; margin-bottom: .5rem; }
.qa-nav-shell .qans-s-line  { height: 18px; width: 100%; }
.qa-nav-shell .qans-s-line.short { width: 72%; }
.qa-nav-shell .qans-s-opt   { height: 56px; width: 100%; margin-top: .25rem; }
.qa-nav-shell .qans-spinner {
  width: 36px; height: 36px;
  border: 3px solid #e2e8f0; border-top-color: var(--qans-brand);
  border-radius: 50%; animation: qansSpin .7s linear infinite;
  margin: .75rem auto 0;
}
@keyframes qansSpin { to { transform: rotate(360deg); } }

/* Engine fadeIn animation (question-attempt.js uses `animation: fadeIn ...`) */
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Question jumper popover ---------- */
.qa-nav-shell .qans-counter-wrap { position: relative; display: flex; justify-content: center; }
.qa-nav-shell .qans-counter-btn {
  background: transparent; border: 0; cursor: pointer; padding: .25rem .5rem;
  border-radius: 10px; display: inline-flex; flex-direction: column; align-items: center;
  -webkit-tap-highlight-color: transparent; transition: background .15s;
}
.qa-nav-shell .qans-counter-btn:hover { background: #f1f5f9; }
.qa-nav-shell .qans-counter-btn:active { transform: scale(.98); }
.qa-nav-shell .qans-counter-btn[aria-expanded="true"] { background: #e2e8f0; }
.qa-nav-shell .qans-counter-sub {
  display: inline-flex; align-items: center; gap: .25rem;
  font-size: .8125rem; color: var(--qans-muted); font-weight: 600; line-height: 1.2;
}
.qa-nav-shell .qans-counter-chev { transition: transform .2s; }
.qa-nav-shell .qans-counter-btn[aria-expanded="true"] .qans-counter-chev { transform: rotate(180deg); }

.qa-nav-shell .qans-jumper {
  position: absolute; bottom: calc(100% + .625rem); left: 50%; transform: translateX(-50%);
  width: min(92vw, 420px); max-height: 55vh; overflow: hidden;
  background: white; border: 1px solid var(--qans-line); border-radius: 16px;
  box-shadow: 0 16px 40px rgba(15,23,42,.18);
  z-index: 9050; display: flex; flex-direction: column;
  animation: qansSlideUp .18s ease-out;
}
.qa-nav-shell .qans-jumper.hidden { display: none; }
.qa-nav-shell .qans-jumper-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem .875rem .5rem; border-bottom: 1px solid var(--qans-line);
}
.qa-nav-shell .qans-jumper-title { font-size: .8125rem; font-weight: 700; color: var(--qans-ink); text-transform: uppercase; letter-spacing: .04em; }
.qa-nav-shell .qans-jumper-close {
  background: transparent; border: 0; padding: .25rem; border-radius: 8px;
  color: var(--qans-muted); cursor: pointer; display: inline-flex;
}
.qa-nav-shell .qans-jumper-close:hover { background: #f1f5f9; color: var(--qans-ink); }
.qa-nav-shell .qans-jumper-grid {
  padding: .75rem; overflow-y: auto;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: .5rem;
}
.qa-nav-shell .qans-jtile {
  min-height: 44px; min-width: 44px; padding: 0;
  border-radius: 10px; border: 1.5px dashed #cbd5e1;
  background: white; color: var(--qans-ink);
  font-weight: 700; font-size: .9375rem; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .1s, background .15s, border-color .15s;
  -webkit-tap-highlight-color: transparent;
}
.qa-nav-shell .qans-jtile:active { transform: scale(.96); }
.qa-nav-shell .qans-jtile.is-attempted { background: #fef3c7; border-color: #fbbf24; color: #92400e; border-style: solid; }
.qa-nav-shell .qans-jtile.is-correct,
.qa-nav-shell .qans-jtile.is-done { background: #d1fae5; border-color: #34d399; color: #065f46; border-style: solid; }
.qa-nav-shell .qans-jtile.is-wrong { background: #fee2e2; border-color: #f87171; color: #991b1b; border-style: solid; }
.qa-nav-shell .qans-jtile.is-active {
  background: var(--qans-brand); border-color: var(--qans-brand-dark); color: white; border-style: solid;
  box-shadow: 0 0 0 3px rgba(5,150,105,.2);
}

.qa-nav-shell .qans-jtile.is-compact { font-size: 13px; letter-spacing: -0.01em; }
.qa-nav-shell .qans-jtile.is-locked {
  background: #f1f5f9; border-color: #cbd5e1; color: #94a3b8; border-style: solid;
  position: relative;
}
.qa-nav-shell .qans-jtile.is-locked::after {
  content: ""; position: absolute; right: 4px; top: 4px; width: 10px; height: 10px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='11' width='18' height='11' rx='2'/><path d='M7 11V7a5 5 0 0 1 10 0v4'/></svg>");
  background-size: contain; background-repeat: no-repeat;
}

/* ---- Locked question paywall panel ---- */
.qa-nav-shell .qans-locked-panel {
  max-width: 420px; margin: 2rem auto; padding: 2rem 1.25rem;
  text-align: center; background: white; border: 1px solid #e2e8f0;
  border-radius: 16px; box-shadow: 0 4px 14px rgba(15,23,42,.06);
}
.qa-nav-shell .qans-locked-icon {
  width: 72px; height: 72px; margin: 0 auto 1rem;
  border-radius: 50%; background: #fef3c7; color: #b45309;
  display: flex; align-items: center; justify-content: center;
}
.qa-nav-shell .qans-locked-title { font-size: 1.125rem; font-weight: 700; color: var(--qans-ink); margin: 0 0 .5rem; }
.qa-nav-shell .qans-locked-desc { font-size: .9375rem; color: #475569; line-height: 1.5; margin: 0 0 1.25rem; }
.qa-nav-shell .qans-locked-cta { width: 100%; padding: .75rem 1rem; font-size: 1rem; }

/* ---- Meta strip (Form/Topic/Subtopic + expected time) ---- */
.qa-meta-strip { margin: 0 0 .75rem; border: 1px solid #e2e8f0; border-radius: 12px; background: #f8fafc; overflow: hidden; }
.qa-meta-strip__row {
  display: flex; align-items: center; gap: .5rem; width: 100%;
  padding: .5rem .625rem; background: transparent; border: 0; cursor: pointer;
  text-align: left; font: inherit; color: var(--qans-ink, #0f172a);
  -webkit-tap-highlight-color: transparent;
}
.qa-meta-strip__row:hover { background: #f1f5f9; }
.qa-meta-strip__chip {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .1875rem .5rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600; line-height: 1;
  background: #fff; border: 1px solid #e2e8f0; color: #334155;
  white-space: nowrap;
}
.qa-meta-strip__chip svg { width: 12px; height: 12px; }
.qa-meta-strip__chip--time { background: #ecfeff; border-color: #a5f3fc; color: #0e7490; }
.qa-meta-strip__topic {
  flex: 1; min-width: 0; font-size: .8125rem; font-weight: 600; color: #334155;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.qa-meta-strip__chev {
  flex-shrink: 0; width: 16px; height: 16px; color: #64748b;
  transition: transform .18s ease;
}
.qa-meta-strip__row[aria-expanded="true"] .qa-meta-strip__chev { transform: rotate(180deg); }
.qa-meta-strip__details {
  display: none; padding: .5rem .75rem .75rem; border-top: 1px solid #e2e8f0;
  background: #fff;
}
.qa-meta-strip__details.is-open { display: block; }
.qa-meta-strip__detail-row {
  display: flex; gap: .5rem; font-size: .8125rem; line-height: 1.5;
  padding: .1875rem 0;
}
.qa-meta-strip__detail-row + .qa-meta-strip__detail-row { border-top: 1px dashed #e2e8f0; }
.qa-meta-strip__detail-label {
  flex-shrink: 0; min-width: 5.5rem; color: #64748b; font-weight: 600;
  text-transform: uppercase; font-size: .6875rem; letter-spacing: .04em;
  padding-top: .125rem;
}
.qa-meta-strip__detail-value { color: #0f172a; font-weight: 500; }
.qa-meta-strip__secondary-label {
  display: block; margin-top: .5rem; font-size: .6875rem;
  font-weight: 700; color: #64748b; text-transform: uppercase; letter-spacing: .04em;
}
