/*
 * Shared styles for the sign-in, password and authenticator pages.
 * Two verbatim copies; change both together:
 *   - HttpApi.Host/wwwroot/css/login-custom.css  (layout: Pages/Shared/_AuthLayout.cshtml)
 *   - Blazor.Client/wwwroot/css/auth.css         (layout: Components/UI/AuthShell.razor)
 * Tokens come from each project's css/tokens.css.
 */

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

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

.auth-body,
.login-body {
    margin: 0;
    background: var(--ps-surface);
}

/* Split layout: brand panel on the left, form on the right */
.auth-layout {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-columns: minmax(400px, 5fr) 7fr;
    background: var(--ps-surface);
    color: var(--ps-ink);
    font-family: var(--ps-font-sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Brand panel */
.auth-aside {
    position: relative;
    min-width: 0;
    background: var(--ps-auth-aside-bg);
    color: var(--ps-auth-aside-ink);
}

/* Sticky so the panel stays composed when a long form (authenticator setup) scrolls. */
.auth-aside__inner {
    position: sticky;
    top: 0;
    isolation: isolate;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 40px 48px 32px;
}

.auth-aside__inner::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background-image: radial-gradient(var(--ps-auth-aside-line) 1px, transparent 1px);
    background-size: 24px 24px;
    -webkit-mask-image: linear-gradient(180deg, #000, transparent 70%);
    mask-image: linear-gradient(180deg, #000, transparent 70%);
}

.auth-aside__flow {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    width: 100%;
    height: auto;
    color: var(--ps-auth-aside-flow);
    pointer-events: none;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
    mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent);
}

.auth-aside__flow path {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.25;
}

.auth-aside__lines path {
    opacity: 0.28;
}

.auth-aside__lines path:nth-child(even) {
    opacity: 0.16;
}

/* Light pulses travelling along the streams; pathLength="1000" on each path keeps the dash maths uniform. */
.auth-aside__pulses path {
    stroke: var(--ps-auth-aside-ink);
    stroke-width: 2;
    stroke-linecap: round;
    stroke-dasharray: 80 920;
    opacity: 0.85;
    animation: auth-flow 9s linear infinite;
}

.auth-aside__pulses path:nth-child(2) {
    animation-duration: 12s;
    animation-delay: -4s;
}

.auth-aside__pulses path:nth-child(3) {
    animation-duration: 15s;
    animation-delay: -9s;
}

@keyframes auth-flow {
    from {
        stroke-dashoffset: 1000;
    }

    to {
        stroke-dashoffset: 0;
    }
}

.auth-aside__body {
    max-width: 460px;
    margin: auto 0;
    padding: 48px 0;
}

.auth-aside__eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 20px;
    padding: 4px 12px;
    border: 1px solid var(--ps-auth-aside-line);
    border-radius: 999px;
    background: var(--ps-auth-aside-tile);
    color: var(--ps-auth-aside-muted);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.auth-aside__eyebrow::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--ps-auth-aside-flow);
}

.auth-aside__title {
    margin: 0 0 14px;
    color: inherit;
    font-size: clamp(26px, 2.4vw, 36px);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.025em;
    text-wrap: balance;
}

.auth-aside__lead {
    max-width: 42ch;
    margin: 0 0 32px;
    color: var(--ps-auth-aside-muted);
    font-size: 15px;
}

.auth-aside__list {
    display: grid;
    gap: 18px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.auth-aside__item {
    display: grid;
    grid-template-columns: 40px 1fr;
    gap: 14px;
    align-items: start;
}

.auth-aside__item-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--ps-auth-aside-line);
    border-radius: 10px;
    background: var(--ps-auth-aside-tile);
}

.auth-aside__item-icon .auth-icon {
    width: 20px;
    height: 20px;
}

.auth-aside__item strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
}

.auth-aside__item span {
    color: var(--ps-auth-aside-muted);
    font-size: 13px;
}

