/* ===========================================
   Follow-Along Page - Card Styles
   Filter bar, main container, loading, grid, card base
   =========================================== */

/* --- Workout Filter Bar Overrides --- */
workout-filter-bar {
    --volt: #DFFF00;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: block;
    min-height: 69px; /* Reserve space before component loads to prevent layout shift */
}

@media (max-width: 768px) {
    workout-filter-bar {
        min-height: 57px; /* Smaller on mobile */
    }
}

/* --- Main Content --- */
.main-container {
    padding: 30px 5% 60px;
    min-height: 50vh;
    position: relative;
    max-width: 1600px;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .main-container {
        padding: 20px 12px 60px;
    }
}

.section-title {
    font-family: 'Anton', sans-serif;
    font-size: 1.5rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* Loading State */
.loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--volt);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- Grid Layout (Default) --- */
/* Use even column counts so follow-along cards can span 2 */
.workout-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding-bottom: 50px;
    /* No transition on grid - causes layout shift when cards expand */
}

@media (min-width: 700px) { .workout-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1100px) { .workout-grid { grid-template-columns: repeat(6, 1fr); } }
@media (min-width: 1500px) { .workout-grid { grid-template-columns: repeat(8, 1fr); } }

/* Follow-along cards span 2 columns */
.card.follow-along-card {
    grid-column: span 2;
}

/* Regular workout cards span 1 column */
.card.regular-card {
    grid-column: span 1;
}

/* --- Placeholder for expanded cards (preserves grid space) --- */
.card-placeholder {
    pointer-events: none;
    visibility: hidden;
}

/* Follow-along placeholder spans 2 columns like the card */
.card-placeholder.follow-along-placeholder {
    grid-column: span 2;
}

/* Placeholder in list mode */
.workout-grid.list-mode .card-placeholder {
    grid-column: span 1 !important;
}

/* --- List View Mode --- */
.workout-grid.list-mode {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* --- Workout Card Base --- */
.card {
    background-color: var(--card-bg);
    border-radius: 4px;
    position: relative;
    cursor: pointer;
    z-index: 1;
    transform-origin: center center;
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.3s ease;
    aspect-ratio: 16/9;
}

/* List Mode: Card Reset */
.workout-grid.list-mode .card {
    aspect-ratio: auto;
    height: 64px;
    display: flex;
    align-items: center;
    padding: 0;
    overflow: hidden;
    border: 1px solid #333;
    grid-column: span 1 !important; /* All cards same width in list */
}

/* In list mode, hide thumbnail badge, show inline badge */
.workout-grid.list-mode .thumbnail-wrapper .follow-along-badge {
    display: none;
}

/* List badge (inline with title) - hidden by default, shown in list mode */
.follow-along-badge.list-badge {
    display: none;
}

.workout-grid.list-mode .follow-along-badge.list-badge {
    display: inline-flex;
    position: static;
    width: 18px;
    height: 18px;
    font-size: 8px;
    margin-left: 8px;
    flex-shrink: 0;
    vertical-align: middle;
}

/* Hide title badge on mobile list (we use meta badge instead) */
@media (max-width: 768px) {
    .workout-grid.list-mode .follow-along-badge.list-badge {
        display: none;
    }
}

/* Hover: Grid Mode - Follow-along cards (desktop only) */
@media (hover: hover) and (pointer: fine) and (min-width: 769px) {
    .workout-grid:not(.list-mode) .card.follow-along-card:not(.expanded):hover {
        transform: scale(1.3);
        box-shadow: 0 20px 40px rgba(0,0,0,0.7);
        z-index: 100;
    }
}

/* Hover: Grid Mode - Regular cards (desktop only) */
@media (hover: hover) and (pointer: fine) and (min-width: 769px) {
    .workout-grid:not(.list-mode) .card.regular-card:hover {
        transform: scale(1.3);
        box-shadow: 0 20px 40px rgba(0,0,0,0.7);
        z-index: 100;
    }
}

/* Regular card specific styles */
/* Half the width of follow-along (16/9), so use 8/9 for same height */
.card.regular-card {
    aspect-ratio: 8/9;
}

.card.regular-card .card-inner {
    background: var(--card-bg);
}

.card.regular-card .thumbnail-img {
    opacity: 0.85;
    transition: opacity 0.3s ease;
}

/* Thumbnail hover only on desktop */
@media (hover: hover) and (pointer: fine) and (min-width: 769px) {
    .card.regular-card:hover .thumbnail-img {
        opacity: 1;
    }
}

.card.regular-card .card-overlay {
    background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.6) 50%, transparent 100%);
    padding: 15px 12px;
}

