/* ================================================================
   Tawjihi Platform — Refinement Layer v5 "منصّة كاملة"
   Stage-20 redesign (2026-07-14).

   Goal: make the platform read as a strong, comprehensive reference —
   "لا ينقص الطالب أي كراسة". Refines the existing v3.premium look
   (does NOT replace it): disciplined subject palette, richer content
   numbers, new comprehensiveness sections, and finish states.

   Loads LAST, after premium-v3.css. Scope: .theme-v3.premium
   ================================================================ */


/* ---------- 0) Refined per-subject palette ----------
   Keep per-subject identity for wayfinding, but deepen + slightly
   desaturate so the grid reads as one coordinated system, not candy. */
.theme-v3.premium [data-subject="math_elmi"],
.theme-v3.premium [data-subject="math_adabi"]        { --s-solid:#4C50A6; --s-grad:linear-gradient(135deg,#5457B4,#3C3F8C); --s-soft:#EDEDF9; --s-shadow:rgba(76,80,166,.28); }
.theme-v3.premium [data-subject="physics"]           { --s-solid:#2B6CB0; --s-grad:linear-gradient(135deg,#3178BE,#215690); --s-soft:#E9F1FA; --s-shadow:rgba(43,108,176,.26); }
.theme-v3.premium [data-subject="chemistry"]         { --s-solid:#0E7C7B; --s-grad:linear-gradient(135deg,#149391,#0B615F); --s-soft:#E5F4F3; --s-shadow:rgba(14,124,123,.26); }
.theme-v3.premium [data-subject="biology"]           { --s-solid:#2F855A; --s-grad:linear-gradient(135deg,#369766,#256A47); --s-soft:#E8F3ED; --s-shadow:rgba(47,133,90,.26); }
.theme-v3.premium [data-subject="arabic_motalaa_elmi"],
.theme-v3.premium [data-subject="arabic_motalaa_adabi"],
.theme-v3.premium [data-subject="arabic_adab"]       { --s-solid:#A02B26; --s-grad:linear-gradient(135deg,#B4322C,#82231F); --s-soft:#F6E7E6; --s-shadow:rgba(160,43,38,.24); }
.theme-v3.premium [data-subject="islamic_elmi"],
.theme-v3.premium [data-subject="islamic_adabi"]     { --s-solid:#6B46C1; --s-grad:linear-gradient(135deg,#7A54D0,#573AA0); --s-soft:#EFEAFA; --s-shadow:rgba(107,70,193,.24); }
.theme-v3.premium [data-subject="english_pupils_elmi"],
.theme-v3.premium [data-subject="english_pupils_adabi"],
.theme-v3.premium [data-subject="english_reading_plus"]{ --s-solid:#B45309; --s-grad:linear-gradient(135deg,#C4610F,#8F4107); --s-soft:#F8EEE1; --s-shadow:rgba(180,83,9,.24); }
.theme-v3.premium [data-subject="it_elmi"],
.theme-v3.premium [data-subject="it_adabi"]          { --s-solid:#B83280; --s-grad:linear-gradient(135deg,#C93C8E,#932865); --s-soft:#F8E8F1; --s-shadow:rgba(184,50,128,.24); }
.theme-v3.premium [data-subject="history"]           { --s-solid:#C05621; --s-grad:linear-gradient(135deg,#D06128,#98431A); --s-soft:#F8EBE1; --s-shadow:rgba(192,86,33,.24); }
.theme-v3.premium [data-subject="geography"]         { --s-solid:#5F8A2E; --s-grad:linear-gradient(135deg,#6E9C38,#4C7023); --s-soft:#EFF4E7; --s-shadow:rgba(95,138,46,.24); }
.theme-v3.premium [data-subject="thaqafa"]           { --s-solid:#0C6E9E; --s-grad:linear-gradient(135deg,#1180B4,#0A567B); --s-soft:#E4F1F8; --s-shadow:rgba(12,110,158,.24); }


/* ---------- 1) Hero trust row ---------- */
.theme-v3.premium .hero-trust {
  display: flex; align-items: center; flex-wrap: wrap;
  gap: .5rem 1.4rem;
  margin-top: 1.6rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--v3-line);
}
.theme-v3.premium .hero-trust .ht-item {
  display: inline-flex; align-items: center; gap: .5rem;
  font-family: 'Tajawal', system-ui, sans-serif;
  font-weight: 600; font-size: .85rem;
  color: var(--v3-ink-2);
}
.theme-v3.premium .hero-trust .ht-item svg { width: 17px; height: 17px; color: var(--v3-brand-1); flex: none; }
.theme-v3.premium .hero-trust .ht-item.is-gold svg { color: var(--v3-gold); }
.theme-v3.premium .hero-trust .ht-item.is-red svg  { color: var(--v3-red); }


/* ---------- 2) Content-scale band — numbers are heroes ---------- */
.theme-v3.premium .scale-band {
  margin: 2rem 0 1rem;
  padding: 1.8rem 1.6rem;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(76,80,166,.05), transparent 60%),
    var(--v3-surface);
  border: 1px solid var(--v3-line);
  border-radius: 20px;
  box-shadow: 0 1px 2px rgba(14,18,25,.03), 0 10px 30px rgba(14,18,25,.04);
}
.theme-v3.premium .scale-head {
  display: flex; align-items: baseline; gap: .6rem; flex-wrap: wrap;
  margin-bottom: 1.4rem;
}
.theme-v3.premium .scale-head .sh-k {
  font-family: 'Tajawal', system-ui, sans-serif;
  font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em;
  color: var(--v3-ink-1);
}
.theme-v3.premium .scale-head .sh-d {
  font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  font-size: .9rem; color: var(--v3-ink-3);
}
.theme-v3.premium .scale-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 1rem;
}
.theme-v3.premium .scale-cell {
  text-align: center;
  padding: .5rem .3rem;
  border-radius: 14px;
  transition: background .15s;
}
.theme-v3.premium .scale-cell:hover { background: var(--v3-surface-2); }
.theme-v3.premium .scale-n {
  font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  font-weight: 800;
  font-size: clamp(1.8rem, 3vw, 2.5rem);
  line-height: 1;
  letter-spacing: -.03em;
  color: var(--v3-brand-ink);
  font-variant-numeric: lining-nums tabular-nums;
}
.theme-v3.premium .scale-n .plus { color: var(--v3-gold); }
.theme-v3.premium .scale-l {
  font-family: 'Tajawal', system-ui, sans-serif;
  font-weight: 600; font-size: .78rem;
  color: var(--v3-ink-3);
  margin-top: .45rem; line-height: 1.35;
}
@media (max-width: 900px) { .theme-v3.premium .scale-grid { grid-template-columns: repeat(3, 1fr); gap: 1rem .6rem; } }
@media (max-width: 420px) { .theme-v3.premium .scale-grid { grid-template-columns: repeat(2, 1fr); } }


/* section rhythm for new blocks */
.theme-v3.premium .study-path-section,
.theme-v3.premium .materials-highlight { margin-top: 1rem; }


/* ---------- 3) Study path — the integrated journey ---------- */
.theme-v3.premium .path-wrap {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: .9rem;
  counter-reset: step;
}
.theme-v3.premium .path-wrap::before {
  content: ""; position: absolute; top: 30px; right: 4%; left: 4%;
  height: 2px;
  background: repeating-linear-gradient(90deg, var(--v3-line-2, #D6D2C4) 0 8px, transparent 8px 16px);
  z-index: 0;
}
.theme-v3.premium .path-step {
  position: relative; z-index: 1;
  text-align: center;
  text-decoration: none; color: inherit;
}
.theme-v3.premium .path-ic {
  width: 60px; height: 60px; margin: 0 auto .8rem;
  border-radius: 16px;
  display: grid; place-items: center;
  background: var(--v3-surface);
  border: 1px solid var(--v3-line);
  color: var(--v3-brand-1);
  box-shadow: 0 4px 14px rgba(14,18,25,.06);
  transition: transform .18s, box-shadow .18s, border-color .18s, background .18s, color .18s;
  position: relative;
}
.theme-v3.premium .path-ic::after {
  counter-increment: step; content: counter(step, arabic-indic);
  position: absolute; top: -8px; right: -8px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--v3-brand-ink); color: #fff;
  font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  font-size: .72rem; font-weight: 700;
  display: grid; place-items: center;
  border: 2px solid var(--v3-bg);
}
.theme-v3.premium .path-step:hover .path-ic {
  transform: translateY(-4px);
  background: var(--v3-brand-1); color: #fff;
  border-color: var(--v3-brand-1);
  box-shadow: 0 12px 24px rgba(76,80,166,.30);
}
.theme-v3.premium .path-ic svg { width: 26px; height: 26px; }
.theme-v3.premium .path-t {
  font-family: 'Tajawal', system-ui, sans-serif;
  font-weight: 700; font-size: .92rem; letter-spacing: -.01em;
  color: var(--v3-ink-1);
}
.theme-v3.premium .path-s {
  font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  font-size: .76rem; color: var(--v3-ink-3); margin-top: .2rem; line-height: 1.4;
}
@media (max-width: 820px) {
  .theme-v3.premium .path-wrap { grid-template-columns: repeat(3, 1fr); gap: 1.6rem .6rem; }
  .theme-v3.premium .path-wrap::before { display: none; }
}
@media (max-width: 380px) { .theme-v3.premium .path-wrap { grid-template-columns: repeat(2, 1fr); } }


/* ---------- 4) Materials highlight — الملازم والكراسات ---------- */
.theme-v3.premium .mat-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.1rem;
}
@media (max-width: 820px) { .theme-v3.premium .mat-grid { grid-template-columns: 1fr; } }
.theme-v3.premium .mat-card {
  display: flex; gap: 1.1rem; align-items: flex-start;
  padding: 1.5rem;
  background: var(--v3-surface);
  border: 1px solid var(--v3-line);
  border-radius: 18px;
  text-decoration: none; color: inherit;
  box-shadow: 0 1px 2px rgba(14,18,25,.02);
  transition: transform .18s, box-shadow .18s, border-color .18s;
  position: relative; overflow: hidden;
}
.theme-v3.premium .mat-card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 4px;
  background: var(--mat-c, var(--v3-brand-1)); opacity: .0; transition: opacity .18s;
}
.theme-v3.premium .mat-card:hover {
  transform: translateY(-3px);
  border-color: var(--mat-c, var(--v3-brand-1));
  box-shadow: 0 18px 36px rgba(14,18,25,.09), 0 4px 10px rgba(14,18,25,.05);
}
.theme-v3.premium .mat-card:hover::before { opacity: 1; }
.theme-v3.premium .mat-ic {
  flex: none; width: 50px; height: 50px; border-radius: 13px;
  display: grid; place-items: center; color: #fff;
  background: var(--mat-c, var(--v3-brand-1));
  box-shadow: 0 6px 16px color-mix(in srgb, var(--mat-c, var(--v3-brand-1)) 32%, transparent), inset 0 1px 0 rgba(255,255,255,.18);
}
.theme-v3.premium .mat-ic svg { width: 24px; height: 24px; }
.theme-v3.premium .mat-b {
  font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  font-weight: 800; font-size: 1.5rem; line-height: 1;
  color: var(--v3-ink-1); font-variant-numeric: lining-nums tabular-nums;
  letter-spacing: -.02em;
}
.theme-v3.premium .mat-b span { font-size: .8rem; font-weight: 600; color: var(--v3-ink-3); margin-right: .3rem; }
.theme-v3.premium .mat-t {
  font-family: 'Tajawal', system-ui, sans-serif;
  font-weight: 700; font-size: 1.02rem; margin: .3rem 0 .2rem; letter-spacing: -.01em;
  color: var(--v3-ink-1);
}
.theme-v3.premium .mat-d {
  font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  font-size: .84rem; color: var(--v3-ink-3); line-height: 1.6;
}


/* ---------- 5) Credibility strip ---------- */
.theme-v3.premium .cred-strip {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin: 1rem 0 0;
  padding: 1.3rem 1.5rem;
  border: 1px dashed var(--v3-line-2, #D6D2C4);
  border-radius: 18px;
  background: var(--v3-surface-2);
}
@media (max-width: 720px) { .theme-v3.premium .cred-strip { grid-template-columns: repeat(2, 1fr); gap: 1.2rem; } }
.theme-v3.premium .cred-item {
  display: flex; align-items: center; gap: .7rem;
  font-family: 'Tajawal', system-ui, sans-serif;
}
.theme-v3.premium .cred-item svg { width: 22px; height: 22px; flex: none; color: var(--v3-brand-1); }
.theme-v3.premium .cred-item .ci-k { font-weight: 700; font-size: .92rem; color: var(--v3-ink-1); line-height: 1.2; }
.theme-v3.premium .cred-item .ci-d { font-size: .76rem; color: var(--v3-ink-3); }


/* ---------- 6) Section head — optional numeral marker ---------- */
.theme-v3.premium .section-head-v3 .sh-index {
  font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  font-weight: 800; font-size: .85rem; color: var(--v3-gold);
  letter-spacing: .12em; display: block; margin-bottom: .3rem;
  font-variant-numeric: lining-nums;
}


/* ---------- 7) Subject card — meta chips + finish polish ---------- */
.theme-v3.premium .subj-card-v3 .meta-v3 {
  display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .1rem;
}
.theme-v3.premium .subj-card-v3 .meta-v3 span {
  display: inline-flex; align-items: center; gap: .25rem;
  background: var(--v3-surface-2);
  border: 1px solid var(--v3-line);
  border-radius: 7px;
  padding: .18rem .5rem;
  font-size: .76rem;
}
.theme-v3.premium .subj-card-v3::after {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--s-grad); opacity: 0; transition: opacity .18s;
}
.theme-v3.premium .subj-card-v3:hover::after { opacity: 1; }


/* ---------- 8) Skeleton loaders (before JS injects content) ---------- */
.theme-v3.premium .sk {
  background: linear-gradient(100deg, var(--v3-surface-2) 30%, var(--v3-line-soft) 50%, var(--v3-surface-2) 70%);
  background-size: 200% 100%;
  animation: sk-shine 1.3s ease-in-out infinite;
  border-radius: 12px;
}
@keyframes sk-shine { to { background-position: -200% 0; } }
.theme-v3.premium .sk-card { height: 168px; border-radius: 16px; }
.theme-v3.premium .sk-book { aspect-ratio: 3/4; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { .theme-v3.premium .sk { animation: none; } }


/* ---------- 9) Small shared finish ---------- */
.theme-v3.premium .num-hero,
.theme-v3.premium .scale-n,
.theme-v3.premium .mat-b,
.theme-v3.premium .cd-big,
.theme-v3.premium .streak-big-v3 { font-variant-numeric: lining-nums tabular-nums; }

/* Buttons — consistent active press */
.theme-v3.premium .btn-v3:active,
.theme-v3.premium .hero-cta:active,
.theme-v3.premium .sh-link-v3:active { transform: translateY(1px); }

/* Footer richer (links row) */
.theme-v3.premium .footer-links {
  display: flex; flex-wrap: wrap; gap: .3rem 1.4rem;
  margin-top: .8rem;
  font-family: 'Tajawal', system-ui, sans-serif; font-size: .86rem;
}
.theme-v3.premium .footer-links a { color: var(--v3-ink-2); font-weight: 600; }
.theme-v3.premium .footer-links a:hover { color: var(--v3-brand-ink); }


/* ---------- 10) Reveal-on-scroll for new sections ---------- */
@keyframes rise-v5 { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.theme-v3.premium .scale-band,
.theme-v3.premium .path-wrap,
.theme-v3.premium .mat-card,
.theme-v3.premium .cred-strip { animation: rise-v5 .55s ease-out both; }
.theme-v3.premium .mat-card:nth-child(2) { animation-delay: .07s; }
.theme-v3.premium .mat-card:nth-child(3) { animation-delay: .14s; }
@media (prefers-reduced-motion: reduce) {
  .theme-v3.premium .scale-band,
  .theme-v3.premium .path-wrap,
  .theme-v3.premium .mat-card,
  .theme-v3.premium .cred-strip { animation: none; }
}


/* ---------- 11b) Premium eyebrow (all inner pages) ---------- */
.theme-v3.premium .section-eyebrow {
  font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  font-weight: 700; font-size: .78rem;
  color: var(--v3-gold);
  letter-spacing: .14em; text-transform: none;
  margin-bottom: .4rem;
}

/* Reusable page trust line under a page header */
.theme-v3.premium .page-trust {
  display: flex; flex-wrap: wrap; gap: .5rem 1.3rem;
  margin-top: 1rem;
}
.theme-v3.premium .page-trust .pt-item {
  display: inline-flex; align-items: center; gap: .45rem;
  font-family: 'Tajawal', system-ui, sans-serif;
  font-weight: 600; font-size: .82rem; color: var(--v3-ink-2);
}
.theme-v3.premium .page-trust .pt-item svg { width: 16px; height: 16px; color: var(--v3-brand-1); flex: none; }
.theme-v3.premium .page-trust .pt-item.is-gold svg { color: var(--v3-gold); }


/* ================================================================
   Stage-21 — Auth nav (login button + account menu) + depth elevation
   ================================================================ */

/* Login button — clear primary CTA in the nav */
.theme-v3.premium .nav-auth-slot { display: inline-flex; align-items: center; }
.theme-v3.premium .nav-auth-btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .55rem 1.05rem;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--v3-brand-1), var(--v3-brand-2));
  color: #fff;
  font-family: 'Tajawal', system-ui, sans-serif;
  font-weight: 700; font-size: .9rem;
  text-decoration: none;
  border: 0;
  box-shadow: 0 6px 16px rgba(76,80,166,.30), inset 0 1px 0 rgba(255,255,255,.16);
  transition: transform .15s, box-shadow .15s, filter .15s;
  white-space: nowrap;
}
.theme-v3.premium .nav-auth-btn svg { width: 17px; height: 17px; }
.theme-v3.premium .nav-auth-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(76,80,166,.40), inset 0 1px 0 rgba(255,255,255,.16); }
.theme-v3.premium .nav-auth-btn:active { transform: translateY(0); }

/* Account chip + dropdown */
.theme-v3.premium .nav-account { position: relative; }
.theme-v3.premium .nav-account-btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .35rem .6rem .35rem .4rem;
  border-radius: 999px;
  background: var(--v3-surface);
  border: 1px solid var(--v3-line);
  cursor: pointer; font-family: 'Tajawal', system-ui, sans-serif;
  color: var(--v3-ink-1); font-weight: 700; font-size: .88rem;
  transition: border-color .15s, box-shadow .15s;
}
.theme-v3.premium .nav-account-btn:hover { border-color: var(--v3-brand-1); box-shadow: 0 4px 12px rgba(76,80,166,.14); }
.theme-v3.premium .nav-account-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  object-fit: cover; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--v3-brand-1), var(--v3-brand-2));
  color: #fff; font-weight: 800; font-size: .95rem; flex: none;
}
.theme-v3.premium .nav-account-name { max-width: 9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.theme-v3.premium .nav-account-caret { color: var(--v3-ink-3); }
.theme-v3.premium .nav-account-menu {
  position: absolute; top: calc(100% + .5rem); left: 0;
  min-width: 220px;
  background: var(--v3-surface);
  border: 1px solid var(--v3-line);
  border-radius: 14px;
  box-shadow: 0 18px 44px rgba(14,18,25,.16), 0 4px 12px rgba(14,18,25,.08);
  padding: .4rem;
  z-index: 60;
  animation: rise-v5 .16s ease-out both;
}
.theme-v3.premium .nav-account-menu .nam-head {
  display: flex; flex-direction: column; gap: .1rem;
  padding: .6rem .7rem .7rem; margin-bottom: .3rem;
  border-bottom: 1px solid var(--v3-line);
}
.theme-v3.premium .nam-head .nam-name { font-family: 'Tajawal', system-ui, sans-serif; font-weight: 800; color: var(--v3-ink-1); font-size: .95rem; }
.theme-v3.premium .nam-head .nam-role {
  font-size: .72rem; font-weight: 700; color: var(--v3-gold);
  letter-spacing: .08em;
}
.theme-v3.premium .nav-account-menu a,
.theme-v3.premium .nav-account-menu button {
  display: flex; align-items: center; gap: .6rem; width: 100%;
  padding: .6rem .7rem; border-radius: 9px;
  font-family: 'Tajawal', system-ui, sans-serif; font-weight: 600; font-size: .9rem;
  color: var(--v3-ink-2); text-decoration: none;
  background: transparent; border: 0; cursor: pointer; text-align: start;
  transition: background .12s, color .12s;
}
.theme-v3.premium .nav-account-menu a svg,
.theme-v3.premium .nav-account-menu button svg { width: 18px; height: 18px; color: var(--v3-ink-3); }
.theme-v3.premium .nav-account-menu a:hover { background: var(--v3-brand-soft); color: var(--v3-brand-ink); }
.theme-v3.premium .nav-account-menu a:hover svg { color: var(--v3-brand-1); }
.theme-v3.premium .nav-account-menu #navSignOut:hover { background: var(--v3-red-soft, #F3E1DF); color: var(--v3-red); }
.theme-v3.premium .nav-account-menu #navSignOut:hover svg { color: var(--v3-red); }

@media (max-width: 560px) {
  .theme-v3.premium .nav-account-name { display: none; }
  .theme-v3.premium .nav-auth-btn span { display: none; }
  .theme-v3.premium .nav-auth-btn { padding: .55rem .7rem; }
}

/* Nav fit — make room for the login button so it never overflows.
   The search is the lowest-priority bar item (has the "/" shortcut),
   so it collapses first as width tightens; nav links tighten too. */
.theme-v3.premium .nav-inner { gap: .55rem; flex-wrap: nowrap; }
.theme-v3.premium .nav-links { gap: .05rem; }
.theme-v3.premium .nav-links .nav-link { padding: .5rem .62rem; font-size: .9rem; }
.theme-v3.premium .nav-search { min-width: 120px; }
/* The 8 nav links + login CTA + icons need the room; the inline search
   (redundant with the "/" shortcut and hero) collapses on all but ultra-wide,
   and links tighten, so the login button always stays on-screen. */
/* Desktop (≥1200, horizontal bar): hide both search entry points — the
   legacy .nav-search AND the command-palette pill (.tsx-trigger, ~92px).
   The nav container is hard-capped (~1180px content box) and the 9 links
   + login CTA already fill it; search stays reachable via the "/" or
   Ctrl+K shortcut and the hero search. On mobile (<1200) the pill STAYS
   visible so touch users (no keyboard) still have a tap-to-search entry. */
@media (min-width: 1200px) {
  .theme-v3.premium nav.nav .nav-search,
  .theme-v3.premium nav.nav .tsx-trigger { display: none !important; }
  /* tighten the horizontal links so 9 links + login fit the capped bar.
     Higher-specificity selectors + !important override the wider base
     gaps (nav-inner 20px, nav-links 5.6px) that otherwise reintroduce
     ~7px of overflow in the 1200–1500 band. */
  .theme-v3.premium nav.nav .container.nav-inner { gap: 12px !important; }
  .theme-v3.premium nav.nav .nav-links { gap: 2px !important; }
  .theme-v3.premium nav.nav .nav-links .nav-link { padding: .46rem .44rem !important; font-size: .86rem !important; }
}

/* ================================================================
   Stage-25 — UNIFIED hamburger nav (single source of truth).
   Root cause of the "ugly full-width menu on tablets": the legacy
   native hamburger (#nav-hamburger) was re-shown by app.css media
   queries in the 769–1199px band and opened the old full-width
   dropdown, while the custom drawer only appeared ≤768px. Fix: the
   custom drawer (mobile-nav.js) owns EVERY width below desktop; the
   native hamburger and its dropdown are killed at all widths; the
   horizontal desktop links appear only ≥1200px (where the 10 links
   + login actually fit). No more dead 769–1199px band. */
.theme-v3.premium #nav-hamburger,
.theme-v3.premium nav.nav .nav-hamburger { display: none !important; }
@media (max-width: 1199.98px) {
  .theme-v3.premium nav.nav .nav-links,
  .theme-v3.premium nav.nav .nav-links.is-open { display: none !important; }
  /* neutralize the legacy body scroll-lock overlay if ever toggled */
  .theme-v3.premium body:has(.nav .nav-links.is-open)::before { display: none !important; }
}

/* Depth elevation — stronger, more premium nav + brand */
.theme-v3.premium nav.nav {
  box-shadow: 0 1px 0 var(--v3-line), 0 6px 24px rgba(14,18,25,.04);
}
.theme-v3.premium .brand-mark {
  box-shadow: 0 6px 18px rgba(30,27,75,.22);
}
.theme-v3.premium .brand-name strong { background: none; }


/* ================================================================
   Stage-22 — polish: contrast, dark-mode, motion, focus
   ================================================================ */

/* Contrast: nudge muted ink darker so small body/meta text clears AA
   comfortably on the ivory surface (was #6E7280 ≈ borderline). */
.theme-v3.premium { --v3-ink-3: #5C606B; }
[data-theme="dark"] .theme-v3.premium { --v3-ink-3: #A6ABB8; }

/* Smooth in-page anchor scrolling (subject page tabs, etc.) */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* Accessible focus ring on all interactive controls */
.theme-v3.premium a:focus-visible,
.theme-v3.premium button:focus-visible,
.theme-v3.premium input:focus-visible,
.theme-v3.premium select:focus-visible,
.theme-v3.premium .tsx-item:focus-visible {
  outline: 2.5px solid var(--v3-brand-1);
  outline-offset: 2px;
  border-radius: 8px;
}

/* Dark-mode: keep the login CTA + account chip legible */
[data-theme="dark"] .theme-v3.premium .nav-account-btn { background: var(--v3-surface-2); }
[data-theme="dark"] .theme-v3.premium .scale-band,
[data-theme="dark"] .theme-v3.premium .mat-card,
[data-theme="dark"] .theme-v3.premium .path-ic { background: var(--v3-surface); }
[data-theme="dark"] .theme-v3.premium .cred-strip { background: var(--v3-surface-2); }
[data-theme="dark"] .theme-v3.premium .hero-trust { border-top-color: var(--v3-line); }

/* Motion: gentle lift feedback on the key content cards (composited only) */
.theme-v3.premium .scale-cell,
.theme-v3.premium .path-ic,
.theme-v3.premium .mat-ic { will-change: auto; }
.theme-v3.premium .subj-card-v3,
.theme-v3.premium .feat-v3,
.theme-v3.premium .mat-card,
.theme-v3.premium .bs-book { transition-timing-function: cubic-bezier(.16,1,.3,1); }

/* Count-up hook (progressive enhancement; JS optional) */
.theme-v3.premium .num-hero[data-countup] { font-variant-numeric: tabular-nums lining-nums; }


/* ================================================================
   Stage-23 — DARK MODE ROOT FIX
   Root cause: light tokens are (re)defined on `.container` and `.nav`
   (not just body), but the dark overrides in theme-v3/premium-v3 only
   target the body-level selectors. Descendants of `.container` therefore
   inherit the LIGHT --v3-surface (#fff) in dark mode → white cards.
   Fix: redefine the full dark token set on `.container` and `.nav` too,
   so the closest ancestor carries dark values. Covers all cards site-wide.
   ================================================================ */
[data-theme="dark"] .theme-v3.premium .container,
[data-theme="dark"] .theme-v3.premium .nav,
[data-theme="dark"] .theme-v3 .container,
[data-theme="dark"] .theme-v3 .nav {
  --v3-bg:         #0E0F15;
  --v3-surface:    #17182A;
  --v3-surface-2:  #1E2038;
  --v3-line:       #262845;
  --v3-line-soft:  #1E2038;
  --v3-line-2:     #33365C;
  --v3-ink-1:      #F5F6FB;
  --v3-ink-2:      #C7CBDA;
  --v3-ink-3:      #9AA0B4;
  --v3-brand-soft: #24264C;
}

/* Nav surface + inputs stay dark too */
[data-theme="dark"] .theme-v3.premium nav.nav { background: rgba(14,15,21,.88); }
[data-theme="dark"] .theme-v3.premium .nav-search,
[data-theme="dark"] .theme-v3.premium .icon-btn { background: var(--v3-surface-2); }

/* Book covers: dark placeholder instead of pale surface-2 */
[data-theme="dark"] .theme-v3.premium .bs-cover { background: var(--v3-surface-2); }

/* Section link chip readable on dark */
[data-theme="dark"] .theme-v3.premium .sh-link-v3 { background: var(--v3-brand-soft); color: #C9CBF5; border-color: var(--v3-brand-soft); }
[data-theme="dark"] .theme-v3.premium .sh-link-v3:hover { background: #2E3060; }

/* Search command palette: dark surface (uses tokens, ensure trigger too) */
[data-theme="dark"] .theme-v3.premium .tsx-trigger { background: var(--v3-surface-2); color: var(--v3-ink-3); }

/* Segment / tab controls (incl. subject-page .tabs) — body-level so it
   applies even outside .container */
/* app.css sets `.tabs {background: #fff !important}` (light) with no dark
   counterpart, so the dark rule MUST also be !important to win. */
[data-theme="dark"] .theme-v3.premium .seg-v3,
[data-theme="dark"] .theme-v3.premium .tabs,
[data-theme="dark"] .theme-v3.premium .branches,
[data-theme="dark"] .theme-v3.premium .branch-tabs,
[data-theme="dark"] .theme-v3.premium .filter-tabs,
[data-theme="dark"] .theme-v3.premium .segments { background: #1E2038 !important; border-color: #33365C !important; }
[data-theme="dark"] .theme-v3.premium .seg-v3 button.is-active,
[data-theme="dark"] .theme-v3.premium .segments .segment.is-active { background: var(--v3-brand-1); color: #fff; }


/* ================================================================
   Stage-24 — Mobile navigation completeness (adapt)
   Root cause: launch-fixes.css hides the hamburger AND the login button
   on ≤768 ("bottom-nav handles it"), but the bottom-nav only carries 5
   core destinations — الملازم/فيديوهات/الأساتذة/الموضوعات and login were
   unreachable on phones. Restore the hamburger drawer (all links) + a
   compact login/account control on mobile. refine-v5 loads after
   launch-fixes, so matching !important wins.
   ================================================================ */
@media (max-width: 768px) {
  /* Mobile hamburger + full drawer are owned by assets/mobile-nav.js.
     Here we only ensure the login/account control stays reachable and the
     top bar stays compact. */
  .theme-v3.premium .nav-auth-slot { display: inline-flex !important; }
  .theme-v3.premium .nav-auth-btn,
  .theme-v3.premium .nav-account-btn { display: inline-flex !important; }
  .theme-v3.premium .nav-auth-btn span,
  .theme-v3.premium .nav-account-name { display: none !important; }
  .theme-v3.premium .nav-inner { gap: .4rem; }
  .theme-v3.premium .brand-name span { display: none; }         /* trim brand subtitle */
}

/* Touch: comfortable tap targets on coarse pointers (phones/tablets) */
@media (pointer: coarse) {
  .theme-v3.premium .footer-links a,
  .theme-v3.premium .sh-link-v3,
  .theme-v3.premium .sh-more-v4,
  .theme-v3.premium a.r-link { display: inline-flex; align-items: center; min-height: 44px; }
  .theme-v3.premium .footer-links { gap: .1rem 1.2rem; }
}

/* Safe area (notch / home indicator) for the fixed bottom nav + offline banner */
@supports (padding: max(0px)) {
  .bottom-nav { padding-bottom: max(0px, env(safe-area-inset-bottom)); }
}


/* ---------- 11) Mobile ---------- */
@media (max-width: 768px) {
  .theme-v3.premium .scale-band { padding: 1.3rem 1.1rem; border-radius: 16px; }
  .theme-v3.premium .path-ic { width: 52px; height: 52px; }
  .theme-v3.premium .mat-card { padding: 1.2rem; }
}

/* ================================================================
   Stage-26 — cover cards (first-page thumbnails) + download bundles
   ================================================================ */

/* ---- resource cover cards (materials: ملازم/كراسات/أوراق عمل) ---- */
.theme-v3.premium .res-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(218px, 1fr));
  gap: 1.15rem;
}
.theme-v3.premium .res-card--cover {
  display: flex;
  flex-direction: column;
  background: var(--v3-surface, #fff);
  border: 1px solid var(--v3-line, #E9E7DF);
  border-radius: 16px;
  overflow: hidden;
  transition: transform .22s var(--v3-ease, cubic-bezier(.16,1,.3,1)), box-shadow .22s ease, border-color .22s ease;
}
.theme-v3.premium .res-card--cover:hover {
  transform: translateY(-4px);
  box-shadow: 0 18px 40px rgba(30,27,75,.14);
  border-color: color-mix(in oklab, var(--subject-accent, var(--v3-brand-1)) 42%, var(--v3-line));
}
.theme-v3.premium .res-thumb {
  position: relative;
  display: block;
  aspect-ratio: 3 / 4;
  background: var(--v3-surface-2, #F4F3EE);
  overflow: hidden;
  border-bottom: 1px solid var(--v3-line, #E9E7DF);
}
.theme-v3.premium .res-thumb-img {
  width: 100%; height: 100%;
  object-fit: cover; object-position: top center;
  display: block;
  transition: transform .3s var(--v3-ease, cubic-bezier(.16,1,.3,1));
}
.theme-v3.premium .res-card--cover:hover .res-thumb-img { transform: scale(1.035); }
.theme-v3.premium .res-thumb-fallback {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  color: #fff;
  background: linear-gradient(150deg,
    var(--subject-accent, var(--v3-brand-1)) 0%,
    color-mix(in oklab, var(--subject-accent, var(--v3-brand-ink)) 70%, #000) 100%);
}
.theme-v3.premium .res-thumb-fallback svg { width: 46px; height: 46px; opacity: .9; }
.theme-v3.premium .res-thumb-badge {
  position: absolute; inset-block-start: .55rem; inset-inline-start: .55rem;
  background: rgba(14,18,25,.72);
  color: #fff; font-family: Tajawal, system-ui, sans-serif;
  font-weight: 700; font-size: .72rem;
  padding: .22rem .55rem; border-radius: 999px;
  backdrop-filter: blur(4px);
}
.theme-v3.premium .res-card--cover .res-body { padding: .7rem .8rem .35rem; flex: 1; }
.theme-v3.premium .res-card--cover .res-title {
  font-family: Tajawal, system-ui, sans-serif; font-weight: 700;
  font-size: .96rem; line-height: 1.4; color: var(--v3-ink-1, #0E1219);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.theme-v3.premium .res-card--cover .res-meta {
  margin-top: .3rem; font-size: .78rem; color: var(--v3-ink-3, #5C606B);
  font-variant-numeric: tabular-nums;
}
.theme-v3.premium .res-card--cover .res-actions {
  display: flex; align-items: center; gap: .4rem;
  padding: .5rem .8rem .8rem;
}
.theme-v3.premium .res-card--cover .res-actions .btn { flex: 1; justify-content: center; }
.theme-v3.premium .res-card--cover .res-actions .bookmark-btn { flex: 0 0 auto; }

/* small preview thumb inside compact test/bank rows */
.theme-v3.premium .test-row.has-resource-cover .resource-cover {
  width: 46px; height: 60px; flex: 0 0 auto;
  border-radius: 8px; overflow: hidden; border: 1px solid var(--v3-line, #E9E7DF);
  background: var(--v3-surface-2, #F4F3EE);
}
.theme-v3.premium .test-row.has-resource-cover .resource-cover img {
  width: 100%; height: 100%; object-fit: cover; object-position: top center;
}

/* ---- download bundle CTA ---- */
.theme-v3.premium .bundle-cta {
  margin: 1.3rem 0 1.6rem;
  padding: 1.5rem 1.6rem;
  border-radius: 20px;
  background:
    radial-gradient(120% 140% at 100% 0, color-mix(in oklab, var(--v3-brand-1) 14%, transparent) 0, transparent 55%),
    var(--v3-surface, #fff);
  border: 1px solid var(--v3-line, #E9E7DF);
}
.theme-v3.premium .bundle-head h2 {
  font-family: Tajawal, system-ui, sans-serif; font-weight: 800;
  font-size: clamp(1.15rem, 1rem + 1vw, 1.5rem); color: var(--v3-brand-ink, #1E1B4B);
  margin: .15rem 0 .2rem;
}
.theme-v3.premium .bundle-eyebrow {
  font-family: Tajawal, system-ui, sans-serif; font-weight: 800; font-size: .74rem;
  letter-spacing: .04em; color: var(--v3-gold, #B08840);
}
.theme-v3.premium .bundle-head p { font-size: .9rem; color: var(--v3-ink-3, #5C606B); margin: 0 0 1rem; }
.theme-v3.premium .bundle-grid {
  display: grid; gap: .85rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.theme-v3.premium .bundle-card {
  display: flex; align-items: center; gap: .85rem;
  padding: .95rem 1.05rem; border-radius: 14px;
  text-decoration: none;
  border: 1px solid var(--v3-line, #E9E7DF);
  background: var(--v3-surface-2, #F4F3EE);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.theme-v3.premium .bundle-card.is-ready {
  background: linear-gradient(135deg, var(--v3-brand-1, #4C50A6), var(--v3-brand-2, #7649AB));
  border-color: transparent;
}
.theme-v3.premium .bundle-card.is-ready:hover {
  transform: translateY(-3px); box-shadow: 0 16px 34px rgba(30,27,75,.3);
}
.theme-v3.premium .bundle-card.is-pending { opacity: .72; cursor: default; }
.theme-v3.premium .bundle-ic {
  flex: 0 0 auto; width: 46px; height: 46px; border-radius: 12px;
  display: grid; place-items: center;
  background: rgba(255,255,255,.18); color: #fff;
}
.theme-v3.premium .bundle-card.is-pending .bundle-ic {
  background: var(--v3-surface, #fff); color: var(--v3-brand-1, #4C50A6);
  border: 1px solid var(--v3-line, #E9E7DF);
}
.theme-v3.premium .bundle-ic svg { width: 24px; height: 24px; }
.theme-v3.premium .bundle-text { display: flex; flex-direction: column; gap: .12rem; flex: 1; min-width: 0; }
.theme-v3.premium .bundle-card.is-ready .bundle-title { color: #fff; font-family: Tajawal, system-ui, sans-serif; font-weight: 800; font-size: .98rem; }
.theme-v3.premium .bundle-card.is-ready .bundle-sub { color: rgba(255,255,255,.85); font-size: .8rem; font-variant-numeric: tabular-nums; }
.theme-v3.premium .bundle-card.is-pending .bundle-title { color: var(--v3-ink-1, #0E1219); font-family: Tajawal, system-ui, sans-serif; font-weight: 800; font-size: .98rem; }
.theme-v3.premium .bundle-card.is-pending .bundle-sub { color: var(--v3-ink-3, #5C606B); font-size: .8rem; }
.theme-v3.premium .bundle-dl { flex: 0 0 auto; color: #fff; opacity: .9; }
.theme-v3.premium .bundle-dl svg { width: 22px; height: 22px; }

/* per-book download button on books grid */
.theme-v3.premium .book-actions { display: flex; align-items: center; gap: .4rem; }
.theme-v3.premium .book-actions .book-dl { flex: 1; justify-content: center; }

/* ---- dark mode ---- */
[data-theme="dark"] .theme-v3.premium .res-card--cover { background: var(--v3-surface, #16181D); border-color: var(--v3-line, #2A2D34); }
[data-theme="dark"] .theme-v3.premium .res-thumb,
[data-theme="dark"] .theme-v3.premium .test-row.has-resource-cover .resource-cover { background: #1F2228; border-color: #2A2D34; }
[data-theme="dark"] .theme-v3.premium .bundle-cta { background: radial-gradient(120% 140% at 100% 0, color-mix(in oklab, var(--v3-brand-1) 22%, transparent) 0, transparent 55%), var(--v3-surface, #16181D); border-color: var(--v3-line, #2A2D34); }
[data-theme="dark"] .theme-v3.premium .bundle-card.is-pending { background: #1F2228; border-color: #2A2D34; }
[data-theme="dark"] .theme-v3.premium .bundle-card.is-pending .bundle-ic { background: #16181D; }

@media (max-width: 560px) {
  .theme-v3.premium .res-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem; }
  .theme-v3.premium .res-card--cover .res-actions { flex-wrap: wrap; }
  .theme-v3.premium .bundle-cta { padding: 1.2rem 1.1rem; }
}
@media (prefers-reduced-motion: reduce) {
  .theme-v3.premium .res-card--cover, .theme-v3.premium .res-thumb-img, .theme-v3.premium .bundle-card { transition: none; }
}

/* ================================================================
   Stage-27 — library hub (materials.html) + category pages
   ================================================================ */
.theme-v3.premium .libhub { margin: 0 0 1.6rem; }
.theme-v3.premium .libhub-head h2 {
  font-family: Tajawal, system-ui, sans-serif; font-weight: 800;
  font-size: clamp(1.1rem, 1rem + .8vw, 1.4rem); color: var(--v3-brand-ink, #1E1B4B);
  margin: .15rem 0 .9rem;
}
.theme-v3.premium .libhub-grid {
  display: grid; gap: .7rem;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
}
.theme-v3.premium .libhub-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: .3rem;
  padding: .95rem 1rem; border-radius: 14px; text-decoration: none;
  background: var(--v3-surface, #fff);
  border: 1px solid var(--v3-line, #E9E7DF);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.theme-v3.premium .libhub-card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in oklab, var(--v3-brand-1) 45%, var(--v3-line));
  box-shadow: 0 12px 26px rgba(30,27,75,.12);
}
.theme-v3.premium .libhub-ic { font-size: 1.35rem; line-height: 1; }
.theme-v3.premium .libhub-t {
  font-family: Tajawal, system-ui, sans-serif; font-weight: 800;
  font-size: .98rem; color: var(--v3-ink-1, #0E1219);
}
.theme-v3.premium .libhub-c { font-size: .78rem; color: var(--v3-ink-3, #5C606B); font-variant-numeric: tabular-nums; }
.theme-v3.premium .lib-crumbs { margin-top: .55rem; }
.theme-v3.premium .lib-crumbs a {
  font-size: .84rem; font-weight: 600; color: var(--v3-brand-1, #4C50A6); text-decoration: none;
}
.theme-v3.premium .lib-crumbs a:hover { text-decoration: underline; }
[data-theme="dark"] .theme-v3.premium .libhub-card { background: var(--v3-surface, #16181D); border-color: var(--v3-line, #2A2D34); }
