/* ============================================================
   📊 Mock Test Analysis — embeddable component (css/analysis.css)
   Scoped with .ma-* so it never touches the rest of the app.
   Light SaaS surface by design (spec): #F8FAFC bg / #FFFFFF cards.
   ============================================================ */

.ma {
  /* ---- tokens ---- */
  --ma-bg: #f8fafc;
  --ma-card: #ffffff;
  --ma-border: #e2e8f0;
  --ma-border-2: #cbd5e1;
  --ma-text: #0f172a;
  --ma-muted: #64748b;
  --ma-faint: #94a3b8;
  --ma-emerald: #10b981;
  --ma-emerald-soft: #ecfdf5;
  --ma-coral: #ef4444;
  --ma-coral-soft: #fef2f2;
  --ma-amber: #f59e0b;
  --ma-amber-soft: #fffbeb;
  --ma-indigo: #4f46e5;
  --ma-indigo-soft: #eef2ff;
  --ma-slate: #64748b;
  --ma-slate-soft: #f1f5f9;
  --ma-r: 16px;
  --ma-r-sm: 10px;
  --ma-r-xs: 8px;
  --ma-sh: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -12px rgba(15, 23, 42, .14);
  --ma-sh-lg: 0 2px 4px rgba(15, 23, 42, .05), 0 18px 40px -18px rgba(15, 23, 42, .22);

  font-family: "Plus Jakarta Sans", "Inter", ui-sans-serif, system-ui, -apple-system,
               "Segoe UI", Roboto, "Noto Sans Devanagari", sans-serif;
  background: var(--ma-bg);
  color: var(--ma-text);
  border-radius: var(--ma-r);
  padding: 20px;
  margin: 0 auto;
  max-width: 1240px;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}
.ma *, .ma *::before, .ma *::after { box-sizing: border-box; }
.ma h1, .ma h2, .ma h3, .ma h4, .ma p, .ma span, .ma div, .ma button, .ma li { color: inherit; }
.ma button { font-family: inherit; cursor: pointer; }

