/* ==========================================================================
   shared-extra.css — ما تحتاجه الطبقة المشتركة (header/footer) ولا يوجد في ملفات
   التصميم الأربعة المنقولة حرفيًا من المعاينة (لا تُعدَّل تلك الملفات، وتُضاف الإضافات هنا).
   يُحمَّل بعد pages.css مباشرة (انظر head.html)، فيتفوّق على ما قبله عند تساوي الخصوصية.

   اتفاقية الصفحات: كل صفحة تلفّ محتواها بـ <main class="page on" id="main">.
   السبب: قاعدة .page في base.css تُخفي الصفحة (display:none) و.page.on تُظهرها،
   وحركات .rv (الظهور عند التحميل) مشروطة بـ .page.on. فبلا "page on" تظهر الصفحة فارغة.
   (في المعاينة كان الراوتر يبدّل الصنف on بين الصفحات، أما الآن فكل صفحة مستند مستقل
   وهي دائمًا الصفحة الحالية.)
   ========================================================================== */

/* current page in the nav.
   The preview marks the current link with the class "on" (set by its JS router). The build
   instead adds aria-current="page" to the link whose data-nav equals the page's nav value
   (see build.mjs), so these rules are a copy of the nav a.on declarations (base.css) and of
   the light-theme override (pages.css), keyed on aria-current. Keep them identical to nav a.on. */
