/* ============================================================================
   مدينة الملك عبدالله الطبية — طبقة الحركة («تدفّق الرعاية» في حركة)
   ----------------------------------------------------------------------------
   عرضٌ فقط فوق الثيم المعتمد (THEME.md): لا تغيّر لونًا ولا تخطيطًا ولا محتوى.
   مبادئ:
   • الأشياء تتجسّد من الضباب (blur → حادّ) ولا تقفز إلى مكانها.
   • الأب يتحرك أولًا ثم أبناؤه بالتتابع، والأرقام آخرًا.
   • transform و opacity و filter فقط — لا width ولا top.
   • الخروج أقصر من الدخول بنحو 40٪.
   • prefers-reduced-motion: تتوقف الحركة كلها ويظهر المحتوى في حالته النهائية.
   • بلا سكربت: المحتوى ظاهر كاملًا (الإخفاء المبدئي مشروط بـ .js-motion).
   ========================================================================== */

:root {
  --m-ease: cubic-bezier(.2, .8, .2, 1);     /* الافتراضي لكل دخول */
  --m-in:   cubic-bezier(.4, 0, 1, 1);       /* للخروج فقط */
  --m-back: cubic-bezier(.34, 1.56, .64, 1); /* تجاوز طفيف: المؤشر المنزلق والأختام */
  --m-fast: 160ms;
  --m-base: 300ms;
  --m-slow: 520ms;
}

/* ── ١. الانتقال بين الصفحات (View Transitions عبر المستندات) ─────────────
   الصفحة القديمة تذوب في الضباب، والجديدة تتجسّد. الشريطان العلويان ثابتان،
   وصورة الخبر في البطاقة «تنمو» لتصبح غلاف المقالة (اسم مشترك news-<id>). */
@view-transition { navigation: auto; }

::view-transition-old(root) { animation: m-vt-out 200ms var(--m-in) both; }
::view-transition-new(root) { animation: m-vt-in 460ms var(--m-ease) both; }
@keyframes m-vt-out { to { opacity: 0; filter: blur(8px); transform: scale(.992); } }
@keyframes m-vt-in  { from { opacity: 0; filter: blur(10px); transform: translateY(12px); } }

.utility     { view-transition-name: kamc-utility; }
::view-transition-group(kamc-utility) { animation: none; }

::view-transition-group(.news-media) { animation-duration: 560ms; animation-timing-function: var(--m-ease); }
::view-transition-old(.news-media),
::view-transition-new(.news-media) { height: 100%; width: 100%; object-fit: cover; overflow: clip; }
::view-transition-image-pair(.news-media) { border-radius: var(--radius-lg); overflow: hidden; }

/* ── ٢. البطل: تتابع افتتاحي (CSS خالص — لا يعتمد على السكربت) ─────────── */
.vhero__img, .vhero__video { animation: m-kenburns 2.6s var(--m-ease) backwards; }
@keyframes m-kenburns { from { transform: scale(1.14); filter: blur(6px) saturate(.8); } to { transform: scale(1.04); filter: none; } }

.vhero__copy > * { animation: m-materialize 900ms var(--m-ease) backwards; }
.vhero__copy > :nth-child(1) { animation-delay: 180ms; }
.vhero__copy > :nth-child(2) { animation-delay: 300ms; }
.vhero__copy > :nth-child(3) { animation-delay: 440ms; }
.vhero__copy > :nth-child(4) { animation-delay: 580ms; }
.vhero__player { animation: m-materialize 700ms 760ms var(--m-ease) backwards; }
@keyframes m-materialize {
  from { opacity: 0; filter: blur(14px); transform: translateY(20px); }
  to   { opacity: 1; filter: blur(0);    transform: none; }
}

/* خطوط التدفّق «تُرسم» من جهة البداية (يمين في العربية) */
.vhero__flow, .page-hero__flow { animation: m-flow-draw-rtl 1.8s 120ms var(--m-ease) backwards; }
[dir="ltr"] .vhero__flow, [dir="ltr"] .page-hero__flow { animation-name: m-flow-draw-ltr; }
@keyframes m-flow-draw-rtl { from { clip-path: inset(0 0 0 100%); } to { clip-path: inset(0); } }
@keyframes m-flow-draw-ltr { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0); } }

