:root {
  --brand: #1668e3;
  --brand-600: #0f56c0;
  --brand-50: #e8f1ff;
  --ink: #0f1b2d;
  --muted: #5a6b82;
  --line: #dbe4f0;
  --card: #ffffff;
  --bg: #f5f8fd;
  --ok: #12a05c;
  --ok-bg: #e7f8ef;
  --bad: #d92d20;
  --bad-bg: #fdeceb;
  --amber: #f5a524;
  --shadow: 0 1px 2px rgba(15, 27, 45, 0.06), 0 10px 28px rgba(15, 27, 45, 0.07);
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #5b9bff;
    --brand-600: #7fb0ff;
    --brand-50: #14233d;
    --ink: #e8eefb;
    --muted: #93a4bf;
    --line: #24324d;
    --card: #121b2e;
    --bg: #0b1220;
    --ok: #3ccf86;
    --ok-bg: #0f2a1f;
    --bad: #ff8078;
    --bad-bg: #2f1513;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 28px rgba(0, 0, 0, 0.35);
  }
}

html[data-lang="en"] .ar,
html[data-lang="ar"] .en { display: none !important; }

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.6 Inter, Cairo, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
:lang(ar) { font-family: Cairo, Inter, system-ui, sans-serif; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; margin: 0 0 8px; }
p { margin: 0 0 12px; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.wrap { max-width: 960px; margin-inline: auto; padding-inline: 20px; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }

/* header */
header.site { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
header.site .wrap { display: flex; align-items: center; justify-content: space-between; height: 62px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.1rem; color: var(--ink); text-decoration: none; }
.brand svg { width: 34px; height: 34px; }
.lang-btn { font: inherit; font-weight: 700; font-size: 0.95rem; padding: 8px 16px; border-radius: 999px; border: 1.5px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.lang-btn:hover { border-color: var(--brand); color: var(--brand); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px 24px; border-radius: 14px; border: 0; font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; transition: transform 0.12s, background 0.12s, box-shadow 0.12s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--brand) 35%, transparent); }
.btn-primary:hover { background: var(--brand-600); }
.btn-primary:disabled { background: var(--line); color: var(--muted); box-shadow: none; cursor: not-allowed; }
.btn-ghost { background: var(--card); color: var(--brand); border: 1.5px solid var(--line); }
.btn-ghost:hover { border-color: var(--brand); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* hero */
.hero { padding: 52px 0 36px; background: radial-gradient(60% 90% at 12% 0%, color-mix(in srgb, var(--brand) 16%, transparent), transparent 62%), radial-gradient(50% 80% at 92% 8%, color-mix(in srgb, var(--ok) 14%, transparent), transparent 58%); }
.eyebrow { display: inline-block; font-size: 0.8rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--brand); margin-bottom: 10px; }
:lang(ar) .eyebrow { letter-spacing: 0; }
.hero h1 { font-size: clamp(2rem, 6vw, 3.1rem); font-weight: 800; }
.hero h1 em { font-style: normal; color: var(--brand); }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 640px; margin-bottom: 22px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 0; padding: 0; list-style: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); font-size: 0.88rem; font-weight: 600; color: var(--ink); }
.chip.brand { background: var(--brand-50); border-color: transparent; color: var(--brand); }

section.block { padding: 34px 0 6px; }
section.block > .wrap > h2 { font-size: 1.5rem; font-weight: 800; margin-bottom: 4px; }
section.block > .wrap > p.muted { margin-bottom: 18px; }
.crumbs { font-size: 0.9rem; color: var(--muted); margin: 18px 0 0; }
.crumbs a { color: var(--muted); }

