/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=Merriweather:wght@400;700&family=Roboto+Slab:wght@400;700&display=swap');

/* Variables */
:root {
    --primary-color: #6A0032;
    --secondary-color: #F5C78B;
    --background-color: #1A1A1A;
    --text-color: #E0E0E0;
    --accent-color: #A3004C; /* A richer purple for accents */
    --card-bg: #2A2A2A;
    --font-heading: 'Merriweather', serif;
    --font-body: 'Roboto Slab', serif;
    --paper-texture: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.8" numOctaves="3" stitchTiles="stitch"/></filter><rect width="100%" height="100%" fill="%23f5f5f5" filter="url(%23noise)" opacity="0.1"/></svg>');
}

/* General Styles */
body {
    margin: 0;
    font-family: var(--font-body);
    background-color: var(--background-color);
    color: var(--text-color);
    overflow-x: hidden; /* Prevent horizontal scroll */
    line-height: 1.6;
    letter-spacing: 0.5px;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--paper-texture);
    opacity: 0.05; /* Subtle grain */
    pointer-events: none;
    z-index: 9999;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    background-color: rgba(42, 42, 42, 0.8); /* Slightly transparent */
    backdrop-filter: blur(10px);
    border-right: 1px solid rgba(106, 0, 50, 0.3);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand-logo img {
    max-width: 100%;
    height: auto;
    display: block;
    margin-bottom: 40px;
}

.nav-links ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nav-links li {
    margin-bottom: 15px;
}

.nav-links a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 1.1em;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 8px;
    transition: all 0.3s ease;
    background-color: transparent;
}

.nav-links a i {
    font-size: 1.3em;
}

.nav-links a:hover,
.nav-links a.active {
    background-color: rgba(106, 0, 50, 0.2);
    color: var(--secondary-color);
    box-shadow: 0 4px 8px rgba(106, 0, 50, 0.2);
}

.user-profile-summary {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: auto; /* Push to bottom */
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-avatar img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--secondary-color);
}

.user-info .user-name {
    font-weight: 700;
    font-size: 1.1em;
    margin: 0 0 5px 0;
}

.user-info .user-level {
    font-size: 0.9em;
    color: rgba(224, 224, 224, 0.7);
    margin: 0;
}

.daily-streak {
    margin-top: 20px;
    background-color: rgba(106, 0, 50, 0.2);
    padding: 15px;
    border-radius: 10px;
    text-align: center;
}

.streak-label {
    font-size: 0.9em;
    color: rgba(224, 224, 224, 0.7);
    display: block;
    margin-bottom: 8px;
}

.streak-flame {
    font-size: 1.8em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.streak-flame .streak-count {
    font-weight: 700;
    color: var(--secondary-color);
}

.main-content {
    flex-grow: 1;
    padding: 0; /* Remove padding as hero section will handle it */
    overflow-y: auto;
    position: relative;
    display: grid;
    grid-template-columns: 1fr;
    gap: 50px;
}

/* Hero Section - New Styles */
.hero-section {
    position: relative;
    height: 100vh; /* Full viewport height */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; /* Ensure video stays within bounds */
    background-color: var(--background-color); /* Fallback color */
}

.background-video {
    position: absolute;
    top: 50%;
    left: 50%;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    transform: translateX(-50%) translateY(-50%);
    z-index: 1; /* Behind overlay */
    object-fit: cover; /* Cover the entire section */
}

.hero-overlay {
    position: relative;
    z-index: 2; /* On top of the video */
    text-align: center;
    color: var(--text-color);
    padding: 20px; /* Add some padding */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3); /* Optional subtle overlay to improve text readability */
}

