/* ============================================================
   story-styles.css
   Story strip, viewer overlay, and upload modal.
   ============================================================ */

/* ─── Story Strip ─── */
.story-strip { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: thin;}
.story-strip::-webkit-scrollbar { height: 3px; }
.story-strip::-webkit-scrollbar { display: none; }

.story-items-container {
    display: contents;  /* children participate in parent flex */
}

.story-item {
    flex-shrink: 0;
    width: 90px;
    height: 140px;
    border-radius: 12px;
    background: var(--glass);
    border: 1.5px solid var(--border);
    overflow: hidden;
    cursor: pointer;
    position: relative;
    transition: transform 0.2s, border-color 0.2s;
}
.story-item:hover { transform: scale(1.04); border-color: var(--gold); }

.story-gradient {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 50%);
}
.story-name {
    position: absolute;
    bottom: 8px; left: 0; right: 0;
    text-align: center;
    font-size: 0.72rem;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}
.story-avatar {
    position: absolute;
    top: 10px; left: 50%;
    transform: translateX(-50%);
    border: 2.5px solid var(--gold);
}
.story-add {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 14px;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 0.73rem;
}
.story-add-icon {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(245,158,11,0.2);
    border: 2px solid var(--gold);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gold);
    font-size: 1.1rem;
    margin-bottom: 2px;
}

/* ── Skeleton loaders ──────────────────────────────────────── */
.story-skeleton {
    pointer-events: none;
    opacity: 0.4;
}
.story-skeleton-circle {
    position: absolute;
    top: 10px;
    left: 18px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(90deg, #1e1e1e 25%, #2a2a2a 50%, #1e1e1e 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
}
.story-skeleton-text {
    position: absolute;
    bottom: 8px;
    left: 23px;
    width: 40px;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(90deg, #1e1e1e 25%, #2a2a2a 50%, #1e1e1e 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite 0.2s;
}
@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.guest-story {
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
    cursor: pointer;
}

/* ══════════════════════════════════════════════════════════
   STORY VIEWER OVERLAY
══════════════════════════════════════════════════════════ */
.story-viewer-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(6px);
    animation: svFadeIn 0.2s ease;
}

@keyframes svFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.story-viewer-wrap {
    position: relative;
    width: 100%;
    max-width: 400px;
    height: 100dvh;
    max-height: 720px;
    border-radius: 20px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 0 0 1px #2a2a2a, 0 30px 80px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
}

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

.story-pb-track {
    flex: 1;
    height: 3px;
    background: rgba(255,255,255,0.25);
    border-radius: 2px;
    overflow: hidden;
}

.story-pb-fill {
    height: 100%;
    width: 0;
    background: #fff;
    border-radius: 2px;
}

/* ── Header ────────────────────────────────────────────────── */
.story-viewer-header {
    position: absolute;
    top: 22px;
    left: 0;
    right: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
}

.story-viewer-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.story-viewer-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

.story-viewer-time {
    font-size: 0.72rem;
    color: rgba(255,255,255,0.65);
    display: block;
    text-shadow: 0 1px 4px rgba(0,0,0,0.6);
}

.story-viewer-controls {
    display: flex;
    gap: 6px;
}

.sv-btn {
    background: rgba(0,0,0,0.4);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.15s;
    backdrop-filter: blur(4px);
}
.sv-btn:hover { background: rgba(0,0,0,0.65); }

/* ── Media ─────────────────────────────────────────────────── */
.story-viewer-media-wrap {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.story-viewer-media {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    background: #000;
}

/* ── Tap zones ─────────────────────────────────────────────── */
.story-tap-prev,
.story-tap-next {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 35%;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 5;
}
.story-tap-prev { left: 0; }
.story-tap-next { right: 0; }

/* ══════════════════════════════════════════════════════════
   STORY UPLOAD MODAL
══════════════════════════════════════════════════════════ */
.story-upload-dialog {
    max-width: 420px;
}

.story-upload-content {
    background: #0d0d0d;
    border: 1px solid #2a2a2a;
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.7);
    overflow: hidden;
    color: #e5e5e5;
}

.story-upload-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 14px;
    border-bottom: 1px solid #1e1e1e;
}

.story-upload-title {
    font-size: 1rem;
    font-weight: 700;
    color: #f5f5f5;
}

