/* ==========================================================
   ویدیوهای دایره‌ای صفحه اول (سبک استوری اینستاگرام)
   ========================================================== */

/* --- ظرف هیرو + تیره‌شدن ملایم عکس + H1 وسط بنر --- */
.upseo-hero-wrap {
  --ust-size: 84px;
  --ust-header: 120px; /* ارتفاع تقریبی هدر؛ برای دیده‌شدن دایره‌ها در ورود اول */
  position: relative;
  max-width: 192rem;
  margin-inline: auto;
}
.upseo-hero-wrap .slide-item img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2560 / 1068;
  object-fit: cover;
  max-height: calc(100vh - var(--ust-header));
  max-height: calc(100svh - var(--ust-header));
  min-height: 220px;
}
.upseo-hero-wrap.has-stories .slide-item img { min-height: 420px; }
.upseo-hero-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: rgba(0, 0, 0, 0.22);
  z-index: 1;
}
.upseo-hero-wrap.has-stories::after {
  background:
    linear-gradient(to top, rgba(0, 0, 0, 0.62) 0%, rgba(0, 0, 0, 0.26) 42%, rgba(0, 0, 0, 0) 75%),
    rgba(0, 0, 0, 0.14);
}
.upseo-hero-title {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0 max(16px, 4vw);
  color: #fff;
  font-size: clamp(22px, 3.4vw, 46px);
  font-weight: 700;
  line-height: 1.6;
  text-align: center;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.55);
  pointer-events: none; /* کلیک روی بنر زیرش کار کند */
}
.upseo-hero-wrap.has-stories .upseo-hero-title {
  bottom: calc(var(--ust-size) + 64px);
}

/* --- ردیف دایره‌ها --- */
.ust-ring,
.ust-ring__in,
.ust-ring__in img,
.ust-ring__ph,
.ust-item__btn,
.ust-stage,
.ust-stage * { box-sizing: border-box; }

.ust-row {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  gap: 18px;
  margin: 0;
  padding: 16px max(16px, 2vw) 18px; /* پدینگ بالا: جلوگیری از بریده‌شدن حلقه هنگام زوم */
  list-style: none;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  pointer-events: none; /* لینک بنر زیر ردیف قابل کلیک بماند */
}
.ust-row::-webkit-scrollbar { display: none; }
.ust-item {
  flex: 0 0 auto;
  margin: 0;
  scroll-snap-align: center;
  pointer-events: auto;
}
/* وسط‌چین وقتی جا هست؛ اسکرول وقتی جا نیست */
.ust-item:first-child { margin-inline-start: auto; }
.ust-item:last-child { margin-inline-end: auto; }

.ust-item__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  width: calc(var(--ust-size) + 14px);
  padding: 0;
  border: 0;
  background: none;
  color: #fff;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ust-ring {
  display: block;
  width: var(--ust-size);
  height: var(--ust-size);
  padding: 3px;
  border-radius: 50%;
  background: linear-gradient(45deg, #f9ce34 0%, #ee2a7b 55%, #6228d7 100%);
  transition: transform 0.2s ease;
}
.ust-ring__in {
  display: block;
  width: 100%;
  height: 100%;
  padding: 2.5px;
  border-radius: 50%;
  background: #fff;
  overflow: hidden;
}
.ust-ring__in img,
.ust-ring__ph {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  background: var(--c-secondary-light, #faf3ea);
  color: var(--c-secondary-shade, #c19277);
  font-size: 26px;
  font-weight: 700;
}
.ust-item__btn:hover .ust-ring { transform: scale(1.05); }
.ust-item__btn:active .ust-ring { transform: scale(0.95); }
.ust-item__btn:focus-visible { outline: none; }
.ust-item__btn:focus-visible .ust-ring { box-shadow: 0 0 0 3px #fff; }
.ust-item.is-seen .ust-ring { background: rgba(255, 255, 255, 0.55); }
.ust-item__name {
  display: block;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  line-height: 1.4;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

@media (max-width: 767px) {
  .upseo-hero-wrap { --ust-size: 60px; --ust-header: 110px; }
  .upseo-hero-wrap.has-stories .slide-item img { min-height: 300px; }
  .upseo-hero-wrap.has-stories .upseo-hero-title { bottom: calc(var(--ust-size) + 52px); }
  .ust-row {
    gap: 12px;
    padding-top: 12px;
    padding-bottom: 10px;
  }
  .ust-item__name { font-size: 11px; }
  .ust-ring__ph { font-size: 20px; }
}

/* --- قفل اسکرول پشت مودال --- */
html.ust-lock { scroll-behavior: auto !important; }
html.ust-lock body {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  overflow: hidden;
}

/* --- مودال --- */
.ust-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  color: #fff;
  font-family: inherit;
}
.ust-modal[hidden] { display: none; }
.ust-modal.is-open { opacity: 1; }
.ust-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
}
@supports (backdrop-filter: blur(1px)) {
  .ust-backdrop {
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }
}

.ust-stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: #000;
  overflow: hidden;
  touch-action: none;
  will-change: transform;
  transform: scale(0.96);
  transition: transform 0.22s ease;
}
.ust-modal.is-open .ust-stage { transform: none; }
.ust-stage.is-dragging { transition: none; }

@media (min-width: 768px) {
  .ust-stage {
    width: auto;
    height: min(92vh, 880px);
    height: min(92dvh, 880px);
    aspect-ratio: 9 / 16;
    border-radius: 18px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  }
}

/* نوار پیشرفت */
.ust-bars {
  position: absolute;
  top: 0;
  inset-inline: 0;
  z-index: 4;
  display: flex;
  gap: 4px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 10px 0;
  pointer-events: none;
}
.ust-bar {
  flex: 1 1 0;
  height: 2.5px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.35);
  overflow: hidden;
}
.ust-bar i {
  display: block;
  width: 100%;
  height: 100%;
  background: #fff;
  transform: scaleX(0);
  transform-origin: right center; /* RTL */
}

