/* =====================================================================
   Irish Theory Test — design system
   Mobile-first · light/dark · RTL-aware (logical properties throughout)
   ===================================================================== */
:root {
  --font-latin: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-arabic: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  --font: var(--font-latin);

  --bg: #f5f7fb;
  --bg-2: #eef1f8;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-solid: #ffffff;
  --surface-2: #f1f4fa;
  --border: rgba(15, 23, 42, 0.10);
  --border-strong: rgba(15, 23, 42, 0.18);
  --text: #0f172a;
  --muted: #475569;
  --faint: #64748b;

  --primary: #4f46e5;
  --primary-2: #6366f1;
  --primary-soft: rgba(79, 70, 229, 0.10);
  --accent: #10b981;
  --accent-soft: rgba(16, 185, 129, 0.14);
  --danger: #f43f5e;
  --danger-soft: rgba(244, 63, 94, 0.14);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.16);
  --plate: #e11d48;

  --grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #10b981 130%);
  --grad-text: linear-gradient(90deg, #4f46e5, #7c3aed 45%, #059669);
  --blob-1: #818cf8; --blob-2: #34d399; --blob-3: #f0abfc;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 1px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px -8px rgba(15, 23, 42, 0.18), 0 2px 6px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 24px 48px -16px rgba(15, 23, 42, 0.25), 0 8px 16px -8px rgba(15, 23, 42, 0.10);
  --glow: 0 0 0 4px var(--primary-soft);

  --r-sm: 10px; --r-md: 16px; --r-lg: 22px; --r-xl: 28px;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-in: cubic-bezier(.4, 0, 1, 1);
  --t-fast: 160ms; --t-med: 260ms; --t-slow: 420ms;
  --z-bg: 0; --z-app: 10; --z-bar: 20; --z-sheet: 30; --z-toast: 50;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #0b1020;
  --bg-2: #0e1428;
  --surface: rgba(19, 26, 46, 0.78);
  --surface-solid: #131a2e;
  --surface-2: #1a2340;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.18);
  --text: #eef2ff;
  --muted: #a5b1c9;
  --faint: #7d8aa6;
  --primary: #818cf8;
  --primary-2: #a5b4fc;
  --primary-soft: rgba(129, 140, 248, 0.16);
  --accent: #34d399;
  --accent-soft: rgba(52, 211, 153, 0.16);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.16);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, 0.16);
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #34d399 130%);
  --grad-text: linear-gradient(90deg, #a5b4fc, #c4b5fd 45%, #6ee7b7);
  --blob-1: #4338ca; --blob-2: #047857; --blob-3: #7e22ce;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px -8px rgba(0, 0, 0, 0.55), 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 24px 48px -16px rgba(0, 0, 0, 0.65), 0 8px 16px -8px rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; overflow-x: clip; }
body {
  margin: 0; min-height: 100dvh;
  font-family: var(--font); font-size: 16px; line-height: 1.55;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--t-slow), color var(--t-slow);
}
html[lang="ar"] body { --font: var(--font-arabic); letter-spacing: 0; }
html[lang="ar"] { --font: var(--font-arabic); }
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: not-allowed; opacity: .5; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; border-radius: 8px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- animated background ---------- */
.bg { position: fixed; inset: 0; z-index: var(--z-bg); overflow: hidden; pointer-events: none; }
.blob {
  position: absolute; border-radius: 50%; filter: blur(70px); opacity: .55;
  will-change: transform; animation: drift 24s ease-in-out infinite alternate;
}
.blob--1 { width: 55vmax; height: 55vmax; background: var(--blob-1); top: -20vmax; inset-inline-start: -15vmax; }
.blob--2 { width: 45vmax; height: 45vmax; background: var(--blob-2); bottom: -18vmax; inset-inline-end: -12vmax; animation-delay: -8s; animation-duration: 30s; }
.blob--3 { width: 35vmax; height: 35vmax; background: var(--blob-3); top: 40%; inset-inline-start: 45%; animation-delay: -15s; animation-duration: 36s; opacity: .35; }
html[data-theme="dark"] .blob { opacity: .38; }
html[data-theme="dark"] .blob--3 { opacity: .25; }
@keyframes drift {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  50%  { transform: translate3d(6vmax, -4vmax, 0) scale(1.12); }
  100% { transform: translate3d(-5vmax, 6vmax, 0) scale(.95); }
}
.grain {
  position: absolute; inset: 0; opacity: .035; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
html[data-theme="dark"] .grain { mix-blend-mode: screen; opacity: .05; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: var(--z-bar);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(14px, calc((100% - 880px) / 2 + 14px));
  backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4);
}
.topbar::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  mask-image: linear-gradient(to bottom, #000 70%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, #000 70%, transparent);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: -.01em; }
.brand__plate {
  width: 34px; height: 34px; display: grid; place-items: center;
  background: #fff; color: var(--plate); border: 2.5px solid var(--plate); border-radius: 9px;
  font: 800 20px/1 var(--font-latin); box-shadow: var(--shadow-sm);
  transition: transform var(--t-med) var(--ease);
}
.brand:hover .brand__plate { transform: rotate(-6deg) scale(1.06); }
.brand__name { font-size: 17px; }
.topbar__actions { display: flex; align-items: center; gap: 8px; }

.langs {
  position: relative; display: inline-flex; padding: 3px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); isolation: isolate;
}
.langs__btn {
  position: relative; z-index: 1; min-width: 44px; height: 34px; padding: 0 10px;
  border-radius: 999px; font-weight: 700; font-size: 13px; color: var(--muted);
  transition: color var(--t-med);
}
.langs__btn[lang="ar"] { font-family: var(--font-arabic); font-size: 14px; }
.langs__btn.is-active { color: #fff; }
.langs__thumb {
  position: absolute; top: 3px; bottom: 3px; inset-inline-start: 3px; width: 44px; border-radius: 999px;
  background: var(--grad); box-shadow: var(--shadow-sm);
  transition: transform var(--t-med) var(--ease), width var(--t-med) var(--ease);
}
.iconbtn {
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.iconbtn:hover { color: var(--text); background: var(--surface-solid); }
.iconbtn:active { transform: scale(.94); }
.ic--moon { display: none; }
html[data-theme="dark"] .ic--moon { display: block; }
html[data-theme="dark"] .ic--sun { display: none; }

/* ---------- app shell ---------- */
.app {
  position: relative; z-index: var(--z-app);
  max-width: 880px; margin: 0 auto; padding: 8px 14px calc(var(--dock-h, 0px) + 24px + var(--safe-b));
}
.view { animation: view-in var(--t-slow) var(--ease) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.loader { display: grid; place-items: center; gap: 18px; padding: 25vh 0; color: var(--muted); }
.loader__plate {
  width: 64px; height: 64px; display: grid; place-items: center; border-radius: 16px;
  background: #fff; border: 4px solid var(--plate); color: var(--plate); font: 800 36px/1 var(--font-latin);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.08); } }

/* ---------- typography ---------- */
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.02em; font-weight: 800; }
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3 { letter-spacing: 0; line-height: 1.35; }
.grad-text { background: var(--grad-text); -webkit-background-clip: text; background-clip: text; color: transparent; }
.muted { color: var(--muted); }
.eyebrow { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--primary); }
html[lang="ar"] .eyebrow { letter-spacing: 0; font-size: 13px; }

/* ---------- surfaces ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-md); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; background: var(--primary-soft); color: var(--primary);
  white-space: nowrap;
}
.chip--accent { background: var(--accent-soft); color: var(--accent); }
.chip--warn { background: var(--warn-soft); color: var(--warn); }
.chip--danger { background: var(--danger-soft); color: var(--danger); }
.chip--ghost { background: var(--surface-2); color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 14px; font-weight: 700; font-size: 15px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  transition: transform var(--t-fast) var(--ease), background var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-solid); border-color: var(--border-strong); }
.btn:active { transform: scale(.97); }
.btn--primary { background: var(--grad); color: #fff; border: 0; box-shadow: 0 10px 24px -10px rgba(79, 70, 229, .6); position: relative; overflow: hidden; }
.btn--primary::after { content: ""; position: absolute; inset: 0; background: linear-gradient(rgba(255,255,255,.18), transparent); opacity: 0; transition: opacity var(--t-fast); }
.btn--primary:hover::after { opacity: 1; }
.btn--primary:hover { background: var(--grad); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--danger { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.btn--block { width: 100%; }
.btn--lg { min-height: 56px; font-size: 16px; padding: 0 26px; border-radius: 16px; }
.btn .ic { flex: none; }
.ic { width: 20px; height: 20px; }
[dir="rtl"] .ic--flip { transform: scaleX(-1); }

/* =====================================================================
   HOME
   ===================================================================== */
.hero { padding: 28px 4px 22px; text-align: center; }
.hero__badge { display: inline-flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.hero h1 { font-size: clamp(30px, 8vw, 46px); }
.hero p { max-width: 46ch; margin: 12px auto 0; color: var(--muted); font-size: 16px; }
.stats { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.stat { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--muted); backdrop-filter: blur(10px); }
.stat b { color: var(--text); font-weight: 800; }

.modes { display: grid; gap: 14px; margin-top: 8px; }
@media (min-width: 640px) { .modes { grid-template-columns: 1fr 1fr; } }
.mode {
  position: relative; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px;
  padding: 20px; text-align: start; overflow: hidden;
  transition: transform var(--t-med) var(--ease), box-shadow var(--t-med) var(--ease), border-color var(--t-med);
}
.mode:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.mode:active { transform: translateY(0) scale(.99); }
.mode__icon { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 16px; background: var(--primary-soft); color: var(--primary); }
.mode__icon .ic { width: 26px; height: 26px; }
.mode--accent .mode__icon { background: var(--accent-soft); color: var(--accent); }
.mode--warn .mode__icon { background: var(--warn-soft); color: var(--warn); }
.mode h3 { font-size: 17px; margin-bottom: 3px; }
.mode p { margin: 0; font-size: 14px; color: var(--muted); }
.mode__arrow { color: var(--faint); transition: transform var(--t-med) var(--ease), color var(--t-med); }
.mode:hover .mode__arrow { color: var(--primary); transform: translateX(4px); }
[dir="rtl"] .mode:hover .mode__arrow { transform: translateX(-4px); }
.mode--featured { grid-column: 1 / -1; background: var(--grad); color: #fff; border: 0; }
.mode--featured .mode__icon { background: rgba(255,255,255,.18); color: #fff; }
.mode--featured p, .mode--featured .mode__arrow { color: rgba(255,255,255,.85); }
.mode--featured::before { content: ""; position: absolute; inset: -40% -20% auto auto; width: 60%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(closest-side, rgba(255,255,255,.28), transparent); pointer-events: none; }
.mode__progress { margin-top: 10px; }

.section { margin-top: 30px; }
.section__head { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section__head h2 { font-size: 20px; }

.cats { display: grid; gap: 10px; }
@media (min-width: 640px) { .cats { grid-template-columns: repeat(2, 1fr); } }
.cat {
  display: grid; gap: 10px; padding: 16px; text-align: start;
  transition: transform var(--t-med) var(--ease), box-shadow var(--t-med) var(--ease);
}
.cat:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.cat__top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.cat__name { font-weight: 700; font-size: 15px; }
.cat__meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-weight: 600; }

.bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.bar > i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--grad); transition: width .9s var(--ease); }
.bar--accent > i { background: var(--accent); }
.mode--featured .bar { background: rgba(255,255,255,.22); border-color: transparent; }
.mode--featured .bar > i { background: #fff; }

.home-progress { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: center; padding: 18px; }
.ring { position: relative; width: 84px; height: 84px; }
.ring svg { transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; stroke-linecap: round; }
.ring__track { stroke: var(--surface-2); }
.ring__fill { stroke: url(#ringGrad); transition: stroke-dashoffset 1.1s var(--ease); }
.ring__label { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: 18px; }
.home-progress__nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.num { display: grid; gap: 2px; }
.num b { font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.num span { font-size: 12px; color: var(--muted); font-weight: 600; }

.footer { margin-top: 40px; text-align: center; font-size: 13px; color: var(--faint); display: grid; gap: 10px; }
.footer__disc { margin: 0 auto; max-width: 60ch; font-size: 12.5px; }
.footer a { text-decoration: underline; text-underline-offset: 3px; }
.link-btn { color: var(--faint); font-size: 13px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: var(--danger); }

/* =====================================================================
   QUIZ (practice + mock)
   ===================================================================== */
.quiz { display: grid; gap: 14px; }
.quiz__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.quiz__title { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; }
.quiz__title .chip { font-size: 12px; }
.quiz__tools { display: flex; align-items: center; gap: 6px; }

.progress { display: grid; gap: 6px; }
.progress__row { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; color: var(--muted); }
.timer { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-weight: 800; font-size: 14px; }
.timer.is-low { color: var(--danger); background: var(--danger-soft); border-color: transparent; animation: pulse 1s ease-in-out infinite; }

.stage { position: relative; overflow-x: clip; margin-inline: -14px; padding-inline: 14px; }
.qcard { padding: 16px; overflow: hidden; }
@media (min-width: 640px) { .qcard { padding: 28px; } }
.qcard.enter-next { animation: slide-next var(--t-slow) var(--ease) both; }
.qcard.enter-prev { animation: slide-prev var(--t-slow) var(--ease) both; }
@keyframes slide-next { from { opacity: 0; transform: translateX(48px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes slide-prev { from { opacity: 0; transform: translateX(-48px) scale(.985); } to { opacity: 1; transform: none; } }

.qcard__meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.qcard__meta-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.qcard__id { font-size: 12px; font-weight: 700; color: var(--faint); font-variant-numeric: tabular-nums; }
.bookmark { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; color: var(--faint); transition: color var(--t-fast), background var(--t-fast), transform var(--t-fast); }
.bookmark:hover { background: var(--warn-soft); color: var(--warn); }
.bookmark.is-on { color: var(--warn); }
.bookmark.is-on .ic { fill: currentColor; animation: pop var(--t-med) var(--ease); }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }

.qcard__fig {
  margin: 0 0 12px; display: grid; place-items: center; padding: 14px; border-radius: var(--r-md);
  background: #fff; border: 1px solid var(--border); min-height: 120px;
}
.qcard__fig img { width: 100%; max-width: 150px; height: auto; aspect-ratio: 1; object-fit: contain; }
@media (min-width: 640px) { .qcard__fig { min-height: 160px; } .qcard__fig img { max-width: 220px; } }
.qcard__q { font-size: 18px; line-height: 1.4; margin-bottom: 14px; font-weight: 700; }
@media (min-width: 640px) { .qcard__q { font-size: 21px; } }

.opts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
@media (min-width: 640px) { .opts { gap: 10px; } .opt { min-height: 56px; padding: 12px 14px; } }
.opt {
  --opt-bg: var(--surface-2); --opt-border: var(--border);
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; width: 100%;
  min-height: 52px; padding: 10px 12px; text-align: start; border-radius: 16px;
  background: var(--opt-bg); border: 1.5px solid var(--opt-border); font-size: 15px; font-weight: 500; line-height: 1.4;
  transition: transform var(--t-fast) var(--ease), background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
  animation: opt-in var(--t-slow) var(--ease) both; animation-delay: calc(var(--i) * 55ms);
}
@keyframes opt-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.opt:hover { --opt-border: var(--border-strong); background: var(--surface-solid); }
.opt:active { transform: scale(.985); }
.opt__key {
  width: 30px; height: 30px; display: grid; place-items: center; border-radius: 9px;
  background: var(--surface-solid); border: 1px solid var(--border); font-size: 13px; font-weight: 800; color: var(--muted);
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.opt__mark { width: 22px; height: 22px; opacity: 0; transform: scale(.5); transition: opacity var(--t-med), transform var(--t-med) var(--ease); }
.opt.is-selected { --opt-border: var(--primary); box-shadow: var(--glow); }
.opt.is-selected .opt__key { background: var(--primary); color: #fff; border-color: transparent; }
.opt.is-correct { --opt-bg: var(--accent-soft); --opt-border: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); animation: correct-pop var(--t-slow) var(--ease); }
.opt.is-correct .opt__key { background: var(--accent); color: #fff; border-color: transparent; }
.opt.is-correct .opt__mark { opacity: 1; transform: none; color: var(--accent); }
.opt.is-wrong { --opt-bg: var(--danger-soft); --opt-border: var(--danger); animation: shake .45s var(--ease); }
.opt.is-wrong .opt__key { background: var(--danger); color: #fff; border-color: transparent; }
.opt.is-wrong .opt__mark { opacity: 1; transform: none; color: var(--danger); }
.opt.is-dim { opacity: .55; }
.opt:disabled { cursor: default; opacity: 1; }
.opt.is-dim:disabled { opacity: .55; }
@keyframes correct-pop { 0% { transform: scale(1); } 40% { transform: scale(1.025); } 100% { transform: scale(1); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-7px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }

/* ---------- bottom dock (fixed nav + feedback) ---------- */
.dock {
  position: fixed; inset-inline: 0; bottom: 0; z-index: var(--z-bar);
  padding: 0 10px calc(10px + var(--safe-b));
  pointer-events: none;
}
.dock__inner {
  max-width: 880px; margin: 0 auto; pointer-events: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); backdrop-filter: blur(18px) saturate(1.5); -webkit-backdrop-filter: blur(18px) saturate(1.5);
  animation: dock-in var(--t-slow) var(--ease) both;
}
html[data-theme="dark"] .dock__inner { background: rgba(19, 26, 46, 0.9); }
@keyframes dock-in { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
/* prev stays left, next stays right in every language (incl. RTL) */
.dock__row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; padding: 10px; direction: ltr; }
[dir="rtl"] .dock__row .ic--flip { transform: none; }
.dock__row .btn { min-width: 56px; padding: 0 16px; }
.dock__row .btn--primary { min-width: 120px; }
.qnav__count { text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; font-size: 14px; color: var(--muted); }
.dock__fb { display: grid; grid-template-rows: 0fr; transition: grid-template-rows var(--t-slow) var(--ease); }
.dock__fb.is-open { grid-template-rows: 1fr; }
.dock__fb > * { overflow: hidden; }

.fb {
  display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start;
  margin: 10px 10px 0; padding: 12px 14px; border-radius: var(--r-md);
}
.fb--in { animation: fb-in var(--t-slow) var(--ease) both; }
@keyframes fb-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.fb.is-right { background: var(--accent-soft); }
.fb.is-wrong { background: var(--danger-soft); }
.fb__icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px; background: var(--surface-solid); color: var(--accent); box-shadow: var(--shadow-sm); }
.fb.is-wrong .fb__icon { color: var(--danger); }
.fb__body { min-width: 0; }
.fb__title { font-weight: 800; font-size: 16px; line-height: 1.3; }
.fb.is-right .fb__title { color: var(--accent); }
.fb.is-wrong .fb__title { color: var(--danger); }
.fb__answer { font-weight: 700; font-size: 14px; color: var(--accent); margin-top: 2px; }
.fb__more { margin-top: 4px; }
.fb__more > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; color: var(--muted); padding: 4px 0; min-height: 32px; }
.fb__more > summary::-webkit-details-marker { display: none; }
.fb__more > summary .ic { width: 16px; height: 16px; transition: transform var(--t-med) var(--ease); }
.fb__more[open] > summary .ic { transform: rotate(180deg); }
.fb__more > p { margin: 2px 0 0; font-size: 14px; line-height: 1.5; color: var(--text); max-height: 26vh; overflow-y: auto; overscroll-behavior: contain; padding-inline-end: 4px; }

.kbd-hint { text-align: center; font-size: 12px; }
@media (max-width: 639px) { .kbd-hint { display: none; } }

/* dots / palette for mock navigation */
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 6px; padding: 14px; }
.dot {
  height: 38px; border-radius: 10px; font-size: 12px; font-weight: 800; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
  transition: transform var(--t-fast), background var(--t-fast), color var(--t-fast);
}
.dot:hover { transform: translateY(-1px); }
.dot.is-answered { background: var(--primary-soft); color: var(--primary); border-color: transparent; }
.dot.is-current { outline: 2px solid var(--primary); outline-offset: 1px; }
.dot.is-right { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.dot.is-wrong { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
details.palette-wrap > summary { list-style: none; cursor: pointer; padding: 12px 16px; font-weight: 700; font-size: 14px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
details.palette-wrap > summary::-webkit-details-marker { display: none; }
details.palette-wrap > summary .ic { transition: transform var(--t-med) var(--ease); }
details.palette-wrap[open] > summary .ic { transform: rotate(180deg); }

/* filters bar (practice) */
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; -ms-overflow-style: none; }
.filters::-webkit-scrollbar { display: none; }
.filter {
  flex: none; min-height: 40px; padding: 0 14px; border-radius: 999px; font-size: 13px; font-weight: 700;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted); backdrop-filter: blur(8px);
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.filter:hover { border-color: var(--border-strong); color: var(--text); }
.filter.is-active { background: var(--text); color: var(--bg); border-color: transparent; }
select.filter { appearance: none; padding-inline-end: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; max-width: 60vw; text-overflow: ellipsis; }
[dir="rtl"] select.filter { background-position: left 12px center; }

/* =====================================================================
   MOCK INTRO + RESULTS
   ===================================================================== */
.intro { padding: 28px 20px; text-align: center; display: grid; gap: 16px; justify-items: center; }
.intro h2 { font-size: 26px; }
.intro p { margin: 0; color: var(--muted); max-width: 44ch; }
.intro__grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; max-width: 420px; }
.intro__cell { display: grid; gap: 2px; padding: 14px 8px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); }
.intro__cell b { font-size: 24px; font-weight: 800; letter-spacing: -.02em; color: var(--primary); }
.intro__cell span { font-size: 12px; font-weight: 600; color: var(--muted); }
.intro__hint { font-size: 13px; color: var(--faint); }

.results { display: grid; gap: 14px; }
.result-hero { padding: 30px 20px; text-align: center; display: grid; justify-items: center; gap: 10px; position: relative; overflow: hidden; }
.result-hero.is-pass { border-color: transparent; }
.result-hero.is-pass::before { content: ""; position: absolute; inset: 0; background: radial-gradient(60% 60% at 50% 0%, var(--accent-soft), transparent); pointer-events: none; }
.result-hero.is-fail::before { content: ""; position: absolute; inset: 0; background: radial-gradient(60% 60% at 50% 0%, var(--danger-soft), transparent); pointer-events: none; }
.bigring { position: relative; width: 168px; height: 168px; }
.bigring svg { transform: rotate(-90deg); }
.bigring circle { fill: none; stroke-width: 12; stroke-linecap: round; }
.bigring__track { stroke: var(--surface-2); }
.bigring__fill { transition: stroke-dashoffset 1.4s var(--ease); stroke: var(--accent); }
.is-fail .bigring__fill { stroke: var(--danger); }
.bigring__label { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; }
.bigring__label b { font-size: 40px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.bigring__label span { font-size: 13px; font-weight: 700; color: var(--muted); }
.result-hero h2 { font-size: 28px; }
.is-pass h2 { color: var(--accent); }
.is-fail h2 { color: var(--danger); }
.result-hero p { margin: 0; color: var(--muted); }
.result-hero .actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 8px; }

.breakdown { padding: 18px; display: grid; gap: 14px; }
.breakdown h3 { font-size: 16px; }
.brow { display: grid; gap: 6px; }
.brow__top { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; font-weight: 700; }
.brow__top span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }

.review { display: grid; gap: 10px; }
.review h3 { font-size: 16px; padding: 4px 4px 0; }
.rv { padding: 16px; display: grid; gap: 10px; }
.rv__q { font-weight: 700; font-size: 15px; display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; }
.rv__n { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; font-size: 12px; font-weight: 800; background: var(--danger-soft); color: var(--danger); flex: none; }
.rv__img { width: 96px; height: 96px; border-radius: 12px; background: #fff; border: 1px solid var(--border); padding: 6px; object-fit: contain; }
.rv__line { display: flex; gap: 8px; align-items: start; font-size: 14px; }
.rv__line .ic { flex: none; margin-top: 2px; }
.rv__line.is-wrong { color: var(--danger); }
.rv__line.is-right { color: var(--accent); }
.rv__expl { font-size: 13px; color: var(--muted); padding-top: 8px; border-top: 1px dashed var(--border); }

/* empty state */
.empty { padding: 40px 20px; text-align: center; display: grid; gap: 12px; justify-items: center; color: var(--muted); }
.empty__icon { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 20px; background: var(--primary-soft); color: var(--primary); }
.empty__icon .ic { width: 30px; height: 30px; }

/* history */
.hist { display: grid; gap: 8px; }
.hist__row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; padding: 12px 14px; font-size: 14px; }
.hist__row b { font-variant-numeric: tabular-nums; }
.hist__row time { color: var(--muted); font-size: 13px; }

/* ---------- toast + confetti ---------- */
.toast {
  position: fixed; inset-inline: 0; bottom: calc(var(--dock-h, 0px) + 20px + var(--safe-b)); margin: 0 auto; width: max-content; max-width: calc(100vw - 32px);
  padding: 12px 18px; border-radius: 14px; background: var(--text); color: var(--bg); font-weight: 700; font-size: 14px;
  box-shadow: var(--shadow-lg); z-index: var(--z-toast); opacity: 0; transform: translateY(12px); pointer-events: none;
  transition: opacity var(--t-med), transform var(--t-med) var(--ease);
}
.toast.is-show { opacity: 1; transform: none; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; width: 100%; height: 100%; }

/* ---------- sheet (confirm dialogs) ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(2, 6, 23, .55); z-index: var(--z-sheet); display: grid; align-items: end; justify-items: center; animation: fade var(--t-med) both; backdrop-filter: blur(4px); }
@media (min-width: 640px) { .sheet-backdrop { align-items: center; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: 100%; max-width: 480px; padding: 24px 20px calc(20px + var(--safe-b)); border-radius: var(--r-xl) var(--r-xl) 0 0;
  background: var(--surface-solid); box-shadow: var(--shadow-lg); display: grid; gap: 14px; animation: sheet-up var(--t-slow) var(--ease) both;
}
@media (min-width: 640px) { .sheet { border-radius: var(--r-xl); margin: 16px; } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
/* top-anchored sheet: keeps the dialog above the mobile keyboard */
.sheet-backdrop--top { align-items: start; }
.sheet-backdrop--top .sheet { margin: max(9vh, 48px) 16px 0; border-radius: var(--r-xl); animation-name: sheet-down; }
@keyframes sheet-down { from { transform: translateY(-32px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet h3 { font-size: 19px; }
.sheet p { margin: 0; color: var(--muted); font-size: 15px; }
.sheet__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .blob { animation: none; }
}

/* ---------- static SEO/content section (home only) ---------- */
.seo { position: relative; z-index: var(--z-app); max-width: 880px; margin: 0 auto; padding: 8px 14px 56px; color: var(--muted); font-size: 15px; }
.seo::before { content: ""; display: block; height: 1px; background: linear-gradient(90deg, transparent, var(--border-strong), transparent); margin: 8px 0 36px; }
.seo .eyebrow { margin: 0 0 6px; }
.seo h2 { font-size: 24px; color: var(--text); margin: 0 0 12px; }
.seo h3 { font-size: 17px; color: var(--text); margin: 28px 0 10px; }
.seo p { margin: 0 0 12px; max-width: 72ch; line-height: 1.65; }
.seo a { color: var(--primary); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.seo__stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 440px; margin: 20px 0 8px; }
.seo__stat { display: grid; gap: 2px; padding: 14px 8px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--border); text-align: center; backdrop-filter: blur(8px); }
.seo__stat b { font-size: 26px; font-weight: 800; letter-spacing: -.02em; background: var(--grad-text); -webkit-background-clip: text; background-clip: text; color: transparent; }
.seo__stat span { font-size: 12px; font-weight: 700; color: var(--muted); }
.seo details { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); margin-bottom: 8px; padding: 0 16px; backdrop-filter: blur(8px); transition: border-color var(--t-fast); }
.seo details:hover { border-color: var(--border-strong); }
.seo details[open] { border-color: var(--primary); }
.seo summary { cursor: pointer; font-weight: 700; color: var(--text); padding: 13px 0; list-style: none; min-height: 48px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.seo summary::-webkit-details-marker { display: none; }
.seo summary svg { flex: none; color: var(--faint); transition: transform var(--t-med) var(--ease); }
.seo details[open] summary svg { transform: rotate(180deg); color: var(--primary); }
.seo details p { padding-bottom: 14px; margin: 0; }
.seo__links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.seo__links a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: 13px; font-weight: 700; text-decoration: none; transition: background var(--t-fast), transform var(--t-fast); }
.seo__links a:hover { background: var(--primary); color: #fff; transform: translateY(-1px); }
.seo__disc { margin-top: 22px; padding-top: 16px; border-top: 1px dashed var(--border); font-size: 12.5px; color: var(--faint); }
/* language switching: html[lang] decides which block shows */
html[lang="ar"] .seo__lang[lang="en"] { display: none; }
html:not([lang="ar"]) .seo__lang[lang="ar"] { display: none; }

/* ---------- static site footer (home only) ---------- */
.site-foot { position: relative; z-index: var(--z-app); max-width: 880px; margin: 0 auto; padding: 10px 14px calc(88px + var(--safe-b)); text-align: center; display: grid; gap: 14px; justify-items: center; }
.site-foot__reset { color: var(--danger); border-color: var(--danger-soft); }
.site-foot__reset:hover { background: var(--danger-soft); border-color: transparent; }
.install-btn { min-width: 240px; }
.site-foot__c { margin: 0; font-size: 12px; color: var(--faint); }

/* ---------- road signs gallery ---------- */
.signs__h { font-size: 22px; }
.signs__hint { margin: 0 0 8px; font-size: 13px; }
.signs { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
@media (min-width: 640px) { .signs { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); } }
.sign { position: relative; aspect-ratio: 1; perspective: 700px; -webkit-tap-highlight-color: transparent; }
.sign__inner { position: absolute; inset: 0; transition: transform .55s var(--ease); transform-style: preserve-3d; }
.sign.is-flipped .sign__inner { transform: rotateY(180deg); }
.sign__face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; border-radius: 14px; display: grid; place-items: center; border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.sign__front { background: #fff; padding: 12px; }
.sign__front img { width: 100%; height: 100%; object-fit: contain; }
.sign__back { background: var(--surface); transform: rotateY(180deg); font-size: 11.5px; font-weight: 700; line-height: 1.3; padding: 8px; text-align: center; color: var(--text); overflow: hidden; }
@media (prefers-reduced-motion: reduce) { .sign__inner { transition: none; } }

/* ---------- misc: meta buttons, jump counter, number input ---------- */
.qcard__meta-right { display: flex; gap: 2px; }
.qnav__count--btn { cursor: pointer; border-radius: 10px; padding: 6px 10px; border: 1px dashed var(--border-strong); transition: background var(--t-fast), border-color var(--t-fast); display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.qnav__count--btn .ic { width: 14px; height: 14px; color: var(--primary); }
.qnav__count--btn:hover { background: var(--surface-2); border-color: var(--primary); color: var(--text); }
.sheet__input { width: 100%; min-height: 52px; padding: 0 16px; font: inherit; font-weight: 700; font-size: 18px; color: var(--text); background: var(--surface-2); border: 1.5px solid var(--border); border-radius: 14px; }
.sheet__input:focus { outline: none; border-color: var(--primary); box-shadow: var(--glow); }
