/*
 * modularsystem.sk — academy (MAM) account pages: the layout academy-sign-in-1 and
 * academy-registration-1 share (`msaAuth` block). Registered in `_styles` after
 * mam-kit.css; the component's own style.css only sets its widths and grid.
 *
 * Shell = one framed card: a value panel (ink / tint, editor content) next to the form;
 * stacked (form first) below 56rem. Values: DESIGN_MANUAL.md §11 "Academy" (`--msa-*` tokens from
 * mam-kit.css), §2 "Semantic" trios, §3 rules for text on a dark surface, §6 focus rule.
 */

.msaAuth {
    display: flex;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
    padding: 5rem 2rem;
    background-color: var(--msa-surface-alt, #f6f8fc);
    color: var(--msa-text, #4b5262);
    container-type: inline-size;
}

.msaAuth[data-bg="none"] {
    background-color: var(--msa-surface, #fff);
}

.msaAuth [hidden] {
    display: none;
}

.msaAuth__inner {
    width: 100%;
    max-width: 68rem;
}

.msaAuth__shell {
    display: grid;
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1fr);
    overflow: hidden;
    background-color: var(--msa-surface, #fff);
    border: 1px solid var(--msa-border, #e4e7ef);
    border-radius: var(--msa-radius, 0.875rem);
    box-shadow: var(
        --msa-shadow,
        0 8px 40px rgba(10, 15, 36, 0.13),
        0 2px 8px rgba(10, 15, 36, 0.06)
    );
}

.msaAuth[data-panel="none"] .msaAuth__shell {
    grid-template-columns: minmax(0, 1fr);
}

/* ----- value panel (second in the DOM, first on screen) ----- */

.msaAuth__panel {
    position: relative;
    order: -1;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    overflow: hidden;
    padding: 3rem 2.5rem;
    color: rgba(255, 255, 255, 0.82);
    background-color: var(--msa-navy, #0b1437);
}

.msaAuth__glow {
    position: absolute;
    inset: auto -30% -35% auto;
    width: 90%;
    height: 80%;
    background: radial-gradient(
        closest-side,
        color-mix(in srgb, var(--msa-blue, #1f45d1) 38%, transparent),
        transparent 70%
    );
    pointer-events: none;
}

.msaAuth__panel > :not(.msaAuth__glow) {
    position: relative;
}

.msaAuth__eyebrow {
    margin: 0;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.78);
}

/* The panel's one red accent: the logo-gradient dash before the eyebrow */
.msaAuth__eyebrow::before {
    content: "";
    display: inline-block;
    width: 1.5rem;
    height: 0.1875rem;
    margin-right: 0.625rem;
    vertical-align: middle;
    background: var(--msa-gradient, linear-gradient(90deg, #fc4f0d, #fe0000));
    border-radius: 2px;
}

.msaAuth__panelTitle {
    margin: 0;
    font-size: 1.875rem;
    font-weight: 800;
    line-height: 1.2;
    color: #fff;
    letter-spacing: -0.02em;
}

.msaAuth__panelText {
    margin: 0;
    font-size: 1.0625rem;
    line-height: 1.65;
}

.msaAuth__panelText a {
    color: inherit;
}

.msaAuth__points {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
    margin: 0.5rem 0 0;
    padding: 0;
    list-style: none;
}

.msaAuth__point {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
}

.msaAuth__pointIcon {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    color: #fff;
    background-color: rgba(255, 255, 255, 0.14);
    border-radius: 50%;
}

.msaAuth__pointIcon svg {
    width: 0.875rem;
    height: 0.875rem;
}

.msaAuth__panelImage {
    margin-top: auto;
    padding-top: 1rem;
}

.msaAuth__panelImage img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: var(--msa-radius, 0.875rem);
}

.msaAuth__panel a:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Light panel: accent tint, ink title, accent only on the large icon tile */
.msaAuth[data-panel="light"] .msaAuth__panel {
    color: var(--msa-text, #4b5262);
    background-color: var(--msa-blue-tint, #eef2fd);
}

.msaAuth[data-panel="light"] .msaAuth__glow {
    display: none;
}

.msaAuth[data-panel="light"] .msaAuth__eyebrow {
    color: var(--msa-blue, #1f45d1);
}

.msaAuth[data-panel="light"] .msaAuth__panelTitle {
    color: var(--msa-ink, #0a0f24);
}

.msaAuth[data-panel="light"] .msaAuth__pointIcon {
    color: #fff;
    background-color: var(--msa-blue, #1f45d1);
}

.msaAuth[data-panel="light"] .msaAuth__panel a:focus-visible {
    outline: var(--msa-focus, 3px solid #1f45d1);
}

/* ----- form side ----- */

.msaAuth__main {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1.5rem;
    min-width: 0;
    padding: 3rem;
}

.msaAuth__view {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-width: 0;
    transition: opacity var(--msa-transition, 0.2s ease);
}

/* Set by the script only (never server-side): the session is being read. */
.msaAuth__main.is-loading .msaAuth__view {
    opacity: 0;
    pointer-events: none;
    transition: none;
}

.msaAuth__view:focus {
    outline: none;
}

.msaAuth__fields {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.msaAuth__head {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.msaAuth__title {
    margin: 0;
    font-size: 1.875rem;
    font-weight: 800;
    line-height: 1.2;
    color: var(--msa-ink, #0a0f24);
    letter-spacing: -0.02em;
}

.msaAuth__title:focus {
    outline: none;
}

.msaAuth__lead {
    margin: 0;
    font-size: 1rem;
    line-height: 1.65;
}

.msaAuth__lead a,
.msaAuth__consent a,
.msaAuth__alt a {
    color: var(--msa-blue, #1f45d1);
    text-underline-offset: 3px;
}

.msaAuth__lead a:hover,
.msaAuth__consent a:hover,
.msaAuth__alt a:hover {
    color: var(--msa-blue-hover, #1838ad);
}

.msaAuth__main a:focus-visible {
    outline: var(--msa-focus, 3px solid #1f45d1);
    outline-offset: 2px;
}

.msaAuth__optional {
    margin-left: 0.25rem;
    font-size: 0.8125rem;
    font-weight: 400;
    color: var(--msa-text, #4b5262);
}

.msaAuth .msaInput {
    min-height: 3rem;
}

.msaAuth .msaInput:disabled {
    background-color: var(--msa-surface-alt, #f6f8fc);
    cursor: not-allowed;
}

.msaAuth .msaInput.is-invalid {
    box-shadow: inset 0 0 0 1px #b3261e;
}

/* Password + show / hide */
.msaAuth__password {
    position: relative;
    display: flex;
}

.msaAuth__password .msaInput {
    padding-right: 3.25rem;
}

.msaAuth__toggle {
    position: absolute;
    top: 0;
    right: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 100%;
    padding: 0;
    color: var(--msa-text, #4b5262);
    background: none;
    border: 0;
    border-radius: var(--msa-radius-input, 0.5rem);
    cursor: pointer;
    transition: color var(--msa-transition, 0.2s ease);
}

.msaAuth__toggle:hover {
    color: var(--msa-ink, #0a0f24);
}

.msaAuth__toggle:focus-visible {
    outline: var(--msa-focus, 3px solid #1f45d1);
    outline-offset: -3px;
}

.msaAuth__toggle:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.msaAuth__toggle svg {
    width: 1.25rem;
    height: 1.25rem;
}

.msaAuth__toggle[aria-pressed="false"] .msaAuth__toggleOff,
.msaAuth__toggle[aria-pressed="true"] .msaAuth__toggleOn {
    display: none;
}

/* Inline field error (text set by the script) */
.msaAuth__error {
    margin: 0;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.5;
    color: #7a1c15;
}

/* Password rule: neutral until met */
.msaAuth__rule {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.msaAuth__rule svg {
    flex-shrink: 0;
    width: 0.875rem;
    height: 0.875rem;
    color: var(--msa-muted, #8a93a8);
}

.msaAuth__rule.is-met {
    color: #0f4d2c;
}

.msaAuth__rule.is-met svg {
    color: #1e7a46;
}

.msaAuth__row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem 1rem;
    margin-top: -0.5rem;
    font-size: 0.9375rem;
}

/* Consent */
.msaAuth__consentField {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.msaAuth__consent {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    line-height: 1.55;
    background-color: var(--msa-surface-alt, #f6f8fc);
    border: 1px solid var(--msa-border, #e4e7ef);
    border-radius: var(--msa-radius-input, 0.5rem);
    cursor: pointer;
}

.msaAuth__consent input {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    margin: 0.05rem 0 0;
    accent-color: var(--msa-blue, #1f45d1);
    cursor: pointer;
}

.msaAuth__consent input:focus-visible {
    outline: var(--msa-focus, 3px solid #1f45d1);
    outline-offset: 2px;
}

.msaAuth__consent.is-invalid {
    background-color: #fdf1f0;
    border-color: #b3261e;
}

/* Altcha */
.msaAuth__captcha {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.msaAuth altcha-widget {
    --altcha-max-width: 100%;
    --altcha-border-radius: 0.5rem;
    --altcha-color-border: #8a93a8;
    --altcha-color-base: #fff;
    --altcha-color-text: #4b5262;
    --altcha-color-border-focus: #1f45d1;

    display: block;
}

.msaAuth altcha-widget.is-invalid {
    --altcha-color-border: #b3261e;
}

/* Actions */
.msaAuth__submit {
    width: 100%;
}

.msaAuth .msaButton:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.msaAuth .msaButton[aria-busy="true"] {
    cursor: progress;
}

.msaAuth .msaButton[aria-busy="true"]::before {
    content: "";
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
    box-sizing: border-box;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: msaAuthSpin 0.7s linear infinite;
}

.msaAuth__actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.msaAuth__actions .msaButton {
    width: 100%;
}

.msaAuth__center {
    display: flex;
    justify-content: center;
    font-size: 0.9375rem;
}

.msaAuth__alt {
    margin: 0;
    padding-top: 1.25rem;
    font-size: 0.9375rem;
    line-height: 1.5;
    text-align: center;
    border-top: 1px solid var(--msa-border, #e4e7ef);
}

.msaAuth__alt a {
    font-weight: 600;
}

/* Trust line under the form */
.msaAuth__note {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.5;
}

.msaAuth__note svg {
    flex-shrink: 0;
    width: 1rem;
    height: 1rem;
    margin-top: 0.1rem;
}

/* Result views (signed in, mail sent, account created, redirect) */
.msaAuth__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 3rem;
    height: 3rem;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--msa-blue, #1f45d1);
    background-color: var(--msa-blue-tint, #eef2fd);
    border-radius: 50%;
}

.msaAuth__badge svg {
    width: 1.5rem;
    height: 1.5rem;
}

.msaAuth__badge--success {
    color: #1e7a46;
    background-color: #effaf3;
}

.msaAuth__who {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    min-width: 0;
    padding: 0.875rem 1rem;
    background-color: var(--msa-surface-alt, #f6f8fc);
    border: 1px solid var(--msa-border, #e4e7ef);
    border-radius: var(--msa-radius-input, 0.5rem);
}

.msaAuth__who .msaAuth__badge {
    flex-shrink: 0;
    width: 2.75rem;
    height: 2.75rem;
}

.msaAuth__whoBody {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.45;
}

.msaAuth__whoName {
    font-weight: 700;
    color: var(--msa-ink, #0a0f24);
    overflow-wrap: anywhere;
}

.msaAuth__whoEmail {
    font-size: 0.875rem;
    overflow-wrap: anywhere;
}

.msaAuth__strong {
    font-weight: 600;
    color: var(--msa-ink, #0a0f24);
    overflow-wrap: anywhere;
}

@keyframes msaAuthSpin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .msaAuth__view,
    .msaAuth__toggle {
        transition: none;
    }

    .msaAuth .msaButton[aria-busy="true"]::before {
        animation: none;
    }
}

/* ----- tiers (desktop-first, DESIGN_MANUAL.md §7) ----- */

@container (width < 72rem) {
    .msaAuth__main {
        padding: 2.5rem;
    }

    .msaAuth__panel {
        padding: 2.5rem 2rem;
    }
}

@container (width < 56rem) {
    .msaAuth__shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .msaAuth__panel {
        order: 0;
        gap: 1rem;
        padding: 2rem 2.5rem;
    }

    .msaAuth__panelTitle {
        font-size: 1.5rem;
    }

    .msaAuth__panelText {
        font-size: 1rem;
    }

    .msaAuth__panelImage {
        display: none;
    }
}

@container (width < 48rem) {
    .msaAuth {
        padding: 3.5rem 1.5rem;
    }
}

@container (width < 37rem) {
    .msaAuth {
        padding: 2rem 1rem;
    }

    .msaAuth__main {
        gap: 1.25rem;
        padding: 1.75rem 1.25rem;
    }

    .msaAuth__panel {
        padding: 1.75rem 1.25rem;
    }

    .msaAuth__title {
        font-size: 1.625rem;
    }

    .msaAuth__panelTitle {
        font-size: 1.375rem;
    }
}
