/* ============================================================
   SHARD-MC — модальная заявка в команду
   ============================================================ */

html.apply-locked,
body.apply-locked {
    overflow: hidden;
}

.apply-modal {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: grid;
    place-items: center;
    padding: 24px;
}

.apply-modal[hidden],
.apply-modal [hidden] {
    display: none !important;
}

.apply-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(5, 4, 3, 0.84);
    backdrop-filter: blur(7px);
    -webkit-backdrop-filter: blur(7px);
}

.apply-dialog {
    position: relative;
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    width: min(1000px, 100%);
    max-height: min(92vh, 920px);
    overflow: hidden;
    background: var(--panel);
    border: 1px solid var(--line-strong);
    box-shadow:
        0 40px 120px rgba(0, 0, 0, 0.65),
        12px 12px 0 rgba(255, 176, 46, 0.08);
    animation: apply-in 0.32s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes apply-in {
    from { opacity: 0; transform: translateY(14px) scale(0.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Левая колонка ------------------------------------------------ */

.apply-side {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 32px 28px 28px;
    border-right: 1px solid var(--line);
    background:
        radial-gradient(circle at 0% 100%, rgba(255, 176, 46, 0.12), transparent 52%),
        linear-gradient(160deg, var(--panel-2), var(--panel));
    overflow-y: auto;
}

.apply-side::after {
    content: 'SHARD';
    position: absolute;
    right: -6px;
    bottom: -18px;
    color: rgba(242, 233, 218, 0.035);
    font-family: var(--font-display);
    font-size: 78px;
    font-weight: 900;
    letter-spacing: -0.06em;
    pointer-events: none;
}

.apply-side .eyebrow {
    margin: 0 0 14px;
    color: var(--amber);
}

.apply-side h2 {
    margin: 0 0 12px;
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
    text-transform: uppercase;
}

.apply-side-copy {
    margin: 0 0 26px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.7;
}

.apply-steps {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0 0 26px;
    padding: 0;
    list-style: none;
    counter-reset: step;
}

.apply-steps li {
    display: flex;
    align-items: baseline;
    gap: 11px;
    padding: 9px 0;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 11.5px;
    transition: color 0.2s;
}

.apply-steps li::before {
    counter-increment: step;
    content: '0' counter(step);
    color: rgba(255, 176, 46, 0.45);
    font-family: var(--font-mono);
    font-size: 8.5px;
}

.apply-steps li.is-current {
    color: var(--cream);
}

.apply-steps li.is-current::before {
    color: var(--amber);
}

.apply-steps li.is-done {
    color: rgba(242, 233, 218, 0.55);
}

.apply-side-note {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 10.5px;
    line-height: 1.65;
}

.apply-side-note b {
    color: var(--amber);
    font-weight: 600;
}

/* Правая колонка ----------------------------------------------- */

.apply-main {
    position: relative;
    max-height: min(92vh, 920px);
    padding: 34px 38px 30px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #3a2c15 #0a0907;
}

.apply-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 3;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    padding: 0;
    background: rgba(10, 9, 7, 0.55);
    border: 1px solid var(--line);
    color: var(--muted);
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.apply-close:hover {
    color: var(--cream);
    border-color: var(--amber);
    background: rgba(255, 176, 46, 0.08);
}

.apply-close svg {
    width: 16px;
    height: 16px;
}

.apply-progress {
    height: 2px;
    margin: 0 0 28px;
    background: var(--line);
    overflow: hidden;
}

.apply-progress span {
    display: block;
    width: 33.333%;
    height: 100%;
    background: var(--amber);
    transition: width 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.apply-status {
    display: none;
    margin: 0 0 18px;
    padding: 11px 14px;
    border: 1px solid rgba(255, 107, 94, 0.45);
    background: rgba(255, 107, 94, 0.08);
    color: #ffb3ab;
    font-size: 12px;
    line-height: 1.5;
}

.apply-status.is-visible {
    display: block;
}

.apply-step h3 {
    margin: 0 0 6px;
    font-family: var(--font-display);
    font-size: clamp(19px, 2.1vw, 24px);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.01em;
    text-transform: uppercase;
}

.apply-step-sub {
    margin: 0 0 24px;
    color: var(--muted);
    font-size: 12.5px;
    line-height: 1.65;
}

/* Поля ---------------------------------------------------------- */

.apply-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.apply-field {
    margin-bottom: 18px;
}

.apply-field > label {
    display: flex;
    align-items: baseline;
    gap: 7px;
    margin-bottom: 7px;
    color: var(--cream);
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.45;
}

.apply-req {
    color: var(--amber);
    font-size: 13px;
    line-height: 1;
}

.apply-opt {
    margin-left: auto;
    color: rgba(169, 156, 138, 0.7);
    font-size: 8px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}

.apply-comment {
    margin: -2px 0 7px;
    color: rgba(169, 156, 138, 0.8);
    font-size: 9px;
    line-height: 1.5;
}

.apply-field input[type="text"],
.apply-field input[type="number"],
.apply-field textarea,
.apply-field select {
    width: 100%;
    padding: 11px 13px;
    background: #0b0a08;
    border: 1px solid var(--line);
    color: var(--cream);
    font-family: var(--font-body);
    font-size: 13px;
    line-height: 1.55;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.apply-field textarea {
    min-height: 106px;
    resize: vertical;
}

.apply-field select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 38px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%23ffb02e' stroke-width='1.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    cursor: pointer;
}

.apply-field input::placeholder,
.apply-field textarea::placeholder {
    color: rgba(169, 156, 138, 0.45);
}

.apply-field input:focus,
.apply-field textarea:focus,
.apply-field select:focus {
    outline: none;
    border-color: var(--amber);
    background: #0f0d0a;
    box-shadow: 0 0 0 3px rgba(255, 176, 46, 0.08);
}

.apply-field.has-error input,
.apply-field.has-error textarea,
.apply-field.has-error select {
    border-color: rgba(255, 107, 94, 0.7);
    background: rgba(255, 107, 94, 0.035);
}

.field-error {
    margin: 6px 0 0;
    color: #ff8e83;
    font-size: 10.5px;
    line-height: 1.45;
}

.field-error:empty {
    display: none;
}

/* Роли ---------------------------------------------------------- */

.role-choice {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 6px;
}

.role-option {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 14px 13px 15px;
    background: #0b0a08;
    border: 1px solid var(--line);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.role-option:hover {
    border-color: rgba(255, 176, 46, 0.45);
    transform: translateY(-1px);
}

.role-option input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.role-option.is-selected {
    border-color: var(--amber);
    background:
        linear-gradient(150deg, rgba(255, 176, 46, 0.12), transparent 70%),
        #0f0d0a;
}

.role-option.is-selected::after {
    content: '✓';
    position: absolute;
    top: 8px;
    right: 10px;
    color: var(--amber);
    font-size: 11px;
}

.role-option-top {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}

.role-option-name {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
    line-height: 1.1;
    text-transform: uppercase;
}

.role-option-tag {
    color: var(--amber);
    font-size: 7.5px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.role-option-desc {
    color: var(--muted);
    font-size: 10.5px;
    line-height: 1.5;
}

.role-hint {
    margin: 4px 0 0;
    color: rgba(169, 156, 138, 0.75);
    font-size: 9.5px;
    line-height: 1.5;
}

/* Согласие ------------------------------------------------------ */

.apply-check {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    margin: 4px 0 0;
    padding: 13px 14px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.012);
    color: var(--muted);
    font-size: 11px;
    line-height: 1.55;
    cursor: pointer;
}

.apply-check input {
    width: 16px;
    height: 16px;
    margin: 2px 0 0;
    accent-color: var(--amber);
    cursor: pointer;
}

.apply-check.has-error {
    border-color: rgba(255, 107, 94, 0.6);
}

.apply-honeypot {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* Навигация ----------------------------------------------------- */

.apply-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.apply-nav .btn {
    min-width: 0;
}

.apply-nav .apply-back {
    margin-right: auto;
}

.apply-nav .apply-submit {
    min-width: 190px;
}

.apply-nav .btn.is-loading {
    opacity: 0.75;
    cursor: wait;
}

/* Загрузка и ошибка -------------------------------------------- */

.apply-loading,
.apply-error {
    padding: 42px 8px;
    text-align: center;
}

.apply-loading .mono,
.apply-error .mono {
    display: block;
    margin-bottom: 12px;
    color: var(--amber);
    font-size: 9px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.apply-loading p,
.apply-error p {
    max-width: 44ch;
    margin: 0 auto 18px;
    color: var(--muted);
    font-size: 12.5px;
    line-height: 1.65;
}

.apply-spinner {
    width: 22px;
    height: 22px;
    margin: 0 auto 18px;
    border: 2px solid var(--line);
    border-top-color: var(--amber);
    border-radius: 50%;
    animation: apply-spin 0.8s linear infinite;
}

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

.apply-error {
    border: 1px dashed rgba(255, 107, 94, 0.4);
    background: rgba(255, 107, 94, 0.04);
}

/* Успех --------------------------------------------------------- */

.apply-done {
    padding: 34px 6px 16px;
    text-align: center;
}

.apply-done-mark {
    display: grid;
    place-items: center;
    width: 58px;
    height: 58px;
    margin: 0 auto 20px;
    border: 1px solid var(--amber);
    background: rgba(255, 176, 46, 0.09);
    color: var(--amber);
    font-size: 24px;
}

.apply-done h3 {
    margin: 0 0 10px;
    font-family: var(--font-display);
    font-size: 22px;
    font-weight: 700;
    line-height: 1.15;
    text-transform: uppercase;
}

.apply-done p {
    max-width: 46ch;
    margin: 0 auto 24px;
    color: var(--muted);
    font-size: 12.5px;
    line-height: 1.7;
}

.apply-done .btn {
    min-width: 150px;
}

/* Мобильная версия --------------------------------------------- */

@media (max-width: 780px) {
    .apply-modal {
        padding: 0;
        place-items: stretch;
    }

    .apply-dialog {
        grid-template-columns: 1fr;
        width: 100%;
        max-height: 100dvh;
        border: 0;
        overflow-y: auto;
        box-shadow: none;
    }

    .apply-side {
        padding: 24px 20px 18px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        overflow: visible;
    }

    .apply-side::after {
        font-size: 54px;
        bottom: -10px;
    }

    .apply-side h2 {
        font-size: 22px;
    }

    .apply-side-copy {
        margin-bottom: 18px;
        font-size: 11.5px;
    }

    .apply-steps {
        flex-direction: row;
        gap: 6px;
        margin: 0;
        padding: 0;
        overflow-x: auto;
    }

    .apply-steps li {
        padding: 5px 8px;
        border: 1px solid var(--line);
        font-size: 10px;
        white-space: nowrap;
    }

    .apply-steps li::before {
        font-size: 8px;
    }

    .apply-steps li.is-current {
        border-color: var(--amber);
    }

    .apply-side-note {
        display: none;
    }

    .apply-main {
        max-height: none;
        padding: 26px 20px 26px;
        overflow: visible;
    }

    .apply-close {
        top: 10px;
        right: 10px;
    }

    .apply-progress {
        margin-bottom: 22px;
    }

    .apply-grid-2 {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .role-choice {
        grid-template-columns: 1fr;
    }

    .role-option {
        padding: 12px 13px;
    }

    .role-option-desc {
        font-size: 11px;
    }

    .apply-nav {
        position: sticky;
        bottom: 0;
        margin: 18px -20px -26px;
        padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
        background: rgba(18, 16, 13, 0.96);
        backdrop-filter: blur(8px);
        border-top: 1px solid var(--line);
    }

    .apply-nav .apply-submit {
        min-width: 0;
        flex: 1;
    }
}

@media (max-width: 420px) {
    .apply-side {
        padding: 22px 16px 16px;
    }

    .apply-main {
        padding: 22px 16px 24px;
    }

    .apply-nav {
        margin: 18px -16px -24px;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    }

    .apply-nav .btn {
        padding-left: 12px;
        padding-right: 12px;
        font-size: 11.5px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .apply-dialog {
        animation: none;
    }

    .apply-spinner {
        animation-duration: 2s;
    }
}