.auth-aside__foot {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ps-auth-aside-muted);
    font-size: 12px;
}

/* Brand */
.auth-brand {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    gap: 10px;
    color: inherit;
    text-decoration: none;
}

.auth-brand:hover {
    color: inherit;
    text-decoration: none;
}

.auth-brand__mark {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: var(--ps-auth-aside-ink);
    color: var(--ps-brand-2);
    font-weight: 700;
    font-size: 18px;
    line-height: 36px;
    text-align: center;
    flex: 0 0 auto;
}

.auth-brand__name {
    font-weight: 600;
    font-size: 18px;
    letter-spacing: -0.01em;
}

/* Icons: stroke glyphs on a 24px grid, coloured by the parent */
.auth-icon {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Form side */
.auth-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
    padding: 40px 24px 28px;
    background: var(--ps-surface);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    margin: auto 0;
    padding: 24px 0;
    animation: auth-rise 0.35s ease-out both;
}

.auth-card--wide {
    max-width: 480px;
}

.auth-card--xl {
    max-width: 620px;
}

@keyframes auth-rise {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.auth-card__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    margin-bottom: 20px;
    border-radius: var(--ps-radius-xl);
    background: var(--ps-primary-soft);
    color: var(--ps-primary);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 16%, transparent);
}

.auth-card__badge .auth-icon {
    width: 24px;
    height: 24px;
}

.auth-card__badge--success {
    background: var(--ps-success-soft);
    color: var(--ps-success);
}

.auth-card__badge--danger {
    background: var(--ps-danger-soft);
    color: var(--ps-danger);
}

.auth-card__title {
    margin: 0 0 6px;
    color: var(--ps-ink);
    font-size: 26px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.auth-card h2 {
    font-size: 15px;
    font-weight: 600;
    margin: 20px 0 8px;
}

.auth-card p {
    margin: 0 0 12px;
}

.auth-card .auth-card__lead {
    margin: 0 0 28px;
    color: var(--ps-muted);
    font-size: 15px;
}

/* Sign-in progress (password -> verification) */
.auth-progress {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
    margin: 0 0 28px;
    padding: 0;
    list-style: none;
    color: var(--ps-muted);
    font-size: 12px;
    font-weight: 500;
}

.auth-progress__step {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.auth-progress__step + .auth-progress__step::before {
    content: "";
    width: 28px;
    height: 1px;
    margin-right: 2px;
    background: var(--ps-border-strong);
}

.auth-progress__step.is-done + .auth-progress__step::before {
    background: var(--ps-primary);
}

.auth-progress__dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: 1px solid var(--ps-border-strong);
    border-radius: 50%;
    background: var(--ps-surface);
    font-size: 11px;
    font-weight: 600;
}

.auth-progress__dot .auth-icon {
    width: 12px;
    height: 12px;
    stroke-width: 2.4;
}

.auth-progress__step.is-done .auth-progress__dot {
    border-color: var(--ps-primary);
    background: var(--ps-primary);
    color: #ffffff;
}

.auth-progress__step.is-current {
    color: var(--ps-ink);
}

.auth-progress__step.is-current .auth-progress__dot {
    border-color: var(--ps-primary);
    color: var(--ps-primary);
    box-shadow: 0 0 0 3px var(--ps-primary-soft);
}

/* Fields */
.login-input {
    margin-bottom: 18px;
}

.login-input label,
.auth-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--ps-gray-700);
    margin-bottom: 6px;
}

