/* =========================================================
   BijakKAFA — design system
   No CDN, no framework. Hand-written so CSP stays strict and
   payload stays under 20KB. Mobile-first from 360px.
   ========================================================= */

:root {
  --brand-50:  #eefbf7;
  --brand-100: #d3f5ea;
  --brand-200: #a8ebd7;
  --brand-300: #6dd9bd;
  --brand-400: #35bf9e;
  --brand-500: #14a085;
  --brand-600: #0a806d;
  --brand-700: #0a6659;
  --brand-800: #0b5149;
  --brand-900: #0a443d;

  --amber-50:  #fffaeb;
  --amber-100: #fff1c6;
  --amber-200: #ffe188;
  --amber-300: #ffcb4a;
  --amber-400: #ffb320;
  --amber-600: #dd6a02;
  --amber-700: #b74a06;

  --ink-50:  #f7f8f8;
  --ink-100: #eeeff1;
  --ink-200: #dcdee2;
  --ink-300: #b9bec6;
  --ink-400: #8d95a1;
  --ink-500: #6b747f;
  --ink-600: #545c66;
  --ink-700: #434a52;
  --ink-800: #2b3038;
  --ink-900: #1a1d22;

  --surface:     #fffdf8;
  --surface-alt: #f7f5ef;

  --green-100: #d1fae5; --green-600: #059669; --green-800: #065f46;
  --red-100:   #fee2e2; --red-600:   #dc2626; --red-800:   #991b1b;

  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05);
  --shadow: 0 4px 12px rgba(16,24,40,.08);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-arabic: "Noto Naskh Arabic", "Amiri", "Traditional Arabic", "Times New Roman", serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-800);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; height: auto; display: block; }

/* ---------- Jawi / Arabic ---------- */
[lang="ar"], [lang="ms-Arab"], .jawi {
  font-family: var(--font-arabic);
  direction: rtl;
  unicode-bidi: isolate;
  line-height: 2.1;
  font-size: 1.15em;
  letter-spacing: 0;
}
.jawi-inline {
  font-family: var(--font-arabic);
  direction: rtl;
  unicode-bidi: embed;
  font-size: 1.1em;
}

/* ---------- focus: always visible ---------- */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--brand-500);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  /* Visually hidden but focusable. Uses 1px + clip instead of left:-9999px
     because a large off-screen box can create horizontal scroll on some
     mobile browsers (and inflates the layout width). */
  position: absolute; top: 0; left: 0;
  width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
  z-index: 100;
  background: var(--brand-700); color: #fff;
  padding: .75rem 1.25rem; border-radius: 0 0 .5rem 0;
  font-weight: 700;
}
.skip-link:focus {
  width: auto; height: auto; overflow: visible;
  clip-path: none; white-space: normal;
}

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

/* ---------- layout ---------- */
.container { width: 100%; max-width: 1120px; margin-inline: auto; padding-inline: 1rem; }
@media (min-width: 640px) { .container { padding-inline: 1.5rem; } }

.stack > * + * { margin-top: 1rem; }
.grid { display: grid; gap: 1rem; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } .grid-4 { grid-template-columns: repeat(4, 1fr); } }

section { padding-block: 3rem; }
@media (min-width: 640px) { section { padding-block: 4.5rem; } }

/* ---------- typography ---------- */
h1, h2, h3, h4 { margin: 0; line-height: 1.25; color: var(--ink-900); font-weight: 800; letter-spacing: -.015em; }
h1 { font-size: clamp(1.75rem, 5vw, 2.75rem); }
h2 { font-size: clamp(1.375rem, 3.5vw, 1.875rem); }
h3 { font-size: 1.0625rem; font-weight: 700; }
p  { margin: 0; }
.lead { font-size: 1.0625rem; color: var(--ink-600); line-height: 1.7; }
.muted { color: var(--ink-500); }
.small { font-size: .8125rem; }
.tiny { font-size: .75rem; }
.center { text-align: center; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255,253,248,.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--ink-200);
}
.site-header .inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px; gap: 1rem;
}
.logo { display: inline-flex; align-items: center; gap: .5rem; text-decoration: none; color: var(--ink-900); }
.logo-mark {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--brand-700); color: #fff;
  font-size: 1.125rem; font-weight: 800;
  font-family: var(--font-arabic);
}
.logo-text { font-size: 1.0625rem; font-weight: 800; letter-spacing: -.02em; }
.logo-text span { color: var(--brand-600); }

.nav { display: none; gap: .25rem; }
@media (min-width: 860px) { .nav { display: flex; } }
.nav a {
  padding: .5rem .75rem; border-radius: 8px;
  font-size: .875rem; font-weight: 600; color: var(--ink-600);
  text-decoration: none;
}
.nav a:hover { background: var(--ink-100); color: var(--ink-900); }

