/*
 * Sign-in page and portal picker, new UI (2026-10). See docs/DESIGN-SYSTEM.md.
 *
 * Loaded only by templates/auth/login-v2.php (UI_SHELL_V2 + kl_ui_preview
 * cookie) and templates/auth/portal-v2.php (Ui::shellV2()). Builds on the
 * --ds-* tokens in kl-ds.css. Colors come from the company's branding
 * variables (--brand-*), emitted inline before this file; KL defaults apply
 * only when a company has no branding.
 */

:root {
    /* The splash of color: the company's accent when branded, OEG blue otherwise
       (OEG's own accent is the same navy as its chrome). */
    --chrome-highlight: var(--brand-accent);
    --chrome-highlight-font: var(--brand-accent-font, #ffffff);
    --surface-bg: #f5f7fb;
    --surface-fg: #182030;
    --surface-card: #ffffff;
    --surface-panel: #f1f4f8;
    --surface-muted: #5d6779;
    --surface-border: #dde3eb;
    --surface-hover: #eef2f7;
}
html:not([data-brand-custom]) {
    --chrome-highlight: #3567e8;
    --chrome-highlight-font: #ffffff;
}
html[data-theme="dark"] {
    --surface-bg: #0f1115;
    --surface-fg: #f4f4f5;
    --surface-card: #1a1d24;
    --surface-panel: #151821;
    --surface-muted: #9aa0a8;
    --surface-border: #2a2e38;
    --surface-hover: #232730;
}
@media (prefers-color-scheme: dark) {
    html[data-theme="system"] {
        --surface-bg: #0f1115;
        --surface-fg: #f4f4f5;
        --surface-card: #1a1d24;
        --surface-panel: #151821;
        --surface-muted: #9aa0a8;
        --surface-border: #2a2e38;
        --surface-hover: #232730;
    }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
.kla-body {
    min-height: 100vh;
    background: var(--ds-bg);
    color: var(--ds-text);
    font: var(--ds-text-md)/1.5 var(--ds-font);
    -webkit-font-smoothing: antialiased;
}
.kla-body button, .kla-body input { font-family: var(--ds-font); }

/* ════════════════ Sign-in ════════════════ */
.kla-signin {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(400px, 1fr);
    min-height: 100vh;
}

/* Left hero */
.kla-hero {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    background: var(--ds-header);
    color: #ffffff;
}
.kla-hero__media { position: absolute; inset: 0; z-index: -2; }
.kla-hero__media img,
.kla-hero__media video { width: 100%; height: 100%; object-fit: cover; display: block; }
/* Darker overlay so the copy reads over any image or video. */
.kla-hero::after {
    content: '';
    position: absolute;
    inset: 0;
    z-index: -1;
    background:
        linear-gradient(180deg, rgba(5, 10, 20, .55) 0%, rgba(5, 10, 20, .78) 60%, rgba(5, 10, 20, .9) 100%),
        linear-gradient(90deg, rgba(5, 10, 20, .35), rgba(5, 10, 20, .6));
    pointer-events: none;
}
.kla-hero__inner {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: clamp(24px, 4vw, 48px);
}
.kla-hero__logo { display: block; width: min(240px, 60%); max-height: 68px; object-fit: contain; object-position: left center; }
.kla-hero__copy { max-width: 520px; margin-top: clamp(64px, 16vh, 160px); }
.kla-hero__title {
    margin: 0;
    font: var(--ds-weight-bold) clamp(32px, 3.4vw, 50px)/1.05 var(--ds-font-display);
    letter-spacing: -0.01em;
    color: #ffffff;
}
.kla-hero__text { margin: var(--ds-space-4) 0 0; font-size: 16px; line-height: 1.6; color: rgba(226, 232, 240, .88); }
.kla-signals {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--ds-space-3);
    max-width: 680px;
    margin-top: auto;
    padding-top: var(--ds-space-10);
}
.kla-signal {
    min-width: 0;
    padding: var(--ds-space-3) var(--ds-space-4) var(--ds-space-4);
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: var(--ds-radius-md);
    background: rgba(255, 255, 255, .06);
    backdrop-filter: blur(10px);
}
.kla-signal span {
    display: block;
    color: color-mix(in srgb, var(--ds-accent) 45%, #ffffff);
    font-size: 11px;
    font-weight: var(--ds-weight-bold);
    letter-spacing: .12em;
    text-transform: uppercase;
}
.kla-signal strong { display: block; margin-top: 6px; font-size: 14px; line-height: 1.25; color: #ffffff; }
.kla-signal em { display: block; margin-top: 6px; font-style: normal; font-size: 12px; line-height: 1.4; color: rgba(226, 232, 240, .74); }
.kla-hero__foot { margin-top: var(--ds-space-6); font-size: var(--ds-text-xs); color: rgba(226, 232, 240, .55); }

/* Right panel and card */
.kla-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(24px, 5vw, 64px) var(--ds-space-4);
    background: var(--ds-bg);
}
.kla-card {
    width: 100%;
    max-width: 400px;
    padding: clamp(24px, 3vw, 36px);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-surface);
    box-shadow: var(--ds-shadow-md);
}
.kla-card__title { margin: 0; font: var(--ds-weight-bold) 24px/1.2 var(--ds-font-display); color: var(--ds-text); }
.kla-card__sub { margin: var(--ds-space-2) 0 var(--ds-space-6); color: var(--ds-text-muted); }

.kla-error { margin-bottom: var(--ds-space-4); color: var(--ds-danger); }
.kla-error svg { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 1px; }
.kla-error span { color: var(--ds-danger); }

.kla-field { display: block; margin-bottom: var(--ds-space-4); }
.kla-field .ds-label { display: block; margin-bottom: 6px; font-size: var(--ds-text-sm); font-weight: var(--ds-weight-semi); color: var(--ds-text); }
.kla-field__row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--ds-space-3); margin-bottom: 6px; }
.kla-field__row .ds-label { margin: 0; }
.kla-body .ds-input { min-height: 44px; font-size: 15px; }
.kla-body .ds-input::placeholder { color: color-mix(in srgb, var(--ds-text-muted) 70%, transparent); }
.kla-submit { width: 100%; margin-top: var(--ds-space-2); font-size: 15px; }

