/* ═══════════════════════════════════════════
   IQ LEVEL — Design System
   Palette: Milky white · Anthropic coral
═══════════════════════════════════════════ */

:root {
  --bg:          #FAF8F5;
  --bg-alt:      #F5F1EB;
  --surface:     #FFFFFF;
  --surface-h:   #F9F7F4;
  --border:      #EBE6DF;
  --border-str:  #D6CFC6;

  --accent:      #CC5533;
  --accent-h:    #B84B2C;
  --accent-lt:   #FBF1ED;
  --accent-md:   #EDCFC4;

  --text-1:      #1C1917;
  --text-2:      #6B635D;
  --text-3:      #A8A29E;
  --text-4:      #C6C0BA;

  --ok:          #16803A;
  --ok-bg:       #F0FDF4;
  --ok-brd:      #86EFAC;
  --err:         #DC2626;
  --err-bg:      #FEF2F2;
  --err-brd:     #FECACA;

  --cat-0-c:     #5B54CC;
  --cat-0-bg:    #F0EFFC;
  --cat-0-brd:   #C5C2F0;
  --cat-1-c:     #166534;
  --cat-1-bg:    #F0FDF4;
  --cat-1-brd:   #86EFAC;
  --cat-2-c:     #92400E;
  --cat-2-bg:    #FFFBEB;
  --cat-2-brd:   #FCD34D;
  --cat-3-c:     #9D174D;
  --cat-3-bg:    #FFF1F2;
  --cat-3-brd:   #FBCFE8;

  --sh-sm: 0 1px 3px rgba(28,25,23,.06), 0 1px 2px rgba(28,25,23,.04);
  --sh-md: 0 4px 14px rgba(28,25,23,.08), 0 2px 6px rgba(28,25,23,.04);
  --sh-lg: 0 12px 32px rgba(28,25,23,.1),  0 4px 8px rgba(28,25,23,.05);

  --r-sm:  8px;
  --r:     14px;
  --r-lg:  20px;
  --r-xl:  28px;

  --font-ar: 'Tajawal', system-ui, sans-serif;
  --font-en: 'Inter',   system-ui, sans-serif;
}

/* ── Reset ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text-1);
  font-family: var(--font-ar);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  line-height: 1.65;
}
body.en { font-family: var(--font-en); }

/* ── Language Toggle ────────────────────── */
.lang-btn {
  position: fixed;
  top: 16px;
  inset-inline-start: 20px;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 16px;
  border-radius: 100px;
  cursor: pointer;
  box-shadow: var(--sh-sm);
  font-family: inherit;
  transition: all .18s ease;
  letter-spacing: .3px;
}
.lang-btn:hover {
  background: var(--surface-h);
  border-color: var(--border-str);
  color: var(--text-1);
}

/* ── Phases ─────────────────────────────── */
.phase { display: block; animation: fadeUp .4s ease both; }
.phase.hidden { display: none !important; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Container ──────────────────────────── */
.container {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ══════════════════════════════════════════
   INTRO PHASE
══════════════════════════════════════════ */
#phase-intro {
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding: 80px 0 60px;
}

.intro-wrap { text-align: center; }

/* Live badge */
.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 7px 18px;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 36px;
  box-shadow: var(--sh-sm);
}
.live-dot {
  width: 7px; height: 7px;
  background: #22C55E;
  border-radius: 50%;
  flex-shrink: 0;
  animation: pulse 2s ease infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34,197,94,.4); }
  50%      { opacity: .8; box-shadow: 0 0 0 5px rgba(34,197,94,0); }
}

/* Brand */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}
.brand-icon {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, var(--accent), #E8734A);
  border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #fff;
  box-shadow: 0 4px 16px rgba(204,85,51,.28);
}
.brand-name {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-1);
  letter-spacing: -.4px;
  line-height: 1.2;
}
.brand-sub {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 1px;
}

/* Heading */
.intro-h1 {
  font-size: clamp(28px, 6vw, 44px);
  font-weight: 900;
  color: var(--text-1);
  letter-spacing: -.5px;
  line-height: 1.2;
  margin-bottom: 14px;
}
.intro-p {
  font-size: 16px;
  color: var(--text-2);
  line-height: 1.75;
  margin-bottom: 36px;
}

/* Input Card */
.input-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: var(--sh-md);
  text-align: start;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.field { display: flex; flex-direction: column; gap: 7px; }
.field-lbl {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.field-inp {
  background: var(--bg-alt);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: 13px 16px;
  font-size: 16px;
  color: var(--text-1);
  font-family: inherit;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
  width: 100%;
}
.field-inp:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(204,85,51,.12);
}
.field-inp::placeholder { color: var(--text-4); }

