/**
 * Collection Components CSS
 *
 * Global styles for collection slider component and collection view.
 * Most styles are encapsulated in Shadow DOM, but these provide
 * integration styles and overrides.
 */

/* Collection Slider Spacing */
collection-slider {
    display: block;
    margin: 2rem 0;
}

/* Ensure fonts are available for collection slider */
collection-slider {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Collection slider below hero, above filter bar */
.collection-slider-container {
    padding: 0;
    background: var(--page-bg, #0F0F0F);
}

/* ===========================================
   Collection Active State
   When a collection is selected, transform the page
   =========================================== */

/* Full-screen overlay feel */
html.collection-active {
    background: #0F0F0F;
    overflow-x: hidden;
}

html.collection-active body {
    background: #0F0F0F;
    overflow-x: hidden;
}

/* Hide collection slider when collection is active */
html.collection-active collection-slider {
    display: none !important;
}

/* Hide filter bar when collection is active */
html.collection-active workout-filter-bar {
    display: none !important;
}


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

.collection-back-btn:hover {
    background: var(--volt, #DFFF00);
    color: black;
    border-color: var(--volt, #DFFF00);
}

.collection-back-btn svg {
    width: 20px;
    height: 20px;
}

html.collection-active .collection-back-btn {
    display: flex;
}

/* Adjust for sidebar on desktop */
@media (min-width: 769px) and (max-width: 1599px) {
    .collection-back-btn {
        left: 80px; /* 60px sidebar + 20px padding */
    }
}

@media (min-width: 1600px) {
    .collection-back-btn {
        left: 300px; /* 280px sidebar + 20px padding */
    }
}

/* ===========================================
   Collection Groups Layout
   =========================================== */

/* Reset the main workout grid when in collection mode */
/* The workout-grid becomes a simple container for groups */
html.collection-active .workout-grid {
    display: block;
    padding: 0;
    max-width: 1400px;
    margin: 0 auto;
}

.collection-group {
    border-bottom: none;
    padding-bottom: 2rem;
    margin-bottom: 0;
}

.collection-group:last-child {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

/* Group header as accordion button */
.collection-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1rem 0 0;
    cursor: pointer;
    text-align: left;
    background: none;
    border: none;
    width: 100%;
}

.collection-group-header:hover .collection-group-title {
    color: rgba(255, 255, 255, 0.7);
}

/* First group - larger gap after hero for visual hierarchy */
.collection-group:first-child .collection-group-header {
    padding-top: 2rem;
}

.collection-group-header-left {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.collection-group-description {
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--volt, #DFFF00);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.collection-group-title {
    font-family: 'Anton', sans-serif;
    font-size: 2rem;
    text-transform: uppercase;
    color: white;
    margin: 0;
    transition: color 0.3s ease;
}

@media (min-width: 768px) {
    .collection-group-title {
        font-size: 2.5rem;
    }
}

.collection-group-header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.collection-group-count {
    font-family: 'Inter', sans-serif;
    font-size: 0.65rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    display: none;
}

@media (min-width: 768px) {
    .collection-group-count {
        display: block;
    }
}

.collection-group-chevron {
    width: 32px;
    height: 32px;
    color: white;
    transition: transform 0.3s ease;
}

.collection-group.collapsed .collection-group-chevron {
    transform: rotate(-90deg);
}

/* Accordion content */
.collection-group-content {
    transition: max-height 0.5s ease-in-out, opacity 0.5s ease-in-out;
    overflow: visible; /* Default - allows hover overflow for scaled cards */
    max-height: 1000px;
    opacity: 1;
}

/* Only clip during accordion animation */
.collection-group-content.animating {
    overflow: hidden;
}

/* Keep clipped when fully collapsed */
.collection-group.collapsed .collection-group-content {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
}

/* Group workout scroll - horizontal scrolling cards */
.collection-group-scroll {
    display: flex;
    overflow-x: auto;
    overflow-y: visible;
    gap: 1rem;
    /* Padding: top/bottom for hover scale, left at edge, right for last card */
    padding: 1.5rem 4rem 1.5rem 0;
    margin: -0.5rem -3rem -0.5rem 0;
    scroll-snap-type: x mandatory;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

@media (min-width: 768px) {
    .collection-group-scroll {
        padding: 3rem 4rem 3rem 0;
        margin: -1rem -3rem -1rem 0;
    }
}

/* Allow cards to overflow for hover effects */
.collection-group-content {
    overflow: visible;
}

.collection-group {
    overflow: visible;
}

.collection-group-scroll::-webkit-scrollbar {
    display: none;
}

/* Cards in collection groups - fixed width for horizontal scroll */
/* Follow-along is 16:9, regular is 8:9. Regular at half width = same height */
/* Exclude expanded cards from these constraints */
/* Mobile: ~85vw for follow-along (90% of full grid width) */
.collection-group-scroll follow-along-card:not(.expanded) {
    flex: 0 0 85vw;
    max-width: 85vw;
    scroll-snap-align: start;
    transform-origin: center center;
    will-change: transform;
}

.collection-group-scroll urban-workout-card:not(.expanded) {
    flex: 0 0 42.5vw;
    max-width: 42.5vw;
    scroll-snap-align: start;
    transform-origin: center center;
    will-change: transform;
}

@media (min-width: 768px) {
    .collection-group-scroll follow-along-card:not(.expanded) {
        flex: 0 0 420px;
        max-width: 420px;
        scroll-snap-align: start;
    }

    .collection-group-scroll urban-workout-card:not(.expanded) {
        flex: 0 0 210px;
        max-width: 210px;
        scroll-snap-align: start;
    }
}

/* Expanded cards need to break out of scroll container constraints */
.collection-group-scroll follow-along-card.expanded,
.collection-group-scroll urban-workout-card.expanded {
    flex: none;
    max-width: none;
}

/* ===========================================
   Collection Hero
   Large image with gradient fade, badge, title, description
   =========================================== */

/* Hide normal hero when collection is active */
html.collection-active hero-section {
    display: none !important;
}

/* Collection hero - hidden by default, shown when active */
.collection-hero {
    display: none;
    position: relative;
    height: 60vh;
    min-height: 500px;
    width: 100%;
    overflow: hidden;
    background: #0F0F0F;
}

html.collection-active .collection-hero {
    display: flex;
    align-items: flex-end;
    padding-bottom: 1rem;
    animation: slideUpFade 0.5s ease-out forwards;
}

/* Slide up animation for collection view */
/* IMPORTANT: End with transform: none (not translateY(0)) to avoid creating
   a containing block that breaks position:fixed on expanded cards */
@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(60px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

/* Animate collection groups with stagger */
/* NOTE: JavaScript clears the animation after completion to prevent
   transform from creating a containing block that breaks position:fixed */
html.collection-active .collection-group {
    animation: slideUpFade 0.5s ease-out forwards;
    opacity: 0;
}

html.collection-active .collection-group:nth-child(1) { animation-delay: 0.1s; }
html.collection-active .collection-group:nth-child(2) { animation-delay: 0.2s; }
html.collection-active .collection-group:nth-child(3) { animation-delay: 0.3s; }
html.collection-active .collection-group:nth-child(4) { animation-delay: 0.4s; }
html.collection-active .collection-group:nth-child(5) { animation-delay: 0.5s; }

/* State after animation cleared by JS */
html.collection-active .collection-group.animation-done {
    animation: none;
    opacity: 1;
    transform: none;
}

/* Animate study section */
html.collection-active .collection-study-section {
    animation: slideUpFade 0.5s ease-out forwards;
    animation-delay: 0.3s;
    opacity: 0;
}

.collection-hero-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    filter: grayscale(100%) contrast(1.25) brightness(0.5);
}

.collection-hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        #0F0F0F 0%,
        rgba(15, 15, 15, 0.8) 30%,
        rgba(15, 15, 15, 0.2) 60%,
        transparent 100%
    );
    z-index: 1;
}

.collection-hero-content {
    position: relative;
    z-index: 2;
    padding: 0 5%;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
}

.collection-hero-badge {
    display: inline-block;
    background: var(--volt, #DFFF00);
    color: #000;
    font-family: 'Inter', sans-serif;
    font-size: 0.625rem;
    font-weight: 800;
    text-transform: uppercase;
    padding: 0.375rem 0.75rem;
    letter-spacing: 0.05em;
}

.collection-hero-title {
    font-family: 'Anton', sans-serif;
    font-size: clamp(3rem, 10vw, 7rem);
    font-weight: 400;
    text-transform: uppercase;
    line-height: 0.95;
    color: white;
    margin: 0;
}

.collection-hero-title-outline {
    display: block;
    -webkit-text-stroke: 1px rgba(255, 255, 255, 0.3);
    color: transparent;
}

.collection-hero-descriptions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}

/* Mobile: hide desktop descriptions, show combined mobile description */
.collection-hero-description--desktop {
    display: none;
}

.collection-hero-description--mobile {
    display: block;
}

@media (min-width: 768px) {
    .collection-hero-descriptions {
        flex-direction: row;
        gap: 2rem;
    }

    /* Desktop: show separate descriptions, hide mobile combined */
    .collection-hero-description--desktop {
        display: block;
    }

    .collection-hero-description--mobile {
        display: none;
    }

    .collection-hero-description:nth-child(2) {
        border-left: none;
        padding-left: 0;
    }
}

.collection-hero-description {
    flex: 1;
    max-width: 400px;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.6;
    margin: 0;
    padding-left: 1rem;
    border-left: 2px solid var(--volt, #DFFF00);
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .collection-hero {
        height: 50vh;
        min-height: 400px;
        padding-bottom: 2rem;
    }

    .collection-hero-description {
        font-size: 0.8rem;
        max-width: 100%;
    }
}

/* ===========================================
   Collection Study Section
   Techniques and Articles below workout groups
   =========================================== */

.collection-study-section {
    margin-top: 1rem;
    padding-top: 1rem;
}

.collection-study-content {
    padding: 0 5%;
}

/* Override stage component padding within collection context */
.collection-study-content stage-page-study-section {
    display: block;
}