.kla-link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--ds-accent);
    font: var(--ds-weight-semi) var(--ds-text-sm) var(--ds-font);
    text-decoration: none;
    cursor: pointer;
}
.kla-link:hover { text-decoration: underline; }
.kla-link:focus-visible { outline: none; box-shadow: var(--ds-focus); border-radius: 4px; }
.kla-resend { display: inline-flex; margin-top: var(--ds-space-4); }

.kla-account {
    display: flex;
    align-items: center;
    gap: var(--ds-space-3);
    margin-bottom: var(--ds-space-5);
    padding: 10px var(--ds-space-3);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-surface-alt);
}
.kla-account__email { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: var(--ds-weight-semi); }

.kla-step-title { margin: 0 0 4px; font-size: var(--ds-text-lg); font-weight: var(--ds-weight-semi); color: var(--ds-text); }
.kla-hint { margin: 0 0 var(--ds-space-4); color: var(--ds-text-muted); font-size: var(--ds-text-sm); }

/* Login method: large selectable cards */
.kla-methods { display: grid; gap: var(--ds-space-3); }
.kla-method {
    display: flex;
    align-items: center;
    gap: var(--ds-space-4);
    width: 100%;
    padding: var(--ds-space-4);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-md);
    background: var(--ds-surface);
    color: var(--ds-text);
    text-align: left;
    cursor: pointer;
    transition: border-color .12s, background-color .12s, box-shadow .12s;
}
.kla-method:hover { border-color: var(--ds-accent); background: var(--ds-accent-soft); }
.kla-method:focus-visible { outline: none; border-color: var(--ds-accent); box-shadow: var(--ds-focus); }
.kla-method__icon {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: var(--ds-radius-sm);
    background: var(--ds-accent-soft);
    color: var(--ds-accent);
}
.kla-method__icon svg { width: 20px; height: 20px; }
.kla-method__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kla-method__label { font-size: 15px; font-weight: var(--ds-weight-semi); }
.kla-method__desc { font-size: var(--ds-text-sm); color: var(--ds-text-muted); }

/* 6-box code */
.kla-otp { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--ds-space-2); margin: var(--ds-space-2) 0 var(--ds-space-4); }
.kla-otp__digit {
    width: 100%;
    min-width: 0;
    height: 52px;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-surface);
    color: var(--ds-text);
    text-align: center;
    font: var(--ds-weight-bold) 20px var(--ds-font);
    -webkit-appearance: none;
}
.kla-otp__digit:focus { outline: none; border-color: var(--ds-accent); box-shadow: var(--ds-focus); }

