/*
 * Ручное восстановление доступа через смену email.
 *
 * Дополняет:
 *
 * - style.css;
 * - login.css.
 *
 * Используется для:
 *
 * - данных старого аккаунта;
 * - нового email;
 * - контактных данных;
 * - состояний ошибок;
 * - успешной отправки;
 * - мобильной и десктопной адаптации.
 */


/* =========================================================
   Переменные
   ========================================================= */

:root {
    --recovery-max-width: 600px;

    --recovery-border:
        color-mix(
            in srgb,
            var(--muted) 22%,
            transparent
        );

    --recovery-field-border:
        color-mix(
            in srgb,
            var(--muted) 40%,
            transparent
        );

    --recovery-section-border:
        color-mix(
            in srgb,
            var(--accent) 14%,
            var(--border)
        );
}


/* =========================================================
   Страница
   ========================================================= */

body.recovery-page {
    min-width: 320px;

    margin: 0;

    background:
        radial-gradient(
            circle at 50% 0,
            color-mix(
                in srgb,
                var(--accent) 8%,
                transparent
            ),
            transparent 30rem
        ),
        var(--bg);
}


/* =========================================================
   Контейнер страницы
   ========================================================= */

.recovery-container {
    display: flex;

    width:
        min(
            calc(
                100%
                - 24px
            ),
            var(--recovery-max-width)
        );

    min-width: 0;

    flex-direction: column;

    gap: 20px;

    margin:
        22px
        auto
        34px;

    padding: 24px;

    box-sizing: border-box;

    background:
        color-mix(
            in srgb,
            var(--surface) 96%,
            transparent
        );

    border:
        1px solid
        var(--recovery-border);

    border-radius:
        var(--radius);

    box-shadow:
        0
        14px
        38px
        rgba(
            0,
            0,
            0,
            0.26
        );

    backdrop-filter:
        blur(14px);

    -webkit-backdrop-filter:
        blur(14px);
}


.recovery-container [hidden] {
    display: none !important;
}


/* =========================================================
   Вступительный блок
   ========================================================= */

.recovery-intro {
    display: flex;

    min-width: 0;

    flex-direction: column;

    align-items: center;

    gap: 8px;

    text-align: center;
}


.recovery-intro-icon,
.recovery-icon {
    display: inline-flex;

    width: 76px;
    height: 76px;

    flex:
        0
        0
        76px;

    align-items: center;
    justify-content: center;

    margin-bottom: 4px;

    color: var(--accent);

    background:
        color-mix(
            in srgb,
            var(--accent) 11%,
            var(--surface-hover)
        );

    border:
        1px solid
        color-mix(
            in srgb,
            var(--accent) 38%,
            transparent
        );

    border-radius: 50%;

    box-shadow:
        0
        12px
        28px
        color-mix(
            in srgb,
            var(--accent) 12%,
            transparent
        );

    font-size: 2rem;
    line-height: 1;

    user-select: none;
}


.recovery-intro h2 {
    margin: 0;

    color: var(--accent);

    font-size:
        clamp(
            1.2rem,
            5vw,
            1.5rem
        );

    line-height: 1.3;
}


.recovery-intro p {
    max-width: 470px;

    margin: 0;

    color: var(--muted);

    font-size: 0.9rem;
    line-height: 1.5;

    overflow-wrap: anywhere;
}


/* =========================================================
   Информационный блок
   ========================================================= */

.recovery-notice {
    display: grid;

    grid-template-columns:
        auto
        minmax(
            0,
            1fr
        );

    align-items: flex-start;

    gap: 12px;

    min-width: 0;

    padding:
        15px;

    background:
        color-mix(
            in srgb,
            var(--accent) 7%,
            var(--surface-hover)
        );

    border:
        1px solid
        color-mix(
            in srgb,
            var(--accent) 27%,
            transparent
        );

    border-radius:
        var(--radius-sm);
}


.recovery-notice-icon {
    display: inline-flex;

    width: 34px;
    height: 34px;

    flex:
        0
        0
        34px;

    align-items: center;
    justify-content: center;

    color:
        var(--accent-contrast);

    background:
        var(--accent);

    border-radius: 11px;

    font-family:
        Georgia,
        serif;

    font-size: 1rem;
    font-weight: 800;
    line-height: 1;
}


