:root {
    --bg-dark: #0a0a0c;
    --bg-card: #151520;
    --text-main: #ffffff;
    --text-muted: #a0a0b0;
    --accent-blue: #0088ff;
    --accent-dark-blue: #0055cc;
    --glass-bg: rgba(10, 10, 12, 0.8);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-glow: rgba(0, 136, 255, 0.15);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow-x: hidden;
    line-height: 1.6;
}

.glow-bg {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 50% 50%, rgba(0, 136, 255, 0.05) 0%, transparent 40%);
    z-index: -1;
    pointer-events: none;
}

h1, h2, h3, h4 {
    font-weight: 700;
}

a {
    color: var(--text-main);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--accent-blue);
}

/* Navbar */
.navbar {
    position: fixed;
    top: 0;
    width: 100%;
    padding: 20px 0;
    background: transparent;
    border-bottom: 1px solid transparent;
    z-index: 1200;
    transition: all 0.3s ease;
}

.navbar.scrolled {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

.logo-wrapper {
    display: flex;
    align-items: center;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-main);
}

.logo-text span {
    color: var(--accent-blue);
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-links li a {
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.nav-links li a:hover,
.nav-links li a.active {
    color: var(--text-main);
}

.menu-toggle {
    display: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-main);
}

/* Content */
.content {
    margin-top: 80px;
    min-height: calc(100vh - 80px);
}

/* Page Sections */
.page-section {
    padding: 4rem 20px;
    max-width: 1200px;
    margin: 0 auto;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 4rem 1rem 2rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: auto;
    margin-top: 10vh; /* Re-adjusted spacing */
}

#hero-logo-placeholder {
    width: 250px;
    height: 250px;
    margin-bottom: 3rem;
}

.hero-title {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.hero-subtitle {
    font-size: 1.2rem;
    color: var(--text-muted);
    max-width: 600px;
    margin-bottom: 2.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2.5rem;
    border-radius: 30px;
    font-weight: 600;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    outline: none;
    text-transform: none;
}

.btn-primary {
    background-color: var(--accent-blue);
    color: var(--text-main);
    box-shadow: 0 4px 15px rgba(0, 136, 255, 0.2);
}

.btn-primary:hover {
    background-color: var(--accent-dark-blue);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 136, 255, 0.4);
    color: var(--text-main);
}

/* Subjects Grid */
.subjects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
}

.subject-card {
    background: var(--bg-card);
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 2rem;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.subject-card:hover {
    background: rgba(25, 25, 35, 0.8);
}

.subject-icon {
    font-size: 3rem;
    color: var(--accent-blue);
    margin-bottom: 1.5rem;
}

.subject-title {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-main);
}

.subject-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

.topics-placeholder {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 1rem;
    border: 1px dashed var(--glass-border);
}

.topics-placeholder ul {
    list-style-position: inside;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.topics-placeholder ul li {
    margin-bottom: 0.5rem;
}

.section-header {
    margin-bottom: 3rem;
    text-align: center;
}

.section-title {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.section-subtitle {
    color: var(--text-muted);
    font-size: 1.2rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    border-top: 1px solid var(--glass-border);
    margin-top: 4rem;
    color: var(--text-muted);
}

/* Animations */
.fade-in {
    opacity: 0;
    filter: blur(10px);
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, filter 0.6s ease-out, transform 0.6s ease-out;
}

.fade-in.visible {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0);
}

.delay-100 { transition-delay: 100ms; }
.delay-200 { transition-delay: 200ms; }
.delay-300 { transition-delay: 300ms; }
.delay-400 { transition-delay: 400ms; }
.delay-500 { transition-delay: 500ms; }

/* Hover Animations for Cards */
.subject-card {
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.subject-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

/* Responsive */
@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }

    .nav-links {
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: var(--glass-bg);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        flex-direction: column;
        align-items: center;
        padding: 2rem 0;
        gap: 1.5rem;
        border-bottom: 1px solid var(--glass-border);
        clip-path: circle(0% at 100% 0);
        transition: clip-path 0.4s ease-out;
    }

    .nav-links.active {
        clip-path: circle(150% at 100% 0);
    }

    .hero-title {
        font-size: 2.5rem;
    }

    .hero-subtitle {
        font-size: 1.1rem;
        padding: 0 1rem;
    }

    #hero-logo-placeholder {
        width: 180px;
        height: 180px;
        margin-bottom: 2rem;
    }

    .section-title {
        font-size: 2rem;
    }

    .subjects-grid {
        grid-template-columns: 1fr;
    }
}

