/* ===================================================================
   قياسي — Core design tokens + component primitives
   Theme is switched with a single [data-theme] attribute.
   =================================================================== */

/* ---------- LIGHT (default) ---------- */
:root,
[data-theme="light"] {
  --paper:        #ECE7DC;  /* app background — warm paper */
  --surface:      #FCFAF5;  /* screen base */
  --surface-2:    #FFFFFF;  /* cards / raised */
  --ink:          #1E2A2C;  /* primary text */
  --muted:        #6E7B7D;  /* secondary text */
  --faint:        #9AA6A7;  /* tertiary / labels */
  --line:         #E8E2D6;  /* hairlines / borders */
  --line-soft:    #F0EBE0;

  --emerald:      #15795B;  /* progress / good — THE accent */
  --emerald-2:    #1B8A66;  /* gradient partner */
  --emerald-deep: #136A4A;
  --emerald-soft: #E2F0EA;  /* tinted fills */
  --on-emerald:   #FFFFFF;

  --gold:         #B07D12;  /* points / rewards ONLY */
  --gold-2:       #E8C25A;
  --gold-soft:    #F8EFD6;

  --terra:        #B6543B;  /* "down" / weak-spot ONLY */
  --terra-ink:    #8F3F2B;
  --terra-soft:   #F4E1DA;

  --shadow-card:  0 1px 2px rgba(30,42,44,.04);
  --shadow-pop:   0 14px 30px -14px rgba(21,121,91,.45);
  --shadow-phone: 0 30px 70px -28px rgba(30,42,44,.45), 0 0 0 1px var(--line);
}

/* ---------- DARK (premium) ---------- */
[data-theme="dark"] {
  --paper:        #10201C;
  --surface:      #0E1F1A;
  --surface-2:    #122A23;
  --ink:          #EAF3EF;
  --muted:        #8FA89F;
  --faint:        #5F7D74;
  --line:         #1F3D34;
  --line-soft:    #1a352d;

  --emerald:      #2EC98E;
  --emerald-2:    #1F9D74;
  --emerald-deep: #0F5D43;
  --emerald-soft: #143A2C;
  --on-emerald:   #06150F;

  --gold:         #E6B45A;
  --gold-2:       #F0CE84;
  --gold-soft:    #2E2410;

  --terra:        #E2876A;
  --terra-ink:    #E2876A;
  --terra-soft:   #3A221A;

  --shadow-card:  0 1px 2px rgba(0,0,0,.25);
  --shadow-pop:   0 14px 32px -14px rgba(0,0,0,.6);
  --shadow-phone: 0 30px 70px -26px rgba(0,0,0,.7), 0 0 0 1px var(--line);
}

/* ---------- spacing / radius scale ---------- */
:root {
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-7: 32px; --s-8: 40px;

  --r-sm: 8px;  --r-md: 12px; --r-lg: 16px;
  --r-xl: 22px; --r-2xl: 28px; --r-pill: 999px;

  --fs-display: 28px;
  --fs-h1: 20px;
  --fs-h2: 17px;
  --fs-lg: 15px;
  --fs-body: 14.5px;
  --fs-sm: 12.5px;
  --fs-xs: 11.5px;
  --fs-2xs: 10.5px;

  --font: 'Readex Pro', system-ui, sans-serif;
}

/* ===================================================================
   Base
   =================================================================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

.q-root {
  font-family: var(--font);
  color: var(--ink);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ===================================================================
   Pills
   =================================================================== */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 600; line-height: 1;
  padding: 6px 11px; white-space: nowrap;
}
.pill svg { width: 13px; height: 13px; }
.pill-gold  { background: var(--gold-soft);    color: var(--gold); }
.pill-em    { background: var(--emerald-soft);  color: var(--emerald); }
.pill-terra { background: var(--terra-soft);    color: var(--terra); }
.pill-ghost { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }

/* ===================================================================
   Cards
   =================================================================== */
.card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-card);
}

