﻿/* 
   styles.css   Minimal custom layer on top of Tailwind CDN
   Handles: CSS vars, animations, decorative effects,
   JS-rendered components, and RTL overrides.
   All layout/spacing/typography = Tailwind utility classes.
 */

/*  Dark (default)  */
:root,
[data-theme="dark"] {
  --clr-bg:                  #070b14;
  --clr-surface:             #0d1424;
  --clr-card:                #111827;
  --clr-border:              rgba(255,255,255,0.07);
  --clr-primary:             #3b82f6;
  --clr-primary-h:           #2563eb;
  --clr-accent:              #8b5cf6;
  --clr-gold:                #f59e0b;
  --clr-text:                #f1f5f9;
  --clr-muted:               #94a3b8;
  --clr-subtle:              #475569;
  --radius:                  16px;
  --radius-sm:               10px;
  --shadow-card:             0 4px 32px rgba(0,0,0,.5);
  --tr:                      0.25s cubic-bezier(.4,0,.2,1);
  --clr-nav-bg:              rgba(7,11,20,.85);
  --clr-grid:                rgba(255,255,255,.025);
  --clr-glow-opacity:        .18;
  --clr-stat-bg:             rgba(13,20,36,.8);
  --clr-mm-bg:               #0d1424;
}

/*  Light  */
[data-theme="light"] {
  --clr-bg:                  #f0f4f8;
  --clr-surface:             #e8eef5;
  --clr-card:                #ffffff;
  --clr-border:              rgba(0,0,0,0.08);
  --clr-primary:             #2563eb;
  --clr-primary-h:           #1d4ed8;
  --clr-accent:              #7c3aed;
  --clr-gold:                #d97706;
  --clr-text:                #0f172a;
  --clr-muted:               #475569;
  --clr-subtle:              #94a3b8;
  --shadow-card:             0 4px 24px rgba(0,0,0,.10);
  --clr-nav-bg:              rgba(240,244,248,.88);
  --clr-grid:                rgba(0,0,0,.04);
  --clr-glow-opacity:        .10;
  --clr-stat-bg:             rgba(255,255,255,.85);
  --clr-mm-bg:               #ffffff;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --clr-bg:#f0f4f8;--clr-surface:#e8eef5;--clr-card:#ffffff;
    --clr-border:rgba(0,0,0,0.08);--clr-primary:#2563eb;--clr-primary-h:#1d4ed8;
    --clr-accent:#7c3aed;--clr-gold:#d97706;--clr-text:#0f172a;
    --clr-muted:#475569;--clr-subtle:#94a3b8;--shadow-card:0 4px 24px rgba(0,0,0,.10);
    --clr-nav-bg:rgba(240,244,248,.88);--clr-grid:rgba(0,0,0,.04);
    --clr-glow-opacity:.10;--clr-stat-bg:rgba(255,255,255,.85);--clr-mm-bg:#ffffff;
  }
}

/*  Base  */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html  { scroll-behavior: smooth; }
body  { font-family: 'Inter', system-ui, sans-serif; background: var(--clr-bg); color: var(--clr-text); line-height: 1.65; overflow-x: hidden; }
a     { color: inherit; text-decoration: none; }

/*  Scrollbar  */
::-webkit-scrollbar       { width: 6px; }
::-webkit-scrollbar-track { background: var(--clr-bg); }
::-webkit-scrollbar-thumb { background: var(--clr-subtle); border-radius: 3px; }

/*  Theme transition  */
html.theme-transitioning,
html.theme-transitioning * { transition: background-color .3s ease, color .3s ease, border-color .3s ease, box-shadow .3s ease !important; }

/*  Utility helpers  */
.container    { max-width: 1140px; margin: 0 auto; padding: 0 1.5rem; }
.font-display { font-family: 'Playfair Display', serif; }