/* نبضة الرعاية: وهج سماوي يسري على خطوط النمط نفسها (قناع من ملف النمط) */
.vhero__flow::after, .page-hero__flow::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(100deg, transparent 42%, rgba(47,169,224,.95) 50%, transparent 58%) 0 0 / 260% 100% no-repeat;
  -webkit-mask: var(--m-flow-mask) center bottom / 100% 100% no-repeat;
          mask: var(--m-flow-mask) center bottom / 100% 100% no-repeat;
  mix-blend-mode: screen; opacity: .55;
  animation: m-pulse 7s 1.6s linear infinite both;
}
.vhero__flow::after { --m-flow-mask: url("../brand-kamc/04-patterns/flow/flow-hero.svg"); }
.page-hero__flow::after { --m-flow-mask: url("../brand-kamc/04-patterns/flow/flow-page.svg"); -webkit-mask-position: center; mask-position: center; }
@keyframes m-pulse { from { background-position: 160% 0; } to { background-position: -60% 0; } }
[dir="ltr"] .vhero__flow::after, [dir="ltr"] .page-hero__flow::after { animation-direction: reverse; }

/* الهيدر الشفاف ينزل بهدوء، وشريط الإجراءات يصعد بالتتابع فوق البطل */
.site-header--transparent { animation: m-drop 700ms 60ms var(--m-ease) backwards; }
@keyframes m-drop { from { opacity: 0; transform: translateY(-14px); } }
.dock__card > li { animation: m-rise 760ms var(--m-ease) backwards; }
.dock__card > li:nth-child(1) { animation-delay: 720ms; }
.dock__card > li:nth-child(2) { animation-delay: 790ms; }
.dock__card > li:nth-child(3) { animation-delay: 860ms; }
.dock__card > li:nth-child(4) { animation-delay: 930ms; }
.dock__card > li:nth-child(5) { animation-delay: 1000ms; }
@keyframes m-rise { from { opacity: 0; transform: translateY(26px); filter: blur(8px); } }
.dock__ib { transition: transform var(--m-base) var(--m-back); }
.dock__act:hover .dock__ib { transform: translateY(-3px) scale(1.06); }

/* ترويسة الصفحات الداخلية: المسار ثم العنوان ثم التمهيد */
.page-hero__in > * { animation: m-materialize 760ms var(--m-ease) backwards; }
.page-hero__in > :nth-child(1) { animation-delay: 80ms; }
.page-hero__in > :nth-child(2) { animation-delay: 180ms; }
.page-hero__in > :nth-child(3) { animation-delay: 300ms; }
.page-hero__media img, .page-hero__media picture { animation: m-kenburns 2.4s var(--m-ease) backwards; }

/* ── ٣. الظهور عند التمرير (يضيف السكربت .rv ثم يحرّكها بالتتابع) ─────── */
.js-motion .rv { opacity: 0; }
.js-motion .rv-img { clip-path: inset(0 0 0 100%); }
[dir="ltr"].js-motion .rv-img { clip-path: inset(0 100% 0 0); }

/* ── ٤. التفاعل الدقيق: رفع البطاقات، ضغط الأزرار ─────────────────────── */
.btn { transition: background var(--dur-fast) var(--ease-flow), border-color var(--dur-fast) var(--ease-flow),
                   color var(--dur-fast) var(--ease-flow), transform var(--m-fast) var(--m-ease), box-shadow var(--m-base) var(--m-ease); }
.btn:active { transform: scale(.97); }
.btn-primary:hover, .btn-light:hover { box-shadow: 0 10px 24px -12px rgba(17,110,158,.55); }