.card.regular-card .card-title {
    font-size: 0.85rem;
    line-height: 1.3;
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card.regular-card .card-meta {
    font-size: 0.7rem;
    margin-top: 4px;
}

/* Hide play icon overlay for regular cards */
.card.regular-card .play-icon-overlay {
    display: none;
}

/* ===========================================
   LOCKED CARD STATE
   =========================================== */
.card.locked {
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.3s ease;
}

.card.locked:hover {
    opacity: 0.85;
    transform: none !important;
    box-shadow: none !important;
}

.card.locked .thumbnail-img {
    opacity: 0.4 !important;
    filter: grayscale(100%);
}

.card.locked:hover .thumbnail-img {
    opacity: 0.4 !important;
    filter: grayscale(100%);
    transform: none !important;
}

/* Hide like button on locked cards */
.card.locked .card-like-btn {
    display: none;
}

/* Lock icon overlay */
.lock-icon-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 10;
}

.lock-icon-overlay svg {
    width: 20px;
    height: 20px;
    color: rgba(255, 255, 255, 0.5);
}

/* Locked card title - gray */
.card.locked .card-title {
    color: rgba(255, 255, 255, 0.4);
}

/* Locked card meta */
.card.locked .card-meta {
    color: rgba(255, 255, 255, 0.3);
}

/* Follow-along badge (camera icon) - hidden in grid, only shown in list */
.follow-along-badge {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: var(--volt);
    color: #000;
    width: 28px;
    height: 28px;
    display: none; /* Hidden in grid view */
    align-items: center;
    justify-content: center;
    font-size: 12px;
    z-index: 5;
    transition: opacity 0.3s ease;
}

.card.expanded .follow-along-badge {
    opacity: 0;
}

/* Like button - top left in grid (urban style) */
.card-like-btn {
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 5;
    transition: opacity 0.3s ease;
}

.card.expanded .card-like-btn {
    opacity: 0;
}

/* Hide card like button in list mode */
.workout-grid.list-mode .card-like-btn {
    display: none;
}

/* Done checkmark - top right in grid (urban style) */
.card-done-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    z-index: 5;
    width: 28px;
    height: 28px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(223, 255, 0, 0.4);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

.card-done-btn svg {
    width: 16px;
    height: 16px;
    color: #DFFF00;
    stroke: #DFFF00;
    stroke-width: 2.5;
}

.card.expanded .card-done-btn {
    opacity: 0;
}

/* Hide done checkmark in list mode (the grid version) */
.workout-grid.list-mode .card-done-btn {
    display: none;
}

/* List mode: Done checkmark inline with meta (mobile) */
.list-done-check {
    display: none;
    color: #DFFF00;
    margin-left: 8px;
}

.list-done-check svg {
    width: 14px;
    height: 14px;
    stroke: #DFFF00;
    stroke-width: 3;
    vertical-align: middle;
}

/* Show inline checkmark only on mobile list mode */
@media (max-width: 768px) {
    .workout-grid.list-mode .list-done-check {
        display: inline-flex;
        align-items: center;
    }
}

/* Mobile list: Follow-along icon in meta (before done check) */
.list-meta-follow-along {
    display: none;
    color: #DFFF00;
    margin-left: 8px;
}

.list-meta-follow-along i {
    font-size: 10px;
}

.list-meta-follow-along svg {
    width: 12px;
    height: 12px;
    color: #DFFF00;
}

/* Show follow-along icon in mobile list mode only */
@media (max-width: 768px) {
    .workout-grid.list-mode .list-meta-follow-along {
        display: inline-flex;
        align-items: center;
    }

    .card.list-view .list-meta-follow-along {
        display: inline-flex;
        align-items: center;
    }
}

/* List mode: Done checkmark after like button (desktop) */
.list-done-container {
    display: none;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
}

.workout-grid.list-mode .list-done-container {
    display: flex;
}

@media (max-width: 768px) {
    .workout-grid.list-mode .list-done-container {
        display: none;
    }
}

.list-done-container svg {
    width: 18px;
    height: 18px;
    stroke: #DFFF00;
    stroke-width: 2.5;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .follow-along-badge {
        width: 24px;
        height: 24px;
        font-size: 10px;
    }

    .card-title {
        font-size: 0.85rem !important;
    }

    .card-meta {
        font-size: 0.7rem !important;
    }
}

/* Hover: List Mode - Subtle (desktop only) */
@media (hover: hover) and (pointer: fine) and (min-width: 769px) {
    .workout-grid.list-mode .card:not(.expanded):hover {
        transform: scale(1.02);
        box-shadow: 0 4px 12px rgba(0,0,0,0.5);
        z-index: 2;
    }
}

.card-inner {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    background: #000;
    transition: border-radius 0.3s ease;
}

/* List Mode: Flex Inner */
.workout-grid.list-mode .card-inner {
    display: flex;
    flex-direction: row;
    align-items: center;
    background: var(--card-bg);
}

/* --- Thumbnail / Video Area --- */
.thumbnail-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    transition: all 0.5s cubic-bezier(0.22, 0.61, 0.36, 1);
    overflow: hidden;
}

/* List Mode: Small Thumbnail */
.workout-grid.list-mode .thumbnail-wrapper {
    width: 100px;
    height: 100%;
    flex-shrink: 0;
}

/* Snap Transition */
.card.snap-transition .thumbnail-wrapper,
.card.snap-transition .thumbnail-img {
    transition: none !important;
}