.hero-overlay h1 {
    font-family: var(--font-heading);
    font-size: 4em;
    color: var(--secondary-color);
    margin-bottom: 15px;
    line-height: 1.1;
    text-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.hero-overlay p {
    font-size: 1.5em;
    margin-bottom: 40px;
    color: rgba(224, 224, 224, 0.9);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.hero-cta {
    font-size: 1.2em;
    padding: 15px 30px;
}

/* Styles moved from general sections to specific ones for clarity */
.section-title {
    font-family: var(--font-heading);
    font-size: 2.5em;
    color: var(--secondary-color);
    margin-bottom: 10px;
    text-align: center;
    line-height: 1.2;
    margin-top: 50px; /* Add margin above section titles */
}

.section-tagline {
    font-size: 1.2em;
    color: rgba(224, 224, 224, 0.8);
    text-align: center;
    margin-bottom: 40px;
    font-style: italic;
}

.cta-button {
    display: inline-block;
    background-color: var(--secondary-color);
    color: var(--primary-color);
    padding: 12px 25px;
    text-decoration: none;
    font-weight: 700;
    border-radius: 25px;
    transition: all 0.3s ease;
    border: 2px solid var(--secondary-color);
}

.cta-button:hover {
    background-color: var(--primary-color);
    color: var(--secondary-color);
    border-color: var(--primary-color);
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(245, 199, 139, 0.3);
}

/* Special CSS Effect: Vintage Paper Texture */
.sidebar,
.overview-card,
.subject-tile,
.tile-inner,
.tile-front,
.tile-back,
.vault-item,
.achievement-badge,
.leaderboard-widget,
.profile-card,
.xp-progress-bar-container, /* Also apply to XP bar container */
#quiz-container /* Apply to quiz container */ {
    position: relative;
    background-color: rgba(42, 42, 42, 0.8); /* Base card color */
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(15px);
}

.sidebar::before,
.overview-card::before,
.subject-tile::before,
.tile-inner::before,
.tile-front::before,
.tile-back::before,
.vault-item::before,
.achievement-badge::before,
.leaderboard-widget::before,
.profile-card::before,
.xp-progress-bar-container::before, /* Also apply to XP bar container */
#quiz-container::before /* Apply to quiz container */ {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--paper-texture);
    opacity: 0.05; /* Subtle grain */
    pointer-events: none;
    border-radius: inherit; /* Inherit from parent */
}


/* Dashboard Section */
.xp-progress-bar-container {
    margin-bottom: 50px;
    padding: 20px 30px;
}

.xp-label {
    font-size: 1em;
    color: rgba(224, 224, 224, 0.8);
    margin-bottom: 15px;
    font-weight: 700;
}

.xp-bar {
    height: 20px;
    background-color: rgba(106, 0, 50, 0.3);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.xp-fill {
    height: 100%;
    width: 60%; /* Placeholder: will be animated */
    background: linear-gradient(90deg, var(--secondary-color), var(--accent-color));
    border-radius: 10px;
    transition: width 0.8s ease-out;
}

.xp-milestone {
    position: absolute;
    top: 50%;
    left: 80%; /* Placeholder */
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    background-color: var(--secondary-color);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--secondary-color);
}

.xp-current {
    position: absolute;
    top: 50%;
    left: 85%; /* Adjust as needed */
    transform: translateY(-50%);
    font-size: 0.8em;
    color: var(--secondary-color);
    font-weight: 700;
    letter-spacing: 1px;
}

.journey-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
}

.overview-card {
    padding: 30px;
    text-align: center;
    border-radius: 15px;
}

.overview-card h3 {
    font-family: var(--font-heading);
    font-size: 1.6em;
    color: var(--secondary-color);
    margin-bottom: 15px;
}

.overview-card p {
    font-size: 1.1em;
    margin-bottom: 25px;
    color: rgba(224, 224, 224, 0.9);
}

.achievement-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
}

.achievement-preview .badge-icon {
    font-size: 1.8em;
}

.achievement-preview p {
    font-size: 1.1em;
    margin-bottom: 0;
    font-weight: 700;
}

/* Subject Expeditions Section */
.subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 30px;
}

.subject-tile {
    cursor: pointer;
    perspective: 1000px;
    background-color: transparent; /* Transparent to allow tile-inner to have bg */
    border: none;
    box-shadow: none;
    border-radius: 15px;
}

.subject-tile::before { /* Remove paper texture from tile base */
    display: none;
}

.tile-inner {
    position: relative;
    width: 100%;
    height: 280px;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    background-color: transparent; /* Transparent to allow front/back to have bg */
    border: none;
    box-shadow: none;
}