/* ===================================================================
   Buttons
   =================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  font-family: inherit; font-size: var(--fs-body); font-weight: 600;
  border-radius: var(--r-md); padding: 14px 16px;
  border: 1.5px solid transparent; cursor: pointer;
  transition: transform .12s ease, background .15s ease, border-color .15s ease, opacity .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.985); }
.btn svg { width: 18px; height: 18px; }

.btn-solid { background: var(--emerald); color: var(--on-emerald); }
.btn-solid:hover { background: var(--emerald-2); }

.btn-line { background: transparent; border-color: var(--emerald); color: var(--emerald); }
.btn-line:hover { background: var(--emerald-soft); }

.btn-ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); }

.btn-white { background: #fff; color: var(--emerald-deep); }

.btn-sm { padding: 10px 14px; font-size: var(--fs-sm); width: auto; }

/* ===================================================================
   Answer option rows (أ / ب / ج / د)
   =================================================================== */
.opt {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: start;
  background: var(--surface-2); border: 1.5px solid var(--line);
  color: var(--ink); border-radius: var(--r-md);
  padding: 14px 14px; font-family: inherit; font-size: var(--fs-body); font-weight: 500;
  cursor: pointer; transition: border-color .14s ease, background .14s ease;
  -webkit-tap-highlight-color: transparent;
}
.opt .opt-k {
  width: 28px; height: 28px; flex: none;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line);
  color: var(--muted); font-size: var(--fs-sm); font-weight: 600;
}
.opt:hover { border-color: var(--faint); }
.opt.sel { border-color: var(--emerald); background: var(--emerald-soft); }
.opt.sel .opt-k { background: var(--emerald); border-color: var(--emerald); color: var(--on-emerald); }

/* review-only states */
.opt.correct { border-color: var(--emerald); background: var(--emerald-soft); }
.opt.correct .opt-k { background: var(--emerald); border-color: var(--emerald); color: var(--on-emerald); }
.opt.incorrect { border-color: var(--terra); background: var(--terra-soft); }
.opt.incorrect .opt-k { background: var(--terra); border-color: var(--terra); color: #fff; }

/* ===================================================================
   Progress bar + session timer
   =================================================================== */
.pbar { height: 6px; border-radius: var(--r-pill); background: var(--line); overflow: hidden; }
.pbar > i { display: block; height: 100%; background: var(--emerald); border-radius: var(--r-pill); transition: width .4s ease; }

.timer {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-sm); font-weight: 700;
  padding: 5px 11px; border-radius: var(--r-pill);
  background: var(--emerald-soft); color: var(--emerald);
}
.timer.warn { background: var(--terra-soft); color: var(--terra); }
.timer svg { width: 14px; height: 14px; }

/* ===================================================================
   Improvement meter (the red/green bars)
   =================================================================== */
.meter { display: flex; gap: 5px; align-items: flex-end; height: 36px; }
.meter .bar { flex: 1; border-radius: 4px; background: var(--emerald-soft); min-height: 6px; }
.meter .bar.up   { background: var(--emerald); }
.meter .bar.down { background: var(--terra); }

/* ===================================================================
   Bottom navigation
   =================================================================== */
.bottom-nav {
  display: flex; justify-content: space-around;
  background: var(--surface-2); border-top: 1px solid var(--line-soft);
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 0px));
}
.bottom-nav .nav-it {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  font-size: var(--fs-2xs); font-weight: 500; color: var(--faint);
  background: none; border: none; font-family: inherit; cursor: pointer;
  flex: 1; padding: 2px 0; transition: color .15s ease;
}
.bottom-nav .nav-it svg { width: 23px; height: 23px; }
.bottom-nav .nav-it.on { color: var(--emerald); }

/* ===================================================================
   Icons — one family, single stroke
   =================================================================== */
.icon { display: inline-block; vertical-align: middle; }
.icon svg {
  width: 100%; height: 100%; display: block;
  fill: none; stroke: currentColor; stroke-width: 1.7;
  stroke-linecap: round; stroke-linejoin: round;
}
.icon.fill svg { fill: currentColor; stroke: none; }

/* segmented control */
.seg {
  display: flex; background: var(--line); border-radius: var(--r-md);
  padding: 3px; gap: 3px;
}
.seg button {
  flex: 1; text-align: center; font-family: inherit;
  font-size: var(--fs-sm); font-weight: 600; padding: 9px 8px;
  border-radius: 9px; color: var(--muted); cursor: pointer;
  background: transparent; border: none; transition: all .15s ease;
}
.seg button.on { background: var(--surface-2); color: var(--ink); box-shadow: 0 2px 6px -2px rgba(0,0,0,.14); }

/* divider with centered label */
.divider { display: flex; align-items: center; gap: 8px; color: var(--faint); font-size: var(--fs-2xs); }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