.login-input input,
.auth-input {
    display: block;
    width: 100%;
    height: 44px;
    padding: 0 14px;
    font: inherit;
    color: var(--ps-ink);
    background: var(--ps-surface);
    border: 1px solid var(--ps-gray-300);
    border-radius: var(--ps-radius-lg);
    box-shadow: var(--ps-shadow-xs);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.login-input input::placeholder {
    color: var(--ps-gray-400);
}

.login-input input:hover:not(:focus) {
    border-color: var(--ps-gray-400);
}

.login-input input:focus {
    outline: none;
    border-color: var(--ps-primary);
    box-shadow: var(--ps-focus-ring);
}

.login-input input.input-validation-error,
.login-input input.invalid {
    border-color: var(--ps-danger);
}

.auth-field {
    position: relative;
}

.auth-field > .auth-icon {
    position: absolute;
    top: 50%;
    left: 14px;
    color: var(--ps-gray-400);
    pointer-events: none;
    transform: translateY(-50%);
    transition: color 0.15s ease;
}

.auth-field:focus-within > .auth-icon {
    color: var(--ps-primary);
}

.auth-field > .auth-icon ~ input {
    padding-left: 42px;
}

.login-input input[autocomplete="one-time-code"] {
    font-family: var(--ps-font-mono);
    font-size: 16px;
    letter-spacing: 0.12em;
    text-align: center;
}

.login-input input[inputmode="numeric"] {
    height: 56px;
    font-size: 24px;
    font-weight: 600;
    letter-spacing: 0.4em;
    /* Letter-spacing trails the last digit; pad the left so the code stays optically centred. */
    padding-left: calc(14px + 0.4em);
}

.login-input input[inputmode="numeric"]::placeholder {
    font-weight: 400;
    color: var(--ps-gray-300);
}

.login-input .text-danger,
.login-input .validation-message,
.field-validation-error {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--ps-danger-text);
}

.field-validation-valid {
    display: none;
}

.login-password-field {
    position: relative;
}

.login-password-field input {
    padding-right: 46px;
}

.login-password-toggle {
    position: absolute;
    top: 50%;
    right: 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: var(--ps-radius-md);
    background: transparent;
    color: var(--ps-gray-500);
    cursor: pointer;
    transform: translateY(-50%);
    transition: background-color 0.15s ease, color 0.15s ease;
}

.login-password-toggle:hover {
    background: var(--ps-gray-100);
    color: var(--ps-ink);
}

.login-password-toggle:focus-visible {
    outline: none;
    box-shadow: var(--ps-focus-ring);
}

.login-password-toggle svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.login-password-toggle__hide {
    display: none;
}

.login-password-toggle.is-visible .login-password-toggle__show {
    display: none;
}

.login-password-toggle.is-visible .login-password-toggle__hide {
    display: block;
}

.login-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 24px;
    font-size: 13px;
}

.auth-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--ps-gray-700);
    cursor: pointer;
    margin: 0;
}

.auth-check input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--ps-primary);
}

/* Buttons and links */
.login-button,
.auth-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 44px;
    padding: 0 16px;
    font: inherit;
    font-weight: 600;
    color: #ffffff;
    background: var(--ps-primary);
    border: 1px solid var(--ps-primary);
    border-radius: var(--ps-radius-lg);
    box-shadow: var(--ps-shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.14);
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}

.login-button:hover,
.auth-button:hover {
    color: #ffffff;
    background: var(--ps-primary-strong);
    border-color: var(--ps-primary-strong);
    text-decoration: none;
}

.login-button:active,
.auth-button:active {
    transform: translateY(1px);
}

.login-button:focus-visible,
.auth-button:focus-visible {
    outline: none;
    box-shadow: var(--ps-focus-ring);
}

.login-button:disabled,
.auth-button:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.login-button.is-loading,
.auth-button.is-loading {
    color: transparent;
    pointer-events: none;
}

.login-button.is-loading::after,
.auth-button.is-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: auth-spin 0.7s linear infinite;
}

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

.auth-button--secondary {
    color: var(--ps-gray-700);
    background: var(--ps-surface);
    border-color: var(--ps-gray-300);
    box-shadow: var(--ps-shadow-xs);
}

.auth-button--secondary:hover {
    color: var(--ps-ink);
    background: var(--ps-gray-50);
    border-color: var(--ps-gray-400);
}