.grad-text {
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  padding-bottom: 0.15em; /* prevent descender clipping (g, y, p …) */
}
.grad-text-hero {
  background: linear-gradient(135deg, #fff 40%, var(--clr-muted));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  padding-bottom: 0.15em;
}
[data-theme="light"] .grad-text-hero {
  background: linear-gradient(135deg, #0f172a 40%, var(--clr-muted));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .grad-text-hero {
    background: linear-gradient(135deg, #0f172a 40%, var(--clr-muted));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  }
}

.section-label {
  display: inline-block;
  font-size: .72rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--clr-primary); margin-bottom: .75rem;
  padding: .25rem .75rem;
  border: 1px solid rgba(59,130,246,.25); border-radius: 50px;
  background: rgba(59,130,246,.06);
}
.section-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 700; margin-bottom: 2.5rem; color: var(--clr-text);
}

/*  Theme icon show/hide  */
.icon-sun  { display: none; }
.icon-moon { display: block; }
[data-theme="light"] .icon-sun  { display: block; }
[data-theme="light"] .icon-moon { display: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .icon-sun  { display: block; }
  :root:not([data-theme]) .icon-moon { display: none; }
}

/*  Animations  */
.fade-in { opacity: 0; transform: translateY(24px); transition: opacity .6s ease, transform .6s ease; }
.fade-in.visible { opacity: 1; transform: translateY(0); }

@keyframes pulse-border {
  0%,100% { box-shadow: 0 0 0 0 rgba(59,130,246,0); }
  50%      { box-shadow: 0 0 0 8px rgba(59,130,246,.12); }
}
.avatar-ring-animate { animation: pulse-border 3s ease-in-out infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/*  Nav scroll state  */
#nav.scrolled {
  background: var(--clr-nav-bg);
  backdrop-filter: blur(16px);
}

/* Nav active link */
[data-page].active { color: var(--clr-text) !important; font-weight: 600 !important; }
[data-page].active::after {
  content: ''; display: block; height: 2px; border-radius: 2px; margin-top: 2px;
  background: linear-gradient(90deg, var(--clr-primary), var(--clr-accent));
}

/*  Mobile menu  */
#mobileMenu {
  position: fixed; top: 0; right: -100%; width: min(320px,100%); height: 100vh;
  background: var(--clr-mm-bg); border-left: 1px solid var(--clr-border);
  z-index: 200; display: flex; flex-direction: column;
  padding: 5rem 2rem 2rem; gap: 1rem;
  transition: right .35s cubic-bezier(.4,0,.2,1);
}
#mobileMenu.open { right: 0; }

/* Click-outside overlay */
#mm-overlay {
  display: none; position: fixed; inset: 0; z-index: 199;
  background: rgba(0,0,0,.45); backdrop-filter: blur(2px);
}
#mm-overlay.open { display: block; }


/* Controls dock pinned to the bottom of the sidebar */
#mm-controls {
  margin-top: auto;
  padding-top: 1.25rem;
  border-top: 1px solid var(--clr-border);
}
.mm-controls-row {
  display: flex; align-items: center; gap: .75rem;
}

/* Signed-in user chip in the sidebar */
.mm-user { display: flex; align-items: center; gap: .6rem; flex: 1; overflow: hidden; }
.mm-user__avatar {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-accent));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .75rem; font-weight: 700;
  border: 2px solid var(--clr-primary);
}
.mm-user__info { display: flex; flex-direction: column; overflow: hidden; }
.mm-user__name { font-size: .78rem; font-weight: 700; color: var(--clr-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mm-user__signout {
  font-size: .68rem; color: var(--clr-muted); background: none; border: none;
  cursor: pointer; text-align: start; padding: 0; transition: color var(--tr);
}
.mm-user__signout:hover { color: #ef4444; }

/* Hide header controls on mobile — they live in the sidebar instead */
@media (max-width: 767px) {
  #langToggle, #themeToggle, #nav-auth-slot { display: none !important; }
}

/*  Buttons  */
.btn-primary {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: .9rem; font-weight: 600; letter-spacing: .01em;
  padding: .65rem 1.5rem; border-radius: 50px; border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--clr-primary), var(--clr-accent));
  color: #fff; box-shadow: 0 4px 20px rgba(59,130,246,.35);
  transition: var(--tr);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 28px rgba(59,130,246,.5); }
.btn-primary-lg   { padding: .85rem 2.2rem; font-size: 1rem; }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: .9rem; font-weight: 600; letter-spacing: .01em;
  padding: .65rem 1.5rem; border-radius: 50px; cursor: pointer;
  background: transparent; color: var(--clr-text); border: 1.5px solid var(--clr-border);
  transition: var(--tr);
}
.btn-ghost:hover { border-color: var(--clr-primary); color: var(--clr-primary); background: rgba(59,130,246,.07); }
.btn-ghost-sm    { font-size: .82rem; padding: .45rem 1rem; }

