/* ==========================================================================
   Shorts Video Player (9:16 TikTok-Style Full-Screen Feed)
   ========================================================================== */

/* --- Container: vertical snap feed --- */
.shorts-feed-container {
    position: relative;
    width: 100%;
    max-width: 440px;
    height: calc(100vh - 88px);          /* fallback */
    height: calc(100dvh - 88px);
    scroll-snap-type: y mandatory;
    overflow-y: scroll;
    overflow-x: hidden;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    background: #000;
    border-radius: var(--radius-xl);
}

.shorts-feed-container::-webkit-scrollbar {
    display: none;
}

/* --- Each slide card: exactly one viewport tile --- */
.short-card {
    scroll-snap-align: start;
    scroll-snap-stop: always;
    position: relative;
    width: 100%;
    height: 100%;                       /* fills one snap-viewport */
    background: #000;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    content-visibility: auto;
    contain-intrinsic-size: 100% 100%;
}

/* Subtle separator between cards */
.short-card + .short-card {
    border-top: 1px solid rgba(255,255,255,0.06);
}

/* --- Video element core --- */
.short-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
    background: #0a0a0a;
    display: block;
    will-change: transform;
}

.short-video[poster] {
    background-size: cover;
    background-position: center;
}

/* ==========================================================================
   Overlay Elements
   ========================================================================== */

/* --- Bottom info bar (author + caption) --- */
.short-overlay-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 76px;
    padding: 36px 18px 24px 18px;
    background: linear-gradient(0deg,
        rgba(0,0,0,0.92) 0%,
        rgba(0,0,0,0.50) 50%,
        transparent 100%);
    color: #FFF;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 20;
    pointer-events: none;
    user-select: none;
}

.short-overlay-bottom * {
    pointer-events: auto;
}

.short-author {
    display: flex;
    align-items: center;
    gap: 10px;
}

.short-author .avatar {
    width: 40px;
    height: 40px;
    border: 2px solid rgba(255,255,255,0.9);
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.short-author .name {
    font-weight: 800;
    font-size: 15px;
    color: #FFF;
    text-shadow: 0 1px 6px rgba(0,0,0,0.9);
    text-decoration: none;
}

.short-follow-btn {
    flex-shrink: 0;
    background: rgba(255,255,255,0.18);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #FFF;
    border: 1px solid rgba(255,255,255,0.35);
    border-radius: var(--radius-full);
    padding: 5px 16px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.short-follow-btn:hover,
.short-follow-btn:active {
    background: var(--primary);
    border-color: var(--primary);
}

.short-caption {
    font-size: 14px;
    line-height: 1.5;
    max-height: 72px;
    overflow: hidden;
    color: rgba(255,255,255,0.93);
    text-shadow: 0 1px 6px rgba(0,0,0,0.9);
    word-break: break-word;
}

.short-caption .hashtag {
    color: #60A5FA;
    font-weight: 700;
}

/* --- Right action column --- */
.short-actions-right {
    position: absolute;
    bottom: 28px;
    right: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 22px;
    z-index: 20;
}

.short-action-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: #FFF;
    gap: 5px;
    cursor: pointer;
    text-decoration: none;
    transition: transform var(--transition-fast);
}

.short-action-item:active {
    transform: scale(0.92);
}

.short-action-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(0,0,0,0.45);
    border: 1px solid rgba(255,255,255,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: transform var(--transition-fast), background var(--transition-fast);
    box-shadow: 0 4px 14px rgba(0,0,0,0.5);
}

.short-action-icon:active {
    transform: scale(1.18);
    background: rgba(0,0,0,0.7);
}

.short-action-item.liked .short-action-icon {
    color: #FF2D55;
    border-color: rgba(255,45,85,0.4);
    background: rgba(255,45,85,0.22);
}

.short-action-item.liked .short-action-icon i {
    animation: bounceScale 0.45s cubic-bezier(0.175,0.885,0.32,1.275);
}

.short-action-label {
    font-size: 11.5px;
    font-weight: 700;
    text-shadow: 0 1px 6px rgba(0,0,0,0.9);
}

/* --- Top-right sound toggle --- */
.short-sound-btn {
    position: absolute;
    top: 18px;
    right: 16px;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #FFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    cursor: pointer;
    z-index: 30;
    border: 1px solid rgba(255,255,255,0.12);
    transition: transform var(--transition-fast), background var(--transition-fast);
}

.short-sound-btn:active {
    transform: scale(1.15);
    background: rgba(0,0,0,0.75);
}

/* --- Equalizer bars --- */
.equalizer-bars {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 14px;
}

.equalizer-bar {
    width: 2.5px;
    background: #FFF;
    border-radius: 1px;
    transition: height 0.15s ease;
}

.equalizer-bars.playing .equalizer-bar:nth-child(1) { animation: soundWave 0.55s infinite ease-in-out; }
.equalizer-bars.playing .equalizer-bar:nth-child(2) { animation: soundWave 0.75s infinite ease-in-out 0.15s; }
.equalizer-bars.playing .equalizer-bar:nth-child(3) { animation: soundWave 0.45s infinite ease-in-out 0.3s; }

/* --- Play / Pause indicator --- */
.short-play-state-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #FFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.175,0.885,0.32,1.275);
    z-index: 25;
}

