/* ===================== صفحه‌ی لیست آلبوم (/album/stories/) ===================== */
.stories-board {
    --sb-accent: #2e66bf;
    --sb-accent-soft: #e8f0fc;
    --sb-text: #1f2937;
    --sb-muted: #6b7280;
    --sb-card: #ffffff;
    --sb-border: #e5e7eb;
    --sb-media-bg: #f1f3f6;
    direction: rtl;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto 20px;
    padding: 8px 0 0;
    text-align: right;
    color: var(--sb-text);
}

/*
 * چیدمان دو‌ستونه‌ی دسکتاپ را تابع positionTlItems در newStory-v21.js انجام می‌دهد:
 * کارت‌ها پشت سر هم در جریان عادی قرار دارند و با top نسبی جابه‌جا می‌شوند و ارتفاع
 * کانتینر از جمع scrollHeight کارت‌ها حساب می‌شود؛ پس روی post-container نباید margin
 * گذاشت (فاصله‌ها فقط با padding که داخل scrollHeight حساب می‌شود)
 */
.post-timeline {
    position: relative;
    margin: 0 auto;
}
/* خط تایم‌لاین وسط صفحه */
.post-timeline::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 3px;
    margin-left: -1.5px;
    border-radius: 3px;
    background: linear-gradient(to bottom, var(--sb-accent-soft), #c9d8f2 6%, #c9d8f2 94%, var(--sb-accent-soft));
}

.post-container {
    position: relative;
    width: 50%;
    margin: 0;
    padding: 0 26px 18px;
    text-align: right;
}
.left {
    right: 50%;
}
.right {
    right: 0;
}
/* نقطه‌ی روی خط تایم‌لاین */
.post-container::after {
    content: '';
    position: absolute;
    top: 22px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--sb-accent);
    box-shadow: 0 0 0 4px var(--sb-accent-soft);
    z-index: 1;
}
.right::after {
    left: -7.5px;
}
.left::after {
    right: -7.5px;
}

/* کارت پست */
.post-content {
    position: relative;
    background: var(--sb-card);
    border: 1px solid var(--sb-border);
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 6px 18px rgba(16, 24, 40, .06);
    overflow: hidden;
    transition: box-shadow .2s ease, transform .2s ease;
}
.post-content:hover {
    box-shadow: 0 2px 6px rgba(16, 24, 40, .08), 0 14px 32px rgba(16, 24, 40, .10);
}

.post-header {
    padding: 16px 18px 12px;
}
.post-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}
.post-title-link {
    flex: 1;
    min-width: 0;
    color: var(--sb-text);
    text-decoration: none;
}
.post-title-link:hover .post-title {
    color: var(--sb-accent);
}
.post-title {
    margin: 0;
    font-size: 1.12rem;
    font-weight: 700;
    line-height: 1.8;
    transition: color .15s ease;
}
.post-edit-btn {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--sb-accent-soft);
    color: var(--sb-accent);
    font-size: 18px;
}
.post-edit-btn:hover {
    background: var(--sb-accent);
    color: #fff;
}
.post-edit-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--sb-border);
    border-radius: 10px;
    font-size: 1rem;
    font-weight: bold;
    font-family: inherit;
}
textarea.post-edit-input {
    font-weight: normal;
    margin: 0 12px;
    width: calc(100% - 24px) !important;
}
.post-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: .85rem;
    color: var(--sb-muted);
}
.post-new-badge {
    padding: 1px 9px;
    border-radius: 999px;
    background: #ffcc00;
    color: #4a3800;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .5px;
    direction: ltr;
    animation: blink 1.4s infinite;
}

.post-desc {
    margin: 0;
    padding: 14px 18px 4px;
    font-size: .95rem;
    line-height: 2;
    color: #374151;
}

.post-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 18px 16px;
}
.post-classes {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.post-class-chip {
    padding: 3px 12px;
    border-radius: 999px;
    background: #f3f4f6;
    border: 1px solid var(--sb-border);
    color: #4b5563;
    font-size: .75rem;
    text-decoration: none;
    transition: background .15s ease, color .15s ease;
}
.post-class-chip:hover {
    background: var(--sb-accent-soft);
    border-color: #c9d8f2;
    color: var(--sb-accent);
}
.post-stats {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-right: auto;
    color: var(--sb-muted);
    font-size: .85rem;
    direction: ltr;
}
.post-views,
.post-like {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.post-content .like-icon.post-like {
    width: auto;
    height: auto;
    padding: 4px 10px;
    border-radius: 999px;
    background: #fdf2f4;
    color: #be123c;
    user-select: none;
}
.post-content .like-icon.post-like:active {
    transform: scale(.92);
}

/* ===================== رسانه‌ها ===================== */
.story-media-single,
.story-slide {
    position: relative;
    background: var(--sb-media-bg);
    text-align: center;
}
.story-media-single .story-media {
    display: block;
    width: 100%;
    height: auto;
    max-height: 560px;
    object-fit: contain;
    margin: 0 auto;
}
.story-image {
    cursor: zoom-in;
}
.story-video {
    display: block;
    width: 100%;
    background: #000;
}
.story-media-single .story-video {
    max-height: 480px;
}
.story-audio {
    width: calc(100% - 32px);
    margin: 24px 16px;
}
.story-video-link {
    position: relative;
    display: block;
    color: #fff;
}
.story-video-play {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 64px;
    height: 64px;
    margin: -32px 0 0 -32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, .55);
    box-shadow: 0 4px 16px rgba(0, 0, 0, .3);
    transition: transform .2s ease, background .2s ease;
}
.story-video-link:hover .story-video-play {
    transform: scale(1.08);
    background: var(--sb-accent);
}
.story-video-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(0, 0, 0, .6);
    color: #fff;
    font-size: .75rem;
    font-weight: bold;
}
.story-video-pending {
    margin: 12px;
    padding: 10px;
    border-radius: 12px;
}
.story-video-pending img {
    width: 100%;
    max-width: 360px;
}

