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

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    min-height: 100svh;
}

body,
h1,
h2,
p,
ul {
    margin: 0;
}

button,
input {
    font: inherit;
}

img {
    display: block;
    max-width: 100%;
}

[hidden] {
    display: none !important;
}

.auth-page {
    display: grid;
    grid-template-rows: minmax(0, 1fr) auto;
    margin: 0;
    background: var(--color-page);
    color: var(--color-text);
    font-family: var(--font-family-sans);
    font-size: var(--font-size-body);
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-body);
}

.auth-shell {
    align-self: center;
    display: flex;
    width: 100%;
    flex-direction: column;
    align-items: center;
    gap: var(--space-8);
    padding: var(--space-10) var(--space-5) var(--space-8);
}

.site-header {
    display: flex;
    justify-content: center;
}

.site-header__logo {
    width: var(--size-logo);
    height: auto;
}

.auth-main {
    width: min(100%, var(--size-card));
}

.notice {
    display: flex;
    width: min(100%, 44rem);
    flex-direction: column;
    gap: var(--space-4);
}

/* The design left-aligns the logo with the text column. Scoped to pages that
   contain a notice, so every other screen keeps its centred logo. */
.auth-shell:has(.notice) .site-header {
    width: min(100%, 44rem);
    justify-content: flex-start;
}

.notice h1 {
    font-size: var(--font-size-heading);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-tight);
}

.notice p {
    font-size: var(--font-size-small);
}

.notice a {
    color: var(--color-brand-primary);
    text-decoration: none;
}

.notice a:hover {
    color: var(--color-brand-primary-hover);
    text-decoration: underline;
    text-underline-offset: var(--space-1);
}

.notice a:focus-visible {
    border-radius: var(--radius-small);
    box-shadow: 0 0 0 var(--size-focus-ring) var(--color-focus-ring);
    outline: none;
}

.auth-card {
    width: 100%;
    padding: var(--space-8);
    border: var(--border-width) solid var(--color-border);
    border-radius: var(--radius-card);
    background: var(--color-surface);
    box-shadow: var(--shadow-card);
}

.auth-card__header {
    margin-bottom: var(--space-6);
    text-align: center;
}

.auth-card__header h1 {
    font-size: var(--font-size-heading);
    font-weight: var(--font-weight-bold);
    line-height: var(--line-height-tight);
}

.auth-card__header p {
    margin-top: var(--space-3);
    color: var(--color-text-muted);
    font-size: var(--font-size-small);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.form-field {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: var(--space-2);
}

.form-field > label {
    font-size: var(--font-size-small);
    font-weight: var(--font-weight-medium);
}

.form-field input {
    width: 100%;
    min-height: var(--size-control);
    padding: var(--space-3) var(--space-4);
    border: var(--border-width) solid var(--color-control-border);
    border-radius: var(--radius-small);
    background: var(--color-surface);
    color: var(--color-text);
    transition:
        border-color var(--transition-fast),
        box-shadow var(--transition-fast);
}

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

.form-field input:hover {
    border-color: var(--color-text-subtle);
}

.form-field input:focus-visible {
    border-color: var(--color-brand-primary);
    box-shadow: 0 0 0 var(--size-focus-ring) var(--color-focus-ring);
    outline: none;
}

.factor-choice {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: var(--space-3);
    padding: 0;
    border: 0;
}

.factor-choice legend {
    margin-bottom: var(--space-3);
    font-size: var(--font-size-small);
    font-weight: var(--font-weight-medium);
}

.factor-option {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4);
    border: var(--border-width) solid var(--color-control-border);
    border-radius: var(--radius-small);
    cursor: pointer;
}

.factor-option:hover {
    border-color: var(--color-text-subtle);
}

.factor-option:has(input:checked) {
    border-color: var(--color-brand-primary);
}

.factor-option:has(input:focus-visible) {
    box-shadow: 0 0 0 var(--size-focus-ring) var(--color-focus-ring);
}

.factor-option input {
    flex: none;
    width: var(--size-radio);
    height: var(--size-radio);
    margin: 0;
    accent-color: var(--color-brand-primary);
}

.factor-option__text {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.factor-option__label {
    font-weight: var(--font-weight-medium);
}

.factor-option__hint {
    color: var(--color-text-muted);
    font-size: var(--font-size-small);
}

.qr-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
    font-size: var(--font-size-small);
}

.qr-code {
    width: var(--size-qr);
    max-width: 100%;
    height: auto;
}

.auth-card__footer {
    margin-top: var(--space-5);
    font-size: var(--font-size-small);
    text-align: center;
}

.password-requirements {
    padding: var(--space-4);
    border-radius: var(--radius-medium);
    background: var(--color-page);
}

.password-requirements h2 {
    margin-bottom: var(--space-3);
    font-size: var(--font-size-small);
    font-weight: var(--font-weight-bold);
}

.password-checklist {
    display: grid;
    gap: var(--space-2);
    padding: 0;
    list-style: none;
}

.password-checklist li {
    display: grid;
    grid-template-columns: var(--size-marker) minmax(0, 1fr);
    align-items: center;
    gap: var(--space-2);
    color: var(--color-text-muted);
    font-size: var(--font-size-small);
}