.story-upload-body {
    padding: 18px 20px;
}

/* ── Drop zone ─────────────────────────────────────────────── */
.story-drop-zone {
    display: block;
    border: 2px dashed #2e2e2e;
    border-radius: 12px;
    background: #111;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    overflow: hidden;
    min-height: 220px;
    position: relative;
}

.story-drop-zone:hover,
.story-drop-zone.drag-over {
    border-color: #f97316;
    background: rgba(249,115,22,0.04);
}

.story-drop-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 8px;
    min-height: 220px;
}

.story-drop-icon {
    font-size: 2.5rem;
    color: #444;
    line-height: 1;
}

.story-drop-zone:hover .story-drop-icon,
.story-drop-zone.drag-over .story-drop-icon {
    color: #f97316;
}

.story-drop-text {
    font-size: 0.9rem;
    font-weight: 600;
    color: #ccc;
    margin: 0;
}

.story-drop-sub {
    font-size: 0.75rem;
    color: #555;
    margin: 0;
}

/* ── Preview ────────────────────────────────────────────────── */
.story-preview-wrap {
    position: relative;
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.story-preview-media {
    width: 100%;
    max-height: 320px;
    object-fit: contain;
    border-radius: 8px;
    display: block;
}

.story-preview-clear {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,0.6);
    border: none;
    color: #fff;
    font-size: 1.2rem;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
}
.story-preview-clear:hover { background: rgba(220,38,38,0.8); }

/* ── Footer ─────────────────────────────────────────────────── */
.story-upload-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px 18px;
    border-top: 1px solid #1a1a1a;
    gap: 10px;
}

.story-upload-status {
    font-size: 0.75rem;
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 55%;
}

/* ── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 576px) {
    .story-viewer-wrap {
        max-width: 100%;
        border-radius: 0;
        max-height: 100dvh;
    }
}
    /* ── Preview grid ── */
    #preview-grid {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
      gap: 10px;
      margin-top: 1rem;
    }
    .thumb {
      position: relative;
      border-radius: 8px;
      overflow: hidden;
      aspect-ratio: 1;
      background: #e9ecef;
      border: 1px solid #dee2e6;
    }
    .thumb img,
    .thumb video {
      width: 100%;
      height: 100%;
      object-fit: cover;
      display: block;
    }
    .thumb .type-badge {
      position: absolute;
      top: 5px;
      left: 5px;
      background: rgba(0,0,0,.5);
      color: #fff;
      font-size: 9px;
      font-weight: 600;
      padding: 2px 6px;
      border-radius: 4px;
      letter-spacing: .4px;
    }
    .thumb .file-label {
      position: absolute;
      bottom: 0;
      left: 0; right: 0;
      background: rgba(0,0,0,.45);
      color: #fff;
      font-size: 10px;
      padding: 3px 6px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
    .thumb .btn-remove {
      position: absolute;
      top: 4px;
      right: 4px;
      width: 22px;
      height: 22px;
      border-radius: 50%;
      background: rgba(0,0,0,.55);
      color: #fff;
      border: none;
      font-size: 12px;
      line-height: 1;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      padding: 0;
    }
    .thumb .btn-remove:hover {
      background: #dc3545;
    }


    .story-btn-submit {
        background: linear-gradient(135deg, #f97316, #dc2626);
        border: none;
        color: #fff;
        padding: 7px 18px;
        border-radius: 8px;
        font-size: 0.82rem;
        font-weight: 600;
        cursor: pointer;
        transition: opacity 0.15s, transform 0.1s;
        box-shadow: 0 4px 14px rgba(249, 115, 22, 0.3);
        display: flex;
        align-items: center;
        gap: 4px;
    }

    .story-btn-cancel {
        background: #1a1a1a;
        border: 1px solid #2e2e2e;
        color: #888;
        padding: 7px 16px;
        border-radius: 8px;
        font-size: 0.82rem;
        font-weight: 500;
        cursor: pointer;
        transition: background 0.15s, color 0.15s;
    }

    .story-count {
        font-size: 0.75rem;
        color: #555;
        font-weight: 500;
        transition: color 0.2s;
        white-space:nowrap;
    }

    #file-count:not(:empty) {
        color: #f97316;
    }
