/* ============================================================
   Bakala Story Widget — story.css
   ============================================================ */

/* ── Slider / Thumbnails ── */
.story-section {
    width: 100%;
    overflow: hidden;
}
.story-section .swiper-container { padding: 10px 0; }
.story-section .swiper-slide { width: auto; text-align: center; padding: 0 3px;}

.story-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.story-image {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    position: relative;
    box-shadow: 0px 5px 6px 0px rgba(0,0,0,.40) inset;
}

.story-item .story-image::before {
    position: absolute;
    inset: 0;
    content: '';
    border-radius: 50%;
    background-color: rgba(0,0,0,0);
    z-index: 8;
    transition: background-color .3s;
}
.story-item:hover .story-image::before { background-color: rgba(0,0,0,.7); }

.story-item .story-image .story-image-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 0;
    transition: opacity .3s;
}
.story-item:hover .story-image .story-image-placeholder { opacity: 1; }
.story-item:hover .story-label { color: #424A62; font-size: 11px; font-weight: 600; }

.story-image-wrapper {
    padding: 12px;
    border-radius: 50%;
    background-size: cover;
    box-shadow:
        10px -10px 5px rgba(220,5,172,.06),
        0px 0px 5px rgba(235,53,44,.32),
        -10px 10px 5px rgba(245,155,8,.06),
        inset 10px -10px 5px rgba(220,5,172,.09),
        inset 0px 0px 5px rgba(235,53,44,.4),
        inset -10px 10px 5px rgba(245,155,8,.09);
}

.story-image-wrapper-wrapper {
    background: #fff;
    position: relative;
    padding: 8px;
}
.story-image-wrapper-wrapper::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    padding: 1px;
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask-composite: exclude;
    -webkit-mask-composite: destination-out;
}

/* ── برچسب story-time ── */
.story-time {
    position: absolute;
    bottom: -12px;
    right: 50%;
    transform: translateX(50%);
    border-radius: 4px;
    background: linear-gradient(262deg, #F09A09 -2.55%, #E60567 48.08%, #EC0642 104.01%);
    padding: 3px 4px;
    color: #fff;
    text-shadow: 0px 1px 0px rgba(0,0,0,.31);
    font-size: 10px;
    font-weight: 600;
    line-height: 11px;
    white-space: nowrap;
    z-index: 9;
}
.story-time::before {
    position: absolute;
    top: 2px;
    left: 0; right: 0; bottom: -2px;
    content: '';
    border-radius: 4px;
    background: linear-gradient(257deg, #F09A09 12.05%, #E60567 88.08%);
    filter: blur(2px);
    z-index: -1;
}

.story-label {
    margin-top: 10px;
    color: #76809C;
    font-size: 11px;
    font-weight: 700;
}

/* ── Wrapper (overlay) ── */
.story-wrapper {
    position: fixed !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 99999 !important;
    padding: 25px;
    background: rgba(0,0,0,.80);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    cursor: crosshair;
    display: flex;
    align-items: center;
    justify-content: center;
}
.story-wrapper-close-story { display: none; }
.story-wrapper-close-related { margin-right: auto; cursor: pointer; }

/* ── Story Slide ── */
.story-slide {
    display: grid;
    margin: 0;
    max-width: fit-content;
    max-height: 90vh;
    aspect-ratio: 9/16;
    position: relative;
    min-height: 80vh;
}
.story-slide img {
    display: block;
    max-width: 100%;
    max-height: 90vh;
    height: auto;
    width: 100%;
}

.story-slide-bg-1,
.story-slide-bg-2,
.story-slide-bg-3 {
    position: absolute;
    z-index: -1;
    border-radius: 20px;
    background: rgba(255,255,255,.08);
}
.story-slide-bg-1 { top:20px; bottom:20px; right:-12px; left:33px; }
.story-slide-bg-2 { top:48px; bottom:48px; right:-25px; left:33px; }
.story-slide-bg-3 { top:20px; bottom:20px; right:25px;  left:-12px; }

.story-slide-items {
    border-radius: 20px;
    grid-area: 1/1;
    overflow: hidden;
    position: relative;
}
.story-slide-items > * {
    opacity: 0;
    pointer-events: none;
    position: absolute;
    top: 0;
}
.story-slide-items .active {
    opacity: 1;
    pointer-events: initial;
    position: relative;
}

/* ── Nav & Thumbs ── */
.story-slide-nav {
    display: grid;
    grid-area: 1/1;
    grid-template-columns: 1fr 1fr;
    z-index: 1;
    height: calc(100% - 90px);
    align-self: end;
}
.story-slide-next,
.story-slide-prev {
    opacity: 0;
    -webkit-appearance: none;
    -webkit-tap-highlight-color: transparent;
}

/* thumb - defined below */

/* ── محصول مرتبط ── */
.story-related-products {
    position: absolute;
    top: 45px;
    right: 0; left: 0;
    margin: 0 20px;
    z-index: 10;
}
.story-related-related-product {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}
.story-related-related-product a {
    display: flex;
    gap: 7px;
    flex-direction: row;
    align-items: center;
    text-decoration: none;
}
.story-related-related-product a img {
    width: 33px;
    height: 33px;
    padding: 6px;
    border-radius: 10px;
    background: #fff;
}
.story-related-product-title {
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    border-radius: 10px;
    background: rgba(255,255,255,.10);
    padding: 0 10px;
    line-height: 37px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
}

/* ── Video Story ── */
.story-video-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    border-radius: 20px;
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    overflow: hidden;
    max-width: 100%;
    width: 100%;
    height: 100%;
}
.story-video-container video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center center;
    display: block;
    background: #000;
}
.video-story .story-related-products { top: 20px; }

