/* ============================================================================
   TESTORIA · SIGN-IN SITE
   Components reference only semantic tokens from tokens.css.
   No inline styles anywhere: the CSP forbids them.
   ========================================================================= */

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100dvh;
    font-family: var(--font-ui);
    font-size: var(--t-body);
    line-height: var(--t-body-lh);
    color: var(--text-primary);
    background: var(--surface-raised);
}

a {
    color: var(--text-on-soft);
    font-weight: var(--w-semi);
    text-decoration: none;
}

    a:hover {
        text-decoration: underline;
    }

    a:focus-visible,
    button:focus-visible,
    input:focus-visible {
        outline: var(--focus-ring) solid var(--border-focus);
        outline-offset: 2px;
    }

h1,
h2,
p {
    margin: 0;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: var(--s-4);
    top: -100px;
    z-index: var(--z-toast);
    padding: var(--s-2) var(--s-4);
    border-radius: var(--r-sm);
    background: var(--surface-inverse);
    color: var(--white);
}

    .skip-link:focus {
        top: var(--s-4);
    }

/* ---------- Logo ---------- */

.logo {
    display: inline-flex;
    align-items: center;
    gap: var(--s-3);
    color: var(--text-primary);
    text-decoration: none;
}

    .logo:hover {
        text-decoration: none;
    }

.logo__mark {
    width: 40px;
    height: 36px;
    flex-shrink: 0;
}

.logo__word {
    font-family: var(--font-display);
    font-weight: var(--w-bold);
    font-size: 24px;
    letter-spacing: var(--track-tight);
}

.logo--sm .logo__mark {
    width: 30px;
    height: 27px;
}

.logo--sm .logo__word {
    font-size: 20px;
}

/* ---------- Split shell (sign-in / sign-up) ---------- */

.shell {
    min-height: 100dvh;
    display: flex;
}

.shell__frame {
    flex: 1 1 auto;
    display: flex;
    min-width: 0;
}

.shell__brand {
    display: none;
}

/* Soft colour blobs behind the form, same as the landing hero. Shown on wide screens only. */
.shell__decor {
    display: none;
}

.shell__main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s-6);
    padding: var(--s-5) var(--gutter) var(--s-6);
}

.shell__top {
    width: 100%;
    max-width: 440px;
}

.shell__content {
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    gap: var(--s-5);
}

.shell__legal {
    width: 100%;
    max-width: 440px;
    margin-top: auto;
    text-align: center;
    font-size: var(--t-cap);
    line-height: var(--t-sub-lh);
    color: var(--text-secondary);
}

/* Wide screens: brand panel on 35% of the viewport, the form as a bordered panel centred in the remaining 65%. */
@media (min-width: 1024px) {
    .shell__brand {
        position: relative;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        flex: 0 0 35%;
        padding: var(--s-12) var(--s-10);
        background: var(--accent-soft);
    }

        .shell__brand::after {
            content: "";
            position: absolute;
            top: 0;
            right: 0;
            bottom: 0;
            width: var(--edge);
            background: var(--accent);
        }

    .brand__group {
        width: 100%;
        max-width: 440px;
        display: flex;
        flex-direction: column;
        gap: var(--s-10);
    }

    .shell__main {
        flex: 1 1 65%;
        justify-content: center;
        padding: var(--s-12) var(--s-10) var(--s-8);
    }

    .shell__main {
        position: relative;
        overflow: hidden;
    }

    .shell__decor {
        position: absolute;
        inset: 0;
        display: block;
        overflow: hidden;
        pointer-events: none;
    }

    /* Blobs are anchored to the centre of the column so they sit right around the form panel. */
    .blob {
        position: absolute;
        top: 50%;
        left: 50%;
        border-radius: 50%;
        filter: blur(60px);
    }

    .blob--blue {
        width: 400px;
        height: 400px;
        transform: translate(-115%, -95%);
        background: var(--blue-500);
        opacity: .42;
    }

    .blob--orange {
        width: 280px;
        height: 280px;
        transform: translate(55%, -115%);
        background: var(--red-500);
        opacity: .28;
    }

    .blob--yellow {
        width: 260px;
        height: 260px;
        transform: translate(-135%, 25%);
        background: var(--amber-500);
        opacity: .26;
    }

    .blob--green {
        width: 340px;
        height: 340px;
        transform: translate(35%, 5%);
        background: var(--green-500);
        opacity: .36;
    }

    .shell__content,
    .shell__legal {
        position: relative;
        z-index: 1;
    }

    .shell__top {
        display: none;
    }

    .shell__content {
        max-width: 480px;
        padding: var(--s-8) 40px;
        border: 1px solid var(--border-strong);
        border-radius: var(--r-xl);
        background: var(--surface-raised);
        box-shadow: var(--elev-2);
    }

    .shell__legal {
        max-width: 480px;
        margin-top: var(--s-1);
    }
}