.header-actions { display: flex; align-items: center; gap: .5rem; }

/* mobile menu */
.mobile-toggle {
  display: grid; place-items: center;
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--ink-200); background: #fff; cursor: pointer;
}
@media (min-width: 860px) { .mobile-toggle { display: none; } }
.mobile-nav { display: none; border-top: 1px solid var(--ink-200); background: var(--surface); }
.mobile-nav.open { display: block; }
.mobile-nav a {
  display: block; padding: .75rem 1rem;
  font-weight: 600; color: var(--ink-700); text-decoration: none;
  border-bottom: 1px solid var(--ink-100);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font-family: inherit; font-size: .9375rem; font-weight: 700;
  border-radius: 10px; border: 2px solid transparent;
  padding: .625rem 1rem; min-height: 44px;   /* WCAG touch target */
  cursor: pointer; text-decoration: none; text-align: center;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--brand-700); color: #fff; }
.btn-primary:hover { background: var(--brand-800); }
.btn-secondary { background: #fff; color: var(--brand-800); border-color: var(--brand-200); }
.btn-secondary:hover { border-color: var(--brand-400); background: var(--brand-50); }
.btn-ghost { background: transparent; color: var(--ink-700); }
.btn-ghost:hover { background: var(--ink-100); }
.btn-danger { background: var(--red-600); color: #fff; }
.btn-danger:hover { background: var(--red-800); }
.btn-sm { font-size: .8125rem; padding: .375rem .75rem; min-height: 36px; }
.btn-lg { font-size: 1rem; padding: .875rem 1.5rem; min-height: 52px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- cards ---------- */
.card {
  background: #fff; border: 1px solid var(--ink-200);
  border-radius: var(--radius-lg); padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}
.card-lg { padding: 1.75rem; }
.card-flat { box-shadow: none; background: var(--surface-alt); }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .125rem .625rem; border-radius: 999px;
  font-size: .75rem; font-weight: 700; letter-spacing: .01em;
  background: var(--ink-100); color: var(--ink-700);
}
.badge-brand { background: var(--brand-100); color: var(--brand-800); }
.badge-amber { background: var(--amber-100); color: var(--amber-700); }
.badge-green { background: var(--green-100); color: var(--green-800); }
.badge-red   { background: var(--red-100);   color: var(--red-800); }

/* ---------- forms ---------- */
.field { margin-bottom: 1rem; }
.label {
  display: block; font-size: .875rem; font-weight: 700;
  color: var(--ink-800); margin-bottom: .375rem;
}
.input, .select, .textarea {
  width: 100%; font-family: inherit; font-size: .9375rem;
  padding: .625rem .875rem; min-height: 44px;
  border: 1px solid var(--ink-300); border-radius: 10px;
  background: #fff; color: var(--ink-900);
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(20,160,133,.15);
  outline: none;
}
.textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
.hint { font-size: .75rem; color: var(--ink-500); margin-top: .25rem; }
.error-text { font-size: .8125rem; color: var(--red-600); margin-top: .25rem; font-weight: 600; }
.input-invalid { border-color: var(--red-600); }
.checkbox-row { display: flex; gap: .625rem; align-items: flex-start; font-size: .875rem; line-height: 1.55; }
.checkbox-row input { margin-top: .25rem; width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--brand-600); }

/* ---------- alerts ---------- */
.alert {
  padding: .875rem 1rem; border-radius: 10px;
  font-size: .875rem; border: 1px solid; line-height: 1.55;
}
.alert strong { display: block; font-weight: 700; margin-bottom: .125rem; }
.alert-success { background: var(--green-100); border-color: #6ee7b7; color: var(--green-800); }
.alert-error   { background: var(--red-100);   border-color: #fca5a5; color: var(--red-800); }
.alert-warning { background: var(--amber-50);  border-color: var(--amber-200); color: var(--amber-700); }
.alert-info    { background: var(--brand-50);  border-color: var(--brand-200); color: var(--brand-900); }

/* ---------- progress ---------- */
.progress {
  height: 10px; width: 100%; border-radius: 999px;
  background: var(--ink-100); overflow: hidden;
}
.progress-bar { height: 100%; border-radius: 999px; background: var(--brand-500); transition: width .3s; }
.progress-bar.amber { background: var(--amber-400); }
.progress-bar.red   { background: var(--red-600); }
.progress-bar.green { background: var(--green-600); }

/* ---------- stats ---------- */
.stat { text-align: center; padding: .625rem .25rem; background: var(--surface-alt); border-radius: 10px; }
.stat dt { font-size: .625rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-500); margin: 0; }
.stat dd { font-size: 1.25rem; font-weight: 800; color: var(--ink-900); margin: .125rem 0 0; }
.stats-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }

/* ---------- quiz ---------- */
.choice {
  display: flex; align-items: flex-start; gap: .75rem;
  width: 100%; text-align: left; font-family: inherit; font-size: .9375rem;
  padding: .875rem 1rem; min-height: 56px;
  border: 2px solid var(--ink-200); border-radius: 12px;
  background: #fff; color: var(--ink-800); cursor: pointer;
  transition: border-color .12s, background-color .12s;
}
.choice:hover:not(:disabled) { border-color: var(--brand-300); background: var(--brand-50); }
.choice[aria-pressed="true"] { border-color: var(--brand-600); background: var(--brand-50); }
.choice-label {
  display: grid; place-items: center; flex-shrink: 0;
  width: 26px; height: 26px; border-radius: 999px;
  background: var(--ink-100); color: var(--ink-600);
  font-size: .75rem; font-weight: 800;
}
.choice[aria-pressed="true"] .choice-label { background: var(--brand-600); color: #fff; }
.choice.correct { border-color: var(--green-600); background: var(--green-100); }
.choice.correct .choice-label { background: var(--green-600); color: #fff; }
.choice.incorrect { border-color: var(--red-600); background: var(--red-100); }
.choice.incorrect .choice-label { background: var(--red-600); color: #fff; }
.choice:disabled { cursor: default; }
.choice-text { flex: 1; line-height: 1.55; }

.quiz-dots { display: flex; flex-wrap: wrap; gap: .375rem; }
.quiz-dot {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--ink-300); background: #fff;
  font-size: .75rem; font-weight: 700; color: var(--ink-600);
  cursor: pointer; padding: 0;
}
.quiz-dot.answered { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.quiz-dot.current { outline: 2px solid var(--brand-600); outline-offset: 2px; }

.timer {
  font-variant-numeric: tabular-nums; font-weight: 800;
  padding: .375rem .75rem; border-radius: 999px;
  background: var(--ink-100); color: var(--ink-800); font-size: .875rem;
}
.timer.urgent { background: var(--red-100); color: var(--red-800); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { padding: .625rem .75rem; text-align: left; border-bottom: 1px solid var(--ink-200); vertical-align: top; }
th { font-weight: 700; color: var(--ink-700); background: var(--surface-alt); font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; }

/* ---------- prose (notes) ---------- */
.prose h2 { font-size: 1.25rem; margin: 1.5rem 0 .5rem; }
.prose h3 { font-size: 1.0625rem; margin: 1.25rem 0 .375rem; }
.prose p { margin: .75rem 0; line-height: 1.75; }
.prose ul, .prose ol { margin: .75rem 0; padding-left: 1.5rem; }
.prose li { margin: .375rem 0; line-height: 1.7; }
.prose blockquote {
  margin: .875rem 0; padding: .625rem .875rem;
  border-left: 3px solid var(--brand-300);
  background: var(--brand-50); color: var(--ink-700);
  border-radius: 0 8px 8px 0;
}
.prose strong { font-weight: 700; color: var(--ink-900); }
.prose code { background: var(--ink-100); padding: .125rem .375rem; border-radius: 4px; font-size: .9em; }

/* ---------- footer ---------- */
.site-footer {
  margin-top: 4rem; padding-block: 3rem;
  border-top: 1px solid var(--ink-200); background: var(--surface-alt);
}
.footer-grid { display: grid; gap: 2rem; }
@media (min-width: 640px) { .footer-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .footer-grid { grid-template-columns: 2fr 1fr 1fr 1fr; } }
.footer-col h2 { font-size: .8125rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-900); margin-bottom: .75rem; }
.footer-col ul { list-style: none; margin: 0; padding: 0; }
.footer-col li { margin-bottom: .5rem; }
.footer-col a { font-size: .875rem; color: var(--ink-600); text-decoration: none; }
.footer-col a:hover { color: var(--brand-700); text-decoration: underline; }
.footer-legal { margin-top: 2.5rem; padding-top: 1.5rem; border-top: 1px solid var(--ink-200); }
.disclaimer { font-size: .75rem; line-height: 1.65; color: var(--ink-500); }

/* ---------- utilities ---------- */
.flex { display: flex; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .25rem; } .gap-2 { gap: .5rem; } .gap-3 { gap: .75rem; } .gap-4 { gap: 1rem; }
.mt-1 { margin-top: .25rem; } .mt-2 { margin-top: .5rem; } .mt-3 { margin-top: .75rem; }
.mt-4 { margin-top: 1rem; } .mt-6 { margin-top: 1.5rem; } .mt-8 { margin-top: 2rem; }
.mb-2 { margin-bottom: .5rem; } .mb-3 { margin-bottom: .75rem; } .mb-4 { margin-bottom: 1rem; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.hidden { display: none; }