.btn-icon {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 10px;
  border: 1.5px solid var(--clr-border); background: transparent;
  color: var(--clr-muted); cursor: pointer; transition: var(--tr); flex-shrink: 0;
}
.btn-icon:hover { border-color: var(--clr-primary); color: var(--clr-primary); background: rgba(59,130,246,.08); }
.btn-icon-lang  { font-size: .78rem; font-weight: 800; font-family: 'Cairo','Inter',system-ui,sans-serif; letter-spacing: .02em; line-height: 1; }

/*  Hero decorative  */
.hero-bg-grid {
  position: absolute; inset: 0;
  background-image: linear-gradient(var(--clr-grid) 1px, transparent 1px),
                    linear-gradient(90deg, var(--clr-grid) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 80% at 50% 50%, #000 30%, transparent 100%);
}
.hero-glow {
  position: absolute; border-radius: 50%; filter: blur(90px);
  opacity: var(--clr-glow-opacity); pointer-events: none;
}
.hero-glow--1 { width: 600px; height: 600px; background: var(--clr-primary); top: -150px; left: -100px; }
.hero-glow--2 { width: 500px; height: 500px; background: var(--clr-accent); bottom: 0; right: -100px; }
.hero-glow--3 { width: 700px; height: 400px; background: var(--clr-accent); top: 50%; left: 50%; transform: translate(-50%,-50%); opacity: .1; }
.hero-glow--4 { width: 800px; height: 400px; background: var(--clr-primary); top: 50%; left: 50%; transform: translate(-50%,-50%); opacity: .12; }

/* 
   JS-RENDERED COMPONENT STYLES
   (cannot use Tailwind  live in JS template literals)
 */

/* Stats bar */
.stats-bar-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px,1fr));
  gap: 1px; background: var(--clr-border);
  border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--clr-border); backdrop-filter: blur(10px);
}
@media (max-width: 640px) { .stats-bar-grid { grid-template-columns: repeat(2,1fr); } }
.stat { background: var(--clr-stat-bg); padding: 1.5rem 1.25rem; text-align: center; transition: background var(--tr); }
.stat:hover { background: rgba(59,130,246,.07); }
.stat__value { font-size: 2rem; font-weight: 800; line-height: 1.1; }
.stat__label { font-size: .75rem; color: var(--clr-muted); font-weight: 500; margin-top: .25rem; letter-spacing: .02em; }

/* Social icons */
.social-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 10px;
  border: 1.5px solid var(--clr-border); color: var(--clr-muted); transition: var(--tr);
}
.social-icon:hover { border-color: var(--clr-primary); color: var(--clr-primary); background: rgba(59,130,246,.08); transform: translateY(-2px); }

/* Contact grid */
.contact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 1rem; }
.contact-item { display: flex; align-items: center; gap: .75rem; padding: .9rem 1.1rem; background: var(--clr-card); border: 1px solid var(--clr-border); border-radius: var(--radius-sm); font-size: .875rem; transition: var(--tr); }
.contact-item:hover { border-color: var(--clr-primary); background: rgba(59,130,246,.06); }
.contact-item__icon  { font-size: 1.1rem; flex-shrink: 0; }
.contact-item__info  { overflow: hidden; }
.contact-item__label { font-size: .7rem; color: var(--clr-subtle); font-weight: 500; text-transform: uppercase; letter-spacing: .06em; }
.contact-item__value { color: var(--clr-text); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Expertise grid */
.expertise-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 1rem; }
.expertise-item { background: var(--clr-card); border: 1px solid var(--clr-border); border-radius: var(--radius-sm); padding: 1rem 1.25rem; font-size: .9rem; font-weight: 500; color: var(--clr-text); display: flex; align-items: center; gap: .75rem; transition: var(--tr); cursor: default; }
.expertise-item::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: linear-gradient(135deg, var(--clr-primary), var(--clr-accent)); flex-shrink: 0; }
.expertise-item:hover { border-color: var(--clr-primary); background: rgba(59,130,246,.06); transform: translateX(4px); }

