/* ============================================================
   BKM Bausparkasse – Keycloak 26 Login Theme (CSS-only)
   parent: keycloak.v2  |  No FTL templates required
   ============================================================

   Selector reference (keycloak.v2 / PatternFly 5):
   - #keycloak-bg          — full-page background element
   - div.kc-logo-text      — top logo area
   - main > div:first-child— the login card
   - #kc-login             — the submit button
   - .pf-v5-c-form-control — input fields
   - .pf-v5-c-form-control:after — input bottom border line

   Dark mode:
   keycloak.v2 adds the class "pf-v5-theme-dark" to <html> when the
   OS/browser prefers dark AND dark mode is enabled for the realm
   (Realm settings → Themes → Dark mode). The dark tokens below are
   keyed on that class, NOT on @media (prefers-color-scheme: dark):
   if the realm turns dark mode off, the card stays white and the
   light tokens must stay active, otherwise text turns light-on-white.

   Contrast (WCAG 2.1 AA, checked with axe-core 4.14):
   light: button #fff on #2f7d70 = 4.90 | title 6.76 | labels 7.46
          links #2f7d70 on #fff = 4.90
   dark:  button #111416 on #63a99d = 6.77 | title 9.73 | labels 11.07
          links #63a99d on #26292d = 5.35  (card bg = #26292d)
   ALTCHA footer (11.2px): light link 4.90 / text 6.58 on #fff,
          dark link 6.50 / text 9.15 on #181818, link underlined
   ============================================================ */

/* --- Design tokens: light (default) ------------------------ */
:root {
    --bkm-purple:        #452647;
    --bkm-teal:          #63a99d;   /* brand teal – decoration only in light mode */

    /* Accessible teal for text and button fills on white */
    --bkm-accent:        #2f7d70;   /* 4.90:1 with #fff */
    --bkm-accent-hover:  #2a7166;   /* 5.75:1 */
    --bkm-accent-active: #235f55;   /* 7.40:1 */
    --bkm-on-accent:     #ffffff;

    --bkm-link:          var(--bkm-accent);
    --bkm-link-hover:    var(--bkm-accent-active);

    --bkm-input-bg:      #eef2f7;
    --bkm-input-focus:   #e4ecf6;
    --bkm-input-text:    #151515;
    --bkm-input-line:    var(--bkm-accent);

    --bkm-title:         #5a5a6a;
    --bkm-label:         #555555;
    --bkm-muted:         #5d5d5d;   /* small print, 6.58:1 on #fff */

    /* KC26 built-in CSS variable for the page background graphic */
    --keycloak-bg-logo-url: none;
}

/* --- Design tokens: dark (keycloak.v2 dark mode) ----------- */
:root.pf-v5-theme-dark {
    /* On the dark card the brand teal itself is accessible,
       so the button uses it with dark text */
    --bkm-accent:        #63a99d;   /* 6.77:1 with #111416 */
    --bkm-accent-hover:  #7dbcb1;   /* 8.54:1 */
    --bkm-accent-active: #93c9bf;   /* 9.99:1 */
    --bkm-on-accent:     #111416;

    --bkm-link:          #63a99d;   /* 5.35:1 on #26292d */
    --bkm-link-hover:    #7dbcb1;   /* 6.75:1 */

    --bkm-input-bg:      #1b1d21;
    --bkm-input-focus:   #303338;
    --bkm-input-text:    #e0e0e0;   /* 12.78:1 on #1b1d21 */
    --bkm-input-line:    #63a99d;

    --bkm-title:         #d2d2dc;   /* 9.73:1 on #26292d */
    --bkm-label:         #e0e0e0;   /* 11.07:1 on #26292d */
    --bkm-muted:         #bababa;   /* small print, 9.15:1 on ALTCHA's #181818 */
}

/* --- Page background -------------------------------------- */
#keycloak-bg {
    background-color: var(--bkm-purple) !important;
    background-image:
            radial-gradient(ellipse at 20% 80%, rgba(77,169,148,0.10) 0%, transparent 55%),
            radial-gradient(ellipse at 80% 10%, rgba(255,255,255,0.04) 0%, transparent 45%) !important;
    background-size: cover !important;
}

