/* ===== RESET & VARIABLES ===== */
:root {
    /* Theme Colors - Contract Law (Deep Blue/Purple Theme) */
    --primary: #1e3a8a; /* Deep Blue */
    --primary-dark: #1e40af; /* Darker Blue */
    --primary-light: #3b82f6; /* Light Blue */
    --secondary: #7c3aed; /* Purple accent */
    --accent: #f59e0b; /* Amber for highlights */
    
    /* Backgrounds */
    --bg-page: #f8fafc;
    --bg-card: #FFFFFF;
    
    /* Text */
    --text-dark: #111827;
    --text-grey: #6B7280;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-page);
    color: var(--text-dark);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* 1. LAYOUT CONTAINER */
.app-container {
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* 2. HEADER */
.content-header {
    background-color: #FFFFFF;
    width: 100%;
    padding: 20px 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #E5E7EB;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 99;
}

.header-left .main-title {
    font-family: 'Inter', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-dark);
}

.header-left .main-subtitle {
    font-size: 0.95rem;
    color: var(--text-grey);
    margin-top: 2px;
}

/* Header Right Side (Button + Logo) */
.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* Quiz Button Styles */
.quiz-btn {
    text-decoration: none;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.9rem;
    padding: 8px 18px;
    border: 2px solid var(--primary);
    border-radius: 8px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: transparent;
}

.quiz-btn:hover {
    background-color: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(30, 58, 138, 0.25);
}

/* Logo styling */
.header-logo {
    height: 60px; 
    width: auto;
    object-fit: contain;
}

/* 3. MAIN CONTENT */
.main-content {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 30px 5%;
    flex: 1;
}

/* 4. WELCOME OVERLAY */
.welcome-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.welcome-overlay.hidden {
    display: none;
}

.welcome-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 40px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    border: 3px solid var(--primary);
}

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

.welcome-icon {
    font-size: 4rem;
    color: var(--primary);
    margin-bottom: 20px;
}

.welcome-content h1 {
    color: var(--primary-dark);
    font-size: 2.5rem;
    margin-bottom: 25px;
    font-weight: 700;
}

.welcome-text {
    text-align: left;
    margin-bottom: 35px;
    line-height: 1.7;
    color: #444;
    font-size: 1.1rem;
}

.welcome-text p {
    margin-bottom: 20px;
    text-align: justify;
}

.immerse-button {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    padding: 18px 35px;
    font-size: 1.3rem;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(30, 58, 138, 0.4);
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
}

.immerse-button:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(30, 58, 138, 0.6);
}

/* 5. STATS SECTION */
.welcome-section {
    background: white;
    border-radius: 12px;
    padding: 25px 30px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
    display: block;
}

.stats-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 18px 15px;
    box-shadow: var(--shadow);
    text-align: center;
    transition: var(--transition);
    border: 1px solid #E5E7EB;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
}

.stat-number {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 6px;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-grey);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 6. RESUME SECTION */
#resume-container {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 12px;
    padding: 0;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
    border: 2px solid var(--primary-dark);
    color: white;
    position: relative;
    overflow: hidden;
}

#resume-container::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(30deg);
    z-index: 1;
}

.resume-button-simple {
    display: flex;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    padding: 25px 30px;
    text-decoration: none;
    font-size: 1em;
    font-weight: 500;
    transition: var(--transition);
    border: none;
    backdrop-filter: blur(10px);
    position: relative;
    z-index: 2;
    width: 100%;
    align-items: center;
    justify-content: center;
}

.resume-button-simple:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
}

.resume-simple-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 400px;
}

.resume-icon {
    font-size: 2rem;
    margin-right: 20px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.resume-text {
    flex: 1;
    text-align: left;
}

.resume-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: white;
}

.resume-subtitle {
    font-size: 1rem;
    opacity: 0.9;
    color: rgba(255, 255, 255, 0.9);
}

.resume-arrow {
    font-size: 1.5rem;
    margin-left: 20px;
    font-weight: bold;
    transition: transform 0.3s ease;
}

.resume-button-simple:hover .resume-arrow {
    transform: translateX(5px);
}

/* 7. CHAPTERS SECTION */
.section-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 35px 0 20px;
    text-align: center;
    position: relative;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: var(--primary);
    border-radius: 3px;
}

.chapters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding-bottom: 60px;
}

/* 8. CARD DESIGN */
.chapter-card {
    background: white;
    border-radius: 12px;
    padding: 22px 20px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
    border: 1px solid #E5E7EB;
    position: relative;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 150px;
}

.chapter-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
    border-color: var(--primary);
}

.chapter-icon {
    font-size: 1.8rem;
    color: var(--primary);
    margin-bottom: 12px;
}

.chapter-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 8px;
    line-height: 1.4;
}

.chapter-desc {
    font-size: 0.8rem;
    color: var(--text-grey);
    line-height: 1.4;
}

.chapter-count {
    font-size: 0.7rem;
    color: var(--primary);
    font-weight: 600;
    margin-top: 8px;
    padding: 3px 8px;
    background: rgba(30, 58, 138, 0.1);
    border-radius: 10px;
}

/* Top Color Strip */
.chapter-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 4px;
    background: #D1D5DB; 
    transition: 0.2s;
}