.brand__body {
    display: flex;
    flex-direction: column;
    gap: var(--s-8);
}

.brand__title {
    max-width: 420px;
    font-family: var(--font-display);
    font-weight: var(--w-bold);
    font-size: 38px;
    line-height: 1.15;
    letter-spacing: var(--track-tight);
}

.brand__lead {
    max-width: 420px;
    margin-top: var(--s-4);
    font-size: 17px;
    line-height: var(--t-body-lh);
    color: var(--text-secondary);
}

.brand__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--s-5);
}

.brand__item {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.brand__icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: var(--r-md);
    display: grid;
    place-items: center;
    background: var(--surface-raised);
    color: var(--blue-650);
    box-shadow: var(--elev-1);
}

.brand__item-title {
    display: block;
    font-weight: var(--w-bold);
}

.brand__item-text {
    display: block;
    font-size: var(--t-sub);
    color: var(--text-secondary);
}

/* ---------- Headings ---------- */

.page-head {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.page-title {
    color: var(--text-primary);
    font-family: var(--font-display);
    font-weight: var(--w-semi);
    font-size: 26px;
    line-height: 1.2;
    letter-spacing: var(--track-tight);
}

@media (min-width: 1024px) {
    .page-title {
        font-size: 28px;
    }
}

.page-sub {
    font-size: var(--t-ui);
    color: var(--text-secondary);
}

    .page-sub b {
        color: var(--text-primary);
    }

/* ---------- Tabs ---------- */

.tabs {
    display: flex;
    gap: var(--s-1);
    padding: var(--s-1);
    border-radius: 12px;
    background: var(--surface-sunken);
}

.tab {
    flex: 1 1 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: var(--ctl-md);
    border-radius: 9px;
    font-size: var(--t-ui);
    font-weight: var(--w-semi);
    color: var(--text-secondary);
}

    .tab:hover {
        color: var(--text-primary);
        text-decoration: none;
    }

.tab--active {
    background: var(--surface-raised);
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(22, 30, 39, .08), 0 0 0 1px rgba(22, 30, 39, .06);
}

/* ---------- Stepper ---------- */

.stepper {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stepper__meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--s-3);
    font-size: var(--t-cap);
    font-weight: var(--w-semi);
    color: var(--text-secondary);
}

.stepper__bars {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
}

.stepper__bar {
    height: 4px;
    border-radius: var(--r-full);
    background: var(--ink-200);
}

.stepper__bar--done {
    background: var(--accent);
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: var(--ctl-lg);
    padding: 0 var(--s-4);
    border: 0;
    border-radius: 12px;
    font-family: var(--font-ui);
    font-size: var(--t-body);
    font-weight: var(--w-semi);
    cursor: pointer;
    text-decoration: none;
    transition: background-color var(--d-fast) var(--ease-out), border-color var(--d-fast) var(--ease-out), color var(--d-fast) var(--ease-out);
    touch-action: manipulation;
}

    .btn:hover {
        text-decoration: none;
    }

