/* --- CORE VARIABLES --- */
:root {
    --bg-color: #050505;
    --hub-bg: radial-gradient(circle at center, #1a1a1a 0%, #000000 100%);
    --text-main: #e5e7eb;
    --text-muted: #9ca3af;
    --accent: #6366f1; /* Indigo */
    --accent-glow: rgba(99, 102, 241, 0.4);
    --border-color: rgba(255, 255, 255, 0.1);
    --font-stack: system-ui, -apple-system, monospace;
}

/* --- RESET & BASE --- */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
button { font: inherit; border: none; background: none; cursor: pointer; }

body {
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* Mobile viewport fix */
    background: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-stack);
    overflow: hidden;
    user-select: none;
}

/* --- BACKGROUND LAYERS --- */
.layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
}

#bgLayer {
    z-index: 0;
    background: var(--hub-bg);
    transition: all 1s ease;
}

#ambientLayer {
    z-index: 1;
    opacity: 0.5;
    transition: opacity 1s ease;
}

/* App container should be above background layers */
#app-container {
    z-index: 10;
    position: relative;
}

/* Pausable animations for performance */
.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.2;
    animation: drift 20s infinite ease-in-out;
}

body.performance-mode .blob {
    animation-play-state: paused;
    display: none; 
}

@keyframes drift {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(30px, -30px) scale(1.1); }
    100% { transform: translate(0, 0) scale(1); }
}

/* --- LOADING SCREEN (Basic) --- */
#loading-screen {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    height: 100dvh; /* Ensure full height on mobile */
    background: #000;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease;
}

#loading-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    transform: scale(1.2); 
}

.loader-bar-container {
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    overflow: hidden;
    width: 200px;
    height: 4px;
}

.loader-bar {
    height: 100%;
    background: #6366f1;
    border-radius: 10px;
    transition: width 0.3s ease;
}

/* Mobile specific adjustments for loading screen */
@media (max-width: 600px) {
    .loader-content {
        transform: scale(1); /* Reduce scale on small screens */
    }
}

.loader-text {
    font-family: "Courier New", Courier, monospace;
    font-weight: 900; 
    font-size: 3rem; /* Desktop size */
    letter-spacing: -0.05em;
    color: #fff;
    text-transform: uppercase;
    text-shadow: 4px 4px 0px #333, -2px -2px 0px #111;
}

/* Mobile text adjustment */
@media (max-width: 600px) {
    .loader-text {
        font-size: 2rem;
    }
}

.loader-bar-container {
    width: 300px;
    height: 20px;
    background: #111;
    border: 2px solid #333;
    padding: 2px;
    position: relative;
}

@media (max-width: 600px) {
    .loader-bar-container {
        width: 80vw; /* Use vw for width on mobile */
        max-width: 300px;
    }
}

.loader-bar {
    width: 0%;
    height: 100%;
    background: var(--accent);
    transition: width 0.1s linear; 
}

/* --- HUB UI --- */
#main-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

#hub-ui {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    z-index: 20;
    transition: opacity 0.4s ease, transform 0.4s ease;
    max-height: 90vh;
    width: 100%;
    padding: 20px;
}

#hub-ui.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.95);
}

.hub-title {
    font-size: 1.5rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.3);
    margin-bottom: 10px;
    position: relative;
    text-align: center;
}

/* --- GRID LAYOUT (Desktop Default) --- */
.app-grid-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
    align-items: center;
}

.grid-row {
    display: flex;
    gap: 24px;
    justify-content: center;
    flex-wrap: wrap; 
}

.app-card {
    width: 180px; 
    height: 180px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    overflow: hidden;
}

.app-card:hover {
    transform: translateY(-6px) scale(1.02);
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 12px 40px var(--accent-glow);
}

.app-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 2px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    transform: translateX(-100%);
    transition: transform 0.5s;
}
.app-card:hover::before { transform: translateX(100%); }

