/* =============================================
   IF Posts Grid Widget
   ============================================= */

.if-pgrid {
    display: flex;
    flex-direction: column;
    gap: var(--if-pgrid-rows-gap, 20px);
}

/* Top row: N equal columns. The column count itself is set responsively by
   the "Колонок в верхнем ряду" Elementor control (higher-specificity inline
   CSS it generates per breakpoint overrides this); this is just the
   desktop-default fallback for when that inline CSS isn't present at all. */
.if-pgrid__top {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--if-pgrid-gap, 20px);
}

/* Bottom row: single column full-width */
.if-pgrid__bottom {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--if-pgrid-gap, 20px);
}

/* =============================================
   Card
   ============================================= */

.if-pgrid__card {
    position: relative;
    display: block;
    overflow: hidden;
    border-radius: 16px;
    height: 300px;
    text-decoration: none;
    color: inherit;
}

/* Background image layer */
.if-pgrid__bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: transform 600ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
    z-index: 1;
}

.if-pgrid__card:hover .if-pgrid__bg {
    transform: scale(1.05);
}

/* Overlay layer */
.if-pgrid__overlay {
    position: absolute;
    inset: 0;
    background: var(--if-pgrid-overlay, rgba(0, 0, 0, 0.35));
    transition: background 400ms ease;
    z-index: 2;
    pointer-events: none;
}

.if-pgrid__card:hover .if-pgrid__overlay {
    background: var(--if-pgrid-overlay-hover, rgba(0, 0, 0, 0.5));
}

/* Resting scrim under the title. The overlay colour can be transparent at rest (the
   home page uses a red multiply on hover only), and on light photos the white title
   was hard to read — «Д» of «Доставка» vanished into a white background. The scrim
   darkens the card at rest and fades out on hover, so the hover effect is unchanged.
   Strength: widget controls «Затемнение под текстом» (--if-pgrid-scrim). */
.if-pgrid__content::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: rgba(0, 0, 0, var(--if-pgrid-scrim, 0.45));
    transition: opacity 400ms ease;
    pointer-events: none;
}

.if-pgrid__card:hover .if-pgrid__content::before {
    opacity: var(--if-pgrid-scrim-hover, 0);
}

/* Content layer (title) */
.if-pgrid__content {
    position: relative;
    z-index: 3;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    height: 100%;
    padding: var(--if-pgrid-card-padding, 24px);
    box-sizing: border-box;
}

.if-pgrid__title {
    margin: 0;
    padding: 0;
    color: #fff;
    font-weight: 900;
    font-style: italic;
    text-transform: uppercase;
    line-height: 1.15;
    font-size: 18px;
    text-shadow: 0 1px 10px rgba(0, 0, 0, 0.35);
}

.if-pgrid__bottom .if-pgrid__title {
    font-size: 36px;
}

/* =============================================
   Responsive
   ============================================= */

/* Column count per breakpoint is set by the responsive "Колонок в верхнем
   ряду" control (Elementor's own generated CSS, matching its default
   breakpoints: mobile ≤767px, tablet 768-1024px) — see class-if-posts-grid-
   widget.php. Existing pages that never touched that control for tablet/
   mobile get 2 / 1 columns automatically (tablet_default/mobile_default);
   it can be tuned per page from the widget's Content panel. Only font sizes
   are set here.  */
@media (min-width: 768px) and (max-width: 1024px) {
    .if-pgrid__bottom .if-pgrid__title {
        font-size: 28px;
    }
}

@media (max-width: 767px) {
    .if-pgrid__title {
        font-size: 16px;
    }

    .if-pgrid__bottom .if-pgrid__title {
        font-size: 22px;
    }

    /* Home page (106), «Новости» on phones — mockup mob-home.png: Inter 600 as typed
       (not uppercase), 11px in the three small cards, 17px in the wide one. ONDER 7px
       draws about twice its size: in a ~110px card the words were cut off by the card
       edge («ПРОФЛИС», «РАСПРОДА»). Elementor has no per-device font family / weight /
       case, so the type is set here; card heights, gaps, padding and top alignment are
       the widget's own phone settings (dev/migrations/mobile-home.php). This file loads
       before Elementor's post CSS, hence the extra class for specificity. */
    .elementor-106 .elementor-element.elementor-element-28cd5d2 .if-pgrid .if-pgrid__card .if-pgrid__title {
        font-family: "Inter", sans-serif;
        font-size: 11px;
        font-style: normal;
        font-weight: 600;
        line-height: 1.2;
        letter-spacing: 0;
        text-transform: none;
        overflow-wrap: break-word;
    }

    .elementor-106 .elementor-element.elementor-element-28cd5d2 .if-pgrid__bottom .if-pgrid__card .if-pgrid__title {
        font-size: 17px;
    }
}
