/* Test setup, runner and results */

/* ---------- setup ---------- */
.resume-card { display: flex; align-items: center; gap: 18px; padding: 16px 20px; margin-bottom: 18px; border-color: color-mix(in srgb, var(--gold) 40%, transparent); flex-wrap: wrap; }
.rc-text { flex: 1; min-width: 200px; display: flex; flex-direction: column; }
.setup-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.setup-main > * + * { margin-top: 24px; }
.setup-main > [hidden] + * { margin-top: 24px; }
.setup-row { display: flex; flex-wrap: wrap; gap: 24px; }
.setup-row .field + .field { margin-top: 0; }
.inline-num { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 2px; }
.num-input { width: 90px; text-align: center; font-variant-numeric: tabular-nums; }
.field > .inline-num { margin-top: 8px; }
.toggles { border-top: 1px solid var(--line); padding-top: 10px; }
.toggles .switch-row strong { font-weight: 600; font-size: 0.95rem; }
.chip-count { font-size: 0.72rem; color: var(--text-3); font-weight: 600; font-variant-numeric: tabular-nums; }

.test-summary { position: sticky; top: 24px; text-align: center; overflow: hidden; }
.test-summary::before {
  content: ''; position: absolute; left: 50%; top: -90px; transform: translateX(-50%); width: 300px; height: 240px;
  background: radial-gradient(closest-side, rgba(242, 181, 68, 0.28), transparent); pointer-events: none;
}
.ts-count { position: relative; }
.ts-num { font-size: 5.2rem; line-height: 1; background: linear-gradient(180deg, var(--gold-hi), var(--gold) 55%, var(--ember)); -webkit-background-clip: text; background-clip: text; color: transparent; }
:root[data-theme='light'] .ts-num { background: linear-gradient(180deg, #d58e10, #b06a00 60%, #b5480f); -webkit-background-clip: text; background-clip: text; }
.ts-text { margin: 8px auto 20px; max-width: 30ch; min-height: 2.8em; }
.ts-start { width: 100%; }
.ts-rules { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; text-align: left; font-size: var(--fs-sm); color: var(--text-2); }
.ts-rules li { display: flex; align-items: center; gap: 10px; }
.ts-rules li > svg { width: 16px; height: 16px; color: var(--gold-text); flex: none; }
.ts-rules .kbd-hint { flex-wrap: wrap; gap: 4px; color: var(--text-3); font-size: var(--fs-xs); }

/* ---------- runner ---------- */
.runner { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; min-height: calc(100dvh - 70px); }
.run-top { display: flex; align-items: center; gap: 16px; padding-bottom: 14px; }
.run-title { flex: 1; min-width: 0; display: flex; flex-direction: column; text-align: center; }
.run-title strong { font-family: var(--font-display); font-weight: 400; font-size: 1.2rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-right { display: flex; align-items: center; gap: 14px; }
.mastered-box { display: flex; align-items: center; gap: 10px; }
.mb-text { display: flex; flex-direction: column; line-height: 1.2; }
.mb-of { font-weight: 700; font-size: 0.95rem; }
.pr-label { font-weight: 800; font-size: 0.95rem; }
.ring.bump { animation: bump 0.5s var(--ease-spring); }
@keyframes bump { 40% { transform: scale(1.14); } }
.timer-pill {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 14px; border-radius: 99px;
  background: var(--surface-2); border: 1px solid var(--line-strong); font-weight: 700; font-size: 0.95rem;
}
.timer-pill svg { width: 16px; height: 16px; color: var(--text-3); }
.timer-pill.low { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 50%, transparent); animation: pulse-border 1s ease-in-out infinite; }
.timer-pill.low svg { color: var(--bad); }
@keyframes pulse-border { 50% { box-shadow: 0 0 0 4px var(--bad-soft); } }
.run-bar { height: 3px; border-radius: 3px; background: var(--surface-hover); overflow: hidden; margin-bottom: clamp(18px, 4vh, 40px); }
.run-bar > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--gold-hi)); box-shadow: 0 0 12px var(--gold); transition: width 0.8s var(--ease); }
.run-stage { flex: 1; }
.run-foot { display: flex; justify-content: center; gap: 22px; flex-wrap: wrap; padding: 22px 0 6px; }
.run-foot > span { display: inline-flex; align-items: center; gap: 4px; }

.q-stage { padding: clamp(22px, 4vw, 40px); border-radius: var(--r-xl); }
.q-stage.enter { animation: q-in 0.45s var(--ease) both; }
@keyframes q-in { from { opacity: 0; transform: translateY(14px) scale(0.99); } }
.q-stage.is-return { border-color: color-mix(in srgb, var(--bad) 30%, transparent); }
.qs-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 16px; }
.qs-count { font-size: var(--fs-sm); font-weight: 700; color: var(--text-3); margin-right: 4px; }
.qs-text { font-family: var(--font-display); font-weight: 400; font-size: clamp(1.45rem, 3vw, 2rem); line-height: 1.28; letter-spacing: -0.005em; margin-bottom: 26px; overflow-wrap: anywhere; }
.qs-text.urdu { font-family: var(--font-urdu); font-size: clamp(1.4rem, 3vw, 1.8rem); line-height: 2.2; }

