/**
 * Popups.
 *
 * Each popup is a native <dialog>, so it sits above everything (the header
 * included), keeps keyboard focus inside and closes on Esc by itself. The
 * dialog covers the whole window and scrolls on its own when its content is
 * taller than the screen; the page underneath is dimmed and blurred.
 */

/*
 * The page stops scrolling while a popup is open. Hiding its scrollbar would
 * widen the page by the scrollbar's width and shift everything sideways, so
 * the space the scrollbar took is kept.
 */
html.bbs-popup-open {
    overflow: hidden;
    scrollbar-gutter: stable;
}

.bbs-popup {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 0;
    background: transparent;
    color: inherit;
}

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

.bbs-popup::backdrop {
    background: rgba(0, 0, 0, 0.45);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.bbs-popup[open],
.bbs-popup[open]::backdrop {
    animation: bbs-popup-fade 0.3s ease-in-out;
}

@keyframes bbs-popup-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Centres the content when it is shorter than the window, and is what the
 * close button is placed against, so the button scrolls with the popup. */
.bbs-popup__body {
    position: relative;
    display: flex;
    box-sizing: border-box;
    align-items: center;
    min-height: 100%;
}

.bbs-popup__body > * {
    width: 100%;
}

/* On narrow screens the popup runs to the sides of the window, so the close
 * button goes above it: this keeps a strip free for it there. */
@media (max-width: 959px) {
    .bbs-popup__body {
        padding-top: 52px;
    }
}

/*
 * Close button: a white disc with a dark cross, so it reads on the white
 * card and on the page behind alike. popups/script.js moves
 * it to the popup's top right corner, outside the popup wherever there is
 * room, so it never covers a heading. top/right below only hold it somewhere
 * sensible until then.
 */
.bbs-popup__close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
    color: #000000;
    cursor: pointer;
    transition: transform 0.2s ease-in-out;
}

.bbs-popup__close svg {
    display: block;
    width: 14px;
    height: 14px;
}

.bbs-popup__close:hover {
    transform: scale(1.08);
}

/* The dialog focuses the close button as it opens; no ring, as on every
 * other button on the site. */
.bbs-popup__close:focus,
.bbs-popup__close:focus-visible {
    outline: none;
}

@media (prefers-reduced-motion: reduce) {
    .bbs-popup[open],
    .bbs-popup[open]::backdrop {
        animation: none;
    }

    .bbs-popup__close {
        transition: none;
    }
}

/* ─────────────────────────────────────────────────────────────────────────
 * Trial lesson popup
 *
 * Values mirror the Tilda original (bebestschool.kz, rec2134113553): an
 * 845 px white card rounded 50 px with yellow shapes in two corners (its
 * background picture), a 30 px bold heading, a 20 px line under it, two
 * points with 33 px green ticks, a 492 px form whose fields are edged in
 * #1cb65a, and a 14 px grey consent line.
 * ───────────────────────────────────────────────────────────────────────── */

.bbs-popup-card {
    --bbs-popup-font: 'ApercuPro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;

    box-sizing: border-box;
    width: calc(100% - 20px);
    max-width: 845px;
    margin: 20px auto;
    padding: 45px 40px 37px;
    border-radius: 50px;
    background: #ffffff url('images/trial-card.webp') center / cover no-repeat;
    color: #000000;
    font-family: var(--bbs-popup-font);
    text-align: center;
}

.bbs-popup-card :where(p) {
    margin: 0;
}

.bbs-popup-card__title {
    font-size: 30px;
    line-height: 1.2;
    font-weight: 700;
}

.bbs-popup-card__subtitle {
    max-width: 560px;
    margin: 15px auto 0;
    font-size: 20px;
    line-height: 1.55;
}

.bbs-popup-card__points {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px 116px;
    margin: 18px 0 0;
    padding: 0;
    list-style: none;
}

.bbs-popup-card__point {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 20px;
    line-height: 1.55;
}

.bbs-popup-card__point img {
    flex: 0 0 33px;
    width: 33px;
    height: 33px;
}

.bbs-popup-card__form {
    max-width: 492px;
    margin: 30px auto 0;
}

