/* ============================================================
   Bakala Story Widget – story-widget.css
   ============================================================ */

/* ---------- CSS Variables ---------- */
:root {
    --bakala-ring-1:  #F09A09;
    --bakala-ring-2:  #E60567;
    --bakala-ring-3:  #EC0642;
    --bakala-badge-1: #F09A09;
    --bakala-badge-2: #E60567;
    --bakala-liked-color: #ff0000;
}

/* ---------- Slider wrapper ---------- */
.bakala-story-slider {
    width: 100%;
    overflow: hidden;
    position: relative;
}
.bakala-story-slider .swiper-container { padding: 10px 0; }
.bakala-story-slider .swiper-slide { width: auto; text-align: center; }

/* ---------- Story Item (thumbnail) ---------- */
.bakala-story-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.bakala-story-image-wrapper-wrapper {
    background: #fff;
    position: relative;
    padding: 3px;
    border-radius: 50%;
}
.bakala-story-image-wrapper-wrapper::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    padding: 3px;
    background: linear-gradient(0deg, rgb(226,234,243), #fff);
    mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    mask-composite: exclude;
    -webkit-mask-composite: destination-out;
}
.bakala-story-image-wrapper {
    padding: 3px;
    border-radius: 50%;
    background: linear-gradient(135deg,
        var(--ring-color-1, var(--bakala-ring-1)),
        var(--ring-color-2, var(--bakala-ring-2)),
        var(--ring-color-3, var(--bakala-ring-3))
    );
    box-shadow:
        10px -10px 5px rgba(220,5,172,.06),
        0 0 5px rgba(235,53,44,.32),
        -10px 10px 5px rgba(245,155,8,.06),
        inset 10px -10px 5px rgba(220,5,172,.09),
        inset 0 0 5px rgba(235,53,44,.4),
        inset -10px 10px 5px rgba(245,155,8,.09);
}
.bakala-story-image {
    width: 50px; height: 50px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    position: relative;
    box-shadow: 0 5px 6px 0 rgba(0,0,0,.40) inset;
    overflow: hidden;
}
.bakala-story-item .bakala-story-image::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background-color: transparent;
    z-index: 8;
    transition: background-color .3s;
}
.bakala-story-item:hover .bakala-story-image::before { background-color: rgba(0,0,0,.5); }
.bakala-story-image-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 0;
    transition: opacity .3s;
}
.bakala-story-item:hover .bakala-story-image-placeholder { opacity: 1; }

/* Badge */
.bakala-story-time {
    position: absolute;
    bottom: -28px;
    right: 50%;
    transform: translateX(50%);
    border-radius: 4px;
    background: linear-gradient(262deg,
        var(--badge-color-1, var(--bakala-badge-1)) -2.55%,
        var(--badge-color-2, var(--bakala-badge-2)) 104.01%
    );
    padding: 2px 4px 0;
    color: #fff;
    text-shadow: 0 1px 0 rgba(0,0,0,.31);
    font-size: 10px;
    font-weight: 800;
    line-height: 12px;
    white-space: nowrap;
    z-index: 2;
}

/* Label */
.bakala-story-label {
    margin-top: 14px;
    color: #76809C;
    font-size: 11px;
    font-weight: 600;
    max-width: 70px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    text-align: center;
}
.bakala-story-item:hover .bakala-story-label { color: #424A62; font-weight: 700; }

/* ============================================================
   Story Modal Wrapper
   ============================================================ */
.bakala-story-wrapper {
    position: fixed;
    inset: 0;
    z-index: 999999;
    padding: 25px;
    background: rgba(0,0,0,.80);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: crosshair;
}
.bakala-story-close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
    background: transparent;
    border: none;
    cursor: pointer;
    opacity: .7;
    transition: opacity .2s;
}
.bakala-story-close-btn:hover { opacity: 1; }

/* ============================================================
   Story Slide
   ============================================================ */