.auth-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    margin-top: 20px;
    font-size: 13px;
}

.auth-links form {
    margin: 0;
}

.auth-links--center {
    justify-content: center;
}

/* :where keeps this at plain ".auth-card a" specificity so banner links can still override it. */
.auth-card a:where(:not(.login-button):not(.auth-button)),
.link-button {
    color: var(--ps-primary-strong);
    font-weight: 500;
    text-decoration: none;
}

.auth-card a:where(:not(.login-button):not(.auth-button)):hover,
.link-button:hover {
    color: var(--ps-primary);
    text-decoration: underline;
}

.auth-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.auth-back .auth-icon {
    width: 16px;
    height: 16px;
}

.link-button {
    border: 0;
    background: transparent;
    padding: 0;
    font: inherit;
    font-weight: 500;
    cursor: pointer;
}

.auth-note {
    margin: 16px 0 0;
    font-size: 12px;
    color: var(--ps-muted);
    text-align: center;
}

.auth-assurance {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--ps-border);
    color: var(--ps-muted);
    font-size: 12px;
}

.auth-assurance .auth-icon {
    width: 16px;
    height: 16px;
    margin-top: 1px;
    color: var(--ps-primary);
}

.auth-hint {
    margin: 0 0 16px;
    font-size: 13px;
    color: var(--ps-muted);
}

/* Banners and panels */
.login-error-banner,
.auth-banner {
    padding: 10px 12px;
    margin-bottom: 18px;
    border: 1px solid transparent;
    border-left-width: 3px;
    border-radius: var(--ps-radius-lg);
    font-size: 13px;
}

.login-error-banner,
.auth-banner--danger {
    background: var(--ps-danger-soft);
    border-color: #fecaca;
    border-left-color: var(--ps-danger);
    color: var(--ps-danger-text);
}

.auth-banner--success {
    background: var(--ps-success-soft);
    border-color: #bbf7d0;
    border-left-color: var(--ps-success);
    color: var(--ps-success-text);
}

.auth-banner--info {
    background: var(--ps-info-soft);
    border-color: #bae6fd;
    border-left-color: var(--ps-info);
    color: var(--ps-info-text);
    word-break: break-all;
}

.auth-banner--warning {
    background: var(--ps-warning-soft);
    border-color: #fde68a;
    border-left-color: var(--ps-warning);
    color: var(--ps-warning-text);
}

.login-error-banner ul,
.auth-banner ul {
    margin: 4px 0 0;
    padding-left: 18px;
}

.login-error-banner.validation-summary-valid,
.auth-banner:empty {
    display: none;
}

.auth-card .login-error-banner a,
.auth-card .auth-banner a {
    color: inherit;
    text-decoration: underline;
}

.auth-panel {
    padding: 12px 14px;
    margin-bottom: 18px;
    background: var(--ps-gray-50);
    border: 1px solid var(--ps-border);
    border-radius: var(--ps-radius-lg);
    font-size: 13px;
    color: var(--ps-ink);
}

.auth-panel strong {
    display: block;
    margin-bottom: 2px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--ps-muted);
}

.auth-panel code {
    display: block;
    font-family: var(--ps-font-mono);
    font-size: 13px;
    color: var(--ps-ink);
    word-break: break-all;
}

/* Authenticator setup */
.auth-steps {
    margin: 0 0 18px;
    padding-left: 18px;
    font-size: 13px;
    color: var(--ps-gray-700);
}

.auth-steps li {
    margin-bottom: 6px;
}

.auth-steps li::marker {
    color: var(--ps-primary);
    font-weight: 600;
}

.auth-qr {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 16px;
    align-items: center;
    padding: 14px;
    margin-bottom: 18px;
    background: var(--ps-gray-50);
    border: 1px solid var(--ps-border);
    border-radius: var(--ps-radius-lg);
}