/* ===================== اسلایدر ===================== */
.story-slider {
    position: relative;
    background: var(--sb-media-bg);
}
.story-slider-track {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.story-slider-track::-webkit-scrollbar {
    display: none;
}
.story-slide {
    flex: 0 0 100%;
    width: 100%;
    aspect-ratio: 4 / 3;
    scroll-snap-align: center;
    scroll-snap-stop: always;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.story-slide .story-media,
.story-slide .story-video-link {
    width: 100%;
    height: 100%;
}
.story-slide .story-media {
    object-fit: contain;
}
.story-slide .story-video-link .story-media {
    object-fit: cover;
}
.story-slide-video {
    background: #000;
}

.story-slider-btn {
    position: absolute;
    top: 50%;
    z-index: 2;
    width: 40px;
    height: 40px;
    margin-top: -20px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, .92);
    color: #111827;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .2);
    cursor: pointer;
    opacity: .9;
    transition: opacity .2s ease, transform .2s ease;
}
.story-slider-btn:hover {
    opacity: 1;
    transform: scale(1.06);
}
.story-slider-btn[disabled] {
    opacity: 0;
    pointer-events: none;
}
/* راست‌به‌چپ: «قبلی» سمت راست و «بعدی» سمت چپ */
.story-slider-prev {
    right: 10px;
}
.story-slider-next {
    left: 10px;
}
.story-slider-counter {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
    padding: 2px 10px;
    border-radius: 999px;
    background: rgba(0, 0, 0, .6);
    color: #fff;
    font-size: .75rem;
    direction: ltr;
    pointer-events: none;
}
.story-slider-dots {
    position: absolute;
    bottom: 10px;
    left: 0;
    right: 0;
    z-index: 2;
    display: flex;
    justify-content: center;
    gap: 6px;
    pointer-events: none;
}
.story-slider-dot {
    width: 7px;
    height: 7px;
    padding: 0;
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, .6);
    box-shadow: 0 0 2px rgba(0, 0, 0, .5);
    cursor: pointer;
    pointer-events: auto;
    transition: width .2s ease, background .2s ease;
}
.story-slider-dot.active {
    width: 20px;
    background: #fff;
}
/* ویدئو کنترل‌های خودش را پایین دارد؛ نقطه‌ها نباید رویشان بیفتند */
.story-slider.on-video .story-slider-dots {
    bottom: auto;
    top: 16px;
}

/* ===================== موبایل ===================== */
@media (hover: none) {
    .story-slider-btn {
        width: 34px;
        height: 34px;
        margin-top: -17px;
        opacity: .8;
    }
}
/* تبلت و موبایل: یک ستون با خط تایم‌لاین سمت راست (همان مرز 780px تابع positionTlItems) */
@media screen and (max-width: 780px) {
    /* فاصله از لبه‌های صفحه؛ کانتینر بالادستی در این قالب padding افقی ندارد */
    .stories-board {
        padding-left: 16px;
        padding-right: 14px;
    }
    .post-timeline::after {
        left: auto;
        right: 11px;
        margin-left: 0;
    }
    .post-container,
    .post-container.left,
    .post-container.right {
        width: 100%;
        right: 0;
        padding: 0 34px 22px 0;
    }
    .post-container.left::after,
    .post-container.right::after {
        left: auto;
        right: 5px;
    }
}
@media screen and (max-width: 600px) {
    .stories-board {
        padding: 4px 12px 0 10px;
    }
    .post-timeline::after {
        right: 6px;
    }
    .post-container,
    .post-container.left,
    .post-container.right {
        padding: 0 22px 18px 0;
    }
    .post-container.left::after,
    .post-container.right::after {
        right: 0;
        width: 13px;
        height: 13px;
    }
    .post-content {
        border-radius: 14px;
    }
    .post-header {
        padding: 14px 14px 10px;
    }
    .post-desc {
        padding: 12px 14px 4px;
    }
    .post-footer {
        padding: 10px 14px 14px;
    }
}

