/* --- CSS VARIABLES --- */
:root {
    /* Theme Colors */
    --bg-color: #121214;       
    --surface-color: #1c1c1f;  
    --primary-color: #3b82f6;  
    --primary-hover: #2563eb;
    --text-main: #ffffff;
    --text-secondary: #a1a1aa;
    
    /* Brand Colors */
    --roblox-color: #EEEEEE; 
    --discord-color: #5865F2;

    /* Dimensions */
    --nav-height: 80px; 
    --border-radius: 12px;

    /* 
       THE MASTER TINT COLOR
       This controls the darkness of the bottom half of the site.
       0.6 = 60% opacity.
    */
    --section-dim-color: rgba(18, 18, 20, 0.6); 
}

/* --- GLOBAL RESET --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scroll-behavior: smooth;
}

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

a {
    text-decoration: none;
    color: inherit;
    transition: 0.3s ease;
}

ul {
    list-style: none;
}

/* --- NAVIGATION --- */
.navbar {
    position: fixed;
    top: 0;
    width: 100%;
    height: var(--nav-height);
    /* Glass effect for navbar */
    background-color: rgba(18, 18, 20, 0.7);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 5%;
    z-index: 100;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.studio-logo {
    width: 40px; 
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.studio-name {
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: -0.5px;
}

.nav-links {
    display: flex;
    gap: 30px;
}

.nav-links a {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
}

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

/* --- GLOBAL FIXED BACKGROUND EFFECTS (ORBS) --- */
.global-background-effects {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    /* Z-Index 0: On top of body color, behind transparent content */
    z-index: 0; 
    pointer-events: none; 
    overflow: hidden;
}

.glow-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(90px); 
    /* 0.25 opacity ensures they aren't too overpowering */
    opacity: 0.25; 
    mix-blend-mode: screen; 
    will-change: transform; 
}

/* --- CONTENT SECTIONS (Layer 1) --- */
.hero, 
.games-section, 
.find-me-section, 
.footer {
    position: relative;
    z-index: 1;
}

/* 
   --- UNIFIED BACKGROUND SECTION --- 
   This is the critical part for consistency.
   It applies the exact same color to Games, Find Me, and Footer
   so there are no seams or color differences.
*/
.games-section, 
.find-me-section, 
.footer {
    background-color: var(--section-dim-color);
    backdrop-filter: blur(10px); 
    
    /* Pulls sections together to hide hairline cracks */
    margin-top: -1px; 
    
    /* Removes borders that might cause visible lines */
    border-top: none;
    border-bottom: none;
    box-shadow: none;
}

/* --- HERO SECTION --- */
.hero {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0 20px;
    overflow: hidden;
    background-color: transparent;
}

.hero-marquee-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1; 
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 20px;
    opacity: 1; 
    overflow: hidden;
    transform: rotate(-3deg) scale(1.1); 
    pointer-events: auto;
}

.marquee-row {
    display: flex;
    width: 100%;
    position: relative;
    
    /* CHANGED: Was 'hidden', change to 'visible' so items can pop out */
    overflow: visible; 
}

.marquee-track {
    display: flex;
    gap: 20px;
    width: max-content;
    will-change: transform;
}

.marquee-left {
    animation: scrollLeft 40s linear infinite;
}

.marquee-right {
    /* CHANGED: Increased from 40s to 65s so the middle row is slower */
    animation: scrollRight 65s linear infinite;
}

@keyframes scrollLeft {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

@keyframes scrollRight {
    0% { transform: translateX(-50%); }
    100% { transform: translateX(0); }
}

.marquee-item {
    width: 300px;
    height: 169px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    transition: all 0.3s ease;
    cursor: default;
    opacity: 0.5; 
}

.marquee-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.marquee-item:hover {
    transform: scale(1.1);
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.8); 
    z-index: 10;
    opacity: 1; 
}

/* 
   HERO OVERLAY
   Uses Linear Gradient to transition perfectly into the unified color
*/
.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0; 
    pointer-events: none;
    
    background: linear-gradient(
        to bottom, 
        rgba(18, 18, 20, 0) 0%, 
        rgba(18, 18, 20, 0.2) 60%, 
        var(--section-dim-color) 100%
    );
}

.hero-content {
    position: relative;
    z-index: 2; 
}

