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


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

:root {
    --forgot-password-max-width: 520px;

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

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

    --forgot-password-step-border:
        color-mix(
            in srgb,
            var(--accent) 14%,
            var(--border)
        );
}


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

body.forgot-password-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);
}


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

.forgot-password-container {
    display: flex;

    width:
        min(
            calc(
                100%
                - 24px
            ),
            var(--forgot-password-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(--forgot-password-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);
}


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


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

.forgot-password-intro {
    display: flex;

    min-width: 0;

    flex-direction: column;

    align-items: center;

    gap: 8px;

    text-align: center;
}


.forgot-password-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;
}


.forgot-password-intro h2 {
    margin: 0;

    color: var(--accent);

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

    line-height: 1.3;
}


.forgot-password-intro p {
    max-width: 420px;

    margin: 0;

    color: var(--muted);

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

    overflow-wrap: anywhere;
}


/* =========================================================
   Индикатор этапов
   ========================================================= */

.forgot-password-progress {
    display: grid;

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

    gap: 7px;

    margin: 0;
    padding: 0;

    list-style: none;
}


.forgot-password-progress-item {
    position: relative;

    display: flex;

    min-width: 0;
    min-height: 68px;

    flex-direction: column;

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

    gap: 5px;

    padding:
        8px
        4px;

    box-sizing: border-box;

    color: var(--muted);

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

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

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

    text-align: center;

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


.forgot-password-progress-item > span {
    display: inline-flex;

    width: 28px;
    height: 28px;

    flex:
        0
        0
        28px;

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

    color: var(--muted);

    background: var(--bg);

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

    border-radius: 50%;

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


.forgot-password-progress-item > strong {
    min-width: 0;

    overflow: hidden;

    font-size: 0.74rem;
    font-weight: 650;
    line-height: 1.2;

    text-overflow: ellipsis;
    white-space: nowrap;
}


.forgot-password-progress-item.active {
    color: var(--accent);

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

    border-color:
        color-mix(
            in srgb,
            var(--accent) 40%,
            var(--border)
        );

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


.forgot-password-progress-item.active > span {
    color:
        var(--accent-contrast);

    background: var(--accent);

    border-color: var(--accent);
}


.forgot-password-progress-item.completed {
    color: var(--text);

    border-color:
        color-mix(
            in srgb,
            var(--accent) 25%,
            var(--border)
        );
}


.forgot-password-progress-item.completed > span {
    color: var(--accent);

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

    border-color:
        color-mix(
            in srgb,
            var(--accent) 42%,
            var(--border)
        );
}


/* =========================================================
   Этап формы
   ========================================================= */

.forgot-password-step {
    display: flex;

    min-width: 0;

    flex-direction: column;

    gap: 17px;

    padding: 18px;

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

    border:
        1px solid
        var(--forgot-password-step-border);

    border-radius: 17px;
}


.forgot-password-step-heading {
    display: flex;

    min-width: 0;

    flex-direction: column;

    align-items: center;

    gap: 6px;

    padding-bottom: 14px;

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

    text-align: center;
}


.forgot-password-step-number {
    display: inline-flex;

    min-height: 27px;

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

    padding:
        4px
        10px;

    color: var(--accent);

    background:
        var(--accent-soft);

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

    border-radius: 999px;

    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    line-height: 1.2;

    text-transform: uppercase;
}


.forgot-password-step-heading h2 {
    margin: 0;

    color: var(--accent);

    font-size:
        clamp(
            1.08rem,
            5vw,
            1.3rem
        );

    line-height: 1.3;
}


.forgot-password-step-heading p {
    margin: 0;

    color: var(--muted);

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

    overflow-wrap: anywhere;
}


.forgot-password-email-display {
    display: block;

    max-width: 100%;

    align-self: center;

    padding:
        8px
        12px;

    box-sizing: border-box;

    color: var(--text);

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

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

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

    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.4;

    overflow-wrap: anywhere;
    word-break: break-word;
}


/* =========================================================
   Формы
   ========================================================= */

.forgot-password-form {
    display: flex;

    min-width: 0;

    flex-direction: column;

    gap: 15px;
}


.forgot-password-form .form-group {
    display: flex;

    min-width: 0;

    flex-direction: column;

    gap: 7px;

    margin: 0;
}


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

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


.forgot-password-form input {
    width: 100%;
    min-width: 0;
    min-height: 50px;

    padding:
        11px
        13px;

    box-sizing: border-box;

    color: var(--text);

    background: var(--bg);

    border:
        1px solid
        var(--forgot-password-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;
}


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


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


.forgot-password-form input:focus-visible {
    background: var(--surface-hover);

    border-color: var(--accent);

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


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


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


.forgot-password-form input:disabled {
    opacity: 0.64;

    cursor: wait;
}


/* =========================================================
   Подсказки
   ========================================================= */

.forgot-password-field-hint {
    margin: 0;

    color: var(--muted);

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

    overflow-wrap: anywhere;
}


/* =========================================================
   Поле шестизначного кода
   ========================================================= */

#password-reset-code {
    min-height: 60px;

    padding:
        10px
        12px;

    font-family:
        ui-monospace,
        SFMono-Regular,
        Menlo,
        Monaco,
        Consolas,
        monospace;

    font-size:
        clamp(
            1.5rem,
            9vw,
            2rem
        );

    font-weight: 750;
    line-height: 1;

    letter-spacing: 0.26em;

    text-align: center;

    caret-color: var(--accent);
}


#password-reset-code::placeholder {
    letter-spacing: 0.2em;
}


/* =========================================================
   Поля пароля
   ========================================================= */

.forgot-password-password-wrapper {
    position: relative;

    display: flex;

    min-width: 0;

    align-items: stretch;
}


.forgot-password-password-wrapper input {
    padding-right: 58px;
}


.forgot-password-toggle-password {
    position: absolute;

    top: 50%;
    right: 4px;

    display: inline-flex;

    width: 44px;
    height: 42px;

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

    padding: 0;

    color: var(--muted);

    background: transparent;

    border: 0;
    border-radius: 9px;

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

    cursor: pointer;

    transform:
        translateY(-50%);

    -webkit-tap-highlight-color:
        transparent;

    transition:
        color 0.16s ease,
        background-color 0.16s ease,
        transform 0.12s ease;
}


.forgot-password-toggle-password:hover {
    color: var(--text);

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


.forgot-password-toggle-password:active {
    transform:
        translateY(-50%)
        scale(0.92);
}


.forgot-password-toggle-password:focus-visible {
    outline:
        3px solid
        color-mix(
            in srgb,
            var(--accent) 58%,
            transparent
        );

    outline-offset: 1px;
}


.forgot-password-toggle-password:disabled {
    opacity: 0.5;

    cursor: not-allowed;
}


.forgot-password-password-icon {
    display: inline-block;

    line-height: 1;
}


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

.forgot-password-form .field-error,
.forgot-password-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;
}


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


.forgot-password-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;
}


.forgot-password-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;
}


/* =========================================================
   Основные кнопки
   ========================================================= */

.forgot-password-submit {
    position: relative;

    display: inline-flex;

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

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

    gap: 10px;

    box-sizing: border-box;

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


.forgot-password-submit-text {
    display: inline-block;
}


.forgot-password-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:
        forgot-password-button-spin
        0.72s
        linear
        infinite;
}


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


.forgot-password-submit:disabled {
    opacity: 0.62;

    cursor: wait;

    transform: none;
}


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


/* =========================================================
   Вторичная кнопка
   ========================================================= */

.forgot-password-secondary-button {
    display: inline-flex;

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

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

    box-sizing: border-box;
}


.forgot-password-secondary-button:disabled {
    opacity: 0.58;

    cursor: wait;

    transform: none;
}


/* =========================================================
   Успешное завершение
   ========================================================= */

.forgot-password-success {
    display: flex;

    min-height: 300px;

    flex-direction: column;

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

    gap: 12px;

    padding:
        22px
        16px;

    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;
}


.forgot-password-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;
}


.forgot-password-success h2 {
    margin: 0;

    color: var(--accent);

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


.forgot-password-success p {
    max-width: 410px;

    margin: 0;

    color: var(--muted);

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


.forgot-password-success .btn {
    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;
}


.forgot-password-success .btn:hover {
    text-decoration: none;
}


/* =========================================================
   Ручное восстановление
   ========================================================= */

.forgot-password-support {
    display: flex;

    flex-direction: column;

    align-items: center;

    gap: 7px;

    padding-top: 15px;

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

    text-align: center;
}


.forgot-password-support p {
    margin: 0;

    color: var(--muted);

    font-size: 0.8rem;
    line-height: 1.4;
}


.forgot-password-support-link {
    display: inline-flex;

    min-height: 40px;

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

    padding:
        2px
        6px;

    color: var(--accent);

    border-radius: 6px;

    font-size: 0.85rem;
    font-weight: 650;

    text-decoration: none;
}


.forgot-password-support-link:hover {
    text-decoration: underline;

    text-underline-offset: 3px;
}


.forgot-password-support-link:focus-visible {
    outline:
        3px solid
        color-mix(
            in srgb,
            var(--accent) 60%,
            transparent
        );

    outline-offset: 2px;
}


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

.forgot-password-footer {
    padding-top: 15px;

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

    text-align: center;
}


.forgot-password-footer p {
    margin: 0;

    color: var(--muted);

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

    overflow-wrap: anywhere;
}


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

.forgot-password-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;
}


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

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

    cursor: not-allowed;

    transform: none;
}


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

@media (min-width: 600px) {
    .forgot-password-container {
        margin-top: 38px;

        padding:
            30px
            32px;
    }


    .forgot-password-progress-item {
        min-height: 72px;
    }


    .forgot-password-progress-item > strong {
        font-size: 0.78rem;
    }
}


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

@media (max-width: 599px) {
    .forgot-password-container {
        width:
            calc(
                100%
                - 20px
            );

        margin-top: 14px;

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


    .forgot-password-icon {
        width: 68px;
        height: 68px;

        flex-basis: 68px;

        font-size: 1.8rem;
    }


    .forgot-password-step {
        padding:
            16px
            13px;
    }
}


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

@media (max-width: 370px) {
    .forgot-password-container {
        width:
            calc(
                100%
                - 14px
            );

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


    .forgot-password-progress {
        gap: 4px;
    }


    .forgot-password-progress-item {
        min-height: 62px;

        padding:
            7px
            2px;
    }


    .forgot-password-progress-item > span {
        width: 25px;
        height: 25px;

        flex-basis: 25px;

        font-size: 0.7rem;
    }


    .forgot-password-progress-item > strong {
        font-size: 0.68rem;
    }


    .forgot-password-step {
        padding:
            14px
            10px;
    }


    #password-reset-code {
        padding-right: 7px;
        padding-left: 7px;

        font-size: 1.4rem;

        letter-spacing: 0.18em;
    }


    #password-reset-code::placeholder {
        letter-spacing: 0.14em;
    }
}


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

@media (
    max-width: 768px
) and (
    orientation: landscape
) and (
    max-height: 500px
) {
    .forgot-password-container {
        max-width: 700px;

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

        padding:
            16px
            20px;
    }


    .forgot-password-intro {
        display: grid;

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

        text-align: left;
    }


    .forgot-password-icon {
        grid-row:
            1
            /
            span 2;

        width: 58px;
        height: 58px;

        flex-basis: 58px;

        font-size: 1.5rem;
    }


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


    .forgot-password-success {
        min-height: 210px;
    }
}


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

@media (
    prefers-reduced-motion: reduce
) {
    .forgot-password-progress-item,
    .forgot-password-form input,
    .forgot-password-toggle-password {
        transition: none;
    }


    .forgot-password-submit-loader {
        animation: none;
    }
}


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

@media print {
    .auth-header,
    .forgot-password-progress,
    .forgot-password-support,
    .forgot-password-footer,
    .forgot-password-submit,
    .forgot-password-secondary-button {
        display: none !important;
    }


    .forgot-password-container {
        width: 100%;
        max-width: none;

        margin: 0;
        padding: 0;

        border: 0;

        box-shadow: none;
    }


    .forgot-password-step,
    .forgot-password-success {
        border:
            1px solid
            var(--muted);

        box-shadow: none;
    }
}