@import url('https://fonts.googleapis.com/css2?family=Cinzel+Decorative:wght@700;900&family=Cinzel:wght@400;600;700&family=Lato:wght@300;400;700&display=swap');

/* ── Variables ─────────────────────────────────────────────────────────── */
:root {
    --gold:        #f0c040;
    --gold-bright: #ffe066;
    --gold-dim:    #b8922a;
    --green-dark:  #0a1a0a;
    --green-mid:   #0f2a0f;
    --green-panel: #0d2010;
    --green-field: #0b1e0e;
    --green-border:#1a4020;
    --text-light:  #f4e8c8;
    --text-dim:    #8faa8f;
    --red-accent:  #e84040;
    --shadow-gold: rgba(240, 192, 64, 0.45);
    --shadow-dark: rgba(0, 0, 0, 0.7);
}

/* ── Reset & base ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body, html {
    min-height: 100vh;
    font-family: 'Lato', sans-serif;
    color: var(--text-light);
    background: var(--green-dark);
    overflow-x: hidden;
}

/* ── Animated background ───────────────────────────────────────────────── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 60% at 50% -10%, rgba(240,192,64,0.18) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 20% 100%, rgba(20,80,20,0.4) 0%, transparent 55%),
        radial-gradient(ellipse 60% 40% at 80% 100%, rgba(20,80,20,0.4) 0%, transparent 55%),
        linear-gradient(180deg, #050e05 0%, #0a1a0a 40%, #061006 100%);
    z-index: 0;
    pointer-events: none;
}

/* Sparkle particles */
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(1px 1px at 10% 20%, rgba(240,192,64,0.6) 0%, transparent 100%),
        radial-gradient(1px 1px at 25% 60%, rgba(240,192,64,0.4) 0%, transparent 100%),
        radial-gradient(1px 1px at 40% 15%, rgba(240,192,64,0.5) 0%, transparent 100%),
        radial-gradient(1px 1px at 55% 75%, rgba(240,192,64,0.3) 0%, transparent 100%),
        radial-gradient(1px 1px at 70% 35%, rgba(240,192,64,0.6) 0%, transparent 100%),
        radial-gradient(1px 1px at 85% 55%, rgba(240,192,64,0.4) 0%, transparent 100%),
        radial-gradient(1px 1px at 15% 85%, rgba(240,192,64,0.3) 0%, transparent 100%),
        radial-gradient(1px 1px at 92% 10%, rgba(240,192,64,0.5) 0%, transparent 100%),
        radial-gradient(2px 2px at 33% 45%, rgba(240,192,64,0.2) 0%, transparent 100%),
        radial-gradient(2px 2px at 77% 80%, rgba(240,192,64,0.2) 0%, transparent 100%);
    z-index: 0;
    pointer-events: none;
    animation: twinkle 4s ease-in-out infinite alternate;
}

@keyframes twinkle {
    from { opacity: 0.6; }
    to   { opacity: 1; }
}

/* ── Page layout ───────────────────────────────────────────────────────── */
#kc-container-wrapper,
.login-pf body,
body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    position: relative;
    z-index: 1;
}

#kc-container,
.container-fluid {
    width: 100%;
    max-width: 500px;
    position: relative;
    z-index: 2;
}

