/* SecAI+ Adaptive Practice Exam — dark, technical, restrained.
   Graphite surfaces; bright blue drives action, bright green means correct. */

:root {
  color-scheme: dark;

  /* surfaces: near-black → graphite, each step one notch lighter */
  --bg:        #0c0f14;
  --bg-2:      #10141b;
  --panel:     #151a23;
  --panel-2:   #1b212c;
  --raised:    #222937;
  --line:      #262e3c;
  --line-soft: #1e2532;

  /* type: white → silver → slate */
  --ink:       #eef2f7;
  --ink-2:     #c2cbd8;
  --muted:     #8492a6;
  --faint:     #5d687a;

  /* accents */
  --blue:      #3d9bff;
  --blue-hi:   #66b2ff;
  --blue-dim:  rgba(61, 155, 255, .13);
  --green:     #2fe08a;
  --green-dim: rgba(47, 224, 138, .12);
  --red:       #ff6b72;
  --red-dim:   rgba(255, 107, 114, .12);

  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;

  --shadow:    0 1px 0 rgba(255,255,255,.03) inset, 0 8px 28px rgba(0,0,0,.45);
  --shadow-sm: 0 2px 10px rgba(0,0,0,.35);
  --ease: cubic-bezier(.22,.61,.36,1);

  --ui:   "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

/* `display` on .modal/.view would otherwise beat the hidden attribute
   and leave an invisible overlay eating every click. */
[hidden] { display: none !important; }

body {
  min-height: 100vh;
  background: var(--bg);
  /* two faint pools of colour so the page isn't a flat slab */
  background-image:
    radial-gradient(900px 520px at 12% -8%,  rgba(61,155,255,.10), transparent 60%),
    radial-gradient(760px 480px at 92% 4%,   rgba(47,224,138,.055), transparent 62%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--ui);
  font-size: 16px;
  line-height: 1.55;
  font-feature-settings: "cv05" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3 { letter-spacing: -.02em; line-height: 1.25; }
h1 { font-size: 1.6rem; font-weight: 700; margin: 0 0 .35em; }
h2 { font-size: 1.05rem; font-weight: 650; margin: 0 0 .7em; }
h3 { font-size: .8rem; font-weight: 650; text-transform: uppercase; letter-spacing: .09em;
     color: var(--muted); margin: 1.4em 0 .6em; }
p  { margin: 0 0 .85em; }
b, strong { font-weight: 650; }

.muted { color: var(--muted); }
.hint  { font-size: .82rem; line-height: 1.5; color: var(--muted); }
.lede  { color: var(--ink-2); max-width: 64ch; }

:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
::selection { background: rgba(61,155,255,.32); }

/* scrollbars inside panels */
* { scrollbar-width: thin; scrollbar-color: var(--raised) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--raised); border-radius: 9px; }

/* ─── top bar ─────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 13px 22px;
  background: rgba(12,15,20,.82);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  border-bottom: 1px solid var(--line-soft);
}
.brand {
  display: flex; align-items: baseline; gap: .45em;
  font-weight: 750; font-size: 1.02rem; letter-spacing: -.025em;
}
.brand::before {
  content: ""; width: 9px; height: 9px; border-radius: 2px; align-self: center;
  background: var(--green); box-shadow: 0 0 10px rgba(47,224,138,.75);
}
.brand span { font-weight: 450; font-size: .95rem; color: var(--muted); letter-spacing: -.01em; }

.topbar-right { display: flex; align-items: center; gap: 16px; }
.who { font-size: .8rem; color: var(--muted); }

.timer {
  font-family: var(--mono); font-weight: 700; font-size: 1.06rem;
  font-variant-numeric: tabular-nums; letter-spacing: .02em;
  padding: 5px 15px; border-radius: 999px;
  color: var(--ink); background: var(--panel-2);
  border: 1px solid var(--line);
  transition: color .3s var(--ease), border-color .3s var(--ease), background .3s var(--ease);
}
.timer.warn { color: #ffd166; border-color: rgba(255,209,102,.5); background: rgba(255,209,102,.08); }
.timer.crit {
  color: var(--red); border-color: rgba(255,107,114,.55); background: var(--red-dim);
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .5; } }

/* ─── layout ──────────────────────────────────────────────── */
.view { max-width: 1120px; margin: 0 auto; padding: 30px 22px 72px; }
#view-home, #view-results { max-width: 920px; }
@media (max-width: 620px) {
  .view { padding: 20px 16px 56px; }
  .topbar { padding: 11px 16px; }
  .brand span, .who { display: none; }   /* keep the bar to one line on a phone */
  .qnav { gap: 8px; }
  .qnav .btn { padding: 10px 13px; }
  .qtext { font-size: 1.04rem; }
}

.card {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 26px;
  margin-bottom: 20px;
}
@media (max-width: 560px) { .card { padding: 20px 17px; border-radius: var(--r); } }

.exam-layout {
  display: grid; grid-template-columns: minmax(0,1fr) 300px;
  gap: 20px; align-items: start;
}
.side { position: sticky; top: 78px; }
@media (max-width: 900px) {
  .exam-layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; order: 2; }
}