nav a[aria-current=page]{color:#fff;background:linear-gradient(135deg,#5B2D8F,#3a1a6e);box-shadow:inset 0 0 0 1px #ffffff22}
nav a[aria-current=page]:after{content:"";position:absolute;inset-inline:30%;bottom:3px;height:2px;border-radius:2px;background:var(--grad)}
html[data-theme=light] nav a[aria-current=page]{color:#fff}

/* language button, hidden until the i18n engine exists (T9 removes the hidden attribute).
   In the preview .lang carries the auto margin that pushes the right-hand cluster (lang, theme,
   login, WhatsApp) to the end of the header, so while it is hidden the theme button takes it over;
   once T9 un-hides .lang this rule stops matching and the preview's layout is restored. */
.lang[hidden]{display:none}
.lang[hidden]+.theme{margin-inline-start:auto}

/* header at tablet / small-laptop widths (821px to 1020px).
   The preview's one-row header (brand, 4+4 nav grid, buttons) is wider than the viewport from 821px up to about 930px
   with the EN button hidden and about 1000px with it shown, so the buttons were clipped by body{overflow-x:hidden}.
   Up to 1020px use the same wrapped layout pages.css applies at <=820px: brand and buttons on the first row, the 4+4 nav
   grid on its own full-width row. Only the wrap rules are repeated: the header keeps its desktop width and radius and the
   links their desktop padding and size. Above 1020px nothing changes.
   T9 NOTE: with the EN button shown the one-row header is still squeezed above 1020px (theme button 21px instead of 40px,
   the brand wordmark under the first nav pill) until about 1095px, so change 1020px to 1100px here when .lang is un-hidden.
   With EN hidden (now) it fits unsqueezed from 1029px, or from 1021px when the scrollbar is an overlay (phones, iPad). */
@media(max-width:1020px){
  header.nav{flex-wrap:wrap}
  nav{order:3;width:100%;margin:0;grid-template-columns:repeat(4,1fr)}
}

/* nav links, tap height >= 44px at <=820px: 13px * 1.75 line-height = 22.75px + 2 * 11px = 44.75px
   (pages.css has 9px = 40.75px). Above 820px the links are 46.25px high already. */
@media(max-width:820px){
  nav a{padding:11px 4px}
}

/* 320px phones: at 13px the four nav columns need about 307px but the header offers 274px (259px with a classic scrollbar),
   so the nav grid ran past the viewport (24px at 320px). 12px text with tighter padding and no column gap needs about 259px.
   359px is where the 13px grid fits again (313px available). Height stays >= 44px: 12px * 1.75 = 21px + 2 * 12px = 45px. */
@media(max-width:359px){
  nav{column-gap:0}
  nav a{padding:12px 2px;font-size:12px}
}

/* light-theme contrast fixes for the footer/CTA band (both are inherited from the preview as they are):
   - the CTA panel stays dark in the light theme, but its .sub kept the light theme's dark --mut (about 1.5:1 on the panel);
     use the same light lavender the preview gives .tt .sub in the light theme.
   - the footer wordmark's first line is coloured through footer.html (var(--tx) instead of the preview's fixed #fff,
     which is white on the light page background). */
html[data-theme=light] .cta .sub{color:#d9ccf0}

/* skip link ("تخطَّ إلى المحتوى"): the first focusable element of every page (first line of header.html, target #main).
   Parked above the viewport until it takes keyboard focus, then it drops in at the start edge (the right side in RTL).
   Dark ink on white keeps the contrast in both themes; z-index sits above the sticky header (60) and the progress bar (200). */
.skip{position:absolute;top:-120px;inset-inline-start:12px;z-index:400;padding:11px 20px;border-radius:14px;background:#fff;color:#1B0E3A;font:600 15px/1.5 var(--fd);box-shadow:0 10px 30px #0008;transition:top .15s}
.skip:focus{top:12px;outline:3px solid var(--or);outline-offset:2px}

/* touch targets >= 44px.
   - theme button: 40px in base.css, 44px at every width (the header row is taller than that already: brand image 50px).
   - header social icons (.strip .soc a): 36px in base.css, 44px circles at <=820px (the icon inside stays 17px).
     Six of them need 6*44 + 5*6 = 294px, which fits from 334px up; below 360px the strip loses 10px of side padding per
     side and the icon gap drops to 2px (264 + 10 = 274px), so nothing runs past the viewport at 320px.
   - footer text links: 3px padding made them 30.5px high; at <=820px each link row is a 44px flex row (icon + text centred).
   - course list buttons (.cl .btn, courses page): 7px padding made them 36.75px high; 11px gives 44.75px at <=820px. */
.theme{width:44px;height:44px}
@media(max-width:820px){
  .strip .soc a{width:44px;height:44px}
  footer a{display:flex;align-items:center;min-height:44px;padding:10px 0}
  .cl .btn{padding-block:11px}
}
@media(max-width:359px){
  .strip{padding-inline:10px}
  .strip .soc{gap:2px}
}

/* horizontal overflow. The home ribbon is rotated (-1.6deg) and bleeds to the viewport edges with negative side margins, so
   its rotated corners stick out about 0.9px per side (320px: scrollWidth 321 > clientWidth 320, and a phone widens its layout
   viewport to fit it; 1280px: 1281 > 1280) and between 821px and 1280px its -40px margins stick out up to 20px. Nothing past
   the viewport edge is visible (body hid it), but it still counted as document overflow. Clipping at <body> instead removes
   it from the document at every width without moving anything:
   - base.css gives <body> overflow-x:hidden, which is propagated to the viewport and so clips nothing inside the document.
     With overflow-x:hidden on <html> the viewport keeps hiding the x axis (no horizontal scrolling, as before) and
     <body> is left free to clip its own content: overflow-x:clip, which unlike hidden creates no scroll container, so the
     sticky header, position:fixed items and the y axis behave exactly as before.
   - It sits inside @supports because a browser that knows overflow-x:hidden but not clip (Safari before 16) would otherwise
     turn <body> into a scroll container and break the sticky header; there the old behaviour stays. */
@supports (overflow-x:clip){
  html{overflow-x:hidden}
  body{overflow-x:clip}
}

/* إصلاحات موروثة من المعاينة (T4): */
/* 1) بطاقة الرؤية لا تتجاوز عرض الشاشة الضيقة */
.vm{grid-template-columns:repeat(auto-fit,minmax(min(320px,100%),1fr))}
/* 2) توهّج الشعار يبقى داخل حاويته حتى مع «تقليل الحركة» */
.ovis{position:relative}
/* 3) أشرطة توزيع CAPM: لا يُقصّ عنوان المجال ولا نسبته على الشاشات الضيقة */
@media(max-width:407px){.bar-row .lab{flex-wrap:wrap}}

/* ==========================================================================
   T5: course ring (carousel.js). The ring, arrows and dots are styled in components.css (verbatim from the preview);
   this adds what the script's DOM needs, the keyboard focus styles and the no-JavaScript fallback.
   ========================================================================== */
/* info block under the ring: the preview wrote these as inline styles on the generated elements */
.cinfo h2{font-size:clamp(20px,2.6vw,30px)}
.cinfo .sub-en{color:var(--mut);font-family:var(--fn)}
.cinfo .acts{margin-top:12px}
.cinfo .btn{padding:10px 26px}
.cinfo .btn+.btn{margin-inline-start:8px}

/* clicks must reach the badges. In the preserve-3d context the .stage is a plane at z=0 that the browser hit-tests before any badge
   sitting behind it (z<0, which is every badge but the front one), so only the front badge could be clicked. The stage takes no
   events (pointerdown on empty ring space still reaches .arc, the drag surface) and the badges take them (pointer-events inherits). */
.arc .stage{pointer-events:none}
.arc .it{pointer-events:auto}

/* focus-visible: components.css removes the ring outline (.arc{outline:none}) and styles no focus at all */
.arc:focus-visible{outline:3px solid var(--or);outline-offset:-5px;border-radius:30px}
.ar:focus-visible,.dot:focus-visible,.cinfo .btn:focus-visible{outline:3px solid var(--or);outline-offset:3px}

/* the dots are 9px wide: stretch their hit area to 17px x 45px (half the 8px gap each side, so neighbours never overlap) */
.dot{position:relative}
.dot:after{content:"";position:absolute;inset:-18px -4px}

/* no JavaScript: carousel.js fills the ring boxes, so without it they would be empty frames (the inline script in head.html adds
   class js). The home page hides its whole ring section; the courses page hides only the ring, because its static list (#clist,
   outside .stagebox) is the fallback and must stay. The heading after the ring then drops the gap that separated it from the ring. */
html:not(.js) .stagebox,html:not(.js) .ringsec{display:none}
html:not(.js) .stagebox+h2{margin-top:0!important}

/* ==========================================================================
   T6: badge-portal page transition (transition.js; the markup is in header.html, its base look in components.css).
   Timeline: click -> "in" (the circle opens from the click, 0.6s) -> navigation at 650ms -> the new page paints with
   html.portal-pending (the portal still covering) -> "out" (the circle closes on the new page, 0.5s, once the fonts are in).
   About 1.3s in total with the page cached; the preview needed 2.1s.
   ========================================================================== */
.portal.in{transition-duration:.6s}
.portal.out{transition-duration:.5s}
.pc{transition-duration:.4s,.5s}
.portal.in .pc{transition-delay:.12s}

/* The new page after a transition. head.html adds html.portal-pending before the first paint, so the portal is already covering
   with the badge shown (no flash of the page, no jump from the "in" phase) until transition.js plays "out" and removes the class.
   The page content stays hidden under it, and its entry animations (.rv) wait for the reveal.
   Safety net with no JavaScript at all: after 3s the cover and the hidden body release themselves, so the page can never stay blocked. */
@keyframes portal-free{to{visibility:visible}}
@keyframes portal-gone{to{visibility:hidden}}
html.portal-pending{background:#0A0615}
html.portal-pending body{visibility:hidden;animation:portal-free .01s 3s forwards}
html.portal-pending .portal{visibility:visible;pointer-events:all;clip-path:circle(150% at 50% 50%);animation:portal-gone .01s 3s forwards}
html.portal-pending .pc{opacity:1;transform:none}
html.portal-pending .page .rv{animation-play-state:paused}

/* transition.js moves focus to <main tabindex="-1"> after a transition: it is a landing spot, not a control, so no ring */
main:focus{outline:none}