.tile-front,
.tile-back {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 25px;
    border-radius: 15px;
    background-color: var(--card-bg); /* Applied here for flip */
    border: 1px solid rgba(255, 255, 255, 0.08); /* Border for front/back */
}

.tile-front {
    z-index: 2;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
}

.tile-front .subject-icon {
    font-size: 3em;
    margin-bottom: 15px;
}

.tile-front .subject-title {
    font-family: var(--font-heading);
    font-size: 1.8em;
    color: var(--secondary-color);
    margin-bottom: 10px;
}

.tile-front .subject-progress {
    font-size: 1.2em;
    font-weight: 700;
    color: var(--text-color);
}

.tile-back {
    transform: rotateY(180deg);
    background-color: var(--card-bg);
    background: linear-gradient(135deg, var(--card-bg), rgba(40, 40, 40, 0.9));
}

.tile-back h4 {
    font-family: var(--font-heading);
    font-size: 1.4em;
    color: var(--secondary-color);
    margin-bottom: 15px;
}

.tile-back ul {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
    margin-bottom: 20px;
}

.tile-back li {
    margin-bottom: 8px;
    color: rgba(224, 224, 224, 0.9);
    font-size: 1em;
    position: relative;
    padding-left: 20px;
}

.tile-back li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--secondary-color);
    font-weight: 700;
}

.progress-ring {
    position: relative;
    width: 80px;
    height: 80px;
    margin-top: 20px;
}

.progress-ring circle {
    transition: stroke-dashoffset 0.8s ease-out;
    transform: rotate(-90deg) translate(0px, -100px); /* Rotated and centered */
}

.progress-ring .progress-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.4em;
    font-weight: 700;
    color: var(--secondary-color);
}

.subject-tile:hover .tile-inner {
    transform: rotateY(180deg);
}

/* Knowledge Vault Section */
.vault-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

.vault-item {
    padding: 30px;
    border-radius: 15px;
}

.vault-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.vault-item .vault-icon {
    font-size: 2.5em;
    color: var(--secondary-color);
}

.vault-item h4 {
    font-family: var(--font-heading);
    font-size: 1.6em;
    color: var(--secondary-color);
    margin: 0;
}

.vault-item p {
    font-size: 1.05em;
    margin-bottom: 25px;
    color: rgba(224, 224, 224, 0.8);
}

.vault-link {
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: 700;
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 3px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.vault-link:hover {
    color: var(--text-color);
    border-color: var(--text-color);
}

#view-universe-btn {
    background: none;
    border: none;
    padding: 0;
    font-size: 1em;
    cursor: pointer;
}

/* Mastery Archives Section */
.achievements-shelf {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 30px;
    padding: 20px;
}

.badge-container {
    position: relative;
    width: 180px; /* Fixed width for the container */
    height: 180px; /* Fixed height */
    display: flex;
    justify-content: center;
    align-items: center;
    transform-style: preserve-3d;
    perspective: 1000px;
}

.achievement-badge {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    border-radius: 50%; /* Circular badges */
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--primary-color) 100%);
    box-shadow: 0 10px 25px rgba(106, 0, 50, 0.5);
    border: none; /* Remove border to let shadow show */
    cursor: pointer;
    transition: transform 0.4s ease, box-shadow 0.4s ease;
    overflow: hidden;
}

.achievement-badge:hover {
    transform: translateY(-10px) scale(1.05);
    box-shadow: 0 15px 35px rgba(106, 0, 50, 0.7);
}

.achievement-badge::before { /* Remove paper texture from badge base */
    display: none;
}

/* Embossed Holographic Effect */
.embossed-holographic {
    position: relative;
    background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05)); /* Base glow */
    filter: brightness(1.2) saturate(1.5); /* Enhanced colors */
    animation: holographic-pulse 4s infinite ease-in-out;
    border-radius: 50%; /* Ensure it's circular */
    overflow: hidden;
}

.embossed-holographic::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.3) 50%, transparent 70%);
    background-size: 200% 200%;
    animation: holographic-shimmer 6s infinite linear;
    pointer-events: none;
}

@keyframes holographic-pulse {
    0%, 100% {
        filter: brightness(1.2) saturate(1.5);
        opacity: 1;
    }
    50% {
        filter: brightness(1.1) saturate(1.3);
        opacity: 0.9;
    }
}