.recovery-notice-content {
    min-width: 0;
}


.recovery-notice h2 {
    margin: 0;

    color: var(--accent);

    font-size: 0.96rem;
    line-height: 1.35;
}


.recovery-notice p {
    margin:
        5px
        0
        0;

    color: var(--muted);

    font-size: 0.82rem;
    line-height: 1.5;

    overflow-wrap: anywhere;
}


/* =========================================================
   Форма
   ========================================================= */

.recovery-form {
    display: flex;

    min-width: 0;

    flex-direction: column;

    gap: 18px;
}


.recovery-form .form-group {
    display: flex;

    min-width: 0;

    flex-direction: column;

    gap: 7px;

    margin: 0;
}


.recovery-form label {
    color: var(--text);

    font-size: 0.9rem;
    font-weight: 650;
    line-height: 1.35;
}


/* =========================================================
   Секции формы
   ========================================================= */

.recovery-form-section {
    display: flex;

    min-width: 0;

    flex-direction: column;

    gap: 16px;

    padding: 18px;

    background:
        color-mix(
            in srgb,
            var(--surface-raised) 88%,
            transparent
        );

    border:
        1px solid
        var(--recovery-section-border);

    border-radius: 17px;
}


.recovery-section-heading {
    display: flex;

    min-width: 0;

    align-items: flex-start;

    gap: 12px;

    padding-bottom: 13px;

    border-bottom:
        1px solid
        var(--border);
}


.recovery-section-heading > div {
    min-width: 0;
}


.recovery-section-number {
    display: inline-flex;

    width: 34px;
    height: 34px;

    min-width: 34px;

    flex:
        0
        0
        34px;

    align-items: center;
    justify-content: center;

    color:
        var(--accent-contrast);

    background:
        var(--accent);

    border-radius: 11px;

    box-shadow:
        0
        8px
        18px
        color-mix(
            in srgb,
            var(--accent) 20%,
            transparent
        );

    font-size: 0.82rem;
    font-weight: 850;
    line-height: 1;
}


.recovery-section-heading h2 {
    margin: 0;

    color: var(--text);

    font-size: 1rem;
    font-weight: 760;
    line-height: 1.3;
}


.recovery-section-heading p {
    margin:
        4px
        0
        0;

    color: var(--muted);

    font-size: 0.76rem;
    line-height: 1.45;

    overflow-wrap: anywhere;
}


/* =========================================================
   Поля формы
   ========================================================= */

.recovery-form input,
.recovery-form textarea {
    width: 100%;
    min-width: 0;

    padding:
        11px
        13px;

    box-sizing: border-box;

    color: var(--text);

    background:
        var(--bg);

    border:
        1px solid
        var(--recovery-field-border);

    border-radius:
        var(--radius-sm);

    font: inherit;
    font-size: 1rem;
    line-height: 1.4;

    outline: none;

    transition:
        border-color 0.16s ease,
        background-color 0.16s ease,
        box-shadow 0.16s ease;
}


.recovery-form input {
    min-height: 50px;
}


.recovery-form textarea {
    min-height: 132px;

    resize: vertical;
}


.recovery-form input::placeholder,
.recovery-form textarea::placeholder {
    color:
        color-mix(
            in srgb,
            var(--muted) 80%,
            transparent
        );
}


.recovery-form input:hover:not(:disabled),
.recovery-form textarea:hover:not(:disabled) {
    border-color:
        color-mix(
            in srgb,
            var(--accent) 32%,
            var(--recovery-field-border)
        );
}


.recovery-form input:focus-visible,
.recovery-form textarea:focus-visible {
    background:
        var(--surface-hover);

    border-color:
        var(--accent);

    box-shadow:
        0
        0
        0
        3px
        color-mix(
            in srgb,
            var(--accent) 24%,
            transparent
        );
}


.recovery-form input[aria-invalid="true"],
.recovery-form textarea[aria-invalid="true"],
.recovery-form input:user-invalid,
.recovery-form textarea:user-invalid {
    border-color:
        color-mix(
            in srgb,
            var(--danger) 68%,
            var(--recovery-field-border)
        );
}