/* cards */
.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.card { display: flex; flex-direction: column; gap: 6px; padding: 18px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); color: var(--ink); text-decoration: none; transition: transform 0.15s, border-color 0.15s; }
a.card:hover { transform: translateY(-3px); border-color: var(--brand); }
.card h3 { font-size: 1.1rem; font-weight: 800; margin: 2px 0 0; }
.card p { margin: 0; }
.card .ico { display: inline-grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: var(--brand-50); color: var(--brand); margin-bottom: 6px; }
.card .ico svg { width: 26px; height: 26px; }
.card .badge { display: inline-grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; background: var(--brand); color: #fff; font-weight: 800; margin-bottom: 6px; }
.card.soon { opacity: 0.62; box-shadow: none; }
.card.exam .ico { background: color-mix(in srgb, var(--amber) 22%, transparent); color: #b7791f; }
.card.challenge .ico { background: var(--ok-bg); color: var(--ok); }
.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.86rem; color: var(--muted); margin-top: 2px; }
.pbar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.pfill { display: block; height: 100%; width: 0; background: var(--ok); border-radius: 99px; transition: width 0.6s; }
.ptext { font-size: 0.84rem; color: var(--muted); margin-top: 4px; min-height: 1.3em; }

.steps { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); counter-reset: s; padding: 0; list-style: none; }
.steps li { counter-increment: s; padding: 18px; background: var(--card); border: 1px solid var(--line); border-radius: 18px; }
.steps li::before { content: counter(s); display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 800; margin-bottom: 8px; }
.steps h3 { font-size: 1.05rem; }
.steps p { color: var(--muted); margin: 0; }

.note { margin-top: 26px; padding: 14px 16px; border-radius: 14px; background: var(--brand-50); color: var(--ink); font-size: 0.95rem; }
footer { margin-top: 48px; padding-block: 26px 46px; color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--line); }
footer p { margin-bottom: 8px; }