/* Timeline */
.timeline { position: relative; display: flex; flex-direction: column; }
.timeline::before { content: ''; position: absolute; left: 23px; top: 0; bottom: 0; width: 2px; background: linear-gradient(to bottom, var(--clr-primary), var(--clr-accent), transparent); }
.timeline-item { display: flex; gap: 2rem; padding: 0 0 2.5rem; position: relative; }
.timeline-item__dot { flex-shrink: 0; width: 48px; height: 48px; border-radius: 50%; background: var(--clr-card); border: 2px solid var(--clr-primary); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; z-index: 1; box-shadow: 0 0 0 4px var(--clr-surface); }
.timeline-item__body { flex: 1; background: var(--clr-card); border: 1px solid var(--clr-border); border-radius: var(--radius); padding: 1.4rem 1.6rem; transition: var(--tr); }
.timeline-item__body:hover { border-color: var(--clr-primary); box-shadow: 0 4px 24px rgba(59,130,246,.12); }
.timeline-item__period  { font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--clr-primary); margin-bottom: .4rem; }
.timeline-item__role    { font-size: 1.05rem; font-weight: 700; color: var(--clr-text); line-height: 1.2; }
.timeline-item__company { font-size: .85rem; color: var(--clr-muted); font-weight: 500; margin: .25rem 0 .75rem; }
.timeline-item__desc    { font-size: .88rem; color: var(--clr-muted); line-height: 1.7; }
@media (max-width: 640px) {
  .timeline::before { display: none; }
  .timeline-item { flex-direction: column; gap: .75rem; }
  .timeline-item__dot { display: none; }
}

/* Cert cards */
.certs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 1.25rem; }
.cert-card { background: var(--clr-card); border: 1px solid var(--clr-border); border-radius: var(--radius); padding: 1.6rem; transition: var(--tr); position: relative; overflow: hidden; }
.cert-card::after { content: ''; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(59,130,246,.05), rgba(139,92,246,.05)); opacity: 0; transition: opacity var(--tr); }
.cert-card:hover { border-color: var(--clr-primary); transform: translateY(-4px); box-shadow: var(--shadow-card); }
.cert-card:hover::after { opacity: 1; }
.cert-card__icon   { font-size: 2rem; margin-bottom: .75rem; }
.cert-card__title  { font-size: .95rem; font-weight: 700; color: var(--clr-text); line-height: 1.3; margin-bottom: .35rem; }
.cert-card__issuer { font-size: .8rem; color: var(--clr-muted); margin-bottom: .5rem; }
.cert-card__year   { display: inline-block; font-size: .72rem; font-weight: 700; color: var(--clr-gold); background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.2); padding: .2rem .65rem; border-radius: 50px; letter-spacing: .04em; }