.recovery-form input[aria-invalid="true"]:focus-visible,
.recovery-form textarea[aria-invalid="true"]:focus-visible,
.recovery-form input:user-invalid:focus-visible,
.recovery-form textarea:user-invalid:focus-visible {
    box-shadow:
        0
        0
        0
        3px
        color-mix(
            in srgb,
            var(--danger) 20%,
            transparent
        );
}


.recovery-form input:disabled,
.recovery-form textarea:disabled {
    opacity: 0.64;

    cursor: wait;
}


/* =========================================================
   Подсказки и счётчик
   ========================================================= */

.recovery-field-hint {
    margin: 0;

    color: var(--muted);

    font-size: 0.76rem;
    line-height: 1.4;

    overflow-wrap: anywhere;
}


.recovery-field-meta {
    display: flex;

    min-width: 0;

    align-items: flex-start;
    justify-content: space-between;

    gap: 12px;
}


.recovery-field-meta
.recovery-field-hint {
    min-width: 0;

    flex:
        1
        1
        auto;
}


.recovery-character-counter {
    flex:
        0
        0
        auto;

    color: var(--muted);

    font-size: 0.72rem;
    font-variant-numeric:
        tabular-nums;
    line-height: 1.4;

    white-space: nowrap;

    transition:
        color 0.16s ease,
        font-weight 0.16s ease;
}


.recovery-character-counter.limit-near {
    color:
        color-mix(
            in srgb,
            var(--warning) 86%,
            var(--text)
        );

    font-weight: 650;
}


.recovery-character-counter.limit-reached {
    color:
        color-mix(
            in srgb,
            var(--danger) 88%,
            var(--text)
        );

    font-weight: 750;
}


/* =========================================================
   Ошибки
   ========================================================= */

.recovery-form .field-error,
.recovery-form-error {
    margin: 0;

    color:
        color-mix(
            in srgb,
            var(--danger) 86%,
            var(--text)
        );

    font-size: 0.82rem;
    line-height: 1.4;

    overflow-wrap: anywhere;
}


.recovery-form .field-error:empty,
.recovery-form-error:empty {
    display: none;
}


.recovery-form .field-error:not(:empty) {
    padding:
        7px
        9px;

    background:
        color-mix(
            in srgb,
            var(--danger) 7%,
            var(--surface)
        );

    border-left:
        3px solid
        color-mix(
            in srgb,
            var(--danger) 70%,
            transparent
        );

    border-radius:
        0
        var(--radius-sm)
        var(--radius-sm)
        0;
}


.recovery-form-error:not(:empty) {
    padding:
        10px
        12px;

    background:
        color-mix(
            in srgb,
            var(--danger) 8%,
            var(--surface)
        );

    border:
        1px solid
        color-mix(
            in srgb,
            var(--danger) 42%,
            transparent
        );

    border-radius:
        var(--radius-sm);

    text-align: center;
}


/* =========================================================
   Кнопка отправки
   ========================================================= */

.recovery-submit-button {
    position: relative;

    display: inline-flex;

    width: 100%;
    min-height: 52px;

    align-items: center;
    justify-content: center;

    gap: 10px;

    box-sizing: border-box;

    font-size: 1rem;
    font-weight: 750;
}


.recovery-submit-text {
    display: inline-block;
}


.recovery-submit-loader {
    width: 18px;
    height: 18px;

    flex:
        0
        0
        18px;

    border:
        2px solid
        color-mix(
            in srgb,
            currentColor 32%,
            transparent
        );

    border-top-color:
        currentColor;

    border-radius: 50%;

    animation:
        recovery-button-spin
        0.72s
        linear
        infinite;
}


.recovery-submit-button[aria-busy="true"] {
    cursor: wait;
}


.recovery-submit-button:disabled {
    opacity: 0.62;

    cursor: wait;

    transform: none;
}


@keyframes recovery-button-spin {
    to {
        transform:
            rotate(360deg);
    }
}


/* =========================================================
   Успешное состояние
   ========================================================= */

.recovery-success {
    display: flex;

    min-height: 320px;

    flex-direction: column;

    align-items: center;
    justify-content: center;

    gap: 12px;

    padding:
        24px
        18px;

    box-sizing: border-box;

    background:
        color-mix(
            in srgb,
            var(--accent) 4%,
            var(--surface-raised)
        );

    border:
        1px solid
        color-mix(
            in srgb,
            var(--accent) 18%,
            var(--border)
        );

    border-radius: 17px;

    text-align: center;
}


