/**
 * File: assets/css/components.css
 * Description: Universal styles for CDA (Component-Driven Architecture) blocks.
 */

/* ==========================================================================
   1. UNIVERSAL EDITORIAL CARD
   ========================================================================== */
.py-card-editorial {
    background-color: var(--py-bg-surface);
    border: 1px solid var(--py-border);
    border-radius: 1rem;
    padding: 1.25rem;
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

.py-card-editorial:hover {
    border-color: var(--py-orange);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* ==========================================================================
   2. VISUAL ASSET WRAPPERS
   ========================================================================== */
.py-card-visual {
    background-color: var(--py-border); /* Subtle fallback background */
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

/* Height Modifiers for different contexts */
.py-card-visual--tall {
    height: 180px; /* Used for detailed Palette and Marketplace grids */
}

.py-card-visual--medium {
    height: 140px; /* Used for denser Home page grids */
}

/* Image constraints */
.py-card-visual img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    opacity: 0.9;
    transition: opacity 0.3s ease;
}

/* Fallback Placeholder Logo */
.py-card-visual img.py-placeholder-img {
    width: auto;
    height: auto;
    max-height: 60px;
    object-fit: contain;
    opacity: 0.4;
}

.py-card-editorial:hover .py-card-visual img.py-placeholder-img {
    opacity: 0.6; /* Slight hover effect for the fallback */
}

.py-card-editorial:hover .py-card-visual img {
    opacity: 1;
}

/* ==========================================================================
   3. STACKING BADGES
   ========================================================================== */
.py-card-badges {
    position: absolute;
    top: 0;
    right: 0; /* Align to the end */
    margin: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    align-items: flex-end;
    z-index: 3;
}

/* ==========================================================================
   4. TYPOGRAPHY & LAYOUT
   ========================================================================== */
.py-card-meta {
    font-size: 0.65rem;
    color: #6c757d; /* Bootstrap text-muted fallback */
    font-family: monospace;
    display: block;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.py-card-title {
    font-weight: 700;
    color: var(--py-text-main);
    margin-bottom: 0.25rem;
    font-size: 1.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.py-card-desc {
    font-size: 0.8rem;
    color: #6c757d;
    line-height: 1.5;
    margin-bottom: 1rem;
    flex-grow: 1; /* Automatically pushes the footer to the bottom of the card */
    
    /* Truncates text to exactly 3 lines to keep grid heights uniform */
    display: -webkit-box;
    line-clamp: 3;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ==========================================================================
   5. UNIFIED FOOTER
   ========================================================================== */
.py-card-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--py-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ==========================================================================
   6. GLOBAL BREADCRUMBS
   ========================================================================== */
.py-breadcrumb {
    font-size: 0.85rem;
    font-family: monospace;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.py-breadcrumb a {
    color: #6c757d; /* text-muted */
    text-decoration: none;
    transition: color 0.2s ease;
}

.py-breadcrumb a:hover {
    color: var(--py-orange); /* Replaces your hover-orange utility */
}

.py-breadcrumb .active {
    color: var(--py-text-main);
    font-weight: bold;
}

/* Custom separator */
.py-breadcrumb-item + .py-breadcrumb-item::before {
    content: "/";
    color: #6c757d;
    opacity: 0.5;
    padding: 0 0.5rem;
}

/* ==========================================================================
   7. MODULE SUB-NAVIGATION
   ========================================================================== */
.py-sub-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 3rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--py-border);
}

.py-sub-nav .btn {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    font-size: 0.875rem; /* Equivalent to .btn-sm */
    font-weight: 600;
}

/* ==========================================================================
   8. Universal Carousel
   ========================================================================== */
    .py-carousel-container {
        position: relative;
        width: 100%;
        margin-top: 1.5rem;
    }
    .py-carousel-track {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
        gap: 1.5rem;
        padding-bottom: 1.5rem; /* Room for drop shadows */
    }
    .py-carousel-track::-webkit-scrollbar {
        display: none; /* Chrome/Safari/Edge */
    }
    .py-carousel-track > .py-carousel-item {
        flex: 0 0 auto;
        scroll-snap-align: start;
    }
    
    /* Device-Specific Peeking Widths */
    @media (min-width: 992px) {
        .py-carousel-track > .py-carousel-item { width: calc(100% / 4.2); } /* Shows 4, peeks 5th */
    }
    @media (min-width: 768px) and (max-width: 991.98px) {
        .py-carousel-track > .py-carousel-item { width: calc(100% / 2.2); } /* Shows 2, peeks 3rd */
    }
    @media (max-width: 767.98px) {
        .py-carousel-track > .py-carousel-item { width: 85%; } /* Shows 1, peeks 2nd */
    }

    /* Floating Navigation Buttons */
    .py-carousel-btn {
        position: absolute;
        top: 40%;
        transform: translateY(-50%);
        z-index: 10;
        width: 45px;
        height: 45px;
        border-radius: 50%;
        background-color: var(--py-bg-surface);
        border: 1px solid var(--py-border);
        color: var(--py-text-main);
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.2s ease;
    }
    .py-carousel-btn:hover {
        background-color: var(--py-bg-base);
        color: var(--py-orange);
        border-color: var(--py-orange);
    }
    .py-carousel-btn.prev { left: -22px; }
    .py-carousel-btn.next { right: -22px; }
    
    /* Auto-hide arrows on touch devices */
    @media (max-width: 991.98px) {
        .py-carousel-btn { display: none; }
    }