.hero-content h1 {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 20px;
    line-height: 1.25; 
    padding-bottom: 0.1em; 
    
    /* Gradient text settings */
    background: linear-gradient(to right, #ffffff, #99c2ff);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;

    /* ADDED: Drop shadow filter to make text pop against the moving images */
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.8));
}

.hero-content p {
    /* CHANGED: Text is now white instead of gray */
    color: #ffffff; 
    font-size: 1.1rem;
    margin-bottom: 40px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    
    /* ADDED: Drop shadow to make white text readable on bright images */
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.cta-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.btn {
    padding: 12px 28px;
    border-radius: 50px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    
    /* ADDED: These lines force the text to be perfectly centered */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    /* CHANGED: Now a solid color (Dark Gray) to match the "filled" style of the blue one */
    background-color: #27272a; 
    color: white;
    border: none; /* Removed the border to match the clean look of the blue button */
    
    /* ADDED: Matching shadow */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.btn-secondary:hover {
    /* Lighten slightly on hover */
    background-color: #3f3f46;
    transform: translateY(-2px);
}

/* --- GAMES SECTION --- */
.games-section {
    padding: 100px 5%;
    min-height: 600px;
    padding-bottom: 80px;
    /* NOTE: Background color removed here, handled by Unified Block above */
}

.stats-container {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.stat-box {
    text-align: center;
    background: rgba(255, 255, 255, 0.03);
    padding: 15px 30px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    min-width: 180px;
    backdrop-filter: blur(5px);
}

.stat-number {
    display: block;
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.section-header {
    text-align: center;
    margin-bottom: 60px;
}

.section-header h2 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.section-header .divider {
    height: 4px;
    width: 60px;
    background-color: var(--primary-color);
    margin: 0 auto;
    border-radius: 2px;
}

.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-top: 50px;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(59, 130, 246, 0.1);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    100% { transform: rotate(360deg); }
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;
}

.game-card {
    /* Making cards slightly transparent to blend with environment */
    background-color: rgba(28, 28, 31, 0.8);
    backdrop-filter: blur(10px);
    border-radius: var(--border-radius);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(255,255,255,0.05);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.game-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border-color: var(--primary-color);
}

.card-image {
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    background-color: #222;
    position: relative;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-content {
    padding: 25px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.card-content h3 {
    font-size: 1.4rem;
    margin-bottom: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-stats {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.game-stats span i {
    color: var(--primary-color);
    margin-right: 5px;
}

.card-content p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
    flex-grow: 1;
    display: -webkit-box;
    line-clamp: 3;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.play-btn {
    display: inline-block;
    width: 100%;
    padding: 10px;
    text-align: center;
    background-color: rgba(59, 130, 246, 0.1);
    color: var(--primary-color);
    border-radius: 8px;
    font-weight: 600;
    margin-top: auto;
}

.play-btn:hover {
    background-color: var(--primary-color);
    color: white;
}

.roblox-btn-icon {
    width: 20px;
    height: 20px;
    vertical-align: middle;
    margin-right: 8px;
    margin-bottom: 2px;
    filter: brightness(0) invert(1);
    display: inline-block;
}

/* --- FIND ME SECTION --- */
.find-me-section {
    padding: 80px 5%;
    padding-bottom: 80px;
    /* NOTE: Background color removed here, handled by Unified Block above */
}

.find-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    max-width: 900px;
    margin: 0 auto;
}

.find-card {
    display: flex;
    align-items: center;
    padding: 25px;
    /* Semi-transparent cards */
    background-color: rgba(28, 28, 31, 0.8);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 16px;
    transition: all 0.3s ease;
}

.find-card:hover {
    transform: translateY(-5px);
    border-color: rgba(255,255,255,0.2);
}

.find-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-right: 20px;
}

.find-svg {
    width: 30px;
    height: 30px;
    filter: brightness(0) invert(1);
    display: block;
}

.find-info h3 {
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.find-info span {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.find-arrow {
    margin-left: auto;
    color: var(--text-secondary);
    transition: 0.3s;
}

.find-card:hover .find-arrow {
    transform: translateX(5px);
    color: white;
}

.roblox-card:hover .find-icon {
    background-color: var(--text-main);
}
.roblox-card .find-icon {
    background-color: rgba(255,255,255,0.1);
}

.roblox-card:hover .find-svg {
    filter: brightness(0);
}

.discord-card:hover .find-icon {
    background-color: var(--discord-color);
    color: white;
}
.discord-card .find-icon {
    background-color: rgba(88, 101, 242, 0.1);
    color: var(--discord-color);
}

/* --- FOOTER --- */
.footer {
    padding: 40px 5%;
    /* NOTE: Background color removed here, handled by Unified Block above */
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    flex-wrap: wrap;
    gap: 20px;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.copyright {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* --- TOAST NOTIFICATIONS (TOP + BOUNCE) --- */
#toast-container {
    position: fixed;
    top: 30px; /* Moved to top */
    left: 50%;
    transform: translateX(-50%); /* Center it horizontally */
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    width: 90%;
    max-width: 450px;
}

.toast {
    background-color: #1c1c1f;
    color: #fff;
    padding: 16px 20px;
    border-radius: 12px;
    border-left: 4px solid var(--primary-color);
    box-shadow: 0 10px 40px rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    gap: 15px;
    pointer-events: auto;
    font-size: 0.95rem;
    font-weight: 500;
    
    /* Prepare for animation */
    opacity: 0;
    
    /* The Bounce Effect */
    animation: toastBounceIn 0.6s cubic-bezier(0.68, -0.55, 0.27, 1.55) forwards;
}

/* Bounce Animation Keyframes */
@keyframes toastBounceIn {
    0% {
        opacity: 0;
        transform: translateY(-50px) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Exit Animation */
.toast.hide {
    animation: toastFadeOut 0.5s ease forwards;
}

@keyframes toastFadeOut {
    0% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-20px); }
}

/* Error Specific Styles */
.toast.error {
    border-left-color: #ef4444; /* Red Border */
    background: linear-gradient(to right, rgba(239, 68, 68, 0.05), #1c1c1f 30%);
}

.toast-icon {
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast.error .toast-icon {
    color: #ef4444; /* Red Icon */
}

/* --- LOADER SCREEN --- */
#loader-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.8s ease-out, visibility 0.8s ease-out;
}

#loader-wrapper.loader-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.loader-logo {
    width: 120px;
    height: 120px;
    margin-bottom: 20px;
    animation: logoPulse 2s infinite ease-in-out;
}

.loader-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.loader-text {
    font-size: 1.2rem;
    color: var(--text-secondary);
    letter-spacing: 2px;
    font-weight: 600;
    text-transform: uppercase;
    animation: textFade 2s infinite ease-in-out;
    text-align: center;
}

@keyframes logoPulse {
    0%, 100% { opacity: 0.3; transform: scale(0.95); }
    50% { opacity: 1; transform: scale(1.05); }
}

@keyframes textFade {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* --- SCROLL REVEAL ANIMATIONS --- */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s ease-out;
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

.games-grid .game-card:nth-child(2) { transition-delay: 100ms; }
.games-grid .game-card:nth-child(3) { transition-delay: 200ms; }
.games-grid .game-card:nth-child(4) { transition-delay: 300ms; }

.hero-bg-static {
    display: none;
}

/* --- ANIMATION KEYFRAMES (For Orbs) --- */
@keyframes randomFloat {
    0% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(10vw, 10vh) scale(1.2); }
    50% { transform: translate(-5vw, 20vh) scale(0.9); }
    75% { transform: translate(-10vw, -10vh) scale(1.1); }
    100% { transform: translate(0, 0) scale(1); }
}

/* --- LENIS SMOOTH SCROLL REQUIRED CSS --- */
html.lenis {
    height: auto;
}
.lenis.lenis-smooth {
    scroll-behavior: auto !important;
}
.lenis.lenis-smooth [data-lenis-prevent] {
    overscroll-behavior: contain;
}
.lenis.lenis-stopped {
    overflow: hidden;
}

/* --- MOBILE RESPONSIVENESS --- */
@media (max-width: 768px) {
    .hero-content h1 { font-size: 2.5rem; }
    .nav-links { display: none; } 
    .footer-content { flex-direction: column; text-align: center; }
}

/* Add these optimizations to your existing style.css */

/* ===== PERFORMANCE-BASED ADJUSTMENTS ===== */

/* Reduce blur on mobile devices */
@media (max-width: 768px) {
    .glow-orb {
        filter: blur(40px) !important; /* Reduced from 90px */
        opacity: 0.2 !important; /* Slightly more transparent */
    }
    
    .navbar,
    .stat-box,
    .game-card,
    .find-card {
        backdrop-filter: blur(5px) !important; /* Reduced from 10px */
    }
}

/* Low performance devices - minimal effects */
.low-performance .glow-orb {
    filter: blur(30px) !important; /* Even less blur */
    opacity: 0.15 !important;
    animation: none !important; /* Disable animation */
}

.low-performance .navbar,
.low-performance .stat-box,
.low-performance .game-card,
.low-performance .find-card {
    backdrop-filter: none !important; /* Remove backdrop blur completely */
    background-color: rgba(28, 28, 31, 0.95) !important; /* Use solid color instead */
}

.low-performance .marquee-item:hover {
    transform: none !important; /* Disable hover effects */
    box-shadow: none !important;
}

/* Pause carousel when not visible */
.hero-marquee-wrapper.paused .marquee-track {
    animation-play-state: paused !important;
}

/* ===== GPU ACCELERATION HINTS ===== */

/* Force GPU acceleration for animated elements */
.glow-orb,
.marquee-track,
.marquee-item {
    will-change: transform;
    transform: translateZ(0); /* Force GPU layer */
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Remove will-change after animation for better performance */
.game-card,
.find-card,
.btn {
    will-change: auto; /* Don't force GPU for everything */
}

.game-card:hover,
.find-card:hover,
.btn:hover {
    will-change: transform;
}

/* ===== OPTIMIZED CAROUSEL ===== */

/* Slower animations = less CPU usage */
@media (max-width: 768px) {
    .marquee-left {
        animation: scrollLeft 60s linear infinite !important; /* Slower from 40s */
    }
    
    .marquee-right {
        animation: scrollRight 90s linear infinite !important; /* Slower from 65s */
    }
}

.low-performance .marquee-left {
    animation: scrollLeft 80s linear infinite !important; /* Even slower */
}

.low-performance .marquee-right {
    animation: scrollRight 120s linear infinite !important;
}

/* Reduce marquee item size on mobile */
@media (max-width: 768px) {
    .marquee-item {
        width: 200px; /* Reduced from 300px */
        height: 113px; /* Maintain 16:9 ratio */
    }
}

/* ===== CONTAIN PAINT/LAYOUT ===== */

/* Isolate expensive operations */
.game-card,
.find-card,
.marquee-item {
    contain: layout style paint;
}

.hero-marquee-wrapper {
    contain: layout style;
}

/* ===== REDUCE MOTION FOR ACCESSIBILITY ===== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .glow-orb {
        animation: none !important;
    }
    
    .marquee-track {
        animation: none !important;
    }
}

/* ===== OPTIMIZE IMAGE RENDERING ===== */

img {
    image-rendering: auto;
    image-rendering: crisp-edges;
    image-rendering: -webkit-optimize-contrast;
}

.marquee-item img,
.card-image img {
    content-visibility: auto; /* Only render when visible */
}

/* ===== REDUCE SHADOWS ON LOW-END ===== */

.low-performance .game-card:hover,
.low-performance .btn-primary,
.low-performance .btn-secondary {
    box-shadow: none !important;
}

/* ===== SIMPLIFY HOVER EFFECTS ON MOBILE ===== */

@media (max-width: 768px) {
    .marquee-item:hover {
        transform: scale(1.05) !important; /* Reduced from 1.1 */
        box-shadow: 0 0 15px rgba(59, 130, 246, 0.5) !important; /* Lighter shadow */
    }
    
    .game-card:hover {
        transform: translateY(-5px) !important; /* Reduced from -10px */
    }
}

/* ===== ADDITIONAL OPTIMIZATIONS ===== */

/* Prevent layout shifts */
.hero,
.games-section,
.find-me-section {
    contain: layout;
}

/* Optimize text rendering */
body {
    text-rendering: optimizeSpeed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Reduce complexity of gradients on mobile */
@media (max-width: 768px) {
    .hero-overlay {
        background: linear-gradient(
            to bottom, 
            rgba(18, 18, 20, 0) 0%, 
            var(--section-dim-color) 80%
        ) !important; /* Simpler gradient */
    }
    
    .hero-content h1 {
        background: #ffffff !important; /* Solid color instead of gradient */
        background-clip: text !important;
        -webkit-background-clip: text !important;
        -webkit-text-fill-color: transparent !important;
    }
}