.q-timer { position: relative; height: 6px; border-radius: 6px; background: var(--surface-hover); margin: -10px 0 22px; }
.q-timer > i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--steel); transition: width 0.2s linear; }
.q-timer.low > i { background: var(--bad); }
.q-timer .qt-num { position: absolute; right: 0; top: -22px; font-size: var(--fs-xs); font-weight: 700; color: var(--text-3); }
.q-timer.low .qt-num { color: var(--bad); }

.opts { display: flex; flex-direction: column; gap: 10px; }
.opt {
  position: relative; display: flex; align-items: center; gap: 14px; width: 100%;
  min-height: 60px; padding: 12px 16px 12px 12px; text-align: left;
  border-radius: 16px; border: 1px solid var(--line-strong);
  background: color-mix(in srgb, var(--surface-solid) 55%, transparent); color: var(--text);
  font-size: 1.02rem; line-height: 1.45;
  transition: transform 0.18s var(--ease), border-color 0.2s, background 0.2s, box-shadow 0.25s, opacity 0.3s;
}
@media (hover: hover) {
  .opt:not([disabled]):hover { transform: translateX(4px); border-color: color-mix(in srgb, var(--gold) 65%, transparent); background: var(--surface-2); box-shadow: 0 10px 30px -18px rgba(242, 181, 68, 0.7); }
  .opt:not([disabled]):hover .opt-key { background: var(--gold); color: var(--on-gold); border-color: transparent; }
}
.opt:not([disabled]):active { transform: scale(0.99); }
.opt:focus-visible { outline-offset: 3px; border-radius: 16px; }
.opt[disabled] { cursor: default; }
.opt-key {
  width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 11px;
  font-weight: 800; font-size: 0.9rem; color: var(--text-2); border: 1px solid var(--line-strong); background: var(--surface-2);
  transition: background 0.2s, color 0.2s;
}
.opt-label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.opt-icon { width: 24px; height: 24px; flex: none; display: grid; place-items: center; }
.opt-icon svg { width: 22px; height: 22px; }