.ncard, a.tile, .ccard, .center { transition: transform var(--m-base) var(--m-ease), box-shadow var(--m-base) var(--m-ease), border-color var(--dur-fast) var(--ease-flow); }
.ncard:hover, a.tile:hover, a.ccard:hover { transform: translateY(-4px); }
.center:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.ncard__img { transition: transform 700ms var(--m-ease); }
.ncard:hover .ncard__img { transform: scale(1.05); }
.tile__ib { transition: transform var(--m-base) var(--m-back), background var(--m-base) var(--m-ease); }
a.tile:hover .tile__ib { transform: rotate(-6deg) scale(1.08); }
.ic-fwd { transition: transform var(--m-base) var(--m-ease); }
a:hover > .ic-fwd, .link:hover .ic-fwd { transform: translateX(-4px); }
[dir="ltr"] a:hover > .ic-fwd, [dir="ltr"] .link:hover .ic-fwd { transform: translateX(4px); }

/* مؤشر القائمة المنزلق (.nav-ink) حُذف 2026-11-14 — انظر التعليق في
   kamc-motion.js. المرور يُفتِّح لون البند، والخطّ للصفحة الحالية وحدها. */
@media (min-width: 1280px) { .site-nav { position: relative; } }

/* شريط تقدّم القراءة في المقالات */
.read-progress { position: fixed; inset-block-start: 0; inset-inline: 0; height: 3px; z-index: 900; pointer-events: none;
  background: var(--kamc-spectrum-flow, var(--accent)); transform: scaleX(0); transform-origin: right; }
[dir="ltr"] .read-progress { transform-origin: left; }

/* ── ٥. الأرقام ─────────────────────────────────────────────────────────── */
.stats dd, [data-count] { font-variant-numeric: tabular-nums; }

/* ── ٦. التبويبات (صفحات المراكز والإدارات) ──────────────────────────────
   بلا سكربت: أقسام متتالية بعناوين h2. بالسكربت: شريط تبويبات بمؤشر منزلق. */
.tabset { margin-block-start: 1.5rem; }
.tabset__panel + .tabset__panel { margin-block-start: 2rem; }
.tabset__panel > h2 { font-size: var(--step-2); margin: 0 0 1rem; }
.tabset.is-on .tabset__panel + .tabset__panel { margin-block-start: 0; }
.tabset.is-on .tabset__panel > h2 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.tabset__list { position: relative; display: flex; gap: .25rem; padding: .375rem; margin-block-end: 1.75rem; overflow-x: auto; scrollbar-width: thin;
  background: var(--bg-surface-3); border-radius: 999px; isolation: isolate; }
.tabset__tab { all: unset; position: relative; z-index: 1; flex: none; padding: .625rem 1.125rem; border-radius: 999px; cursor: pointer;
  font-weight: 700; font-size: .9375rem; color: var(--fg-muted); white-space: nowrap; transition: color 200ms var(--m-ease); }
.tabset__tab:hover { color: var(--fg-strong); }
.tabset__tab[aria-selected="true"] { color: var(--btn-on-fill); }
.tabset__tab:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }
.tabset__pill { position: absolute; z-index: 0; inset-block: .375rem; left: 0; width: 0; border-radius: 999px; background: var(--btn-fill);
  box-shadow: 0 6px 16px -8px rgba(17,110,158,.6); transition: transform 440ms var(--m-back), width 440ms var(--m-back); }