/* --- SPA and Animation Styles --- */

.spa-page {
    display: none;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.spa-page.active {
    display: block;
    opacity: 1;
}

/* Dynamic Logo transitions (from mdsonair.it) */
#dynamic-logo {
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid var(--accent-blue);
    box-shadow: 0 10px 40px rgba(0, 136, 255, 0.4);
    position: fixed;
    /* Must NEVER change position type so transitions don't break instantly */
    z-index: 10;
}

#dynamic-logo.logo-home {
    /* Home page large state - dynamically locked to the placeholder via JS CSS Variables */
    width: 250px;
    height: 250px;
    top: calc(var(--logo-home-top, 140px) - var(--scroll-y, 0px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}

#dynamic-logo.logo-nav {
    /* Nav bar small state - aligned nicely */
    position: fixed;
    width: 45px;
    height: 45px;
    top: 15px;
    left: max(calc((100vw - 1200px) / 2 + 20px), 20px);
    transform: translateX(0);
    box-shadow: 0 0 10px rgba(0, 136, 255, 0.4);
    border-width: 1px;
    z-index: 1300;
}

/* Enable smooth transitions ONLY when clicking nav links, NOT when scrolling */
body.is-transitioning #dynamic-logo {
    z-index: 9999 !important;
}

body.is-transitioning #dynamic-logo.logo-home {
    transition: all 0.6s cubic-bezier(0.25, 0.8, 0.25, 1), z-index 0s 0s;
}

body.is-transitioning #dynamic-logo.logo-nav {
    transition: all 0.6s cubic-bezier(0.25, 0.8, 0.25, 1), z-index 0s 0s;
}

body.home-active .logo-text {
    opacity: 1;
    margin-left: 0;
}

body:not(.home-active) .logo-text {
    opacity: 1;
    margin-left: 60px;
}

.logo-text {
    transition: margin-left 0.6s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: inline-block;
}

@media (max-width: 768px) {
    #dynamic-logo.logo-home {
        width: 180px;
        height: 180px;
    }
    #dynamic-logo.logo-nav {
        width: 35px;
        height: 35px;
        top: 18px;
        left: 20px;
    }
    body:not(.home-active) .logo-text {
        margin-left: 50px;
    }
}

/* Sequential Animation Classes for Subjects */
.subject-card {
    /* Initial state for the SPA animation */
    opacity: 0;
    filter: blur(10px);
    transform: translateX(-20px);
    transition: opacity 0.6s ease, filter 0.6s ease, transform 0.6s ease;
}

.subject-card.focused {
    opacity: 1;
    filter: blur(0);
    transform: translateX(0);
}

/* Also for cards on the home page, so they can animate too */
#home .subject-card {
    opacity: 0;
    filter: blur(10px);
    transform: translateX(-20px);
    transition: opacity 0.6s ease, filter 0.6s ease, transform 0.6s ease;
}
#home .subject-card.focused {
    opacity: 1;
    filter: blur(0);
    transform: translateX(0);
}

/* Full page subject content animation */
.subject-page-content {
    opacity: 0;
    filter: blur(10px);
    transform: translateY(-30px);
    transition: opacity 0.6s ease, filter 0.6s ease, transform 0.6s ease;
}

.subject-page-content.focused {
    opacity: 1;
    filter: blur(0);
    transform: translateY(0);
}
