/*
 * Prism MCP — login / account-picker / consent styling.
 *
 * The look is reproduced from the Prism Portal auth screens (prism-portal:
 * src/app/(auth)/layout.tsx, src/components/auth/login-form/login-form.tsx and
 * src/theme/{auth-theme.tsx,colors.ts,shadows.ts}) so a user redirected here out of an AI
 * client lands on a page that plainly belongs to Prism.
 *
 * EVERYTHING IS SAME-ORIGIN. This is a login page on a security-sensitive service, so it makes
 * no third-party request at all: no Google Fonts, no CDN, no remote image. The font, the
 * background and the logo are files in this repo under /assets, served by this application.
 * Do not replace any of them with a remote URL.
 *
 * Font: Plus Jakarta Sans (the portal's font), self-hosted. One variable woff2, latin subset,
 * 27 KB, taken from Google Fonts v12 and redistributable under the SIL Open Font License 1.1.
 * The stack falls back to the platform UI font if the file is unavailable.
 */

@font-face {
    font-family: 'Plus Jakarta Sans';
    font-style: normal;
    /* Variable font: one file covers the whole 200–800 weight axis. */
    font-weight: 200 800;
    font-display: swap;
    src: url('/assets/fonts/plus-jakarta-sans-latin.woff2') format('woff2');
}

:root {
    /* Portal brand tokens — auth-theme.tsx / colors.ts / shadows.ts. */
    --prism-gradient: linear-gradient(360deg, #642dff 0%, #9f64ff 142.5%);
    --prism-fg: #1b1b1b;            /* neutral-9, the portal's --foreground-primary */
    --prism-fg-muted: #454545;      /* neutral-7 */
    --prism-fg-soft: #5d5d5d;       /* neutral-6 */
    --prism-label: #484a4a;         /* portal auth input label */
    --prism-input-border: #cbcbcb;  /* portal auth input border */
    --prism-hairline: #e3e3e3;      /* neutral-1 */
    --prism-focus: #853aff;         /* primary-7, Mantine --input-bd-focus */
    --prism-surface: #ffffff;
    --prism-radius-sm: 8px;         /* theme radius md */
    --prism-radius-lg: 16px;        /* theme radius lg */
    --prism-radius-card: 24px;      /* the card's rounded-3xl */
    --prism-shadow-section: 0 6px 20px 0 rgba(19, 19, 19, 0.06);
    --prism-error-bg: #fff5f5;      /* red-0 */
    --prism-error-border: #ffccc5;  /* red-3 */
    --prism-error-fg: #671515;      /* red-9 */
    --prism-danger: #c92a2a;        /* red-8, the destructive accent on the consent screen */
    --prism-info-bg: #f6f2ff;       /* primary tint, for the informational disclosure */
    --prism-info-border: #ded0ff;
    --prism-info-fg: #3a2a63;
    --prism-muted-surface: #fafafa;
}

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

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

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    color: var(--prism-fg);
    -webkit-font-smoothing: antialiased;
    /* The solid colour is sampled from the artwork, so the page never flashes white or dark. */
    background-color: #eef3fd;
    background-image: url('/assets/bg-global-auth.png');
    background-repeat: no-repeat;
    background-size: cover;
    /* Portal: object-[70%_100%] on small screens, centred from sm up. */
    background-position: 70% 100%;
}

@media (min-width: 40em) {
    body {
        background-position: center;
    }
}

/* --------------------------------------------------------------------------------------- */

.auth-shell {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 40px 16px;
}

@media (min-width: 48em) {
    .auth-shell {
        padding: 56px 48px;
    }
}

@media (min-width: 64em) {
    .auth-shell {
        padding: 56px 64px;
    }
}

.auth-panel {
    width: 100%;
    max-width: 500px;
}

.auth-header {
    margin-bottom: 32px;
}

@media (min-width: 64em) {
    .auth-header {
        margin-bottom: 40px;
    }
}

.auth-logo {
    display: block;
    height: 40px;
    width: auto;
    margin-bottom: 28px;
}

.auth-title {
    margin: 0 0 12px;
    font-size: 28px;
    line-height: 1.1;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.auth-subtitle {
    margin: 0;
    font-size: 16px;
    line-height: 1.45;
    font-weight: 400;
    color: var(--prism-fg-muted);
}

/*
 * The consent heading is a whole sentence carrying an untrusted client name, not a two-word
 * page title, so it steps down a size rather than running to five lines on a phone.
 */
.auth-title--compact {
    font-size: 22px;
    line-height: 1.25;
}

@media (min-width: 64em) {
    .auth-title {
        font-size: 36px;
    }

    .auth-title--compact {
        font-size: 26px;
    }

    .auth-subtitle {
        font-size: 20px;
    }

    .auth-subtitle--compact {
        font-size: 16px;
    }
}

.auth-card {
    background: var(--prism-surface);
    border-radius: var(--prism-radius-card);
    padding: 32px;
    box-shadow: var(--prism-shadow-section);
}

@media (max-width: 26em) {
    .auth-card {
        padding: 24px 20px;
        border-radius: var(--prism-radius-lg);
    }
}

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

.auth-form {
    display: grid;
    gap: 24px;
}

.auth-field label {
    display: block;
    font-size: 14px;
    line-height: 14px;
    font-weight: 400;
    color: var(--prism-label);
    padding-bottom: 12px;
}

.auth-field input {
    width: 100%;
    height: 48px;
    padding: 0 12px;
    border: 2px solid var(--prism-input-border);
    border-radius: var(--prism-radius-sm);
    background: var(--prism-surface);
    color: var(--prism-fg);
    font-family: inherit;
    font-size: 16px;
}

.auth-field input:focus {
    border-color: var(--prism-focus);
}

/* A ring rather than a bare border-colour swap, so focus is not signalled by colour alone. */
.auth-field input:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(133, 58, 255, 0.22);
}