/* ── ٧. القيم IMPACT ────────────────────────────────────────────────────── */
.values-grid { list-style: none; margin: 1.75rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
@media (max-width: 760px) { .values-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 420px) { .values-grid { grid-template-columns: 1fr; } }
.values-grid li { position: relative; overflow: hidden; display: grid; gap: .25rem; padding: 1.5rem 1.375rem 1.375rem; border-radius: var(--radius-lg);
  background: var(--bg-surface); border: 1px solid var(--border); transition: transform var(--m-base) var(--m-ease), box-shadow var(--m-base) var(--m-ease); }
.values-grid li:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.values-grid li::before { content: ""; position: absolute; inset-inline: 0; inset-block-start: 0; height: 3px; background: var(--kamc-spectrum-flow, var(--accent));
  transform: scaleX(var(--bar, 1)); transform-origin: right; transition: transform 900ms var(--m-ease); }
[dir="ltr"] .values-grid li::before { transform-origin: left; }
.values-grid__letter { font: 700 3.25rem/1 var(--font-sans); color: var(--accent-text); opacity: .9; margin-block-end: .5rem; font-family: "IBM Plex Sans", var(--font-sans); }
.values-grid strong { font-size: 1.125rem; color: var(--fg-strong); }
.values-grid__alt { font-size: .875rem; color: var(--fg-faint); }

/* ── ٨. كلمة المدير العام ──────────────────────────────────────────────────
   المتن يأتي فقراتٍ متتالية من الاستيراد، ويُعاد بناؤه عرضًا في `ceo_letter()`:
   الصورة `figure` بتعريفٍ تحتها، والمراكز شبكةً موصولة بصفحاتها، والتوقيع
   كتلةً واحدة. وتبقى قاعدة الفقرة الأولى للمتن الذي لم يُحوَّل. */
.ceo-letter > .ceo-photo,
.ceo-letter > p:first-child:has(img) { float: inline-end; width: min(42%, 300px); margin: 0 0 1.25rem 0; margin-inline-start: 1.75rem; }
.ceo-letter > .ceo-photo img,
.ceo-letter > p:first-child img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); }
.ceo-letter::after { content: ""; display: block; clear: both; }
.ceo-photo figcaption { display: grid; gap: .125rem; margin-block-start: .875rem; text-align: center; line-height: 1.5; }
.ceo-photo figcaption b { color: var(--fg-strong); font-size: 1rem; }
.ceo-photo figcaption span { color: var(--fg-muted); font-size: .875rem; }

/* ثمانية مراكز كانت ثماني فقرات كاملة الارتفاع — صارت شبكةً من بطاقاتٍ
   تُنقر، وكلٌّ منها يفتح صفحة مركزه. */
.ceo-centers { list-style: none; margin: 1.25rem 0 1.75rem; padding: 0; display: grid; gap: .625rem;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); }
.ceo-centers li { margin: 0; }
.ceo-centers a, .ceo-centers span {
  display: flex; align-items: center; gap: .625rem; min-height: 100%; padding: .75rem .9375rem;
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  color: var(--fg-strong); font-size: .9375rem; line-height: 1.45; text-decoration: none;
  transition: border-color var(--dur-fast) var(--ease-flow), box-shadow var(--dur-fast) var(--ease-flow), transform var(--dur-fast) var(--ease-flow); }
.ceo-centers a::before, .ceo-centers span::before {
  content: ""; flex: none; width: 6px; height: 22px; border-radius: 3px;
  background: linear-gradient(to bottom, var(--kamc-blue-light), var(--kamc-navy)); }
.ceo-centers a:hover { border-color: var(--accent); box-shadow: var(--shadow-md); color: var(--accent-text);
  text-decoration: none; transform: translateY(-2px); }

/* التوقيع كتلةً واحدة بخطٍّ فاصل، بدل أربع فقرات متباعدة */
.ceo-sign { margin-block-start: 2rem; padding-block-start: 1.25rem; border-block-start: 1px solid var(--border); }
.ceo-sign p { margin: 0; line-height: 1.8; color: var(--fg-muted); }
.ceo-sign p:nth-child(2) { color: var(--fg-strong); font-weight: 700; margin-block-start: .5rem; }

@media (max-width: 600px) {
  .ceo-letter > .ceo-photo,
  .ceo-letter > p:first-child:has(img) { float: none; width: 70%; margin: 0 auto 1.5rem; }
}