/* ---------------- header ---------------- */
.ma-head {
  display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap;
  padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--ma-border);
}
.ma-head-main { flex: 1; min-width: 240px; }
.ma-title { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -.02em; line-height: 1.25; }
.ma-sub { margin: 6px 0 0; font-size: 13px; color: var(--ma-muted); display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.ma-sub i { font-style: normal; color: var(--ma-faint); }
.ma-pct {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 999px;
  background: var(--ma-indigo-soft); border: 1px solid color-mix(in srgb, var(--ma-indigo) 26%, transparent);
  color: var(--ma-indigo); font-weight: 800; font-size: 13px; white-space: nowrap;
}
.ma-pct small { font-weight: 600; color: color-mix(in srgb, var(--ma-indigo) 70%, var(--ma-muted)); font-size: 11px; }
.ma-demo {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  background: var(--ma-amber-soft); border: 1px solid color-mix(in srgb, var(--ma-amber) 40%, transparent);
  color: #92400e; font-size: 11px; font-weight: 700;
}

/* ---------------- KPI strip ---------------- */
.ma-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.ma-kpi {
  background: var(--ma-card); border: 1px solid var(--ma-border); border-radius: var(--ma-r);
  padding: 16px 16px 14px; box-shadow: var(--ma-sh); display: flex; flex-direction: column; gap: 10px;
  min-height: 132px;
}
.ma-kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ma-kpi-label { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ma-muted); }
.ma-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 999px;
  font-size: 10.5px; font-weight: 800; letter-spacing: .01em; white-space: nowrap;
}
.ma-chip.coral { background: var(--ma-coral-soft); color: var(--ma-coral); border: 1px solid color-mix(in srgb, var(--ma-coral) 25%, transparent); }
.ma-chip.emerald { background: var(--ma-emerald-soft); color: var(--ma-emerald); border: 1px solid color-mix(in srgb, var(--ma-emerald) 25%, transparent); }
.ma-chip.amber { background: var(--ma-amber-soft); color: #b45309; border: 1px solid color-mix(in srgb, var(--ma-amber) 30%, transparent); }
.ma-chip.indigo { background: var(--ma-indigo-soft); color: var(--ma-indigo); border: 1px solid color-mix(in srgb, var(--ma-indigo) 25%, transparent); }
.ma-chip.slate { background: var(--ma-slate-soft); color: var(--ma-slate); border: 1px solid var(--ma-border); }
.ma-kpi-val { display: flex; align-items: baseline; gap: 6px; }
.ma-kpi-num { font-size: 27px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.ma-kpi-den { font-size: 13px; font-weight: 600; color: var(--ma-faint); }
.ma-kpi-foot { margin-top: auto; font-size: 11.5px; color: var(--ma-muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ma-ring-wrap { display: flex; align-items: center; gap: 14px; }
.ma-ring { flex: none; }
.ma-ring-num { font-size: 21px; font-weight: 800; letter-spacing: -.02em; }
.ma-ring-sub { font-size: 11px; color: var(--ma-muted); }
.ma-bar { height: 6px; border-radius: 999px; background: var(--ma-slate-soft); overflow: hidden; }
.ma-bar > i { display: block; height: 100%; border-radius: 999px; background: var(--ma-indigo); }

/* ---------------- action dock ---------------- */
.ma-dock { display: flex; gap: 12px; flex-wrap: wrap; margin: 0 0 18px; }
.ma-btn {
  display: inline-flex; align-items: center; gap: 9px; padding: 12px 18px; border-radius: var(--ma-r-sm);
  font-size: 13.5px; font-weight: 700; border: 1px solid transparent; transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.ma-btn:active { transform: translateY(1px); }
.ma-btn-primary { background: var(--ma-indigo); color: #fff; box-shadow: 0 1px 2px rgba(79, 70, 229, .3), 0 10px 22px -10px rgba(79, 70, 229, .7); }
.ma-btn-primary:hover { background: #4338ca; }
.ma-btn-ghost { background: #fff; color: var(--ma-text); border-color: var(--ma-border-2); box-shadow: var(--ma-sh); }
.ma-btn-ghost:hover { border-color: var(--ma-indigo); color: var(--ma-indigo); }
.ma-btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------------- 2-col diagnostic grid ---------------- */
.ma-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 14px; margin-bottom: 18px; }
.ma-panel { background: var(--ma-card); border: 1px solid var(--ma-border); border-radius: var(--ma-r); padding: 16px 16px 14px; box-shadow: var(--ma-sh); }
.ma-panel.alert { border-color: color-mix(in srgb, var(--ma-amber) 45%, transparent); background: linear-gradient(180deg, #fffdf7, #fff); }
.ma-panel.danger { border-color: color-mix(in srgb, var(--ma-coral) 40%, transparent); }
.ma-panel + .ma-panel { margin-top: 14px; }
.ma-panel-title { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 800; margin: 0 0 12px; letter-spacing: -.01em; }
.ma-panel-title .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ma-indigo); flex: none; }
.ma-panel-title small { font-weight: 600; color: var(--ma-muted); font-size: 11.5px; margin-left: auto; }

/* benchmark bars */
.ma-bench { display: flex; flex-direction: column; gap: 12px; }
.ma-bench-row { display: grid; grid-template-columns: 84px 1fr 74px; align-items: center; gap: 10px; }
.ma-bench-name { font-size: 12px; font-weight: 700; color: var(--ma-muted); }
.ma-bench-track { height: 22px; border-radius: 8px; background: var(--ma-slate-soft); overflow: hidden; }
.ma-bench-fill { height: 100%; border-radius: 8px; display: flex; align-items: center; justify-content: flex-end; padding-right: 8px; color: #fff; font-size: 11px; font-weight: 800; }
.ma-bench-val { font-size: 12.5px; font-weight: 800; text-align: right; }

/* section pills */
.ma-secs { display: flex; flex-direction: column; gap: 9px; margin-top: 14px; }
.ma-sec { display: grid; grid-template-columns: 96px 1fr 96px; align-items: center; gap: 10px; }
.ma-sec-name { font-size: 12.5px; font-weight: 700; }
.ma-sec-bar { height: 8px; border-radius: 999px; background: var(--ma-slate-soft); overflow: hidden; }
.ma-sec-bar > i { display: block; height: 100%; border-radius: 999px; }
.ma-sec-meta { font-size: 11.5px; color: var(--ma-muted); text-align: right; font-weight: 600; }

/* alert lists */
.ma-list { display: flex; flex-direction: column; gap: 9px; }
.ma-item {
  display: flex; gap: 11px; align-items: flex-start; padding: 10px 11px; border-radius: var(--ma-r-sm);
  background: var(--ma-slate-soft); border: 1px solid var(--ma-border);
}
.ma-item.amber { background: var(--ma-amber-soft); border-color: color-mix(in srgb, var(--ma-amber) 32%, transparent); }
.ma-item.coral { background: var(--ma-coral-soft); border-color: color-mix(in srgb, var(--ma-coral) 28%, transparent); }
.ma-qn {
  flex: none; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  font-size: 12px; font-weight: 800; background: #fff; border: 1px solid var(--ma-border-2); color: var(--ma-text);
}
.ma-item.amber .ma-qn { border-color: color-mix(in srgb, var(--ma-amber) 50%, transparent); color: #92400e; }
.ma-item.coral .ma-qn { border-color: color-mix(in srgb, var(--ma-coral) 45%, transparent); color: #b91c1c; }
.ma-item-body { flex: 1; min-width: 0; }
.ma-item-t { font-size: 12.5px; font-weight: 700; margin-bottom: 3px; }
.ma-item-m { font-size: 11.5px; color: var(--ma-muted); display: flex; gap: 8px; flex-wrap: wrap; }
.ma-item-m b { color: var(--ma-text); font-weight: 700; }

/* ---------------- review module ---------------- */
.ma-review { background: var(--ma-card); border: 1px solid var(--ma-border); border-radius: var(--ma-r); box-shadow: var(--ma-sh); overflow: hidden; }
.ma-tabs { display: flex; gap: 6px; padding: 12px 14px; border-bottom: 1px solid var(--ma-border); overflow-x: auto; }
.ma-tab {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; border-radius: 999px; white-space: nowrap;
  background: #fff; border: 1px solid var(--ma-border-2); font-size: 12.5px; font-weight: 700; color: var(--ma-muted);
  transition: all .18s ease;
}
.ma-tab:hover { border-color: var(--ma-indigo); color: var(--ma-indigo); }
.ma-tab[aria-selected="true"] { background: var(--ma-indigo); border-color: var(--ma-indigo); color: #fff; }
.ma-tab .cnt { padding: 1px 7px; border-radius: 999px; font-size: 10.5px; font-weight: 800; background: var(--ma-slate-soft); color: var(--ma-muted); }
.ma-tab[aria-selected="true"] .cnt { background: rgba(255, 255, 255, .24); color: #fff; }

.ma-split { display: grid; grid-template-columns: 268px 1fr; }
.ma-palette { border-right: 1px solid var(--ma-border); padding: 14px; background: #fcfdfe; max-height: 620px; overflow-y: auto; }
.ma-pal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.ma-pal-title { font-size: 11.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ma-muted); }
.ma-legend { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.ma-legend span { font-size: 10.5px; color: var(--ma-muted); display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.ma-legend i { width: 8px; height: 8px; border-radius: 50%; display: block; }
.ma-pal-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 7px; }
.ma-pal-q {
  position: relative; aspect-ratio: 1; border-radius: var(--ma-r-xs); border: 1px solid var(--ma-border-2);
  background: #fff; font-size: 12px; font-weight: 700; color: var(--ma-text);
  display: grid; place-items: center; transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.ma-pal-q:hover { transform: translateY(-2px); box-shadow: var(--ma-sh); }
.ma-pal-q[aria-current="true"] { border-color: var(--ma-indigo); box-shadow: 0 0 0 2px var(--ma-indigo), 0 8px 18px -10px rgba(79, 70, 229, .75); }
.ma-pal-q .st { position: absolute; right: 2px; bottom: 2px; width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid #fff; }
.ma-pal-q.correct .st { background: var(--ma-emerald); }
.ma-pal-q.incorrect .st { background: var(--ma-coral); }
.ma-pal-q.skipped .st { background: var(--ma-slate); }
.ma-pal-q.trap .st { background: var(--ma-amber); }
.ma-pal-q.review .st { background: var(--ma-indigo); }
.ma-pal-q.correct { background: var(--ma-emerald-soft); }
.ma-pal-q.incorrect { background: var(--ma-coral-soft); }
.ma-pal-q.skipped { background: var(--ma-slate-soft); }
.ma-pal-q.trap { background: var(--ma-amber-soft); }

.ma-detail { padding: 16px; min-width: 0; }
.ma-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--ma-border); }
.ma-meta .num { font-size: 13px; font-weight: 800; }
.ma-tag { padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--ma-slate-soft); color: var(--ma-muted); border: 1px solid var(--ma-border); }
.ma-tag.indigo { background: var(--ma-indigo-soft); color: var(--ma-indigo); border-color: color-mix(in srgb, var(--ma-indigo) 22%, transparent); }
.ma-time { margin-left: auto; display: inline-flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--ma-muted); font-weight: 600; }
.ma-time b { color: var(--ma-text); }
.ma-qtext { font-size: 14.5px; line-height: 1.6; font-weight: 600; margin: 0 0 14px; }
.ma-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.ma-opt {
  display: flex; gap: 10px; align-items: flex-start; padding: 11px 12px; border-radius: var(--ma-r-sm);
  border: 1px solid var(--ma-border); background: #fff; font-size: 13px; text-align: left; width: 100%;
}
.ma-opt .key { flex: none; width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; font-size: 11.5px; font-weight: 800; background: var(--ma-slate-soft); color: var(--ma-muted); }
.ma-opt.right { border-color: var(--ma-emerald); background: var(--ma-emerald-soft); }
.ma-opt.right .key { background: var(--ma-emerald); color: #fff; }
.ma-opt.wrong { border-color: var(--ma-coral); background: var(--ma-coral-soft); }
.ma-opt.wrong .key { background: var(--ma-coral); color: #fff; }
.ma-opt-note { display: block; font-size: 10.5px; font-weight: 800; margin-top: 4px; letter-spacing: .03em; }
.ma-opt.right .ma-opt-note { color: #047857; }
.ma-opt.wrong .ma-opt-note { color: #b91c1c; }

.ma-acc { border: 1px solid var(--ma-border); border-radius: var(--ma-r-sm); overflow: hidden; }
.ma-acc + .ma-acc { margin-top: 10px; }
.ma-acc-btn { width: 100%; display: flex; align-items: center; gap: 9px; padding: 12px 13px; background: var(--ma-slate-soft); border: 0; font-size: 12.5px; font-weight: 800; color: var(--ma-text); text-align: left; }
.ma-acc-btn .chev { margin-left: auto; transition: transform .22s ease; font-size: 11px; color: var(--ma-muted); }
.ma-acc.open .ma-acc-btn .chev { transform: rotate(180deg); }
.ma-acc-body { display: none; padding: 13px; font-size: 13px; line-height: 1.6; background: #fff; border-top: 1px solid var(--ma-border); }
.ma-acc.open .ma-acc-body { display: block; }
.ma-steps { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.ma-formula {
  margin-top: 10px; padding: 9px 11px; border-radius: var(--ma-r-xs); background: var(--ma-indigo-soft);
  color: #3730a3; font-size: 12.5px; font-weight: 700; border: 1px solid color-mix(in srgb, var(--ma-indigo) 20%, transparent);
}
.ma-note { margin-top: 10px; padding: 9px 11px; border-radius: var(--ma-r-xs); background: var(--ma-amber-soft); color: #92400e; font-size: 12.5px; border: 1px solid color-mix(in srgb, var(--ma-amber) 28%, transparent); }

/* ---------------- skeletons ---------------- */
@keyframes ma-shimmer { 0% { background-position: -420px 0; } 100% { background-position: 420px 0; } }
.ma-sk {
  border-radius: var(--ma-r-xs);
  background: linear-gradient(90deg, #eef2f7 8%, #f8fafc 20%, #eef2f7 33%);
  background-size: 800px 100%; animation: ma-shimmer 1.25s linear infinite;
}
.ma-sk-card { height: 132px; border-radius: var(--ma-r); }
.ma-sk-line { height: 13px; margin-bottom: 9px; }
.ma-sk-line.w40 { width: 40%; } .ma-sk-line.w60 { width: 60%; } .ma-sk-line.w80 { width: 80%; }

/* ---------------- empty state ---------------- */
.ma-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 34px 20px; text-align: center; }
.ma-empty .ic { font-size: 26px; }
.ma-empty .t { font-size: 14px; font-weight: 800; }
.ma-empty .m { font-size: 12.5px; color: var(--ma-muted); max-width: 380px; }

/* ---------------- mobile: palette drawer ---------------- */
.ma-pal-toggle { display: none; }
@media (max-width: 1080px) {
  .ma-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ma-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .ma { padding: 14px; border-radius: 12px; }
  .ma-split { grid-template-columns: 1fr; }
  .ma-palette {
    border-right: 0; border-bottom: 1px solid var(--ma-border);
    max-height: 0; overflow: hidden; padding: 0 14px; transition: max-height .28s ease, padding .28s ease;
  }
  .ma-palette.open { max-height: 340px; padding: 14px; overflow-y: auto; }
  .ma-pal-toggle {
    display: flex; align-items: center; justify-content: space-between; width: 100%;
    padding: 11px 14px; background: #fff; border: 0; border-bottom: 1px solid var(--ma-border);
    font-size: 12.5px; font-weight: 800; color: var(--ma-text);
  }
  .ma-pal-toggle .chev { transition: transform .22s ease; color: var(--ma-muted); }
  .ma-palette.open + .ma-detail { border-top: 0; }
  .ma-pal-toggle.open .chev { transform: rotate(180deg); }
  .ma-opts { grid-template-columns: 1fr; }
  .ma-bench-row { grid-template-columns: 70px 1fr 62px; }
}
@media (max-width: 640px) {
  .ma-kpis { grid-template-columns: 1fr; }
  .ma-title { font-size: 19px; }
  .ma-kpi { min-height: 0; }
  .ma-sec { grid-template-columns: 78px 1fr 84px; }
  .ma-dock .ma-btn { flex: 1; justify-content: center; }
}
@media (prefers-reduced-motion: reduce) {
  .ma * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------------- print / "Download PDF Report" ---------------- */
.ma-print { display: none; }
@media print {
  body * { visibility: hidden !important; }
  .ma-print, .ma-print * { visibility: visible !important; }
  .ma-print {
    display: block !important; position: absolute; inset: 0; margin: 0; padding: 0;
    font-family: "Inter", system-ui, sans-serif; color: #0f172a; background: #fff;
  }
  .ma-print h1 { font-size: 19px; margin: 0 0 4px; }
  .ma-print h2 { font-size: 13px; margin: 18px 0 6px; text-transform: uppercase; letter-spacing: .06em; color: #4f46e5; }
  .ma-print p { font-size: 11px; color: #64748b; margin: 0 0 8px; }
  .ma-print table { width: 100%; border-collapse: collapse; font-size: 10.5px; }
  .ma-print th, .ma-print td { border: 1px solid #cbd5e1; padding: 4px 6px; text-align: left; }
  .ma-print th { background: #f1f5f9; font-weight: 700; }
  .ma-print tr { page-break-inside: avoid; }
}