/* ─── buttons & fields ────────────────────────────────────── */
.btn {
  font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer;
  display: inline-flex; align-items: center; gap: .5em; white-space: nowrap;
  padding: 10px 17px; border-radius: 10px;
  color: var(--ink-2);
  background: var(--panel-2);
  border: 1px solid var(--line);
  transition: background .16s var(--ease), border-color .16s var(--ease),
              color .16s var(--ease), transform .08s var(--ease);
}
.btn:hover:not(:disabled) { background: var(--raised); border-color: #33405a; color: var(--ink); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .32; cursor: not-allowed; }

.btn.primary {
  color: #041225; border-color: transparent;
  background: linear-gradient(180deg, var(--blue-hi), var(--blue));
  box-shadow: 0 1px 0 rgba(255,255,255,.22) inset, 0 4px 16px rgba(61,155,255,.28);
}
.btn.primary:hover:not(:disabled) {
  color: #041225; background: linear-gradient(180deg, #82c2ff, #4aa4ff);
  box-shadow: 0 1px 0 rgba(255,255,255,.28) inset, 0 6px 22px rgba(61,155,255,.4);
}
.btn.small { padding: 7px 13px; font-size: .84rem; border-radius: 9px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover:not(:disabled) { background: var(--panel-2); color: var(--ink-2); }
.btn.danger:hover:not(:disabled) { color: var(--red); border-color: rgba(255,107,114,.45); background: var(--red-dim); }
.btn.wide { width: 100%; justify-content: center; margin-top: 14px; }

.actions { display: flex; flex-wrap: wrap; gap: 11px; margin-top: 20px; }
.actions.secondary { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line-soft); }

/* spec strip under the intro copy */
.specs {
  list-style: none; display: flex; flex-wrap: wrap; gap: 10px;
  padding: 0; margin: 22px 0 4px;
}
.specs li {
  display: flex; align-items: baseline; gap: .45em;
  padding: 9px 15px; border-radius: 999px;
  background: var(--bg-2); border: 1px solid var(--line);
}
.specs b {
  font-family: var(--mono); font-size: .95rem; font-weight: 700;
  color: var(--blue-hi); letter-spacing: -.01em;
}
.specs li:last-child b { color: var(--green); font-family: var(--ui); font-size: .88rem; }
.specs span { font-size: .82rem; color: var(--muted); }

.field { display: block; margin: 24px 0 8px; max-width: 360px; }
.field span {
  display: block; font-size: .74rem; font-weight: 650; text-transform: uppercase;
  letter-spacing: .09em; color: var(--muted); margin-bottom: 7px;
}
.field input {
  font: inherit; width: 100%; padding: 11px 14px;
  border-radius: 10px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line);
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.field input::placeholder { color: var(--faint); }
.field input:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-dim);
}

.check { display: flex; align-items: flex-start; gap: 10px; font-size: .88rem;
         color: var(--ink-2); margin: 16px 0; cursor: pointer; }
.check input { margin-top: 2px; }

kbd {
  font-family: var(--mono); font-size: .74em; font-weight: 500;
  padding: 2px 6px; border-radius: 5px; color: var(--ink-2);
  background: var(--raised); border: 1px solid var(--line); border-bottom-width: 2px;
}

