/* =========================================
   1. BASIS VARIABLEN & GLOBAL
   ========================================= */
:root {
    --primary: #007bff;
    --primary-hover: #0056b3;
    --bg: #f4f7f9;
    --text: #333;
    --white-glass: rgba(255, 255, 255, 0.98);
    --border: #e0e4e8;
    
    /* Feedback Farben */
    --success-bg: #eaffea;
    --success-text: #155724;
    --error-bg: #ffe6e6;
    --error-text: #721c24;
}

* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    /* WICHTIG: Platz für den Gradient unten lassen */
    padding-bottom: 80px;
}

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

/* =========================================
   2. HEADER & NAVIGATION
   ========================================= */
header {
    background-color: var(--white-glass);
    border-bottom: 1px solid var(--border);
    height: 60px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo { font-size: 1.5rem; font-weight: 800; text-decoration: none; color: var(--text); text-transform: uppercase; }
.logo span { color: var(--primary); }

.btn-login {
    color: var(--primary);
    font-weight: bold;
    text-decoration: none;
    border: 1px solid var(--primary);
    padding: 4px 12px;
    border-radius: 4px;
    transition: background 0.2s;
}
.btn-login:hover { background-color: rgba(0, 123, 255, 0.1); }

/* =========================================
   3. LAYOUT & TEXTE
   ========================================= */
.main-wrapper {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
    flex: 1;
    padding: 2rem 0;
    display: flex;
    flex-direction: column;
    /* align-items: center; <- Deaktiviert, stört manchmal bei voller Breite */
}

.page-header {
    text-align: center;
    max-width: 800px;
    margin: 0 auto 3rem auto;
}

.page-header h1 {
    font-size: 2.5rem;
    color: var(--text);
    margin-bottom: 1rem;
    font-weight: 800;
    opacity: 0;
    animation: fadeInUp 0.6s ease-out forwards;
}

.text-primary { color: var(--primary) !important; }

.welcome-text, .page-header p {
    font-size: 1.1rem;
    line-height: 1.6;
    color: #555;
    text-align: left; /* Ggf. center für Header p? */
    opacity: 0;
    animation: fadeInUp 0.6s ease-out forwards;
    animation-delay: 0.2s;
}
.page-header p { text-align: center; } /* Spezifischer Fix für Header */

.text-center { text-align: center; }

.badge { 
    background: var(--primary); 
    color: #fff; 
    padding: 4px 12px; 
    border-radius: 20px; 
    font-size: 0.8rem; 
    font-weight: bold; 
    text-transform: uppercase;
    display: inline-block;
    margin-bottom: 0.5rem;
    opacity: 0;
    animation: fadeInUp 0.6s ease-out forwards;
}

/* =========================================
   4. GRID & KATEGORIE-KACHELN (Original)
   ========================================= */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
    width: 100%;
    padding: 1rem 0;
}

.card-item {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    height: 100%;
    opacity: 0;
    animation: fadeInUp 0.6s ease-out forwards;
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), 
                box-shadow 0.3s cubic-bezier(0.25, 0.8, 0.25, 1),
                border-color 0.3s ease;
}

/* Animation Delays */
.card-item:nth-child(1) { animation-delay: 0.3s; }
.card-item:nth-child(2) { animation-delay: 0.4s; }
.card-item:nth-child(3) { animation-delay: 0.5s; }
.card-item:nth-child(4) { animation-delay: 0.6s; }
.card-item:nth-child(n+5) { animation-delay: 0.7s; }

.card-item:not(.disabled):hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.12);
    border-color: var(--primary);
}

.card-image {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #eee;
    border-bottom: 1px solid #f0f0f0;
}
.card-image img { width: 100%; height: 100%; object-fit: cover; }

.card-body { padding: 1.5rem; flex-grow: 1; display: flex; flex-direction: column; }
.card-body h3, .card-body h2 { margin: 0 0 0.5rem 0; color: var(--primary); font-size: 1.3rem; }
.card-body p { margin: 0; font-size: 0.95rem; color: #666; line-height: 1.5; }
.card-icon { font-size: 2.5rem; margin-bottom: 1rem; display: block; }

.card-footer {
    padding: 1rem 1.5rem;
    background: #f8f9fa;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--primary);
    transition: background 0.3s ease;
}
.card-item:hover .card-footer { background: #eef6ff; }
.card-item.disabled { background: #f9f9f9; opacity: 0.6; cursor: not-allowed; }

/* =========================================
   5. NEU: LEKTIONS-KARTEN (subject.php)
   ========================================= */
.lesson-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    position: relative;
    height: 100%;
}

.lesson-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.12);
    border-color: var(--primary);
}