.recovery-success-icon {
    display: inline-flex;

    width: 76px;
    height: 76px;

    flex:
        0
        0
        76px;

    align-items: center;
    justify-content: center;

    color: var(--accent);

    background:
        color-mix(
            in srgb,
            var(--accent) 12%,
            var(--surface-hover)
        );

    border:
        1px solid
        color-mix(
            in srgb,
            var(--accent) 42%,
            transparent
        );

    border-radius: 50%;

    box-shadow:
        0
        12px
        28px
        color-mix(
            in srgb,
            var(--accent) 12%,
            transparent
        );

    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
}


.recovery-success h2 {
    margin: 0;

    color: var(--accent);

    font-size: 1.3rem;
    line-height: 1.3;
}


.recovery-success p {
    max-width: 420px;

    margin: 0;

    color: var(--muted);

    font-size: 0.9rem;
    line-height: 1.5;

    overflow-wrap: anywhere;
}


.recovery-success-button {
    display: inline-flex;

    width:
        min(
            100%,
            290px
        );

    min-height: 48px;

    align-items: center;
    justify-content: center;

    margin-top: 4px;

    box-sizing: border-box;

    text-decoration: none;
}


.recovery-success-button:hover {
    text-decoration: none;
}


/* =========================================================
   Альтернативный сброс пароля
   ========================================================= */

.recovery-alternative {
    display: grid;

    grid-template-columns:
        auto
        minmax(
            0,
            1fr
        );

    align-items: center;

    gap:
        10px
        12px;

    min-width: 0;

    padding: 15px;

    background:
        color-mix(
            in srgb,
            var(--surface-hover) 70%,
            transparent
        );

    border:
        1px solid
        color-mix(
            in srgb,
            var(--muted) 18%,
            transparent
        );

    border-radius:
        var(--radius-sm);
}


.recovery-alternative-icon {
    display: inline-flex;

    grid-row:
        1
        /
        span 2;

    width: 42px;
    height: 42px;

    flex:
        0
        0
        42px;

    align-items: center;
    justify-content: center;

    color: var(--accent);

    background:
        var(--accent-soft);

    border:
        1px solid
        color-mix(
            in srgb,
            var(--accent) 22%,
            transparent
        );

    border-radius: 13px;

    font-size: 1.15rem;
}


.recovery-alternative-content {
    min-width: 0;
}


.recovery-alternative h2 {
    margin: 0;

    color: var(--text);

    font-size: 0.96rem;
    line-height: 1.35;
}


.recovery-alternative p {
    margin:
        4px
        0
        0;

    color: var(--muted);

    font-size: 0.8rem;
    line-height: 1.45;

    overflow-wrap: anywhere;
}


.recovery-password-button {
    display: inline-flex;

    grid-column:
        1
        /
        -1;

    width: 100%;
    min-height: 46px;

    align-items: center;
    justify-content: center;

    margin-top: 3px;

    box-sizing: border-box;

    text-align: center;
    text-decoration: none;
}


.recovery-password-button:hover {
    text-decoration: none;
}


/* =========================================================
   Нижняя информация
   ========================================================= */

.recovery-footer {
    display: flex;

    min-width: 0;

    flex-direction: column;

    gap: 8px;

    padding-top: 15px;

    border-top:
        1px solid
        color-mix(
            in srgb,
            var(--muted) 16%,
            transparent
        );

    text-align: center;
}


.recovery-footer p {
    margin: 0;

    color: var(--muted);

    font-size: 0.72rem;
    line-height: 1.45;

    overflow-wrap: anywhere;
}


.recovery-footer-links {
    display: flex;

    flex-wrap: wrap;

    align-items: center;
    justify-content: center;

    gap:
        5px
        13px;
}


.recovery-footer-links a {
    display: inline-flex;

    min-height: 36px;

    align-items: center;

    padding:
        0
        2px;

    color: var(--accent);

    border-radius: 5px;

    font-size: 0.74rem;

    text-decoration: none;
}


.recovery-footer-links a:hover {
    text-decoration: underline;

    text-underline-offset: 3px;
}


.recovery-footer-links a:focus-visible {
    outline:
        3px solid
        color-mix(
            in srgb,
            var(--accent) 58%,
            transparent
        );

    outline-offset: 2px;
}


