/* ===========================================
   Follow-Along Page - Expanded Card State
   Detail content, back button, backdrop, preview mute
   =========================================== */

/* --- Expanded State --- */
/* Note: For shadow DOM components, position/size is handled by host element */
/* These styles are for non-component cards only */
.card.expanded:not(.shadow-dom-card) {
    position: fixed !important;
    z-index: 10001 !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    margin: 0 !important;
}

/* Common expanded styles for all cards */
.card.expanded {
    border-radius: 0;
    cursor: default;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scroll on iOS */
    background: #101010;
    display: block;
    aspect-ratio: auto;
    transform: none;
    touch-action: pan-y; /* Allow vertical scrolling inside modal */
    overscroll-behavior: contain; /* Prevent scroll chaining to background */
}

.card.expanded .card-inner {
    border-radius: 0;
    height: auto;
    min-height: 100vh;
    background: transparent;
    display: block !important;
}

/* Expanded Mode: Hero Header */
.card.expanded .thumbnail-wrapper {
    height: auto;
    aspect-ratio: 16/9;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

/* Mobile: Video touches top, full width */
@media (max-width: 768px) {
    .card.expanded .thumbnail-wrapper {
        max-width: 100%;
    }
}

.card.expanded .video-container {
    pointer-events: auto;
}

.card.expanded .card-overlay {
    opacity: 0;
    pointer-events: none;
    display: none !important;
}

/* Hide list-view mobile like button when expanded */
.card.expanded .list-like-mobile {
    display: none !important;
}

/* Expanded: hide thumbnail, show video */
.card.expanded .thumbnail-img {
    opacity: 0;
}

.card.expanded .preview-video {
    opacity: 1;
}

/* --- Detail Content --- */
.detail-content {
    display: none;
    padding: 30px 5%;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s ease 0.3s, transform 0.5s ease 0.3s;
    background: #101010;
    color: var(--text-primary);
}

.card.expanded .detail-content {
    display: block;
    opacity: 1;
    transform: translateY(0);
    max-width: 1200px;
    margin: 0 auto;
    padding-left: 0;
    padding-right: 0;
}

/* Padding when video is edge-to-edge (viewport < 1200px + padding) */
@media (max-width: 1232px) {
    .card.expanded .detail-content {
        padding-left: 16px;
        padding-right: 16px;
    }
}

.detail-header {
    margin-bottom: 30px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 20px;
    position: relative;
}

.detail-header-like {
    position: absolute;
    top: 0;
    right: 0;
}

.detail-category { color: var(--volt); font-size: 0.75rem; font-weight: 500; text-transform: uppercase; margin-bottom: 8px; letter-spacing: 0.1em; }
.detail-title { font-family: 'Anton', sans-serif; font-size: clamp(1.8rem, 5vw, 2.5rem); font-weight: 400; text-transform: uppercase; letter-spacing: 0.02em; margin-bottom: 8px; }
.detail-location { color: var(--text-secondary); font-size: 0.9rem; display: flex; align-items: center; gap: 6px; }
.detail-tabs { display: flex; gap: 30px; margin-bottom: 25px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.tab { padding-bottom: 10px; color: var(--text-secondary); cursor: pointer; font-size: 0.9rem; font-weight: 600; letter-spacing: 0.5px; border-bottom: 2px solid transparent; }
.tab.active { color: white; border-bottom: 2px solid var(--volt); }
.detail-body { display: grid; grid-template-columns: 1fr; gap: 40px; }
.description-text { color: #ccc; line-height: 1.6; font-size: 1rem; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; background: #1a1a1a; padding: 20px; border-radius: 8px; border: 1px solid #333; }
.stat-item label { display: block; color: var(--text-secondary); font-size: 0.7rem; text-transform: uppercase; margin-bottom: 5px; letter-spacing: 0.5px; }
.stat-item span { font-size: 0.95rem; color: white; font-weight: 500; }
.rating-dots { display: flex; gap: 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background-color: #444; }
.dot.filled { background-color: var(--volt); }

/* --- Back Button --- */
.control-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
    backdrop-filter: blur(4px);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease 0.3s;
}

.card.expanded .control-btn {
    opacity: 1;
    pointer-events: auto;
    display: flex;
    transition: opacity var(--player-transition-medium);
}

.control-btn svg {
    width: 18px;
    height: 18px;
}

.control-btn:hover {
    background: var(--volt);
    color: black;
    border-color: var(--volt);
}

/* --- Backdrop --- */
.backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    z-index: 10000; /* Same as sidebar, expanded card is 10001 */
}

body.has-expanded-card .backdrop {
    opacity: 1;
    pointer-events: auto;
}

/* Lock scroll when modal is expanded */
html.has-expanded-card,
html.has-expanded-card body {
    overflow: hidden !important;
    overscroll-behavior: none !important;
}

/* On mobile, use more aggressive scroll lock */
@media (max-width: 768px) {
    html.has-expanded-card,
    html.has-expanded-card body {
        position: fixed !important;
        width: 100% !important;
        height: 100% !important;
        touch-action: none !important;
    }
}

/* Hide navbar when expanded */
body.has-expanded-card .navbar {
    opacity: 0;
    pointer-events: none;
}

/* --- Preview Mute Button (desktop only) --- */
.preview-mute-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.6);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    display: none; /* Hidden by default, shown when video plays */
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, opacity 0.2s ease;
    opacity: 0;
    pointer-events: none;
}

.preview-mute-btn svg {
    width: 18px;
    height: 18px;
    color: white;
}

.preview-mute-btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* Show mute icon by default, hide unmute icon */
.preview-mute-btn .mute-icon {
    display: block;
}
.preview-mute-btn .unmute-icon {
    display: none;
}

/* When unmuted, show unmute icon, hide mute icon */
.preview-mute-btn.audio-on .mute-icon {
    display: none;
}
.preview-mute-btn.audio-on .unmute-icon {
    display: block;
}

/* Show button only when video is playing (desktop hover) */
.card.video-playing:not(.expanded) .preview-mute-btn {
    display: flex;
    opacity: 1;
    pointer-events: auto;
}

/* Hide on mobile */
@media (max-width: 768px) {
    .preview-mute-btn {
        display: none !important;
    }
}

/* Hide in list view */
.workout-grid.list-mode .preview-mute-btn {
    display: none !important;
}

/* Hide when card is expanded (full video controls take over) */
.card.expanded .preview-mute-btn {
    display: none !important;
}