/* --- BKM logo: bottom-right corner via pseudo-element ----- */
/* We pin it on the body so it always stays fixed on-screen   */
body::after {
    content: '';
    display: block;
    position: fixed;
    bottom: 0;
    right: 0;
    width: 200px;
    height: 300px;
    background-image: url('../img/bkmdreieck.svg');
    background-repeat: no-repeat;
    background-size: contain;
    background-position: bottom right;
    pointer-events: none;
    z-index: 9999;
}

/* --- Hide default Keycloak logo / header text ------------- */
/* keycloak.v2 renders the realm name as "BKM - Login" here  */
div.kc-logo-text,
div.kc-logo-text span,
#kc-header,
#kc-header-wrapper,
.kc-logo-text {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
    position: absolute !important;
    pointer-events: none !important;
}

/* --- Login card top border (teal accent, decorative) ------ */
main > div:first-child {
    border-top: 5px solid var(--bkm-teal) !important;
}

/* --- Page title ------------------------------------------- */
#kc-page-title,
h1#kc-page-title {
    color: var(--bkm-title) !important;
    font-weight: 300 !important;
    font-size: 1.6rem !important;
    text-align: center !important;
    letter-spacing: 0.01em !important;
}

/* --- Inputs ----------------------------------------------- */
.pf-v5-c-form-control {
    background-color: var(--bkm-input-bg) !important;
    color: var(--bkm-input-text) !important;
}

.pf-v5-c-form-control > input,
.pf-v5-c-form-control > select,
.pf-v5-c-form-control > textarea {
    color: var(--bkm-input-text) !important;
}

.pf-v5-c-form-control:focus-within {
    background-color: var(--bkm-input-focus) !important;
}

/* --- Input bottom border accent (replaces PF5 blue) ------- */
.pf-v5-c-form-control::after {
    border-block-end-color: var(--bkm-input-line) !important;
}

/* --- Submit / Sign-In button ------------------------------ */
#kc-login {
    background-color: var(--bkm-accent) !important;
    border-color:     var(--bkm-accent) !important;
    color:            var(--bkm-on-accent) !important;
}

#kc-login:hover,
#kc-login:focus-visible {
    background-color: var(--bkm-accent-hover) !important;
    border-color:     var(--bkm-accent-hover) !important;
}

#kc-login:active {
    background-color: var(--bkm-accent-active) !important;
    border-color:     var(--bkm-accent-active) !important;
}

/* --- Links ------------------------------------------------ */
a {
    color: var(--bkm-link) !important;
}
a:hover,
a:focus-visible {
    color: var(--bkm-link-hover) !important;
}

/* --- Checkbox accent -------------------------------------- */
input[type="checkbox"] {
    accent-color: var(--bkm-accent);
}

/* --- Form labels ------------------------------------------ */
.pf-v5-c-form__label-text {
    color: var(--bkm-label) !important;
}

/* --- ALTCHA widget (custom Vertriebspartner view) --------- */
/* ALTCHA 3 switches light/dark via light-dark(), i.e. it follows
   color-scheme. PF5 sets color-scheme: dark only together with
   .pf-v5-theme-dark, so the widget follows Keycloak's mode and
   stays light when the realm disables dark mode.
   :root:root out-ranks ALTCHA's own :root block, which it injects
   at runtime after this stylesheet. */
:root:root {
    --altcha-color-primary:         var(--bkm-accent);
    --altcha-color-primary-content: var(--bkm-on-accent);
}

/* ALTCHA dims the 11px footer to 70 % opacity, which pulled the
   "ALTCHA" link down to 2.82:1 (light) / 3.85:1 (dark). Use
   full opacity and a muted text colour that passes on its own. */
.altcha-footer {
    opacity: 1 !important;
    color: var(--bkm-muted) !important;
}

/* Link inside running text must not rely on colour alone
   (WCAG 1.4.1 / axe link-in-text-block) → underline it. */
.altcha-footer a {
    color: var(--bkm-link) !important;
    text-decoration: underline !important;
    text-underline-offset: 2px;
}

/* --- Responsive: shrink logo on small screens ------------- */
@media (max-width: 600px) {
    body::after {
        width: 150px;
        height: 105px;
    }
}

/* --- Hide browser-native password reveal button ----------- */
/* Chrome/Edge/Safari ship their own eye icon; KC already     */
/* provides one via .pf-v5-c-button — suppress the native one */
input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear,
input[type="password"]::-webkit-contacts-auto-fill-button,
input[type="password"]::-webkit-credentials-auto-fill-button {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}