/* Inter (variable) — relative path so the CSS keeps working if the /static route prefix changes */
@font-face {
    font-family: "Inter";
    src: url("../font/Inter.ttf") format("truetype");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: "JetBrains Mono";
    src: url("../font/JetBrainsMono.woff2") format("woff2");
    font-weight: 100 800;
    font-style: normal;
    font-display: swap;
}

/* Same names and values as src/styles.css of web-platform-frontend (Tailwind palette + brand), so the auth pages look like the web app */
:root {
    --font-sans: "Inter", ui-sans-serif, system-ui, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, monospace;
    --brand-500: #53ad31;
    --brand-600: #47932a;
    --brand-700: #357018;
    --primary: var(--brand-500);
    --primary-hover: var(--brand-600);
    --primary-foreground: #fff;
    --ring: var(--brand-500);
    --color-white: #fff;
    --color-neutral-50: #fafafa;
    --color-neutral-100: #f5f5f5;
    --color-neutral-200: #e5e5e5;
    --color-neutral-300: #d4d4d4;
    --color-neutral-400: #a3a3a3;
    --color-neutral-500: #737373;
    --color-neutral-600: #525252;
    --color-neutral-700: #404040;
    --color-neutral-900: #171717;
    --color-neutral-950: #0a0a0a;
    --color-red-50: #fef2f2;
    --color-red-200: #fecaca;
    --color-red-600: #dc2626;
    --color-red-700: #b91c1c;
    --color-orange-700: #c2410c;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --tracking-tight: -0.025em;
}

* {
    box-sizing: border-box;
}

/* Author display rules (.auth-button: inline-flex) would beat the UA [hidden] rule, so the passkey buttons hidden until passkey.js finds support would show */
[hidden] {
    display: none !important;
}

body {
    margin: 0;
    color: var(--color-neutral-900);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 20px;
    background: var(--color-white);
    -webkit-font-smoothing: antialiased;
}

p {
    margin: 0;
}

/* Type scale, named after the Figma text styles like the frontend's typo-* utilities */
.typo-text-lg-semibold {
    font-size: 18px;
    line-height: 28px;
    letter-spacing: var(--tracking-tight);
    font-weight: 600;
}

.typo-text-sm-regular {
    font-size: 14px;
    line-height: 20px;
    font-weight: 400;
}

.typo-text-sm-medium {
    font-size: 14px;
    line-height: 20px;
    font-weight: 500;
}

.typo-text-xs-regular {
    font-size: 12px;
    line-height: 16px;
    font-weight: 400;
}

.typo-text-xs-medium {
    font-size: 12px;
    line-height: 16px;
    font-weight: 500;
}

/* Page shell: one 344px column on white, like the onboarding of the web app */
.auth-shell {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    padding: 200px 24px 64px;
}

@media (max-height: 800px), (max-width: 480px) {
    .auth-shell {
        padding-top: 96px;
    }
}

.auth-column {
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: 344px;
    max-width: 100%;
    animation: auth-rise 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
    view-transition-name: auth-column;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Buttons of the same kind (passkey, providers) sit closer together */
.auth-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* A form inside a stack only wraps its button */
.auth-stack > form {
    display: contents;
}

.auth-header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-inline: 24px;
    text-align: center;
}

.auth-title {
    margin: 0;
    color: var(--color-neutral-900);
}

.auth-subtitle {
    color: var(--color-neutral-600);
    overflow-wrap: anywhere;
}

.auth-status-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    margin-inline: auto;
    color: var(--color-neutral-700);
}

.auth-status-icon svg {
    width: 32px;
    height: 32px;
}

.auth-status-icon-error {
    color: var(--color-red-700);
}

/* Form field: label row (label + optional note on the right), control, hint, error */
.auth-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.auth-field-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.auth-label {
    color: var(--color-neutral-700);
}

/* Two fields side by side (first and last name) */
.auth-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.auth-hint {
    color: var(--color-neutral-600);
}

.auth-error {
    color: var(--color-red-700);
}

/* An error that belongs to the whole form sits close under the field above it */
.auth-form > .auth-error {
    margin-top: -16px;
}

.auth-input {
    display: block;
    width: 100%;
    min-width: 0;
    height: 36px;
    padding: 0 12px;
    border: 1px solid var(--color-neutral-300);
    border-radius: var(--radius-lg);
    background: var(--color-white);
    color: var(--color-neutral-950);
    font: inherit;
    outline: none;
    transition: box-shadow 0.15s;
}

.auth-input::placeholder {
    color: var(--color-neutral-400);
}

.auth-input:focus-visible {
    border-color: var(--ring);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 50%, transparent);
}

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

.auth-input[aria-invalid="true"]:focus-visible {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-red-700) 20%, transparent);
}