/* Primary Button */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--r);
  padding: 15px 32px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(204,85,51,.3);
  transition: all .18s ease;
  width: 100%;
  justify-content: center;
  letter-spacing: .2px;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-h);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(204,85,51,.35);
}
.btn-primary:disabled {
  background: var(--border-str);
  color: var(--text-4);
  box-shadow: none;
  cursor: not-allowed;
}
.btn-arrow { font-size: 18px; line-height: 1; }

/* Ghost Button */
.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  color: var(--text-2);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: 15px 28px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all .18s ease;
  justify-content: center;
}
.btn-ghost:hover {
  background: var(--surface-h);
  border-color: var(--border-str);
  color: var(--text-1);
}

/* Meta row */
.meta-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 20px 0 16px;
  flex-wrap: wrap;
}
.meta-item { font-size: 14px; color: var(--text-2); }
.meta-item strong { color: var(--accent); font-weight: 800; }
.meta-sep { color: var(--border-str); font-size: 16px; }

/* Category pills */
.cat-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.cat-pill {
  font-size: 12px;
  font-weight: 700;
  padding: 5px 13px;
  border-radius: 100px;
  letter-spacing: .4px;
}
.cat-0 { background: var(--cat-0-bg); color: var(--cat-0-c); border: 1px solid var(--cat-0-brd); }
.cat-1 { background: var(--cat-1-bg); color: var(--cat-1-c); border: 1px solid var(--cat-1-brd); }
.cat-2 { background: var(--cat-2-bg); color: var(--cat-2-c); border: 1px solid var(--cat-2-brd); }
.cat-3 { background: var(--cat-3-bg); color: var(--cat-3-c); border: 1px solid var(--cat-3-brd); }

/* ══════════════════════════════════════════
   TEST PHASE
══════════════════════════════════════════ */
#phase-test { min-height: 100vh; display: flex; flex-direction: column; }

/* Header */
.test-hdr {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--sh-sm);
}
.test-logo {
  font-size: 15px;
  font-weight: 800;
  color: var(--accent);
  flex-shrink: 0;
  letter-spacing: -.2px;
}
.prog-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}
.prog-track {
  flex: 1;
  height: 5px;
  background: var(--bg-alt);
  border-radius: 99px;
  overflow: hidden;
}
.prog-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #E8734A);
  border-radius: 99px;
  width: 0;
  transition: width .5s ease;
}
.prog-txt {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 600;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Timer */
.timer-box {
  position: relative;
  width: 44px; height: 44px;
  flex-shrink: 0;
}
.timer-svg { width: 44px; height: 44px; }
.timer-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  font-family: var(--font-en);
}
.timer-num.urgent { color: var(--err); }

/* Test body */
.test-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}
.q-card {
  width: 100%;
  max-width: 640px;
  animation: fadeUp .35s ease both;
}

/* Category badge inside question */
.q-cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 18px;
}

/* Question text */
.q-text {
  font-size: clamp(16px, 2.5vw, 21px);
  font-weight: 700;
  color: var(--text-1);
  line-height: 1.5;
  margin-bottom: 20px;
}

/* Sequence display */
.q-seq {
  background: var(--accent-lt);
  border: 1px solid var(--accent-md);
  border-radius: var(--r-lg);
  padding: 22px 16px;
  text-align: center;
  font-size: clamp(22px, 4.5vw, 32px);
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 3px;
  margin-bottom: 24px;
  font-family: var(--font-en);
  line-height: 1;
}

/* Options grid */
.opts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Option button */
.opt-btn {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: 14px 16px;
  cursor: pointer;
  color: var(--text-1);
  font-size: 15px;
  font-family: inherit;
  text-align: start;
  transition: all .15s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  line-height: 1.4;
  box-shadow: var(--sh-sm);
}
.opt-btn:hover:not(:disabled) {
  border-color: var(--accent-md);
  background: var(--accent-lt);
  transform: translateY(-1px);
  box-shadow: var(--sh-md);
}
.opt-btn:disabled { cursor: default; }
.opt-btn.correct {
  border-color: var(--ok-brd) !important;
  background: var(--ok-bg) !important;
  color: var(--ok);
}
.opt-btn.wrong {
  border-color: var(--err-brd) !important;
  background: var(--err-bg) !important;
  color: var(--err);
  animation: shake .38s ease;
}
.opt-btn.reveal {
  border-color: var(--ok-brd) !important;
  background: var(--ok-bg) !important;
  color: var(--ok);
  opacity: .7;
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25%,75%  { transform: translateX(-5px); }
  50%      { transform: translateX(5px); }
}

