/* ==========================================================
   Custom login + register pages — OJS 3.3, default theme
   Loaded only by the overrides in plugins/themes/default/templates/frontend/pages/
   (userLogin.tpl, userRegister.tpl), so no other page is affected.
   Delete a .tpl to turn that page back to the original.

   Colour: --login-brand is set by the template from each journal's
   theme colour. The card head reuses the site's own sidebar-block look
   (brand band + white title); the Login button is the only other place
   the brand colour appears, so it stays the one clear action.
   ========================================================== */

.page_auth_custom {
    /* Fallbacks for browsers without color-mix(): plain brand + neutral tints */
    --login-brand-strong: var(--login-brand);
    --login-on-brand: #ffffff;
    --login-link: var(--login-brand);
    --login-ring: rgba(0, 0, 0, 0.18);
    --login-tint: #f4f5f8;
    --login-tint-border: #e2e4ea;

    --login-ink: #1d1f27;
    --login-muted: #5d6170;
    --login-line: #d5d8e0;
    --login-surface: #ffffff;

    padding-bottom: 48px;
}

.page_auth_custom.is_brand_light {
    --login-on-brand: rgba(0, 0, 0, 0.84);
}

@supports (color: color-mix(in srgb, red 50%, blue)) {
    /* Dark brand colours: deepen slightly so white text on bright blues
       (e.g. #0080ff) still reaches 4.5:1. */
    .page_auth_custom.is_brand_dark {
        --login-brand-strong: color-mix(in srgb, var(--login-brand) 84%, #000);
        --login-link: color-mix(in srgb, var(--login-brand) 84%, #000);
    }

    /* Light brand colours: keep the band as-is, darken links a lot. */
    .page_auth_custom.is_brand_light {
        --login-link: color-mix(in srgb, var(--login-brand) 40%, #000);
    }

    .page_auth_custom {
        --login-ring: color-mix(in srgb, var(--login-brand) 28%, transparent);
        --login-tint: color-mix(in srgb, var(--login-brand) 7%, #fff);
        --login-tint-border: color-mix(in srgb, var(--login-brand) 22%, #fff);
    }
}

/* The sidebar "User Login" block repeats this form; hide it on this page only */
.pkp_page_login .pkp_structure_sidebar .block_login_form {
    display: none;
}

.page_auth_custom .cmp_breadcrumbs {
    margin-bottom: 20px;
}

/* ---------- Card ---------- */
.page_auth_custom .login_card {
    box-sizing: border-box;
    width: 100%;
    max-width: 380px;
    margin: 8px 0 0; /* left-aligned with the breadcrumb */
    background: var(--login-surface);
    border: 1px solid var(--login-tint-border);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(16, 18, 27, 0.05), 0 12px 28px -12px rgba(16, 18, 27, 0.18);
    overflow: hidden;
}

.page_auth_custom .login_card_head {
    padding: 18px 24px;
    color: var(--login-on-brand);
    background: var(--login-brand-strong);
}

.page_auth_custom .login_card_head h1 {
    margin: 0;
    padding: 0;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.25;
    color: inherit;
    border: 0;
}

.page_auth_custom .login_card_body {
    padding: 24px 24px 22px;
}

/* ---------- Messages ---------- */
.page_auth_custom .login_notice,
.page_auth_custom .pkp_form_error {
    margin: 0 0 20px;
    padding: 11px 14px;
    font-size: 14px;
    line-height: 1.45;
    border-radius: 6px;
}

.page_auth_custom .login_notice {
    color: var(--login-ink);
    background: var(--login-tint);
    border: 1px solid var(--login-tint-border);
}

.page_auth_custom .pkp_form_error {
    color: #8f1d1d;
    background: #fdf1f1;
    border: 1px solid #f3c9c9;
}

/* ---------- Form reset (default theme narrows the form and pads every row) ---------- */
.page_auth_custom .cmp_form.login {
    max-width: none;
    margin: 0;
}

.page_auth_custom .cmp_form.login fieldset {
    margin: 0;
    padding: 0;
    border: 0;
}

.page_auth_custom .cmp_form .fields > div {
    padding-bottom: 0;
}

/* ---------- Fields ---------- */
.page_auth_custom .cmp_form .username {
    margin-bottom: 16px;
}

.page_auth_custom .cmp_form .password {
    margin-bottom: 14px;
}

.page_auth_custom .cmp_form .username label,
.page_auth_custom .cmp_form .password label {
    display: block;
}

.page_auth_custom .cmp_form .username .label,
.page_auth_custom .cmp_form .password .label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 700;
    font-style: normal;
    color: var(--login-ink);
}

.page_auth_custom .cmp_form .required {
    color: #b42318;
}

.page_auth_custom .cmp_form input[type="text"],
.page_auth_custom .cmp_form input[type="password"] {
    box-sizing: border-box;
    width: 100%;
    max-width: none;
    height: 44px;
    padding: 0 12px;
    font-size: 15px;
    color: var(--login-ink);
    background: #ffffff;
    border: 1px solid var(--login-line);
    border-radius: 6px;
    box-shadow: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.page_auth_custom .cmp_form input[type="text"]:hover,
.page_auth_custom .cmp_form input[type="password"]:hover {
    border-color: #b6bac6;
}

.page_auth_custom .cmp_form input[type="text"]:focus,
.page_auth_custom .cmp_form input[type="password"]:focus {
    outline: none;
    border-color: var(--login-brand-strong);
    box-shadow: 0 0 0 3px var(--login-ring);
}

/* ---------- Remember me + forgot password ---------- */
.page_auth_custom .login_row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    margin-bottom: 22px;
}

.page_auth_custom .cmp_form .remember label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    cursor: pointer;
}

.page_auth_custom .cmp_form .remember input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--login-brand-strong);
}

.page_auth_custom .cmp_form .remember .label {
    font-size: 14px;
    color: var(--login-muted);
}

.page_auth_custom .login_forgot {
    font-size: 14px;
    color: var(--login-link);
    text-decoration: none;
}

.page_auth_custom .login_forgot:hover,
.page_auth_custom .login_forgot:focus {
    text-decoration: underline;
}

/* ---------- Buttons ---------- */
.page_auth_custom .cmp_form .buttons {
    margin: 0;
}

.page_auth_custom .cmp_form .buttons .submit {
    box-sizing: border-box;
    display: block;
    width: 100%;
    height: 46px;
    margin: 0;
    padding: 0 16px;
    font-size: 15px;
    font-weight: 700;
    line-height: 44px;
    text-align: center;
    text-decoration: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, filter 0.15s ease;
}

.page_auth_custom .cmp_form .buttons .submit {
    color: var(--login-on-brand);
    background: var(--login-brand-strong);
    border: 1px solid var(--login-brand-strong);
    box-shadow: none;
}

.page_auth_custom .cmp_form .buttons .submit:hover {
    filter: brightness(0.9);
}

/* Register: a quiet text line under the Login button, not a second big button */
.page_auth_custom .login_register {
    margin: 18px 0 0;
    font-size: 14px;
    line-height: 1.45;
    text-align: center;
    color: var(--login-muted);
}

.page_auth_custom .login_register a {
    font-weight: 700;
    color: var(--login-link);
    text-decoration: none;
}

.page_auth_custom .login_register a:hover,
.page_auth_custom .login_register a:focus {
    text-decoration: underline;
}

.page_auth_custom .cmp_form .buttons .submit:focus-visible,
.page_auth_custom .login_register a:focus-visible,
.page_auth_custom .login_forgot:focus-visible {
    outline: 3px solid var(--login-ring);
    outline-offset: 2px;
}

/* ==========================================================
   Register page (userRegister.tpl): same card, wider for the longer form
   ========================================================== */
.page_auth_custom.page_register_custom .login_card {
    max-width: 560px;
}

.page_register_custom .cmp_form.register {
    max-width: none;
    margin: 0;
}

/* Sections (Profile, Login, consent...) separated by a thin line */
.page_register_custom .cmp_form fieldset {
    margin: 0 0 22px;
    padding: 0;
    border: 0;
}

.page_register_custom .cmp_form fieldset + fieldset {
    padding-top: 22px;
    border-top: 1px solid #eceef2;
}

/* Float takes the legend out of the fieldset border, so it sits below the divider */
.page_register_custom .cmp_form legend {
    float: left;
    width: 100%;
    margin: 0 0 14px;
    padding: 0;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--login-ink);
}

