/* ==================================================================
   Companion tools (Python readiness check, mirror exam).

   Loaded after assets/theme.css, which supplies every colour, radius
   and shadow token, so these pages re-skin with the rest of the Study
   Lab — light by default, dark via the same topbar toggle. Class names
   are t- prefixed so nothing here collides with the guide's own CSS.
================================================================== */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Source Sans 3', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, h4 { font-family: 'Fraunces', serif; font-weight: 600; line-height: 1.25; }
a { color: var(--accent); }

/* ---------- Topbar: same chrome as the guide ---------- */
.topbar-global {
  position: sticky; top: 0; z-index: 20;
  height: 52px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
}
.topbar-brand { text-decoration: none; display: inline-flex; align-items: baseline; }
.topbar-brand span {
  font-family: 'Source Sans 3', sans-serif; font-weight: 500;
  color: var(--ink-soft); margin-left: 6px;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-link {
  font-weight: 600; font-size: 12.5px; color: var(--ink); text-decoration: none;
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px;
  background: var(--paper);
}
.topbar-link:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle {
  display: flex; align-items: center; gap: 8px;
  font-family: 'Source Sans 3', sans-serif; font-weight: 600; font-size: 12.5px;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 14px 6px 6px; cursor: pointer;
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle-dot {
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; font-size: 11px;
}
.topbar-link:focus-visible, .theme-toggle:focus-visible, .topbar-brand:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---------- Page ---------- */
.t-page { max-width: 760px; margin: 0 auto; padding: 28px 16px 72px; }

.t-eyebrow {
  font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent);
  margin: 0 0 8px;
}
.t-title { font-size: 2rem; margin: 0 0 10px; letter-spacing: -0.02em; }
.t-lede { color: var(--ink-mid); font-size: 15.5px; margin: 0 0 12px; max-width: 64ch; }
.t-muted { color: var(--ink-soft); font-size: 14px; margin: 0 0 10px; }

.t-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 26px 26px 22px;
}
.t-card + .t-card { margin-top: 16px; }

.t-hero { margin-bottom: 22px; }

.t-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1px; background: var(--line); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; margin: 20px 0 22px;
}
.t-stat { background: var(--card-tint); padding: 14px 10px; text-align: center; }
.t-stat-n { font-family: 'Fraunces', serif; font-weight: 700; font-size: 1.35rem; line-height: 1.1; display: block; }
.t-stat-l {
  font-family: 'JetBrains Mono', monospace; font-size: 10.5px; color: var(--ink-soft);
  text-transform: uppercase; letter-spacing: 0.06em;
}

.t-notice {
  border-radius: 10px; padding: 12px 14px; margin: 12px 0;
  font-size: 13.5px; line-height: 1.55; color: var(--ink-mid);
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
}
.t-notice.warn { background: var(--gold-soft); border-color: color-mix(in srgb, var(--gold) 35%, transparent); }
.t-notice-title {
  font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 12px;
  color: var(--accent); margin-bottom: 4px;
}

.t-domain-table { width: 100%; border-collapse: collapse; margin: 18px 0 8px; font-size: 13.5px; box-shadow: none; border-radius: 0; }
.t-domain-table td { padding: 9px 0; border-bottom: 1px dashed var(--line); vertical-align: top; }
.t-domain-table td:last-child {
  text-align: right; font-family: 'JetBrains Mono', monospace; font-size: 12px;
  color: var(--ink-soft); white-space: nowrap; padding-left: 12px;
}
.t-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }

/* ---------- Buttons ---------- */
.t-btn {
  font-family: 'Source Sans 3', sans-serif; font-weight: 600; font-size: 14px;
  border-radius: 999px; padding: 10px 20px; cursor: pointer;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}