/* Custom Hover Colors */
.app-card.gold-hover:hover { box-shadow: 0 12px 40px rgba(251, 191, 36, 0.3); }
.app-card.gold-hover::before { background: linear-gradient(90deg, transparent, #fbbf24, transparent); }

.app-card.discord-hover:hover { box-shadow: 0 12px 40px rgba(88, 101, 242, 0.3); }
.app-card.discord-hover::before { background: linear-gradient(90deg, transparent, #5865F2, transparent); }

.app-card.sc-hover:hover { box-shadow: 0 12px 40px rgba(255, 85, 0, 0.3); }
.app-card.sc-hover::before { background: linear-gradient(90deg, transparent, #ff5500, transparent); }

.app-card.teal-hover:hover { box-shadow: 0 12px 40px rgba(20, 184, 166, 0.3); }
.app-card.teal-hover::before { background: linear-gradient(90deg, transparent, #14b8a6, transparent); }

.card-icon {
    width: 54px;
    height: 54px;
    margin-bottom: 16px;
    color: var(--text-main);
    opacity: 0.8;
    transition: all 0.3s ease;
}

.app-card:hover .card-icon { opacity: 1; color: white; transform: scale(1.1); }
.card-label { font-size: 0.8rem; font-weight: 500; letter-spacing: 0.05em; color: var(--text-muted); }

.external-icon {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 14px;
    height: 14px;
    opacity: 0.3;
}

/* --- SIDEBAR SOCIALS (Desktop: Left Vertical) --- */
#socials-sidebar {
    position: absolute;
    left: 30px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column; /* Vertical Categories */
    gap: 40px;
    z-index: 25;
    transition: opacity 0.4s ease;
}

#hub-ui.hidden #socials-sidebar { opacity: 0; pointer-events: none; }

.sidebar-section {
display: flex;
flex-direction: column; /* Header Top, Icons Below */
align-items: flex-start;
gap: 12px;
}

.sidebar-header {
font-size: 0.6rem;
font-weight: 700;
color: #555;
letter-spacing: 2px;
text-transform: uppercase;
padding-left: 2px;
}

.icons-row {
display: flex;
flex-direction: column; /* Vertical Icons on Desktop */
gap: 15px;
}

.link-item {
display: flex;
align-items: center;
justify-content: center;
width: 32px;
height: 32px;
text-decoration: none;
color: #666;
transition: all 0.2s;
border-radius: 50%;
background: rgba(255,255,255,0.02);
border: 1px solid rgba(255,255,255,0.05);
}

.link-item:hover {
    color: #fff;
    background: rgba(255,255,255,0.1);
    transform: scale(1.1);
    border-color: rgba(255,255,255,0.3);
}

.link-icon { width: 16px; height: 16px; fill: currentColor; }

.icon-purple { color: #a855f7; } 
.icon-blue { color: #3b82f6; }   
.icon-orange { color: #f97316; } 
.icon-red { color: #ef4444; }    

/* --- BOTTOM CONTROLS --- */
.bottom-controls {
    margin-top: 40px;
    display: flex;
    gap: 12px;
    align-items: center;
}

.volume-container {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.05);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.1);
}
input[type="range"] {
    -webkit-appearance: none;
    width: 80px;
    height: 3px;
    background: #444;
    border-radius: 2px;
    outline: none;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #888;
    cursor: pointer;
    transition: background 0.2s;
}
input[type="range"]:hover::-webkit-slider-thumb { background: #fff; }

/* --- APP RUNTIME CONTAINER --- */
#app-viewport {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    z-index: 50;
    background: #000;
    display: none;
    flex-direction: column;
}

#app-viewport.active { display: flex; }

.nav-bar {
    height: 48px;
    background: #0f0f13;
    border-bottom: 1px solid #222;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 16px;
}

.nav-home-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #fff;
    transition: background 0.2s;
}
.nav-home-btn:hover { background: rgba(255, 255, 255, 0.2); }

.nav-title { font-size: 0.85rem; color: #888; font-weight: 500; flex: 1; text-align: center; }

.nav-memory-badge {
    font-size: 0.65rem;
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid;
    font-family: monospace;
    text-transform: uppercase;
}

.mem-active { color: #22c55e; border-color: rgba(34, 197, 94, 0.3); background: rgba(34, 197, 94, 0.1); }
.mem-frozen { color: #f59e0b; border-color: rgba(245, 158, 11, 0.3); background: rgba(245, 158, 11, 0.1); }
.mem-purged { color: #ef4444; border-color: rgba(239, 68, 68, 0.3); background: rgba(239, 68, 68, 0.1); }

.frame-container { 
    flex: 1; width: 100%; height: 100%; position: relative; 
    display: flex; justify-content: center; align-items: center;
}
iframe { width: 100%; height: 100%; border: none; background: #000; }

/* SoundCloud Embed Container */
.sc-container {
    width: 100%;
    max-width: 800px;
    height: 480px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 20px;
    background: #000;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.sc-container iframe { border-radius: 12px; }

/* --- MOBILE MEDIA QUERIES --- */
@media (max-width: 768px) {
    
    /* Responsive Loading Screen */
    .loader-text { font-size: 2rem; }
    .loader-bar-container { width: 70vw; }

    /* Allow scrolling on hub */
    #hub-ui {
        overflow-y: auto;
        justify-content: flex-start;
        padding-top: 40px;
        padding-bottom: 140px; /* Increased Padding for Safe Area/Bottom Dock */
    }

    .hub-title { font-size: 1.2rem; }

    /* Move Sidebar to Bottom Dock */
    #socials-sidebar {
        position: fixed;
        left: 0;
        top: auto;
        bottom: 0;
        transform: none;
        width: 100%;
        background: rgba(10, 10, 10, 0.95);
        backdrop-filter: blur(10px);
        border-right: none;
        border-top: 1px solid rgba(255,255,255,0.1);
        flex-direction: row;
        justify-content: space-around;
        padding: 15px 10px calc(15px + env(safe-area-inset-bottom)) 10px; /* Safe Area Padding */
        gap: 10px;
        height: auto;
        z-index: 100; /* Ensure it's above other content */
    }

    .sidebar-section {
        flex-direction: row;
        align-items: center;
        gap: 6px;
    }

    .icons-row {
        flex-direction: row; /* Horizontal icons on mobile */
        gap: 15px;
    }

    .sidebar-header {
        font-size: 0.5rem;
        letter-spacing: 1px;
        padding-left: 0;
        display: none; /* Hide headers on mobile to save space, icons are clear enough */
    }

    /* Adjust Grid for Mobile (2 Columns strict) */
    .app-grid-container { 
        width: 100%; 
        display: grid;
        grid-template-columns: 1fr 1fr; /* Force 2 columns */
        gap: 15px;
        padding: 0 10px; /* Side padding */
    }
    
    /* Flatten rows for mobile grid */
    .grid-row {
        display: contents; /* Allows children to ignore this container and use parent grid */
    }

    .app-card {
        width: 100%; /* Fill grid cell */
        height: 140px; /* Shorter cards */
    }

    .card-icon { width: 40px; height: 40px; margin-bottom: 10px; }
    .card-label { font-size: 0.65rem; text-align: center; }

    /* Bottom Controls (Volume) above dock */
    .bottom-controls {
        margin-top: 20px;
        margin-bottom: 20px;
    }
    
    /* Responsive Embed */
    .sc-container { height: 100%; padding: 0; border: none; border-radius: 0; }
    .sc-container iframe { border-radius: 0; }
}

/* --- SITE FOOTER --- */
.site-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    padding: 8px 20px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
    pointer-events: none;
}

.footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.4);
    pointer-events: auto;
}

.footer-links a {
    color: rgba(255, 255, 255, 0.5);
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: rgba(255, 255, 255, 0.8);
}

.footer-divider {
    opacity: 0.3;
}

.footer-copyright {
    opacity: 0.6;
}

@media (max-width: 480px) {
    .footer-links {
        font-size: 0.6rem;
        gap: 6px;
    }
}
