/* ============================================================
   Unendliche Geschichte – Mystisches Dark Theme
   ============================================================ */

/* ---- CSS Custom Properties ---- */
:root {
    --bg-deep:      #0a0a1a;
    --bg-card:      #12122a;
    --bg-card-2:    #1a1a35;
    --violet:       #6c3fa1;
    --violet-light: #9b6fd4;
    --gold:         #c9a84c;
    --gold-light:   #e8c96a;
    --text-main:    #e8e0d0;
    --text-muted:   #8a84a0;
    --text-accent:  #b8a8d8;
    --border:       rgba(108, 63, 161, 0.3);
    --glow-violet:  0 0 20px rgba(108, 63, 161, 0.4);
    --glow-gold:    0 0 20px rgba(201, 168, 76, 0.4);
    --transition:   all 0.3s ease;
}

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

html { scroll-behavior: smooth; }

body {
    background-color: var(--bg-deep);
    color: var(--text-main);
    font-family: 'Raleway', sans-serif;
    font-size: 1rem;
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* ---- Hintergrund-Nebel ---- */
.nebula-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(ellipse at 20% 20%, rgba(108, 63, 161, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(201, 168, 76, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(26, 26, 53, 0.8) 0%, transparent 70%),
        var(--bg-deep);
    animation: nebulaShift 20s ease-in-out infinite alternate;
}

@keyframes nebulaShift {
    0%   { background-position: 0% 0%, 100% 100%, 50% 50%; }
    50%  { background-position: 10% 30%, 90% 70%, 60% 40%; }
    100% { background-position: 20% 10%, 80% 90%, 40% 60%; }
}

/* ---- Typografie ---- */
h1, h2, h3, .mystic-heading {
    font-family: 'Cinzel', serif;
    color: var(--gold);
    letter-spacing: 0.05em;
}

h4, h5, h6 { font-family: 'Cinzel', serif; color: var(--text-accent); }

.story-text {
    font-family: 'Crimson Text', serif;
    font-size: 1.2rem;
    line-height: 1.9;
    color: var(--text-main);
}

a {
    color: var(--violet-light);
    text-decoration: none;
    transition: var(--transition);
}
a:hover { color: var(--gold); }

/* ---- Navigation ---- */
.mystic-nav {
    background: rgba(10, 10, 26, 0.95) !important;
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: var(--transition);
}

.mystic-brand {
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gold) !important;
    letter-spacing: 0.08em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-shadow: var(--glow-gold);
    transition: var(--transition);
}
.mystic-brand:hover { text-shadow: 0 0 30px rgba(201, 168, 76, 0.7); }

.brand-icon {
    color: var(--violet-light);
    animation: starPulse 3s ease-in-out infinite;
    font-size: 0.8rem;
}

@keyframes starPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.5; transform: scale(0.8); }
}

.mystic-nav-link {
    color: var(--text-accent) !important;
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem !important;
    border-radius: 6px;
    transition: var(--transition);
    letter-spacing: 0.03em;
}
.mystic-nav-link:hover {
    color: var(--gold) !important;
    background: rgba(108, 63, 161, 0.15);
}