@keyframes holographic-shimmer {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}


.achievement-badge .badge-icon {
    font-size: 3.5em;
    margin-bottom: 10px;
    color: var(--secondary-color);
    text-shadow: 0 0 5px var(--secondary-color), 0 0 15px var(--secondary-color);
}

.achievement-badge .badge-text {
    text-align: center;
    font-family: var(--font-heading);
    color: var(--text-color);
    font-weight: 700;
}

.achievement-badge .badge-text p {
    margin: 0 0 5px 0;
    font-size: 1.1em;
    line-height: 1.1;
}

.achievement-badge .badge-text span {
    font-size: 0.85em;
    color: rgba(224, 224, 224, 0.8);
}

/* Leaderboards Section */
.leaderboard-widget {
    padding: 30px;
    max-width: 600px;
    margin: 0 auto;
}

.leaderboard-widget h3 {
    font-family: var(--font-heading);
    font-size: 1.8em;
    color: var(--secondary-color);
    text-align: center;
    margin-bottom: 25px;
}

.leaderboard-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.leader-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    margin-bottom: 10px;
    border-radius: 10px;
    transition: background-color 0.3s ease;
}

.leader-item:hover {
    background-color: rgba(106, 0, 50, 0.1);
}

.leader-item.current-user {
    background-color: var(--primary-color);
    box-shadow: 0 0 15px var(--primary-color);
    border: 1px solid var(--secondary-color);
}

.leader-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.leader-info img {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--secondary-color);
}

.leader-info span {
    font-size: 1.1em;
    font-weight: 500;
}

.leader-score {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--secondary-color);
}

.leader-item.current-user .leader-score {
    color: var(--text-color);
}

.leader-item.current-user .leader-info span {
    font-weight: 700;
}

/* Profile Section */
.profile-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
}

.profile-card {
    padding: 30px;
}

.profile-avatar {
    display: block;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin: 0 auto 20px auto;
    border: 3px solid var(--secondary-color);
}

.profile-card h3 {
    font-family: var(--font-heading);
    font-size: 1.8em;
    color: var(--secondary-color);
    text-align: center;
    margin-bottom: 10px;
}

.profile-card p {
    text-align: center;
    font-size: 1.1em;
    color: rgba(224, 224, 224, 0.8);
    margin-bottom: 15px;
}

.edit-profile-btn {
    display: block;
    width: fit-content;
    margin: 25px auto 0 auto;
    background-color: var(--primary-color);
    color: var(--secondary-color);
    padding: 10px 20px;
    border: 2px solid var(--secondary-color);
    border-radius: 20px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.3s ease;
}

.edit-profile-btn:hover {
    background-color: var(--secondary-color);
    color: var(--primary-color);
    box-shadow: 0 4px 8px rgba(245, 199, 139, 0.3);
}

.profile-card h4 {
    font-family: var(--font-heading);
    font-size: 1.4em;
    color: var(--secondary-color);
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding-bottom: 10px;
}

.preference-item {
    margin-bottom: 15px;
}

.preference-item label {
    font-weight: 700;
    color: var(--secondary-color);
    display: block;
    margin-bottom: 5px;
}

.preference-item span {
    color: rgba(224, 224, 224, 0.9);
    font-size: 1.05em;
}

/* Live Quiz Module */
.live-quiz-module {
    background: linear-gradient(135deg, var(--primary-color) 0%, rgba(106, 0, 50, 0.7) 50%, var(--primary-color) 100%);
    padding: 50px 30px;
    border-radius: 15px;
    position: relative;
    overflow: hidden; /* For confetti */
    margin-top: 50px; /* Add margin above this section */
}

.live-quiz-module::before { /* Remove paper texture for dynamic module */
    display: none;
}

#quiz-container {
    text-align: center;
    max-width: 700px;
    margin: 0 auto;
    padding: 30px;
    background-color: rgba(42, 42, 42, 0.9);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#quiz-question-area {
    margin-bottom: 30px;
}