.short-play-state-indicator.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* --- Progress seek bar --- */
.short-progress-bar-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255,255,255,0.15);
    z-index: 25;
    cursor: pointer;
}

.short-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #FF2D55, #FF5177);
    width: 0%;
    transition: width 0.08s linear;
    border-radius: 0 1px 1px 0;
}

/* --- Heart burst overlay (double-tap) --- */
.short-card .heart-burst-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 90px;
    color: #FFF;
    filter: drop-shadow(0 8px 24px rgba(255,45,85,0.7));
    pointer-events: none;
    display: none;
    z-index: 35;
}

.short-card .heart-burst-overlay.animate {
    display: block;
    animation: heartBurst 0.8s cubic-bezier(0.175,0.885,0.32,1.275) forwards;
}

/* --- Loading spinner card --- */
.short-card-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    background: #0a0a0a;
}

.short-card-loader .spinner {
    width: 40px;
    height: 40px;
    border-width: 3px;
    border-color: rgba(255,255,255,0.15);
    border-top-color: #FF2D55;
}

.short-card-loader .shorts-loading-text {
    color: rgba(255,255,255,0.5);
    font-size: 13px;
    font-weight: 600;
}

/* Shimmer loading skeleton */
.short-card-loader.shimmer {
    background: linear-gradient(
        90deg,
        #0a0a0a 0%,
        #1a1a2e 40%,
        #0a0a0a 80%
    );
    background-size: 200% 100%;
    animation: shortsShimmer 1.5s ease-in-out infinite;
}

@keyframes shortsShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ==========================================================================
   Sound Indicator Flash
   ========================================================================== */

.short-sound-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 10px 18px;
    border-radius: var(--radius-full);
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #FFF;
    font-size: 14px;
    font-weight: 700;
    opacity: 0;
    pointer-events: none;
    z-index: 35;
    transition: opacity 0.2s ease;
}

.short-sound-indicator.show {
    opacity: 1;
}

/* ==========================================================================
   Empty & Error States
   ========================================================================== */

.shorts-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 40px;
    text-align: center;
    color: #FFF;
    background: radial-gradient(ellipse at center, #1a1025 0%, #000 100%);
}

.shorts-empty-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    box-shadow: 0 8px 28px rgba(255,45,85,0.5);
}

.shorts-empty-illustration {
    width: 200px;
    height: 200px;
    max-width: 65vw;
    object-fit: contain;
    margin-bottom: 8px;
    filter: drop-shadow(0 14px 28px rgba(247, 37, 133, 0.4));
    animation: floatSubtle 4s ease-in-out infinite alternate;
}

.shorts-empty-title {
    font-size: 20px;
    font-weight: 800;
}

.shorts-empty-desc {
    font-size: 14px;
    color: rgba(255,255,255,0.65);
    max-width: 300px;
    line-height: 1.5;
}

.shorts-error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 40px;
    text-align: center;
    color: #FFF;
    background: #000;
}

.shorts-error-icon {
    font-size: 36px;
    color: #F59E0B;
}

.shorts-error-text {
    font-size: 14px;
    color: rgba(255,255,255,0.7);
}

/* ==========================================================================
   Infinite Scroll Sentinel
   ========================================================================== */

.shorts-sentinel {
    width: 100%;
    height: 1px;
    scroll-snap-align: none;
    opacity: 0;
    pointer-events: none;
}

/* ==========================================================================
   Action Item Polish
   ========================================================================== */