/* =========================================================
   JavaScript отключён
   ========================================================= */

.recovery-noscript {
    padding:
        11px
        12px;

    color:
        color-mix(
            in srgb,
            var(--danger) 86%,
            var(--text)
        );

    background:
        color-mix(
            in srgb,
            var(--danger) 8%,
            var(--surface)
        );

    border:
        1px solid
        color-mix(
            in srgb,
            var(--danger) 42%,
            transparent
        );

    border-radius:
        var(--radius-sm);

    font-size: 0.84rem;
    line-height: 1.45;

    text-align: center;
}


/* =========================================================
   Отключённые состояния
   ========================================================= */

.recovery-container button:disabled,
.recovery-container .btn:disabled {
    opacity: 0.62;

    cursor: not-allowed;

    transform: none;
}


/* =========================================================
   Планшеты и десктоп
   ========================================================= */

@media (min-width: 700px) {
    .recovery-container {
        margin-top: 38px;

        padding:
            30px
            32px;
    }


    .recovery-password-button {
        grid-column: 2;

        width: auto;
        min-width: 230px;

        justify-self: start;
    }
}


/* =========================================================
   Мобильные устройства
   ========================================================= */

@media (max-width: 699px) {
    .recovery-container {
        width:
            calc(
                100%
                - 20px
            );

        margin-top: 14px;

        padding:
            20px
            16px
            calc(
                22px
                + env(
                    safe-area-inset-bottom,
                    0px
                )
            );
    }


    .recovery-intro-icon,
    .recovery-icon {
        width: 68px;
        height: 68px;

        flex-basis: 68px;

        font-size: 1.8rem;
    }


    .recovery-form-section {
        padding:
            15px
            12px;
    }


    .recovery-field-meta {
        flex-direction: column;

        gap: 4px;
    }


    .recovery-character-counter {
        align-self: flex-end;
    }
}


/* =========================================================
   Маленькие телефоны
   ========================================================= */

@media (max-width: 380px) {
    .recovery-container {
        width:
            calc(
                100%
                - 14px
            );

        padding-right: 12px;
        padding-left: 12px;
    }


    .recovery-notice,
    .recovery-alternative {
        padding:
            13px
            11px;
    }


    .recovery-form-section {
        padding:
            14px
            10px;
    }


    .recovery-section-heading {
        gap: 9px;
    }


    .recovery-section-number {
        width: 31px;
        height: 31px;

        min-width: 31px;

        flex-basis: 31px;

        border-radius: 10px;
    }


    .recovery-form textarea {
        min-height: 116px;
    }
}


/* =========================================================
   Низкий горизонтальный экран
   ========================================================= */

@media (
    max-width: 900px
) and (
    orientation: landscape
) and (
    max-height: 540px
) {
    .recovery-container {
        max-width: 760px;

        margin-top: 8px;
        margin-bottom: 12px;

        padding:
            16px
            20px;
    }


    .recovery-intro {
        display: grid;

        grid-template-columns:
            auto
            minmax(
                0,
                1fr
            );

        text-align: left;
    }


    .recovery-intro-icon,
    .recovery-icon {
        grid-row:
            1
            /
            span 2;

        width: 58px;
        height: 58px;

        flex-basis: 58px;

        font-size: 1.5rem;
    }


    .recovery-intro h2,
    .recovery-intro p {
        grid-column: 2;
    }


    .recovery-success {
        min-height: 220px;
    }
}


/* =========================================================
   Уменьшение анимации
   ========================================================= */

@media (
    prefers-reduced-motion: reduce
) {
    .recovery-form input,
    .recovery-form textarea,
    .recovery-character-counter {
        transition: none;
    }


    .recovery-submit-loader {
        animation: none;
    }
}


/* =========================================================
   Печать
   ========================================================= */

@media print {
    .auth-header,
    .recovery-submit-button,
    .recovery-alternative,
    .recovery-footer {
        display: none !important;
    }


    .recovery-container {
        width: 100%;
        max-width: none;

        margin: 0;
        padding: 0;

        border: 0;

        box-shadow: none;
    }


    .recovery-form-section,
    .recovery-notice,
    .recovery-success {
        break-inside: avoid;

        border:
            1px solid
            var(--muted);

        box-shadow: none;
    }
}