/**
 * Polyflor Collections Widget
 * Clean CSS with data attribute architecture
 */

/* ========================================
 * BASE VARIABLES
 * ======================================== */

[data-section-type="collections"] {
    --pct-primary: #1a1a1a;
    --pct-text: #666666;
    --pct-surface: #ffffff;
    width: 100%;
    font-family: "Helvetica Pro", Helvetica, Arial, sans-serif;
}

/* ========================================
 * HEADER
 * ======================================== */

[data-slot="header"] {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

[data-slot="heading"] {
    margin: 0;
    font-size: 28px;
    font-weight: 400;
    line-height: 1.2;
    color: var(--pct-primary);
    font-family: "Helvetica Pro", Helvetica, Arial, sans-serif;
}

[data-slot="header-link"] {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--pct-primary);
    text-decoration: underline;
    text-underline-offset: 3px;
    transition: opacity 0.2s ease;
}

[data-slot="header-link"] svg {
    width: 16px;
    height: 16px;
}

/* ========================================
 * GRID - BASE
 * ======================================== */

[data-slot="grid"] {
    display: grid;
    gap: 32px;
}

/* ========================================
 * GRID - COLUMNS (applies to both layouts)
 * ======================================== */

[data-section-type="collections"][data-columns="1"] [data-slot="grid"] {
    grid-template-columns: 1fr;
}

[data-section-type="collections"][data-columns="2"] [data-slot="grid"] {
    grid-template-columns: repeat(2, 1fr);
}

[data-section-type="collections"][data-columns="3"] [data-slot="grid"] {
    grid-template-columns: repeat(3, 1fr);
}

[data-section-type="collections"][data-columns="4"] [data-slot="grid"] {
    grid-template-columns: repeat(4, 1fr);
}

/* ========================================
 * GRID - FEATURE LAYOUT
 * Feature card spans 2 columns and 2 rows
 * ======================================== */

[data-section-type="collections"][data-layout="feature"] [data-slot="feature-card"] {
    grid-column: span 2;
    grid-row: span 2;
}

/* Feature with 2 columns: feature takes full width */
[data-section-type="collections"][data-layout="feature"][data-columns="2"] [data-slot="feature-card"] {
    grid-column: span 2;
    grid-row: span 1;
}

/* Feature with 1 column: everything stacks */
[data-section-type="collections"][data-layout="feature"][data-columns="1"] [data-slot="feature-card"] {
    grid-column: span 1;
    grid-row: span 1;
}

/* ========================================
 * FEATURE CARD
 * ======================================== */

[data-slot="feature-card"] {
    position: relative;
    display: block;
    text-decoration: none;
    color: inherit;
    min-height: 420px;
    overflow: hidden;
}

