/* WPSTORY Frontend Styles — Instagram-like story bar */

.wpstory-bar {
    --wpstory-size: 70px;
    --wpstory-color: #e1306c;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
    /* direction set via dir attribute from is_rtl() */
}

.wpstory-highlights,
.wpstory-stories-list {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 8px 4px 12px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    scroll-behavior: smooth;
    width: 100%;
    box-sizing: border-box;
}

.wpstory-highlights::-webkit-scrollbar,
.wpstory-stories-list::-webkit-scrollbar {
    display: none;
}

/* Single horizontal row: highlights + stories together when both present */
.wpstory-bar.wpstory-combined-row {
    flex-direction: row;
    gap: 12px;
    align-items: flex-start;
}

.wpstory-bar.wpstory-combined-row .wpstory-highlights,
.wpstory-bar.wpstory-combined-row .wpstory-stories-list {
    width: auto;
    flex: 0 0 auto;
    padding-top: 8px;
    padding-bottom: 12px;
}

.wpstory-bar.wpstory-combined-row .wpstory-stories-list {
    flex: 1 1 auto;
    min-width: 0;
}

.wpstory-item {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    cursor: pointer;
    width: calc(var(--wpstory-size) + 12px);
    max-width: calc(var(--wpstory-size) + 12px);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.wpstory-circle {
    width: var(--wpstory-size) !important;
    height: var(--wpstory-size) !important;
    min-width: var(--wpstory-size);
    min-height: var(--wpstory-size);
    max-width: var(--wpstory-size);
    max-height: var(--wpstory-size);
    border-radius: 50% !important;
    padding: 3px;
    background: var(--wpstory-color);
    position: relative;
    box-sizing: border-box;
    overflow: hidden;
    flex-shrink: 0;
}

.wpstory-item.has-gradient .wpstory-circle {
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
}

.wpstory-item.viewed .wpstory-circle {
    background: #c7c7c7;
}

.wpstory-circle img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 50% !important;
    border: 2.5px solid #fff;
    display: block;
    background: #eee;
    max-width: 100%;
    aspect-ratio: 1 / 1;
}

.wpstory-highlight .highlight-circle {
    background: #dbdbdb;
    padding: 2px;
}

.wpstory-highlight .highlight-circle img {
    border-color: #fafafa;
}

.wpstory-title {
    font-size: 11px;
    margin-top: 6px;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #262626;
    line-height: 1.3;
    font-weight: 400;
}

/* Auto-scroll pause on hover */
.wpstory-stories-list.wpstory-auto-scroll:hover {
    scroll-behavior: auto;
}

/* Modal */
.wpstory-modal {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    /* direction set via dir attribute from is_rtl() */
}

.wpstory-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
}

.wpstory-modal-content {
    position: relative;
    width: 100%;
    max-width: 420px;
    height: 100%;
    max-height: 90vh;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

@media (max-width: 480px) {
    .wpstory-modal-content {
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        height: 100%;
    }
}

.wpstory-progress-bars {
    display: flex;
    gap: 4px;
    padding: 12px 12px 0;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
}

.wpstory-progress-bar {
    flex: 1;
    height: 2px;
    background: rgba(255, 255, 255, 0.35);
    border-radius: 2px;
    overflow: hidden;
}

.wpstory-progress-bar span {
    display: block;
    height: 100%;
    width: 0;
    background: #fff;
    border-radius: 2px;
}

.wpstory-progress-bar.active span {
    animation: wpstory-progress linear forwards;
}

.wpstory-progress-bar.done span {
    width: 100%;
    animation: none;
}

@keyframes wpstory-progress {
    from { width: 0; }
    to { width: 100%; }
}

.wpstory-modal .wpstory-close {
    position: absolute;
    top: 28px;
    left: 12px;
    z-index: 15;
    background: none !important;
    border: none !important;
    color: #fff !important;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    opacity: 0.9;
    box-shadow: none !important;
    text-shadow: none;
    min-width: auto;
    min-height: auto;
}

.wpstory-viewer-header {
    position: absolute;
    top: 28px;
    right: 12px;
    left: 50px;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
}

.wpstory-viewer-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255,255,255,0.5);
}

.wpstory-viewer-name {
    font-size: 14px;
    font-weight: 600;
}

.wpstory-viewer-time {
    font-size: 12px;
    opacity: 0.7;
    margin-right: auto;
}

.wpstory-media-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #111;
    position: relative;
    overflow: hidden;
}

.wpstory-media-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    width: 100%;
    height: 100%;
}

.wpstory-media-video {
    width: 100%;
    height: 100%;
    border: none;
    pointer-events: none;
}

/* Transparent overlay so hold-to-pause works over iframe videos */
.wpstory-media-overlay {
    position: absolute;
    inset: 0;
    z-index: 4;
    background: transparent;
    touch-action: none;
}

.wpstory-viewer-footer {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    justify-content: center;
    gap: 12px;
    padding: 0 16px;
}

.wpstory-cta {
    background: rgba(255,255,255,0.2);
    color: #fff;
    padding: 10px 24px;
    border-radius: 24px;
    text-decoration: none;
    font-size: 14px;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.3);
}

.wpstory-cta:hover {
    background: rgba(255,255,255,0.35);
    color: #fff;
}