.video-play-pause-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    position: absolute;
    inset: 0;
    z-index: 30;
}
.video-custom-controls {
    position: absolute;
    bottom: 20px;
    left: 0;
    display: flex;
    align-items: center;
    padding: 10px;
    z-index: 40;
    opacity: .8;
    width: 65%;
    transition: opacity .3s;
}
.story-video-container:hover .video-custom-controls { opacity: 1; }

.video-track-container { flex: 1; margin: 0 10px; }
.video-progress-bar {
    height: 4px;
    border-radius: 10px;
    background: rgba(255,255,255,.40);
    overflow: hidden;
    cursor: pointer;
}
.video-progress-fill {
    height: 100%;
    border-radius: 10px;
    background: #fff;
    width: 0%;
    transition: width .1s;
    float: left;
}
.video-time-display {
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 7px;
}

/* ── Bottom Bar (لایک / کامنت) ── */
.story-bottom-bar {
    position: absolute;
    bottom: 15px;
    right: 20px;
    display: flex;
    align-items: center;
    gap:28px;
    z-index: 50;
    width: 20%;
}
.story-bottom-bar button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
}
.story-slide-thumbs {
    display: flex;
    grid-column: 1 / 3;
    position: absolute;
    top: 20px;
    right: 20px;
    left: 20px;
    z-index:9999;
}
.story-slide-thumb-item {
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.30);
    display: block;
    flex: 1;
    height: 4px;
    margin: 5px;
    overflow: hidden;
    position: relative;
}

.story-slide-thumb-fill {
    position: absolute;
    top: 0;
    right: 0;
    transform-origin: right;
    height: 100%;
    width: var(--progress);
    background: #fff;
    border-radius: inherit;
    transition: width 0.2s linear;
}

.story-bottom-bar button span {
    color: #fff !important;
    font-size: 16px;
    font-weight: 600;

}
.story-bottom-bar button span.like-count{
    margin-top: 2px;
}
.story-bottom-bar button.liked svg   { fill: red; stroke: red; }
.story-bottom-bar button.processing  { opacity: .7; pointer-events: none; }

@keyframes like-animation {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.2); }
    100% { transform: scale(1); }
}
.story-bottom-bar button.liked { animation: like-animation .3s forwards; }

