/* =====================================================================
   هيرو صفحة الدورات — مسقط طابق على ورق مخطط غامق
   كل قاعة = تصنيف، والممر = كل الدورات. الكلاسات بتبلش بـ ch-
   (الرسم والتفاعل: assets/js/courses-hero.js)
   ===================================================================== */

.ch {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  color: #fff;
  background-color: var(--dh-ink);
  background-image: radial-gradient(70% 60% at 85% 20%, rgba(217, 169, 63, 0.09), transparent 65%);
}

/* الشبكة + الضو حوالين الماوس (نفس فكرة الفوتر) */
.ch__grid,
.ch__glow {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(var(--c) 1px, transparent 1px),
    linear-gradient(90deg, var(--c) 1px, transparent 1px),
    linear-gradient(var(--c2) 1px, transparent 1px),
    linear-gradient(90deg, var(--c2) 1px, transparent 1px);
  background-size: 80px 80px, 80px 80px, 16px 16px, 16px 16px;
  background-position: center top;
}
.ch__grid {
  --c: rgba(217, 235, 235, 0.06);
  --c2: rgba(217, 235, 235, 0.025);
  -webkit-mask-image: linear-gradient(to bottom, #000 70%, transparent);
  mask-image: linear-gradient(to bottom, #000 70%, transparent);
}
.ch__glow {
  --c: rgba(242, 210, 127, 0.4);
  --c2: rgba(242, 210, 127, 0.14);
  opacity: 0;
  transition: opacity 0.5s ease;
  -webkit-mask-image: radial-gradient(circle 220px at var(--mx, 50%) var(--my, 50%), #000, transparent 75%);
  mask-image: radial-gradient(circle 220px at var(--mx, 50%) var(--my, 50%), #000, transparent 75%);
}
.ch.is-lit .ch__glow { opacity: 1; }

.ch__in {
  display: grid;
  gap: 2.75rem;
  padding-top: clamp(7rem, 16vw, 8.5rem);
  padding-bottom: 2.5rem;
}
@media (min-width: 1024px) {
  .ch__in {
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    align-items: center;
    gap: clamp(2rem, 4vw, 4.5rem);
    min-height: calc(100svh - 3.2rem);
    padding-top: 6.5rem;
    padding-bottom: 2rem;
  }
}

/* ---------- النص ---------- */
.ch__title {
  margin-top: 1.5rem;
  font-size: clamp(2.9rem, 1.6rem + 4.6vw, 5.6rem);
  font-weight: 900;
  line-height: 1.12;
  letter-spacing: -0.02em;
}
.ch__title em {
  font-style: normal;
  color: transparent;
  /* الكلمة بتتعبّى ذهبي من اليمين لليسار */
  background:
    linear-gradient(135deg, var(--dh-gold-light), var(--dh-gold)) no-repeat right / 0% 100%,
    #fff;
  -webkit-background-clip: text;
  background-clip: text;
  transition: background-size 1.4s var(--dh-ease-io) 0.7s;
}
.is-visible .ch__title em { background-size: 100% 100%; }

.ch__lead {
  margin-top: 1.3rem;
  max-width: 30rem;
  font-size: clamp(1.05rem, 0.95rem + 0.4vw, 1.25rem);
  line-height: 1.85;
  color: rgba(217, 235, 235, 0.74);
}

/* أرقام بشكل جدول لوحة */
.ch__stats {
  margin-top: 2rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 30rem;
  border: 1px solid rgba(217, 235, 235, 0.16);
}
.ch__stats > div {
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-end;
  gap: 0.2rem;
  padding: 0.9rem 1rem 0.85rem;
}
.ch__stats > div + div { border-inline-start: 1px solid rgba(217, 235, 235, 0.16); }
.ch__stats dd {
  font-family: var(--dh-mono);
  font-size: clamp(1.6rem, 1.2rem + 1.2vw, 2.25rem);
  font-weight: 500;
  line-height: 1.1;
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.ch__stats dt {
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(217, 235, 235, 0.6);
}

.ch__cta {
  margin-top: 2rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
}
.ch__cta .ds-btn svg { transform: rotate(-90deg); }
.ch__cta .ds-btn:hover svg { transform: rotate(-90deg) translateX(-4px); }
.ch__hint {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: rgba(217, 235, 235, 0.62);
}
.ch__hint svg { width: 1.1rem; height: 1.1rem; color: var(--dh-gold); flex-shrink: 0; }

/* دخول النص: عنصر ورا عنصر */
.ch-up {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.8s ease, transform 1s var(--dh-ease);
  transition-delay: calc(var(--i, 0) * 110ms + 150ms);
}
.is-visible .ch-up { opacity: 1; transform: none; }

/* ---------- المخطط ---------- */
.ch-plan { margin: 0; }
.ch-plan__box {
  position: relative;
  width: 100%;
  aspect-ratio: 1.32;
  min-height: 300px;
  max-height: calc(100svh - 10rem);
}
@media (max-width: 1023px) {
  .ch-plan__box { aspect-ratio: 1.25; max-height: none; }
}
@media (max-width: 639px) {
  .ch-plan__box { aspect-ratio: auto; height: min(560px, 135vw); min-height: 420px; }
}

.ch-svg {
  direction: ltr;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}
.ch-svg .l {
  fill: none;
  stroke: rgba(217, 235, 235, 0.8);
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1 2;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 1.3s var(--dh-ease-io) var(--d, 0s);
}
.ch-svg .w { stroke: #e3f0f0; stroke-width: 1.5; }
.ch-svg .p { stroke: #e3f0f0; stroke-width: 2.4; stroke-linecap: square; }
.ch-svg .t { stroke: rgba(217, 235, 235, 0.45); stroke-width: 0.8; }
.ch-svg .g { stroke: var(--dh-gold-light); }
.ch-svg .ax {
  fill: none;
  stroke: rgba(242, 210, 127, 0.22);
  stroke-width: 0.8;
  stroke-dasharray: 12 3 2 3;
  opacity: 0;
  transition: opacity 0.9s ease var(--d, 0s);
}
.ch-svg .fade { opacity: 0; transition: opacity 0.8s ease var(--d, 0s); }
.ch-svg .hatch { fill: url(#chHatch); }
.ch-svg .col { fill: #e3f0f0; }
.ch-svg .cut { fill: var(--dh-ink); }
.ch-svg .bub { fill: var(--dh-ink); stroke: rgba(242, 210, 127, 0.55); stroke-width: 1; }
.ch-svg text { font-family: Cairo, sans-serif; font-size: 11px; font-weight: 600; fill: rgba(217, 235, 235, 0.72); }
.ch-svg text.m { font-family: var(--dh-mono); font-size: 9.5px; font-weight: 500; fill: var(--dh-gold-light); }
.ch-svg text.g { fill: var(--dh-gold-light); font-size: 10.5px; font-weight: 700; }
.ch-svg text.cap { font-size: 11.5px; font-weight: 700; fill: rgba(217, 235, 235, 0.7); }

.ch-plan.is-drawn .ch-svg .l { stroke-dashoffset: 0; }
.ch-plan.is-drawn .ch-svg .fade,
.ch-plan.is-drawn .ch-svg .ax { opacity: 1; }

/* ---------- القاعات (أزرار) ---------- */
.ch-rooms { position: absolute; inset: 0; }
.ch-room,
.ch-hall {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--w);
  height: var(--h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.4rem;
  text-align: center;
  color: #fff;
  cursor: pointer;
  opacity: 0;
}
.ch-plan.is-drawn .ch-room,
.ch-plan.is-drawn .ch-hall { animation: ch-in 0.8s var(--dh-ease) var(--d, 0s) both; }

/* تعبئة مهشّرة ذهبية للقاعة المختارة/تحت الماوس */
.ch-room::before,
.ch-hall::before {
  content: "";
  position: absolute;
  inset: 0;
  background-color: rgba(217, 169, 63, 0.08);
  background-image: repeating-linear-gradient(-45deg, rgba(242, 210, 127, 0.16) 0 1px, transparent 1px 7px);
  opacity: 0;
  transition: opacity 0.35s ease, background-color 0.35s ease;
}
.ch-room > *,
.ch-hall > * { position: relative; }
.ch-room:focus-visible,
.ch-hall:focus-visible { outline: 2px solid var(--dh-gold); outline-offset: -3px; }
.ch-room:focus-visible::before,
.ch-room[aria-pressed="true"]::before,
.ch-hall[aria-pressed="true"]::before { opacity: 1; }
.ch-room[aria-pressed="true"]::before { background-color: rgba(217, 169, 63, 0.16); }
.ch-room[aria-pressed="true"] { box-shadow: inset 0 0 0 1.5px var(--dh-gold); }

.ch-room { container-type: size; gap: 0.1rem; }
.ch-room__no {
  position: absolute;
  top: 0.4rem;
  right: 0.45rem;
  padding: 0.12rem 0.32rem;
  border: 1px solid rgba(242, 210, 127, 0.38);
  font-family: var(--dh-mono);
  font-size: 0.66rem;
  font-weight: 500;
  line-height: 1.2;
  color: var(--dh-gold-light);
  transition: background-color 0.3s ease, color 0.3s ease;
}
/* الرقم بعيد عن الباب (الباب دايماً عجهة الممر) */
.ch-room[data-side="bottom"] .ch-room__no { top: auto; bottom: 0.4rem; }
.ch-room[data-side="left"] .ch-room__no { right: auto; left: 0.45rem; }
.ch-room[aria-pressed="true"] .ch-room__no { background: var(--dh-gold); border-color: var(--dh-gold); color: var(--dh-ink); }
.ch-room__type {
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(217, 235, 235, 0.55);
}
.ch-room__name {
  font-size: clamp(0.88rem, 0.72rem + 0.45vw, 1.08rem);
  font-weight: 800;
  line-height: 1.3;
  transition: color 0.3s ease, opacity 0.3s ease;
}
.ch-room__meta {
  margin-top: 0.1rem;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  color: rgba(217, 235, 235, 0.7);
  transition: opacity 0.3s ease;
}
.ch-room[aria-pressed="true"] .ch-room__name { color: var(--dh-gold-light); }

/* القاعات الصغيرة: أخفي التفاصيل الزايدة */
@container (max-height: 88px) { .ch-room__type { display: none; } }
@container (max-height: 56px) { .ch-room__meta { display: none; } }
@container (max-width: 104px) {
  .ch-room__name { font-size: 0.8rem; }
  .ch-room__meta { font-size: 0.66rem; }
}
@container (max-width: 74px) { .ch-room__no { display: none; } }

/* الممر */
.ch-hall { flex-direction: row; }
.ch-hall__in {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
  font-size: 0.78rem;
  font-weight: 700;
  color: rgba(217, 235, 235, 0.72);
  transition: color 0.3s ease;
}
.ch-hall__in b { font-family: var(--dh-mono); font-weight: 500; color: var(--dh-gold-light); }
.ch-hall[aria-pressed="true"] .ch-hall__in { color: #fff; }
.ch-hall::before { background-color: rgba(217, 169, 63, 0.05); }
.ch-plan.is-vertical .ch-hall__in { transform: rotate(-90deg); }

@media (hover: hover) and (pointer: fine) {
  .ch-room:hover::before,
  .ch-hall:hover::before { opacity: 1; }
  .ch-room:hover .ch-room__name { color: var(--dh-gold-light); }
  .ch-hall:hover .ch-hall__in { color: #fff; }
  /* باقي القاعات بتخفت شوي */
  .ch-rooms:has(.ch-room:hover) .ch-room:not(:hover) .ch-room__name,
  .ch-rooms:has(.ch-room:hover) .ch-room:not(:hover) .ch-room__meta { opacity: 0.45; }
}

/* ---------- شريط اللوحة تحت الهيرو ---------- */
.ch-strip {
  position: relative;
  border-top: 1px solid rgba(217, 235, 235, 0.14);
}
.ch-strip__in {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  font-size: 0.78rem;
  color: rgba(217, 235, 235, 0.58);
}
.ch-strip__in > div {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.85rem 0;
}
.ch-strip__in b { font-family: var(--dh-mono); font-weight: 500; color: #fff; }
.ch-strip__in .ch-strip__note { grid-column: 1 / -1; border-top: 1px solid rgba(217, 235, 235, 0.1); }
.ch-strip__note b { font-family: Cairo, sans-serif; font-weight: 700; color: var(--dh-gold-light); }
@media (max-width: 767px) { .ch-strip__in .ch-strip__opt { display: none; } }
@media (min-width: 768px) {
  .ch-strip__in { grid-template-columns: auto auto auto 1fr; gap: 2.5rem; }
  .ch-strip__in .ch-strip__note { grid-column: auto; border-top: 0; justify-content: flex-end; }
}

@keyframes ch-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ---------- تقليل الحركة: كل شي مرسوم من الأول ---------- */
.ch-plan.is-static .ch-svg .l,
.ch-plan.is-static .ch-svg .fade,
.ch-plan.is-static .ch-svg .ax { transition: none; }
.ch-plan.is-static .ch-room,
.ch-plan.is-static .ch-hall { animation: none; opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .ch-up, .ch__title em, .ch__glow { transition: none; }
  .ch-up { opacity: 1; transform: none; }
  .ch__title em { background-size: 100% 100%; }
}
