/* ===================================================================
   site-header.css — الهيدر الموحّد لجميع صفحات المنصة (مطابق لهيدر index.html)
   يعمل على الديسكتوب والموبايل وفي الوضعين الفاتح والداكن.
   =================================================================== */

:is(.pg, body) .hx {
  --hv-navy: #1B1A5C;
  --hv-teal: #4338CA;
  --hv-org: #4338CA;
  background: linear-gradient(90deg, #F4FAFD 0%, #FFFFFF 46%, #CFEFF4 100%);
  border-bottom: 0;
  position: relative;
  z-index: 100;
}

html[data-theme=dark] :is(.pg, body) .hx {
  --hv-navy: #EEF0FF;
  --hv-teal: #22D3EE;
  --hv-org: #FFB04A;
  background: var(--bg, #08111F);
}

:is(.pg, body) .hx .hd {
  max-width: none;
  width: 100%;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  gap: clamp(12px, 1.3vw, 24px);
  min-height: clamp(78px, 6.2vw, 102px);
  padding-block: 14px;
  padding-inline-start: clamp(16px, 6vw, 110px);
  padding-inline-end: clamp(16px, 5vw, 96px);
}

/* الشعار: دورق تيل بسائل ذهبي متحرك + DR + اسم المدرّس */
:is(.pg, body) .hx .brand {
  display: inline-flex;
  align-items: center;
  gap: clamp(10px, 1.25vw, 18px);
  font: 800 clamp(22px, 2.2vw, 36px)/1.2 'Cairo', Tahoma, sans-serif;
  color: var(--hv-navy);
  margin-inline-end: auto;
  text-decoration: none;
  flex: 0 0 auto;
}

:is(.pg, body) .hx .brand .brand__cap {
  width: clamp(32px, 2.9vw, 48px);
  height: auto;
  aspect-ratio: 46/54;
  stroke: none;
  fill: none;
  color: #4338CA;
  transform-origin: 50% 65%;
  animation: brandFlaskShake 1.5s ease-in-out infinite;
  filter: drop-shadow(0 3px 8px rgba(11, 122, 113, .22));
  flex: none;
}

html[data-theme=dark] :is(.pg, body) .hx .brand .brand__cap {
  color: #22D3EE;
  filter: drop-shadow(0 3px 10px rgba(43, 208, 192, .32));
}

@keyframes brandFlaskShake {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  15% { transform: translateX(2.5px) rotate(9deg); }
  30% { transform: translateX(-2.5px) rotate(-9deg); }
  45% { transform: translateX(2px) rotate(7deg); }
  60% { transform: translateX(-2px) rotate(-7deg); }
  75% { transform: translateX(1px) rotate(4deg); }
}

:is(.pg, body) .hx .brand__name {
  display: inline-flex;
  align-items: baseline;
  gap: .32em;
  font-weight: 700;
}

:is(.pg, body) .hx .brand__dr {
  font-family: Georgia, 'Times New Roman', serif;
  font-weight: 800;
  font-size: 1.05em;
  letter-spacing: .03em;
  color: #4338CA;
}

html[data-theme=dark] :is(.pg, body) .hx .brand__dr {
  color: #22D3EE;
}

:is(.pg, body) .hx .brand__ruqaa {
  font-family: 'El Messiri', 'Cairo', sans-serif;
  font-weight: 700;
  font-size: 1.05em;
  line-height: 1.25;
}

@media (prefers-reduced-motion: reduce) {
  :is(.pg, body) .hx .brand .brand__cap { animation: none; }
}

/* الروابط: في الديسكتوب تظهر أفقيًا في الصفحات الداخلية، وتختفي في الصفحة الرئيسية التي تستخدم زر القائمة الجانبية (.dhm) */
:is(.pg, body) .hx .nav {
  display: flex;
  align-items: center;
  gap: clamp(4px, .6vw, 12px);
  margin-inline: auto;
}

@media (min-width: 721px) {
  :is(.pg, body) .hx:has(.dhm) .nav {
    display: none;
  }
  :is(.pg, body) .hx.has-user .dhm {
    order: 3;
  }
  :is(.pg, body) .hx.has-user .hs {
    order: 4;
  }
}

:is(.pg, body) .hx .nav a {
  padding: 9px 14px;
  border-radius: 999px;
  font: 700 16px/1.3 'Cairo', Tahoma, sans-serif;
  color: var(--hv-navy);
  white-space: nowrap;
  text-decoration: none;
  transition: background-color .2s, color .2s;
}

:is(.pg, body) .hx .nav a:hover,
:is(.pg, body) .hx .nav a[aria-current="page"] {
  background: color-mix(in srgb, #4338CA 12%, transparent);
  color: var(--hv-teal);
}

/* كبسولة النهاري/الليلي — أزرق سماوي مع دائرة بيضاء وشمس/هلال كحلي */
:is(.pg, body) .hx .he {
  margin-inline-start: clamp(8px, 1.4vw, 22px);
  display: flex;
  align-items: center;
  flex: none;
}

:is(.pg, body) .hx .tg {
  --tgw: clamp(70px, 5.2vw, 88px);
  --tgh: clamp(36px, 2.6vw, 44px);
  --thumb: calc(var(--tgh) - 8px);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: var(--tgw);
  height: var(--tgh);
  padding: 0 9px;
  border: 1.5px solid #96C9F4;
  border-radius: 999px;
  box-sizing: border-box;
  cursor: pointer;
  background: linear-gradient(135deg, #B5DBFA 0%, #D8EEFD 100%);
  box-shadow: 0 4px 14px rgba(105, 172, 230, .35), inset 0 2px 6px rgba(105, 172, 230, .28);
  transition: border-color .25s, box-shadow .25s, background .25s;
}

:is(.pg, body) .hx .tg::before {
  content: "";
  position: absolute;
  top: 2.5px;
  left: 3px;
  width: var(--thumb);
  height: var(--thumb);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 10px rgba(11, 28, 51, .18);
  transition: transform .28s cubic-bezier(.22, 1, .36, 1), background .25s, box-shadow .25s;
}

:is(.pg, body) .hx .tg .i {
  position: relative;
  z-index: 1;
  width: calc(var(--thumb) * .58);
  height: calc(var(--thumb) * .58);
  stroke-width: 2;
  fill: none;
  stroke: currentColor;
}

:is(.pg, body) .hx .tg .i:first-of-type { color: #12123A; }
:is(.pg, body) .hx .tg .i:first-of-type circle { fill: none; }
:is(.pg, body) .hx .tg .i:nth-of-type(2) { color: #12123A; fill: none; stroke: currentColor; opacity: .9; }

html[data-theme=dark] :is(.pg, body) .hx .tg {
  background: linear-gradient(135deg, #0D1F38, #163254);
  border-color: rgba(61, 214, 195, .42);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .45), inset 0 1px 2px rgba(255, 255, 255, .08);
}

html[data-theme=dark] :is(.pg, body) .hx .tg::before {
  transform: translateX(calc(var(--tgw) - var(--tgh) - 1px));
  background: #12123A;
  box-shadow: 0 2px 10px rgba(43, 208, 192, .4), inset 0 0 0 1.5px #22D3EE;
}

html[data-theme=dark] :is(.pg, body) .hx .tg .i:first-of-type { color: #22D3EE; opacity: .9; }
html[data-theme=dark] :is(.pg, body) .hx .tg .i:nth-of-type(2) { color: #38DFF5; opacity: 1; }

/* منطقة الحساب في الهيدر (#acct): زر إنشاء حساب المميّز أو زر البروفايل عند الدخول */
:is(.pg, body) .hx .hs {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

:is(.pg, body) .hx .hs .hl,
:is(.pg, body) .hx .hs .hb {
  display: none;
}

/* زر إنشاء حساب — لون وتنسيق وخط مميّز */
:is(.pg, body) .hx .hx-signup,
:is(.pg, body) .hx .dh-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 46px;
  padding: 0 22px;
  border-radius: 999px;
  background: linear-gradient(135deg, #1B1A5C 0%, #103A63 100%);
  color: #FFD479 !important;
  border: 1.5px solid rgba(255, 176, 46, .55);
  font: 800 15.5px/1 'El Messiri', 'Cairo', sans-serif;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 8px 18px -8px rgba(11, 38, 66, .55);
  transition: transform .2s, box-shadow .2s, filter .2s;
}

:is(.pg, body) .hx .hx-signup:hover,
:is(.pg, body) .hx .dh-cta:hover {
  transform: translateY(-2px);
  filter: brightness(1.06);
  box-shadow: 0 12px 22px -8px rgba(245, 158, 11, .45);
}

:is(.pg, body) .hx .hx-signup svg,
:is(.pg, body) .hx .dh-cta svg {
  width: 19px;
  height: 19px;
  flex: none;
  fill: #FFB02E;
  stroke: none;
}

html[data-theme=dark] :is(.pg, body) .hx .hx-signup,
html[data-theme=dark] :is(.pg, body) .hx .dh-cta {
  background: linear-gradient(135deg, #FFB02E 0%, #4338CA 100%);
  color: #071426 !important;
  border-color: rgba(255, 224, 130, .7);
}

html[data-theme=dark] :is(.pg, body) .hx .hx-signup svg,
html[data-theme=dark] :is(.pg, body) .hx .dh-cta svg {
  fill: #071426;
}

/* زر البروفايل عند تسجيل الدخول (يظهر على الشمال خالص) */
:is(.pg, body) .hx .hx-prof {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 4px 6px 4px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #4338CA 0%, #4F46E5 100%);
  color: #fff !important;
  border: 1.5px solid rgba(43, 208, 192, .5);
  font: 800 14px/1 'Cairo', Tahoma, sans-serif;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 8px 18px -8px rgba(11, 122, 113, .55);
  transition: transform .2s, box-shadow .2s;
}

:is(.pg, body) .hx .hx-prof:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px -8px rgba(11, 122, 113, .65);
}

:is(.pg, body) .hx .hx-prof__av {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .2);
  color: #fff;
  display: grid;
  place-items: center;
  flex: none;
}

:is(.pg, body) .hx .hx-prof__av svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
}

/* الخط البرتقالي تحت الهيدر */
:is(.pg, body) .hx .ac {
  height: 3px;
  background: linear-gradient(90deg, #22D3EE, #6366F1 50%, #4338CA);
}

/* =================== استجابة الموبايل (≤720px) — سطر واحد دائماً =================== */
@media (max-width: 720px) {
  :is(.pg, body) .hx .hd {
    flex-wrap: wrap;
    gap: 5px;
    padding: 10px 10px !important;
    min-height: 68px;
  }

  :is(.pg, body) .hx .brand {
    order: 1;
    flex: 1 1 auto;
    min-width: 0;
    margin-inline-end: auto;
    gap: 5px;
    font-size: clamp(13px, 3.6vw, 17px);
    min-height: 40px;
    white-space: nowrap;
  }

  :is(.pg, body) .hx .brand .brand__cap {
    width: clamp(18px, 4.8vw, 23px);
    display: block !important;
  }

  :is(.pg, body) .hx .he {
    order: 2;
    margin-inline-start: 2px;
  }

  :is(.pg, body) .hx {
    --tgw: 52px;
    --tgh: 28px;
    --tgi: 12px;
  }

  :is(.pg, body) .hx .tg {
    width: 52px;
    height: 28px;
    --thumb: 21px;
    padding: 0 6px;
  }

  :is(.pg, body) .hx .tg .i {
    width: 12px;
    height: 12px;
  }

  :is(.pg, body) .hx .tg::before {
    top: 2px;
    left: 2.5px;
    width: 21px;
    height: 21px;
  }

  html[data-theme=dark] :is(.pg, body) .hx .tg::before {
    transform: translateX(23px);
  }

  /* زر إنشاء حساب أو البروفايل ظاهر دائمًا في نفس السطر */
  :is(.pg, body) .hx .hs {
    order: 3;
    display: flex !important;
    width: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    gap: 4px;
  }

  /* عند تسجيل الدخول: البروفايل على أقصى الشمال مكان زر الهمبرجر */
  :is(.pg, body) .hx.has-user .hs {
    order: 4;
  }

  :is(.pg, body) .hx.has-user .hm {
    order: 3;
  }

  :is(.pg, body) .hx .hx-signup,
  :is(.pg, body) .hx .dh-cta {
    min-height: 33px;
    padding: 0 9px;
    font-size: 11.5px;
    gap: 4px;
  }

  :is(.pg, body) .hx .hx-signup svg,
  :is(.pg, body) .hx .dh-cta svg {
    width: 13px;
    height: 13px;
  }

  :is(.pg, body) .hx .hx-prof {
    min-height: 33px;
    padding: 2px 4px 2px 8px;
    font-size: 11.5px;
    gap: 4px;
  }

  :is(.pg, body) .hx .hx-prof__av {
    width: 23px;
    height: 23px;
  }

  :is(.pg, body) .hx .hm {
    order: 4;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: #fff;
    border: 1px solid #DCE5EC;
    flex: none;
  }

  html[data-theme=dark] :is(.pg, body) .hx .hm {
    background: var(--card, #15143A);
    border-color: var(--bd, #2D2B66);
  }

  :is(.pg, body) .hx .nav {
    order: 5;
    display: none;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    margin: 10px 0 0;
    padding: 10px 0 4px;
    gap: 2px;
    border-top: 1px solid var(--bd, #E2E4F0);
  }

  :is(.pg, body) .hx .nav a {
    padding: 10px 14px;
    font-size: 15.5px;
    border-radius: 10px;
    white-space: normal;
  }

  :is(.pg, body) .hx.is-open .nav {
    display: flex;
  }
}