/* Read-only fields (the account email): visibly not editable, but still selectable and readable by screen readers */
.auth-input[readonly] {
    border-color: var(--color-neutral-200);
    background: var(--color-neutral-50);
    color: var(--color-neutral-600);
}

.auth-input[readonly]:focus-visible {
    border-color: var(--color-neutral-300);
    box-shadow: none;
}

/* Password input with the show / hide button inside */
.auth-password {
    position: relative;
}

.auth-password .auth-input {
    padding-right: 40px;
}

.auth-password-toggle {
    position: absolute;
    top: 2px;
    right: 2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: var(--radius-md);
    background: none;
    color: var(--color-neutral-700);
    cursor: pointer;
}

.auth-password-toggle:hover {
    color: var(--color-neutral-950);
}

.auth-password-toggle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 50%, transparent);
}

.auth-password-toggle svg {
    width: 16px;
    height: 16px;
}

.auth-strength {
    color: var(--color-neutral-600);
}

.auth-strength[data-level="short"] {
    color: var(--color-red-700);
}

.auth-strength[data-level="weak"] {
    color: var(--color-orange-700);
}

.auth-strength[data-level="strong"] {
    color: var(--brand-700);
}

/* Consent checkbox: box and text on one line, the box looks like the frontend's uiCheckbox */
.auth-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    color: var(--color-neutral-600);
}

.auth-checkbox-input {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin: 2px 0 0;
    border: 1px solid var(--color-neutral-300);
    border-radius: 4px;
    background: var(--color-white) center / 100% no-repeat;
    appearance: none;
    cursor: pointer;
    outline: none;
}

.auth-checkbox-input:checked {
    border-color: var(--color-neutral-900);
    background-color: var(--color-neutral-900);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M3.5 8.25L6.5 11.25L12.5 5.25' stroke='white' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.auth-checkbox-input:focus-visible {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 50%, transparent);
}

.auth-checkbox-input[aria-invalid="true"] {
    border-color: var(--color-red-700);
}

/* Code input: the plain input until code-input.js swaps in one box per digit */
.auth-code-fallback {
    font-family: var(--font-mono);
    letter-spacing: 0.2em;
}

.auth-code-boxes {
    display: grid;
    grid-template-columns: repeat(var(--code-length, 6), minmax(0, 1fr));
    gap: 12px;
}

.auth-code-box {
    width: 100%;
    min-width: 0;
    height: 48px;
    padding: 0;
    border: 1px solid var(--color-neutral-300);
    border-radius: var(--radius-lg);
    background: var(--color-white);
    color: var(--color-neutral-950);
    font: inherit;
    font-size: 20px;
    line-height: 28px;
    font-weight: 500;
    text-align: center;
    outline: none;
    caret-color: transparent;
}

.auth-code-box:focus-visible {
    border-color: var(--color-neutral-900);
    box-shadow: 0 0 0 1px var(--color-neutral-900);
}

.auth-code-boxes[aria-invalid="true"] .auth-code-box {
    border-color: var(--color-red-700);
}

/* spinner under the boxes while an auto-submitted code is posted */
.auth-code-loading {
    display: flex;
    justify-content: center;
}

.auth-code-loading .auth-spinner {
    border-color: var(--color-neutral-200);
    border-top-color: var(--color-neutral-700);
}

/* TOTP enrollment (mfa-setup): QR tile and manual key on a light panel */
.auth-qr-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 24px;
    border-radius: var(--radius-xl);
    background: var(--color-neutral-50);
    text-align: center;
}

.auth-qr {
    display: block;
    width: 144px;
    height: 144px;
    padding: 10px;
    border: 1px solid var(--color-neutral-200);
    border-radius: var(--radius-lg);
    background: var(--color-white);
}

.auth-qr-key {
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: var(--color-neutral-600);
}

.auth-qr-key strong {
    color: var(--color-neutral-950);
    font-family: var(--font-mono);
    font-weight: 500;
    word-spacing: 0.25em;
}

/* Buttons, named like the frontend's uiButton variants; also used on <a> elements, hence the link resets */
.auth-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 36px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    background: var(--primary);
    color: var(--primary-foreground);
    font: inherit;
    font-weight: 500;
    white-space: nowrap;
    text-decoration: none;
    cursor: pointer;
    outline: none;
    transition: box-shadow 0.15s;
}

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

.auth-button:focus-visible {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 50%, transparent);
}

.auth-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.auth-button-secondary {
    border-color: var(--color-neutral-300);
    background: var(--color-white);
    color: var(--color-neutral-700);
}

.auth-button-secondary:hover {
    background: var(--color-neutral-100);
}

.auth-provider-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* "OR" separator between the password form and the other sign-in methods */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--color-neutral-600);
    text-transform: uppercase;
}

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

