﻿/* ===================================================
   RPG Login Theme – Dark Fantasy
   =================================================== */

/* ---------- Google Font ---------- */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Inter:wght@300;400;500;600&display=swap');

@font-face {
    font-family: 'ipamjm';
    /*font-family: '851tegaki_zatsu';
    src: url('../fonts/851tegaki_zatsu_normal_0883.ttf') format('truetype');*/
    font-weight: normal;
    font-style: normal;
}

/* ---------- CSS Variables ---------- */
:root {
    --bg-primary: #0a0e17;
    --bg-card: rgba(15, 20, 35, 0.85);
    --gold: #d4a843;
    --gold-light: #f0d078;
    --gold-dim: #8a6d2b;
    --accent-blue: #4fc3f7;
    --accent-purple: #b388ff;
    --text-primary: #e8e6e3;
    --text-muted: #8a8d93;
    --border-glow: rgba(212, 168, 67, 0.4);
    --error-red: #ef5350;
    --success-green: #66bb6a;
    /*--font-display: 'Cinzel', '851tegaki_zatsu', serif;
    --font-chinese: '851tegaki_zatsu', 'Inter', sans-serif;
    --font-body: 'Inter', '851tegaki_zatsu', sans-serif;*/
    --font-display: 'Cinzel', 'ipamjm', serif;
    --font-chinese: 'ipamjm', 'Inter', sans-serif;
    --font-body: 'Inter', 'ipamjm', sans-serif;
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body.login-body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* ---------- Starfield Background ---------- */
.starfield {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
    background: radial-gradient(ellipse at 50% 0%, #1a1040 0%, #0a0e17 60%, #050710 100%);
}

.starfield canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ---------- Floating Particles (CSS) ---------- */
.particle {
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: 1;
    opacity: 0;
    animation: particleFloat 6s ease-in-out infinite;
}

@keyframes particleFloat {
    0% {
        opacity: 0;
        transform: translateY(0) scale(0.5);
    }

    20% {
        opacity: 1;
    }

    80% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform: translateY(-120px) scale(0);
    }
}

/* ---------- Main Container ---------- */
.login-container {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 440px;
    padding: 0 20px;
}

/* ---------- Title ---------- */
.rpg-title {
    text-align: center;
    margin-bottom: 32px;
    position: relative;
}

.rpg-title h1 {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    color: var(--gold);
    text-shadow: 0 0 20px rgba(212, 168, 67, 0.5), 0 0 60px rgba(212, 168, 67, 0.2);
    letter-spacing: 2px;
    min-height: 2.8rem;
}

.rpg-title .subtitle {
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 8px;
    letter-spacing: 3px;
    text-transform: uppercase;
}

/* Title cursor blink */
.title-cursor {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background: var(--gold);
    margin-left: 3px;
    vertical-align: text-bottom;
    animation: cursorBlink 0.8s ease-in-out infinite;
}

@keyframes cursorBlink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

/* ---------- Auth Card ---------- */
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glow);
    border-radius: 16px;
    padding: 36px 32px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow:
        0 0 30px rgba(212, 168, 67, 0.08),
        0 8px 32px rgba(0, 0, 0, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    animation: cardAppear 0.8s ease-out;
    position: relative;
    overflow: hidden;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    border-radius: 16px;
    border: 1px solid transparent;
    background: linear-gradient(135deg, var(--gold-dim), transparent 40%, transparent 60%, var(--gold-dim)) border-box;
    -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: borderGlow 4s ease-in-out infinite;
    pointer-events: none;
}

@keyframes borderGlow {

    0%,
    100% {
        opacity: 0.4;
    }

    50% {
        opacity: 1;
    }
}