.kinetic-typography-container h3 {
    font-family: var(--font-heading);
    font-size: 2.2em;
    color: var(--secondary-color);
    margin-bottom: 20px;
    opacity: 0; /* Initially hidden */
    transform: translateY(20px); /* Start slightly down */
    animation: reveal-text 1s ease-out forwards;
}

@keyframes reveal-text {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.countdown-timer {
    position: relative;
    width: 100px;
    height: 100px;
    margin: 20px auto;
}

.watch-face {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 5px solid var(--secondary-color);
    border-radius: 50%;
    background-color: rgba(25, 25, 25, 0.5);
}

.watch-face::before { /* Small center dot */
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 15px;
    height: 15px;
    background-color: var(--secondary-color);
    border-radius: 50%;
    z-index: 10;
}

.hand {
    position: absolute;
    bottom: 50%;
    left: 50%;
    transform-origin: bottom center;
    background-color: var(--secondary-color);
    z-index: 5;
}

.hand.hour {
    width: 6px;
    height: 25px;
    border-radius: 3px;
    animation: rotate-hour 12s linear infinite; /* Slower rotation */
}

.hand.minute {
    width: 4px;
    height: 35px;
    border-radius: 2px;
    animation: rotate-minute 60s linear infinite;
}

.hand.second {
    width: 2px;
    height: 45px;
    background-color: var(--text-color);
    animation: rotate-second 1s linear infinite;
}

#timer-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.3em;
    font-weight: 700;
    color: var(--secondary-color);
    z-index: 11;
}

@keyframes rotate-hour {
    from { transform: translate(-50%, 0) rotate(0deg); }
    to { transform: translate(-50%, 0) rotate(360deg); }
}

@keyframes rotate-minute {
    from { transform: translate(-50%, 0) rotate(0deg); }
    to { transform: translate(-50%, 0) rotate(360deg); }
}

@keyframes rotate-second {
    from { transform: translate(-50%, 0) rotate(0deg); }
    to { transform: translate(-50%, 0) rotate(360deg); }
}

#quiz-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-top: 30px;
}

.quiz-option {
    background-color: var(--card-bg);
    color: var(--text-color);
    padding: 15px 20px;
    border: 2px solid var(--primary-color);
    border-radius: 10px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 700;
}

.quiz-option:hover {
    background-color: var(--primary-color);
    color: var(--secondary-color);
    border-color: var(--secondary-color);
    transform: translateY(-3px);
}

.quiz-option.correct {
    background-color: rgba(85, 239, 196, 0.7); /* Green */
    border-color: #55efc4;
    color: var(--background-color);
}

.quiz-option.incorrect {
    background-color: rgba(255, 99, 71, 0.7); /* Red */
    border-color: #ff6347;
    color: var(--background-color);
}

#quiz-feedback {
    margin-top: 25px;
    font-size: 1.2em;
    font-weight: 700;
    min-height: 2em;
}

/* Confetti Animation */
#confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 100;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: var(--secondary-color);
    opacity: 0;
    animation: fall 2s forwards;
}

.confetti.green { background-color: #55efc4; }
.confetti.red { background-color: #ff6347; }
.confetti.purple { background-color: var(--primary-color); }
.confetti.amber { background-color: var(--secondary-color); }

@keyframes fall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(calc(var(--vh, 1vh) * 100 + 100px)) rotate(720deg);
        opacity: 0;
    }
}

/* The Grand Library Section - Parallax */
.the-grand-library-section {
    padding: 0; /* Remove padding to allow parallax to fill */
    background-color: transparent;
    box-shadow: none;
    border: none;
    margin-top: 50px; /* Add margin above section */
}

.the-grand-library-section::before { /* Remove paper texture for library */
    display: none;
}

.library-parallax-container {
    width: 100%;
    height: 60vh; /* Adjust height as needed */
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--secondary-color);
    text-align: center;
    border-radius: 15px; /* Apply to container */
}

.parallax-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
}

.layer-back {
    background-image: url('https://images.unsplash.com/photo-1521120138990-0f2062397582?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80'); /* Dark library background */
    transform: translateZ(-2px) scale(1.5); /* Move back and scale up */
    z-index: 0;
}