@media (max-width: 900px) {
    .kla-signin { grid-template-columns: 1fr; }
    .kla-hero__inner { min-height: 0; padding: var(--ds-space-6) var(--ds-space-4); }
    .kla-hero__copy { margin-top: var(--ds-space-8); }
    .kla-hero__title { font-size: clamp(28px, 7vw, 40px); }
    .kla-signals { padding-top: var(--ds-space-6); }
    .kla-panel { align-items: flex-start; padding: var(--ds-space-6) var(--ds-space-4) var(--ds-space-10); }
}
@media (max-width: 600px) {
    .kla-signals { grid-template-columns: 1fr; }
    .kla-card { padding: var(--ds-space-5); }
    .kla-otp { gap: 6px; }
    .kla-otp__digit { height: 46px; font-size: 18px; }
}

/* ════════════════ Portal picker ════════════════ */
.klp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ds-space-4);
    min-height: 64px;
    padding: var(--ds-space-3) clamp(16px, 3vw, 32px);
    background: var(--ds-header);
    color: var(--brand-on-dark, #ffffff);
}
.klp-header__brand img { display: block; max-width: 200px; max-height: 40px; object-fit: contain; }
.klp-header__fallback { font-weight: var(--ds-weight-bold); }
.klp-header__account { display: flex; align-items: center; gap: var(--ds-space-4); min-width: 0; font-size: var(--ds-text-sm); }
.klp-header__who { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; opacity: .9; }
.klp-header__signout {
    padding: 6px 12px;
    border: 1px solid color-mix(in srgb, currentColor 30%, transparent);
    border-radius: var(--ds-radius-sm);
    background: transparent;
    color: inherit;
    font: var(--ds-weight-semi) var(--ds-text-sm) var(--ds-font);
    cursor: pointer;
    white-space: nowrap;
}
.klp-header__signout:hover { background: color-mix(in srgb, currentColor 12%, transparent); }
.klp-header__signout:focus-visible { outline: none; box-shadow: var(--ds-focus); }

.klp-main { max-width: 1080px; margin: 0 auto; padding: clamp(40px, 9vh, 96px) var(--ds-space-4) var(--ds-space-10); }
.klp-intro { text-align: center; margin-bottom: var(--ds-space-10); }
.klp-title { margin: 0; font: var(--ds-weight-bold) clamp(28px, 3.4vw, 38px)/1.15 var(--ds-font-display); color: var(--ds-text); }
.klp-sub { margin: var(--ds-space-2) 0 0; font-size: 16px; color: var(--ds-text-muted); }

.klp-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--ds-space-5); }
.klp-form { margin: 0; flex: 1 1 280px; max-width: 340px; }
.klp-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--ds-space-2);
    width: 100%;
    height: 100%;
    padding: var(--ds-space-6);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-surface);
    box-shadow: var(--ds-shadow-sm);
    color: var(--ds-text);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: border-color .12s, box-shadow .12s, transform .12s;
}
.klp-card:hover { border-color: var(--ds-accent); box-shadow: var(--ds-shadow-md); transform: translateY(-2px); }
.klp-card:focus-visible { outline: none; border-color: var(--ds-accent); box-shadow: var(--ds-focus); }
.klp-card__icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    margin-bottom: var(--ds-space-2);
    border-radius: var(--ds-radius-md);
    background: var(--ds-accent-soft);
    color: var(--ds-accent);
}
.klp-card__icon svg { width: 24px; height: 24px; }
.klp-card__name { font: var(--ds-weight-semi) var(--ds-text-xl)/1.2 var(--ds-font-display); }
.klp-card__desc { flex: 1; color: var(--ds-text-muted); font-size: var(--ds-text-md); line-height: 1.5; }
.klp-card__cta { margin-top: var(--ds-space-3); color: var(--ds-accent); font-weight: var(--ds-weight-semi); }

@media (max-width: 600px) {
    .klp-header__who { display: none; }
    .klp-form { max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
    .klp-card, .kla-method { transition: none; }
    .klp-card:hover { transform: none; }
}