.bakala-story-slide {
    position: relative;
    display: grid;
    max-width: 366px;
    width: 100%;
    max-height: 90vh;
    aspect-ratio: 9/16;
    cursor: default;
    z-index: 5;
}
.bakala-slide-bg-1,.bakala-slide-bg-2,.bakala-slide-bg-3 {
    position: absolute;
    z-index: -1;
    border-radius: 20px;
    background: rgba(255,255,255,.08);
}
.bakala-slide-bg-1 { top:20px; bottom:20px; right:-12px; left:33px; }
.bakala-slide-bg-2 { top:48px; bottom:48px; right:-25px; left:33px; }
.bakala-slide-bg-3 { top:20px; bottom:20px; right:25px;  left:-12px; }

.bakala-story-slide-items {
    border-radius: 20px;
    grid-area: 1/1;
    overflow: hidden;
    position: relative;
}
.bakala-story-slide-items > .bakala-story-slide-item {
    opacity: 0;
    pointer-events: none;
    position: absolute;
    inset: 0;
    transition: opacity .25s;
}
.bakala-story-slide-items > .bakala-story-slide-item.active {
    opacity: 1;
    pointer-events: initial;
    position: relative;
}
.bakala-story-slide-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Navigation tap zones */
.bakala-story-slide-nav {
    display: grid;
    grid-area: 1/1;
    grid-template-columns: 1fr 1fr;
    z-index: 5;
    position: absolute;
    inset: 0;
    bottom: 90px;
    pointer-events: none;
}
.bakala-slide-next,.bakala-slide-prev {
    pointer-events: all;
    opacity: 0;
    -webkit-appearance: none;
    cursor: pointer;
    border: none;
    background: transparent;
}

/* Thumbs */
.bakala-story-slide-thumbs {
    display: flex;
    flex-direction: row-reverse;
    position: absolute;
    top: 15px;
    right: 15px;
    left: 15px;
    z-index: 6;
    gap: 4px;
}
.bakala-story-slide-thumb-item {
    border-radius: 4px;
    background: rgba(255,255,255,.30);
    display: block;
    flex: 1;
    height: 2px;
    overflow: hidden;
}
.bakala-story-slide-thumb-item.active::after {
    border-radius: 4px;
    background: rgba(255,255,255,.90);
    content: '';
    display: block;
    height: 2px;
}

/* ============================================================
   Video Story
   ============================================================ */
.bakala-video-container {
    position: relative;
    grid-area: 1/1;
    border-radius: 20px;
    overflow: hidden;
    background: rgba(0,0,0,.85);
    backdrop-filter: blur(30px);
    display: flex;
    align-items: center;
    justify-content: center;
}
.bakala-video-container video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    max-height: 90vh;
}
.bakala-video-play-pause-btn {
    position: absolute;
    inset: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: opacity .3s;
}
.bakala-video-controls {
    position: absolute;
    bottom: 70px;
    left: 10px;
    width: 60%;
    z-index: 15;
    padding: 8px 10px;
    opacity: .85;
    transition: opacity .3s;
}
.bakala-video-container:hover .bakala-video-controls { opacity: 1; }
.bakala-video-time-display {
    display: flex;
    justify-content: space-between;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 5px;
}
.bakala-video-progress-bar {
    height: 4px;
    border-radius: 10px;
    background: rgba(255,255,255,.35);
    overflow: hidden;
    cursor: pointer;
}
.bakala-video-progress-fill {
    height: 100%;
    border-radius: 10px;
    background: #fff;
    width: 0%;
    transition: width .1s linear;
}

/* ============================================================
   Bottom Bar
   ============================================================ */