/* Two-column grid for the profile + account fields */
.page_register_custom .cmp_form legend + .fields,
.page_register_custom .cmp_form legend + .fields ~ .fields {
    clear: both;
}

.page_register_custom .cmp_form .identity .fields,
.page_register_custom .cmp_form .login .fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.page_auth_custom.page_register_custom .cmp_form .fields > div {
    grid-column: 1 / -1;
    margin: 0;
    padding-bottom: 0;
}

.page_auth_custom.page_register_custom .cmp_form .identity .given_name,
.page_auth_custom.page_register_custom .cmp_form .identity .family_name,
.page_auth_custom.page_register_custom .cmp_form .login .password {
    grid-column: auto;
}

.page_register_custom .cmp_form .fields .label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 700;
    font-style: normal;
    color: var(--login-ink);
}

.page_register_custom .cmp_form input[type="email"],
.page_register_custom .cmp_form select {
    box-sizing: border-box;
    width: 100%;
    max-width: none;
    height: 44px;
    padding: 0 12px;
    font-size: 15px;
    line-height: normal;
    color: var(--login-ink);
    background: #ffffff;
    border: 1px solid var(--login-line);
    border-radius: 6px;
    box-shadow: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.page_register_custom .cmp_form input[type="email"]:hover,
.page_register_custom .cmp_form select:hover {
    border-color: #b6bac6;
}

.page_register_custom .cmp_form input[type="email"]:focus,
.page_register_custom .cmp_form select:focus {
    outline: none;
    border-color: var(--login-brand-strong);
    box-shadow: 0 0 0 3px var(--login-ring);
}

/* Consent and reviewer checkboxes: one group, no divider between them */
.page_register_custom .cmp_form .consent .fields + .fields {
    margin-top: 12px;
}

.page_register_custom .cmp_form .consent {
    margin-bottom: 12px;
}

.page_register_custom .cmp_form .consent + .reviewer {
    padding-top: 0;
    border-top: 0;
}

.page_register_custom .cmp_form .optin label {
    position: relative;
    display: block;
    margin: 0;
    padding-left: 26px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--login-muted);
    cursor: pointer;
}