.wpstory-modal .wpstory-viewers-btn {
    background: rgba(255,255,255,0.15) !important;
    color: #fff !important;
    border: 1px solid rgba(255,255,255,0.25) !important;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    box-shadow: none !important;
}

.wpstory-viewer-placeholder {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #444;
    flex-shrink: 0;
}

.wpstory-no-viewers {
    padding: 20px;
    text-align: center;
}

.wpstory-nav {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 30%;
    z-index: 5;
    cursor: pointer;
}

/* Tap zones. LTR: left = previous, right = next. RTL (mirrored): right = previous, left = next. */
.wpstory-prev {
    left: 0;
    right: auto;
}

.wpstory-next {
    right: 0;
    left: auto;
}

[dir="rtl"] .wpstory-prev {
    right: 0;
    left: auto;
}

[dir="rtl"] .wpstory-next {
    left: 0;
    right: auto;
}

/* Visible previous / next buttons (same side logic as tap zones) */
.wpstory-modal .wpstory-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 12;
    width: 36px;
    height: 36px;
    padding: 0;
    min-width: 0;
    min-height: 0;
    border-radius: 50%;
    border: none !important;
    background: rgba(0, 0, 0, 0.45) !important;
    box-shadow: none !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85;
    transition: opacity .15s, background .15s;
}

.wpstory-modal .wpstory-arrow:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.7) !important;
}

.wpstory-modal .wpstory-arrow.is-hidden {
    display: none;
}

.wpstory-arrow span {
    display: block;
    width: 10px;
    height: 10px;
    border: solid #fff;
    border-width: 0 0 2px 2px;
}

/* LTR */
.wpstory-arrow-prev { left: 8px; right: auto; }
.wpstory-arrow-next { right: 8px; left: auto; }
.wpstory-arrow-prev span { transform: rotate(45deg); margin-left: 4px; }
.wpstory-arrow-next span { transform: rotate(-135deg); margin-right: 4px; }

/* RTL */
[dir="rtl"] .wpstory-arrow-prev { right: 8px; left: auto; }
[dir="rtl"] .wpstory-arrow-next { left: 8px; right: auto; }
[dir="rtl"] .wpstory-arrow-prev span { transform: rotate(-135deg); margin-left: 0; margin-right: 4px; }
[dir="rtl"] .wpstory-arrow-next span { transform: rotate(45deg); margin-right: 0; margin-left: 4px; }

@media (hover: none) {
    .wpstory-modal .wpstory-arrow { opacity: 0.6; }
}

/* Viewers panel */
.wpstory-viewers-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 50%;
    background: #1a1a1a;
    border-radius: 16px 16px 0 0;
    z-index: 20;
    color: #fff;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.wpstory-viewers-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #333;
}

.wpstory-viewers-header h3 {
    margin: 0;
    font-size: 16px;
}

.wpstory-viewers-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
}

.wpstory-viewers-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    flex: 1;
}

.wpstory-viewers-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #2a2a2a;
}

.wpstory-viewers-list img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.wpstory-viewers-list .name {
    flex: 1;
    font-size: 14px;
}

.wpstory-viewers-list .time {
    font-size: 12px;
    opacity: 0.6;
}

/* Submit form */
.wpstory-submit-form-wrap {
    max-width: 480px;
    margin: 20px auto;
    padding: 24px;
    background: #fafafa;
    border-radius: 12px;
    border: 1px solid #eee;
    direction: rtl;
}

.wpstory-submit-form-wrap h3 {
    margin-top: 0;
}

.wpstory-submit-form-wrap label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

.wpstory-submit-form-wrap input[type="text"],
.wpstory-submit-form-wrap input[type="url"],
.wpstory-submit-form-wrap select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin-bottom: 12px;
    box-sizing: border-box;
}

.wpstory-submit-form-wrap .wpstory-submit-btn {
    background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366) !important;
    color: #fff !important;
    border: none !important;
    padding: 12px 28px;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
    width: 100%;
    box-shadow: none !important;
    text-transform: none;
    font-family: inherit;
    line-height: 1.4;
}

.wpstory-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.wpstory-submit-message {
    margin-top: 12px;
    padding: 10px;
    border-radius: 6px;
    background: #f0f0f0;
}

.wpstory-notice {
    padding: 12px 16px;
    background: #fff3cd;
    border-radius: 8px;
    direction: rtl;
}

/* Scroll lock (iOS-friendly: position fixed + restore scrollY in JS) */
html.wpstory-open,
body.wpstory-open {
    overflow: hidden !important;
    height: 100% !important;
    width: 100% !important;
    overscroll-behavior: none;
}

body.wpstory-open {
    position: fixed !important;
    left: 0;
    right: 0;
}

/* Isolate plugin buttons from theme button styles */
.wpstory-modal button,
.wpstory-submit-form-wrap button {
    font-family: inherit;
    appearance: none;
    -webkit-appearance: none;
}

.wpstory-viewers-close {
    background: none !important;
    border: none !important;
    color: #fff !important;
    box-shadow: none !important;
}

/* Responsive */
@media (max-width: 768px) {
    .wpstory-bar {
        --wpstory-size: 64px;
    }
}

@media (max-width: 480px) {
    .wpstory-bar {
        --wpstory-size: 58px;
    }
    .wpstory-title {
        font-size: 10px;
    }
}