.btn--primary {
    background: var(--accent-action);
    color: var(--text-on-accent);
}

    .btn--primary:hover {
        background: var(--accent-hover);
    }

.btn:disabled {
    cursor: default;
}

.btn:disabled:not(.is-loading) {
    opacity: .5;
}

.btn.is-loading {
    position: relative;
    color: transparent;
    pointer-events: none;
}

    .btn.is-loading::after {
        content: "";
        position: absolute;
        top: 50%;
        left: 50%;
        width: 20px;
        height: 20px;
        margin: -10px 0 0 -10px;
        border: 2px solid currentColor;
        border-right-color: transparent;
        border-radius: 50%;
        animation: btn-spin .7s linear infinite;
    }

.btn--primary.is-loading::after {
    border-color: var(--text-on-accent);
    border-right-color: transparent;
}

.btn--ghost.is-loading::after {
    border-color: var(--text-primary);
    border-right-color: transparent;
}

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

.btn--ghost,
.btn--social {
    background: var(--surface-raised);
    border: 1px solid var(--border-strong);
    color: var(--text-primary);
}

    .btn--ghost:hover,
    .btn--social:hover {
        border-color: var(--text-tertiary);
        background: var(--surface);
    }

.social {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s-3);
}

.social--single {
    grid-template-columns: minmax(0, 1fr);
}

.social-mark {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    color: var(--white);
    font-weight: 800;
    line-height: 1;
}

.social-mark--vk {
    border-radius: 7px;
    background: #0077FF;
    font-size: 11px;
}

.social-mark--yandex {
    border-radius: var(--r-full);
    background: #FC3F1D;
    font-size: 14px;
}

.divider {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    font-size: var(--t-cap);
    color: var(--text-secondary);
}

    .divider::before,
    .divider::after {
        content: "";
        flex: 1 1 auto;
        height: 1px;
        background: var(--border);
    }

/* ---------- Forms ---------- */

.form {
    display: flex;
    flex-direction: column;
    gap: var(--s-4);
    margin: 0;
}

.form__submit {
    margin-top: var(--s-1);
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.field-pair {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--s-4);
}

@media (min-width: 480px) {
    .field-pair {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: var(--s-3);
    }
}

.field__row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--s-3);
    font-size: var(--t-sub);
}

.field__label {
    font-size: var(--t-sub);
    font-weight: var(--w-semi);
    color: var(--ink-700);
    padding: 0;
}

.hint {
    font-size: var(--t-cap);
    color: var(--text-secondary);
}

.input {
    width: 100%;
    min-height: var(--ctl-lg);
    padding: 0 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--r-sm);
    background: var(--surface-raised);
    font-family: var(--font-ui);
    font-size: 16px;
    font-weight: var(--w-medium);
    color: var(--text-primary);
}

    .input::placeholder {
        color: var(--text-tertiary);
    }

    .input:focus {
        outline: none;
        border-color: var(--border-focus);
        box-shadow: 0 0 0 3px var(--blue-100);
    }

    .input[aria-invalid="true"] {
        border-color: var(--danger);
    }

.input-wrap {
    position: relative;
}

    .input-wrap .input {
        padding-right: 52px;
    }

.reveal {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 40px;
    height: 40px;
    display: none;
    place-items: center;
    border: 0;
    border-radius: var(--r-xs);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}

    .reveal:hover {
        background: var(--surface-sunken);
        color: var(--text-primary);
    }

.js .reveal {
    display: grid;
}

.reveal__off {
    display: none;
}

.reveal[aria-pressed="true"] .reveal__on {
    display: none;
}

.reveal[aria-pressed="true"] .reveal__off {
    display: block;
}

