/* ==========================================================
   DimosTV F2.0-R02.4 — Canonical Secondary Homepage Rails
   Final presentation authority for Discover by Municipality
   and Popular Videos. Data/rendering contracts remain unchanged.
========================================================== */

.dtv-home-after-highlights {
    --dtv-secondary-gap: 28px;
    display: grid !important;
    grid-template-columns: minmax(0, 1.35fr) minmax(420px, .95fr) !important;
    gap: var(--dtv-secondary-gap) !important;
    align-items: start !important;
    min-width: 0;
}

.dtv-home-discover-municipalities,
.dtv-home-popular-videos {
    min-width: 0;
}

.dtv-home-discover-municipalities {
    align-self: start !important;
}

.dtv-home-block-head {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 18px !important;
    min-width: 0;
}

.dtv-home-block-head h2 {
    min-width: 0;
}

/* Desktop contract: ten selected municipalities as 5 + 5. */
.dtv-home-municipality-grid {
    display: grid !important;
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    gap: clamp(12px, 1.5vw, 20px) !important;
    overflow: visible !important;
    padding: 0 !important;
}

.dtv-home-municipality-chip {
    min-width: 0 !important;
    min-height: 132px !important;
    justify-content: flex-start !important;
}

.dtv-home-municipality-logo {
    width: clamp(68px, 6vw, 94px) !important;
    height: clamp(68px, 6vw, 94px) !important;
    flex: 0 0 auto;
}

.dtv-home-municipality-chip > strong {
    width: 100%;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    overflow-wrap: anywhere;
    line-height: 1.25 !important;
}

/* Popular keeps its five-item ranked vertical hierarchy. */
.dtv-home-popular-list {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 13px !important;
    min-width: 0;
}

.dtv-home-popular-item {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.dtv-home-popular-copy,
.dtv-home-popular-copy strong {
    min-width: 0;
}

/* Tablet: sections stack; municipality grid stays readable. */
@media (min-width: 821px) and (max-width: 1180px) {
    .dtv-home-after-highlights {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 24px !important;
    }

    .dtv-home-municipality-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
    }
}

@media (min-width: 769px) and (max-width: 820px) {
    .dtv-home-after-highlights {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 22px !important;
    }

    .dtv-home-municipality-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
        gap: 16px !important;
    }

    .dtv-home-municipality-logo {
        width: 82px !important;
        height: 82px !important;
    }
}

/* Mobile: native horizontal municipality rail; Popular remains vertical. */
@media (max-width: 768px) {
    .dtv-home-after-highlights {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 20px !important;
    }

    .dtv-home-discover-municipalities,
    .dtv-home-popular-videos {
        min-width: 0;
    }

    .dtv-home-block-head {
        align-items: flex-start !important;
        gap: 10px !important;
    }

    .dtv-home-block-head h2 {
        font-size: clamp(18px, 5vw, 22px) !important;
        line-height: 1.08 !important;
    }

    .dtv-home-block-head a {
        flex: 0 0 auto;
    }

    .dtv-home-municipality-grid {
        display: flex !important;
        flex-flow: row nowrap !important;
        gap: 12px !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        padding: 4px 2px 12px !important;
        scroll-snap-type: x mandatory;
        scroll-padding-inline: 2px;
        overscroll-behavior-inline: contain;
        scrollbar-width: none;
    }

    .dtv-home-municipality-grid::-webkit-scrollbar {
        display: none;
    }

    .dtv-home-municipality-chip {
        flex: 0 0 112px !important;
        width: 112px !important;
        min-width: 112px !important;
        min-height: 118px !important;
        scroll-snap-align: start;
    }

    .dtv-home-municipality-logo {
        width: 76px !important;
        height: 76px !important;
    }

    .dtv-home-municipality-chip > strong {
        font-size: 13px !important;
        line-height: 1.15 !important;
        word-break: normal !important;
        overflow-wrap: normal !important;
        hyphens: none !important;
    }
}

@media (max-width: 560px) {
    .dtv-home-popular-item {
        grid-template-columns: 34px 72px minmax(0, 1fr) !important;
        gap: 10px !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .dtv-home-municipality-logo,
    .dtv-home-popular-item {
        transition: none !important;
    }
}