/* quiz */
.quiz { position: relative; overflow: hidden; background: var(--card); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); padding: 20px; margin: 18px 0 8px; }
.q-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.q-count { font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { flex: 1; height: 10px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), #4fa0ff); border-radius: 99px; transition: width 0.4s; }
.tag { display: inline-block; font-size: 0.82rem; font-weight: 700; color: var(--brand); background: var(--brand-50); padding: 4px 10px; border-radius: 999px; margin-bottom: 8px; }
.qimg { display: block; width: 100%; max-width: 460px; height: auto; margin: 6px auto 16px; border-radius: 16px; box-shadow: 0 6px 18px rgba(15, 27, 45, 0.12); }
.q-text { font-size: 1.28rem; font-weight: 800; margin: 4px 0 14px; }
.opts { display: grid; gap: 10px; }
.opt { display: flex; align-items: flex-start; gap: 12px; width: 100%; text-align: start; padding: 14px 16px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--card); color: var(--ink); font: inherit; cursor: pointer; transition: border-color 0.12s, background 0.12s, opacity 0.2s; }
.opt:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-50); }
.opt:disabled { cursor: default; }
.opt .radio { flex: none; display: grid; place-items: center; width: 24px; height: 24px; margin-top: 1px; border-radius: 50%; border: 2px solid var(--line); color: #fff; }
.opt .radio svg { width: 14px; height: 14px; }
.opt.correct { border-color: var(--ok); background: var(--ok-bg); }
.opt.correct .radio { background: var(--ok); border-color: var(--ok); }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt.wrong .radio { background: var(--bad); border-color: var(--bad); }
.opt.dim { opacity: 0.5; }
.fb { margin: 14px 0 0; padding: 14px 16px; border-radius: 14px; border-inline-start: 5px solid; }
.fb.ok { background: var(--ok-bg); border-color: var(--ok); }
.fb.bad { background: var(--bad-bg); border-color: var(--bad); }
.fb strong { display: block; margin-bottom: 2px; }
.fb.ok strong { color: var(--ok); }
.fb.bad strong { color: var(--bad); }
.fb .src { margin-top: 8px; font-size: 0.82rem; color: var(--muted); }
.actions { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; gap: 10px; padding: 14px 0 2px; margin-top: 14px; background: linear-gradient(to top, var(--card) 72%, transparent); }
.actions .btn-primary:only-child { flex: 1; }
.start-screen { text-align: center; padding: 18px 6px 10px; }
.start-screen h2 { font-size: 1.4rem; font-weight: 800; }
.start-screen .btn { margin-top: 8px; }

.result { text-align: center; }
.result-badge { display: grid; place-items: center; width: 60px; height: 60px; margin: 4px auto 2px; border-radius: 50%; animation: badge-pop 0.55s cubic-bezier(.34, 1.56, .64, 1) both; }
.result-badge svg { width: 32px; height: 32px; }
.result-badge.ok { background: var(--ok-bg); color: var(--ok); }
.result-badge.retry { background: var(--brand-50); color: var(--brand); animation: badge-pop 0.55s cubic-bezier(.34, 1.56, .64, 1) both, badge-nudge 1.8s 0.6s ease-in-out 1; }
.result-badge.ok .draw { stroke-dasharray: 30; stroke-dashoffset: 30; animation: draw-check 0.45s 0.3s ease-out forwards; }
@keyframes badge-pop { 0% { transform: scale(0); opacity: 0; } 65% { transform: scale(1.18); opacity: 1; } 100% { transform: scale(1); } }
@keyframes badge-nudge { 0%, 100% { transform: rotate(0deg); } 25% { transform: rotate(-14deg); } 50% { transform: rotate(0deg); } 75% { transform: rotate(14deg); } }
@keyframes draw-check { to { stroke-dashoffset: 0; } }
.ring { position: relative; width: 150px; height: 150px; margin: 6px auto 12px; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring .track { fill: none; stroke: var(--line); stroke-width: 12; }
.ring .val { fill: none; stroke-width: 12; stroke-linecap: round; stroke-dasharray: 339.3; stroke-dashoffset: 339.3; transition: stroke-dashoffset 1s ease-out; }
.ring .pct { position: absolute; inset: 0; display: grid; place-items: center; font-size: 2rem; font-weight: 800; }
.result h2 { font-size: 1.5rem; font-weight: 800; }
.stats { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.stat { padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: 0.9rem; background: var(--brand-50); }
.stat.ok { background: var(--ok-bg); color: var(--ok); }
.stat.bad { background: var(--bad-bg); color: var(--bad); }
.review { text-align: start; margin-top: 18px; }
.review h3 { font-size: 1.1rem; font-weight: 800; }
.review ul { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 10px; }
.review li { padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; }
.review li strong { display: block; margin-bottom: 4px; }
.result .actions { justify-content: center; position: static; background: none; }

.confetti-box { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall 3.2s linear forwards; }
@keyframes fall { to { transform: translateY(560px) rotate(540deg); opacity: 0.9; } }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  .confetti-box { display: none; }
}
@media (max-width: 520px) {
  .quiz { padding: 16px; border-radius: 18px; }
  .hero { padding-top: 36px; }
}
.hero.compact { padding: 22px 0 8px; }
.hero.compact h1 { font-size: clamp(1.6rem, 5vw, 2.2rem); }
.hero.compact .lead { font-size: 1rem; margin-bottom: 6px; }
.foot-nav { display: flex; gap: 16px; margin-top: 10px; }
.foot-nav a { color: var(--muted); font-weight: 600; }
.prose h2 { font-size: 1.15rem; margin-top: 26px; }
.prose h2:first-child { margin-top: 0; }
.prose p { color: var(--ink); }
.disclaimer { display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem; font-weight: 700; color: var(--ink); background: color-mix(in srgb, var(--amber) 18%, var(--card)); border: 1px solid color-mix(in srgb, var(--amber) 45%, var(--line)); padding: 6px 12px; border-radius: 999px; margin: 4px 0 14px; }

/* reference / study-guide content */
.trivia { display: flex; gap: 14px; padding: 16px 18px; margin: 18px 0; background: color-mix(in srgb, var(--amber) 10%, var(--card)); border: 1px solid color-mix(in srgb, var(--amber) 35%, var(--line)); border-radius: 18px; }
.trivia .ico { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: color-mix(in srgb, var(--amber) 25%, transparent); color: #9a6b0a; }
@media (prefers-color-scheme: dark) { .trivia .ico { color: var(--amber); } }
.trivia .ico svg { width: 22px; height: 22px; }
.trivia h3 { font-size: 1rem; font-weight: 800; margin: 4px 0 8px; }
.trivia ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.trivia li { position: relative; padding-inline-start: 16px; color: var(--ink); font-size: 0.95rem; }
.trivia li::before { content: "•"; position: absolute; inset-inline-start: 0; color: var(--amber); font-weight: 800; }
.trivia.small { padding: 12px 14px; margin: 14px 0; }
.trivia.small h3 { font-size: 0.9rem; }
.trivia.small li { font-size: 0.88rem; }
.ref-groups { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-top: 16px; }
.ref-group { padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; }
.ref-group h4 { font-size: 0.95rem; font-weight: 800; margin: 0 0 8px; color: var(--brand); }
.ref-group ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.ref-group li { font-size: 0.9rem; color: var(--muted); padding-inline-start: 14px; position: relative; }
.ref-group li::before { content: "–"; position: absolute; inset-inline-start: 0; }
.ref-chapter { margin-bottom: 30px; }
.ref-chapter h2 { font-size: 1.2rem; font-weight: 800; margin-bottom: 12px; }