.thumbnail-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.5s ease, filter 0.3s ease;
}

/* Grey filter only on desktop grid mode */
@media (min-width: 769px) and (hover: hover) and (pointer: fine) {
    .workout-grid:not(.list-mode) .thumbnail-img {
        filter: grayscale(60%) brightness(0.8);
    }

    .workout-grid:not(.list-mode) .card:hover .thumbnail-img {
        filter: grayscale(0%) brightness(1);
    }

    /* Shadow DOM cards (no .workout-grid ancestor) */
    .card:not(.list-view) .thumbnail-img {
        filter: grayscale(60%) brightness(0.8);
    }

    .card:not(.list-view):hover:not(.locked) .thumbnail-img {
        filter: grayscale(0%) brightness(1);
    }
}

.card.video-playing .thumbnail-img {
    opacity: 0;
}

.video-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.preview-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.8s ease;
    transform: scale(1);
    transform-origin: center;
}

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

/* --- Content & Overlays --- */

.card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 10px;
    background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
    opacity: 1;
    transition: opacity 0.2s;
    pointer-events: none;
}

.workout-grid.list-mode .card-overlay {
    position: relative;
    background: none;
    width: auto;
    flex: 1;
    min-width: 0;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    overflow: hidden;
}

@media (max-width: 768px) {
    .workout-grid.list-mode .card-overlay {
        padding: 0 12px;
    }
}

.card-info-main {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.workout-grid.list-mode .card-info-main {
    justify-content: center;
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.card-title {
    font-family: 'Anton', sans-serif;
    font-size: 1rem;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #fff;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.workout-grid.list-mode .card-title {
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    margin-bottom: 2px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.card-meta {
    display: flex;
    font-size: 0.75rem;
    color: #ddd;
}

.tag {
    font-size: 0.6rem;
    padding: 2px 6px;
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 2px;
    margin-right: 5px;
    text-transform: uppercase;
    display: inline-block;
}

.tag.free {
    background: var(--volt);
    color: #000;
    border-color: var(--volt);
}

/* ===========================================
   SHADOW DOM LIST VIEW STYLES
   For follow-along-card component which uses Shadow DOM
   These duplicate .workout-grid.list-mode rules using .card.list-view
   =========================================== */

/* List View: Card Reset */
.card.list-view {
    aspect-ratio: auto;
    height: 64px;
    display: flex;
    align-items: center;
    padding: 0;
    overflow: hidden;
    border: 1px solid #333;
}

/* List View: Expanded Override */
.card.list-view.expanded {
    height: auto;
    min-height: 100%;
    display: block;
    border: none;
    overflow: visible;
}

/* List view: hide thumbnail badge, show inline badge */
.card.list-view .thumbnail-wrapper .follow-along-badge {
    display: none;
}

.card.list-view .follow-along-badge.list-badge {
    display: inline-flex;
    position: static;
    width: 18px;
    height: 18px;
    font-size: 8px;
    margin-left: 8px;
    flex-shrink: 0;
    vertical-align: middle;
}

@media (max-width: 768px) {
    .card.list-view .follow-along-badge.list-badge {
        display: none;
    }
}

/* Hover: List View - Subtle (desktop only) */
@media (hover: hover) and (pointer: fine) and (min-width: 769px) {
    .card.list-view:not(.expanded):hover {
        transform: scale(1.02);
        box-shadow: 0 4px 12px rgba(0,0,0,0.5);
        z-index: 2;
    }
}

/* List View: Flex Inner */
.card.list-view .card-inner {
    display: flex;
    flex-direction: row;
    align-items: center;
    background: var(--card-bg);
}

/* List View: Small Thumbnail */
.card.list-view .thumbnail-wrapper {
    width: 100px;
    height: 100%;
    flex-shrink: 0;
}

/* Hide card like button in list view */
.card.list-view .card-like-btn {
    display: none;
}

/* Hide done checkmark in list view (the grid version) */
.card.list-view .card-done-btn {
    display: none;
}

/* Show inline checkmark only on mobile list view */
@media (max-width: 768px) {
    .card.list-view .list-done-check {
        display: inline-flex;
        align-items: center;
    }
}

/* Show follow-along icon in mobile list view only */
@media (max-width: 768px) {
    .card.list-view .list-meta-follow-along {
        display: inline-flex;
        align-items: center;
    }
}

/* List view: Done checkmark after like button (desktop) */
.card.list-view .list-done-container {
    display: flex;
}

@media (max-width: 768px) {
    .card.list-view .list-done-container {
        display: none;
    }
}

/* List View: Card Overlay */
.card.list-view .card-overlay {
    position: relative;
    background: none;
    width: auto;
    flex: 1;
    min-width: 0;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    overflow: hidden;
}

@media (max-width: 768px) {
    .card.list-view .card-overlay {
        padding: 0 12px;
    }
}

/* List View: Info Main */
.card.list-view .card-info-main {
    justify-content: center;
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

/* List View: Card Title */
.card.list-view .card-title {
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0;
    margin-bottom: 2px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
