/**
 * Photo gallery block.
 *
 * Values mirror the Tilda original (bebestschool.kz/kursy-matematiki,
 * rec869851808 and rec869852533): on a #ffd62c band, a 40 px bold heading
 * 720 px wide 60 px from the top, 37 px under it the photos, 216 × 375 and
 * 20 px apart across the 1160 px grid, 30 px from the bottom. On phones the
 * row scrolls sideways instead of shrinking the photos to thumbnails.
 */

.bbs-gallery {
    padding: 60px 0 30px;
    background: #ffd62c;
    color: #000000;
    font-family: var(--bbs-font, 'ApercuPro', Arial, sans-serif);
}

.bbs-gallery__inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.bbs-gallery__title {
    max-width: 720px;
    margin: 0 auto;
    color: inherit;
    font-size: 40px;
    line-height: 50px;
    font-weight: 700;
    text-align: center;
}

.bbs-gallery__list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 216px));
    justify-content: center;
    gap: 20px;
    margin: 37px 0 0;
    padding: 0;
    list-style: none;
}

.bbs-gallery__item {
    margin: 0;
}

.bbs-gallery__link {
    display: block;
    overflow: hidden;
    aspect-ratio: 216 / 375;
    cursor: zoom-in;
}

.bbs-gallery__img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease-in-out;
}

.bbs-gallery__link:hover .bbs-gallery__img,
.bbs-gallery__link:focus-visible .bbs-gallery__img {
    transform: scale(1.04);
}

.bbs-gallery__link:focus-visible {
    outline: 2px solid #000000;
    outline-offset: 3px;
}

