/* =====================================================
   SECTIONS — portfolio tiles, [mg_realizacje] band,
   [mg_blog_najnowsze] latest posts (inc/sections.php)

   Breakpoints: large >= 1200px, tablet 768–1199px, phone <= 767px.
   The band is always one row: 4 columns, 2 on tablets, and on phones one
   column of 2 tiles. The archive grid uses the same 4/2/1 columns over as
   many rows as the page has items. Both are full width with no gaps, so in
   Elementor place the shortcode in a full-width container with no padding.
   ===================================================== */

.mg-band,
.mg-latest {
    font-size: 16px;
    font-weight: 400;
    line-height: 1.6;
}
.mg-band .container,
.mg-latest .container {
    max-width: 1220px;
    padding: 0 40px;
}

/* ---- Section heading (shared) ---- */
.mg-band__head,
.mg-latest__head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 28px;
}
.mg-band .mg-band__title,
.mg-latest .mg-latest__title {
    margin: 0 0 8px;
    font-size: 40px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -1.1px;
    text-align: left;
    text-transform: none;
}
.mg-band .mg-band__title::before,
.mg-latest .mg-latest__title::before {
    content: '';
    display: block;
    width: 48px;
    height: 4px;
    margin-bottom: 20px;
    background: #d9161e;
}
.mg-band .mg-band__lede,
.mg-latest .mg-latest__lede {
    margin: 0;
    font-size: 16px;
    text-align: left;
}
.mg-band .mg-band__all,
.mg-latest .mg-latest__all {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    font-size: 14px;
    text-decoration: underline;
    text-underline-offset: 7px;
}
.mg-band .mg-band__all:hover,
.mg-latest .mg-latest__all:hover {
    text-decoration-thickness: 3px;
}

/* ---- Portfolio band ---- */
.mg-band {
    background: #191b20;
    color: #fff;
}
.mg-band .mg-band__head {
    padding-top: 52px;
    padding-bottom: 52px;
}
.mg-band .mg-band__title { color: #fff; }
.mg-band .mg-band__lede { color: #c7c9ce; }
.mg-band .mg-band__all { color: #fff; }
.mg-band .mg-band__all:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 4px;
}

/* ---- Tile grid ---- */
.mg-tiles {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
}
.mg-tiles--band.mg-tiles--n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.mg-tiles--band.mg-tiles--n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mg-tiles--band.mg-tiles--n1 { grid-template-columns: minmax(0, 1fr); }
.mg-tiles__item {
    min-width: 0;
    margin: 0;
    padding: 0;
}

/* ---- Tile ---- */
.mg-tiles .mg-tile {
    position: relative;
    display: block;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    isolation: isolate;
    background: #35373c;
    color: #fff;
    text-decoration: none;
}
.mg-tiles .mg-tile__img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.35s ease;
}
.mg-tiles .mg-tile::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0) 38%, rgba(0, 0, 0, 0.38) 65%, rgba(0, 0, 0, 0.86) 100%);
    transition: background 0.22s ease;
}
.mg-tiles .mg-tile__caption {
    position: absolute;
    left: 24px;
    right: 76px;
    bottom: 22px;
    z-index: 2;
}
.mg-tiles .mg-tile__cat {
    margin: 0 0 4px;
    font-size: 11px;
    font-weight: 400;
    line-height: 1.5;
    letter-spacing: 0.6px;
    text-transform: uppercase;
}
.mg-tiles .mg-tile__title {
    margin: 0;
    color: #fff;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.25;
    text-align: left;
    overflow-wrap: anywhere;
}
.mg-tiles .mg-tile__arrow {
    position: absolute;
    right: 22px;
    bottom: 22px;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    background: #d9161e;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    transition: background-color 0.22s ease, color 0.22s ease;
}
/* Focus ring as a layer above the image and gradient (an outline would be
   painted beneath them); the transparent outline shows in forced-colors mode. */
.mg-tiles .mg-tile::before {
    content: '';
    position: absolute;
    inset: 7px;
    z-index: 3;
    border: 3px solid #fff;
    opacity: 0;
    pointer-events: none;
}
.mg-tiles .mg-tile:focus-visible {
    outline: 3px solid transparent;
    outline-offset: -7px;
}
.mg-tiles .mg-tile:focus-visible::before {
    opacity: 1;
}
.mg-tiles .mg-tile:focus-visible::after {
    background: linear-gradient(180deg, rgba(25, 27, 32, 0.25), rgba(25, 27, 32, 0.9));
}
.mg-tiles .mg-tile:focus-visible .mg-tile__img {
    transform: scale(1.03);
}
@media (hover: hover) and (pointer: fine) {
    .mg-tiles .mg-tile:hover::after {
        background: linear-gradient(180deg, rgba(25, 27, 32, 0.25), rgba(25, 27, 32, 0.9));
    }
    .mg-tiles .mg-tile:hover .mg-tile__img {
        transform: scale(1.03);
    }
    .mg-tiles .mg-tile:hover .mg-tile__arrow {
        background: #fff;
        color: #d9161e;
    }
}
@media (min-width: 1600px) {
    .mg-tiles .mg-tile__caption { left: 28px; right: 84px; bottom: 26px; }
    .mg-tiles .mg-tile__arrow { right: 26px; bottom: 26px; }
    .mg-tiles .mg-tile__title { font-size: 24px; }
}