/* قسم الكلمة في الرئيسية */
.ceo-feature__grid { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: clamp(2rem, 5vw, 4rem); align-items: center; }
.ceo-feature__photo { position: relative; }
.ceo-feature__photo img { width: 100%; aspect-ratio: 4 / 5; object-fit: cover; border-radius: var(--radius-xl); display: block; box-shadow: var(--shadow-lg); }
.ceo-feature__photo::before { content: ""; position: absolute; inset: 1.25rem -1.25rem -1.25rem 1.25rem; border-radius: var(--radius-xl); z-index: -1;
  background: url("../brand-kamc/04-patterns/flow/flow-page.svg") center / 100% 100% no-repeat, var(--kamc-navy); }
[dir="ltr"] .ceo-feature__photo::before { inset: 1.25rem 1.25rem -1.25rem -1.25rem; }
.ceo-feature blockquote { margin: 0; font-size: var(--step-1); line-height: 1.9; color: var(--fg); position: relative; padding-inline-start: 1.5rem; border-inline-start: 3px solid var(--accent); }
.ceo-feature__sig { margin: 1.5rem 0 1.75rem; display: grid; gap: .125rem; }
.ceo-feature__sig b { color: var(--fg-strong); font-size: 1.0625rem; }
.ceo-feature__sig small { color: var(--fg-faint); }
@media (max-width: 860px) { .ceo-feature__grid { grid-template-columns: 1fr; } .ceo-feature__photo { max-width: 300px; } }