/* هدر */
.ust-head {
  position: absolute;
  top: 0;
  inset-inline: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 22px) 12px 28px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
}
.ust-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: #333;
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  flex: 0 0 auto;
}
.ust-avatar[hidden] { display: none; }
.ust-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  margin-inline-end: auto;
  line-height: 1.35;
}
.ust-name {
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.ust-views {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  opacity: 0.9;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.ust-btn,
.ust-nav,
.ust-like {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: none;
  color: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ust-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5));
}
.ust-btn:active { background: rgba(255, 255, 255, 0.15); }
.ust-mute .ust-ico-off { display: none; }
.ust-mute.is-muted .ust-ico-on { display: none; }
.ust-mute.is-muted .ust-ico-off { display: block; }

/* ویدیو */
.ust-media {
  position: absolute;
  inset: 0;
  z-index: 1;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.ust-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
  pointer-events: none;
}
.ust-video.is-cover { object-fit: cover; }
.ust-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 38px;
  height: 38px;
  margin: -19px 0 0 -19px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  opacity: 0;
  pointer-events: none;
  animation: ust-spin 0.8s linear infinite;
  transition: opacity 0.15s;
}
.ust-modal.is-loading .ust-spinner { opacity: 1; }
@keyframes ust-spin { to { transform: rotate(360deg); } }
.ust-pause {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 68px;
  height: 68px;
  margin: -34px 0 0 -34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.ust-modal.is-paused .ust-pause { opacity: 1; }
.ust-error {
  position: absolute;
  inset-inline: 20px;
  top: 50%;
  transform: translateY(-50%);
  text-align: center;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
}
.ust-modal.has-error .ust-error { opacity: 1; }

/* پایین */
.ust-foot {
  position: absolute;
  bottom: 0;
  inset-inline: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 36px 14px calc(env(safe-area-inset-bottom, 0px) + 16px);
  background: linear-gradient(to top, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0));
}
.ust-cta {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ust-cta[hidden] { display: none; }
.ust-cta:active { background: rgba(255, 255, 255, 0.28); }
.ust-like-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-inline-start: auto;
  flex: 0 0 auto;
}
.ust-like {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5));
}
.ust-like .ust-heart-f { display: none; }
.ust-like.is-liked .ust-heart-o { display: none; }
.ust-like.is-liked .ust-heart-f { display: block; }
.ust-like.is-pop svg { animation: ust-pop 0.38s cubic-bezier(0.3, 1.6, 0.5, 1); }
@keyframes ust-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.35); }
  100% { transform: scale(1); }
}
.ust-like-n {
  min-width: 24px;
  font-size: 14px;
  font-weight: 600;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* قلب بزرگ با دابل‌تپ */
.ust-burst {
  position: absolute;
  z-index: 3;
  width: 96px;
  height: 96px;
  margin: -48px 0 0 -48px;
  pointer-events: none;
  animation: ust-burst 0.8s ease-out forwards;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4));
}
@keyframes ust-burst {
  0% { opacity: 0; transform: scale(0.3) rotate(-12deg); }
  25% { opacity: 1; transform: scale(1.15) rotate(6deg); }
  60% { opacity: 1; transform: scale(1) rotate(0); }
  100% { opacity: 0; transform: scale(1.3) translateY(-30px); }
}

/* دکمه‌های قبلی/بعدی فقط دسکتاپ */
.ust-nav {
  position: relative;
  z-index: 5;
  width: 44px;
  height: 44px;
  margin: 0 14px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  transition: background 0.15s;
}
.ust-nav:hover { background: rgba(255, 255, 255, 0.3); }
.ust-nav[hidden] { visibility: hidden; display: inline-flex; }
@media (max-width: 767px), (hover: none) {
  .ust-nav { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
  .ust-modal,
  .ust-stage,
  .ust-ring { transition: none; }
  .ust-like.is-pop svg,
  .ust-burst { animation: none; }
}