.bakala-story-bottom-bar {
    position: absolute;
    bottom: 15px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 18px;
    z-index: 20;
}
.bakala-like-btn,.bakala-comment-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    color: #fff;
    transition: transform .2s;
}
.bakala-like-btn:active,.bakala-comment-btn:active { transform: scale(.88); }
.bakala-like-count,.bakala-comment-count { font-size: 12px; font-weight: 700; color: #fff; }
.bakala-like-btn.liked svg { fill: var(--bakala-liked-color) !important; stroke: var(--bakala-liked-color) !important; }
@keyframes bakala-like-pop { 0%{transform:scale(1)}50%{transform:scale(1.3)}100%{transform:scale(1)} }
.bakala-like-btn.liked { animation: bakala-like-pop .3s ease forwards; }
.bakala-like-btn.processing,.bakala-comment-btn.processing { opacity:.6; pointer-events:none; }

/* ============================================================
   Related Product
   ============================================================ */
.bakala-story-related-products {
    position: absolute;
    top: 45px;
    right: 0;
    left: 0;
    margin: 0 15px;
    z-index: 20;
}
.bakala-video-story .bakala-story-related-products { top: 18px; }
.bakala-story-related-product { display:flex; align-items:center; justify-content:space-between; gap:10px; }
.bakala-story-related-product a { display:flex; gap:7px; align-items:center; text-decoration:none; flex:1; min-width:0; }
.bakala-story-related-product a img { width:33px; height:33px; padding:5px; border-radius:10px; background:#fff; object-fit:cover; flex-shrink:0; }
.bakala-story-related-product a span {
    overflow:hidden; display:-webkit-box; -webkit-line-clamp:1; line-clamp:1; -webkit-box-orient:vertical;
    border-radius:10px; background:rgba(255,255,255,.10);
    padding:0 10px; line-height:34px; font-size:11px; font-weight:700; color:#fff; min-width:0;
}
.bakala-close-related { background:transparent; border:none; cursor:pointer; flex-shrink:0; opacity:.7; transition:opacity .2s; }
.bakala-close-related:hover { opacity:1; }

/* Dynamic content area */
.bakala-story-slide-content { position:absolute; inset:0; z-index:20; pointer-events:none; }
.bakala-story-slide-content > * { pointer-events:all; }

/* ============================================================
   Comments Panel
   ============================================================ */
.bakala-story-comments {
    position: absolute;
    inset: 0;
    border-radius: 20px;
    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);
    z-index: 30;
    display: flex;
    flex-direction: column;
    padding: 15px;
    gap: 8px;
    overflow: hidden;
}
.bakala-comments-head { display:flex; justify-content:space-between; align-items:center; flex-shrink:0; }
.bakala-comments-head span { color:#fff; font-size:15px; font-weight:700; }
.bakala-close-comments { background:transparent; border:none; cursor:pointer; opacity:.7; transition:opacity .2s; }
.bakala-close-comments:hover { opacity:1; }

.bakala-story-comments-list {
    flex:1; overflow-y:auto; overscroll-behavior:contain; -webkit-overflow-scrolling:touch;
    display:flex; flex-direction:column; gap:2px;
}
.bakala-story-comments-list::-webkit-scrollbar { width:3px; }
.bakala-story-comments-list::-webkit-scrollbar-track { background:transparent; }
.bakala-story-comments-list::-webkit-scrollbar-thumb { background:rgba(255,255,255,.3); border-radius:2px; }

.bakala-story-comment { display:flex; gap:10px; padding:8px 0; border-bottom:1px solid rgba(255,255,255,.07); }
.bakala-story-comment:last-child { border-bottom:none; }
.bakala-comment-avatar { width:34px; height:34px; border-radius:50%; background:rgba(255,255,255,.12); display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.bakala-comment-body { flex:1; min-width:0; }
.bakala-comment-meta { display:flex; align-items:center; gap:10px; margin-bottom:3px; }
.bakala-comment-author { color:#fff; font-size:11px; font-weight:800; }
.bakala-comment-date { color:rgba(255,255,255,.55); font-size:10px; }
.bakala-comment-text { color:#fff; font-size:12px; font-weight:500; line-height:1.5; word-break:break-word; margin:0; }
.bakala-loading-comments,.bakala-no-comments { text-align:center; padding:15px; color:rgba(255,255,255,.5); font-size:12px; }
.bakala-login-prompt { text-align:center; color:rgba(255,255,255,.6); font-size:12px; padding:10px 0; }

/* Comment Form */
.bakala-comment-form { flex-shrink:0; display:flex; flex-direction:column; gap:6px; margin-top:4px; }
.bakala-emoji-row { display:flex; gap:6px; justify-content:center; flex-wrap:wrap; }
.bakala-emoji { font-size:22px; cursor:pointer; transition:transform .15s; line-height:1; display:inline-flex; align-items:center; justify-content:center; width:28px; height:28px; }
.bakala-emoji img.emoji { width:22px !important; height:22px !important; margin:0 !important; padding:0 !important; display:inline !important; vertical-align:middle !important; border:none !important; box-shadow:none !important; }
.bakala-emoji:hover { transform:scale(1.3); }
.bakala-comment-input-row {
    display:flex; gap:8px; align-items:flex-end;
    border-radius:20px; border:1px solid rgba(255,255,255,.20); padding:5px;
}
.bakala-comment-input-row textarea {
    flex:1; background:transparent; border:none; outline:none;
    color:#fff; font-size:12px; font-weight:500; resize:none;
    padding:5px 10px; height:32px; line-height:1.5; font-family:inherit;
}
.bakala-comment-input-row textarea::placeholder { color:rgba(255,255,255,.4); }
.bakala-comment-submit {
    width:34px; height:34px; border-radius:50%;
    background:#09F; border:none; cursor:pointer;
    display:flex; align-items:center; justify-content:center;
    flex-shrink:0; transition:background .2s;
}
.bakala-comment-submit:hover { background:#007acc; }
.bakala-comment-submit:disabled { opacity:.5; cursor:not-allowed; }

/* ============================================================
   Notification Bar
   ============================================================ */
.bakala-notif-bar {
    position: fixed;
    bottom: -80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999999;
    background: #1f2128;
    border-radius: 12px;
    padding: 10px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 8px 32px rgba(0,0,0,.4);
    transition: bottom .35s cubic-bezier(.34,1.56,.64,1);
    max-width: 90vw;
    white-space: nowrap;
    pointer-events: none;
}
.bakala-notif-bar.active { bottom: 24px; pointer-events: all; }
.bakala-notif-bar.error   { border-left: 3px solid #F04055; }
.bakala-notif-bar.success { border-left: 3px solid #3EB580; }
.bakala-notif-bar.warning { border-left: 3px solid #DB921A; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 992px) {
    .bakala-story-image { width:40px; height:40px; }
    .bakala-story-time  { font-size:9px; }
    .bakala-story-label { font-size:10px; }
}
@media (max-width: 480px) {
    .bakala-story-wrapper { padding:0; }
    .bakala-story-slide { max-width:100%; max-height:100dvh; border-radius:0; }
    .bakala-story-slide-items,.bakala-video-container,.bakala-story-comments { border-radius:0; }
    .bakala-slide-bg-1,.bakala-slide-bg-2,.bakala-slide-bg-3 { display:none; }
}

/* ── Toast (اضافه شده) ─────────────────────────── */
.bks-toast {
    position: fixed;
    bottom: -70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999999;
    background: #1e2130;
    border-radius: 12px;
    padding: 11px 22px;
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 8px 32px rgba(0,0,0,.5);
    transition: bottom .35s cubic-bezier(.34,1.56,.64,1);
    white-space: nowrap;
    pointer-events: none;
    max-width: 90vw;
    text-align: center;
}
.bks-toast--show  { bottom: 24px; pointer-events: all; }
.bks-toast--error   { border-left: 3px solid #f87171; }
.bks-toast--success { border-left: 3px solid #4ade80; }
.bks-toast--warning { border-left: 3px solid #fbbf24; }

/* ── fix: overlay cursor ───────────────────────── */
.bakala-story-wrapper { cursor: default; }

/* ══════════════════════════════════════════════════
   Viewed State — حلقه خاکستری بعد از دیدن استوری
══════════════════════════════════════════════════ */
.bakala-story-image-wrapper.bks-viewed {
    background: linear-gradient(135deg, #9ca3af, #d1d5db);
    box-shadow: none;
}

/* ══════════════════════════════════════════════════
   Inter-story navigation buttons (چپ/راست modal)
══════════════════════════════════════════════════ */
.bks-story-prev,
.bks-story-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 999999;
    background: rgba(255,255,255,.15);
    border: none;
    cursor: pointer;
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: .7;
    transition: opacity .2s, background .2s;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    flex-shrink: 0;
}
.bks-story-prev:hover,
.bks-story-next:hover { opacity: 1; background: rgba(255,255,255,.28); }

.bks-story-prev { left: -52px; }
.bks-story-next { right: -52px; }

/* روی موبایل دکمه‌ها رو مخفی کن — سوییچ با کشیدن (swipe) انجام میشه */
@media (max-width: 540px) {
    .bks-story-prev,
    .bks-story-next { display: none; }
}

/* ══════════════════════════════════════════════════
   Auto-advance progress fill داخل thumb
══════════════════════════════════════════════════ */
.bakala-story-slide-thumb-item {
    position: relative;
    overflow: hidden;
}
.bakala-story-slide-thumb-item .bks-thumb-fill {
    position: absolute;
    left: 0; top: 0;
    height: 100%;
    width: 0%;
    background: rgba(255,255,255,.90);
    border-radius: 4px;
    pointer-events: none;
}

/* ══════════════════════════════════════════════════
   Fan / Butterfly Deck
   کارت‌ها داخل wrapper (fixed fullscreen) قرار
   می‌گیرن تا overflow مشکل نسازه
══════════════════════════════════════════════════ */

/* هر کارت fan — fixed، z-index بالاتر از modal (999999) */
.bks-fan-card {
    position: fixed;
    border-radius: 18px;
    overflow: hidden;
    cursor: pointer;
    transform-origin: center bottom;
    transition: transform .45s cubic-bezier(.34,1.3,.64,1),
                opacity .35s ease,
                filter .35s ease,
                box-shadow .35s ease;
    will-change: transform, opacity, filter;
    /* حالت پیش‌فرض: نامرئی */
    opacity: 0;
    pointer-events: none;
    z-index: 1000010;
    box-shadow: 0 16px 48px rgba(0,0,0,.6);
}

/* تصویر پیش‌نمایش */
.bks-fan-card img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

/* لایه frosted glass روی کارت — حالت بسته */
.bks-fan-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: opacity .35s ease;
    z-index: 1;
    border-radius: inherit;
}

/* لایه gradient پایین */
.bks-fan-card::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 50%;
    background: linear-gradient(to top, rgba(0,0,0,.6), transparent);
    z-index: 2;
    border-radius: 0 0 18px 18px;
    opacity: 0;
    transition: opacity .35s ease;
}

/* وقتی fan باز است — کارت شفاف‌تر میشه */
.bks-fan-card.bks-fan-visible {
    opacity: 1;
    pointer-events: all;
}
.bks-fan-card.bks-fan-visible::before {
    opacity: 0.45;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
.bks-fan-card.bks-fan-visible::after { opacity: 1; }

/* hover — کاملاً شفاف */
.bks-fan-card.bks-fan-visible:hover { box-shadow: 0 20px 60px rgba(0,0,0,.75); }
.bks-fan-card.bks-fan-visible:hover::before { opacity: 0.1; backdrop-filter: blur(0px); -webkit-backdrop-filter: blur(0px); }

/* دکمه باز/بسته */
.bks-fan-toggle {
    position: absolute;
    bottom: 68px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000020;
    background: rgba(255,255,255,.12);
    border: 1px solid rgba(255,255,255,.22);
    border-radius: 24px;
    color: rgba(255,255,255,.9);
    font-size: 11px;
    font-family: inherit;
    padding: 5px 14px 5px 11px;
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background .2s, border-color .2s;
    pointer-events: all;
    white-space: nowrap;
    letter-spacing: .3px;
}
.bks-fan-toggle:hover {
    background: rgba(255,255,255,.22);
    border-color: rgba(255,255,255,.4);
}
.bks-fan-toggle .bks-fan-arrow {
    display: flex;
    transition: transform .38s cubic-bezier(.34,1.3,.64,1);
}
.bks-fan-toggle.bks-fan-open .bks-fan-arrow { transform: rotate(180deg); }

/* ══════════════════════════════════════════════════
   Double-tap heart animation
══════════════════════════════════════════════════ */
@keyframes bks-heart-pop {
    0%   { transform: scale(0) rotate(-15deg); opacity: 1; }
    40%  { transform: scale(1.4) rotate(5deg);  opacity: 1; }
    70%  { transform: scale(1.1) rotate(-3deg); opacity: 1; }
    100% { transform: scale(1.3) rotate(0deg);  opacity: 0; }
}
.bks-heart-anim {
    position: absolute;
    font-size: 60px;
    pointer-events: none;
    z-index: 100;
    animation: bks-heart-pop .85s ease forwards;
    line-height: 1;
    user-select: none;
}