/* ─── question ────────────────────────────────────────────── */
.qhead { display: flex; align-items: center; gap: 13px; flex-wrap: wrap; margin-bottom: 18px; }
.qcount {
  font-family: var(--mono); font-size: .78rem; font-weight: 500;
  letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.qcount b { color: var(--ink); font-weight: 700; }

.badge {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
  padding: 4px 10px; border-radius: 999px;
  color: var(--green); background: var(--green-dim);
  border: 1px solid rgba(47,224,138,.35);
}

.btn.flag { margin-left: auto; padding: 7px 13px; font-size: .82rem; }
.btn.flag .flag-icon { font-size: .95em; line-height: 1; }
.btn.flag[aria-pressed="true"] {
  color: var(--blue); background: var(--blue-dim); border-color: rgba(61,155,255,.5);
}

.qtext {
  font-size: 1.1rem; line-height: 1.62; color: var(--ink);
  letter-spacing: -.008em; margin-bottom: 22px; white-space: pre-wrap;
}

/* a table / command output that belongs to the question */
.exhibit {
  margin: 12px 0; padding: 12px 14px; overflow-x: auto; max-width: 100%;
  font-family: var(--mono); font-size: .8rem; line-height: 1.5; white-space: pre;
  color: var(--ink-2); background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px;
}

/* long unbreakable strings (registry keys, file paths, URLs) must wrap instead of widening the page */
.qtext, .opt, .review .rtext, .review ul li, .review .why, .flag-list { overflow-wrap: anywhere; }

/* an exhibit image from the source PDF: light backing so dark-on-white screenshots stay legible */
.exhibit-img {
  display: block; max-width: 100%; height: auto; margin: 12px 0; padding: 6px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
}

.options { display: flex; flex-direction: column; gap: 10px; }
.opt {
  display: flex; gap: 13px; align-items: flex-start; cursor: pointer;
  padding: 14px 16px; border-radius: 11px;
  color: var(--ink-2);
  background: var(--bg-2); border: 1px solid var(--line);
  transition: background .14s var(--ease), border-color .14s var(--ease), color .14s var(--ease);
}
.opt:hover { background: var(--panel-2); border-color: #33405a; color: var(--ink); }
.opt input, .check input {
  appearance: none; -webkit-appearance: none; flex: none; cursor: pointer;
  width: 17px; height: 17px; margin: 0; position: relative;
  background: var(--bg); border: 1.5px solid #3a465c;
  transition: border-color .14s var(--ease), background .14s var(--ease), box-shadow .14s var(--ease);
}
.opt input { margin-top: 2px; }
.opt input[type=radio],    .check input[type=radio]    { border-radius: 50%; }
.opt input[type=checkbox], .check input[type=checkbox] { border-radius: 5px; }
.opt:hover input { border-color: #4d5c78; }

.opt input:checked, .check input:checked { border-color: var(--blue); background: var(--blue); }
.opt input:checked::after, .check input:checked::after {
  content: ""; position: absolute; inset: 0; margin: auto;
}
.opt input[type=radio]:checked::after, .check input[type=radio]:checked::after {
  width: 6px; height: 6px; border-radius: 50%; background: #06182c;
}
.opt input[type=checkbox]:checked::after, .check input[type=checkbox]:checked::after {
  width: 5px; height: 9px; margin-top: -1px;
  border: solid #06182c; border-width: 0 2px 2px 0; transform: rotate(42deg);
}
.opt .letter {
  font-family: var(--mono); font-weight: 700; font-size: .84rem;
  color: var(--faint); flex: none; min-width: 1.15em; padding-top: .12em;
}
.opt.sel {
  color: var(--ink);
  background: var(--blue-dim);
  border-color: rgba(61,155,255,.55);
  box-shadow: 0 0 0 1px rgba(61,155,255,.18), 0 4px 16px rgba(61,155,255,.1);
}
.opt.sel .letter { color: var(--blue-hi); }

.qnav {
  display: flex; gap: 11px; align-items: center;
  margin-top: 24px; padding-top: 19px; border-top: 1px solid var(--line-soft);
}
.qnav #btn-next { margin-left: auto; }

/* ─── navigator ───────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.grid button {
  position: relative; font-family: var(--mono); font-size: .76rem; font-weight: 500;
  cursor: pointer; aspect-ratio: 1; padding: 0;
  color: var(--muted); background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 7px;
  transition: background .14s var(--ease), color .14s var(--ease),
              border-color .14s var(--ease), transform .1s var(--ease);
}
.grid button:hover { transform: translateY(-1px); border-color: #3a4763; color: var(--ink); }

/* answered → green fill */
.grid button.answered {
  color: var(--green); background: var(--green-dim);
  border-color: rgba(47,224,138,.42); font-weight: 700;
}
/* flagged → blue border plus a corner marker, so it reads even next to green */
.grid button.flagged { border-color: var(--blue); color: var(--blue-hi); }
.grid button.flagged::after {
  content: ""; position: absolute; top: 3px; right: 3px;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--blue-hi); box-shadow: 0 0 6px rgba(102,178,255,.8);
}
.grid button.flagged.answered { background: var(--green-dim); color: var(--green); }
/* current → silver ring */
.grid button.current {
  box-shadow: 0 0 0 2px var(--ink-2); border-color: transparent; color: var(--ink);
}

.legend {
  list-style: none; display: flex; flex-wrap: wrap; gap: 13px;
  padding: 0; margin: 13px 0 0; font-size: .72rem; color: var(--muted);
}
.legend li { display: flex; align-items: center; gap: 6px; }
.sw {
  width: 11px; height: 11px; border-radius: 3px; display: inline-block;
  background: var(--bg-2); border: 1px solid var(--line);
}
.sw.answered { background: var(--green-dim); border-color: rgba(47,224,138,.42); }
.sw.flagged { background: transparent; border-color: var(--blue); position: relative; }
.sw.flagged::after {
  content: ""; position: absolute; top: 1px; right: 1px;
  width: 3px; height: 3px; border-radius: 50%; background: var(--blue-hi);
}

.flagged-block { margin-top: 4px; }
.flag-list { list-style: none; padding: 0; margin: 0; max-height: 196px; overflow-y: auto; }
.flag-list li { margin-bottom: 5px; }
.flag-list li.empty { font-size: .82rem; color: var(--faint); padding: 2px 0; }
.flag-list button {
  font: inherit; font-size: .82rem; text-align: left; cursor: pointer; width: 100%;
  display: flex; gap: 9px; align-items: baseline;
  padding: 8px 10px; border-radius: 8px; color: var(--ink-2);
  background: var(--blue-dim); border: 1px solid rgba(61,155,255,.32);
  transition: background .14s var(--ease), border-color .14s var(--ease);
}
.flag-list button:hover { background: rgba(61,155,255,.22); border-color: var(--blue); color: var(--ink); }
.flag-list b { font-family: var(--mono); font-size: .76rem; color: var(--blue-hi); flex: none; }
.flag-list span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.progress-line {
  margin: 17px 0 0; font-size: .8rem; color: var(--muted);
  padding-top: 15px; border-top: 1px solid var(--line-soft);
}
#answered-count { font-family: var(--mono); font-weight: 700; color: var(--ink); }
.kbd { margin-top: 12px; line-height: 2; }

/* ─── progress card ───────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(126px, 1fr)); gap: 11px; }
.stat {
  position: relative; overflow: hidden;
  background: var(--bg-2);
  border: 1px solid var(--line); border-left: 2px solid rgba(61,155,255,.55);
  border-radius: var(--r); padding: 15px 16px;
}
.stat b {
  display: block; font-family: var(--mono); font-size: 1.6rem; font-weight: 700;
  line-height: 1.15; letter-spacing: -.02em; color: var(--ink);
}
.stat span { font-size: .75rem; color: var(--muted); }
.stat i { font-style: normal; color: var(--ink-2); }
#st-weak     { color: var(--red); }
.stat:nth-child(3) { border-left-color: rgba(255,107,114,.55); }
.stat:nth-child(4) { border-left-color: rgba(47,224,138,.55); }
#st-mastered { color: var(--green); }

.history {
  display: flex; align-items: flex-end; gap: 6px; height: 64px;
  margin: 6px 0 4px; padding: 0 1px 7px;
  border-bottom: 1px solid var(--line);
}
.hist-title { margin: 24px 0 0; }
.history i {
  flex: 1; max-width: 22px; min-height: 3px; border-radius: 4px 4px 1px 1px;
  background: linear-gradient(180deg, var(--blue-hi), rgba(61,155,255,.35));
}
.history i:last-child { background: linear-gradient(180deg, var(--green), rgba(47,224,138,.3)); }

.weak-list { margin-top: 18px; font-size: .88rem; }
.weak-list summary {
  cursor: pointer; font-weight: 600; color: var(--ink-2);
  padding: 11px 0; list-style: none;
}
.weak-list summary::-webkit-details-marker { display: none; }
.weak-list summary::before {
  content: "▸"; display: inline-block; margin-right: .5em;
  color: var(--blue); font-size: .85em;
  transition: transform .15s var(--ease);
}
.weak-list[open] summary::before { transform: rotate(90deg); }
.weak-list summary:hover { color: var(--ink); }
.weak-list ol { max-height: 320px; overflow-y: auto; padding-left: 1.5em; margin: 4px 0 0; }
.weak-list li { margin: .65em 0; color: var(--muted); line-height: 1.5; }
.weak-list .misses { font-family: var(--mono); font-size: .8em; font-weight: 700; color: var(--red); }

/* ─── results ─────────────────────────────────────────────── */
.score-row { display: flex; align-items: center; gap: 26px; flex-wrap: wrap; }
.ring {
  --pct: 0; width: 124px; height: 124px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: conic-gradient(var(--blue) 0deg, var(--green) calc(var(--pct) * 3.6deg),
                             var(--line-soft) calc(var(--pct) * 3.6deg));
}
.ring b {
  width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center;
  background: var(--panel); color: var(--ink);
  font-family: var(--mono); font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em;
}
.score-facts p { margin: 0 0 .35em; color: var(--muted); font-size: .92rem; }
.score-facts b { font-family: var(--mono); font-size: 1.2rem; color: var(--ink); }

/* ─── review list ─────────────────────────────────────────── */
.review-filter { margin-bottom: 10px; }
.review { list-style: none; padding: 0; margin: 0; }
.review > li { padding: 19px 0; border-top: 1px solid var(--line-soft); }
.review > li:first-child { border-top: 0; padding-top: 4px; }

.review .rq { display: flex; gap: 11px; align-items: baseline; }
.review .rn { font-family: var(--mono); font-size: .85rem; color: var(--faint); flex: none; }
.review .rtext { flex: 1; min-width: 0; color: var(--ink); line-height: 1.55; white-space: pre-line; }

.review .tag {
  font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .09em;
  padding: 4px 9px; border-radius: 999px; flex: none; align-self: flex-start;
}
.review .tag.ok   { color: var(--green); background: var(--green-dim); border: 1px solid rgba(47,224,138,.32); }
.review .tag.no   { color: var(--red);   background: var(--red-dim);   border: 1px solid rgba(255,107,114,.32); }
.review .tag.skip { color: var(--muted); background: var(--raised);    border: 1px solid var(--line); }

.review ul { list-style: none; padding: 0; margin: 13px 0 0 2.1em; font-size: .9rem; }
.review ul li {
  display: flex; gap: .5em; padding: 8px 12px; margin-bottom: 5px;
  border-radius: 8px; border: 1px solid transparent; color: var(--muted);
}
.review li.correct {
  color: var(--green); background: var(--green-dim);
  border-color: rgba(47,224,138,.35); font-weight: 600;
}
.review li.chosen-wrong {
  color: var(--red); background: var(--red-dim);
  border-color: rgba(255,107,114,.35); text-decoration: line-through;
  text-decoration-color: rgba(255,107,114,.45);
}
.review .mark { font-family: var(--mono); font-weight: 700; flex: none; width: 1em; }
.review .why {
  margin: 10px 0 0 2.1em; padding: 10px 14px; font-size: .9rem; line-height: 1.6;
  color: var(--ink-2); background: var(--panel-2); border-left: 2px solid var(--line);
  border-radius: 0 8px 8px 0;
}
.review .why-label {
  display: block; margin-bottom: 3px; font-family: var(--mono); font-size: .7rem;
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}

/* ─── modal ───────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 18px;
  background: rgba(6,8,12,.72);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fade .16s var(--ease);
}
@keyframes fade { from { opacity: 0; } }
.modal-box {
  max-width: 440px; padding: 26px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: 0 24px 60px rgba(0,0,0,.6);
  animation: rise .2s var(--ease);
}
@keyframes rise { from { opacity: 0; transform: translateY(10px) scale(.985); } }
.modal-box p { color: var(--ink-2); }

/* ─── footer ──────────────────────────────────────────────── */
.foot {
  text-align: center; font-size: .76rem; color: var(--faint);
  padding: 0 22px 36px;
}
#foot-count { font-family: var(--mono); color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