/* ===================== فرم پست جدید (بدون تغییر نسبت به v10) ===================== */
.card {
    padding: 6px;
}
.flex-container {
    display: flex;
    flex-wrap: wrap;
}
.flex-item {
    padding: 10px;
    flex: 50%;
}
@media (max-width: 600px) {
    .flex-item {
        flex: 100%;
    }
}
.multiselect-dropdown {
    min-width: 100%;
}
#selected_classes_div {
    background-color: #FFF8DC;
    margin: 6px;
    border-radius: 6px;
}
#unselected_classes_div {
    background-color: #00FFFF;
    margin: 6px;
    border-radius: 6px;
}

/* ===================== صفحه‌ی تک پست (/album/story/...) ===================== */
.stories-board.story-single {
    max-width: 900px;
    padding-top: 0;
}
.story-single .post-header {
    padding: 20px 22px 14px;
}
.story-single .post-title {
    font-size: 1.35rem;
    line-height: 1.9;
}
.story-single .post-desc-full {
    padding: 18px 22px 6px;
    font-size: 1rem;
    line-height: 2.1;
}
.story-single .post-desc-full img {
    max-width: 100%;
    height: auto;
}
.story-single .post-desc-full textarea.post-edit-input {
    margin: 0;
    width: 100% !important;
}
.story-single .post-footer {
    padding: 14px 22px 18px;
}
.story-single .story-slide {
    aspect-ratio: 16 / 11;
}
.story-single .story-media-single .story-media {
    max-height: 640px;
}
/* ویدئوی آپارات (iframe) */
.story-embed {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
}
.story-slide .story-embed {
    height: 100%;
    aspect-ratio: auto;
}
.story-embed iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}
.story-slide:has(.story-embed) {
    background: #000;
}
@media screen and (max-width: 600px) {
    .story-single .post-header {
        padding: 16px 14px 10px;
    }
    .story-single .post-title {
        font-size: 1.15rem;
    }
    .story-single .post-desc-full {
        padding: 14px 14px 4px;
    }
    .story-single .post-footer {
        padding: 12px 14px 14px;
    }
}

/* ===================== پیش‌نمایش بزرگ تصاویر (lightbox) ===================== */
.story-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 12, 16, .92);
    animation: story-lightbox-in .18s ease;
    touch-action: pan-y;
}
@keyframes story-lightbox-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
.story-lightbox-stage {
    position: absolute;
    inset: 70px 80px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.story-lightbox-media {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
    user-select: none;
}
video.story-lightbox-media {
    background: #000;
}
/* ویدئوی آپارات: قاب ۱۶:۹ تا جایی که صفحه جا دارد */
.story-lightbox-embed {
    position: relative;
    width: min(100%, calc((100vh - 90px) * 16 / 9));
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
}
.story-lightbox-embed iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}
/* پوستر ویدئوی آپارات در صفحه‌ی لیست (کلیک = رفتن به صفحه‌ی پست برای پخش) */
.story-lightbox-link {
    position: relative;
    display: flex;
    max-width: 100%;
    max-height: 100%;
    color: #fff;
}
.story-lightbox-link:hover .story-video-play {
    transform: scale(1.08);
    background: var(--sb-accent, #2e66bf);
}

/* دکمه‌ی «نمایش بزرگ» روی اسلایدهای ویدئویی */
.story-expand-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 3;
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 10px;
    background: rgba(0, 0, 0, .55);
    color: #fff;
    cursor: pointer;
    transition: background .15s ease, transform .15s ease;
}
.story-expand-btn:hover {
    background: var(--sb-accent, #2e66bf);
    transform: scale(1.06);
}
.story-media-single.story-slide-video {
    position: relative;
}
.story-lightbox-btn,
.story-lightbox-close {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    cursor: pointer;
    transition: background .15s ease, transform .15s ease;
}
.story-lightbox-btn:hover,
.story-lightbox-close:hover {
    background: rgba(255, 255, 255, .28);
}
.story-lightbox-btn {
    top: 50%;
    width: 52px;
    height: 52px;
    margin-top: -26px;
}
.story-lightbox-btn:active {
    transform: scale(.92);
}
/* راست‌به‌چپ: «قبلی» سمت راست و «بعدی» سمت چپ (مثل اسلایدر پست) */
.story-lightbox-prev {
    right: 18px;
}
.story-lightbox-next {
    left: 18px;
}
.story-lightbox-close {
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    font-size: 30px;
    line-height: 1;
}
.story-lightbox-counter {
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 3px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    font-size: .85rem;
    direction: ltr;
}
@media screen and (max-width: 600px) {
    .story-lightbox-stage {
        inset: 70px 0 90px;
    }
    .story-lightbox-media,
    .story-lightbox-embed {
        border-radius: 0;
    }
    .story-lightbox-embed {
        width: 100%;
    }
    .story-lightbox-btn {
        top: auto;
        bottom: 22px;
        margin-top: 0;
        width: 48px;
        height: 48px;
    }
    .story-lightbox-prev {
        right: 22%;
    }
    .story-lightbox-next {
        left: 22%;
    }
}