.card-hero {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    overflow: hidden;
}

.card-hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
    display: block;
}

.lesson-card:hover .card-hero img { transform: scale(1.05); }

.hero-overlay {
    position: absolute;
    bottom: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(to bottom, transparent 40%, rgba(0,0,0,0.6) 70%, rgba(0,0,0,0.9) 100%);
    display: flex; align-items: flex-end;
    padding: 1.2rem;
    pointer-events: none;
}

.hero-title {
    color: #fff;
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.3;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
    z-index: 2;
}

.card-preview {
    font-size: 0.95rem;
    color: #555;
    line-height: 1.5;
    margin-bottom: 1rem;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* =========================================
   6. NEU: LEKTIONS-PLAYER (view_lesson.php)
   ========================================= */
.lesson-player {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 1200px;
    height: auto;
    min-height: 600px;
    display: flex;
    flex-direction: column;
    overflow: visible;
    animation: fadeInUp 0.5s ease-out forwards;
    margin: 0 auto;
    position: relative;
    transition: min-height 0.3s ease;
    padding-bottom: 40px; 
}

.lesson-header-bar {
    flex: 0 0 auto;
    padding: 0.8rem 1.5rem;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    font-size: 0.9rem;
    border-radius: 12px 12px 0 0;
}
.lesson-badge { background: var(--primary); color: #fff; padding: 3px 10px; border-radius: 15px; font-weight: bold; text-transform: uppercase; font-size: 0.75rem; }
.lesson-progress { color: #888; font-weight: 600; }

.lesson-body { display: flex; flex: 1; align-items: stretch; }

.content-main {
    flex: 2;
    min-width: 300px;
    border-right: 1px solid #eee;
    display: flex;
    flex-direction: column;
    height: auto;
}

.image-stage {
    flex: 0 0 auto; width: 100%; aspect-ratio: 16 / 9;
    background: #000; overflow: hidden; position: relative;
}
.image-stage img { width: 100%; height: 100%; object-fit: cover; display: block; }

.image-overlay {
    position: absolute; bottom: 0; left: 0; width: 100%;
    background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.5) 50%, transparent 100%);
    padding: 4rem 1.5rem 1.5rem 1.5rem; pointer-events: none; display: flex; align-items: flex-end;
}
.image-overlay h2 {
    color: #fff; margin: 0; font-size: 1.6rem; font-weight: 800; line-height: 1.2;
    text-shadow: 0 2px 4px rgba(0,0,0,0.6); animation: fadeInUp 0.5s ease-out forwards;
}

.question-area { flex: 1; padding: 1.5rem 2rem; background: #fff; overflow: visible; height: auto; }
.question-area p { font-size: 1.1rem; line-height: 1.6; color: #444; margin-bottom: 1rem; }
.story-label { color: var(--primary); font-size: 0.85rem; text-transform: uppercase; font-weight: bold; display: block; margin-bottom: 0.5rem; }

.content-sidebar {
    flex: 1;
    min-width: 280px;
    padding: 2rem;
    background: #f9fbfd;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #eee;
    overflow: visible;
    height: auto;
    border-radius: 0 0 12px 0;
}

.info-box { background: #fff; border: 1px solid #e0e4e8; border-radius: 8px; padding: 1rem; margin-bottom: 1rem; }
.info-title { color: var(--primary); font-weight: bold; font-size: 0.9rem; margin-bottom: 0.5rem; display: block; }
.info-text { color: #666; font-size: 0.9rem; line-height: 1.5; margin: 0; }

.answer-list { display: flex; flex-direction: column; gap: 0.8rem; }
.btn-answer {
    background: #fff; border: 2px solid #e0e4e8; padding: 1rem; border-radius: 8px;
    text-align: left; font-size: 0.95rem; color: #555; cursor: pointer; transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}
.btn-answer:hover:not(:disabled) {
    border-color: var(--primary); transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.05); color: var(--primary);
}
.btn-answer:disabled { opacity: 0.6; cursor: default; transform: none; }
.btn-answer.status-correct { border-color: #28a745; background: var(--success-bg); color: var(--success-text); font-weight: bold; }
.btn-answer.status-wrong { border-color: #dc3545; background: var(--error-bg); color: var(--error-text); }

.feedback-box {
    margin-top: 1rem; padding: 1rem; border-radius: 6px; font-size: 0.9rem; line-height: 1.5;
    display: none; animation: fadeInUp 0.3s ease-out;
}
.feedback-box.is-correct { background: var(--success-bg); border-left: 4px solid #28a745; color: var(--success-text); }
.feedback-box.is-wrong { background: var(--error-bg); border-left: 4px solid #dc3545; color: var(--error-text); }

.sidebar-footer { 
    margin-top: auto; padding-top: 2rem; border-top: none; background: transparent; position: relative; z-index: 5;
}
.btn-action {
    background: var(--primary); color: #fff; border: none; width: 100%; padding: 14px;
    border-radius: 8px; font-size: 1rem; font-weight: bold; cursor: pointer;
    display: flex; justify-content: center; align-items: center; gap: 8px;
    transition: background 0.2s; box-shadow: 0 4px 10px rgba(0,123,255,0.2);
}
.btn-action:hover { background: var(--primary-hover); transform: translateY(-1px); }
.success-card { background: var(--success-bg); border:1px solid #c3e6cb; padding:1.5rem; text-align:center; border-radius:8px; margin-bottom:1rem; }

/* =========================================
   7. NEU: GLOBALE ELEMENTE (Footer & Verlauf)
   ========================================= */

/* Der Fade-Out Verlauf am unteren Bildschirmrand */
.bottom-gradient {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 80px;
    /* Verlauf von Transparent zur Hintergrundfarbe (hier #f4f7f9 aus --bg) */
    background: linear-gradient(to bottom, rgba(244, 247, 249, 0), rgba(244, 247, 249, 1));
    pointer-events: none;
    z-index: 99;
}

/* Transparenter Footer (keine Box mehr) */
footer {
    background: transparent;
    border: none;
    border-top: none; /* explizit */
    padding: 2rem 0;
    text-align: center;
    margin-top: auto;
    color: #888;
    position: relative;
    z-index: 100;
}
.footer-links a { color: #999; text-decoration: none; margin: 0 10px; font-size: 0.9rem; }
.back-link { margin-top: 3rem; text-decoration: none; color: #888; display: inline-block; transition: color 0.2s; }
.back-link:hover { color: var(--primary); }

/* --- MOBILE --- */
@media (max-width: 900px) {
    .grid-container { grid-template-columns: 1fr; }
    
    /* Lesson Player Mobile */
    .lesson-player { border: none; border-radius: 0; }
    .lesson-body { flex-direction: column; }
    .content-main { border-right: none; height: auto; }
    .image-stage { aspect-ratio: 16/9; }
    .image-overlay h2 { font-size: 1.3rem; padding-bottom: 1rem; }
    .question-area { height: auto; padding: 1.5rem; }
    .content-sidebar { height: auto; padding: 1.5rem; border-left:none; border-top:none; background: #fff; }
    .sidebar-footer { padding-bottom: 2rem; }
}
/* Animation für die Lektions-Karten */
.lesson-card {
    /* ... deine bestehenden Styles ... */
    
    /* Das hier fehlt für den Flug-Effekt: */
    opacity: 0; /* Erst unsichtbar machen */
    animation: fadeInUp 0.5s ease-out forwards;
}

/* Der "Regen"-Effekt (Verzögerung für jede Karte) */
.lesson-card:nth-child(1) { animation-delay: 0.1s; }
.lesson-card:nth-child(2) { animation-delay: 0.2s; }
.lesson-card:nth-child(3) { animation-delay: 0.3s; }
.lesson-card:nth-child(4) { animation-delay: 0.4s; }
.lesson-card:nth-child(5) { animation-delay: 0.5s; }
.lesson-card:nth-child(n+6) { animation-delay: 0.6s; }