﻿/*
    Login pages (Views/Shared/_LayoutAnon.cshtml and Views/Login/*).

    The theme of the host comes from css/themes/<theme>/<theme>-login.min.css, compiled from
    themes/login-base.scss: it sets the --login-* properties (brand surface, accent and the
    accent made readable per colour scheme) and the logo. This file reads only those.

    Colour scheme: the app's own dark mode setting (localStorage 'fuusor-dark-mode', set as
    data-theme on <html> by the layout) wins; without it the system preference applies.
*/

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

:root {
    color-scheme: light;
    --l-page: #eef0f3;
    --l-surface: #ffffff;
    --l-text: #15191e;
    --l-muted: #5b6370;
    --l-border: #dde1e7;
    --l-input-bg: #ffffff;
    --l-input-border: #c5cbd4;
    --l-input-border-hover: #9aa2ae;
    --l-hover: #f1f3f6;
    --l-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 16px 40px rgba(16, 24, 40, 0.14);
    --l-sheet-shadow: 0 -10px 40px rgba(16, 24, 40, 0.16);
    --l-accent-fill: var(--login-accent, #4fd3ff);
    --l-on-accent: var(--login-on-accent, #111111);
    --l-accent-text: var(--login-accent-text, #2f7e99);
    --l-ring: rgba(47, 126, 153, 0.25);
    --l-danger-text: #b42318;
    --l-danger-bg: #fef3f2;
    --l-danger-border: #fecdca;
    --l-success-text: #067647;
    --l-success-bg: #ecfdf3;
    --l-success-border: #abefc6;
    --l-info-text: #175cd3;
    --l-info-bg: #eff8ff;
    --l-info-border: #b2ddff;
    --l-radius: 10px;
}

/* color-mix() only where supported, in @supports blocks: a declaration holding var() is not validated when parsed, so a
   second declaration in the same rule would always win over the plain fallback before it, and then fail. */
@supports (color: color-mix(in srgb, red, red)) {
    :root {
        --l-ring: color-mix(in srgb, var(--l-accent-text) 25%, transparent);
    }
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;
        --l-page: #141414;
        --l-surface: #1e1e1e;
        --l-text: #ececec;
        --l-muted: #a3a3a3;
        --l-border: #333333;
        --l-input-bg: #262626;
        --l-input-border: #4a4a4a;
        --l-input-border-hover: #6a6a6a;
        --l-hover: #2a2a2a;
        --l-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px rgba(0, 0, 0, 0.5);
        --l-sheet-shadow: 0 -10px 40px rgba(0, 0, 0, 0.45);
        --l-accent-fill: var(--login-accent-dark, #4fd3ff);
        --l-on-accent: var(--login-on-accent-dark, #111111);
        --l-accent-text: var(--login-accent-text-dark, #4fd3ff);
        --l-danger-text: #fda29b;
        --l-danger-bg: #3a1714;
        --l-danger-border: #7a271a;
        --l-success-text: #75e0a7;
        --l-success-bg: #0f2a1d;
        --l-success-border: #085d3a;
        --l-info-text: #84caff;
        --l-info-bg: #102a43;
        --l-info-border: #1849a9;
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --l-page: #141414;
    --l-surface: #1e1e1e;
    --l-text: #ececec;
    --l-muted: #a3a3a3;
    --l-border: #333333;
    --l-input-bg: #262626;
    --l-input-border: #4a4a4a;
    --l-input-border-hover: #6a6a6a;
    --l-hover: #2a2a2a;
    --l-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 16px 40px rgba(0, 0, 0, 0.5);
    --l-sheet-shadow: 0 -10px 40px rgba(0, 0, 0, 0.45);
    --l-accent-fill: var(--login-accent-dark, #4fd3ff);
    --l-on-accent: var(--login-on-accent-dark, #111111);
    --l-accent-text: var(--login-accent-text-dark, #4fd3ff);
    --l-danger-text: #fda29b;
    --l-danger-bg: #3a1714;
    --l-danger-border: #7a271a;
    --l-success-text: #75e0a7;
    --l-success-bg: #0f2a1d;
    --l-success-border: #085d3a;
    --l-info-text: #84caff;
    --l-info-bg: #102a43;
    --l-info-border: #1849a9;
}

/* ---------- Base ---------- */

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

[hidden] {
    display: none !important;
}

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

body.login {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--l-page);
    color: var(--l-text);
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

.login-icon {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
}

/* ---------- Shell: brand panel + sheet ---------- */

.login-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

/* The brand panel carries the theme's top bar background, which the logos are drawn for. */
.login-brand {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    height: clamp(140px, 22vh, 196px);
    padding: 16px 24px 40px;
    padding-top: max(16px, env(safe-area-inset-top));
    background: var(--login-brand, linear-gradient(#4d4d4d, #1a1a1a));
}

/* Accent glow over the brand surface (hidden by a theme with a background image). */
.login-brand::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(70% 90% at 0% 100%, rgba(79, 211, 255, 0.28), transparent 70%),
        radial-gradient(55% 70% at 100% 0%, rgba(79, 211, 255, 0.16), transparent 70%);
}

@supports (color: color-mix(in srgb, red, red)) {
    .login-brand::before {
        background:
            radial-gradient(70% 90% at 0% 100%, color-mix(in srgb, var(--login-accent, #4fd3ff) 30%, transparent), transparent 70%),
            radial-gradient(55% 70% at 100% 0%, color-mix(in srgb, var(--login-accent, #4fd3ff) 18%, transparent), transparent 70%);
    }
}

/* Faint dot grid, fading out towards the edges. */
.login-brand::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image: radial-gradient(rgba(128, 128, 128, 0.22) 1px, transparent 1.6px);
    background-size: 22px 22px;
    -webkit-mask-image: radial-gradient(ellipse at 50% 50%, #000 15%, transparent 72%);
    mask-image: radial-gradient(ellipse at 50% 50%, #000 15%, transparent 72%);
}

.login-brand__image {
    display: none;
    position: absolute;
    inset: 0;
    z-index: -1;
    background-size: cover;
    background-position: center;
}

.login-brand__plate {
    display: flex;
    max-width: 100%;
}

.login-brand__logo {
    width: min(240px, 64vw);
    height: 56px;
    max-width: 100%;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
}

/* The sheet holds the forms; on a phone it slides up over the brand panel. */
.login-sheet {
    position: relative;
    z-index: 1;
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    margin-top: -24px;
    padding: 10px 20px 16px;
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    background: var(--l-surface);
    border-radius: 24px 24px 0 0;
    box-shadow: var(--l-sheet-shadow);
}

.login-sheet__top {
    display: flex;
    justify-content: flex-end;
    min-height: 40px;
}

.login-sheet__content {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    padding: 4px 0 28px;
}

.login-sheet__footer {
    display: flex;
    justify-content: center;
    min-height: 24px;
}

@media (min-width: 960px) {
    .login-shell {
        flex-direction: row;
    }

    .login-brand {
        flex: 1 1 auto;
        height: auto;
        min-height: 100vh;
        /* The sheet overlaps the panel's right edge by its corner radius. */
        padding: 48px 76px 48px 48px;
    }

    .login-brand__logo {
        width: clamp(220px, 24vw, 360px);
        height: 120px;
    }

    .login-sheet {
        flex: 0 0 auto;
        width: clamp(460px, 38vw, 580px);
        min-height: 100vh;
        margin: 0 0 0 -28px;
        padding: 24px 48px;
        border-radius: 28px 0 0 28px;
        box-shadow: -14px 0 44px rgba(0, 0, 0, 0.14);
    }

    .login-sheet__content {
        justify-content: center;
        max-width: 380px;
        padding: 24px 0 40px;
    }
}

/* Tablet in portrait: the form in the middle of the sheet. */
@media (min-width: 600px) and (max-width: 959px) and (min-height: 700px) {
    .login-sheet__content {
        justify-content: center;
    }
}

/* Phone in landscape: keep the form above the keyboard. */
@media (max-width: 959px) and (max-height: 520px) {
    .login-brand {
        height: 104px;
        padding-bottom: 36px;
    }

    .login-brand__logo {
        height: 44px;
    }
}

/* ---------- Language menu ---------- */

.login-lang {
    position: relative;
}

.login-lang > summary {
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 36px;
    padding: 0 10px 0 8px;
    border-radius: 999px;
    color: var(--l-muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.login-lang > summary::-webkit-details-marker {
    display: none;
}

.login-lang > summary:hover,
.login-lang[open] > summary {
    background: var(--l-hover);
    color: var(--l-text);
}

.login-lang > summary:focus-visible {
    outline: 2px solid var(--l-accent-text);
    outline-offset: 2px;
}

.login-lang .login-icon {
    width: 18px;
    height: 18px;
}

.login-lang__chevron {
    width: 16px;
    height: 16px;
    transition: transform 0.15s ease;
}

.login-lang[open] .login-lang__chevron {
    transform: rotate(180deg);
}

.login-lang__menu {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 10;
    min-width: 200px;
    padding: 6px;
    background: var(--l-surface);
    border: 1px solid var(--l-border);
    border-radius: 12px;
    box-shadow: var(--l-shadow);
}

.login-lang__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 40px;
    padding: 8px 12px;
    border-radius: 8px;
    color: var(--l-text);
    font-size: 14px;
    text-decoration: none;
}

.login-lang__item:hover,
.login-lang__item:focus-visible {
    background: var(--l-hover);
    color: var(--l-text);
    text-decoration: none;
    outline: none;
}

.login-lang__item[aria-current="true"] {
    font-weight: 600;
}

.login-lang__item .login-icon {
    color: var(--l-accent-text);
}

/* ---------- Panels and text ---------- */

.login-panel {
    display: flex;
    flex-direction: column;
}

.login-title {
    margin: 0 0 24px;
    font-size: 26px;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.login-title + .login-subtitle {
    margin-top: -16px;
}

.login-subtitle {
    margin: 0 0 24px;
    color: var(--l-muted);
}

@media (min-width: 960px) {
    .login-title {
        font-size: 30px;
    }
}

.login-status-icon {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin-bottom: 18px;
    border-radius: 50%;
    color: var(--l-success-text);
    background: var(--l-success-bg);
    border: 1px solid var(--l-success-border);
}

.login-status-icon .login-icon {
    width: 26px;
    height: 26px;
}

/* ---------- Form controls ---------- */

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.login-label {
    font-size: 14px;
    font-weight: 500;
}

.login-input {
    width: 100%;
    height: 48px;
    margin: 0;
    padding: 0 14px;
    font: inherit;
    font-size: 16px; /* 16px keeps iOS from zooming in on focus */
    color: var(--l-text);
    background-color: var(--l-input-bg);
    border: 1px solid var(--l-input-border);
    border-radius: var(--l-radius);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    -webkit-appearance: none;
    appearance: none;
}

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

.login-input:focus {
    outline: none;
    border-color: var(--l-accent-text);
    box-shadow: 0 0 0 4px var(--l-ring);
}

.login-input:-webkit-autofill,
.login-input:-webkit-autofill:hover {
    -webkit-text-fill-color: var(--l-text);
    -webkit-box-shadow: 0 0 0 100px var(--l-input-bg) inset;
    caret-color: var(--l-text);
}

.login-input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 100px var(--l-input-bg) inset, 0 0 0 4px var(--l-ring);
}

.login-input::-ms-reveal {
    display: none;
}

.login-input.input-validation-error {
    border-color: var(--l-danger-text);
}

select.login-input {
    padding-right: 42px;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a919c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 18px 18px;
}

.login-password {
    position: relative;
}

.login-password .login-input {
    padding-right: 52px;
}

.login-password__toggle {
    position: absolute;
    top: 50%;
    right: 4px;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    color: var(--l-muted);
    background: transparent;
    border: 0;
    border-radius: 8px;
    transform: translateY(-50%);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.login-password__toggle:hover {
    color: var(--l-text);
    background: var(--l-hover);
}

.login-password__toggle:focus-visible {
    outline: 2px solid var(--l-accent-text);
    outline-offset: -2px;
}

.login-password__toggle .login-icon--hide,
.login-password__toggle[aria-pressed="true"] .login-icon--show {
    display: none;
}

.login-password__toggle[aria-pressed="true"] .login-icon--hide {
    display: block;
}

.login-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 4px 12px;
    margin-top: -4px;
}

.login-check {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 36px;
    font-size: 14px;
    cursor: pointer;
}

.login-check input {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--l-accent-fill);
    cursor: pointer;
}

.login-link {
    padding: 6px 0;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--l-accent-text);
    background: none;
    border: 0;
    border-radius: 4px;
    text-decoration: none;
    cursor: pointer;
}

.login-link:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

.login-link:focus-visible {
    outline: 2px solid var(--l-accent-text);
    outline-offset: 2px;
}

.login-field-error,
.field-validation-error {
    color: var(--l-danger-text);
    font-size: 13px;
}

.field-validation-valid,
.validation-summary-valid {
    display: none;
}

/* ---------- Buttons ---------- */

.login-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 48px;
    margin: 0;
    padding: 0 18px;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: var(--l-radius);
    cursor: pointer;
    transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
    -webkit-tap-highlight-color: transparent;
}

.login-button:hover {
    text-decoration: none;
}

.login-button:active {
    transform: translateY(1px);
}

.login-button:focus-visible {
    outline: 3px solid var(--l-accent-text);
    outline-offset: 2px;
}

.login-button[disabled] {
    cursor: default;
}

.login-button--primary {
    color: var(--l-on-accent);
    background-color: var(--l-accent-fill);
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.1);
}

.login-button--primary:hover {
    color: var(--l-on-accent);
    box-shadow: inset 0 0 0 100vmax rgba(0, 0, 0, 0.06), 0 1px 2px rgba(16, 24, 40, 0.1);
}

@supports (color: color-mix(in srgb, red, red)) {
    .login-button--primary:hover {
        box-shadow: inset 0 0 0 100vmax color-mix(in srgb, var(--l-on-accent) 12%, transparent), 0 1px 2px rgba(16, 24, 40, 0.1);
    }
}

.login-button--secondary {
    color: var(--l-text);
    background-color: var(--l-surface);
    border-color: var(--l-input-border);
}

.login-button--secondary:hover {
    color: var(--l-text);
    background-color: var(--l-hover);
}

.login-button + .login-button,
.login-actions {
    margin-top: 2px;
}

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

/* Busy state of a submit button: a spinner before the label. */
.login-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: login-spin 0.7s linear infinite;
}

.login-button.is-busy .login-spinner {
    display: inline-block;
}

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

.login-divider {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 24px 0 16px;
    color: var(--l-muted);
    font-size: 13px;
}

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

.login-providers {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.login-providers .login-button {
    font-weight: 500;
}

/* ---------- Alerts (also the markup of Html.Alert) ---------- */

.login-alerts:empty {
    display: none;
}

.login-alert,
.alert,
.validation-summary-errors {
    margin: 0 0 18px;
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.45;
    border: 1px solid;
    border-radius: var(--l-radius);
}

/* An icon beside the text. Html.Alert puts its text straight into .alert, so .alert stays a block: as a flex
   container it would split a sentence with a link into side-by-side items. */
.login-alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.alert {
    position: relative;
    padding-right: 40px;
}

.login-alert .login-icon {
    width: 18px;
    height: 18px;
    margin-top: 1px;
}

.login-alert--danger,
.alert-danger,
.validation-summary-errors {
    color: var(--l-danger-text);
    background: var(--l-danger-bg);
    border-color: var(--l-danger-border);
}

.alert-success {
    color: var(--l-success-text);
    background: var(--l-success-bg);
    border-color: var(--l-success-border);
}

.alert-info {
    color: var(--l-info-text);
    background: var(--l-info-bg);
    border-color: var(--l-info-border);
}

.alert a,
.login-alert a {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.alert .close {
    position: absolute;
    top: 10px;
    right: 10px;
    margin: 0;
    padding: 0 4px;
    font: inherit;
    font-size: 20px;
    line-height: 1;
    color: inherit;
    background: none;
    border: 0;
    opacity: 0.7;
    cursor: pointer;
}

.alert .close:hover {
    opacity: 1;
}

.validation-summary-errors ul {
    margin: 0;
    padding-left: 18px;
}

/* ---------- Footer ---------- */

.login-powered-by {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--l-muted);
    font-size: 12px;
}

.login-powered-by__logo {
    height: 15px;
    width: auto;
}

.login-powered-by__logo--dark {
    display: none;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .login-powered-by__logo--light {
        display: none;
    }

    :root:not([data-theme="light"]) .login-powered-by__logo--dark {
        display: inline;
    }
}

:root[data-theme="dark"] .login-powered-by__logo--light {
    display: none;
}

:root[data-theme="dark"] .login-powered-by__logo--dark {
    display: inline;
}

/* ---------- Motion ---------- */

@media (prefers-reduced-motion: no-preference) {
    .login-panel {
        animation: login-rise 0.4s cubic-bezier(0.2, 0.7, 0.2, 1) both;
    }
}

@keyframes login-rise {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}