/* Six-digit code: one real input so paste, autofill and screen readers keep working. */
.code-input {
    min-height: 60px;
    padding: 0 var(--s-4);
    text-align: center;
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 28px;
    font-weight: var(--w-bold);
    letter-spacing: .5em;
    font-variant-numeric: tabular-nums;
}

    .code-input::placeholder {
        letter-spacing: .5em;
        color: var(--ink-300);
    }

.field-error {
    display: flex;
    gap: 6px;
    align-items: flex-start;
    font-size: var(--t-cap);
    line-height: var(--t-cap-lh);
    color: var(--danger);
}

    .field-error svg {
        flex-shrink: 0;
        margin-top: 1px;
    }

.alert {
    display: flex;
    gap: var(--s-3);
    align-items: flex-start;
    padding: var(--s-3) 14px;
    border-radius: 12px;
    font-size: var(--t-sub);
    line-height: var(--t-sub-lh);
}

    .alert svg {
        flex-shrink: 0;
        margin-top: 2px;
    }

.alert--error {
    background: var(--danger-soft);
    color: var(--danger);
}

.alert--success {
    background: var(--success-soft);
    color: var(--success);
}

.alert--info {
    background: var(--accent-soft);
    color: var(--text-on-soft);
}

.notice {
    display: flex;
    gap: var(--s-3);
    align-items: flex-start;
    padding: 14px var(--s-4);
    border-radius: 12px;
    background: var(--surface);
    font-size: var(--t-sub);
    line-height: var(--t-sub-lh);
    color: var(--ink-700);
}

.notice__title {
    display: block;
    font-weight: var(--w-bold);
    font-size: var(--t-ui);
    color: var(--text-primary);
}

.center-text {
    text-align: center;
    font-size: var(--t-ui);
    color: var(--text-secondary);
}

.link-button {
    display: inline;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    font-weight: var(--w-semi);
    color: var(--text-on-soft);
    cursor: pointer;
}

    .link-button:hover {
        text-decoration: underline;
    }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: var(--tap-min);
    color: var(--ink-700);
}

.icon-badge {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: var(--accent-soft);
    color: var(--blue-650);
}

.icon-badge--green {
    background: var(--success-soft);
    color: var(--success);
}

.icon-badge--red {
    background: var(--danger-soft);
    color: var(--danger);
}

/* ---------- Card shell (consent, errors, handoff, sign-out) ---------- */

.card-shell {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
}

.topbar {
    display: flex;
    align-items: center;
    min-height: var(--header-h);
    padding: 0 var(--gutter);
    border-bottom: 1px solid var(--border);
    background: var(--surface-raised);
}

.card-main {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--s-4);
    padding: var(--s-6) var(--gutter) var(--s-8);
}

.card {
    width: 100%;
    max-width: 520px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: var(--s-6) var(--s-5);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    background: var(--surface-raised);
    box-shadow: var(--elev-2);
}

@media (min-width: 560px) {
    .card {
        padding: var(--s-8);
    }
}

.card-note {
    max-width: 520px;
    text-align: center;
    font-size: var(--t-cap);
    line-height: 1.5;
    color: var(--text-secondary);
}

.details {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: var(--s-2) var(--s-4);
    margin: 0;
    padding: 14px var(--s-4);
    border-radius: 12px;
    background: var(--surface);
    font-size: var(--t-sub);
}

    .details dt {
        color: var(--text-secondary);
    }

    .details dd {
        margin: 0;
        font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
        overflow-wrap: anywhere;
    }

/* ---------- Consent ---------- */

.apps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
}

.app-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--r-md);
    display: grid;
    place-items: center;
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--surface-sunken);
    font-weight: 800;
    font-size: 22px;
    color: var(--ink-700);
}

    .app-icon img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

.app-icon--testoria {
    border: 0;
    background: var(--accent-soft);
}

.apps__dots {
    display: flex;
    gap: 5px;
}

    .apps__dots span {
        width: 5px;
        height: 5px;
        border-radius: var(--r-full);
        background: var(--ink-400);
    }