/* Colors mapped from JS (Contract Law Theme) */
.chapter-card.blue::before { background: #3B82F6; } /* Blue */
.chapter-card.teal::before { background: #10B981; } /* Teal */
.chapter-card.gold::before { background: #F59E0B; } /* Gold/Amber */
.chapter-card.slate::before { background: #7c3aed; } /* Purple */
.chapter-card.indigo::before { background: #4f46e5; } /* Indigo */

/* 9. FLOATING HOME BUTTON */
.floating-home-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-shadow: 0 6px 20px rgba(30, 58, 138, 0.4);
    transition: var(--transition);
    z-index: 1000;
    border: 2px solid white;
    animation: float 3s ease-in-out infinite;
}

.floating-home-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-5px) scale(1.1);
    box-shadow: 0 10px 25px rgba(30, 58, 138, 0.6);
    animation: none;
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-8px); }
    100% { transform: translateY(0px); }
}

/* 10. FOOTER */
footer {
    margin-top: auto;
    background: white;
    border-top: 1px solid #E5E7EB;
    text-align: center;
    padding: 25px;
    color: var(--text-grey);
    font-size: 0.9rem;
}

.heart {
    color: #e74c3c;
    animation: heartbeat 1.5s infinite;
}

@keyframes heartbeat {
    0% { transform: scale(1); }
    5% { transform: scale(1.1); }
    10% { transform: scale(1); }
    15% { transform: scale(1.1); }
    20% { transform: scale(1); }
    100% { transform: scale(1); }
}

/* ===== 11. MOBILE RESPONSIVENESS ===== */
@media (max-width: 768px) {
    /* Hide Logo & Stats on mobile */
    .header-logo { display: none !important; }
    .welcome-section { display: none !important; }
    
    /* Layout adjustments */
    .content-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
        padding: 20px;
    }

    /* Standardized Title First Order */
    .header-left {
        order: 1;
        width: 100%;
        padding-top: 0;
    }

    /* Standardized Button Second Order */
    .header-right {
        order: 2;
        width: 100%;
        justify-content: center;
        margin-top: 5px;
    }

    .quiz-btn {
        width: 100%; /* Full width button on mobile */
        justify-content: center;
        padding: 12px;
    }
    
    .main-content {
        padding: 20px;
        padding-top: 20px;
    }
    
    .chapters-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .section-title {
        margin-top: 20px;
        font-size: 1.4rem;
    }
    
    /* Resume section mobile */
    #resume-container {
        margin-bottom: 18px;
    }
    
    .resume-button-simple {
        padding: 20px 25px;
    }
    
    .resume-simple-content {
        max-width: 100%;
    }
    
    .resume-icon {
        font-size: 1.8rem;
        margin-right: 15px;
    }
    
    .resume-title {
        font-size: 1.2rem;
    }
    
    .resume-subtitle {
        font-size: 0.95rem;
    }
    
    /* Welcome overlay mobile */
    .welcome-container {
        padding: 25px;
    }
    
    .welcome-content h1 {
        font-size: 1.8rem;
    }
    
    .welcome-text {
        font-size: 1rem;
    }
    
    .immerse-button {
        padding: 15px 25px;
        font-size: 1.1rem;
    }
    
    /* Floating button mobile */
    .floating-home-btn {
        width: 55px;
        height: 55px;
        bottom: 20px;
        right: 20px;
    }
}

@media (max-width: 480px) {
    .content-header {
        padding: 15px 15px;
        gap: 12px;
    }
    
    .main-title {
        font-size: 1.3rem;
    }

    .main-subtitle {
        font-size: 0.8rem;
    }

    .main-content {
        padding: 15px;
    }

    .chapters-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .chapter-card {
        padding: 15px;
        min-height: 120px;
    }

    .chapter-icon {
        font-size: 1.3rem;
        margin-bottom: 8px;
    }

    .chapter-title {
        font-size: 0.85rem;
    }

    .chapter-desc {
        font-size: 0.7rem;
    }

    /* Very small screen floating button */
    .floating-home-btn {
        width: 50px;
        height: 50px;
        bottom: 15px;
        right: 15px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-page: #0f172a;
        --bg-card: #1e293b;
        --text-dark: #f1f5f9;
        --text-grey: #94a3b8;
    }
    
    .welcome-section, .stat-card, .chapter-card, footer, .content-header {
        background: #1e293b;
        color: #f1f5f9;
        border-color: #334155;
    }

    body {
        background-color: #0f172a;
        color: #f1f5f9;
    }

    .main-title, .section-title {
        color: #f1f5f9;
    }
    
    .chapter-card:hover {
        border-color: var(--primary);
    }
    
    #resume-container {
        background: linear-gradient(135deg, var(--primary-dark), #1e3a8a);
        border-color: var(--primary-dark);
    }
    
    .quiz-btn {
        color: #f1f5f9;
        border-color: var(--primary);
    }
    
    .quiz-btn:hover {
        background-color: var(--primary);
        color: white;
    }

    .floating-home-btn {
        background: var(--primary-dark);
        border: 2px solid #1e293b;
    }
    
    .stat-label, .main-subtitle, .chapter-desc, footer {
        color: #94a3b8;
    }

    .stat-number {
        color: var(--primary-light);
    }

    .chapter-icon {
        color: var(--primary-light);
    }
    
    .chapter-count {
        background: rgba(59, 130, 246, 0.2);
        color: var(--primary-light);
    }
    
    /* Welcome overlay dark mode */
    .welcome-container {
        background: #1e293b;
        border-color: var(--primary);
    }
    
    .welcome-content h1 {
        color: #f1f5f9;
    }
    
    .welcome-text {
        color: #cbd5e1;
    }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .heart, .floating-home-btn, .resume-icon {
        animation: none;
    }
    
    .resume-button-simple:hover .resume-arrow {
        transform: none;
    }
}