/* ── Card ──────────────────────────────────────────────────────────────── */
#kc-content,
.card-pf {
    background: linear-gradient(160deg, #0f2a10 0%, #0a1e0a 50%, #071507 100%);
    border: 2px solid var(--gold-dim);
    border-radius: 16px;
    padding: 0;
    box-shadow:
        0 0 0 1px rgba(240,192,64,0.1),
        0 0 40px rgba(240,192,64,0.15),
        0 30px 80px rgba(0,0,0,0.8),
        inset 0 1px 0 rgba(240,192,64,0.2);
    overflow: hidden;
    animation: cardReveal 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes cardReveal {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Gold marquee border effect */
#kc-content::before,
.card-pf::before {
    content: '';
    display: block;
    height: 6px;
    background: linear-gradient(90deg,
        transparent 0%,
        var(--gold-dim) 15%,
        var(--gold-bright) 35%,
        var(--gold) 50%,
        var(--gold-bright) 65%,
        var(--gold-dim) 85%,
        transparent 100%);
    animation: shimmer 3s ease-in-out infinite;
}

@keyframes shimmer {
    0%   { background-position: -200% center; }
    100% { background-position: 200% center; }
}

/* ── Header / Logo area ────────────────────────────────────────────────── */
#kc-header,
.login-pf-header {
    text-align: center;
    padding: 32px 40px 24px;
    background: linear-gradient(180deg, rgba(240,192,64,0.06) 0%, transparent 100%);
    border-bottom: 1px solid rgba(240,192,64,0.12);
}

#kc-header-wrapper,
.login-pf-header h1 {
    font-family: 'Cinzel Decorative', cursive;
    font-size: clamp(1.6rem, 4vw, 2.2rem);
    font-weight: 900;
    letter-spacing: 0.02em;
    line-height: 1.1;
    background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 50%, var(--gold-dim) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: none;
    filter: drop-shadow(0 2px 8px rgba(240,192,64,0.4));
    margin-bottom: 4px;
}

/* Subtitle under logo */
#kc-header::after {
    content: '🎰 Free-to-Play Arcade 🎰';
    display: block;
    font-family: 'Cinzel', serif;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--gold-dim);
    margin-top: 6px;
}

/* ── Form container ────────────────────────────────────────────────────── */
#kc-content-wrapper,
#kc-form-wrapper,
.login-pf-page {
    padding: 28px 40px 32px;
}

/* Page title (Sign In / Register) */
#kc-page-title,
h1.login-pf-page-header {
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--gold);
    text-align: center;
    margin-bottom: 24px;
}

/* ── Form groups ───────────────────────────────────────────────────────── */
.form-group,
.pf-v5-c-form__group {
    margin-bottom: 14px;
    position: relative;
}

label,
.pf-v5-c-form__label {
    display: block;
    font-family: 'Cinzel', serif;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--gold-dim);
    margin-bottom: 6px;
}

/* ── Inputs ────────────────────────────────────────────────────────────── */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="username"],
.form-control,
.pf-v5-c-form-control {
    width: 100%;
    height: 48px;
    background: var(--green-field);
    border: 1px solid var(--green-border);
    border-radius: 8px;
    color: var(--text-light);
    font-family: 'Lato', sans-serif;
    font-size: 0.95rem;
    padding: 0 16px;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    outline: none;
    -webkit-appearance: none;
}

