/* ==========================================================================
   Stories Experience Styles — Linear / Slack Dark Theme System
   ========================================================================== */

/* Stories Tray: Subtle surface panel with 1px border */
.stories-tray {
    display: flex;
    gap: var(--space-16);
    padding: var(--space-16) var(--space-24);
    overflow-x: auto;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    scrollbar-width: none;
}
.stories-tray::-webkit-scrollbar {
    display: none;
}

.story-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    flex-shrink: 0;
    width: 72px;
    user-select: none;
}

/* 64px circular avatar with unseen 2px gradient ring & 2px gap */
.story-ring {
    width: 68px;
    height: 68px;
    padding: 2px;
    border-radius: var(--radius-full);
    background: var(--grad-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform var(--ease-normal);
}
.story-item:hover .story-ring {
    transform: scale(1.04);
}

/* Seen ring: 1.5px subtle border */
.story-ring.seen {
    background: var(--border-strong);
}

.story-ring-inner {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    border: 2px solid var(--bg-surface);
    background: var(--bg-surface-2);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.story-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.story-avatar-fallback {
    width: 100%;
    height: 100%;
    background: var(--grad-avatar);
    color: #ffffff;
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* "Your Story" item with small (+) badge in --grad-brand */
.story-ring.your-story {
    background: transparent;
    border: 2px dashed var(--accent);
}
.add-story-btn {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 22px;
    height: 22px;
    background: var(--grad-brand);
    color: #ffffff;
    border: 2px solid var(--bg-surface);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.4);
}
.add-story-btn svg {
    width: 13px;
    height: 13px;
    stroke: #ffffff;
    stroke-width: 2.2;
}

/* Name label: 12px text-secondary, truncated */
.story-user-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

/* --------------------------------------------------------------------------
   Fullscreen Story Viewer Overlay
   -------------------------------------------------------------------------- */
.story-viewer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(7, 11, 20, 0.95);
    z-index: var(--z-story-viewer);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.story-viewer-card {
    width: 100%;
    max-width: 440px;
    height: 90vh;
    max-height: 820px;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xl);
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-elevated);
}

.story-progress-bar-wrap {
    position: absolute;
    top: 12px;
    left: 14px;
    right: 14px;
    display: flex;
    gap: 4px;
    z-index: 20;
}
.story-progress-segment {
    flex: 1;
    height: 3px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 2px;
    overflow: hidden;
}
.story-progress-fill {
    height: 100%;
    width: 0%;
    background: #ffffff;
    transition: width linear;
}
.story-progress-fill.done {
    width: 100%;
}

.story-viewer-header {
    position: absolute;
    top: 26px;
    left: 16px;
    right: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 20;
    color: #ffffff;
}
.story-header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}
.story-header-user .conv-avatar {
    width: 36px;
    height: 36px;
    font-size: 13px;
    border: 1.5px solid #ffffff;
}
.story-header-name {
    font-size: 14px;
    font-weight: 600;
}
.story-header-time {
    font-size: 12px;
    opacity: 0.8;
}

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

.story-media-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.story-text-card {
    padding: 32px;
    color: #ffffff;
    font-size: 20px;
    font-weight: 600;
    text-align: center;
    line-height: 1.4;
    word-break: break-word;
}

/* Tap Zones */
.story-tap-zone {
    position: absolute;
    top: 60px;
    bottom: 80px;
    width: 35%;
    z-index: 10;
    cursor: pointer;
}
.story-tap-zone.left { left: 0; }
.story-tap-zone.right { right: 0; width: 65%; }

/* Story Footer Actions */
.story-viewer-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px 20px 20px 20px;
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.85) 100%);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 20;
}

.story-reply-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-full);
    padding: 10px 16px;
    color: #ffffff;
    font-size: 13.5px;
    backdrop-filter: blur(8px);
}
.story-reply-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
}

.story-reaction-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: transform var(--ease-normal);
}
.story-reaction-btn:hover {
    transform: scale(1.15);
}

/* ==========================================================================
   Story Caption Overlay — Always Clearly Visible Above Footer
   ========================================================================== */
.story-caption-overlay {
    position: absolute;
    bottom: 88px;
    left: 16px;
    right: 16px;
    z-index: 30;
    background: rgba(8, 12, 22, 0.84);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    padding: 12px 18px;
    border-radius: 16px;
    color: #ffffff;
    font-size: 14.5px;
    font-weight: 600;
    line-height: 1.45;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.24);
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.8);
    word-break: break-word;
    max-height: 120px;
    overflow-y: auto;
    pointer-events: auto;
    transition: bottom 200ms ease;
}

/* When viewing own story with self-analytics footer */
.story-viewer-card.is-self .story-caption-overlay {
    bottom: 64px;
}

/* Self Story Analytics Footer (View Count for Author) */
.story-viewer-self-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 12px 20px 18px 20px;
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.82) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
}
.story-viewer-analytics {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    padding: 6px 16px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
    backdrop-filter: blur(12px);
}