/* Lines under the form (links, resend, privacy notice) */
.auth-foot {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-inline: 24px;
    color: var(--color-neutral-600);
    text-align: center;
}

/* Text link (typo-text-sm-link of the frontend); also on buttons that must post (resend) */
.auth-link {
    padding: 0;
    border: none;
    border-radius: 2px;
    background: none;
    color: var(--color-neutral-950);
    font: inherit;
    font-weight: 500;
    text-decoration-line: underline;
    text-decoration-color: var(--color-neutral-300);
    text-underline-offset: 4px;
    cursor: pointer;
    outline: none;
}

.auth-link:hover {
    text-decoration-color: var(--color-neutral-950);
}

.auth-link:focus-visible {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 50%, transparent);
}

.auth-link:disabled {
    color: var(--color-neutral-500);
    text-decoration: none;
    cursor: default;
}

/* a form that reads as a single line of text (e.g. "Didn't get a code? Send it again") */
.auth-inline-form {
    display: inline;
}

/* in-button loading indicator shown while a form post is in flight */
.auth-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid color-mix(in srgb, var(--primary-foreground) 35%, transparent);
    border-top-color: var(--primary-foreground);
    border-radius: 50%;
    animation: auth-spin 0.7s linear infinite;
}

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

.auth-button-secondary .auth-spinner {
    border-color: color-mix(in srgb, var(--color-neutral-700) 25%, transparent);
    border-top-color: var(--color-neutral-700);
}

/* pill showing who is signed in */
.auth-identity {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    width: fit-content;
    margin-inline: auto;
    padding: 6px 14px;
    border: 1px solid var(--color-neutral-200);
    border-radius: 999px;
    background: var(--color-neutral-50);
    color: var(--color-neutral-900);
    font-size: 13px;
}

.auth-identity svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: var(--color-neutral-500);
}

/* min-width: 0 lets the nested spans ellipsis instead of stretching the pill past the column */
.auth-identity-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.35;
}

.auth-identity span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.auth-identity-email {
    color: var(--color-neutral-500);
    font-size: 12px;
}

/* subtle entrance on fresh loads */
@keyframes auth-rise {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .auth-column {
        animation: none;
    }
}

/* Cross-document view transitions: navigations between the auth pages morph into each other instead of hard-reloading */
@view-transition {
    navigation: auto;
}

@media (prefers-reduced-motion: reduce) {
    @view-transition {
        navigation: none;
    }
}

/* the entrance animation is for fresh loads — during a page-to-page transition the morph already does the work */
html:active-view-transition .auth-column {
    animation: none;
}

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

/* passkey list on /account/passkeys: each row switches between view, rename and delete confirmation with its own hidden radio group */
.passkey-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--color-neutral-200);
    border-radius: var(--radius-lg);
}

.passkey-row {
    padding: 10px 8px 10px 14px;
}

.passkey-row + .passkey-row {
    border-top: 1px solid var(--color-neutral-200);
}

.passkey-mode {
    display: none;
}

.passkey-view,
.passkey-edit,
.passkey-confirm {
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 36px;
}

.passkey-edit,
.passkey-confirm,
.passkey-row:has(.passkey-mode-edit:checked) .passkey-view,
.passkey-row:has(.passkey-mode-delete:checked) .passkey-view {
    display: none;
}

.passkey-row:has(.passkey-mode-edit:checked) .passkey-edit,
.passkey-row:has(.passkey-mode-delete:checked) .passkey-confirm {
    display: flex;
}

.passkey-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.passkey-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.passkey-meta {
    color: var(--color-neutral-500);
    font-size: 12px;
    line-height: 16px;
}

.passkey-edit .auth-input {
    flex: 1;
}

.passkey-icon {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: var(--radius-lg);
    background: none;
    color: var(--color-neutral-500);
    cursor: pointer;
}

.passkey-icon svg {
    width: 16px;
    height: 16px;
}

.passkey-icon:hover {
    background: var(--color-neutral-100);
    color: var(--color-neutral-700);
}

.passkey-icon-danger:hover {
    background: var(--color-red-50);
    color: var(--color-red-700);
}

.passkey-icon:focus-visible,
.passkey-small-button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 50%, transparent);
}

.passkey-confirm {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    padding: 4px 6px 2px 0;
}

.passkey-confirm-text {
    flex-basis: 100%;
    overflow-wrap: anywhere;
}

.passkey-small-button {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--color-neutral-300);
    border-radius: var(--radius-lg);
    background: var(--color-white);
    color: var(--color-neutral-700);
    font: inherit;
    font-weight: 500;
    cursor: pointer;
}

.passkey-small-button:hover {
    background: var(--color-neutral-100);
}

.passkey-small-button-danger {
    border-color: var(--color-red-200);
    color: var(--color-red-600);
}

.passkey-small-button-danger:hover {
    background: var(--color-red-50);
}