.page_register_custom .cmp_form .optin label + label {
    margin-top: 10px;
}

.page_register_custom .cmp_form .optin input[type="checkbox"] {
    position: absolute;
    top: 3px;
    left: 0;
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--login-brand-strong);
}

.page_register_custom .cmp_form .optin a {
    color: var(--login-link);
}

/* Reviewer interests field: shown by the theme JS when "reviewer" is ticked */
.page_auth_custom.page_register_custom .cmp_form .fields .reviewer_interests.is_visible {
    margin-top: 14px;
    padding-bottom: 0;
}

/* Server-side error summary */
.page_register_custom #formErrors {
    margin: 0 0 20px;
    padding: 12px 14px;
    color: #8f1d1d;
    background: #fdf1f1;
    border: 1px solid #f3c9c9;
    border-radius: 6px;
}

.page_register_custom #formErrors .pkp_form_error {
    margin: 0 0 4px;
    padding: 0;
    font-size: 14px;
    color: inherit;
    background: none;
    border: 0;
}

.page_register_custom #formErrors .pkp_form_error_list {
    margin: 0;
    padding-left: 18px;
    font-size: 14px;
    line-height: 1.5;
}

.page_register_custom #formErrors .pkp_form_error_list a {
    color: inherit;
}

.page_register_custom .cmp_form .buttons {
    margin-top: 4px;
}

@media (max-width: 560px) {
    .page_register_custom .cmp_form .identity .fields,
    .page_register_custom .cmp_form .login .fields {
        grid-template-columns: 1fr;
    }
}

/* ---------- Small screens ---------- */
@media (max-width: 480px) {
    .page_auth_custom .login_card_head {
        padding: 16px 20px;
    }

    .page_auth_custom .login_card_body {
        padding: 22px 20px 20px;
    }

    .page_auth_custom .login_card_head h1 {
        font-size: 20px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .page_auth_custom .cmp_form input,
    .page_auth_custom .cmp_form .buttons .submit {
        transition: none;
    }
}