.t-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.t-btn.primary { background: var(--accent); border-color: transparent; color: #fff; box-shadow: var(--shadow-sm); }
.t-btn.primary:hover:not(:disabled) { background: var(--accent-deep); color: #fff; }
:root[data-theme="dark"] .t-btn.primary { color: #06202A; }
:root[data-theme="dark"] .t-btn.primary:hover:not(:disabled) { color: #06202A; }
.t-btn.small { padding: 6px 13px; font-size: 12.5px; }
.t-btn.on { background: var(--gold-soft); border-color: var(--gold); color: var(--gold); }
.t-btn:disabled { opacity: 0.4; cursor: default; }
.t-btn:focus-visible, .t-opt:focus-visible, .t-grid button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.t-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.t-actions.center { justify-content: center; }

/* ---------- Run status row ---------- */
.t-status {
  display: flex; align-items: center; gap: 14px; margin-bottom: 16px;
  font-family: 'JetBrains Mono', monospace; font-size: 12.5px; color: var(--ink-soft);
}
.t-track { flex: 1; height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.t-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.25s ease; }
.t-tally { display: flex; gap: 12px; }
.t-tally .ok { color: var(--pass); }
.t-tally .no { color: var(--fail); }
.t-timer {
  font-weight: 700; color: var(--ink); padding: 4px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line);
}
.t-timer.low { color: var(--fail); border-color: var(--fail); }

/* ---------- Tags ---------- */
.t-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.t-tag {
  display: inline-block; font-family: 'JetBrains Mono', monospace;
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: var(--card-tint); color: var(--ink-soft); border: 1px solid var(--line);
}
.t-tag.beginner { background: var(--card-tint); color: var(--ink-soft); }
.t-tag.intermediate { background: var(--gold-soft); color: var(--gold); border-color: transparent; }
.t-tag.review { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.t-tag.dom-plan    { background: var(--dom-plan-soft);    color: var(--dom-plan);    border-color: transparent; }
.t-tag.dom-genai   { background: var(--dom-genai-soft);   color: var(--dom-genai);   border-color: transparent; }
.t-tag.dom-vision  { background: var(--dom-vision-soft);  color: var(--dom-vision);  border-color: transparent; }
.t-tag.dom-text    { background: var(--dom-text-soft);    color: var(--dom-text);    border-color: transparent; }
.t-tag.dom-extract { background: var(--dom-extract-soft); color: var(--dom-extract); border-color: transparent; }

/* ---------- Question ---------- */
.t-q { font-size: 17px; line-height: 1.5; font-weight: 600; margin: 0 0 14px; color: var(--ink); }
.t-snippet {
  font-family: 'JetBrains Mono', monospace; font-size: 13.5px; line-height: 1.55;
  background: var(--card-tint); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; margin: 0 0 18px; overflow-x: auto; color: var(--ink);
}
.t-exhibit {
  font-size: 14px; line-height: 1.6; white-space: pre-wrap; color: var(--ink-mid);
  background: var(--card-tint); border: 1px solid var(--line);
  border-left: 3px solid var(--accent); border-radius: 10px;
  padding: 14px 16px; margin: 0 0 16px;
}

.t-opts { display: flex; flex-direction: column; gap: 9px; }
.t-opt {
  text-align: left; font: inherit; font-size: 14.5px; line-height: 1.45;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 11px 14px; cursor: pointer;
  display: flex; align-items: flex-start; gap: 10px;
  transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}
.t-opt.code { font-family: 'JetBrains Mono', monospace; font-size: 13.5px; white-space: pre-wrap; }
.t-opt:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.t-opt:disabled { cursor: default; }
.t-opt .idx { flex: 0 0 auto; font-family: 'JetBrains Mono', monospace; font-weight: 700; color: var(--ink-soft); }
.t-opt.picked { border-color: var(--accent); background: var(--accent-soft); }
.t-opt.picked .idx { color: var(--accent); }
.t-opt.correct { border-color: var(--pass); background: var(--pass-soft); }
.t-opt.correct .idx { color: var(--pass); }
.t-opt.wrong { border-color: var(--fail); background: var(--fail-soft); }
.t-opt.wrong .idx { color: var(--fail); }
.t-opt.dim { opacity: 0.6; }

.t-explain {
  margin-top: 16px; padding: 12px 14px; border-radius: 10px;
  background: var(--card-tint); border: 1px solid var(--line);
  font-size: 14px; line-height: 1.55; color: var(--ink-mid);
}
.t-verdict { font-weight: 700; margin-bottom: 6px; }
.t-verdict.ok { color: var(--pass); }
.t-verdict.no { color: var(--fail); }
.t-line { margin-top: 6px; padding-left: 10px; border-left: 3px solid var(--line); }
.t-line.wrong { border-left-color: var(--fail); }
.t-line.right { border-left-color: var(--pass); }
.t-line b { color: var(--ink); }

.t-nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.t-nav.end { justify-content: flex-end; }
.t-nav .left { display: flex; gap: 8px; flex-wrap: wrap; }

/* Build-list ordering */
.t-order { display: flex; flex-direction: column; gap: 8px; }
.t-order-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 9px 12px;
}
.t-order-n { font-family: 'JetBrains Mono', monospace; font-weight: 700; color: var(--ink-soft); flex: 0 0 auto; }
.t-order-text { flex: 1; font-size: 14px; }
.t-order-btns { display: flex; gap: 4px; flex: 0 0 auto; }

/* Question navigator */
.t-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; margin-top: 20px; }
.t-grid button {
  font-family: 'JetBrains Mono', monospace; font-size: 11px; padding: 6px 0;
  border-radius: 6px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-soft); cursor: pointer;
}
.t-grid button.answered { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.t-grid button.flagged { background: var(--gold-soft); border-color: var(--gold); color: var(--gold); }
.t-grid button.current { outline: 2px solid var(--ink); outline-offset: 1px; color: var(--ink); font-weight: 700; }

/* ---------- Results ---------- */
.t-result { text-align: center; padding: 34px 26px; }
.t-big { font-family: 'Fraunces', serif; font-size: 2.6rem; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 2px; }
.t-big.pass { color: var(--pass); }
.t-big.fail { color: var(--fail); }
.t-pct { font-family: 'JetBrains Mono', monospace; font-size: 14.5px; color: var(--ink-soft); margin-bottom: 8px; }
.t-result .t-muted { margin-bottom: 20px; }
.t-result .t-notice { text-align: left; margin: 0 0 22px; }

.t-section { text-align: left; margin-top: 26px; padding-top: 20px; border-top: 1px solid var(--line); }
.t-section h3 { font-size: 1.05rem; margin: 0 0 14px; }
.t-row { display: flex; justify-content: space-between; font-size: 14px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.t-row:last-child { border-bottom: none; }
.t-row .miss { color: var(--fail); font-family: 'JetBrains Mono', monospace; font-size: 12.5px; }

.t-bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 11px; font-size: 13.5px; }
.t-bar-row .name { width: 42%; flex: 0 0 auto; }
.t-bar-row .t-track { height: 8px; border-radius: 4px; }
.t-bar-row .score { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--ink-soft); width: 48px; text-align: right; }

.t-review-item { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; background: var(--surface); }
.t-review-item.wrong { border-left: 3px solid var(--fail); }
.t-review-item.right { border-left: 3px solid var(--pass); }
.t-review-item .t-tags { margin-bottom: 6px; }
.t-review-q { font-size: 14.5px; font-weight: 600; margin: 4px 0 8px; }
.t-review-item .t-line { font-size: 13.5px; line-height: 1.5; color: var(--ink-mid); }

.t-foot { margin-top: 28px; text-align: center; font-size: 13px; color: var(--ink-soft); }
.t-foot a { font-weight: 600; text-decoration: none; }
.t-foot a:hover { text-decoration: underline; }
/* Privacy Policy / Legal Notice / Cookie Settings, under the line above. */
.t-foot-legal { margin-top: 8px; justify-content: center; }

@media (max-width: 640px) {
  .t-page { padding-top: 20px; }
  .t-title { font-size: 1.6rem; }
  .t-card { padding: 20px 16px 18px; }
  .t-result { padding: 26px 16px; }
  .t-grid { grid-template-columns: repeat(8, 1fr); }
  .t-bar-row .name { width: 38%; font-size: 12.5px; }
  .topbar-link { display: none; }
  .theme-toggle-label { display: none; }
  .theme-toggle { padding: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .t-opt, .t-btn, .t-fill { transition: none; }
  .t-opt:hover:not(:disabled) { transform: none; }
}

/* ---------- Mirror exam: hero header + live tracker ---------- */
.t-page.wide { max-width: 1080px; }

.x-hero {
  display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
  position: relative; overflow: hidden; margin-bottom: 18px;
  padding: 22px 26px; border-radius: var(--radius); color: #fff;
  background:
    radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--dom-vision) 70%, transparent) 0%, transparent 55%),
    radial-gradient(90% 120% at 0% 100%, color-mix(in srgb, var(--dom-genai) 60%, transparent) 0%, transparent 60%),
    linear-gradient(135deg, #0B1B4D 0%, var(--accent-deep) 55%, var(--accent) 130%);
  box-shadow: var(--shadow-md);
}
.x-hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0.35;
  background-image: linear-gradient(rgba(255,255,255,.08) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.08) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(100deg, transparent 20%, #000 100%);
  -webkit-mask-image: linear-gradient(100deg, transparent 20%, #000 100%);
}
.x-hero-main, .x-clock { position: relative; z-index: 1; }
.x-hero-eyebrow {
  display: flex; align-items: center; gap: 8px; margin: 0 0 6px;
  font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.12em; color: rgba(255,255,255,.8);
}
.x-live { width: 8px; height: 8px; border-radius: 50%; background: #4ADE80; box-shadow: 0 0 0 0 rgba(74,222,128,.6); animation: x-pulse 1.8s infinite; }
@keyframes x-pulse { 70% { box-shadow: 0 0 0 8px rgba(74,222,128,0); } 100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); } }
.x-hero-title { margin: 0; font-size: 1.85rem; letter-spacing: -0.02em; color: #fff; }
.x-hero-sub { margin: 4px 0 0; font-size: 14px; color: rgba(255,255,255,.8); }
.x-hero-sub b { color: #fff; }
.x-clock {
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
  padding: 10px 16px; border-radius: 14px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.28);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.x-clock-label { font-family: 'JetBrains Mono', monospace; font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: rgba(255,255,255,.75); }
.x-clock .t-timer { font-size: 1.7rem; padding: 0; background: none; border: none; color: #fff; letter-spacing: 0.02em; }
.x-clock .t-timer.low { color: #FCA5A5; }
.x-clock.low { border-color: #FCA5A5; }

.x-layout { display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 18px; align-items: start; }
.x-flag-jumps { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.x-tracker {
  position: sticky; top: 68px; display: flex; flex-direction: column; gap: 14px;
  max-height: calc(100vh - 86px);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-md); padding: 16px 12px 12px;
}
.x-ring {
  --pct: 0; align-self: center; position: relative; width: 104px; height: 104px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--line) 0);
}
.x-ring::before { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--surface); }
.x-ring > * { position: relative; }
.x-ring-n { font-family: 'Fraunces', serif; font-weight: 700; font-size: 1.4rem; line-height: 1; }
.x-ring-l { font-family: 'JetBrains Mono', monospace; font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.x-counts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; text-align: center; }
.x-counts div { background: var(--card-tint); border-radius: 8px; padding: 6px 2px; }
.x-counts b { display: block; font-family: 'Fraunces', serif; font-size: 1.1rem; line-height: 1.1; }
.x-counts span { font-family: 'JetBrains Mono', monospace; font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); }
.x-counts .fl b { color: var(--gold); }

.x-list { list-style: none; margin: 0; padding: 0 2px 0 0; overflow-y: auto; min-height: 0; position: relative; display: flex; flex-direction: column; gap: 3px; }
.x-row {
  width: 100%; display: flex; align-items: center; gap: 8px; text-align: left;
  font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: var(--ink-soft);
  padding: 5px 8px; border-radius: 8px; cursor: pointer;
  border: 1px solid transparent; background: transparent;
}
.x-row:hover { background: var(--card-tint); }
.x-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.x-row-dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.x-row-n { font-weight: 700; width: 22px; color: var(--ink); }
.x-row-st { margin-left: auto; font-size: 10.5px; }
.x-row.answered { background: var(--accent-soft); color: var(--accent); }
.x-row.flagged { background: var(--gold-soft); color: var(--gold); border-color: var(--gold); }
.x-row.current { border-color: var(--ink); font-weight: 700; }

@media (max-width: 860px) {
  .x-layout { grid-template-columns: 1fr; }
  .x-tracker { position: static; max-height: none; order: -1; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .x-ring { width: 76px; height: 76px; } .x-ring::before { inset: 7px; } .x-ring-n { font-size: 1.05rem; }
  .x-counts { flex: 1; min-width: 180px; }
  .x-list { flex-direction: row; flex-wrap: wrap; width: 100%; max-height: 132px; }
  .x-list li { flex: 0 0 auto; }
  .x-row-st, .x-row-dot { display: none; }
  .x-row { padding: 5px 9px; }
  .x-row-n { width: auto; }
  .x-hero { padding: 18px 16px; }
  .x-hero-title { font-size: 1.4rem; }
}
@media (prefers-reduced-motion: reduce) { .x-live { animation: none; } }

/* ---------- Premium gate ---------- */
a.t-btn { display: inline-block; text-decoration: none; }
.t-loading { color: var(--ink-soft); font-size: 14px; }
.t-perks { list-style: none; padding: 0; margin: 4px 0 18px; }
.t-perks li { position: relative; padding: 4px 0 4px 24px; font-size: 14.5px; color: var(--ink-mid); }
.t-perks li::before { content: "✓"; position: absolute; left: 2px; color: var(--pass); font-weight: 700; }