@keyframes cardAppear {
    0% {
        opacity: 0;
        transform: translateY(24px) scale(0.97);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ---------- Auth Panels ---------- */
.auth-panel {
    display: none;
}

.auth-panel.active {
    display: block;
    animation: panelSlideIn 0.4s ease-out;
}

@keyframes panelSlideIn {
    0% {
        opacity: 0;
        transform: translateX(20px);
    }

    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

.auth-panel h2 {
    font-family: var(--font-display);
    font-size: 1.35rem;
    color: var(--gold-light);
    text-align: center;
    margin-bottom: 28px;
    letter-spacing: 1px;
}

/* ---------- Form Groups ---------- */
.form-group {
    margin-bottom: 30px;
    /* Increased from 20px */
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.input-wrapper {
    position: relative;
}

.input-wrapper input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.85rem;
    /* Match label size */
    font-family: var(--font-body);
    /* Revert to Inter for normal case */
    font-weight: 500;
    /* Regular weight */
    transition: all 0.3s ease;
    outline: none;
}

.input-wrapper input::placeholder {
    color: rgba(255, 255, 255, 0.2);
}

.input-wrapper input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(212, 168, 67, 0.15), 0 0 20px rgba(212, 168, 67, 0.1);
    background: #0f1423;
    /* Solid background to match label */
}

/* Wave Label Animation */
.input-wrapper label {
    position: absolute;
    top: 15px;
    left: 15px;
    pointer-events: none;
    color: rgba(255, 255, 255, 0.5);
    /* Placeholder color */
    display: flex;
    /* Allow spans to animate individually */
}

.input-wrapper label span {
    display: inline-block;
    font-size: 0.85rem;
    /* Slightly smaller for all-caps */
    font-family: var(--font-display);
    /* Use RPG title font (Cinzel) */
    font-weight: 600;
    text-transform: uppercase;
    min-width: 0px;
    transition: 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* When Input Focused OR Valid (has text) OR Autofilled */
.input-wrapper input:focus+label span,
.input-wrapper input:valid+label span,
.input-wrapper input:-webkit-autofill+label span {
    color: var(--gold);
    /* Use theme color instead of #3679ff */
    transform: translateY(-24px);
    /* Slightly higher to center on border */
    font-size: 14px;
    text-shadow: 0 0 5px var(--gold);
    background-color: #0f1423;
    /* Solid background to block border */
    /* Fully opaque to block border */
    padding: 0 3px;
    /* Add padding to cover border width */
    margin: 0 -2px;
    /* Pull letters closer to form continuous block */
    z-index: 2;
    /* Ensure on top of border */
    position: relative;
    border-radius: 2px;
}

/* Adjust input padding so text doesn't overlap label if label moves */
.input-wrapper input {
    /* Ensure input has enough padding-top if needed, but for now standard is fine */
    background: transparent;
}

/* ---------- Password Toggle ---------- */
.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.toggle-password:hover {
    color: var(--gold);
}

.toggle-password svg {
    width: 18px;
    height: 18px;
}

.input-wrapper:has(.toggle-password) input {
    padding-right: 44px;
}

/* ---------- Submit Button ---------- */
.btn-submit {
    width: 100%;
    padding: 13px 24px;
    margin-top: 8px;
    background: linear-gradient(135deg, var(--gold-dim), var(--gold));
    border: none;
    border-radius: 8px;
    color: #0a0e17;
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 2px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.btn-submit::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s ease;
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(212, 168, 67, 0.4), 0 0 40px rgba(212, 168, 67, 0.15);
}

.btn-submit:hover::before {
    left: 100%;
}

.btn-submit:active {
    transform: translateY(0);
}

.btn-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ---------- Messages ---------- */
.error-msg {
    color: var(--error-red);
    font-size: 0.85rem;
    margin-top: 12px;
    text-align: center;
    min-height: 1.2em;
}

.success-msg {
    color: var(--success-green);
    font-size: 0.85rem;
    margin-top: 12px;
    text-align: center;
    min-height: 1.2em;
}

/* ---------- Switch Link ---------- */
.switch-link {
    text-align: center;
    margin-top: 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.switch-link a {
    color: var(--accent-blue);
    cursor: pointer;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s, text-shadow 0.2s;
}

.switch-link a:hover {
    color: var(--gold-light);
    text-shadow: 0 0 10px rgba(212, 168, 67, 0.4);
}

/* ---------- Footer ---------- */
.login-footer {
    position: relative;
    z-index: 10;
    text-align: center;
    margin-top: 32px;
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    opacity: 0.6;
}

/* ---------- Decorative Divider ---------- */
.divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    gap: 12px;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
}

.divider span {
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* ---------- Loading Spinner (RPG style) ---------- */
.login-loading {
    display: none;
    justify-content: center;
    align-items: center;
    margin-top: 12px;
}

.login-loading.show {
    display: flex;
}

.login-loading .spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(212, 168, 67, 0.2);
    border-top: 2px solid var(--gold);
    border-radius: 50%;
    animation: spinnerRotate 0.8s linear infinite;
    margin-right: 8px;
}

@keyframes spinnerRotate {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.login-loading span {
    font-size: 0.85rem;
    color: var(--gold);
    letter-spacing: 1px;
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
    .login-container {
        padding: 0 16px;
    }

    .auth-card {
        padding: 28px 20px;
    }

    .rpg-title h1 {
        font-size: 1.5rem;
    }
}