.password-checklist__marker {
    position: relative;
    width: var(--size-marker);
    height: var(--size-marker);
    border-radius: 50%;
    background: var(--color-strength-fair);
}

.password-checklist li[data-pass="true"] .password-checklist__marker {
    background: var(--color-strength-strong);
}

.password-checklist li[data-pass="true"] .password-checklist__marker::after {
    position: absolute;
    top: 44%;
    left: 50%;
    width: 48%;
    height: 26%;
    border-bottom: var(--border-width-strong) solid var(--color-on-brand);
    border-left: var(--border-width-strong) solid var(--color-on-brand);
    content: "";
    transform: translate(-50%, -50%) rotate(-45deg);
}

.password-control {
    position: relative;
}

.password-control input {
    padding-right: var(--size-control);
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: var(--space-1);
    display: grid;
    width: calc(var(--size-control) - var(--space-2));
    height: calc(var(--size-control) - var(--space-2));
    padding: 0;
    border: 0;
    border-radius: var(--radius-small);
    background: transparent;
    cursor: pointer;
    place-items: center;
    transform: translateY(-50%);
}

.password-toggle:hover {
    background: var(--color-page);
}

.password-toggle:focus-visible {
    box-shadow: 0 0 0 var(--size-focus-ring) var(--color-focus-ring);
    outline: none;
}

.password-toggle img {
    width: var(--space-5);
    height: var(--space-5);
}

.password-strength {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.strength-meter {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-1);
}

.strength-meter span {
    height: var(--size-meter);
    border-radius: var(--radius-small);
    background: var(--color-meter-track);
    transition: background-color var(--transition-fast);
}

.password-strength[data-strength="weak"] .strength-meter span:first-child {
    background: var(--color-strength-weak);
}

.password-strength[data-strength="fair"] .strength-meter span:nth-child(-n + 2) {
    background: var(--color-strength-fair);
}

.password-strength[data-strength="good"] .strength-meter span:nth-child(-n + 3) {
    background: var(--color-strength-good);
}

.password-strength[data-strength="strong"] .strength-meter span {
    background: var(--color-strength-strong);
}

.strength-label {
    display: flex;
    justify-content: space-between;
    color: var(--color-text-muted);
    font-size: var(--font-size-caption);
}

.strength-label strong {
    font-weight: var(--font-weight-medium);
}

.password-strength[data-strength="weak"] .strength-label strong {
    color: var(--color-strength-weak);
}

.password-strength[data-strength="fair"] .strength-label strong {
    color: var(--color-strength-fair);
}

.password-strength[data-strength="good"] .strength-label strong {
    color: var(--color-strength-good);
}

.password-strength[data-strength="strong"] .strength-label strong {
    color: var(--color-strength-strong);
}

.button {
    min-height: var(--size-control);
    padding: var(--space-3) var(--space-5);
    border: 0;
    border-radius: var(--radius-small);
    cursor: pointer;
    font-weight: var(--font-weight-medium);
    transition:
        background-color var(--transition-fast),
        box-shadow var(--transition-fast);
}

a.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    text-decoration: none;
}

/* A short, muted aside inside an auth card, matching the password-requirements
   panel's surface. */
.auth-note {
    padding: var(--space-4);
    border-radius: var(--radius-medium);
    background: var(--color-page);
    color: var(--color-text-muted);
    font-size: var(--font-size-small);
}

/* Stacked full-width actions: the primary one first, a secondary one beneath. */
.auth-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin-top: var(--space-6);
}

.button--primary {
    background: var(--color-brand-primary);
    color: var(--color-on-brand);
}

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

.button--primary:focus-visible {
    box-shadow: 0 0 0 var(--size-focus-ring) var(--color-focus-ring);
    outline: none;
}

.button--secondary {
    border: var(--border-width) solid var(--color-control-border);
    background: var(--color-surface);
    color: var(--color-text);
}

.button--secondary:hover {
    border-color: var(--color-text-subtle);
}

.button--secondary:focus-visible {
    box-shadow: 0 0 0 var(--size-focus-ring) var(--color-focus-ring);
    outline: none;
}

.auth-form--secondary {
    margin-top: var(--space-4);
}

.form-field__hint {
    color: var(--color-text-muted);
    font-size: var(--font-size-small);
}

/* A .button that is a link (the outage screen's Retry). */
a.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.auth-card__actions {
    text-align: center;
}

.site-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-5);
    color: var(--color-text-subtle);
    font-size: var(--font-size-caption);
    text-align: center;
}

.site-footer__links {
    display: flex;
    gap: var(--space-4);
}

.site-footer a {
    color: var(--color-brand-primary);
    text-underline-offset: var(--space-1);
}

.site-footer a:hover {
    color: var(--color-brand-primary-hover);
}

.site-footer a:focus-visible {
    border-radius: var(--radius-small);
    box-shadow: 0 0 0 var(--size-focus-ring) var(--color-focus-ring);
    outline: none;
}

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

@media (max-width: 36rem) {
    .auth-shell {
        gap: var(--space-6);
        padding: var(--space-8) var(--space-4) var(--space-5);
    }

    .auth-card {
        padding: var(--space-6) var(--space-5);
    }

    .site-footer {
        flex-direction: column;
        gap: var(--space-2);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