/* Option key */
.opt-key {
  width: 26px; height: 26px;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: var(--text-3);
  flex-shrink: 0;
  font-family: var(--font-en);
}
.opt-btn.correct .opt-key { background: rgba(22,128,58,.1); border-color: var(--ok-brd); color: var(--ok); }
.opt-btn.wrong   .opt-key { background: rgba(220,38,38,.1); border-color: var(--err-brd); color: var(--err); }

/* Feedback bar */
.feedback-bar {
  margin-top: 14px;
  padding: 14px 18px;
  border-radius: var(--r);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  animation: fadeUp .3s ease;
}
.feedback-bar.ok {
  background: var(--ok-bg);
  border: 1px solid var(--ok-brd);
}
.feedback-bar.err {
  background: var(--err-bg);
  border: 1px solid var(--err-brd);
}
.fb-icon { font-size: 18px; line-height: 1; flex-shrink: 0; margin-top: 1px; }
.fb-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 3px;
}
.feedback-bar.ok  .fb-title { color: var(--ok); }
.feedback-bar.err .fb-title { color: var(--err); }
.fb-exp { font-size: 13px; color: var(--text-2); line-height: 1.55; }

/* Skip hint */
.skip-hint {
  text-align: center;
  font-size: 11.5px;
  color: var(--text-4);
  margin-top: 16px;
}

/* ══════════════════════════════════════════
   RESULT PHASE
══════════════════════════════════════════ */
#phase-result { padding: 56px 0 80px; }

/* Hero */
.result-hero {
  text-align: center;
  margin-bottom: 40px;
}
.eyebrow {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 3px;
  margin-bottom: 16px;
}
.iq-num {
  font-size: clamp(88px, 18vw, 136px);
  font-weight: 900;
  color: var(--accent);
  line-height: .9;
  letter-spacing: -4px;
  font-family: var(--font-en);
  text-shadow: 0 4px 40px rgba(204,85,51,.18);
}
.iq-lbl {
  font-size: 13px;
  color: var(--text-3);
  margin-top: 8px;
  text-transform: uppercase;
  letter-spacing: 2px;
}
.class-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 100px;
  padding: 10px 24px;
  box-shadow: var(--sh-md);
}
.class-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
#class-txt {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
}
.pct-txt {
  margin-top: 12px;
  font-size: 14px;
  color: var(--text-3);
}
.pct-txt strong { color: var(--text-1); font-weight: 700; }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 14px;
  text-align: center;
  box-shadow: var(--sh-sm);
}
.stat-val {
  font-size: clamp(26px, 5vw, 36px);
  font-weight: 900;
  color: var(--accent);
  font-family: var(--font-en);
  line-height: 1;
}
.stat-lbl {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 7px;
  text-transform: uppercase;
  letter-spacing: .8px;
}

/* Section card */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: var(--sh-sm);
}
.sec-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 22px;
}

/* Breakdown */
.bd-list { display: flex; flex-direction: column; gap: 16px; }
.bd-row {}
.bd-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 7px;
}
.bd-name { font-size: 14px; font-weight: 600; color: var(--text-1); }
.bd-score { font-size: 14px; font-weight: 800; font-family: var(--font-en); }
.bd-track {
  height: 8px;
  background: var(--bg-alt);
  border-radius: 99px;
  overflow: hidden;
}
.bd-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 1.2s ease;
}

/* Certificate section */
.cert-hdr-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  flex-wrap: wrap;
  gap: 8px;
}
.cert-hint { font-size: 12px; color: var(--text-4); }
.cert-wrap {
  border-radius: var(--r-lg);
  overflow: hidden;
  background: var(--bg-alt);
  min-height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
}
.cert-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-3);
  font-size: 13px;
}
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#cert-img {
  width: 100%;
  display: block;
  cursor: pointer;
  transition: opacity .2s;
}
#cert-img:hover { opacity: .95; }

/* Action row */
.action-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.action-row .btn-primary,
.action-row .btn-ghost {
  flex: 1;
  min-width: 160px;
}

/* Footer note */
.foot-note {
  text-align: center;
  font-size: 12px;
  color: var(--text-4);
}

/* ══════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════ */
@media (max-width: 520px) {
  .opts-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stats-grid .stat-card:last-child { grid-column: 1 / -1; }
  .intro-h1 { font-size: 30px; }
  .iq-num { font-size: 96px; }
}

@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr; }
  .meta-row { gap: 8px; font-size: 13px; }
}

/* ══════════════════════════════════════════
   PRINT / share polish
══════════════════════════════════════════ */
@media print {
  .lang-btn, .action-row { display: none; }
}