/* ---- Latest blog posts ---- */
.mg-latest {
    padding: 72px 0 80px;
    background: #f5f5f3;
    color: #262626;
}
.mg-latest .mg-latest__head { margin-bottom: 32px; }
.mg-latest .mg-latest__title { color: #262626; }
.mg-latest .mg-latest__lede { color: #62666d; }
.mg-latest .mg-latest__all { color: #262626; }
.mg-latest .mg-latest__all:hover { color: #d9161e; }
.mg-latest .mg-latest__all:focus-visible,
.mg-latest .mg-post-card:focus-visible {
    outline: 3px solid #d9161e;
    outline-offset: 4px;
}
.mg-latest__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.mg-latest__grid > li {
    display: flex;
    min-width: 0;
    margin: 0;
}
.mg-latest .mg-post-card {
    display: flex;
    flex-direction: column;
    width: 100%;
    background: #fff;
    border: 1px solid #e9e9e6;
    color: #262626;
    text-decoration: none;
    transition: border-color 0.2s ease;
}
.mg-latest .mg-post-card:hover { border-color: #d9161e; }
.mg-latest .mg-post-card__img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
}
.mg-latest .mg-post-card__body { padding: 24px; }
.mg-latest .mg-post-card__cat {
    margin: 0 0 12px;
    color: #d9161e;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.2px;
    text-transform: uppercase;
}
.mg-latest .mg-post-card__title {
    margin: 0 0 18px;
    color: #262626;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -0.25px;
    text-align: left;
}
.mg-latest .mg-post-card__meta {
    margin: 0;
    color: #62666d;
    font-size: 12px;
}
/* Large screens: image beside the text. */
@media (min-width: 1200px) {
    .mg-latest .mg-post-card--image {
        display: grid;
        grid-template-columns: 42% minmax(0, 1fr);
    }
    /* Core sizes="auto" CSS gives lazy images contain-intrinsic-size 3000×1500,
       which would set the row height; let the text and min-height decide it. */
    .mg-latest .mg-post-card--image .mg-post-card__img {
        align-self: stretch;
        height: auto;
        min-height: 224px;
        aspect-ratio: auto;
        contain-intrinsic-size: none;
    }
}

/* ---- Tablet ---- */
@media (max-width: 1199px) {
    .mg-tiles,
    .mg-tiles--band.mg-tiles--n3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .mg-tiles--band.mg-tiles--n1 { grid-template-columns: minmax(0, 1fr); }
    /* One row: the band shows its first 2 tiles. */
    .mg-tiles--band > .mg-tiles__item:nth-child(n+3) { display: none; }
    .mg-tiles .mg-tile__caption { left: 24px; bottom: 24px; }
    .mg-tiles .mg-tile__arrow { right: 24px; bottom: 24px; }
    .mg-tiles .mg-tile__title { font-size: 24px; }
}

/* ---- Phone ---- */
@media (max-width: 767px) {
    /* style.css pads every Elementor top section 15px on phones; these sections run edge to edge. */
    .elementor-section.elementor-top-section:has(.mg-band, .mg-latest) {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }
    .mg-band .container,
    .mg-latest .container { padding: 0 20px; }
    .mg-band__head,
    .mg-latest__head { display: block; }
    .mg-band .mg-band__title,
    .mg-latest .mg-latest__title {
        font-size: 32px;
        letter-spacing: -0.65px;
    }
    .mg-band .mg-band__title::before,
    .mg-latest .mg-latest__title::before {
        width: 40px;
        margin-bottom: 16px;
    }
    .mg-band .mg-band__lede,
    .mg-latest .mg-latest__lede { font-size: 14px; }
    .mg-band .mg-band__all,
    .mg-latest .mg-latest__all { margin-top: 14px; }
    .mg-band .mg-band__head {
        padding-top: 36px;
        padding-bottom: 36px;
    }

    /* Band: one column, still its first 2 tiles. */
    .mg-tiles,
    .mg-tiles--band.mg-tiles--n3,
    .mg-tiles--band.mg-tiles--n2 { grid-template-columns: minmax(0, 1fr); }
    .mg-tiles .mg-tile::after {
        background: linear-gradient(180deg, transparent 35%, rgba(0, 0, 0, 0.48) 65%, rgba(0, 0, 0, 0.9) 100%);
    }
    .mg-tiles .mg-tile__caption { left: 20px; right: 72px; bottom: 18px; }
    .mg-tiles .mg-tile__cat { font-size: 10px; letter-spacing: 0.4px; }
    .mg-tiles .mg-tile__title { font-size: 22px; }
    .mg-tiles .mg-tile__arrow { right: 20px; bottom: 20px; width: 40px; height: 40px; }

    .mg-latest { padding: 44px 0 48px; }
    .mg-latest .mg-latest__head { margin-bottom: 24px; }
    .mg-latest__grid { grid-template-columns: minmax(0, 1fr); }
    .mg-latest .mg-post-card__body { padding: 22px; }
    .mg-latest .mg-post-card__title { font-size: 20px; margin-bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    .mg-tiles .mg-tile__img,
    .mg-tiles .mg-tile::after,
    .mg-tiles .mg-tile__arrow,
    .mg-latest .mg-post-card {
        transition: none;
    }
    .mg-tiles .mg-tile:hover .mg-tile__img,
    .mg-tiles .mg-tile:focus-visible .mg-tile__img {
        transform: none;
    }
}
