/**
 * Contact Form 7 — the theme's forms.
 *
 * Applies to forms whose template wraps its fields in <div class="bbs-cf7">
 * (inc/cf7-forms/). Values mirror the Tilda form on bebestschool.kz
 * (rec799963523): 50 px fields with a 1 px black border on white, 20 px
 * apart, 16 px type, round radio buttons, and a green 200 × 50 button
 * rounded 15 px with 14 px capitals.
 *
 * A block can retune a form through the variables below by setting them on
 * the form from a more specific selector — the Trial form block, for one,
 * tightens it on phones with `.bbs-trial .bbs-cf7 { --bbs-cf7-height: … }`.
 */

.bbs-cf7 {
    --bbs-cf7-font: 'ApercuPro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    --bbs-cf7-ink: #000000;
    --bbs-cf7-field-bg: #ffffff;
    --bbs-cf7-border: #000000;
    --bbs-cf7-height: 50px;
    --bbs-cf7-gap: 20px;
    --bbs-cf7-size: 16px;
    --bbs-cf7-button-bg: #1cb65a;
    --bbs-cf7-button-bg-hover: #169c4c;
    --bbs-cf7-button-ink: #ffffff;
    --bbs-cf7-button-width: 200px;
    --bbs-cf7-button-radius: 15px;
    --bbs-cf7-button-align: center;
    --bbs-cf7-error: #b3261e;

    display: flex;
    flex-direction: column;
    gap: var(--bbs-cf7-gap);
    color: var(--bbs-cf7-ink);
    font-family: var(--bbs-cf7-font);
    font-size: var(--bbs-cf7-size);
    line-height: 1.55;
    text-align: left;
}

.bbs-cf7 *,
.bbs-cf7 *::before,
.bbs-cf7 *::after {
    box-sizing: border-box;
}

.bbs-cf7 p {
    margin: 0;
}

/* CF7 wraps every control in a span of its own. */
.bbs-cf7 .wpcf7-form-control-wrap {
    display: block;
}

/* ── Text, email, phone, number, select, textarea ── */
.bbs-cf7 input[type="text"],
.bbs-cf7 input[type="email"],
.bbs-cf7 input[type="tel"],
.bbs-cf7 input[type="number"],
.bbs-cf7 input[type="url"],
.bbs-cf7 input[type="date"],
.bbs-cf7 select,
.bbs-cf7 textarea {
    display: block;
    width: 100%;
    height: var(--bbs-cf7-height);
    margin: 0;
    padding: 0 20px;
    border: 1px solid var(--bbs-cf7-border);
    border-radius: 0;
    background: var(--bbs-cf7-field-bg);
    color: var(--bbs-cf7-ink);
    font: inherit;
    font-size: var(--bbs-cf7-size);
    line-height: 1.33;
    box-shadow: none;
    outline: none;
    appearance: none;
    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.bbs-cf7 textarea {
    height: auto;
    min-height: calc(var(--bbs-cf7-height) * 2.4);
    padding-top: 13px;
    padding-bottom: 13px;
    resize: vertical;
}

.bbs-cf7 select {
    padding-right: 44px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23000' stroke-width='1.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 20px center;
    background-size: 12px 8px;
}

.bbs-cf7 ::placeholder {
    color: var(--bbs-cf7-ink);
    opacity: 0.5;
}

.bbs-cf7 input:focus,
.bbs-cf7 select:focus,
.bbs-cf7 textarea:focus {
    box-shadow: 0 0 0 2px var(--bbs-cf7-button-bg);
}

/* A field the form fills by itself — the vacancy a resume is for. */
.bbs-cf7 input[readonly] {
    background: #f5f5f5;
    font-weight: 600;
    text-overflow: ellipsis;
    cursor: default;
}

.bbs-cf7 input[readonly]:focus {
    box-shadow: none;
}

/* ── Phone fields: intl-tel-input's flag and dial code (inc/phone.js) ── */
.bbs-cf7 .iti {
    --iti-hover-color: rgba(0, 0, 0, 0.05);
    --iti-border-color: var(--bbs-cf7-border);
    --iti-dialcode-color: var(--bbs-cf7-ink);
    --iti-dropdown-bg: #ffffff;
    --iti-spacer-horizontal: 12px;
    --iti-arrow-color: var(--bbs-cf7-ink);

    display: block;
    width: 100%;
}

.bbs-cf7 .iti__selected-country {
    font: inherit;
    font-size: var(--bbs-cf7-size);
}

.bbs-cf7 .iti__selected-country-primary {
    padding-left: 20px;
}

.bbs-cf7 .iti__selected-dial-code {
    color: var(--bbs-cf7-ink);
}

/* The field keeps its own right padding; the library sets the left one to clear the flag. */
.bbs-cf7 .iti input.iti__tel-input {
    padding-right: 20px;
}

/* The country list, wherever it is hung (inc/phone.js). */
.iti--container .iti__dropdown-content,
.bbs-cf7 .iti__dropdown-content {
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    font-family: 'ApercuPro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    font-size: 15px;
}

.iti__search-input {
    font-family: inherit;
    font-size: 15px;
}

.iti__country.iti__highlight {
    background-color: #eefaf2;
}

/* ── Group label, e.g. "Как с вами лучше связаться?" ── */
.bbs-cf7__choice {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.bbs-cf7__label {
    display: block;
    margin: 0 0 5px;
    padding: 0;
    font-size: var(--bbs-cf7-size);
    line-height: 1.55;
    font-weight: 400;
}

/* ── Radio buttons and checkboxes ── */
.bbs-cf7 .wpcf7-radio,
.bbs-cf7 .wpcf7-checkbox,
.bbs-cf7 .wpcf7-acceptance {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.bbs-cf7 .wpcf7-list-item {
    display: block;
    margin: 0;
}

.bbs-cf7 .wpcf7-list-item label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.4;
}

.bbs-cf7 input[type="radio"],
.bbs-cf7 input[type="checkbox"] {
    flex: 0 0 auto;
    display: grid;
    place-content: center;
    width: 20px;
    height: 20px;
    margin: 0;
    border: 2px solid var(--bbs-cf7-ink);
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    appearance: none;
}

.bbs-cf7 input[type="checkbox"] {
    border-radius: 4px;
}

.bbs-cf7 input[type="radio"]::before {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--bbs-cf7-ink);
    transform: scale(0);
    transition: transform 0.15s ease-in-out;
}

.bbs-cf7 input[type="checkbox"]::before {
    content: '';
    width: 10px;
    height: 6px;
    margin-top: -3px;
    border: solid var(--bbs-cf7-ink);
    border-width: 0 0 2px 2px;
    transform: rotate(-45deg) scale(0);
    transition: transform 0.15s ease-in-out;
}

.bbs-cf7 input[type="radio"]:checked::before {
    transform: scale(1);
}

.bbs-cf7 input[type="checkbox"]:checked::before {
    transform: rotate(-45deg) scale(1);
}

.bbs-cf7 input[type="radio"]:focus-visible,
.bbs-cf7 input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--bbs-cf7-button-bg);
    outline-offset: 2px;
}