/* ---- Buttons ---- */
.mystic-btn {
    background: linear-gradient(135deg, var(--violet), #4a2070);
    border: 1px solid var(--violet);
    color: var(--text-main) !important;
    font-family: 'Raleway', sans-serif;
    font-weight: 600;
    letter-spacing: 0.05em;
    border-radius: 6px;
    transition: var(--transition);
    text-shadow: none;
}
.mystic-btn:hover {
    background: linear-gradient(135deg, var(--violet-light), var(--violet));
    box-shadow: var(--glow-violet);
    transform: translateY(-1px);
    color: #fff !important;
}

.mystic-btn-outline {
    background: transparent;
    border: 1px solid var(--violet) !important;
    color: var(--violet-light) !important;
    font-size: 0.85rem;
    border-radius: 6px;
    transition: var(--transition);
}
.mystic-btn-outline:hover {
    background: rgba(108, 63, 161, 0.2);
    color: var(--gold) !important;
    border-color: var(--gold) !important;
}

.btn-mystic-primary {
    background: linear-gradient(135deg, var(--violet) 0%, #4a2070 100%);
    border: 1px solid var(--violet);
    color: #fff;
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    letter-spacing: 0.08em;
    padding: 0.6rem 1.5rem;
    border-radius: 6px;
    transition: var(--transition);
}
.btn-mystic-primary:hover {
    box-shadow: var(--glow-violet);
    transform: translateY(-2px);
    color: #fff;
    background: linear-gradient(135deg, var(--violet-light) 0%, var(--violet) 100%);
}

.btn-mystic-gold {
    background: linear-gradient(135deg, var(--gold) 0%, #a0762a 100%);
    border: 1px solid var(--gold);
    color: #0a0a1a;
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    letter-spacing: 0.08em;
    padding: 0.6rem 1.5rem;
    border-radius: 6px;
    font-weight: 700;
    transition: var(--transition);
}
.btn-mystic-gold:hover {
    box-shadow: var(--glow-gold);
    transform: translateY(-2px);
    color: #0a0a1a;
}

/* ---- Karten ---- */
.mystic-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.mystic-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--violet), var(--gold), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}
.mystic-card:hover::before { opacity: 1; }
.mystic-card:hover { border-color: rgba(108, 63, 161, 0.5); }

/* ---- Hero Section ---- */
.hero-section {
    position: relative;
    min-height: 85vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    overflow: hidden;
    padding: 4rem 1rem;
}

#particleCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 800px;
}

.hero-title {
    font-family: 'Cinzel', serif;
    font-size: clamp(2rem, 6vw, 4.5rem);
    font-weight: 900;
    color: var(--gold);
    text-shadow: 0 0 40px rgba(201, 168, 76, 0.5), 0 0 80px rgba(201, 168, 76, 0.2);
    letter-spacing: 0.1em;
    line-height: 1.2;
    animation: titleGlow 4s ease-in-out infinite alternate;
}

@keyframes titleGlow {
    from { text-shadow: 0 0 20px rgba(201, 168, 76, 0.4), 0 0 40px rgba(201, 168, 76, 0.2); }
    to   { text-shadow: 0 0 40px rgba(201, 168, 76, 0.7), 0 0 80px rgba(201, 168, 76, 0.3), 0 0 120px rgba(108, 63, 161, 0.2); }
}

.hero-subtitle {
    font-family: 'Crimson Text', serif;
    font-size: clamp(1.1rem, 2.5vw, 1.5rem);
    color: var(--text-accent);
    margin: 1.5rem 0;
    font-style: italic;
    line-height: 1.6;
}

.hero-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: center;
    margin: 2rem 0;
    color: var(--violet-light);
    font-size: 1.2rem;
    letter-spacing: 0.3em;
}
.hero-divider::before,
.hero-divider::after {
    content: '';
    flex: 1;
    max-width: 120px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--violet-light));
}
.hero-divider::after {
    background: linear-gradient(90deg, var(--violet-light), transparent);
}

/* ---- Story-Vorschau ---- */
.story-preview {
    background: rgba(18, 18, 42, 0.7);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    margin: 2rem 0;
    backdrop-filter: blur(8px);
    font-family: 'Crimson Text', serif;
    font-size: 1.15rem;
    color: var(--text-accent);
    line-height: 1.8;
    font-style: italic;
    position: relative;
}
.story-preview::before {
    content: '❝';
    font-size: 3rem;
    color: var(--violet);
    line-height: 1;
    position: absolute;
    top: 0.5rem;
    left: 1rem;
    opacity: 0.5;
}

/* ---- Formular ---- */
.mystic-form .form-control,
.mystic-form .form-select {
    background: var(--bg-card-2);
    border: 1px solid var(--border);
    color: var(--text-main);
    border-radius: 8px;
    font-family: 'Raleway', sans-serif;
    transition: var(--transition);
}
.mystic-form .form-control:focus,
.mystic-form .form-select:focus {
    background: var(--bg-card-2);
    border-color: var(--violet);
    color: var(--text-main);
    box-shadow: 0 0 0 3px rgba(108, 63, 161, 0.25), var(--glow-violet);
    outline: none;
}
.mystic-form .form-control::placeholder { color: var(--text-muted); }