input[type="text"]::placeholder,
input[type="email"]::placeholder,
input[type="password"]::placeholder {
    color: var(--text-dim);
    opacity: 0.7;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
.form-control:focus,
.pf-v5-c-form-control:focus {
    border-color: var(--gold-dim);
    background: #0f2510;
    box-shadow: 0 0 0 3px rgba(240,192,64,0.12), inset 0 1px 3px rgba(0,0,0,0.3);
}

/* Error state */
.has-error input,
input.error {
    border-color: var(--red-accent) !important;
    box-shadow: 0 0 0 3px rgba(232,64,64,0.15) !important;
}

/* ── Two-column row for first/last or name fields ──────────────────────── */
.form-group.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ── Sign Up / Submit button ───────────────────────────────────────────── */
.btn-primary,
input[type="submit"],
button[type="submit"],
#kc-login,
#kc-register {
    width: 100%;
    height: 52px;
    margin-top: 8px;
    background: linear-gradient(180deg, #2a6e20 0%, #1a5014 50%, #143d10 100%);
    border: 2px solid var(--gold-dim);
    border-radius: 10px;
    color: var(--gold-bright);
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow:
        0 0 20px rgba(240,192,64,0.15),
        inset 0 1px 0 rgba(240,192,64,0.2),
        0 4px 16px rgba(0,0,0,0.4);
    -webkit-appearance: none;
    appearance: none;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.btn-primary:hover,
input[type="submit"]:hover,
button[type="submit"]:hover,
#kc-login:hover,
#kc-register:hover {
    background: linear-gradient(180deg, #358028 0%, #245c1a 50%, #1a4a14 100%);
    border-color: var(--gold);
    box-shadow:
        0 0 30px rgba(240,192,64,0.3),
        inset 0 1px 0 rgba(240,192,64,0.3),
        0 6px 20px rgba(0,0,0,0.5);
    transform: translateY(-1px);
    color: var(--gold-bright);
}

.btn-primary:active,
input[type="submit"]:active,
button[type="submit"]:active {
    transform: translateY(0);
    box-shadow:
        0 0 15px rgba(240,192,64,0.2),
        0 2px 8px rgba(0,0,0,0.4);
}

/* ── Links ─────────────────────────────────────────────────────────────── */
a, .login-pf-signup a {
    color: var(--gold);
    text-decoration: none;
    transition: color 0.15s;
}

a:hover {
    color: var(--gold-bright);
    text-decoration: underline;
}

/* ── Register / Login links below form ─────────────────────────────────── */
#kc-registration,
#kc-form-options,
.login-pf-signup {
    text-align: center;
    margin-top: 20px;
    font-size: 0.85rem;
    color: var(--text-dim);
    font-family: 'Lato', sans-serif;
}

/* ── Checkbox (terms) ──────────────────────────────────────────────────── */
.checkbox,
.pf-v5-c-check {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 14px 0;
    font-size: 0.85rem;
    color: var(--text-dim);
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--gold);
    cursor: pointer;
    flex-shrink: 0;
}

/* ── Alert / error messages ────────────────────────────────────────────── */
.alert,
.pf-v5-c-alert {
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 0.875rem;
    border: 1px solid;
}

.alert-error,
.pf-v5-c-alert--danger {
    background: rgba(232, 64, 64, 0.12);
    border-color: rgba(232, 64, 64, 0.4);
    color: #ff9090;
}

.alert-warning {
    background: rgba(240,192,64,0.08);
    border-color: rgba(240,192,64,0.3);
    color: var(--gold);
}

.alert-success {
    background: rgba(64,200,64,0.08);
    border-color: rgba(64,200,64,0.3);
    color: #80e080;
}

/* ── Forgot password ───────────────────────────────────────────────────── */
#kc-form-options .checkbox {
    justify-content: space-between;
}

/* ── Divider ───────────────────────────────────────────────────────────── */
.login-pf-header hr,
hr {
    border: none;
    border-top: 1px solid rgba(240,192,64,0.12);
    margin: 20px 0;
}

/* ── Password visibility toggle ────────────────────────────────────────── */
.pf-v5-c-button.pf-m-plain {
    background: transparent;
    border: none;
    color: var(--gold-dim);
    cursor: pointer;
    padding: 0 12px;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

/* ── Help text / validation ────────────────────────────────────────────── */
.help-block,
.pf-v5-c-form__helper-text {
    font-size: 0.78rem;
    color: #ff8080;
    margin-top: 4px;
}

/* ── Social login buttons (if any) ─────────────────────────────────────── */
.social-section {
    margin-top: 20px;
}

.zocial {
    border-radius: 8px;
    border: 1px solid var(--green-border);
    background: var(--green-field);
    color: var(--text-light);
    transition: border-color 0.2s;
}

.zocial:hover {
    border-color: var(--gold-dim);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 540px) {
    #kc-content-wrapper,
    #kc-form-wrapper,
    .login-pf-page {
        padding: 20px 24px 28px;
    }

    #kc-header,
    .login-pf-header {
        padding: 24px 24px 20px;
    }
}

/* ── Keycloak-specific overrides ────────────────────────────────────────── */
.login-pf-page .container {
    max-width: 500px;
    margin: 0 auto;
}

/* Hide Keycloak default header/footer chrome */
.login-pf-header img {
    display: none;
}

/* Fix PatternFly v5 form layout */
.pf-v5-c-form {
    --pf-v5-c-form--m-horizontal__group-label--md--GridColumnWidth: none;
}

/* Ensure body fills viewport */
.login-pf {
    background: var(--green-dark) !important;
}
