/* ===========================================================================
   RedoSchool — экран входа (логин).
   Космический фон в стиле игры, стеклянная карточка, бренд-кнопка.
   Разметка — #auth-gate в index.html, логика — auth.js.
   =========================================================================== */

.auth-gate {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 28px;
    overflow: hidden;
    background-color: #1a2160;
    background-image:
        radial-gradient(120% 120% at 50% 10%, rgba(24, 33, 92, 0) 45%, rgba(8, 12, 40, 0.72) 100%),
        url("loading/bg.jpg");
    background-size: cover, cover;
    background-position: center, center;
    background-repeat: no-repeat, no-repeat;
}

.auth-gate[hidden] {
    display: none;
}

.auth-scene {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.auth-star {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 8px 2px rgba(180, 226, 255, 0.9);
    animation: auth-twinkle 3.6s ease-in-out infinite;
}

.auth-star-1 { left: 24%; top: 26%; animation-delay: 0s; }
.auth-star-2 { left: 74%; top: 30%; animation-delay: 1.2s; transform: scale(1.3); }
.auth-star-3 { left: 62%; top: 68%; animation-delay: 2.3s; transform: scale(0.7); }

.auth-card {
    position: relative;
    z-index: 1;
    width: min(400px, 100%);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 30px 30px 26px;
    border-radius: 26px;
    background: linear-gradient(180deg, rgba(28, 40, 96, 0.82), rgba(14, 21, 58, 0.9));
    border: 1.5px solid rgba(150, 190, 255, 0.32);
    box-shadow:
        0 26px 60px rgba(5, 9, 34, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.14);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    animation: auth-card-in 520ms cubic-bezier(0.22, 1, 0.36, 1);
}

.auth-logo {
    width: clamp(150px, 46%, 210px);
    height: auto;
    margin: -6px auto 8px;
    filter: drop-shadow(0 8px 18px rgba(6, 12, 44, 0.5));
    animation: auth-logo-wobble 4.4s ease-in-out infinite;
    pointer-events: none;
    -webkit-user-drag: none;
}

/* ---------------------------------------------------------------------------
   Типографика экрана входа записана ОТДЕЛЬНЫМИ свойствами, а не сокращённым
   `font:`. Раньше здесь стояло `font: 900 26px/1.15 inherit`, и браузер молча
   выбрасывал такое объявление ЦЕЛИКОМ: `inherit` — CSS-wide keyword, он
   допустим только как значение целого свойства (`font: inherit`), а внутри
   сокращённой записи делает её недействительной. На живой сборке b249 из-за
   этого заголовок получал дефолт h1 (32px/700), а кнопка входа и поля —
   системный Arial 13.3333px/400.
   Семейство здесь НЕ задаётся: оно наследуется от `.auth-gate` (и дальше от
   body, где живёт единственный шрифтовой токен шаблона). Вписать семейство в
   каждое правило значило бы развести одно значение по шести местам — рано или
   поздно оно разъедется с родителем.
   --------------------------------------------------------------------------- */

.auth-title {
    margin: 4px 0 2px;
    text-align: center;
    color: #ffffff;
    font-size: 26px;
    font-weight: 900;
    line-height: 1.15;
    letter-spacing: -0.01em;
}

.auth-subtitle {
    margin: 0 0 22px;
    text-align: center;
    color: var(--rs-muted);
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
}

.auth-field {
    display: grid;
    gap: 7px;
    margin: 0 0 16px;
}

/* Раскрытая запись — причина у правила .auth-title выше. */
.auth-label {
    color: #c9d8ff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding-left: 2px;
}

.auth-field input {
    width: 100%;
    height: 50px;
    box-sizing: border-box;
    border: 1.5px solid rgba(150, 190, 255, 0.28);
    border-radius: 14px;
    padding: 0 16px;
    color: #ffffff;
    background: rgba(10, 16, 46, 0.6);
    outline: none;
    /* Раскрытая запись — причина у правила .auth-title выше. Тонкость: заголовок и
       подписи «выживали» и без семейства, потому что наследуют его от .auth-gate, а
       элементы формы (input, button) шрифт по умолчанию НЕ наследуют — UA-стиль даёт
       им системный Arial 13.3333px/400. Поэтому здесь наследование запрашивается
       явно, отдельным свойством: вот так `inherit` законен, внутри сокращённого
       `font:` — нет. */
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.auth-field input::placeholder {
    color: rgba(169, 184, 230, 0.55);
    font-weight: 500;
}

.auth-field input:focus {
    border-color: var(--rs-orange);
    background: rgba(10, 16, 46, 0.85);
    box-shadow: 0 0 0 4px rgba(255, 122, 26, 0.16);
}

.auth-submit {
    position: relative;
    width: 100%;
    height: 52px;
    margin-top: 6px;
    border: 0;
    border-radius: 14px;
    color: #ffffff;
    background: linear-gradient(180deg, var(--rs-orange-hi), var(--rs-orange) 55%, var(--rs-orange-lo));
    cursor: pointer;
    /* Раскрытая запись, семейство унаследовано явно — как у .auth-field input выше:
       button шрифт документа по умолчанию не наследует. */
    font-family: inherit;
    font-size: 17px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: 0.02em;
    box-shadow: 0 10px 22px rgba(244, 98, 10, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    transition: transform 120ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.auth-submit:hover:not(:disabled) {
    filter: brightness(1.05);
    box-shadow: 0 14px 28px rgba(244, 98, 10, 0.46), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.auth-submit:active:not(:disabled) {
    transform: translateY(2px);
}

.auth-submit:disabled {
    cursor: progress;
}

.auth-submit.is-busy .auth-submit-label {
    visibility: hidden;
}

.auth-submit-spinner {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 22px;
    height: 22px;
    margin: -11px 0 0 -11px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-top-color: #ffffff;
    opacity: 0;
}

.auth-submit.is-busy .auth-submit-spinner {
    opacity: 1;
    animation: auth-spin 0.7s linear infinite;
}

.auth-error {
    min-height: 20px;
    margin-top: 14px;
    text-align: center;
    color: #ffb0b0;
    /* Раскрытая запись — причина у правила .auth-title выше. */
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
}

@keyframes auth-card-in {
    from { opacity: 0; transform: translateY(22px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes auth-logo-wobble {
    0%, 100% { transform: rotate(-2.5deg) scale(1); }
    50%      { transform: rotate(2.5deg) scale(1.05); }
}

@keyframes auth-twinkle {
    0%, 100% { opacity: 0.25; }
    50%      { opacity: 1; }
}

@keyframes auth-spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 480px) {
    .auth-card { padding: 24px 22px 22px; border-radius: 22px; }
    .auth-title { font-size: 22px; }
}

/* ---------------------------------------------------------------------------
   Исход попытки входа показывается ДВИЖЕНИЕМ, а не только цветом текста.
   Неверно — короткая тряска карточки и красная рамка полей; верно — кнопка
   подтверждает приём и карточка уходит вверх. Характер движения разный, потому
   что цвет различают не все, а «пароль не тот» и «сеть недоступна» красные
   одинаково. При `prefers-reduced-motion` тряска и уход выключены, но рамка,
   цвет кнопки и текст остаются — правило доступности не отменяет различия.
   --------------------------------------------------------------------------- */

.auth-card.is-denied {
    animation: auth-shake 420ms cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

.auth-field.is-invalid input,
.auth-field.is-invalid input:focus {
    border-color: #ff8b8b;
    background: rgba(74, 18, 28, 0.6);
    box-shadow: 0 0 0 4px rgba(255, 96, 96, 0.18);
}

.auth-error:not(:empty) {
    animation: auth-error-in 240ms ease-out;
}

.auth-submit.is-accepted,
.auth-submit.is-accepted:disabled {
    background: linear-gradient(180deg, #63e29a, #2fb872 55%, #1c9159);
    box-shadow: 0 10px 22px rgba(31, 160, 100, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    cursor: default;
}

.auth-gate.is-accepted .auth-card {
    animation: auth-card-out 380ms cubic-bezier(0.4, 0, 0.9, 0.3) forwards;
}

@keyframes auth-shake {
    10%, 90% { transform: translateX(-3px); }
    20%, 80% { transform: translateX(5px); }
    30%, 50%, 70% { transform: translateX(-9px); }
    40%, 60% { transform: translateX(9px); }
}

@keyframes auth-error-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes auth-card-out {
    to { opacity: 0; transform: translateY(-18px) scale(0.97); }
}

@media (prefers-reduced-motion: reduce) {
    .auth-card, .auth-logo, .auth-star { animation: none !important; }
    .auth-card.is-denied, .auth-gate.is-accepted .auth-card, .auth-error:not(:empty) {
        animation: none !important;
    }
}