.short-action-item {
    will-change: transform;
}

/* ==========================================================================
   Reduced Motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .shorts-feed-container {
        scroll-behavior: auto;
    }

    .short-card {
        content-visibility: visible;
    }

    .short-card .heart-burst-overlay.animate,
    .short-action-item.liked .short-action-icon i {
        animation: none;
    }

    .short-play-state-indicator {
        transition: none;
    }

    .short-card-loader.shimmer {
        animation: none;
        background: #0a0a0a;
    }

    .equalizer-bars.playing .equalizer-bar {
        animation: none;
    }
}

/* ==========================================================================
   Desktop (> 767px)
   ========================================================================== */

@media (min-width: 768px) {
    .shorts-feed-container {
        border-radius: var(--radius-xl);
        box-shadow: 0 16px 48px rgba(0,0,0,0.5);
    }

    .short-card {
        border-radius: var(--radius-xl);
    }
}

/* ==========================================================================
   Mobile (< 768px) — Full-Screen Immersive
   ========================================================================== */

@media (max-width: 767px) {

    /* Full viewport height: header + bottom nav space */
    .shorts-feed-container {
        max-width: 100%;
        width: 100%;
        height: 100dvh;
        height: 100vh;
        border-radius: 0;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 200;
    }

    .short-card {
        border-radius: 0;
        border: none;
        box-shadow: none;
    }

    /* Adjust overlay spacing for safe areas */
    .short-overlay-bottom {
        right: 62px;
        padding: 40px 14px 28px 14px;
        padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
    }

    .short-actions-right {
        bottom: 32px;
        bottom: calc(32px + env(safe-area-inset-bottom, 0px));
        right: 10px;
        gap: 18px;
    }

    .short-action-icon {
        width: 44px;
        height: 44px;
        font-size: 22px;
    }

    .short-action-label {
        font-size: 10.5px;
    }

    .short-sound-btn {
        top: calc(18px + env(safe-area-inset-top, 0px));
        right: 14px;
        width: 36px;
        height: 36px;
    }

    .short-author .name {
        font-size: 14px;
    }

    .short-caption {
        font-size: 13px;
        max-height: 60px;
    }

    .short-progress-bar-container {
        height: 2px;
    }

    /* Close / back button for mobile exit */
    .shorts-mobile-back {
        display: flex;
        position: fixed;
        top: calc(14px + env(safe-area-inset-top, 0px));
        left: 14px;
        z-index: 220;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: rgba(0,0,0,0.5);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        color: #FFF;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        cursor: pointer;
        border: 1px solid rgba(255,255,255,0.15);
        text-decoration: none;
    }
}

@media (min-width: 768px) {
    .shorts-mobile-back {
        display: none;
    }
}

/* ==========================================================================
   Rotating Vinyl Music Disc (Phase 2)
   ========================================================================== */

.short-music-disc-wrapper {
    position: relative;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 4px;
    cursor: pointer;
}

.short-music-disc {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: radial-gradient(circle, #1e293b 35%, #090d16 65%, #000 100%);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6), inset 0 0 0 2px rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid #18181b;
    position: relative;
    animation: spinMusicDisc 3.5s linear infinite;
    animation-play-state: paused;
    transition: transform 0.2s ease;
}

.short-music-disc.spinning {
    animation-play-state: running;
}

.short-music-disc:hover {
    transform: scale(1.08);
}

.short-music-disc .music-avatar {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.music-notes {
    position: absolute;
    top: 0;
    left: -4px;
    pointer-events: none;
}

.music-note {
    position: absolute;
    color: #f43f5e;
    font-size: 14px;
    font-weight: 700;
    opacity: 0;
    text-shadow: 0 0 6px rgba(244, 63, 94, 0.7);
}

.short-music-disc.spinning ~ .music-notes .n1 {
    animation: floatMusicNote 2.4s ease-out infinite;
}

.short-music-disc.spinning ~ .music-notes .n2 {
    animation: floatMusicNote 2.4s ease-out infinite 1.2s;
}

@keyframes spinMusicDisc {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes floatMusicNote {
    0% {
        transform: translate(0, 0) scale(0.6) rotate(0deg);
        opacity: 0;
    }
    30% {
        opacity: 0.95;
    }
    100% {
        transform: translate(-22px, -42px) scale(1.15) rotate(-25deg);
        opacity: 0;
    }
}