.auth-qr__frame {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    padding: 8px;
    background: #ffffff;
    border: 1px solid var(--ps-border);
    border-radius: var(--ps-radius-md);
    box-shadow: var(--ps-shadow-xs);
}

.auth-qr__frame svg {
    width: 100%;
    max-width: 160px;
    height: auto;
}

.auth-qr__copy {
    font-size: 13px;
    color: var(--ps-gray-700);
}

.auth-qr__copy strong {
    display: block;
    margin-bottom: 4px;
    color: var(--ps-ink);
    font-weight: 600;
}

.auth-qr__copy p {
    margin: 0 0 8px;
}

.auth-qr__copy ul {
    margin: 0;
    padding-left: 18px;
}

.auth-qr__copy li {
    margin-bottom: 4px;
}

.auth-details {
    margin-bottom: 18px;
    padding: 10px 14px;
    border: 1px solid var(--ps-border);
    border-radius: var(--ps-radius-lg);
    background: var(--ps-surface);
    font-size: 13px;
}

.auth-details summary {
    cursor: pointer;
    font-weight: 500;
    color: var(--ps-gray-700);
}

.auth-details code {
    display: block;
    margin-top: 10px;
    font-family: var(--ps-font-mono);
    font-size: 12px;
    word-break: break-all;
    color: var(--ps-ink);
}

/* Recovery codes */
.auth-codes {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 0 0 24px;
}

.auth-codes__item {
    padding: 10px 12px;
    background: var(--ps-gray-50);
    border: 1px solid var(--ps-border);
    border-radius: var(--ps-radius-md);
    font-family: var(--ps-font-mono);
    font-size: 14px;
    letter-spacing: 0.04em;
    text-align: center;
    color: var(--ps-ink);
}

/* Error page */
.auth-status {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    margin-bottom: 12px;
    border-radius: 999px;
    background: var(--ps-danger-soft);
    color: var(--ps-danger-text);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* Footer */
.auth-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 16px;
    margin-top: 24px;
    font-size: 12px;
    color: var(--ps-muted);
}

.auth-footer a {
    color: var(--ps-muted);
    text-decoration: none;
}

.auth-footer a:hover {
    color: var(--ps-ink);
    text-decoration: underline;
}

@media (max-height: 720px) {
    .auth-aside__lead {
        display: none;
    }

    .auth-aside__title {
        margin-bottom: 28px;
    }
}

@media (max-width: 1100px) {
    .auth-aside__inner {
        padding: 32px 32px 28px;
    }
}

/* Stacked: the brand panel becomes a header band and the form a card that overlaps it */
@media (max-width: 900px) {
    .auth-layout {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto 1fr;
        background: var(--ps-bg);
    }

    .auth-aside__inner {
        position: relative;
        min-height: 0;
        padding: 24px 20px 64px;
    }

    .auth-aside__body,
    .auth-aside__foot {
        display: none;
    }

    .auth-aside__flow {
        height: 100%;
    }

    .auth-main {
        padding: 0 16px 28px;
        background: var(--ps-bg);
    }

    .auth-card {
        margin: -40px 0 0;
        padding: 28px 24px;
        background: var(--ps-surface);
        border: 1px solid var(--ps-border);
        border-radius: var(--ps-radius-xl);
        box-shadow: var(--ps-shadow-md);
    }
}

@media (max-width: 480px) {
    .auth-card {
        padding: 24px 20px;
    }

    .auth-card__title {
        font-size: 22px;
    }

    .auth-codes,
    .auth-qr {
        grid-template-columns: 1fr;
    }

    .login-actions {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .login-input input[inputmode="numeric"] {
        font-size: 20px;
        letter-spacing: 0.3em;
        padding-left: calc(14px + 0.3em);
    }
}

@media (prefers-reduced-motion: reduce) {
    .auth-layout * {
        transition-duration: 0.001ms !important;
    }

    .auth-card {
        animation: none;
    }

    .auth-aside__pulses {
        display: none;
    }
}