.layer-middle {
    background-image: url('https://images.unsplash.com/photo-1495457038775-bf9115730694?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80'); /* Bookshelves */
    transform: translateZ(-1px) scale(1.25); /* Move back and scale up */
    z-index: 1;
    opacity: 0.8;
}

.layer-front {
    background-image: url('https://images.unsplash.com/photo-1472214103451-bf9115730694?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80'); /* Subtle ambient light */
    background-blend-mode: overlay;
    background-color: rgba(106, 0, 50, 0.4);
    z-index: 2;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--secondary-color);
    text-shadow: 0 0 10px var(--primary-color);
}

.library-content {
    padding: 50px;
    background-color: rgba(42, 42, 42, 0.7);
    border-radius: 15px;
    max-width: 600px;
    font-size: 1.2em;
    line-height: 1.7;
    backdrop-filter: blur(5px);
}

/* 3D Model Viewer */
#model-viewer-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(26, 26, 26, 0.95);
    z-index: 10000;
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(20px);
}

#model-viewer-container.visible {
    display: flex;
}

#close-model-viewer {
    position: absolute;
    top: 30px;
    right: 30px;
    background: var(--primary-color);
    color: var(--secondary-color);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 2em;
    cursor: pointer;
    line-height: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}

#close-model-viewer:hover {
    background-color: var(--secondary-color);
    color: var(--primary-color);
    transform: rotate(90deg);
}

model-viewer {
    width: 80%;
    height: 80%;
    background-color: transparent;
}

/* Responsive Adjustments */
@media (max-width: 1200px) {
    .sidebar {
        width: 250px;
    }
    .hero-overlay h1 {
        font-size: 3.5em;
    }
    .hero-overlay p {
        font-size: 1.3em;
    }
    .main-content {
        padding: 0; /* Keep padding 0 for main content */
    }
    .section-title {
        font-size: 2.2em;
    }
    .section-tagline {
        font-size: 1.1em;
    }
}

@media (max-width: 992px) {
    .app-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        padding: 20px;
        position: relative;
        border-right: none;
        border-bottom: 1px solid rgba(106, 0, 50, 0.3);
        z-index: 100; /* Sidebar above main content when collapsed */
    }
    .user-profile-summary {
        margin-top: 0;
        padding-top: 15px;
        border-top: none;
    }
    .main-content {
        padding: 0; /* Keep padding 0 */
        gap: 40px;
    }
    .hero-section {
        height: 70vh; /* Reduce hero height on smaller screens */
    }
    .hero-overlay h1 {
        font-size: 3em;
    }
    .xp-progress-bar-container {
        margin-bottom: 30px;
    }
    .subject-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
    .tile-inner {
        height: 260px;
    }
    .vault-content,
    .profile-content {
        grid-template-columns: 1fr;
    }
    .live-quiz-module {
        padding: 40px 20px;
    }
    .library-parallax-container {
        height: 50vh;
    }
}

@media (max-width: 768px) {
    .hero-section {
        height: 60vh; /* Further reduce hero height */
    }
    .hero-overlay h1 {
        font-size: 2.5em;
    }
    .hero-overlay p {
        font-size: 1.1em;
        margin-bottom: 30px;
    }
    .hero-overlay .cta-button {
        padding: 12px 25px;
    }
    .section-title {
        font-size: 2em;
    }
    .section-tagline {
        font-size: 1em;
    }
    .overview-card,
    .vault-item,
    .profile-card,
    .leaderboard-widget {
        padding: 20px;
    }
    .subject-grid {
        grid-template-columns: 1fr;
    }
    .tile-front .subject-icon {
        font-size: 2.5em;
    }
    .tile-front .subject-title {
        font-size: 1.5em;
    }
    .live-quiz-module {
        padding: 30px 15px;
    }
    #quiz-container {
        padding: 20px;
    }
    .kinetic-typography-container h3 {
        font-size: 1.8em;
    }
    .countdown-timer {
        width: 80px;
        height: 80px;
    }
    #timer-display {
        font-size: 1.1em;
    }
    .quiz-option {
        padding: 12px 15px;
        font-size: 1em;
    }
    #close-model-viewer {
        top: 20px;
        right: 20px;
        width: 35px;
        height: 35px;
        font-size: 1.8em;
    }
}