.opt.is-correct {
  border-color: var(--ok); background: var(--ok-soft);
  box-shadow: 0 0 0 1px var(--ok), 0 0 34px -6px color-mix(in srgb, var(--ok) 70%, transparent);
}
.opt.is-correct .opt-key { background: var(--ok); color: #04150d; border-color: transparent; }
.opt.is-correct .opt-icon { color: var(--ok); }
.opt.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.is-wrong .opt-key { background: var(--bad); color: #1d0503; border-color: transparent; }
.opt.is-wrong .opt-icon { color: var(--bad); }
.opt.is-answer { border-color: color-mix(in srgb, var(--ok) 70%, transparent); border-style: dashed; }
.opt.is-answer .opt-key { color: var(--ok); border-color: var(--ok); }
.opt.is-answer .opt-icon { color: var(--ok); }
.opt.is-dim { opacity: 0.45; }

/* ---------- exam runner: question + navigator ---------- */
.runner.runner-exam { max-width: 1200px; }
.exam-layout { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 22px; align-items: start; }
.exam-status { margin-top: 14px; }
.exam-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.exam-nav .btn { min-width: 132px; justify-content: center; }
.qnav { position: sticky; top: 16px; padding: 18px; }
.qnav-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.qnav-count { font-family: var(--font-display); font-size: 1.6rem; line-height: 1; color: var(--gold-text, var(--gold)); }
.qnav-hint { margin-top: 4px; }
.qnav-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 8px; margin: 14px 0 16px; max-height: min(52vh, 420px); overflow-y: auto; padding: 2px; }
.qnav-item {
  height: 42px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface-2); color: var(--text);
  font-weight: 650; font-size: 0.92rem; font-variant-numeric: tabular-nums;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.qnav-item:hover { border-color: var(--gold); transform: translateY(-1px); }
.qnav-item.is-current { background: var(--gold); color: var(--on-gold); border-color: transparent; box-shadow: 0 6px 18px -8px var(--gold); }
.qnav-empty { margin: 14px 0 16px; }
.qnav-submit { width: 100%; justify-content: center; }
.qnav-submit.is-ready { box-shadow: 0 0 0 4px color-mix(in srgb, var(--gold) 28%, transparent); }
@media (max-width: 920px) {
  .exam-layout { grid-template-columns: 1fr; }
  .qnav { position: static; }
  .qnav-grid { max-height: none; }
}
@media (max-width: 520px) {
  .exam-nav .btn { min-width: 0; flex: 1; }
}
/* Exam mode ("show right or wrong" off): the pick is marked neutrally. */
.opt.is-picked { border-color: var(--steel); background: var(--steel-soft); }
.opt.is-picked .opt-key { background: var(--steel); color: #0b1020; border-color: transparent; }
.fb-neutral { background: var(--surface-2); border: 1px solid var(--line); align-items: center; }
.fb-neutral .fb-ic { background: var(--steel-soft); color: var(--steel); }
.pop { animation: pop 0.45s var(--ease-spring); }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.03); } 100% { transform: scale(1); } }
.shake { animation: shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

.feedback:empty { display: none; }
.feedback { margin-top: 18px; }
.fb { display: flex; align-items: flex-start; gap: 14px; padding: 14px 14px 14px 16px; border-radius: 16px; animation: modal-in 0.35s var(--ease) both; flex-wrap: wrap; }
.fb-ok { background: var(--ok-soft); border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); }
.fb-bad { background: var(--bad-soft); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); }
.fb-ic { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 10px; }
.fb-ic svg { width: 18px; height: 18px; }
.fb-ok .fb-ic { background: var(--ok); color: #04150d; }
.fb-bad .fb-ic { background: var(--bad); color: #1d0503; }
.fb-body { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 4px; font-size: 0.95rem; }
.fb-body strong { font-size: 1rem; }
.fb .btn { align-self: center; }

.saving { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 300px; color: var(--text-2); }

.burst { position: fixed; z-index: 80; pointer-events: none; width: 0; height: 0; }
.burst i {
  position: absolute; width: 7px; height: 7px; border-radius: 2px; left: -3px; top: -3px;
  background: var(--gold-hi); box-shadow: 0 0 8px var(--gold);
  animation: spark 0.7s var(--ease) forwards;
}
.burst i:nth-child(3n) { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.burst i:nth-child(4n) { width: 5px; height: 5px; border-radius: 50%; }
@keyframes spark {
  from { transform: translate(0, 0) scale(1); opacity: 1; }
  to { transform: translate(var(--dx), var(--dy)) scale(0.2) rotate(120deg); opacity: 0; }
}

/* ---------- results ---------- */
.results-hero { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: clamp(22px, 5vw, 56px); align-items: center; padding: clamp(24px, 4vw, 44px); overflow: hidden; }
.results-hero::before {
  content: ''; position: absolute; left: -100px; top: -140px; width: 480px; height: 480px; border-radius: 50%;
  background: radial-gradient(circle, rgba(242, 181, 68, 0.22), transparent 62%); pointer-events: none;
}
.results-hero.great::before { background: radial-gradient(circle, rgba(70, 209, 154, 0.22), rgba(242, 181, 68, 0.12) 40%, transparent 65%); }
.rh-ring { position: relative; }
.rs-ring-label { display: flex; flex-direction: column; align-items: center; }
.rs-score-wrap { display: flex; align-items: flex-start; line-height: 1; }
.rs-score { font-size: 4.4rem; letter-spacing: -0.03em; }
.rs-pct { font-family: var(--font-display); font-size: 1.6rem; margin-top: 8px; color: var(--text-2); }
.rh-copy { position: relative; }
.rh-kicker { margin-bottom: 6px; }
.rh-grade { font-size: clamp(2.4rem, 5.5vw, 3.8rem); line-height: 1; letter-spacing: -0.02em; }
.results-hero.great .rh-grade { background: linear-gradient(100deg, var(--gold-hi), var(--gold) 50%, var(--ember)); -webkit-background-clip: text; background-clip: text; color: transparent; }
:root[data-theme='light'] .results-hero.great .rh-grade { background: linear-gradient(100deg, #c98200, #a65d00 60%, #b5480f); -webkit-background-clip: text; background-clip: text; }
.rh-sub { color: var(--text-2); margin: 10px 0 20px; font-size: 1.04rem; max-width: 52ch; }
.rh-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin: 0 0 24px; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.rh-stat { padding: 12px 14px; }
.rh-stat + .rh-stat { border-left: 1px solid var(--line); }
.rh-stat dt { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--text-3); font-weight: 600; }
.rh-stat dt svg { width: 14px; height: 14px; }
.rh-stat dd { margin: 4px 0 0; font-family: var(--font-display); font-size: 1.45rem; line-height: 1.1; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .setup-grid { grid-template-columns: 1fr; }
  .test-summary { position: static; order: -1; }
  .ts-num { font-size: 4rem; }
  .ts-rules { display: none; }
}
@media (max-width: 760px) {
  .results-hero { grid-template-columns: 1fr; text-align: center; }
  .rh-ring { justify-self: center; }
  .rh-sub { margin-left: auto; margin-right: auto; }
  .rh-stats { grid-template-columns: 1fr 1fr; text-align: left; }
  .rh-stat:nth-child(3) { border-left: 0; }
  .rh-stat:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .rs-actions { justify-content: center; }
  .run-title { display: none; }
  .run-top { justify-content: space-between; }
  .run-foot { display: none; }
  .mb-text { display: none; }
}
@media (max-width: 480px) {
  .runner { min-height: auto; }
  .q-stage { padding: 20px 16px; }
  .qs-text { font-size: 1.32rem; margin-bottom: 20px; }
  .opt { min-height: 54px; padding: 10px 12px 10px 10px; gap: 12px; font-size: 0.97rem; }
  .opt-key { width: 32px; height: 32px; }
  .rs-ring { transform: scale(0.85); margin: -14px 0; }
}