/* ── ٩. تكبير الصور داخل المقالات (البطاقة تتحول إلى نافذة) ───────────── */
.article-body img.zoomable { cursor: zoom-in; }
.zoom { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; }
.zoom__backdrop { position: absolute; inset: 0; background: rgba(6,23,40,.72); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.zoom__img { position: fixed; left: 0; top: 0; transform-origin: 0 0; border-radius: var(--radius-lg); box-shadow: 0 30px 80px -20px rgba(0,0,0,.6); cursor: zoom-out; max-width: none; }
.zoom__close { position: fixed; inset-block-start: 1rem; inset-inline-end: 1rem; z-index: 2; width: 48px; height: 48px; border-radius: 50%; cursor: pointer;
  border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.12); color: #fff; font-size: 1.5rem; line-height: 1; }
.zoom__close:focus-visible { outline: 3px solid var(--kamc-blue-light); outline-offset: 3px; }

/* جداول المحتوى المستورد */
.article-body table.data-table { width: 100%; border-collapse: collapse; margin-block: 1rem 1.5rem; font-size: .9375rem; display: block; overflow-x: auto; }
.article-body table.data-table td, .article-body table.data-table th { border: 1px solid var(--border); padding: .5rem .75rem; vertical-align: top; }
.article-body img { max-width: 100%; height: auto; border-radius: var(--radius-md); }

/* ── ١٠. الحركة المخفّضة: النهائي مباشرة ─────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  .js-motion .rv { opacity: 1; }
  .js-motion .rv-img { clip-path: none; }
  .vhero__flow::after, .page-hero__flow::after { animation: none; opacity: 0; }
  .ncard:hover, a.tile:hover, a.ccard:hover, .center:hover, .values-grid li:hover { transform: none; }
  .ncard:hover .ncard__img { transform: none; }
}

/* ============================================================================
   تنسيق الحركة (motion choreography) — 2026-11-13
   ----------------------------------------------------------------------------
   الحركة هنا ليست زينة: ترتيبٌ زمنيّ يقول للعين أين تبدأ وإلى أين تنتقل.
   القاعدة: مصدرٌ واحد للحركة في كل مشهد، وتتابعٌ من الأب إلى الأبناء، وخروجٌ
   أسرع من الدخول. كلها transform/opacity/filter فقط، وتتوقف كاملةً مع
   prefers-reduced-motion.
   ========================================================================== */

/* ── ١. القوائم المنسدلة: اللوح يفتح ثم تتعاقب عناصره ───────────────────── */
.js-motion .site-submenu > a,
.js-motion .megacol { opacity: 0; transform: translateY(-6px); }
.js-motion .site-nav__group:hover > .site-submenu > a,
.js-motion .site-nav__group:focus-within > .site-submenu > a,
.js-motion .site-nav__group:hover > .site-submenu .megacol,
.js-motion .site-nav__group:focus-within > .site-submenu .megacol {
  opacity: 1; transform: none;
  transition: opacity 260ms var(--m-ease), transform 260ms var(--m-ease);
}
/* تتابع العناصر: 28ms بين السطر والذي يليه، ويُعاد الصفر عند الإغلاق */
.js-motion .site-submenu > a:nth-child(1) { transition-delay: 40ms; }
.js-motion .site-submenu > a:nth-child(2) { transition-delay: 68ms; }
.js-motion .site-submenu > a:nth-child(3) { transition-delay: 96ms; }
.js-motion .site-submenu > a:nth-child(4) { transition-delay: 124ms; }
.js-motion .site-submenu > a:nth-child(5) { transition-delay: 152ms; }
.js-motion .site-submenu > a:nth-child(n+6) { transition-delay: 180ms; }
.js-motion .megacol { transition-delay: calc(40ms + var(--g, 0) * 60ms); }
.js-motion .site-nav__group:not(:hover):not(:focus-within) > .site-submenu > a,
.js-motion .site-nav__group:not(:hover):not(:focus-within) > .site-submenu .megacol { transition-delay: 0s; }

/* الشيفرون يدور مع فتح القائمة */
.site-nav .caret { transition: transform var(--m-fast) var(--m-ease), opacity var(--m-fast) linear; }
.site-nav__group:hover > a .caret, .site-nav__group:focus-within > a .caret { transform: rotate(180deg); opacity: 1; }

/* ── ٢. مشهد الدخول للصفحة: ترويسة → عنوان → سطر → محتوى ────────────────
   الصفحات الداخلية تدخل مرتّبةً كما تدخل الرئيسية، فلا تبدو «قافزة». */
@keyframes m-rise { from { opacity: 0; transform: translateY(14px); filter: blur(6px); } }
/* التأخير بالعنصر لا بترتيبه: مسار التنقل يبعث JSON-LD داخل الترويسة، فلو
   عُدّت الأبناء بالترتيب لحسب السكربت واحدًا منها وظهر السطر قبل العنوان. */
.js-motion .page-hero__in > :not(script),
.js-motion .phead__in > :not(script) { animation: m-rise 620ms var(--m-ease) both; }
.js-motion .page-hero__in > .breadcrumbs, .js-motion .phead__in > .breadcrumbs { animation-delay: 60ms; }
.js-motion .page-hero__in > h1, .js-motion .phead__in > h1 { animation-delay: 150ms; }
.js-motion .page-hero__in > .lead, .js-motion .phead__in > .lead { animation-delay: 240ms; }
/* النمط المتدفّق خلف الترويسة يتمدّد ببطء فيمنحها عمقًا حيًّا */
@keyframes m-flow-drift { from { transform: translate3d(0,0,0) scale(1.04); } to { transform: translate3d(-2.5%,0,0) scale(1.1); } }
.js-motion .page-hero__flow, .js-motion .phead__flow { animation: m-flow-drift 24s ease-in-out infinite alternate; will-change: transform; }

/* ── ٣. شريط الإجراءات السريعة يرتفع بعد البطل ──────────────────────────── */
@keyframes m-dock-in { from { opacity: 0; transform: translateY(26px); } }
.js-motion .dock__card { animation: m-dock-in 700ms var(--m-ease) 320ms both; }
.js-motion .dock__act { animation: m-rise 520ms var(--m-ease) both; }
.js-motion .dock__card > li:nth-child(1) .dock__act { animation-delay: 420ms; }
.js-motion .dock__card > li:nth-child(2) .dock__act { animation-delay: 475ms; }
.js-motion .dock__card > li:nth-child(3) .dock__act { animation-delay: 530ms; }
.js-motion .dock__card > li:nth-child(4) .dock__act { animation-delay: 585ms; }
.js-motion .dock__card > li:nth-child(5) .dock__act { animation-delay: 640ms; }

/* ── ٤. البطاقات: ارتفاع لطيف وأيقونة تستجيب ────────────────────────────── */
.plink > a, .pcard, .unitcard--link, .orgkid a, .mat, .offer, .doc-card {
  transition: transform var(--m-base) var(--m-ease), border-color var(--dur-fast) var(--ease-flow), box-shadow var(--m-base) var(--m-ease); }
.plink > a:hover, a.pcard:hover, .unitcard--link:hover, .orgkid a:hover, a.mat:hover { transform: translateY(-3px); }
.plink__ib, .pcard__ib, .tile__ib, .mat__ib { transition: transform var(--m-base) var(--m-back), background var(--dur-fast) var(--ease-flow); }
.plink > a:hover .plink__ib, a.pcard:hover .pcard__ib, a.tile:hover .tile__ib, a.mat:hover .mat__ib { transform: scale(1.08) rotate(-4deg); }
.pcard__go, .plink__ext { transition: opacity var(--m-fast) linear, transform var(--m-base) var(--m-ease); }
a.pcard:hover .pcard__go { transform: translateX(-4px); }
[dir="ltr"] a.pcard:hover .pcard__go { transform: translateX(4px); }

/* ── ٥. البوابة: بطاقات الأنظمة تتعاقب عند فتح الصفحة ───────────────────── */
.js-motion .plinks > li { animation: m-rise 520ms var(--m-ease) both; }
.js-motion .plinks > li:nth-child(1) { animation-delay: 60ms; }
.js-motion .plinks > li:nth-child(2) { animation-delay: 100ms; }
.js-motion .plinks > li:nth-child(3) { animation-delay: 140ms; }
.js-motion .plinks > li:nth-child(4) { animation-delay: 180ms; }
.js-motion .plinks > li:nth-child(n+5) { animation-delay: 220ms; }
/* النجمة تنبض لحظة التثبيت */
@keyframes m-star-pop { 40% { transform: scale(1.35) rotate(12deg); } 100% { transform: none; } }
.plink__star.is-on .ic { animation: m-star-pop 420ms var(--m-back); }

/* ── ٦. حلقة التقدّم وأشرطة النسب تملأ عند ظهورها ───────────────────────── */
.project__track i, .metric__bar i { transform-origin: var(--fill-origin, right); }
[dir="ltr"] .project__track i, [dir="ltr"] .metric__bar i { --fill-origin: left; }
@keyframes m-fill { from { transform: scaleX(0); } }
.js-motion .project__track i, .js-motion .metric__bar i { animation: m-fill 900ms var(--m-ease) 200ms both; }

/* ── ٧. خطوة التهيئة حين تُعلَّم ────────────────────────────────────────── */
@keyframes m-check { 50% { transform: scale(1.06); } }
.onb__item:has(input:checked) { animation: m-check 320ms var(--m-ease); }

/* ── ٨. المعرض: الصورة تقترب قليلًا والعنوان يرتفع ──────────────────────── */
.gallery figcaption { transition: transform var(--m-base) var(--m-ease); }
.gallery li:hover figcaption { transform: translateY(-3px); }

/* ── ٩. احترام تفضيل تقليل الحركة: كل ما سبق يتوقف ──────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .js-motion .site-submenu > a, .js-motion .megacol { opacity: 1; transform: none; transition: none; }
  .js-motion .page-hero__in > :not(script), .js-motion .phead__in > :not(script),
  .js-motion .dock__card, .js-motion .dock__act, .js-motion .plinks > li { animation: none; }
  .js-motion .page-hero__flow, .js-motion .phead__flow { animation: none; }
  .js-motion .project__track i, .js-motion .metric__bar i { animation: none; }
  .plink > a:hover, a.pcard:hover, .unitcard--link:hover, .orgkid a:hover, a.mat:hover { transform: none; }
  .plink > a:hover .plink__ib, a.pcard:hover .pcard__ib, a.tile:hover .tile__ib { transform: none; }
  .plink__star.is-on .ic, .onb__item:has(input:checked) { animation: none; }
}

/* ⚠ درج الجوال: القوائم الفرعية كانت مخفيّة تمامًا.
   الكتلة أعلاه تُخفي روابط القائمة المنسدلة (`opacity: 0`) ولا تُظهرها إلا
   بـ `:hover` أو `:focus-within` — وكلاهما لا وجود له على اللمس. فكان الدرج
   يعرض «الرئيسية» و«عن المدينة» وتحتهما فراغٌ أبيض: كل الصفحات الداخلية
   غائبة عن زائر الجوال. العلّة سابقة لشريط القائمة الجديد وكشفها فحصه.
   دون 1280 لا قائمة منسدلة أصلًا — القائمة الفرعية قائمةٌ ساكنة في الدرج. */
@media (max-width: 1279px) {
  .js-motion .site-submenu > a,
  .js-motion .megacol { opacity: 1; transform: none; transition-delay: 0s; }
}

/* ═══════════════════════════════════════════════════════════════════════
   العودة إلى الأعلى وفهرس الصفحة — منقولان من Motion Prompt بأرقامهما
   // Motion Prompt #151 · MIT License (c) 2026 Shohei Ohtaki · https://showheyohtaki.github.io/motion-prompt/#151
   // Motion Prompt #150 · MIT License (c) 2026 Shohei Ohtaki · https://showheyohtaki.github.io/motion-prompt/#150
   الألوان وحدها بُدِّلت إلى أزرق الهوية مع المحافظة على العلاقة: النشط أغمق.
   ═══════════════════════════════════════════════════════════════════════ */

/* زرّ العودة: دائرةٌ في الزاوية السفلية، والظهور والصعود من السكربت (المواصفة
   ٨٠←١٤٠ بكسل). المرور يُغمِّق اللون في ٠٫٢ ثانية — المدة من المواصفة. */
.to-top {
  position: fixed; inset-block-end: 1.25rem; inset-inline-end: 1.25rem; z-index: 70;
  width: 46px; height: 46px; border: 0; border-radius: 50%; padding: 0; cursor: pointer;
  display: grid; place-items: center;
  background: var(--kamc-navy); color: #fff;
  box-shadow: 0 3px 10px rgba(28, 35, 51, .3);
  opacity: 0; pointer-events: none;
  transition: background-color .2s cubic-bezier(.33, 1, .68, 1);
}
.to-top:hover, .to-top:focus-visible { background: #0D3A66; }
.to-top:focus-visible { outline: 3px solid var(--kamc-blue-light); outline-offset: 3px; }
.to-top .ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
@media print { .to-top { display: none; } }

/* فهرس الصفحة: البند النشط خلفيةٌ باهتة وشريطٌ على الحافة ونصٌّ عريض،
   والتبديل في ٠٫٢٥ ثانية بتيسير تكعيبي خارج — كلاهما من المواصفة. */
.toc {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 1.25rem; margin-block-end: 1.25rem;
}
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 0; }
.toc a {
  position: relative; display: block; padding: .4rem .625rem; border-radius: var(--radius-xs);
  color: var(--fg-muted); font-size: .9375rem; line-height: 1.5; text-decoration: none;
  transition: background-color .25s cubic-bezier(.33, 1, .68, 1),
              color .25s cubic-bezier(.33, 1, .68, 1),
              font-weight .25s;
}
.toc a::before {
  content: ""; position: absolute; inset-block: 2px; inset-inline-start: 0; width: 4px;
  border-radius: 2px; background: var(--accent); transform: scaleY(0); transform-origin: center;
  transition: transform .25s cubic-bezier(.33, 1, .68, 1);
}
.toc a:hover { color: var(--accent-text); }
.toc a.is-here { background: var(--bg-surface-3); color: var(--accent-text); font-weight: 700; }
.toc a.is-here::before { transform: scaleY(1); }

/* الفهرس فوق القائمة الجانبية، وكلاهما يلتصق بأعلى الإطار على الشاشات الواسعة */
@media (max-width: 1023px) { .toc { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .to-top, .toc a, .toc a::before { transition-duration: .01ms; }
}