.auth-button {
    height: 48px;
    margin-top: 8px;
    border: 0;
    border-radius: var(--prism-radius-sm);
    background-image: var(--prism-gradient);
    color: #ffffff;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.auth-button:hover {
    filter: brightness(1.07);
}

.auth-button:active {
    filter: brightness(0.94);
}

.auth-button:focus-visible {
    outline: 3px solid rgba(100, 45, 255, 0.45);
    outline-offset: 2px;
}

/* --- error ------------------------------------------------------------------------------ */

.auth-error {
    margin-bottom: 24px;
    padding: 12px 14px;
    border: 1px solid var(--prism-error-border);
    border-radius: var(--prism-radius-sm);
    background: var(--prism-error-bg);
    color: var(--prism-error-fg);
    font-size: 14px;
    line-height: 1.45;
}

/* --- account picker --------------------------------------------------------------------- */

.account-list {
    display: grid;
    gap: 12px;
}

.account-list form {
    margin: 0;
}

.account {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 64px;
    padding: 12px 16px;
    border: 1px solid var(--prism-hairline);
    border-radius: 12px;
    background: var(--prism-surface);
    color: var(--prism-fg);
    font-family: inherit;
    font-size: 16px;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.account:hover {
    border-color: var(--prism-focus);
    box-shadow: var(--prism-shadow-section);
}

.account:focus-visible {
    outline: 3px solid rgba(100, 45, 255, 0.45);
    outline-offset: 2px;
}

.account img {
    flex: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.account .name {
    font-weight: 600;
}

.account .role {
    margin-left: auto;
    padding: 4px 10px;
    border-radius: 999px;
    background: #f2f2f2;
    color: var(--prism-fg-soft);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
}

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

/* --- consent ---------------------------------------------------------------------------- */

.consent-heading {
    margin: 0 0 10px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--prism-fg-soft);
}

/* Plain-prose access summary (owner decision 2026-08-14): the scopes are no longer enumerated
   as a per-scope list — the approve form now holds only display:none hidden inputs. */
.consent-summary {
    margin: 0;
    font-size: 15px;
    line-height: 1.45;
    color: var(--prism-fg);
}

/*
 * The two notices. They must stay prominent AND tell each other apart at a glance: the
 * disclosure is information about where the data goes, the decline warning is a consequence the
 * user is one click away from causing. Different hue, different icon, different weight — and
 * neither is allowed to shrink into fine print, because they are why this page exists.
 */
.notice {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    padding: 16px;
    border: 1px solid;
    border-left-width: 4px;
    border-radius: var(--prism-radius-lg);
    font-size: 14px;
    line-height: 1.55;
}

.notice-icon {
    flex: none;
    width: 20px;
    height: 20px;
    margin-top: 1px;
}

/*
 * The lead-in stays INLINE. Both notices are written as one sentence beginning "Data
 * disclosure: by connecting…" / "If you decline: declining ends…", so promoting the lead-in to
 * its own line leaves the sentence starting mid-thought on a lowercase word. Prominence here
 * comes from the icon, the accent edge and the fill — not from breaking the copy up.
 */
.notice strong {
    font-weight: 700;
}

.notice--info {
    border-color: var(--prism-info-border);
    border-left-color: var(--prism-focus);
    background: var(--prism-info-bg);
    color: var(--prism-info-fg);
}

.notice--danger {
    border-color: var(--prism-error-border);
    border-left-color: var(--prism-danger);
    background: var(--prism-error-bg);
    color: var(--prism-error-fg);
}

.notice--danger strong {
    color: var(--prism-danger);
}

/*
 * Two independent forms styled into one button row — see the SECURITY note in consent.html.
 * The Connect button sits OUTSIDE the approve form and reaches it with form="approve-form",
 * because HTML forms cannot nest and merging them would break the deny path.
 */
.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
    align-items: stretch;
}

.actions > .approve,
.actions > .decline-form {
    flex: 1 1 190px;
}

.decline-form {
    margin: 0;
}

.actions button {
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border-radius: var(--prism-radius-sm);
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    cursor: pointer;
}

.approve {
    border: 0;
    background-image: var(--prism-gradient);
    color: #ffffff;
}

.approve:hover {
    filter: brightness(1.07);
}

.approve:active {
    filter: brightness(0.94);
}

.approve:focus-visible {
    outline: 3px solid rgba(100, 45, 255, 0.45);
    outline-offset: 2px;
}

/*
 * Declining is destructive (it disconnects every AI client), so it is a real, full-weight
 * button in the danger colour — never a faint link the user cannot find or takes for a
 * throwaway. It is deliberately not the primary gradient: it is a choice, not the default.
 */
.cancel {
    border: 2px solid var(--prism-error-border);
    background: var(--prism-surface);
    color: var(--prism-danger);
}

.cancel:hover {
    border-color: var(--prism-danger);
    background: var(--prism-error-bg);
}

.cancel:focus-visible {
    outline: 3px solid rgba(201, 42, 42, 0.45);
    outline-offset: 2px;
}

@media (max-width: 30em) {
    .actions {
        flex-direction: column;
    }

    /*
     * Once the row becomes a column, flex-basis is a HEIGHT — the row's 190px basis would
     * stretch Connect into a slab most of a phone screen tall. Both buttons go back to
     * sizing from their own content.
     */
    .actions > .approve,
    .actions > .decline-form {
        flex: 0 0 auto;
    }
}