/* ── File upload, e.g. a resume ──
   inc/cf7.js puts a «Загрузить файл» button of its own beside the field and
   hides the browser's: black, white 16 px text, rounded 5 px, as the Tilda
   one — the chosen file's name beside it. Without the script the browser's
   own button shows, dressed the same way. */
.bbs-cf7 input[type="file"] {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: var(--bbs-cf7-ink);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}

.bbs-cf7 input[type="file"]::file-selector-button,
.bbs-cf7-file__button {
    height: 38px;
    margin: 0 14px 0 0;
    padding: 0 20px;
    border: 0;
    border-radius: 5px;
    background: #000000;
    color: #ffffff;
    font: inherit;
    font-size: 16px;
    line-height: 38px;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

.bbs-cf7 input[type="file"]:hover::file-selector-button,
.bbs-cf7-file__button:hover {
    background: #333333;
}

.bbs-cf7-file__button:focus-visible {
    outline: 2px solid var(--bbs-cf7-ink);
    outline-offset: 3px;
}

/* The browser's field, still what the form sends, out of sight. */
.bbs-cf7 input.bbs-cf7-file__input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.bbs-cf7-file {
    display: flex;
    align-items: center;
    min-width: 0;
}

.bbs-cf7-file__button {
    flex: 0 0 auto;
}

.bbs-cf7-file__name {
    min-width: 0;
    overflow: hidden;
    font-size: 14px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Button ── */
.bbs-cf7__submit {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: var(--bbs-cf7-button-align);
    gap: 10px;
}

.bbs-cf7 .wpcf7-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--bbs-cf7-button-width);
    height: var(--bbs-cf7-height);
    margin: 0;
    padding: 0 24px;
    border: 0;
    border-radius: var(--bbs-cf7-button-radius);
    background: var(--bbs-cf7-button-bg);
    color: var(--bbs-cf7-button-ink);
    font: inherit;
    font-size: 14px;
    line-height: 1.2;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out, opacity 0.2s ease-in-out;
}

.bbs-cf7 .wpcf7-submit:hover,
.bbs-cf7 .wpcf7-submit:focus-visible {
    background: var(--bbs-cf7-button-bg-hover);
}

