/*
 * Ondato IdP pages (sign-in, two-factor, sign-out, errors).
 *
 * Values come from the "OS 2.0 Screens" Figma file, section "2FA Auth". The states and pages the design doesn't show
 * (hover, focus, mobile, SSO-only sign-in, message pages) are built from the same tokens.
 */

/* ---------- Fonts (self-hosted, SIL OFL: see the OFL.txt next to each) ---------- */

@font-face {
    font-family: "DM Sans";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("../fonts/dm-sans/dm-sans-latin-ext.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: "DM Sans";
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url("../fonts/dm-sans/dm-sans-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
    font-family: "DM Mono";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/dm-mono/dm-mono-500-latin-ext.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: "DM Mono";
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url("../fonts/dm-mono/dm-mono-500-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------- Tokens ---------- */

:root {
    --font-sans: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: "DM Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    /* From Figma */
    --color-text: #0b0b0b;
    --color-text-secondary: #535353;
    --color-text-helper: #717171;
    --color-text-placeholder: #adadad;
    --color-text-error: #ff4838;
    --color-error: #fd2222;
    --color-border: #e8e8e8;
    --color-surface: #ffffff;
    --color-surface-muted: #fafafa;
    --color-brand: #0053ff;
    --color-link: #0042cf;
    --color-primary: #202020;
    --color-primary-text: #ffffff;
    --color-secondary: #d2e1ff;
    --color-secondary-text: #0053ff;
    --color-disabled: #e8e8e8;
    --color-disabled-border: #cbcbcb;
    --color-disabled-text: #8b8b8b;
    --color-warning: #fff7bb;
    --color-warning-text: #623700;
    --color-codes: #f6f8ff;
    --color-codes-text: #001a64;

    /* Inferred: interaction states the design doesn't show */
    --color-primary-hover: #3a3a3a;
    --color-primary-active: #0b0b0b;
    --color-secondary-hover: #c0d5ff;
    --color-secondary-active: #aac7ff;
    --color-link-hover: #00309a;
    --color-border-hover: #cbcbcb;
    --color-focus: var(--color-brand);
    --focus-halo: 0 0 0 3px rgba(0, 83, 255, 0.16);
    --color-error-halo: rgba(253, 34, 34, 0.12);

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-card: 28px;
    --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 36px 28px -7px rgba(0, 0, 0, 0.05), 0 17px 17px -7px rgba(0, 0, 0, 0.04);
}

/* ---------- Page ---------- */

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

/* Scripts hide elements with the hidden attribute; a display rule below must not show them again. */
[hidden] {
    display: none !important;
}

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

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    padding: 32px 16px;
    background: var(--color-surface);
    color: var(--color-text);
    font: 400 15px/20px var(--font-sans);
    /* Figma sets the optical size to 14 for every text style; without this, headings use a sharper cut. */
    font-variation-settings: "opsz" 14;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/*
 * The OS 2.0 animated dot wave (os_2_bg.svg from OndatoOS.Frontend), covering the screen as the OS sign-in page does.
 * The SVG animates itself and shows a still frame when the user asks for reduced motion, so no CSS or script drives it.
 * The colour is the SVG's own backdrop, shown until it loads.
 */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: #eae9e9 url("../images/background-dot-wave.svg") no-repeat center / cover;
}

/* ---------- Card ---------- */

.card {
    width: 100%;
    max-width: 440px;
    /* auto margins centre the card, and keep its top reachable when it is taller than the screen */
    margin: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    background: var(--color-surface);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
}

.card--narrow {
    max-width: 400px;
}

/* Sign-in and the authenticator set-up space everything 20px apart; the other 2FA cards keep 32px before the actions. */
.card--compact {
    gap: 20px;
}

.card__content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.card__header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    text-align: center;
}

.logo {
    display: block;
    width: 58px;
    height: auto;
    margin-bottom: 14px;
}

/* ---------- Text ---------- */

.title {
    margin: 0;
    font-size: 24px;
    line-height: 32px;
    font-weight: 700;
}

.title--lg {
    font-size: 32px;
    line-height: 38px;
}

.lead {
    margin: 0;
    color: var(--color-text-secondary);
    text-wrap: pretty;
}

.text-strong {
    font-weight: 700;
    color: var(--color-text);
}

.help {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin: 0;
    text-align: center;
    color: var(--color-text-secondary);
    font-size: 13px;
    line-height: 16px;
    font-weight: 500;
}

/* ---------- Form fields ---------- */

.fields {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* A field with its label, then the checkbox under it (two-factor sign-in). */
.fields--loose {
    gap: 12px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.field__label {
    font-weight: 700;
}

.input {
    width: 100%;
    height: 40px;
    margin: 0;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text);
    font: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

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

.input:hover {
    border-color: var(--color-border-hover);
}

.input:focus {
    outline: none;
    border-color: var(--color-focus);
    box-shadow: var(--focus-halo);
}

/* ASP.NET Core adds input-validation-error to inputs whose model value failed validation. */
.input.input-validation-error,
.input[aria-invalid="true"] {
    border-color: var(--color-error);
}

.input.input-validation-error:focus,
.input[aria-invalid="true"]:focus {
    box-shadow: 0 0 0 3px var(--color-error-halo);
}

.field-error,
.field-validation-error {
    color: var(--color-text-error);
    font-size: 13px;
    line-height: 16px;
}

/* The empty messages ASP.NET Core renders while a field or the form is valid. */
.field-validation-valid,
.validation-summary-valid {
    display: none;
}

.validation-summary-errors ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

/* Checkbox: 20px brand-blue box with the white tick, as in the design. */
.checkbox {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    align-self: flex-start;
    font-size: 13px;
    line-height: 16px;
    font-weight: 500;
    cursor: pointer;
}

.checkbox input {
    appearance: none;
    flex: none;
    display: grid;
    place-content: center;
    width: 20px;
    height: 20px;
    margin: 0;
    border: 1.5px solid var(--color-disabled-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}

.checkbox input::before {
    content: "";
    width: 16px;
    height: 16px;
    background-color: var(--color-primary-text);
    -webkit-mask: url("../images/icons/check.svg") no-repeat center / contain;
    mask: url("../images/icons/check.svg") no-repeat center / contain;
    transform: scale(0);
    transition: transform 0.1s;
}

.checkbox input:hover {
    border-color: var(--color-text-helper);
}

.checkbox input:checked {
    background: var(--color-brand);
    border-color: var(--color-brand);
}

.checkbox input:checked::before {
    transform: scale(1);
}

.checkbox input:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

/* ---------- Buttons and links ---------- */

.actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* The help text under the actions sits 20px below them. */
.actions + .help,
.actions .help {
    margin-top: 12px;
}

/*
 * Two buttons side by side, primary on the right. Put the primary button first in the markup: Enter in a field
 * submits the form with its first submit button.
 */
.button-row {
    display: flex;
    flex-direction: row-reverse;
    gap: 8px;
}

.button-row > .btn {
    flex: 1 1 0;
    min-width: 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 8px 20px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    font: 500 15px/16px var(--font-mono);
    text-transform: uppercase;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.btn:has(> .icon:first-child) {
    padding-left: 16px;
}

.btn:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

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

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

.btn--primary:active {
    background: var(--color-primary-active);
}

.btn--secondary {
    background: var(--color-secondary);
    color: var(--color-secondary-text);
}

.btn--secondary:hover {
    background: var(--color-secondary-hover);
}

.btn--secondary:active {
    background: var(--color-secondary-active);
}

.btn:disabled,
.btn[aria-disabled="true"] {
    background: var(--color-disabled);
    border-color: var(--color-disabled-border);
    color: var(--color-disabled-text);
    cursor: not-allowed;
}

/* Sign in with an external provider: the provider's own logo, in colour. */
.btn__logo {
    flex: none;
    width: 18px;
    height: 18px;
}

.link {
    color: var(--color-link);
    font: 500 13px/16px var(--font-mono);
    text-decoration: underline;
    text-underline-position: from-font;
    border-radius: 4px;
}

.link:hover {
    color: var(--color-link-hover);
}

.link:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
}

.link--with-logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* External provider links under the local sign-in buttons. */
.providers {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
}

/* "or" between the local sign-in and the external providers. */
.divider {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--color-text-helper);
    font-size: 13px;
    line-height: 16px;
    font-weight: 500;
}

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

/* ---------- Icons: single-colour SVGs used as masks, so they take the text colour ---------- */

.icon {
    flex: none;
    display: inline-block;
    width: 20px;
    height: 20px;
    background-color: currentColor;
    -webkit-mask: no-repeat center / contain;
    mask: no-repeat center / contain;
}

.icon--sm {
    width: 16px;
    height: 16px;
}

.icon--arrow-right {
    -webkit-mask-image: url("../images/icons/arrow-right.svg");
    mask-image: url("../images/icons/arrow-right.svg");
}

.icon--check {
    -webkit-mask-image: url("../images/icons/check.svg");
    mask-image: url("../images/icons/check.svg");
}

.icon--close {
    -webkit-mask-image: url("../images/icons/close.svg");
    mask-image: url("../images/icons/close.svg");
}

.icon--copy {
    -webkit-mask-image: url("../images/icons/copy.svg");
    mask-image: url("../images/icons/copy.svg");
}

.icon--info {
    -webkit-mask-image: url("../images/icons/info-circle.svg");
    mask-image: url("../images/icons/info-circle.svg");
}

.icon-button {
    flex: none;
    display: inline-grid;
    place-content: center;
    width: 32px;
    height: 32px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: inherit;
    cursor: pointer;
    transition: background-color 0.15s;
}

.icon-button:hover {
    background: rgba(0, 0, 0, 0.06);
}

.icon-button:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 0;
}

/* ---------- Alerts ---------- */

.alert {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-weight: 700;
}

.alert__text {
    flex: 1;
    margin: 0;
}

.alert .icon-button {
    width: 24px;
    height: 24px;
    margin: -4px;
    color: var(--color-text);
}

.alert--warning {
    background: var(--color-warning);
    color: var(--color-warning-text);
}

/* Inferred: a neutral notice for status messages, on the grey of the QR panel. */
.alert--neutral {
    background: var(--color-surface-muted);
    color: var(--color-text);
    font-weight: 500;
}

/* ---------- Authenticator set-up ---------- */

.step {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.step__title {
    display: flex;
    gap: 6px;
    margin: 0;
    font-weight: 700;
}

/* Step whose field lines up with its title text, not with the number (step 3). */
.step--indented {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 6px;
    row-gap: 6px;
}

.step--indented > .step__number {
    font-weight: 700;
}

.step--indented > .step__body {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.app-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
    color: var(--color-text-secondary);
}

.app-list li {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 4px 16px;
    padding-left: 22px;
}

.app-list li::before {
    content: "";
    position: absolute;
    left: 9px;
    top: 9px;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: currentColor;
}

.app-list__links {
    display: flex;
    gap: 16px;
}

.panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-md);
    background: var(--color-surface-muted);
}

.qr {
    width: 178px;
    height: 178px;
}

/* qrcode.js draws a canvas and an img; show the img at the panel's size. */
.qr canvas {
    display: none !important;
}

.qr img {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

.secret {
    margin: 0;
    color: var(--color-text-helper);
    font-size: 13px;
    line-height: 16px;
    font-weight: 500;
    text-align: center;
    overflow-wrap: anywhere;
}

/* ---------- Recovery codes ---------- */

.codes {
    display: grid;
    grid-template-columns: repeat(2, max-content);
    justify-content: center;
    gap: 12px 32px;
    margin: 0;
    padding: 12px;
    list-style: none;
    border-radius: var(--radius-md);
    background: var(--color-codes);
    color: var(--color-codes-text);
    font-variant-numeric: tabular-nums;
}

/* ---------- Message pages: a reference to give support ---------- */

.reference {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.reference__label {
    color: var(--color-text-helper);
    font-size: 13px;
    line-height: 16px;
    font-weight: 500;
}

.reference__box {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 4px 4px 12px;
    border-radius: var(--radius-md);
    background: var(--color-surface-muted);
}

.reference__value {
    flex: 1;
    min-width: 0;
    font: 500 13px/16px var(--font-mono);
    overflow-wrap: anywhere;
}

.reference__box .icon-button {
    color: var(--color-brand);
}

/* Front-channel sign-out: loads the other applications' sign-out pages without showing them. */
iframe.signout {
    position: absolute;
    width: 0;
    height: 0;
    border: 0;
    visibility: hidden;
}

/* Text only screen readers announce, e.g. "Copied". */
.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;
}

/* ---------- Small screens ---------- */

@media (max-width: 479px) {
    body {
        padding: 16px;
    }

    .card {
        padding: 20px 16px;
        border-radius: 20px;
    }

    .title--lg {
        font-size: 28px;
        line-height: 34px;
    }

    /* iOS zooms into fields with text under 16px when they get focus. */
    .input {
        font-size: 16px;
    }

    /* Primary on top, then the secondary action. */
    .button-row {
        flex-direction: column;
    }

    .button-row > .btn {
        flex: none;
    }
}

/* ---------- Accessibility preferences ---------- */

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

@media (forced-colors: active) {
    /* Mask icons are drawn with background-color, which forced colours would remove. */
    .icon,
    .checkbox input::before {
        forced-color-adjust: none;
        background-color: ButtonText;
    }

    .btn--primary .icon {
        background-color: ButtonText;
    }
}
