/**
 * ZFlix legacy card layout compatibility layer.
 * Restores the spacing, poster proportions and readable two-line titles from
 * the previous theme while keeping DooPlay 2.5.24 templates and security fixes.
 */

/*
 * DooPlay bundles Font Awesome 5, while this Font Awesome 6 class name is used
 * by the legacy ZFlix markup. Map it to FA5's supported magic-wand glyph.
 */
.fas.fa-wand-magic-sparkles::before {
    content: "\f0d0" !important;
}

/* Font-independent icon used by the Smart Filter controls. */
.zflix-inline-magic-icon {
    display: inline-block !important;
    width: 16px !important;
    height: 16px !important;
    margin-right: 5px !important;
    fill: none !important;
    stroke: #63e6be !important;
    stroke-width: 2.2 !important;
    stroke-linecap: round !important;
    stroke-linejoin: round !important;
    vertical-align: -3px !important;
}

/* Homepage poster modules: clean six-card desktop grid with real gutters. */
.module > .content > .items:not(.owl-carousel):not(#zflix-filter-results) {
    display: grid !important;
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    gap: 12px !important;
    width: 100% !important;
    padding: 0 !important;
    overflow: visible !important;
}

.module > .content > .items:not(.owl-carousel):not(#zflix-filter-results) > .item {
    float: none !important;
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

/* Keep the classic portrait poster ratio and prevent neighbouring cards merging. */
.module > .content > .items:not(.owl-carousel):not(#zflix-filter-results) > .item:not(.episodes) > .poster {
    display: block !important;
    position: relative !important;
    width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    padding-top: 145% !important;
    overflow: hidden !important;
    border-radius: 7px 7px 0 0 !important;
}

.module > .content > .items:not(.owl-carousel):not(#zflix-filter-results) > .item:not(.episodes) > .poster img {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    object-fit: cover !important;
}

/* Old-style readable card information: centred title, up to two lines. */
.module > .content > .items:not(.owl-carousel):not(#zflix-filter-results) > .item:not(.episodes) > .data {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: 100% !important;
    min-height: 82px !important;
    margin: 0 !important;
    padding: 11px 8px 12px !important;
    text-align: center !important;
    box-sizing: border-box !important;
}

.module > .content > .items:not(.owl-carousel):not(#zflix-filter-results) > .item:not(.episodes) > .data h3 {
    display: -webkit-box !important;
    width: 100% !important;
    height: auto !important;
    min-height: 38px !important;
    margin: 0 0 5px !important;
    overflow: hidden !important;
    white-space: normal !important;
    text-overflow: clip !important;
    -webkit-box-orient: vertical !important;
    -webkit-line-clamp: 2 !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    line-height: 19px !important;
    overflow-wrap: anywhere !important;
}

.module > .content > .items:not(.owl-carousel):not(#zflix-filter-results) > .item:not(.episodes) > .data h3 a {
    white-space: normal !important;
}

.module > .content > .items:not(.owl-carousel):not(#zflix-filter-results) > .item:not(.episodes) > .data span {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    font-size: 12px !important;
    line-height: 18px !important;
    text-align: center !important;
}

/* Episodes are landscape cards; only restore their grid spacing. */
.module > .content > .items:not(.owl-carousel):not(#zflix-filter-results) > article.episodes {
    width: 100% !important;
}

.module > .content > .zflix-episodes-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
}

@media (max-width: 1130px) {
    .module > .content > .items:not(.owl-carousel):not(#zflix-filter-results) {
        grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    }

    .module > .content > .zflix-episodes-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 900px) {
    .module > .content > .items:not(.owl-carousel):not(#zflix-filter-results) {
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    }
}

/* Match the legacy mobile design: exactly two large cards per row. */
@media (max-width: 768px) {
    .module > .content > .items:not(.owl-carousel):not(#zflix-filter-results) {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 16px 14px !important;
        padding: 0 5px !important;
    }

    .module > .content > .items:not(.owl-carousel):not(#zflix-filter-results) > .item:not(.episodes) > .data {
        min-height: 86px !important;
        padding: 11px 7px 13px !important;
    }

    .module > .content > .items:not(.owl-carousel):not(#zflix-filter-results) > .item:not(.episodes) > .data h3 {
        min-height: 40px !important;
        font-size: 14px !important;
        line-height: 20px !important;
    }

    .module > .content > .zflix-episodes-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 320px) {
    .module > .content > .items:not(.owl-carousel):not(#zflix-filter-results) {
        gap: 10px !important;
    }
}
