/*!
 * Story Player Styles v1.0.0
 * Author: Amir Rezaie (https://amir-rezaie.ir)
 * License: MIT
 */

#stories-container {
    display: flex;
    gap: 15px;
    padding: 15px;
    overflow-x: auto;
}

.story {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
}

.story-avatar {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    padding: 2px;
    background: linear-gradient(45deg, #ff6b6b, #ff3838);
    transition: background 0.3s;
}

.story-avatar.viewed {
    background: #ddd !important;
}

.story-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 2px solid white;
    object-fit: cover;
}

.story-username {
    margin-top: 5px;
    font-size: 12px;
    color: #333;
    white-space: nowrap;
}

.story-modal {
    display: none;
    position: fixed;
    inset: 0;
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    background: rgba(0, 0, 0, 0.92);
    z-index: 1000;
    box-sizing: border-box;
    padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

.progress-container {
    position: absolute;
    top: max(12px, env(safe-area-inset-top, 0px));
    inset-inline-start: max(12px, env(safe-area-inset-left, 0px));
    inset-inline-end: max(12px, env(safe-area-inset-right, 0px));
    height: 4px;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
}

.progress-fill {
    width: 0%;
    height: 100%;
    background: #4CAF50;
    border-radius: 2px;
    transition: width linear;
}

.story-content {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    box-sizing: border-box;
    padding: 52px 0 88px;
}

/* قاب استوری ۹:۱۶؛ ارتفاع از viewport، عرض از نسبت؛ محتوا با object-fit: cover پر می‌شود */
.media-container {
    position: relative;
    flex: 0 0 auto;
    height: min(calc(100dvh - 152px), calc((100vw - 32px) * 16 / 9));
    max-height: calc(100dvh - 152px);
    max-width: calc(100vw - 32px);
    aspect-ratio: 9 / 16;
    width: auto;
    overflow: hidden;
    border-radius: 12px;
    background: #000;
    touch-action: pan-y;
    margin-inline: auto;
}

.story-media {
    display: none;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.video-media {
    display: none;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    background: #000;
}

.nav-button {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.3);
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
}

.prev-button {
    inset-inline-end: clamp(12px, 4vw, 28px);
}
.next-button {
    inset-inline-start: clamp(12px, 4vw, 28px);
}

.close-button {
    position: absolute;
    top: max(16px, env(safe-area-inset-top, 0px));
    inset-inline-end: max(16px, env(safe-area-inset-right, 0px));
    background: rgba(255,255,255,0.3);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    z-index: 1001;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* نوار تمام‌عرض پایین قاب استوری؛ کارت با flex وسط می‌نشیند (RTL/LTR یکسان) */
.story-link-bar {
    position: absolute;
    inset-inline: 0;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    display: none;
    justify-content: center;
    align-items: center;
    padding-inline: 12px;
    box-sizing: border-box;
    z-index: 1002;
    pointer-events: none;
}

.story-link-bar.is-visible {
    display: flex;
}

.story-link {
    position: relative;
    display: inline-flex;
    align-items: stretch;
    justify-content: center;
    width: auto;
    max-width: 100%;
    margin: 0;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    padding: 10px 14px;
    border-radius: 14px;
    text-decoration: none;
    font-size: 14px;
    box-sizing: border-box;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    pointer-events: auto;
}

/* فقط لینک (بدون product_id): دکمهٔ متنی، بدون تصویر */
.story-link.is-link-only .story-link-image {
    display: none;
}

.story-link.is-link-only {
    align-items: center;
    padding: 12px 22px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.35);
}

.story-link.is-link-only .story-link-box {
    gap: 0;
    max-width: none;
    justify-content: center;
}

.story-link.is-link-only .story-link-info {
    flex: 0 1 auto;
    text-align: center;
}

.story-link.is-link-only .story-link-title {
    display: block;
    -webkit-line-clamp: unset;
    overflow: visible;
}

.story-link-box {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: min(288px, 100%);
}

.story-link-image {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.12);
}

.story-link-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.story-link-info {
    flex: 1;
    min-width: 0;
    text-align: start;
}

.story-link-title {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

.story-link-meta {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-top: 5px;
    font-variant-numeric: tabular-nums;
}

.story-link-meta[hidden] {
    display: none !important;
}

.story-link-price {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.02em;
}

.story-link-currency {
    font-size: 11px;
    font-weight: 600;
    opacity: 0.88;
}