/* The form's own look is inc/cf7.css; here only its green edges. */
.bbs-popup-card .bbs-cf7 {
    --bbs-cf7-border: #1cb65a;
}

.bbs-popup-card__consent {
    max-width: 360px;
    margin: 14px auto 0;
    color: #5c5c5c;
    font-size: 14px;
    line-height: 1.25;
}

.bbs-popup-card__consent a {
    color: #1cb65a;
}

@media (max-width: 959px) {
    .bbs-popup-card__form {
        max-width: 461px;
    }
}

@media (max-width: 639px) {
    .bbs-popup-card {
        margin: 0 auto 20px;
        padding: 30px 16px 28px;
        border-radius: 40px;
    }

    .bbs-popup-card__title {
        font-size: 26px;
    }

    .bbs-popup-card__subtitle {
        font-size: 18px;
    }

    .bbs-popup-card__points {
        gap: 6px 40px;
    }

    .bbs-popup-card__point {
        font-size: 18px;
    }

    .bbs-popup-card__point img {
        flex-basis: 29px;
        width: 29px;
        height: 29px;
    }

    .bbs-popup-card__form {
        margin-top: 22px;
    }

    .bbs-popup-card .bbs-cf7 {
        --bbs-cf7-height: 44px;
        --bbs-cf7-gap: 12px;
    }
}

/* Two points one under the other on the narrowest screens, as the original. */
@media (max-width: 479px) {
    .bbs-popup-card__points {
        flex-direction: column;
        align-items: center;
    }
}

/* ─────────────────────────────────────────────────────────────────────────
 * Resume popup
 *
 * Values mirror the Tilda original (bebestschool.kz/offers, rec579292506):
 * a plain white 560 px card, 45 px inside it a 36 px heading and a 16 px
 * light line, then 60 px fields rounded 5 px with a #c9c9c9 edge, 25 px
 * apart, a black «Загрузить файл» button and a black full-width «Отправить».
 * On phones the card runs to the edges, the heading 28 px, fields 50 px.
 * ───────────────────────────────────────────────────────────────────────── */

.bbs-popup-card--resume {
    max-width: 560px;
    padding: 40px 45px;
    border-radius: 0;
    background: #ffffff;
}

.bbs-popup-card--resume .bbs-popup-card__title {
    font-size: 36px;
    line-height: 1.23;
    font-weight: 600;
}

.bbs-popup-card--resume .bbs-popup-card__subtitle {
    margin-top: 10px;
    font-size: 16px;
    line-height: 1.55;
    font-weight: 300;
}

.bbs-popup-card--resume .bbs-popup-card__form {
    max-width: none;
    margin-top: 24px;
}

.bbs-popup-card--resume .bbs-cf7 {
    --bbs-cf7-border: #c9c9c9;
    --bbs-cf7-height: 60px;
    --bbs-cf7-gap: 25px;
    --bbs-cf7-button-bg: #000000;
    --bbs-cf7-button-bg-hover: #333333;
    --bbs-cf7-button-radius: 5px;
}

.bbs-popup-card--resume .bbs-cf7 :is(input[type="text"], input[type="email"], input[type="tel"]) {
    border-radius: 5px;
}

.bbs-popup-card--resume .bbs-cf7__submit {
    display: block;
}

.bbs-popup-card--resume .bbs-cf7 .wpcf7-submit {
    width: 100%;
    font-size: 16px;
    font-weight: 600;
    text-transform: none;
}

/* On phones the card is the whole screen, as the original's; the close
 * button (popups/script.js) then sits in its top right corner. */
@media (max-width: 639px) {
    .bbs-popup--resume .bbs-popup__body {
        align-items: stretch;
        padding-top: 0;
    }

    .bbs-popup-card--resume {
        width: 100%;
        margin: 0;
        padding: 64px 20px 30px;
    }

    .bbs-popup-card--resume .bbs-popup-card__title {
        font-size: 28px;
    }

    .bbs-popup-card--resume .bbs-popup-card__subtitle {
        margin-top: 6px;
        font-size: 12px;
    }

    .bbs-popup-card--resume .bbs-popup-card__form {
        margin-top: 15px;
    }

    .bbs-popup-card--resume .bbs-cf7 {
        --bbs-cf7-height: 50px;
    }
}