[data-slot="feature-card"] [data-slot="card-image"] {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

[data-slot="feature-card"] [data-slot="card-image"] img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Feature content overlay */
[data-slot="feature-content"] {
    position: absolute;
    bottom: 24px;
    left: 24px;
    right: 40%;
    background: var(--pct-surface, #ffffff);
    padding: 24px;
}

[data-slot="feature-content"] [data-slot="card-badge"] {
    display: block;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--pct-text);
    margin-bottom: 8px;
}

[data-slot="feature-content"] [data-slot="card-title"] {
    margin: 0 0 12px 0;
    font-size: 22px;
    font-weight: 500;
    line-height: 1.3;
    color: var(--pct-primary);
    font-family: "Helvetica Pro", Helvetica, Arial, sans-serif;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: transparent;
    transition: text-decoration-color 0.2s ease;
}

[data-slot="feature-card"]:hover [data-slot="card-title"],
[data-slot="feature-card"]:focus-visible [data-slot="card-title"] {
    text-decoration-color: currentColor;
}

[data-slot="feature-content"] [data-slot="card-description"] {
    margin: 0 0 16px 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--pct-text);
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

[data-slot="feature-content"] [data-slot="card-button"] {
    display: inline-block;
    font-size: 14px;
    font-weight: 500;
    color: var(--pct-primary);
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* ========================================
 * CONTENT CARD - BASE
 * ======================================== */

[data-slot="content-card"] {
    display: flex;
    text-decoration: none;
    color: inherit;
    transition: transform 0.2s ease;
}

[data-slot="content-card"] [data-slot="card-image"] {
    position: relative;
    overflow: hidden;
    background: #f0f0f0;
    flex-shrink: 0;
}

[data-slot="content-card"] [data-slot="card-image"] img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Badge on image */
[data-slot="content-card"] [data-slot="card-badge"] {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: var(--pct-surface, #ffffff);
    color: var(--pct-primary);
    border-radius: 4px;
    z-index: 1;
}

/* Card text */
[data-slot="card-text"] {
    display: flex;
    flex-direction: column;
}

[data-slot="card-text"] [data-slot="card-title"] {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 500;
    line-height: 1.4;
    color: var(--pct-primary);
    font-family: "Helvetica Pro", Helvetica, Arial, sans-serif;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: transparent;
    transition: text-decoration-color 0.2s ease;
}

[data-slot="content-card"]:hover [data-slot="card-title"],
[data-slot="content-card"]:focus-visible [data-slot="card-title"] {
    text-decoration-color: currentColor;
}

[data-slot="card-text"] [data-slot="card-description"] {
    margin: 0;
    font-size: 13px;
    line-height: 1.5;
    color: var(--pct-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ========================================
 * CARD VARIANT - PROMINENT (Vertical)
 * ======================================== */

[data-slot="content-card"][data-card-variant="prominent"] {
    flex-direction: column;
}

[data-slot="content-card"][data-card-variant="prominent"] [data-slot="card-image"] {
    aspect-ratio: 4 / 3;
    width: 100%;
    margin-bottom: 12px;
}

[data-slot="content-card"][data-card-variant="prominent"] [data-slot="card-title"] {
    font-size: 17px;
}

[data-slot="content-card"][data-card-variant="prominent"] [data-slot="card-description"] {
    -webkit-line-clamp: 3;
}

/* ========================================
 * CARD VARIANT - SUBTLE (Horizontal)
 * ======================================== */

[data-slot="content-card"][data-card-variant="subtle"] {
    flex-direction: row;
    align-items: flex-start;
    gap: 16px;
}

[data-slot="content-card"][data-card-variant="subtle"] [data-slot="card-image"] {
    width: 120px;
    height: 90px;
    flex-shrink: 0;
}

[data-slot="content-card"][data-card-variant="subtle"] [data-slot="card-text"] {
    padding-top: 4px;
}

[data-slot="content-card"][data-card-variant="subtle"] [data-slot="card-title"] {
    font-size: 15px;
}

[data-slot="content-card"][data-card-variant="subtle"] [data-slot="card-badge"] {
    top: 8px;
    left: 8px;
    padding: 3px 8px;
    font-size: 9px;
}

/* ========================================
 * RESPONSIVE - TABLET
 * Elementor handles column breakpoints,
 * we just adjust feature card behavior
 * ======================================== */

@media (max-width: 1024px) {
    [data-slot="feature-card"] {
        min-height: 360px;
    }

    [data-slot="feature-content"] {
        right: 25%;
    }
}

/* ========================================
 * RESPONSIVE - MOBILE (768px)
 * Major layout changes for touch devices
 * ======================================== */

@media (max-width: 768px) {
    /* Force single column on mobile */
    [data-slot="grid"] {
        grid-template-columns: 1fr !important;
        gap: 24px;
    }

    /* Feature card takes single column on mobile */
    [data-section-type="collections"][data-layout="feature"] [data-slot="feature-card"] {
        grid-column: span 1;
        grid-row: span 1;
    }

    /* Header stays as row on mobile */
    [data-slot="header"] {
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20px;
    }

    [data-slot="heading"] {
        font-size: 24px;
    }

    /* Header link - better touch target */
    [data-slot="header-link"] {
        min-height: 44px;
        padding: 8px 0;
    }

    /* Feature card - looks like regular card on mobile */
    [data-slot="feature-card"] {
        display: flex;
        flex-direction: column;
        min-height: auto;
    }

    [data-slot="feature-card"] [data-slot="card-image"] {
        position: relative;
        inset: auto;
        width: 100%;
        aspect-ratio: 4 / 3;
        margin-bottom: 12px;
    }

    /* Feature content - simple text below image like other cards */
    [data-slot="feature-content"] {
        position: relative;
        bottom: auto;
        left: auto;
        right: auto;
        margin: 0;
        padding: 0;
        background: transparent;
    }

    [data-slot="feature-content"] [data-slot="card-badge"] {
        display: inline-block;
        padding: 4px 10px;
        font-size: 11px;
        background: var(--pct-surface, #ffffff);
        border-radius: 4px;
        margin-bottom: 8px;
    }

    [data-slot="feature-content"] [data-slot="card-title"] {
        font-size: 17px;
        margin-bottom: 4px;
    }

    [data-slot="feature-content"] [data-slot="card-description"] {
        font-size: 13px;
        -webkit-line-clamp: 2;
        margin-bottom: 0;
    }

    [data-slot="feature-content"] [data-slot="card-button"] {
        display: none;
    }

    /* Subtle cards become vertical on mobile */
    [data-slot="content-card"][data-card-variant="subtle"] {
        flex-direction: column;
    }

    [data-slot="content-card"][data-card-variant="subtle"] [data-slot="card-image"] {
        width: 100%;
        height: auto;
        aspect-ratio: 16 / 10;
        margin-bottom: 12px;
    }

    [data-slot="content-card"][data-card-variant="subtle"] [data-slot="card-text"] {
        padding-top: 0;
    }

    /* Better touch targets for cards */
    [data-slot="card-text"] {
        min-height: 44px;
        padding: 4px 0;
    }

    /* Prominent card image spacing */
    [data-slot="content-card"][data-card-variant="prominent"] [data-slot="card-image"] {
        margin-bottom: 10px;
    }
}

/* ========================================
 * RESPONSIVE - SMALL MOBILE (540px)
 * Tighter spacing and stacked header
 * ======================================== */

@media (max-width: 540px) {
    /* Reduce grid gap further */
    [data-slot="grid"] {
        gap: 16px;
    }

    /* Header stays horizontal on small mobile */
    [data-slot="header"] {
        flex-wrap: nowrap;
        gap: 12px;
        margin-bottom: 16px;
    }

    [data-slot="heading"] {
        font-size: 22px;
    }

    /* Feature card matches other cards */
    [data-slot="feature-content"] [data-slot="card-title"] {
        font-size: 15px;
    }

    /* Content card adjustments */
    [data-slot="content-card"][data-card-variant="prominent"] [data-slot="card-title"],
    [data-slot="content-card"][data-card-variant="subtle"] [data-slot="card-title"] {
        font-size: 15px;
    }

    [data-slot="card-text"] [data-slot="card-description"] {
        font-size: 12px;
        -webkit-line-clamp: 2;
    }
}

/* ========================================
 * RESPONSIVE - EXTRA SMALL (400px)
 * Very compact layout for small phones
 * ======================================== */

@media (max-width: 400px) {
    /* Minimal grid gap */
    [data-slot="grid"] {
        gap: 12px;
    }

    /* Compact header */
    [data-slot="header"] {
        gap: 6px;
        margin-bottom: 12px;
    }

    [data-slot="heading"] {
        font-size: 20px;
    }

    [data-slot="header-link"] {
        font-size: 13px;
    }

    /* Feature card matches content cards */
    [data-slot="feature-card"] [data-slot="card-image"] {
        margin-bottom: 8px;
    }

    [data-slot="feature-content"] [data-slot="card-title"] {
        font-size: 14px;
    }

    /* Content cards - compact */
    [data-slot="content-card"][data-card-variant="prominent"] [data-slot="card-image"],
    [data-slot="content-card"][data-card-variant="subtle"] [data-slot="card-image"] {
        aspect-ratio: 16 / 9;
        margin-bottom: 8px;
    }

    [data-slot="content-card"][data-card-variant="prominent"] [data-slot="card-title"],
    [data-slot="content-card"][data-card-variant="subtle"] [data-slot="card-title"] {
        font-size: 14px;
    }

    [data-slot="card-text"] [data-slot="card-description"] {
        font-size: 11px;
    }

    /* Badge smaller on tiny screens */
    [data-slot="content-card"] [data-slot="card-badge"] {
        top: 8px;
        left: 8px;
        padding: 3px 6px;
        font-size: 9px;
    }
}

/* ========================================
 * ELEMENTOR EDITOR
 * ======================================== */

.elementor-editor-active [data-section-type="collections"] {
    min-height: 200px;
}

.elementor-editor-active [data-slot="grid"]:empty::after {
    content: 'Add collection items to display';
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px;
    text-align: center;
    color: #999;
    background: #f8f8f8;
    border: 2px dashed #ddd;
    font-size: 14px;
    grid-column: 1 / -1;
}

/* ========================================
 * HOVER ANIMATIONS (Optional)
 * Only active when data-animate="true"
 * ======================================== */

/* Prominent card - image scale on hover */
[data-animate="true"] [data-slot="content-card"][data-card-variant="prominent"] [data-slot="card-image"] img {
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

[data-animate="true"] [data-slot="content-card"][data-card-variant="prominent"]:hover [data-slot="card-image"] img {
    transform: scale(1.05);
}

/* Header link animation */
[data-animate="true"] [data-slot="header-link"] {
    transition: opacity 0.2s ease;
}

[data-animate="true"] [data-slot="header-link"]:hover {
    opacity: 0.7;
}

[data-animate="true"] [data-slot="header-link"] svg {
    transition: transform 0.2s ease;
}

[data-animate="true"] [data-slot="header-link"]:hover svg {
    transform: translateX(3px);
}

/* ========================================
 * ACCESSIBILITY
 * ======================================== */

@media (prefers-reduced-motion: reduce) {
    [data-slot="card-title"],
    [data-animate="true"] [data-slot="content-card"][data-card-variant="prominent"] [data-slot="card-image"] img,
    [data-animate="true"] [data-slot="header-link"],
    [data-animate="true"] [data-slot="header-link"] svg {
        transition: none !important;
    }
}

[data-slot="feature-card"]:focus-visible,
[data-slot="content-card"]:focus-visible,
[data-slot="header-link"]:focus-visible {
    outline: 2px solid var(--pct-primary);
    outline-offset: 4px;
}

/* ========================================
 * PRINT
 * ======================================== */

@media print {
    [data-section-type="collections"][data-layout="feature"] [data-slot="grid"],
    [data-section-type="collections"][data-layout="standard"] [data-slot="grid"] {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 16px !important;
    }

    [data-slot="feature-card"] {
        grid-column: span 1 !important;
        grid-row: span 1 !important;
        min-height: auto !important;
    }

    [data-slot="feature-content"] {
        position: relative !important;
        margin: 8px 0 0 0 !important;
        padding: 12px !important;
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }

    [data-slot="content-card"][data-card-variant="prominent"]:hover [data-slot="card-image"] img {
        transform: none !important;
    }
}