.bbs-cf7 .wpcf7-submit:focus-visible {
    outline: 2px solid var(--bbs-cf7-ink);
    outline-offset: 3px;
}

/* While sending: CF7 marks the form, and shows its spinner beside the button. */
.wpcf7-form.submitting .bbs-cf7 .wpcf7-submit {
    opacity: 0.6;
    cursor: progress;
}

.bbs-cf7 .wpcf7-spinner {
    margin: 0;
}

/* ── Errors, as the Tilda forms show them ──
 *
 * A field that failed gets a red edge and, just under it, a white bubble
 * pointing up at it with the reason in red: "Обязательное поле", "Укажите,
 * пожалуйста, корректный email". The bubble floats over what is below
 * rather than pushing it down, and goes as soon as the field is changed
 * (inc/cf7.js). The summary goes into a red notice in the bottom right
 * corner of the window, not under the form.
 */
.bbs-cf7 .wpcf7-form-control-wrap {
    position: relative;
}

/* Doubled class: over the field's own edge, and a block's or the popup's colour for it. */
.bbs-cf7.bbs-cf7 :is(input, select, textarea).wpcf7-not-valid {
    border-color: #ff0000;
}

.bbs-cf7 .wpcf7-not-valid-tip {
    position: absolute;
    z-index: 5;
    top: calc(100% + 5px);
    left: 0;
    display: block;
    width: max-content;
    max-width: 100%;
    margin: 0;
    padding: 8px 10px;
    border-radius: 2px;
    background: #ffffff;
    box-shadow: 0 1px 20px rgba(0, 0, 0, 0.2);
    color: #ff0000;
    font-family: var(--bbs-cf7-font);
    font-size: 13px;
    line-height: 1;
    font-weight: 400;
    text-align: left;
    pointer-events: none;
    animation: bbs-cf7-tip-in 0.2s ease-out;
}

/* The little arrow pointing up at the field. */
.bbs-cf7 .wpcf7-not-valid-tip::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 20px;
    border: 5px solid transparent;
    border-bottom-color: #ffffff;
}

/* Radio buttons and checkboxes: the bubble under the whole group. */
.bbs-cf7 .wpcf7-radio + .wpcf7-not-valid-tip,
.bbs-cf7 .wpcf7-checkbox + .wpcf7-not-valid-tip,
.bbs-cf7 .wpcf7-acceptance + .wpcf7-not-valid-tip {
    top: calc(100% + 8px);
}

@keyframes bbs-cf7-tip-in {
    from {
        opacity: 0;
        transform: translateY(-3px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* The line CF7 prints under the form: only for "sent" — errors go to the notice. */
.wpcf7 form:has(.bbs-cf7) .wpcf7-response-output {
    margin: 16px 0 0;
    padding: 10px 14px;
    border: 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: inset 3px 0 0 #1cb65a;
    color: #000000;
    font-family: 'ApercuPro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.4;
}

.wpcf7 form:has(.bbs-cf7):not(.sent) .wpcf7-response-output,
.wpcf7 form:has(.bbs-cf7) .wpcf7-response-output:empty {
    display: none;
}

/* ── The notice in the bottom right corner (inc/cf7.js) ── */
.bbs-form-notice {
    position: fixed;
    z-index: 10000;
    right: 20px;
    bottom: 20px;
    box-sizing: border-box;
    width: max-content;
    max-width: min(420px, calc(100vw - 40px));
    margin: 0;
    padding: 20px 40px 20px 20px;
    border: 0;
    border-radius: 3px;
    background: #f95d51;
    box-shadow: 0 0 3px 1px rgba(0, 0, 0, 0.2);
    color: #ffffff;
    font-family: 'ApercuPro', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    font-weight: 300;
    text-align: left;
    animation: bbs-form-notice-in 0.25s ease-out;
}

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

.bbs-form-notice__item {
    margin: 0;
}

.bbs-form-notice__close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 14px;
    height: 14px;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: #ffffff;
    cursor: pointer;
}

.bbs-form-notice__close::before,
.bbs-form-notice__close::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 1px;
    background: currentColor;
}

.bbs-form-notice__close::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

.bbs-form-notice__close::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

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

@keyframes bbs-form-notice-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@media (max-width: 479px) {
    .bbs-form-notice {
        right: 10px;
        bottom: 10px;
        left: 10px;
        width: auto;
        max-width: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bbs-cf7 .wpcf7-not-valid-tip,
    .bbs-form-notice {
        animation: none;
    }

    .bbs-cf7 input,
    .bbs-cf7 select,
    .bbs-cf7 textarea,
    .bbs-cf7 .wpcf7-submit,
    .bbs-cf7 input[type="radio"]::before,
    .bbs-cf7 input[type="checkbox"]::before {
        transition: none;
    }
}