.mystic-form textarea.form-control {
    min-height: 160px;
    font-family: 'Crimson Text', serif;
    font-size: 1.1rem;
    resize: vertical;
}

.mystic-form label {
    color: var(--text-accent);
    font-size: 0.9rem;
    letter-spacing: 0.05em;
    margin-bottom: 0.4rem;
}

/* ---- Story-Beiträge ---- */
.story-entry {
    border-left: 3px solid var(--violet);
    padding: 1.5rem 1.5rem 1.5rem 2rem;
    margin-bottom: 1.5rem;
    background: rgba(18, 18, 42, 0.5);
    border-radius: 0 10px 10px 0;
    animation: fadeInUp 0.6s ease both;
    transition: border-color 0.3s;
}
.story-entry:hover { border-left-color: var(--gold); }

.story-entry-author {
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    color: var(--gold);
    letter-spacing: 0.1em;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.story-entry-content {
    font-family: 'Crimson Text', serif;
    font-size: 1.2rem;
    line-height: 1.85;
    color: var(--text-main);
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ---- Animationen ---- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fade-in-up { animation: fadeInUp 0.6s ease both; }

/* Staggered delays für Listenelemente */
.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
.stagger-5 { animation-delay: 0.5s; }

/* ---- Rangliste ---- */
.ranking-table {
    border-collapse: separate;
    border-spacing: 0 8px;
    width: 100%;
}

.ranking-table thead th {
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}

.ranking-row {
    background: var(--bg-card);
    border: 1px solid var(--border);
    transition: var(--transition);
}
.ranking-row:hover {
    background: var(--bg-card-2);
    border-color: rgba(108, 63, 161, 0.5);
    transform: translateX(4px);
}

.ranking-row td {
    padding: 1rem;
    vertical-align: middle;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.ranking-row td:first-child {
    border-left: 1px solid var(--border);
    border-radius: 8px 0 0 8px;
}
.ranking-row td:last-child {
    border-right: 1px solid var(--border);
    border-radius: 0 8px 8px 0;
}

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 0.9rem;
}

.rank-1 {
    background: linear-gradient(135deg, var(--gold), #a0762a);
    color: #0a0a1a;
    box-shadow: var(--glow-gold);
    animation: crownPulse 2s ease-in-out infinite;
}
.rank-2 { background: linear-gradient(135deg, #c0c0c0, #888); color: #0a0a1a; }
.rank-3 { background: linear-gradient(135deg, #cd7f32, #8b4513); color: #fff; }
.rank-other { background: var(--bg-card-2); color: var(--text-muted); border: 1px solid var(--border); }

@keyframes crownPulse {
    0%, 100% { box-shadow: 0 0 15px rgba(201, 168, 76, 0.4); }
    50%       { box-shadow: 0 0 30px rgba(201, 168, 76, 0.8), 0 0 60px rgba(201, 168, 76, 0.3); }
}

.rank-username {
    font-family: 'Raleway', sans-serif;
    font-weight: 600;
    color: var(--text-main);
}

.rank-words {
    font-family: 'Cinzel', serif;
    color: var(--violet-light);
    font-size: 1.1rem;
}

/* ---- Profil ---- */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    transition: var(--transition);
}
.stat-card:hover {
    border-color: var(--violet);
    box-shadow: var(--glow-violet);
    transform: translateY(-3px);
}

.stat-number {
    font-family: 'Cinzel', serif;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--gold);
    line-height: 1;
    display: block;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    margin-top: 0.5rem;
    display: block;
}

/* ---- Admin ---- */
.admin-table {
    font-size: 0.9rem;
}
.admin-table th {
    font-family: 'Cinzel', serif;
    font-size: 0.75rem;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: var(--bg-card-2);
    border-bottom: 1px solid var(--border) !important;
    color: var(--text-accent);
}
.admin-table td {
    background: var(--bg-card);
    border-bottom: 1px solid rgba(108, 63, 161, 0.15) !important;
    color: var(--text-main);
    vertical-align: middle;
}
.admin-table tbody tr:hover td { background: var(--bg-card-2); }

/* ---- Word Counter ---- */
.word-counter {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: right;
    margin-top: 0.3rem;
    transition: var(--transition);
}
.word-counter.has-words { color: var(--violet-light); }

/* ---- Alerts / Flash Messages ---- */
.alert {
    border-radius: 8px;
    border: 1px solid;
    font-size: 0.9rem;
}
.alert-success { background: rgba(40, 167, 69, 0.15); border-color: rgba(40, 167, 69, 0.4); color: #7bdf9c; }
.alert-danger  { background: rgba(220, 53, 69, 0.15);  border-color: rgba(220, 53, 69, 0.4);  color: #f08090; }
.alert-warning { background: rgba(201, 168, 76, 0.15); border-color: rgba(201, 168, 76, 0.4); color: var(--gold-light); }
.alert-info    { background: rgba(108, 63, 161, 0.15); border-color: rgba(108, 63, 161, 0.4); color: var(--text-accent); }
.btn-close { filter: invert(1) grayscale(1) brightness(2); }

/* ---- Page Headers ---- */
.page-header {
    text-align: center;
    margin-bottom: 2.5rem;
    padding: 2rem 0 1.5rem;
}
.page-header h1 {
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    margin-bottom: 0.5rem;
}
.page-header-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--violet-light);
    margin-top: 1rem;
}
.page-header-divider::before,
.page-header-divider::after {
    content: '';
    width: 80px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--violet-light));
}
.page-header-divider::after {
    background: linear-gradient(90deg, var(--violet-light), transparent);
}

/* ---- Auth-Seiten ---- */
.auth-container {
    max-width: 420px;
    margin: 3rem auto;
}
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2.5rem 2rem;
}
.auth-title {
    font-family: 'Cinzel', serif;
    font-size: 1.5rem;
    color: var(--gold);
    text-align: center;
    margin-bottom: 0.5rem;
}
.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 2rem;
}

/* ---- Footer ---- */
.mystic-footer {
    background: rgba(10, 10, 26, 0.95);
    border-top: 1px solid var(--border);
    padding: 1.25rem 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.footer-link {
    color: var(--text-muted);
    transition: var(--transition);
}
.footer-link:hover { color: var(--gold); }

.footer-sep { color: var(--border); margin: 0 0.4rem; }

.footer-credit { font-size: 0.82rem; }

.footer-year { color: var(--violet-light); font-weight: 600; }

/* ---- Impressum / Datenschutz ---- */
.legal-content h2 {
    font-size: 1.2rem;
    margin-top: 2rem;
    color: var(--violet-light);
}
.legal-content h3 { font-size: 1rem; color: var(--text-accent); }
.legal-content p, .legal-content li { font-size: 0.95rem; color: var(--text-main); }
.legal-content a { color: var(--violet-light); }
.legal-content a:hover { color: var(--gold); }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--violet); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--violet-light); }

/* ---- Utilities ---- */
.text-gold    { color: var(--gold) !important; }
.text-violet  { color: var(--violet-light) !important; }
.text-muted-mystic { color: var(--text-muted) !important; }
.border-mystic { border-color: var(--border) !important; }
.bg-mystic-card { background: var(--bg-card) !important; }

/* ---- Main Content ---- */
.main-content { flex: 1; padding-top: 0.5rem; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .hero-section { min-height: 70vh; padding: 3rem 1rem; }
    .mystic-brand { font-size: 0.95rem; }
    .story-entry { padding: 1rem 1rem 1rem 1.25rem; }
    .auth-card { padding: 1.75rem 1.25rem; }
    .stat-number { font-size: 2rem; }
}

@media (max-width: 480px) {
    .hero-title { font-size: 1.8rem; }
    .hero-subtitle { font-size: 1rem; }
}

/* ---- Scroll-Animation Klassen (via IntersectionObserver) ---- */
.scroll-reveal {
    opacity: 0;
    transform: translateY(25px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}
.scroll-reveal.visible {
    opacity: 1;
    transform: translateY(0);
}
