/* Fatwaa Q&A — responsive fixes
 * Loaded site-wide via class-frontend.php::enqueue_responsive_fixes().
 * All rules use !important to override Bricks-generated inline CSS.
 * Bricks CSS has its own !important rules for .categories-card so we
 * match the same weight to win the cascade.
 */

/* === Hero: avoid extra-wide hero on landscape tablets === */
@media (max-width: 1199px) and (min-width: 992px) {
    .home-hero-grid {
        gap: 36px !important;
    }
    .home-hero-title {
        font-size: clamp(28px, 4.2vw, 46px) !important;
    }
}

/* === Stats grid: 3 cols desktop, 3 cols tablet, 1 col mobile === */
@media (max-width: 991px) and (min-width: 600px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 18px !important;
    }
    .stat-number {
        font-size: 28px !important;
    }
}
@media (max-width: 599px) {
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 18px !important;
        text-align: center !important;
    }
    .stat-item {
        padding: 18px 12px !important;
    }
}

/* === Two-column body (categories + scholars) on tablet === */
@media (max-width: 991px) and (min-width: 600px) {
    .home-two-column-grid {
        grid-template-columns: 1fr !important;
        gap: 32px !important;
    }
    .categories-card {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }
}

/* === Categories pill grid: 2-col on small desktop / 1-col on mobile ===
   The Bricks-generated rule at @media(max-width:479px) sets the categories-card
   to grid-template-columns: 1fr 1fr (2 columns) !important. To override and force
   1 column on real mobile, we use a more-specific selector with !important. */
@media (max-width: 767px) and (min-width: 480px) {
    .categories-card {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}
@media (max-width: 479px) {
    /* Use higher specificity: .brxe-div.home-card.categories-card has same specificity
       as Bricks' .categories-card (1 class), but .home-card is also a class so this
       rule wins by specificity. Plus !important for safety. */
    .home-card.categories-card,
    .home-card.categories-card.brxe-div {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    .category-item {
        padding: 12px 14px !important;
    }
}

/* === Each .category-grid item is itself a grid container forced to 1-col by
   Bricks. On real mobile, ensure the inner content (the <a> tag) takes full
   width of its single cell. === */
@media (max-width: 599px) {
    .category-grid,
    .category-grid.brxe-div {
        grid-template-columns: 1fr !important;
        width: 100% !important;
    }
    .category-item {
        width: 100% !important;
    }
}

/* === Scholars cards: stack on tablet too === */
@media (max-width: 700px) {
    .scholars-card {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }
    .scholar-item {
        flex-direction: row !important;
        text-align: left !important;
        gap: 16px !important;
    }
    .scholar-image-placeholder {
        width: 56px !important;
        height: 56px !important;
        margin: 0 !important;
        flex-shrink: 0 !important;
    }
}

/* === Header nav: enable horizontal scroll on tablet too, not just mobile === */
@media (max-width: 1199px) {
    .header-row-bottom {
        justify-content: flex-start;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .header-row-bottom::-webkit-scrollbar {
        display: none;
    }
    .brxe-nav-nested.main-nav > ul.brx-nav-nested-items {
        justify-content: flex-start !important;
        flex-wrap: nowrap !important;
        gap: 2px !important;
    }
    ul.main-nav-list {
        justify-content: flex-start !important;
        gap: 2px !important;
        flex-wrap: nowrap !important;
    }
    a.brxe-text-link.main-nav-link {
        padding: 12px 14px !important;
        font-size: 13px !important;
        letter-spacing: 0.05em !important;
        white-space: nowrap !important;
    }
}

/* === Hero typography: ensure small phones have a usable size === */
@media (max-width: 380px) {
    .home-hero-title {
        font-size: 28px !important;
        line-height: 1.1 !important;
    }
    .home-hero-text {
        font-size: 16px !important;
    }
    .home-section-title {
        font-size: 22px !important;
    }
    .home-container {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }
}

/* === Prevent horizontal scroll on entire page from any overflow === */
html, body {
    overflow-x: hidden;
}

/* === Ask a Question CTA card on mobile === */
@media (max-width: 599px) {
    .home-card {
        padding: 24px 20px !important;
    }
    .home-section-header {
        gap: 12px !important;
    }
}

/* === Stat numbers shouldn't wrap or shrink too small === */
.stat-number {
    word-break: keep-all;
    white-space: nowrap;
}

/* === Why-item icon stays visible on very small screens === */
@media (max-width: 380px) {
    .why-icon {
        font-size: 20px !important;
    }
    .why-text {
        font-size: 14px !important;
    }
}