/* ── 1199 and below: five to a row still, smaller ── */
@media (max-width: 1199px) {
    .bbs-gallery__list {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

@media (max-width: 959px) {
    .bbs-gallery__inner {
        max-width: 680px;
    }
}

/* ── 639 and below: a row that scrolls sideways ── */
@media (max-width: 639px) {
    .bbs-gallery {
        padding-bottom: 40px;
    }

    .bbs-gallery__title {
        max-width: 300px;
        font-size: 28px;
        line-height: 35px;
    }

    .bbs-gallery__list {
        display: flex;
        gap: 12px;
        margin: 30px -20px 0;
        padding: 0 20px 4px;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scroll-padding: 0 20px;
        scroll-snap-type: x mandatory;
        scrollbar-width: none;
    }

    .bbs-gallery__list::-webkit-scrollbar {
        display: none;
    }

    .bbs-gallery__item {
        flex: 0 0 150px;
        scroll-snap-align: start;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bbs-gallery__img {
        transition: none;
    }
}

/* ── "Carousel" layout ──
   As the review screenshots on bebestschool.com/vidguki (rec2080628173): on
   white, 90 px above and below; a 36 px bold heading on the left and two
   46 px round black arrows on the right; 40 px under them one row of photos
   400 px high — 350 on phones — each as wide as it is, 20 px apart, that
   scrolls and swipes by itself. The row runs the whole width of the screen:
   it starts in line with the heading and scrolls out to both edges.
   script.js shows the arrows. */
.bbs-gallery--carousel {
    padding: 90px 0;
    background: #ffffff;
}

.bbs-gallery--carousel .bbs-gallery__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.bbs-gallery--carousel .bbs-gallery__title {
    max-width: none;
    margin: 0;
    font-size: 36px;
    line-height: 1.23;
    text-align: left;
}

.bbs-gallery__nav {
    display: flex;
    flex: 0 0 auto;
    gap: 10px;
}

.bbs-gallery__nav[hidden] {
    display: none;
}

.bbs-gallery__arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #000000;
    color: #ffffff;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out, opacity 0.2s ease-in-out;
}

.bbs-gallery__arrow svg {
    width: 9px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.bbs-gallery__arrow:hover:not(:disabled) {
    background: #1cb65a;
}

.bbs-gallery__arrow:focus-visible {
    outline: 2px solid #1cb65a;
    outline-offset: 2px;
}

.bbs-gallery__arrow:disabled {
    opacity: 0.3;
    cursor: default;
}

.bbs-gallery--carousel .bbs-gallery__list {
    display: flex;
    /* Not the grid's "center": a row wider than the screen would lose its start. */
    justify-content: flex-start;
    gap: 20px;
    margin: 40px 0 0;
    /* In line with the 1160 px column until scrolled. */
    padding: 0 max(20px, calc((100% - 1160px) / 2)) 4px;
    scroll-padding: 0 max(20px, calc((100% - 1160px) / 2));
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-behavior: smooth;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
}

.bbs-gallery--carousel .bbs-gallery__list::-webkit-scrollbar {
    display: none;
}

.bbs-gallery--carousel .bbs-gallery__item {
    flex: 0 0 auto;
    scroll-snap-align: start;
}

.bbs-gallery--carousel .bbs-gallery__link {
    height: 400px;
    aspect-ratio: auto;
}

.bbs-gallery--carousel .bbs-gallery__img {
    width: auto;
    max-width: none;
    height: 100%;
    object-fit: contain;
}

.bbs-gallery--carousel .bbs-gallery__link:hover .bbs-gallery__img,
.bbs-gallery--carousel .bbs-gallery__link:focus-visible .bbs-gallery__img {
    transform: none;
}

@media (max-width: 959px) {
    .bbs-gallery--carousel .bbs-gallery__inner {
        max-width: none;
    }
}

@media (max-width: 639px) {
    .bbs-gallery--carousel {
        padding: 45px 0;
    }

    .bbs-gallery--carousel .bbs-gallery__title {
        max-width: none;
        font-size: 28px;
    }

    /* One slide to a screen: each takes the row's whole width, the photo shown
       whole in the middle of it, and the row stops on a slide. */
    .bbs-gallery--carousel .bbs-gallery__list {
        gap: 20px;
        margin: 24px 0 0;
        padding: 0 20px 4px;
        scroll-padding: 0 20px;
        scroll-snap-type: x mandatory;
    }

    .bbs-gallery--carousel .bbs-gallery__item {
        flex: 0 0 100%;
        scroll-snap-stop: always;
    }

    .bbs-gallery--carousel .bbs-gallery__link {
        height: 350px;
    }

    .bbs-gallery--carousel .bbs-gallery__img {
        width: 100%;
        max-width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bbs-gallery--carousel .bbs-gallery__list {
        scroll-behavior: auto;
    }
}

/* ── The lightbox (script.js) ── */
.bbs-lightbox {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: rgba(0, 0, 0, 0.9);
    color: #ffffff;
}

.bbs-lightbox:not([open]) {
    display: none;
}

.bbs-lightbox::backdrop {
    background: transparent;
}

.bbs-lightbox__figure {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 60px 70px;
    box-sizing: border-box;
}

.bbs-lightbox__img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.bbs-lightbox__btn {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

.bbs-lightbox__btn:hover,
.bbs-lightbox__btn:focus-visible {
    background: rgba(255, 255, 255, 0.25);
}

.bbs-lightbox__btn:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

.bbs-lightbox__btn svg {
    width: 22px;
    height: 22px;
}

.bbs-lightbox__close {
    top: 10px;
    right: 10px;
}

.bbs-lightbox__prev,
.bbs-lightbox__next {
    top: 50%;
    margin-top: -24px;
}

.bbs-lightbox__prev {
    left: 10px;
}

.bbs-lightbox__next {
    right: 10px;
}

.bbs-lightbox__counter {
    position: absolute;
    bottom: 18px;
    left: 0;
    width: 100%;
    font-family: var(--bbs-font, 'ApercuPro', Arial, sans-serif);
    font-size: 14px;
    text-align: center;
}

@media (max-width: 639px) {
    .bbs-lightbox__figure {
        padding: 60px 10px;
    }

    .bbs-lightbox__prev,
    .bbs-lightbox__next {
        top: auto;
        bottom: 6px;
        margin-top: 0;
    }
}

/* "bbs-gallery--mosaic" (the block's Additional CSS class): the whole
   width, square photos 20 px apart in four columns, the first, sixth and
   seventh of every seven twice the size — as on bebestschool.kz/speaking-club
   (rec422427751). On phones two columns, 10 px apart. */
.bbs-gallery--mosaic {
    padding: 60px 0 40px;
}

.bbs-gallery--mosaic .bbs-gallery__inner {
    max-width: none;
}

.bbs-gallery--mosaic .bbs-gallery__list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.bbs-gallery--mosaic .bbs-gallery__title + .bbs-gallery__list {
    margin-top: 37px;
}

.bbs-gallery--mosaic .bbs-gallery__link {
    aspect-ratio: 1;
}

.bbs-gallery--mosaic .bbs-gallery__item:nth-child(7n + 1),
.bbs-gallery--mosaic .bbs-gallery__item:nth-child(7n + 6),
.bbs-gallery--mosaic .bbs-gallery__item:nth-child(7n + 7) {
    grid-column: span 2;
    grid-row: span 2;
}

@media (max-width: 639px) {
    .bbs-gallery--mosaic .bbs-gallery__inner {
        padding: 0 10px;
    }

    /* A grid still, not the plain look's sideways row. */
    .bbs-gallery--mosaic .bbs-gallery__list {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        margin: 20px 0 0;
        padding: 0;
        overflow: visible;
    }

    .bbs-gallery--mosaic .bbs-gallery__item {
        flex: none;
    }

    .bbs-gallery--mosaic .bbs-gallery__item:nth-child(7n + 1),
    .bbs-gallery--mosaic .bbs-gallery__item:nth-child(7n + 6),
    .bbs-gallery--mosaic .bbs-gallery__item:nth-child(7n + 7) {
        grid-row: auto;
    }
}

/*
 * "--course": bebestschool.com's course pages (/speaking-club-polish,
 * rec1130897011 over rec1130897016): the heading up to 1000 px wide, the
 * photos 25 px under it.
 */
@media (min-width: 960px) {
    .bbs-gallery--course .bbs-gallery__title {
        max-width: 1000px;
    }

    .bbs-gallery--course .bbs-gallery__list {
        margin-top: 25px;
    }
}

/*
 * "--big": bebestschool.com/korporativna-anglijska (rec1014864891 over the
 * T156 grid rec1014879281) — on white, the heading 40 px green bold on the
 * left; three photos 360 × 625, 20 px apart, 37 px under it.
 */
.bbs-gallery.bbs-gallery--big {
    padding: 7px 0 0;
    background: #ffffff;
}

.bbs-gallery--big .bbs-gallery__title {
    max-width: none;
    color: #1cb65a;
    font-size: 40px;
    line-height: 40px;
    text-align: left;
}

@media (min-width: 960px) {
    .bbs-gallery--big .bbs-gallery__list {
        grid-template-columns: repeat(3, 360px);
        gap: 20px;
        margin-top: 43px;
    }

    .bbs-gallery--big .bbs-gallery__img,
    .bbs-gallery--big img {
        width: 360px;
        height: 625px;
        object-fit: cover;
    }
}
