/* ============================================================================
   Highlight Stories — استوری هایلایت (نسخه ۱.۰.۰)
   ----------------------------------------------------------------------------
   کامپوننت مستقل «استوری/هایلایت» به سبک اینستاگرام برای قالب Educeet / Vayad
   Self-contained Instagram-style Stories/Highlights component.

   - بدون هیچ وابستگی (No dependencies — pure CSS)
   - تمام کلاس‌ها با پیشوند hls- هستند تا با کلاس‌های قالب (it-*) تداخل نکنند
     All classes are prefixed with `hls-` so nothing collides with theme CSS.
   - از متغیرهای رنگ و فونت خودِ قالب استفاده می‌کند و اگر موجود نباشند،
     مقادیر پیش‌فرض برند جایگزین می‌شوند.
     Uses the theme's own CSS variables with brand fallbacks.
   ========================================================================== */

.hls-strip,
.hls-viewer {
  /* رنگ‌ها و فونت‌ها — Colors & fonts (edit here to re-brand) */
  --hls-ring-a: var(--it-theme-2, #F8C62F);   /* زرد برند */
  --hls-ring-b: var(--it-theme-3, #1AB69D);   /* فیروزه‌ای */
  --hls-ring-c: var(--it-theme-1, #03594E);   /* سبز تیره برند */
  --hls-ring-seen: var(--it-gray-2, #D9D9D9); /* حلقه دیده‌شده */
  --hls-title: var(--it-heading-primary, #0C121D);
  --hls-text: var(--it-text-body, #6C757D);
  --hls-ff-heading: var(--it-ff-heading, 'Peyda-Bold', sans-serif);
  --hls-ff-body: var(--it-ff-body, 'Peyda-Regular', sans-serif);
  --hls-ff-medium: var(--it-ff-jost, 'Peyda-Medium', sans-serif);
  /* اندازه‌ها — Sizing */
  --hls-size: 84px;            /* قطر حلقه در دسکتاپ */
  --hls-size-sm: 68px;         /* قطر حلقه در موبایل */
  --hls-ring-width: 3px;
  --hls-gap: 28px;
  --hls-z: 100000;             /* بالاتر از هدر چسبان قالب */
}

/* ============================== 1) نوار هایلایت‌ها — The strip ============ */

.hls-strip {
  position: relative;
  padding: 22px 0 14px;
}

/* برای صفحه‌هایی که هدرِ شفاف و شناور دارند (مثل instructor-showcase):
   این کلاس را به سکشن اضافه کنید تا نوار زیر هدر پنهان نشود.
   For pages with a transparent/absolute header, add this modifier
   to the wrapping section so the strip clears the floating header. */
.hls-area--under-transparent-header {
  padding-top: var(--hls-header-offset, 108px);
}
@media (max-width: 991.98px) {
  .hls-area--under-transparent-header { padding-top: var(--hls-header-offset-sm, 92px); }
}

.hls-strip__track {
  display: flex;
  align-items: flex-start;
  gap: var(--hls-gap);
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;             /* Firefox */
  scroll-snap-type: x proximity;
  padding: 6px 2px 10px;
}
.hls-strip__track::-webkit-scrollbar { display: none; } /* Chrome/Safari */

/* محو شدن لبه‌ها هنگام اسکرول — soft edge fade */
.hls-strip--fade .hls-strip__track {
  -webkit-mask-image: linear-gradient(to left, transparent 0, #000 34px, #000 calc(100% - 34px), transparent 100%);
          mask-image: linear-gradient(to left, transparent 0, #000 34px, #000 calc(100% - 34px), transparent 100%);
}

.hls-item {
  flex: 0 0 auto;
  width: calc(var(--hls-size) + 14px);
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* حلقه گرادیانی — the gradient ring */
.hls-item__ring {
  position: relative;
  width: var(--hls-size);
  height: var(--hls-size);
  border-radius: 50%;
  padding: var(--hls-ring-width);
  background: conic-gradient(from 210deg,
      var(--hls-ring-a), var(--hls-ring-b) 35%,
      var(--hls-ring-c) 62%, var(--hls-ring-a) 100%);
  transition: transform .35s cubic-bezier(.34,1.56,.64,1), filter .3s ease;
}
.hls-item__ring::before {              /* شکاف سفید بین حلقه و عکس */
  content: "";
  position: absolute;
  inset: var(--hls-ring-width);
  border-radius: 50%;
  background: var(--it-common-white, #fff);
}
.hls-item__cover {
  position: absolute;
  inset: calc(var(--hls-ring-width) + 3px);
  border-radius: 50%;
  overflow: hidden;
  transform: translateZ(0);
}
.hls-item__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .45s ease;
}

/* برچسب زیر حلقه — label */
.hls-item__label {
  max-width: calc(var(--hls-size) + 14px);
  font-family: var(--hls-ff-medium);
  font-size: 13px;
  line-height: 1.4;
  color: var(--hls-title);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color .25s ease;
}

/* حالت‌های تعامل — hover / focus / seen */
@media (hover: hover) {
  .hls-item:hover .hls-item__ring { transform: scale(1.06); }
  .hls-item:hover .hls-item__cover img { transform: scale(1.08); }
  .hls-item:hover .hls-item__label { color: var(--hls-ring-c); }
}
.hls-item:active .hls-item__ring { transform: scale(.97); }
.hls-item:focus-visible { outline: none; }
.hls-item:focus-visible .hls-item__ring {
  outline: 2px solid var(--hls-ring-c);
  outline-offset: 3px;
}
.hls-item.is-seen .hls-item__ring {
  background: var(--hls-ring-seen);
}
.hls-item.is-seen .hls-item__label { color: var(--hls-text); }

/* پالس ملایم برای آیتم‌های دیده‌نشده — subtle attention pulse */
@keyframes hls-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(26, 182, 157, .35); }
  55%      { box-shadow: 0 0 0 9px rgba(26, 182, 157, 0); }
}
.hls-item:not(.is-seen) .hls-item__ring { animation: hls-pulse 3.2s ease-in-out infinite; }

/* ============================== 2) نمایشگر استوری — The viewer =========== */

.hls-viewer {
  position: fixed;
  inset: 0;
  z-index: var(--hls-z);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(9, 12, 16, .55);
  opacity: 0;
  pointer-events: none;
  transition: opacity .28s ease;
}
.hls-viewer::before {                  /* بک‌دراپ تار — blurred backdrop */
  content: "";
  position: absolute;
  inset: 0;
  backdrop-filter: blur(20px) saturate(.8);
  -webkit-backdrop-filter: blur(20px) saturate(.8);
  background: rgba(9, 12, 16, .38);
}
.hls-viewer.is-open {
  opacity: 1;
  pointer-events: auto;
}
.hls-viewer * { box-sizing: border-box; }

/* صحنه ۹:۱۶ — the 9:16 stage */
.hls-viewer__stage {
  position: relative;
  z-index: 1;
  width: min(min(92dvh, 92vh) * 9 / 16, calc(100vw - 32px));
  aspect-ratio: 9 / 16;
  max-height: min(92dvh, 92vh);
  border-radius: 20px;
  overflow: hidden;
  background: #101318;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
  transform: scale(.88);
  transition: transform .32s cubic-bezier(.22,1,.36,1);
  touch-action: none;      /* سوایپ‌ها را خودمان مدیریت می‌کنیم، نه اسکرول مرورگر */
  user-select: none;
  -webkit-user-select: none;
}
.hls-viewer.is-open .hls-viewer__stage { transform: scale(1); }

/* جابه‌جایی بین استوری‌ها — story switch animation */
@keyframes hls-stage-in-next { from { transform: translateX(-6%) scale(.94); opacity: .2; } to { transform: none; opacity: 1; } }
@keyframes hls-stage-in-prev { from { transform: translateX(6%)  scale(.94); opacity: .2; } to { transform: none; opacity: 1; } }
.hls-viewer__stage.hls-anim-next { animation: hls-stage-in-next .34s cubic-bezier(.22,1,.36,1); }
.hls-viewer__stage.hls-anim-prev { animation: hls-stage-in-prev .34s cubic-bezier(.22,1,.36,1); }
/* در حالت چپ‌به‌چین جهت انیمیشن برعکس می‌شود — mirrored for LTR sites */
[dir="ltr"] .hls-viewer__stage.hls-anim-next { animation-name: hls-stage-in-prev; }
[dir="ltr"] .hls-viewer__stage.hls-anim-prev { animation-name: hls-stage-in-next; }

/* رسانه — media */
.hls-viewer__media {
  position: absolute;
  inset: 0;
}
.hls-viewer__media img,
.hls-viewer__media video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  -webkit-user-drag: none;  /* جلوگیری از درگِ بومی تصویر که سوایپ را خراب می‌کند */
  user-select: none;
  -webkit-user-select: none;
}
@keyframes hls-media-in { from { opacity: 0; transform: scale(1.045); } to { opacity: 1; transform: scale(1); } }
.hls-viewer__media.is-entering > * { animation: hls-media-in .45s ease both; }

/* اسکریم‌های بالا و پایین برای خوانایی — readability scrims */
.hls-viewer__stage::before,
.hls-viewer__stage::after {
  content: "";
  position: absolute;
  left: 0; right: 0;
  z-index: 2;
  pointer-events: none;
}
.hls-viewer__stage::before {
  top: 0;
  height: 110px;
  background: linear-gradient(to bottom, rgba(0,0,0,.55), transparent);
}
.hls-viewer__stage::after {
  bottom: 0;
  height: 130px;
  background: linear-gradient(to top, rgba(0,0,0,.5), transparent);
}

/* نوارهای پیشرفت — progress segments */
.hls-viewer__progress {
  position: absolute;
  top: 10px;
  left: 12px; right: 12px;
  z-index: 5;
  display: flex;
  gap: 4px;
}
.hls-viewer__bar {
  flex: 1;
  height: 3px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .32);
  overflow: hidden;
}
.hls-viewer__bar i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: #fff;
  transform: scaleX(0);
  transform-origin: right center;      /* RTL: پر شدن از راست */
}
[dir="ltr"] .hls-viewer__bar i { transform-origin: left center; }
.hls-viewer__bar.is-done i { transform: scaleX(1); }

/* هدر نمایشگر — viewer header */
.hls-viewer__head {
  position: absolute;
  top: 22px;
  left: 12px; right: 12px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
}
.hls-viewer__avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: hidden;
  flex: 0 0 auto;
  border: 2px solid rgba(255,255,255,.85);
}
.hls-viewer__avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hls-viewer__titles { min-width: 0; }
.hls-viewer__title {
  font-family: var(--hls-ff-heading);
  font-size: 15px;
  line-height: 1.3;
  margin: 0;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 8px rgba(0,0,0,.4);
}
.hls-viewer__subtitle {
  font-family: var(--hls-ff-body);
  font-size: 12px;
  color: rgba(255,255,255,.75);
  margin: 1px 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hls-viewer__actions {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* دکمه‌های شیشه‌ای — glass buttons */
.hls-btn {
  appearance: none;
  border: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.14);
  color: #fff;
  cursor: pointer;
  transition: background .2s ease, transform .2s ease;
  -webkit-tap-highlight-color: transparent;
}
.hls-btn:hover { background: rgba(255,255,255,.28); }
.hls-btn:active { transform: scale(.92); }
.hls-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.hls-btn svg { width: 18px; height: 18px; display: block; }
.hls-btn[hidden] { display: none; }

/* کپشن — caption */
.hls-viewer__caption {
  position: absolute;
  bottom: 24px;
  left: 18px; right: 18px;
  z-index: 4;
  color: #fff;
  text-align: start;
}
.hls-viewer__caption h4 {
  font-family: var(--hls-ff-heading);
  font-size: 21px;
  line-height: 1.45;
  margin: 0 0 6px;
  color: #fff;
  text-shadow: 0 2px 14px rgba(0,0,0,.45);
}
.hls-viewer__caption p {
  font-family: var(--hls-ff-body);
  font-size: 14px;
  line-height: 1.8;
  margin: 0;
  color: rgba(255,255,255,.92);
  text-shadow: 0 1px 10px rgba(0,0,0,.4);
}
@keyframes hls-caption-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.hls-viewer__caption.is-entering > * { animation: hls-caption-in .5s .12s ease both; }

/* دکمه اقدام (CTA) — call-to-action pill */
.hls-viewer__cta {
  position: absolute;
  bottom: 24px;
  inset-inline-end: 18px;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 99px;
  background: var(--it-theme-2, #F8C62F);
  color: var(--it-heading-primary, #0C121D);
  font-family: var(--hls-ff-heading);
  font-size: 13.5px;
  text-decoration: none;
  box-shadow: 0 10px 26px rgba(0,0,0,.35);
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .25s ease;
}
.hls-viewer__cta:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 30px rgba(0,0,0,.4);
  color: var(--it-heading-primary, #0C121D);
}
.hls-viewer__cta svg { width: 15px; height: 15px; }
.hls-viewer__cta[hidden] { display: none; }
/* اگر کپشن و CTA هم‌زمان باشند، کپشن بالاتر می‌نشیند */
.hls-viewer__stage.has-cta .hls-viewer__caption { bottom: 86px; }

/* نواحی لمس رفت/برگشت — tap zones */
.hls-viewer__tap {
  position: absolute;
  top: 70px;
  bottom: 90px;
  width: 38%;
  z-index: 3;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.hls-viewer__tap:focus-visible { outline: none; }
.hls-viewer__tap--next { inset-inline-end: 0; }   /* RTL: «بعدی» سمت چپ صفحه */
.hls-viewer__tap--prev { inset-inline-start: 0; } /* RTL: «قبلی» سمت راست صفحه */

/* فلش‌های دسکتاپ — desktop arrows (outside the stage) */
.hls-viewer__arrow {
  position: absolute;
  top: 50%;
  z-index: 2;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.12);
  color: #fff;
  cursor: pointer;
  transition: background .2s ease, transform .2s ease;
}
.hls-viewer__arrow:hover { background: rgba(255,255,255,.26); }
.hls-viewer__arrow:active { transform: translateY(-50%) scale(.92); }
.hls-viewer__arrow svg { width: 20px; height: 20px; }
.hls-viewer__arrow--next { inset-inline-end:   max(18px, calc(50% - min(min(92dvh, 92vh) * 9 / 32, 50vw) - 78px)); }
.hls-viewer__arrow--prev { inset-inline-start: max(18px, calc(50% - min(min(92dvh, 92vh) * 9 / 32, 50vw) - 78px)); }
.hls-viewer__arrow[disabled] { opacity: .25; cursor: default; }
.hls-viewer__arrow[disabled]:hover { background: rgba(255,255,255,.12); }

/* نشانگر مکث و لودینگ — pause & loading indicators */
.hls-viewer__spinner {
  position: absolute;
  top: 50%; left: 50%;
  z-index: 4;
  width: 42px; height: 42px;
  margin: -21px 0 0 -21px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.25);
  border-top-color: #fff;
  animation: hls-spin .8s linear infinite;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.hls-viewer__spinner.is-visible { opacity: 1; }
@keyframes hls-spin { to { transform: rotate(360deg); } }

.hls-viewer__paused {
  position: absolute;
  top: 50%; left: 50%;
  z-index: 4;
  transform: translate(-50%, -50%) scale(.8);
  width: 58px; height: 58px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.45);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.hls-viewer__paused.is-visible { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.hls-viewer__paused svg { width: 22px; height: 22px; }

/* ============================== 3) موبایل — Mobile ======================= */

@media (max-width: 767.98px) {
  .hls-strip { padding: 16px 0 8px; }
  .hls-strip,
  .hls-viewer { --hls-size: var(--hls-size-sm); --hls-gap: 18px; }
  .hls-item__label { font-size: 12px; }

  .hls-viewer { align-items: stretch; }
  .hls-viewer__stage {
    width: 100vw;
    max-height: none;
    height: 100dvh;
    aspect-ratio: auto;
    border-radius: 0;
  }
  .hls-viewer__arrow { display: none; }         /* در موبایل: لمس و سوایپ */
  .hls-viewer__progress { top: max(10px, env(safe-area-inset-top)); }
  .hls-viewer__head { top: calc(max(10px, env(safe-area-inset-top)) + 12px); }
  .hls-viewer__caption { bottom: calc(24px + env(safe-area-inset-bottom)); }
  .hls-viewer__cta { bottom: calc(24px + env(safe-area-inset-bottom)); }
  .hls-viewer__stage.has-cta .hls-viewer__caption { bottom: calc(86px + env(safe-area-inset-bottom)); }
}

/* حرکت کمتر — reduced motion */
@media (prefers-reduced-motion: reduce) {
  .hls-item__ring,
  .hls-item__cover img,
  .hls-viewer,
  .hls-viewer__stage,
  .hls-viewer__cta { transition: none; }
  .hls-item:not(.is-seen) .hls-item__ring { animation: none; }
  .hls-viewer__stage.hls-anim-next,
  .hls-viewer__stage.hls-anim-prev,
  .hls-viewer__media.is-entering > *,
  .hls-viewer__caption.is-entering > * { animation: none; }
}

/* جلوگیری از اسکرول بدنه وقتی استوری باز است — body scroll lock */
body.hls-lock { overflow: hidden; }

.hls-viewer__html {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    overflow: auto;
    color: #fff;
    background: linear-gradient(160deg,#4f46e5,#9333ea);
}

#courseHighlights .title,
#courseHighlights .subtitle {
    direction: rtl;
    unicode-bidi: plaintext;
}