.consent-title {
    text-align: center;
    font-family: var(--font-display);
    font-weight: var(--w-semi);
    font-size: var(--t-title);
    line-height: 1.3;
    letter-spacing: var(--track-tight);
}

.domain-box {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: var(--s-4) 18px;
    border: 1px solid var(--accent-line);
    border-radius: var(--r-md);
    background: var(--accent-soft);
}

.domain-box__label {
    font-size: var(--t-micro);
    font-weight: var(--w-bold);
    letter-spacing: var(--track-caps);
    text-transform: uppercase;
    color: var(--text-on-soft);
}

.domain-box__host {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: var(--track-tight);
    line-height: 1.2;
    overflow-wrap: anywhere;
}

    .domain-box__host svg {
        flex-shrink: 0;
        color: var(--text-on-soft);
    }

.domain-box__text {
    font-size: var(--t-sub);
    color: var(--ink-700);
}

.account-row {
    display: flex;
    align-items: center;
    gap: var(--s-3);
}

.account-row__text {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.account-row__caption {
    font-size: var(--t-cap);
    color: var(--text-secondary);
}

.account-row__name {
    font-weight: var(--w-bold);
    font-size: var(--t-ui);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-row > a {
    flex-shrink: 0;
    white-space: nowrap;
}

.avatar {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: var(--r-full);
    display: grid;
    place-items: center;
    background: var(--success-mark);
    color: var(--white);
    font-weight: var(--w-bold);
}

.perms {
    display: flex;
    flex-direction: column;
    gap: var(--s-3);
    margin: 0;
    padding: 0;
    list-style: none;
}

.perms__title {
    font-size: var(--t-ui);
    font-weight: var(--w-bold);
}

.perm {
    display: flex;
    gap: var(--s-3);
    align-items: center;
    font-size: var(--t-ui);
}

.perm__mark {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: var(--r-full);
    display: grid;
    place-items: center;
    background: var(--success-soft);
    color: var(--success);
}

.perm--muted {
    font-size: var(--t-sub);
    color: var(--text-secondary);
}

    .perm--muted .perm__mark {
        background: var(--surface-sunken);
        color: var(--text-secondary);
    }

.check-row {
    display: flex;
    gap: var(--s-3);
    align-items: flex-start;
    padding: 14px var(--s-4);
    border-radius: 12px;
    background: var(--surface);
    cursor: pointer;
}

.check-row__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.check-row__title {
    font-weight: var(--w-bold);
    font-size: var(--t-ui);
}

.check-row__sub {
    font-size: var(--t-cap);
    color: var(--text-secondary);
}

.check {
    appearance: none;
    -webkit-appearance: none;
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    margin: 0;
    display: grid;
    place-content: center;
    border: 1.5px solid var(--text-tertiary);
    border-radius: 6px;
    background: var(--surface-raised);
    cursor: pointer;
}

    .check:checked {
        border-color: var(--accent-action);
        background: var(--accent-action);
    }

        .check:checked::after {
            content: "";
            width: 6px;
            height: 11px;
            border: solid var(--white);
            border-width: 0 2.5px 2.5px 0;
            transform: translateY(-1px) rotate(45deg);
        }

.actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--s-3);
}

/* ---------- QR sign-in ---------- */

.qr {
    align-self: center;
    width: 264px;
    padding: 12px;
    border: 1px solid var(--border-strong);
    border-radius: 18px;
    background: #fff;
    box-shadow: var(--elev-1);
    line-height: 0;
}

    .qr > svg {
        display: block;
        width: 100%;
        height: auto;
    }

.qr__hint {
    margin: 0;
    font-size: var(--t-cap);
    line-height: 1.45;
    color: var(--text-secondary);
    text-align: center;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
    }

    .btn.is-loading::after {
        animation-duration: 1.6s;
    }
}

.app-icon--testoria .logo__mark {
    width: 34px;
    height: 31px;
}
