@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

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

:root {
    /* Light Theme Colors */
    --primary: #000000;
    --secondary: #1a1a1a;
    --accent: #9500c6;
    --accent-light: #b84dd9;
    --accent-dark: #7000a0;
    --accent-purple: #9500c6;
    --accent-magenta: #c21f88;
    --accent-violet: #d64de8;
    --light: #ffffff;
    --paper: #f8f8f8;
    --card-bg: rgba(0, 0, 0, 0.02);
    --border: rgba(0, 0, 0, 0.08);
    --nav-bg: rgba(255, 255, 255, 0.4);
    --nav-border: rgba(0, 0, 0, 0.1);
    --text-primary: #000000;
    --text-secondary: rgba(0, 0, 0, 0.5);
    --text-tertiary: rgba(0, 0, 0, 0.4);
    --card-bg-solid: rgba(255, 255, 255, 0.5);
    --paper-texture-blend: multiply;
    --paper-texture-opacity: 1;
    
    /* Spacing */
    --sp-base: 16px;
    --sp-sm: 8px;
    --sp-lg: 24px;
    --sp-xl: 32px;
    
    /* Border radius */
    --radius-sm: 12px;
    --radius: 20px;
    --radius-lg: 32px;
    
    /* Transitions */
    --transition: all 0.8s cubic-bezier(0.19, 1, 0.22, 1);
}

/* Dark Theme */
body.dark-theme {
    --primary: #ffffff;
    --secondary: #e0e0e0;
    --paper: #0a0a0a;
    --card-bg: rgba(255, 255, 255, 0.03);
    --border: rgba(255, 255, 255, 0.12);
    --nav-bg: rgba(20, 20, 20, 0.8);
    --nav-border: rgba(255, 255, 255, 0.15);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-tertiary: rgba(255, 255, 255, 0.5);
    --card-bg-solid: rgba(20, 20, 20, 0.8);
    --paper-texture-blend: screen;
    --paper-texture-opacity: 0.3;
}

html {
    font-size: 15px;
    font-family: 'Inter', sans-serif;
}

body {
    background: var(--paper);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    height: 100vh;
    overflow: hidden;
    position: relative;
    transition: background-color 0.3s ease, color 0.3s ease;
    padding: 20px 0;
    box-sizing: border-box;
}

/* Paper texture */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        repeating-linear-gradient(0deg, rgba(0,0,0,0.015) 0px, transparent 1px, transparent 2px, rgba(0,0,0,0.015) 3px),
        repeating-linear-gradient(90deg, rgba(0,0,0,0.015) 0px, transparent 1px, transparent 2px, rgba(0,0,0,0.015) 3px);
    pointer-events: none;
    z-index: 2;
    mix-blend-mode: var(--paper-texture-blend);
    opacity: var(--paper-texture-opacity);
    transition: opacity 0.3s ease;
}

/* Game of Life Canvas */
#gameCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0.8;
    transition: opacity 0.6s ease;
}

/* Main Container */
main {
    width: 90vw;
    max-width: 1400px;
    flex: 1;
    max-height: calc(100vh - 200px);
    background: transparent;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: border-color 0.3s ease;
    
    display: grid;
    grid-template-rows: auto 1fr;
    grid-template-columns: 200px 1fr;
    grid-template-areas:
        "nav header"
        "nav content";
    
    position: relative;
    z-index: 10;
}

/* Navigation Sidebar */
nav {
    grid-area: nav;
    background: var(--nav-bg);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--nav-border);
    padding: var(--sp-xl) 0;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: var(--sp-xl);
}

.logo-container {
    padding: 0 var(--sp-lg);
    display: flex;
    justify-content: center;
}

.logo-container img {
    width: 100%;
    height: auto;
    max-width: 100%;
}

.nav-items {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--sp-sm);
    padding: 0 var(--sp-base);
}

.nav-items li a {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    padding: var(--sp-sm) var(--sp-base);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.93rem;
    transition: var(--transition);
    position: relative;
}

.nav-items li a::before {
    content: '';
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: transparent;
    transition: var(--transition);
}

.nav-items li a.active {
    color: var(--text-primary);
    background: rgba(149, 0, 198, 0.1);
}

.nav-items li a.active::before {
    background: var(--accent);
}

.nav-items li a:hover {
    color: var(--text-primary);
    background: var(--card-bg);
}

.nav-icon {
    width: 18px;
    height: 18px;
    opacity: 0.6;
}

/* Header */
header {
    grid-area: header;
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 0 var(--sp-xl);
    display: flex;
    align-items: center;
    gap: var(--sp-lg);
    transition: border-color 0.3s ease;
}

header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    flex: 1;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-actions {
    display: flex;
    gap: var(--sp-sm);
}

.toggle-btn {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.toggle-btn:hover {
    background: var(--card-bg);
    border-color: var(--border);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.toggle-btn.active {
    background: rgba(149, 0, 198, 0.1);
    border-color: var(--accent);
    color: var(--accent-dark);
}

/* Content Area */
.content {
    grid-area: content;
    padding: var(--sp-xl);
    overflow-y: auto;
    background: transparent;
}

/* Scrollbar */
.content::-webkit-scrollbar {
    width: 6px;
}

.content::-webkit-scrollbar-track {
    background: transparent;
}

.content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.content::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Section Cards */
.section-card {
    background: var(--card-bg-solid);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--sp-xl);
    margin-bottom: var(--sp-lg);
    transition: all 0.3s ease;
}

.section-card h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: var(--sp-base);
    background: linear-gradient(135deg, var(--accent-dark) 0%, var(--accent-violet) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.section-card p {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--text-secondary);
    margin-bottom: var(--sp-base);
}

.section-card p:last-child {
    margin-bottom: 0;
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--card-bg-solid);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border);
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: all 0.3s ease;
}

.mobile-menu-btn:hover {
    background: var(--card-bg);
    border-color: var(--accent);
}

.mobile-menu-btn span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.mobile-menu-btn.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.mobile-menu-btn.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-btn.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

nav.mobile-open {
    transform: translateX(0) !important;
}

/* Site-Wide Login Overlay */
#siteLoginOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--paper);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.site-login-card {
    background: var(--card-bg-solid);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 32px;
    max-width: 380px;
    width: 90%;
}

.site-login-card h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 4px;
    text-align: center;
    background: linear-gradient(135deg, var(--accent-dark) 0%, var(--accent-violet) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.site-login-logo {
    text-align: center;
    margin-bottom: 16px;
}

.site-login-logo img {
    max-width: 140px;
    height: auto;
}

/* Responsive */
@media (max-width: 1200px) {
    main {
        width: 95vw;
        aspect-ratio: auto;
        min-height: 90vh;
    }
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: flex;
    }
    
    main {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "content";
        padding-top: 0;
    }
    
    nav {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        height: 100vh;
        z-index: 99;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 2px 0 20px rgba(0, 0, 0, 0.1);
    }
    
    header {
        padding: var(--sp-base) var(--sp-lg);
    }
    
    header h1 {
        font-size: 1.1rem;
    }
    
    .header-actions {
        gap: 6px;
    }
    
    .toggle-btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }
    
    #toggleText {
        display: none;
    }
}
