/**
 * Explore — desktop / laptop layout
 * Mobile (≤767px) keeps fullscreen reels untouched.
 */

@media (min-width: 768px) {
    /* ── Grid surface (Instagram-web style) ── */
    body.bn-explore-grid-page .bn-explore-page--grid,
    .bn-explore-page--grid {
        max-width: min(1080px, 100%) !important;
        margin-inline: auto !important;
        padding: 16px 20px 40px !important;
    }

    .bn-explore-page--grid .explore-app-grid,
    .bn-explore-page--grid .explore-app-grid--grid12,
    .bn-explore-page--grid #exploreMasonry {
        display: grid !important;
        grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
        gap: 8px !important;
    }

    .bn-explore-page--grid .explore-app-card,
    .bn-explore-page--grid .bn-explore-card,
    .bn-explore-page--grid .explore-app-card--wide,
    .bn-explore-page--grid .explore-app-card--tall {
        height: auto !important;
        min-height: 0 !important;
        aspect-ratio: 1 / 1 !important;
        border-radius: 12px !important;
    }

    .bn-explore-page--grid .explore-card-media {
        aspect-ratio: 1 / 1 !important;
        height: 100% !important;
    }

    .explore-reels-entry-chip {
        margin: 0 0 14px !important;
    }

    .explore-provider-rail {
        max-width: min(1080px, 100%);
        margin-inline: auto;
        margin-bottom: 16px;
    }

    /* ── Desktop split post dialog ── */
    .explore-modal-dialog {
        display: none;
    }

    #explorePostModal.open:not(.explore-reels-open) {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: clamp(16px, 2.5vw, 28px) !important;
        background:
            radial-gradient(circle at 50% 0%, rgba(201, 164, 94, 0.12), transparent 36rem),
            rgba(8, 12, 11, 0.78) !important;
        backdrop-filter: blur(20px) saturate(140%) !important;
        -webkit-backdrop-filter: blur(20px) saturate(140%) !important;
    }

    #explorePostModal.open:not(.explore-reels-open) .explore-reels-shell,
    #explorePostModal.open:not(.explore-reels-open) .explore-reels-rail,
    #explorePostModal.open:not(.explore-reels-open) .explore-reels-comment-teaser,
    #explorePostModal.open:not(.explore-reels-open) .explore-reels-fx-layer,
    #explorePostModal.open:not(.explore-reels-open) .explore-reels-center-overlay,
    #explorePostModal.open:not(.explore-reels-open) .explore-reels-sheet,
    #explorePostModal.open:not(.explore-reels-open) > .explore-reels-close {
        display: none !important;
    }

    #explorePostModal.open:not(.explore-reels-open) .explore-modal-dialog,
    #explorePostModal.open:not(.explore-reels-open) #exploreDesktopDialog {
        display: flex !important;
        flex-direction: column;
        position: relative;
        width: min(1120px, calc(100vw - 40px)) !important;
        height: min(86vh, 820px) !important;
        max-width: min(1120px, calc(100vw - 40px)) !important;
        max-height: min(86vh, 820px) !important;
        margin: 0 auto !important;
        border-radius: 24px !important;
        overflow: hidden !important;
        z-index: 2;
        background: #0c1210 !important;
        border: 1px solid rgba(201, 166, 107, 0.22);
        box-shadow: 0 28px 80px rgba(0, 0, 0, 0.45);
    }

    #explorePostModal.open:not(.explore-reels-open) .explore-modal-grid {
        display: grid !important;
        grid-template-columns: minmax(0, 1.4fr) minmax(300px, 380px) !important;
        grid-template-rows: minmax(0, 1fr) !important;
        width: 100% !important;
        height: 100% !important;
        min-height: 0 !important;
        max-height: none !important;
        overflow: hidden !important;
    }

    #explorePostModal.open:not(.explore-reels-open) .explore-modal-media {
        min-width: 0 !important;
        min-height: 0 !important;
        height: 100% !important;
        max-height: none !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        background: #060807 !important;
        overflow: hidden !important;
    }

    #explorePostModal.open:not(.explore-reels-open) .explore-modal-media .post-carousel,
    #explorePostModal.open:not(.explore-reels-open) .explore-modal-media .post-carousel-track,
    #explorePostModal.open:not(.explore-reels-open) .explore-modal-media .post-carousel-slide,
    #explorePostModal.open:not(.explore-reels-open) .explore-modal-media .ba-slider,
    #explorePostModal.open:not(.explore-reels-open) .explore-modal-media .bn-video-shell {
        width: 100% !important;
        height: 100% !important;
        min-height: 0 !important;
        max-height: 100% !important;
    }

    #explorePostModal.open:not(.explore-reels-open) .explore-modal-media img,
    #explorePostModal.open:not(.explore-reels-open) .explore-modal-media video {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        object-fit: contain !important;
    }

    #explorePostModal.open:not(.explore-reels-open) .explore-modal-panel {
        display: flex !important;
        flex-direction: column !important;
        min-height: 0 !important;
        height: 100% !important;
        max-height: none !important;
        overflow: hidden !important;
        border-top: none !important;
        border-right: 1px solid rgba(201, 166, 107, 0.14) !important;
        background: linear-gradient(180deg, #faf8f4 0%, #f3efe6 100%) !important;
        color: #1c2a26 !important;
    }

    #explorePostModal.open:not(.explore-reels-open) .explore-modal-author {
        flex: 0 0 auto !important;
        padding: 14px 16px !important;
        border-bottom: 1px solid rgba(201, 166, 107, 0.18) !important;
        background: transparent !important;
    }

    #explorePostModal.open:not(.explore-reels-open) .explore-modal-caption {
        flex: 0 0 auto !important;
        max-height: 26% !important;
        overflow-y: auto !important;
        padding: 12px 16px !important;
        border-bottom: 1px solid rgba(201, 166, 107, 0.14) !important;
    }

    #explorePostModal.open:not(.explore-reels-open) .explore-modal-comments {
        flex: 1 1 auto !important;
        min-height: 100px !important;
        max-height: none !important;
        overflow-y: auto !important;
        padding: 12px 16px !important;
    }

    #explorePostModal.open:not(.explore-reels-open) .explore-modal-actions {
        flex: 0 0 auto !important;
        border-top: 1px solid rgba(201, 166, 107, 0.18) !important;
        background: rgba(255, 255, 255, 0.55) !important;
    }

    #explorePostModal.open:not(.explore-reels-open) .explore-modal-close {
        top: 12px !important;
        left: 12px !important;
        background: rgba(255, 255, 255, 0.92) !important;
    }

    /* ── Reels on desktop = centered phone column (beats fullscreen !important layer) ── */
    #explorePostModal.explore-modal.open.explore-reels-open,
    #explorePostModal.explore-reels-open {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 16px !important;
        background: rgba(0, 0, 0, 0.92) !important;
        --reels-desk-w: min(420px, calc(100vw - 32px));
        --reels-desk-h: min(92dvh, 860px);
        --reels-desk-left: calc(50% - (var(--reels-desk-w) / 2));
        --reels-desk-top: calc(50% - (var(--reels-desk-h) / 2));
    }

    #explorePostModal.explore-reels-open .explore-reels-shell {
        position: relative !important;
        inset: auto !important;
        top: auto !important;
        right: auto !important;
        bottom: auto !important;
        left: auto !important;
        width: var(--reels-desk-w) !important;
        height: var(--reels-desk-h) !important;
        max-width: var(--reels-desk-w) !important;
        max-height: var(--reels-desk-h) !important;
        min-height: 0 !important;
        border-radius: 18px !important;
        overflow: hidden !important;
        box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
        flex: 0 0 auto !important;
        z-index: 1 !important;
    }

    #explorePostModal.explore-reels-open .explore-reels-viewport,
    #explorePostModal.explore-reels-open .explore-reels-track,
    #explorePostModal.explore-reels-open .explore-reels-slide {
        width: 100% !important;
        height: 100% !important;
        min-height: 100% !important;
        max-height: 100% !important;
    }

    #explorePostModal.explore-reels-open .explore-reels-slide-media {
        bottom: var(--reels-media-bottom, 60px) !important;
    }

    /* Chrome pinned to phone column, not full monitor edges */
    #explorePostModal.explore-reels-open .explore-reels-rail {
        position: absolute !important;
        left: calc(var(--reels-desk-left) + var(--reels-desk-w) - 62px) !important;
        right: auto !important;
        inset-inline-end: auto !important;
        inset-inline-start: auto !important;
        bottom: calc(var(--reels-desk-top) + 72px) !important;
        top: auto !important;
        z-index: 100 !important;
    }

    #explorePostModal.explore-reels-open .explore-reels-comment-teaser {
        position: absolute !important;
        left: calc(var(--reels-desk-left) + 12px) !important;
        right: calc(100% - var(--reels-desk-left) - var(--reels-desk-w) + 72px) !important;
        inset-inline-start: auto !important;
        inset-inline-end: auto !important;
        bottom: calc(var(--reels-desk-top) + 10px) !important;
        top: auto !important;
        width: auto !important;
        max-width: none !important;
        z-index: 90 !important;
    }

    #explorePostModal.explore-reels-open .explore-reels-slide-meta {
        left: 12px !important;
        right: 72px !important;
    }

    #explorePostModal.explore-reels-open .explore-reels-close.explore-modal-close {
        position: absolute !important;
        top: calc(var(--reels-desk-top) + 12px) !important;
        left: calc(var(--reels-desk-left) + 12px) !important;
        right: auto !important;
        z-index: 110 !important;
    }

    #explorePostModal.explore-reels-open .explore-reels-center-overlay,
    #explorePostModal.explore-reels-open .explore-reels-fx-layer {
        position: absolute !important;
        left: var(--reels-desk-left) !important;
        top: var(--reels-desk-top) !important;
        width: var(--reels-desk-w) !important;
        height: var(--reels-desk-h) !important;
        inset: auto !important;
        right: auto !important;
        bottom: auto !important;
        pointer-events: none;
    }

    #explorePostModal.explore-reels-open .explore-reels-center-overlay {
        pointer-events: none;
        display: flex !important;
        align-items: center;
        justify-content: center;
        gap: 16px;
    }

    #explorePostModal.explore-reels-open .explore-reels-center-overlay:not([hidden]) {
        pointer-events: auto;
    }
}

