/**
 * أدلة الأنظمة — token-level theme, both palettes defined at :root so the
 * un-stamped "system" state (no explicit data-theme, most viewers) still
 * resolves correctly off prefers-color-scheme alone. See the dark block below.
 *
 * Palette: the "Trust & Authority" navy/slate the design-system search
 * returned for a documentation/utility product — chosen deliberately as the
 * SHELL's neutral, so it never competes with whichever project's own brand
 * color tints that project's section. --accent-fallback is what the shell
 * itself uses (nav focus rings, links) when no project color is in scope.
 */
:root {
  --paper: #f8fafc;
  --surface: #ffffff;
  --sunken: #eef1f5;
  --ink: #0f172a;
  --ink-soft: #334155;
  --muted: #64748b;
  --rule: #e2e8f0;
  --rule-soft: #edf1f5;
  --accent-fallback: #0369a1;
  --danger: #dc2626;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 28px -16px rgba(15, 23, 42, .16);
  --radius: 14px;
  --radius-sm: 9px;
  --ease: cubic-bezier(.22, .61, .36, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0b0f16;
    --surface: #121722;
    --sunken: #171d29;
    --ink: #eef2f8;
    --ink-soft: #c3cbda;
    --muted: #8b96a8;
    --rule: #232b3a;
    --rule-soft: #1b2230;
    --accent-fallback: #7dd3fc;
    --danger: #f87171;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 12px 32px -18px rgba(0, 0, 0, .65);
  }
}
:root[data-theme="dark"] {
  --paper: #0b0f16;
  --surface: #121722;
  --sunken: #171d29;
  --ink: #eef2f8;
  --ink-soft: #c3cbda;
  --muted: #8b96a8;
  --rule: #232b3a;
  --rule-soft: #1b2230;
  --accent-fallback: #7dd3fc;
  --danger: #f87171;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 12px 32px -18px rgba(0, 0, 0, .65);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.65 "IBM Plex Sans Arabic", "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent-fallback);
  outline-offset: 3px;
  border-radius: 4px;
}
button { font: inherit; cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

.wrap { max-width: 60rem; margin: 0 auto; padding: 0 1.25rem; }
@media (max-width: 640px) { .wrap { padding: 0 1rem; } }

/* ---------- header ---------- */
header.site {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--rule);
}
.bar {
  display: flex; align-items: center; gap: .75rem;
  min-height: 64px; padding: .6rem 0;
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; letter-spacing: -.01em; }
.brand .mark {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  background: var(--ink); color: var(--paper);
  display: grid; place-items: center; font-weight: 700; font-size: .95rem;
}
.brand .name { font-size: 1.02rem; }
.brand .sub { color: var(--muted); font-weight: 400; font-size: .85rem; }
.spacer { flex: 1; }
.crumb {
  display: flex; align-items: center; gap: .4rem;
  font-size: .88rem; color: var(--muted);
}
.crumb a { text-decoration: none; padding: .3rem .1rem; }
.crumb a:hover { color: var(--ink); }
.crumb .sep { opacity: .5; }
.crumb .current { color: var(--ink); font-weight: 600; }

/* ---------- hero ---------- */
.hero { padding: 2.75rem 0 2rem; }
.hero .eyebrow {
  font: 700 .72rem/1 ui-sans-serif, sans-serif;
  letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}
.hero h1 {
  font-size: clamp(1.7rem, 4vw, 2.35rem); line-height: 1.22;
  margin: .5rem 0 .5rem; letter-spacing: -.015em; text-wrap: balance;
}
.hero p { color: var(--ink-soft); max-width: 60ch; margin: 0; font-size: 1rem; }

/* ---------- project cards (library home) ---------- */
.projects {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr));
  gap: .9rem; margin: 1.75rem 0 4rem;
}
.pcard {
  --tint: var(--accent-fallback);
  display: flex; flex-direction: column; gap: .85rem;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
  padding: 1.15rem 1.2rem 1.3rem; box-shadow: var(--shadow);
  text-decoration: none; color: inherit;
  transition: transform .18s var(--ease), border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.pcard:hover, .pcard:focus-visible { transform: translateY(-2px); border-color: var(--tint); }
.pcard .top { display: flex; align-items: center; gap: .7rem; }
.pcard .mark {
  width: 40px; height: 40px; border-radius: 10px; flex-shrink: 0;
  background: var(--tint); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 1.05rem;
}
.pcard h2 { font-size: 1.08rem; margin: 0; letter-spacing: -.01em; }
.pcard .count {
  font-size: .82rem; color: var(--muted); margin: 0;
}
.pcard .count b { color: var(--ink); font-variant-numeric: tabular-nums; }
.pcard .go {
  margin-top: auto; display: inline-flex; align-items: center; gap: .35rem;
  font-size: .86rem; font-weight: 600; color: var(--tint);
}
.pcard .go svg { width: 15px; height: 15px; transition: transform .18s var(--ease); }
[dir="rtl"] .pcard .go svg { transform: scaleX(-1); }
.pcard:hover .go svg { transform: translateX(-3px); }
[dir="rtl"] .pcard:hover .go svg { transform: scaleX(-1) translateX(-3px); }

/* ---------- guide list (project page) ---------- */
.guides { display: flex; flex-direction: column; gap: .7rem; margin: 1.75rem 0 4rem; }

.gitem {
  --tint: var(--accent-fallback);
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.gitem summary {
  list-style: none; cursor: pointer;
  display: flex; align-items: center; gap: .9rem;
  padding: 1rem 1.15rem; min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}
.gitem summary::-webkit-details-marker { display: none; }
.gitem summary:focus-visible { outline-offset: -3px; }

.gitem .num {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: var(--sunken); color: var(--ink-soft);
  display: grid; place-items: center;
  font: 700 .82rem/1 ui-monospace, monospace; font-variant-numeric: tabular-nums;
}
.gitem[open] .num { background: var(--tint); color: #fff; }

.gitem .meta { flex: 1; min-width: 0; }
.gitem h3 { font-size: .98rem; margin: 0; font-weight: 650; }
.gitem .role {
  display: inline-block; margin-top: .25rem; font-size: .78rem; color: var(--muted);
}
.gitem .dur {
  flex-shrink: 0; font: 500 .8rem/1 ui-monospace, monospace;
  color: var(--muted); font-variant-numeric: tabular-nums;
}
.gitem .chev { flex-shrink: 0; width: 18px; height: 18px; color: var(--muted); transition: transform .18s var(--ease); }
.gitem[open] .chev { transform: rotate(180deg); }

.gitem .player { padding: 0 1.15rem 1.15rem; }
.gitem video {
  width: 100%; display: block; border-radius: var(--radius-sm);
  background: #000; aspect-ratio: 16 / 9;
}

/* Expand animation — height auto is not animatable, so this fades+slides the
   inner wrapper on open rather than the <details> box itself. */
.gitem .player { animation: reveal .22s var(--ease); }
@keyframes reveal {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.empty {
  text-align: center; padding: 3.5rem 1.5rem; color: var(--muted);
  border: 1px dashed var(--rule); border-radius: var(--radius);
}
.empty b { display: block; color: var(--ink); margin-bottom: .3rem; font-size: 1rem; }

.foot {
  border-top: 1px solid var(--rule); padding: 1.5rem 0 3rem;
  font-size: .82rem; color: var(--muted);
}