/* Dash cards */
.dash-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 1.25rem; }
.dash-card { background: var(--clr-card); border: 1px solid var(--clr-border); border-radius: var(--radius); padding: 1.4rem 1.5rem; display: flex; align-items: flex-start; gap: 1rem; position: relative; overflow: hidden; transition: var(--tr); }
.dash-card::before { content: ''; position: absolute; top: 0; left: 0; width: 3px; height: 100%; border-radius: 3px 0 0 3px; }
.dash-card--blue::before  { background: var(--clr-primary); }
.dash-card--green::before { background: #22c55e; }
.dash-card--gold::before  { background: var(--clr-gold); }
.dash-card--red::before   { background: #ef4444; }
.dash-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-card); border-color: var(--clr-primary); }
.dash-card__icon  { font-size: 1.6rem; flex-shrink: 0; }
.dash-card__body  { flex: 1; }
.dash-card__value { font-size: 1.8rem; font-weight: 800; line-height: 1; margin-bottom: .2rem; }
.dash-card--blue  .dash-card__value { color: var(--clr-primary); }
.dash-card--green .dash-card__value { color: #22c55e; }
.dash-card--gold  .dash-card__value { color: var(--clr-gold); }
.dash-card--red   .dash-card__value { color: #ef4444; }
.dash-card__label { font-size: .85rem; font-weight: 600; color: var(--clr-text); }
.dash-card__sub   { font-size: .72rem; color: var(--clr-subtle); margin-top: .15rem; }
.dash-card__ring  { flex-shrink: 0; margin-left: auto; }

/* Sim options */
.sim-options { display: flex; flex-direction: column; gap: .6rem; }
.sim-option { display: flex; align-items: center; gap: .75rem; padding: .8rem 1rem; border-radius: var(--radius-sm); border: 1.5px solid var(--clr-border); cursor: pointer; transition: var(--tr); background: var(--clr-surface); }
.sim-option input[type="radio"] { display: none; }
.sim-option:hover    { border-color: var(--clr-primary); background: rgba(59,130,246,.04); }
.sim-option.selected { border-color: var(--clr-primary); background: rgba(59,130,246,.06); }
.sim-option__inner  { flex: 1; }
.sim-option__label  { font-size: .88rem; font-weight: 600; color: var(--clr-text); display: flex; align-items: center; gap: .5rem; }
.sim-option__meta   { font-size: .75rem; color: var(--clr-muted); }
.sim-option__badge  { font-size: .65rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; background: rgba(59,130,246,.12); color: var(--clr-primary); border: 1px solid rgba(59,130,246,.25); padding: .1rem .45rem; border-radius: 4px; }
.sim-option__check  { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--clr-border); display: flex; align-items: center; justify-content: center; color: transparent; transition: var(--tr); flex-shrink: 0; }
.sim-option.selected .sim-option__check { background: var(--clr-primary); border-color: var(--clr-primary); color: #fff; }

/* Exam rows */
.exam-row { display: flex; align-items: center; gap: .75rem; padding: .85rem 1.6rem; border-bottom: 1px solid var(--clr-border); transition: background var(--tr); }
.exam-row:last-child { border-bottom: none; }
.exam-row:hover { background: rgba(59,130,246,.04); }
.exam-row__num    { font-size: .75rem; font-weight: 700; color: var(--clr-subtle); width: 28px; flex-shrink: 0; }
.exam-row__info   { flex: 1; overflow: hidden; }
.exam-row__mode   { font-size: .85rem; font-weight: 600; color: var(--clr-text); }
.exam-row__date   { font-size: .72rem; color: var(--clr-muted); }
.exam-row__score  { font-size: 1rem; font-weight: 800; min-width: 44px; text-align: right; }
.exam-row__score--pass { color: #22c55e; }
.exam-row__score--fail { color: #ef4444; }
.exam-row__badge  { font-size: .65rem; font-weight: 800; letter-spacing: .08em; padding: .2rem .55rem; border-radius: 4px; flex-shrink: 0; }
.badge--pass { background: rgba(34,197,94,.12); color: #22c55e; border: 1px solid rgba(34,197,94,.25); }
.badge--fail { background: rgba(239,68,68,.10); color: #ef4444; border: 1px solid rgba(239,68,68,.2); }
.exam-row__review { color: var(--clr-subtle); display: flex; align-items: center; transition: color var(--tr); }
.exam-row__review:hover { color: var(--clr-primary); }

/* Exam row – mobile layout */
@media (max-width: 640px) {
  .exam-row {
    display: grid;
    grid-template-columns: 26px 1fr auto auto;
    grid-template-rows: auto auto;
    column-gap: .55rem;
    row-gap: .15rem;
    padding: .85rem 1rem;
    align-items: start;
  }
  .exam-row > .exam-row__num {
    grid-area: 1 / 1 / 3 / 2;
    align-self: center;
    width: auto;
  }
  .exam-row > .exam-row__info   { grid-area: 1 / 2 / 3 / 3; }
  .exam-row > .exam-row__mode   { margin-bottom: .15rem; }
  .exam-row > .exam-row__score  {
    grid-area: 1 / 3 / 2 / 4;
    align-self: start;
    min-width: unset;
    font-size: .95rem;
    text-align: center;
  }
  .exam-row > .exam-row__badge  {
    grid-area: 2 / 3 / 3 / 4;
    align-self: center;
    text-align: center;
    font-size: .6rem;
    padding: .18rem .5rem;
  }
  .exam-row > .exam-row__review {
    grid-area: 1 / 4 / 3 / 5;
    align-self: center;
    justify-self: center;
  }
  [dir="rtl"] .exam-row { flex-direction: unset; }
}

/* Score chart */
.score-chart { position: relative; display: flex; align-items: flex-end; gap: .6rem; height: 160px; padding: 0 0 .5rem; border-bottom: 2px solid var(--clr-border); }
.chart-bar-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: .3rem; position: relative; }
.chart-bar { width: 100%; min-height: 4px; border-radius: 4px 4px 0 0; transition: height .6s cubic-bezier(.4,0,.2,1); }
.chart-bar--pass { background: linear-gradient(to top, #16a34a, #4ade80); }
.chart-bar--fail { background: linear-gradient(to top, #b91c1c, #f87171); }
.chart-bar__label { font-size: .62rem; font-weight: 700; color: var(--clr-muted); position: absolute; top: 0; }
.chart-bar__x     { font-size: .6rem; color: var(--clr-subtle); white-space: nowrap; margin-top: .3rem; }
.chart-avg-line   { position: absolute; left: 0; right: 0; height: 2px; background: var(--clr-gold); opacity: .7; border-radius: 2px; pointer-events: none; }
.chart-avg-line::after { content: 'avg'; position: absolute; right: 0; top: -14px; font-size: .6rem; color: var(--clr-gold); font-weight: 700; }

/* ═══════════════════════════════════════════════════════
   SKELETON LOADING
═══════════════════════════════════════════════════════ */
@keyframes skel-shimmer {
  0%   { background-position: 200% center; }
  100% { background-position: -200% center; }
}
.skel {
  display: block;
  background: linear-gradient(
    90deg,
    var(--clr-border)  25%,
    var(--clr-surface) 50%,
    var(--clr-border)  75%
  );
  background-size: 200% 100%;
  animation: skel-shimmer 1.6s ease-in-out infinite;
  border-radius: 6px;
  pointer-events: none;
  user-select: none;
  flex-shrink: 0;
}

/* 
   ARABIC / RTL
 */
[dir="rtl"] body,
[dir="rtl"] h1,[dir="rtl"] h2,[dir="rtl"] h3,
[dir="rtl"] h4,[dir="rtl"] h5,[dir="rtl"] h6,
[dir="rtl"] .section-title,
[dir="rtl"] .section-label,
[dir="rtl"] .btn-primary,
[dir="rtl"] .btn-ghost {
  font-family: 'Cairo', 'Inter', system-ui, sans-serif;
}

[dir="rtl"] #mobileMenu {
  right: auto; left: -100%;
  border-left: none; border-right: 1px solid var(--clr-border);
  transition: left .35s cubic-bezier(.4,0,.2,1);
}
[dir="rtl"] #mobileMenu.open { left: 0; }
[dir="rtl"] .mm-controls-row { flex-direction: row-reverse; }
[dir="rtl"] .mm-user          { flex-direction: row-reverse; }
[dir="rtl"] .mm-user__info    { align-items: flex-end; }

[dir="rtl"] .timeline::before  { right: 23px; left: auto; }
[dir="rtl"] .timeline-item     { flex-direction: row-reverse; }
[dir="rtl"] .timeline-item__body { text-align: right; }

[dir="rtl"] .contact-item { flex-direction: row-reverse; text-align: right; }
[dir="rtl"] .expertise-item:hover { transform: translateX(-4px); }
[dir="rtl"] .cert-card     { text-align: right; }
[dir="rtl"] .dash-card     { text-align: right; }
[dir="rtl"] .dash-card::before { left: auto; right: 0; border-radius: 0 3px 3px 0; }
[dir="rtl"] .dash-card__ring   { margin-left: 0; margin-right: auto; }
[dir="rtl"] .sim-option        { flex-direction: row-reverse; }
[dir="rtl"] .exam-row          { flex-direction: row-reverse; }
[dir="rtl"] .exam-row__score   { text-align: left; }
[dir="rtl"] .score-chart       { direction: ltr; }

/* ═══════════════════════════════════════════════════════
   HISTORY PAGE
═══════════════════════════════════════════════════════ */

/* Filter pills */
.hist-filter {
  font-size: .75rem; font-weight: 600; padding: .35rem .9rem;
  border-radius: 99px; border: 1px solid var(--clr-border);
  color: var(--clr-muted); background: transparent;
  cursor: pointer; transition: var(--tr);
}
.hist-filter:hover { border-color: var(--clr-primary); color: var(--clr-primary); }
.hist-filter--active {
  background: var(--clr-primary); border-color: var(--clr-primary);
  color: #fff;
}

/* History rows */
.hist-row { border-bottom: 1px solid var(--clr-border); transition: background var(--tr); }
.hist-row:last-child { border-bottom: none; }
.hist-row:hover { background: rgba(59,130,246,.03); }

.hist-row__summary {
  display: flex; align-items: center; gap: .75rem;
  padding: .9rem 1.5rem;
  flex-wrap: wrap;
}

/* Correct / wrong / skipped chips */
.hist-row__chips { display: flex; gap: .35rem; flex-shrink: 0; }
.hist-chip {
  font-size: .65rem; font-weight: 700; padding: .18rem .5rem;
  border-radius: 4px; letter-spacing: .04em;
}
.hist-chip--correct { background: rgba(34,197,94,.12);  color: #22c55e; border: 1px solid rgba(34,197,94,.25); }
.hist-chip--wrong   { background: rgba(239,68,68,.10);  color: #ef4444; border: 1px solid rgba(239,68,68,.2); }
.hist-chip--skip    { background: rgba(148,163,184,.1); color: var(--clr-subtle); border: 1px solid var(--clr-border); }

/* Domain expand toggle */
.hist-row__toggle {
  color: var(--clr-subtle); display: flex; align-items: center;
  transition: color var(--tr), transform var(--tr); flex-shrink: 0;
  background: none; border: none; cursor: pointer; padding: 2px;
}
.hist-row__toggle:hover { color: var(--clr-primary); }
.hist-row__toggle--open { transform: rotate(180deg); color: var(--clr-primary); }

/* Domain breakdown panel */
.hist-row__domains { padding: 0 1.5rem 1rem 2.75rem; }
.hist-domains-inner { display: flex; flex-direction: column; gap: .6rem; }
.hist-domain-row { display: flex; align-items: center; gap: .75rem; }
.hist-domain-name {
  font-size: .72rem; font-weight: 600; color: var(--clr-muted);
  width: 160px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hist-domain-bar-bg {
  flex: 1; height: 6px; background: var(--clr-border); border-radius: 99px; overflow: hidden;
}
.hist-domain-bar-fill { height: 100%; border-radius: 99px; transition: width .6s cubic-bezier(.4,0,.2,1); }
.hist-domain-pct { font-size: .72rem; font-weight: 700; width: 36px; text-align: right; flex-shrink: 0; }

/* Toast notification */
.hist-toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%) translateY(24px);
  background: var(--clr-card); border: 1px solid var(--clr-border);
  color: var(--clr-text); font-size: .85rem; font-weight: 600;
  padding: .75rem 1.5rem; border-radius: 99px;
  box-shadow: var(--shadow-card); z-index: 9999;
  opacity: 0; transition: opacity .3s ease, transform .3s ease;
  white-space: nowrap;
}
.hist-toast--success { border-color: rgba(34,197,94,.4); color: #22c55e; }
.hist-toast--error   { border-color: rgba(239,68,68,.4);  color: #ef4444; }
.hist-toast--show    { opacity: 1; transform: translateX(-50%) translateY(0); }

/* RTL */
[dir="rtl"] .hist-row__summary { flex-direction: row-reverse; }
[dir="rtl"] .hist-row__domains { padding: 0 2.75rem 1rem 1.5rem; }
[dir="rtl"] .hist-domain-row   { flex-direction: row-reverse; }
[dir="rtl"] .hist-domain-pct   { text-align: left; }

/* ═══════════════════════════════════════
   History row – mobile layout (≤ 640 px)
   Switches from flex-wrap to CSS grid so
   every element has a defined grid area.
═══════════════════════════════════════ */
@media (max-width: 640px) {
  .hist-row__summary {
    display: grid;
    grid-template-columns: 26px 1fr auto auto;
    grid-template-rows: auto auto auto;
    column-gap: .55rem;
    row-gap: 0;
    padding: .9rem 1rem 1rem;
    align-items: start;
  }

  /* #N – left spine, vertically centred across all 3 rows */
  .hist-row__summary > .exam-row__num {
    grid-area: 1 / 1 / 4 / 2;
    align-self: center;
    font-size: .72rem;
    font-weight: 700;
    color: var(--clr-subtle);
  }

  /* Mode label + date block – rows 1–2, col 2 */
  .hist-row__summary > .exam-row__info {
    grid-area: 1 / 2 / 3 / 3;
    min-width: 0;
    padding-top: .05rem;
    padding-bottom: .05rem;
  }
  .hist-row__summary > .exam-row__info .exam-row__mode {
    font-size: .88rem;
    line-height: 1.25;
    margin-bottom: .2rem;
  }
  .hist-row__summary > .exam-row__info .exam-row__date {
    font-size: .7rem;
    line-height: 1.35;
    white-space: normal;        /* allow date to wrap on very narrow screens */
  }

  /* Score % – row 1, col 3 */
  .hist-row__summary > .exam-row__score {
    grid-area: 1 / 3 / 2 / 4;
    align-self: start;
    min-width: unset;
    font-size: 1rem;
    text-align: center;
    padding-top: .05rem;
  }

  /* Pass / fail badge – row 2, col 3 */
  .hist-row__summary > .exam-row__badge {
    grid-area: 2 / 3 / 3 / 4;
    align-self: center;
    text-align: center;
    font-size: .6rem;
    padding: .18rem .5rem;
  }

  /* Chips – row 3, cols 2–3 */
  .hist-row__summary > .hist-row__chips {
    grid-area: 3 / 2 / 4 / 4;
    justify-content: flex-start;
    margin-top: .45rem;
    gap: .3rem;
  }
  .hist-row__summary > .hist-row__chips .hist-chip {
    font-size: .64rem;
    padding: .2rem .5rem;
  }

  /* Expand chevron (or spacer) – col 4, all rows */
  .hist-row__summary > .hist-row__toggle,
  .hist-row__summary > span:last-child {
    grid-area: 1 / 4 / 4 / 5;
    align-self: center;
    justify-self: center;
  }

  /* Domain breakdown: indent to align with grid col 2 */
  .hist-row__domains {
    padding: 0 1rem .9rem calc(26px + .55rem + 1rem);
  }
  .hist-domain-name { width: 120px; font-size: .68rem; }

  /* RTL: grid col order is auto-mirrored by the row's dir; cancel the flex override */
  [dir="rtl"] .hist-row__summary { flex-direction: unset; }
  [dir="rtl"] .hist-row__domains {
    padding: 0 calc(26px + .55rem + 1rem) .9rem 1rem;
  }
  [dir="rtl"] .hist-row__summary > .hist-row__chips {
    justify-content: flex-end;
  }
}