@media (min-width: 768px) and (max-width: 1100px) {
    .bn-explore-page--grid .explore-app-grid,
    .bn-explore-page--grid .explore-app-grid--grid12,
    .bn-explore-page--grid #exploreMasonry {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 767px) {
    .explore-modal-dialog {
        display: none !important;
    }
}

/* Provider rail (shared) */
.explore-provider-rail {
    margin: 0 0 12px;
    padding: 10px 10px 8px;
    border-radius: 16px;
    background: rgba(255, 254, 251, 0.72);
    border: 1px solid rgba(201, 166, 107, 0.14);
    box-shadow: none;
}

.explore-provider-rail__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.explore-provider-rail__tabs {
    display: inline-flex;
    gap: 2px;
    padding: 2px;
    border-radius: 999px;
    background: rgba(53, 95, 88, 0.05);
    border: 1px solid rgba(201, 166, 107, 0.12);
}

.explore-provider-rail__tab {
    border: 0;
    background: transparent;
    color: #7a807a;
    font: inherit;
    font-size: 0.74rem;
    font-weight: 650;
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.explore-provider-rail__tab.is-active {
    background: #fff;
    color: #274842;
    box-shadow: 0 1px 4px rgba(39, 72, 66, 0.06);
}

.explore-provider-rail__all {
    font-size: 0.7rem;
    font-weight: 650;
    color: #a8844a;
    text-decoration: none;
    white-space: nowrap;
}

.explore-provider-rail__all:hover {
    color: #274842;
}

.explore-provider-rail__scroller {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 2px 2px 4px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.explore-provider-rail__scroller::-webkit-scrollbar {
    display: none;
}

.explore-provider-card {
    flex: 0 0 auto;
    width: 96px;
    scroll-snap-align: start;
    text-decoration: none;
    color: inherit;
    text-align: center;
}

.explore-provider-card__avatar {
    width: 56px;
    height: 56px;
    margin: 0 auto 6px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(201, 166, 107, 0.38);
    background: #ede8df;
    box-shadow: none;
}

.explore-provider-card__name {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    color: #1c2a26;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.explore-provider-card__sub {
    display: block;
    margin-top: 1px;
    font-size: 0.62rem;
    font-weight: 500;
    color: #7a807a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.explore-provider-rail__empty {
    margin: 0;
    padding: 6px 4px 2px;
    font-size: 0.76rem;
    color: #7a807a;
}