/* ── کامنت‌ها ── */
.story-comments {
    overflow-y: auto;
    border-radius: 20px;
    padding: 40px 15px;
    position: absolute;
    inset: 0;
    z-index: 100;
    background: linear-gradient(0deg, rgba(0,0,0,.80) 0%, rgba(0,0,0,.70) 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: none;
    flex-direction: column;
    justify-content: flex-end;
}
.story-comments-top-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: auto;
}
.story-comments-top-head span { color: #fff; font-size: 15px; font-weight: 700; }
.story-comments-top-head button,
.close-story-comments {
    outline: none;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
}
.story-comments-list { margin-bottom: 10px; overflow-y: scroll; }

.story-comment {
    padding: 10px 0;
    margin-bottom: 8px;
    display: flex;
    gap: 18px;
}
.story-comment-image {
    width: 36px; height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(47,49,50,.76);
    border-radius: 50%;
    flex-shrink: 0;
}
.story-comment-content { width: calc(100% - 54px); }
.story-comment-top { display: flex; gap: 15px; align-items: center; }
.comment-author  { color: #fff; font-size: 12px; font-weight: 800; }
.comment-text    { color: #fff; font-size: 12px; font-weight: 600; margin-top: 5px; background: transparent;padding: 10px;border-radius: 10px;border-color: rgba(255,255,255,.20);box-shadow: none;}
.comment-date    { color: rgba(255,255,255,.6); font-size: 10px; font-weight: 500; }
.loading-comments, .no-comments { text-align: center; padding: 15px; color: #888; }
.error-message { text-align: center; padding: 15px; color: #ff6b6b; }

/* ── Comment Form ── */
.story-comment-form {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    border-radius: 25px;
    border: 1px solid rgba(255,255,255,.20);
    padding: 5px;
    align-items: flex-end;
    color: #fff !important;
}
.story-comment-form textarea , .story-comment-form textarea::placeholder {
    width: 80%;
    color: #ccc !important;
    font-size: 12px;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    padding: 5px 10px;
    height: 32px !important;
    line-height: 1.7;
}
.story-comment-form .submit-comment {
    width: 20%;
    border-radius: 40px;
    background: #09f;
    border: none;
    cursor: pointer;
    color: #fff;
    padding: 8px 0;
}

/* ── Responsive ── */
@media (max-width: 992px) {
    .story-image  { width: 60px; height: 60px; }
    .story-time   { font-size: 9px; }
    .story-bottom-bar { gap:5px; }
    .story-bottom-bar button span {font-size: 14px}
    .story-slide  { margin: 12px auto; }
}

@media (max-width: 767px) {
    .story-bottom-bar          { padding: 0 0 0 10px; }
    .story-bottom-bar button   { padding: 3px 8px; margin-left: 5px; }
    .story-bottom-bar .like-count,
    .story-bottom-bar .comment-count { font-size: 10px; }
    .story-bottom-bar { gap:5px; }
    .story-bottom-bar button span {font-size: 12px}
}

/* ══════════════════════════════════════════════════════
   اضافه‌شده در v2
   ══════════════════════════════════════════════════════ */

/* ── حلقه رنگی با هاله گرادیانت ── */
.story-image-wrapper-wrapper { background: transparent !important; }
.story-image-wrapper {
    padding: 3px;
    border-radius: 50%;
    background: #fff;
}
/* هاله رنگی با CSS variable */
.story-image-wrapper.bk-story-ring {
    box-shadow:
        0 0 0 2px var(--bk-ring-color, #E60567),
        0 0 8px 3px color-mix(in srgb, var(--bk-ring-color, #E60567) 50%, transparent),
        10px -10px 6px color-mix(in srgb, var(--bk-ring-color, #E60567) 10%, transparent),
        -10px 10px 6px color-mix(in srgb, var(--bk-ring-color, #E60567) 10%, transparent);
    transition: box-shadow .3s;
}

/* ── سوییچ بین استوری‌ها ── */
.story-switch-btn {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,.15);
    backdrop-filter: blur(4px);
    border: none;
    border-radius: 50%;
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    z-index: 100000;
    transition: background .2s;
}
.story-switch-btn:hover { background: rgba(255,255,255,.3); }
.story-switch-prev { right: 21px; }
.story-switch-next { left:  25px; }

/* ── دکمه بستن ── */
.story-wrapper-close-story {
    position: absolute;
    top: 16px; right: 16px;
    background: rgba(0,0,0,.4);
    border: none; border-radius: 50%;
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    z-index: 300;
}

/* ── ناوبری داخل اسلاید ── */
.story-slide-prev,
.story-slide-next {
    position: absolute;
    top: 0; bottom: 0;
    width: 35%;
    background: transparent;
    border: none;
    z-index: 10;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.story-slide-prev { right: 0; }
.story-slide-next { left: 0; }

/* ── thumbs بالا ── */
/* thumb - defined below */

/* ── محصول مرتبط ── */
.story-related-products {
    position: absolute;
    top: 45px;
    right: 0; left: 0;
    margin: 0 15px;
    z-index: 30;
}
.story-related-products-list { width: 100%; }
.story-related-related-product {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.story-related-related-product a {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    flex: 1;
    min-width: 0;
}
.story-related-related-product a img {
    width: 40px; height: 40px;
    border-radius: 8px;
    background: #fff;
    object-fit: contain;
    flex-shrink: 0;
    padding: 4px;
}
.story-related-product-title {
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    background: rgba(255, 255, 255, 0.10);
    backdrop-filter: blur(3px);
    border-radius: 8px;
    padding: 2px 10px;
    flex: 1;
}
.story-wrapper-close-related {
    cursor: pointer;
    flex-shrink: 0;
    opacity: .8;
    transition: opacity .2s;
}
.story-wrapper-close-related:hover { opacity: 1; }

/* ── لینک پوشاننده تصویر ── */
.story-slide-link {
    position: absolute;
    inset: 0;
    z-index: 5;
}

/* ── فرم کامنت ── */
.story-login-notice {
    text-align: center;
    padding: 10px;
    color: rgba(255,255,255,.7);
    font-size: 13px;
}
.story-login-notice a { color: #09f; }

/* ── ویدیو fullscreen در استوری ── */

/* ── ویدیو ── */
.story-video-container video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center center;
    display: block;
    background: #000;
}
.story-slide-item .story-video-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── seen story ── */
.story-image-wrapper.bk-seen {
    box-shadow:
        0 0 0 2px #bbb !important,
        0 0 0 4px white !important;
    filter: grayscale(60%);
    opacity: .65;
    transition: all .3s;
}
.story-item:hover .story-image-wrapper.bk-seen {
    opacity: .9;
    filter: grayscale(20%);
}

/* ════════════════════════════════════════════════
   Fix v3
   ════════════════════════════════════════════════ */

/* ── seen story ── */
.story-image-wrapper.bk-seen {
    box-shadow: 0 0 0 2px #bbb !important;
    opacity: .55;
    transition: box-shadow .3s, opacity .3s;
}
.story-item:hover .story-image-wrapper.bk-seen { opacity: .85; }

/* ── ویدیو افقی: وسط‌چین ── */
.story-slide-item .story-video-container video {
    object-fit: contain;
    object-position: center center;
    background: #000;
}

/* ── سوییچ دسکتاپ ── */
.story-switch-prev,
.story-switch-next {
    display: flex !important;
}

/* ── story-slide-items کلیک‌پذیر ── */
.story-slide-items {
    cursor: pointer;
}
.story-slide-items .story-bottom-bar,
.story-slide-items .story-related-products,
.story-slide-items a,
.story-slide-items button,
.story-slide-items video {
    cursor: auto;
}
.story-slide-item .story-video-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    max-height: 90vh;
    aspect-ratio: 9 / 16;
    position: relative;
    min-height: 80vh;
}
.story-slide-item > img {
    max-height: 90vh;
    aspect-ratio: 9 / 16;
    object-fit: contain;
    min-height: 80vh;
}
/* ── Thumbs progress bar ── */

.story-slide-thumb-item {
    flex: 1;
    height: 3px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.35); /* زمینه تیره */
    overflow: hidden;
    position: relative;
    --progress: 0%;
}


/* .story-slide-item > img{
    background:rgba(0,0,0,0.9)
} */
/* ══════════════════════════════════════════════════
   پس‌زمینه blur مثل اینستاگرام
   ══════════════════════════════════════════════════ */

/* هر اسلاید - فقط موقع active دیده بشه */
.story-slide-items .story-slide-item {
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 20px;
    background-color: #1a1a1a;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* ⭐ فقط اسلاید active دیده بشه */
.story-slide-items .story-slide-item.active {
    opacity: 1;
    pointer-events: initial;
    position: relative; /* ⭐ active برگرده به relative */
}

/* ⭐ لایه blur روی پس‌زمینه */
.story-slide-item.has-bg::before {
    content: '';
    position: absolute;
    inset: -20px;
    background-image: inherit;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: blur(40px) brightness(0.3);
    -webkit-filter: blur(40px) brightness(0.3);
    transform: scale(1.15);
    z-index: 0;
}

/* ⭐ تصویر اصلی - بالای blur */
.story-slide-item > img {
    position: relative;
    z-index: 1;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 20px;
    opacity: 1; /* ⭐ همیشه دیده بشه */
}

/* ⭐ ویدیو - بالای blur */
.story-slide-item .story-video-container {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
}

/* ⭐ ویدیو پس‌زمینه blur نمیخواد */
.story-slide-item:has(.story-video-container) {
    background: #000 !important;
}

.story-slide-item:has(.story-video-container)::before {
    display: none;
}
/* ════════════════════════════════════════════════
   Fix v4 - thumb fill + hold to pause
   ════════════════════════════════════════════════ */

/* ── thumb fill - از CSS variable استفاده می‌کنه ── */
/* JS مقدار --progress رو set می‌کنه */

/* ── حذف دکمه play/pause وسط در حالت عادی ── */
.video-play-pause-btn {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ── نمایش pause icon موقع hold ── */
.story-video-container.is-paused::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.3);
    z-index: 20;
    pointer-events: none;
}