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

/* --- Layered Architecture --- */
@layer reset, base, theme, layout, components, utilities;

@layer reset {
    *, *::before, *::after {
        box-sizing: border-box;
        margin: 0;
        padding: 0;
    }
    
    html {
        scroll-behavior: smooth;
        -webkit-text-size-adjust: 100%;
    }
    
    body {
        min-height: 100vh;
        text-rendering: optimizeSpeed;
        line-height: 1.6;
        overflow-x: hidden;
    }

    img, picture, svg {
        max-width: 100%;
        display: block;
    }

    input, button, textarea, select {
        font: inherit;
    }
    
    a {
        color: inherit;
        text-decoration: none;
    }
}

@layer base {
    :root {
        /* Design Tokens: Colors in OKLCH */
        --accent-hue: 262; /* Royal Violet */
        
        --color-accent: oklch(0.65 0.22 var(--accent-hue));
        --color-accent-hover: oklch(0.55 0.22 var(--accent-hue));
        --color-accent-subtle: oklch(0.95 0.02 var(--accent-hue));
        
        /* Font tokens */
        --font-family-sans: 'Inter', system-ui, -apple-system, sans-serif;
        --font-family-display: 'Outfit', var(--font-family-sans);
        --font-family-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
        
        /* Transition times */
        --transition-fast: 0.2s ease;
        --transition-medium: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        
        /* Smooth shadows */
        --shadow-soft: 
            0 2px 4px oklch(0 0 0 / 0.02),
            0 4px 8px oklch(0 0 0 / 0.02),
            0 12px 24px oklch(0 0 0 / 0.03);
            
        --shadow-medium:
            0 4px 6px oklch(0 0 0 / 0.04),
            0 12px 20px oklch(0 0 0 / 0.04),
            0 24px 48px oklch(0 0 0 / 0.06);

        --shadow-premium:
            0 1px 2px oklch(0 0 0 / 0.05),
            0 8px 16px oklch(0 0 0 / 0.05),
            0 24px 64px oklch(0 0 0 / 0.1);
            
        /* Border Radii */
        --radius-sm: 6px;
        --radius-md: 12px;
        --radius-lg: 20px;
        --radius-full: 9999px;
    }
    
    body {
        font-family: var(--font-family-sans);
        font-size: 1rem;
        -webkit-font-smoothing: antialiased;
    }
    
    h1, h2, h3, h4 {
        font-family: var(--font-family-display);
        font-weight: 700;
        line-height: 1.15;
        letter-spacing: -0.02em;
    }
    
    h1 { font-size: clamp(2.2rem, 1.5rem + 3vw, 4rem); text-wrap: balance; }
    h2 { font-size: clamp(1.6rem, 1.2rem + 2vw, 2.5rem); text-wrap: balance; }
    h3 { font-size: 1.5rem; }
    
    p {
        text-wrap: pretty;
        max-width: 75ch;
    }
}

@layer theme {
    :root, .light {
        color-scheme: light dark;
        
        --color-bg-base: oklch(0.99 0.005 240);
        --color-bg-surface: oklch(1 0 0);
        --color-bg-subtle: oklch(0.97 0.005 240);
        
        --color-text-main: oklch(0.2 0.01 240);
        --color-text-muted: oklch(0.5 0.01 240);
        
        --color-border: oklch(0.9 0.005 240);
        --color-border-glow: oklch(0.9 0.03 var(--accent-hue) / 0.4);
        
        --glass-bg: rgba(255, 255, 255, 0.7);
        --glass-border: rgba(255, 255, 255, 0.6);
        --glass-shadow: 0 8px 32px 0 rgba(142, 120, 219, 0.04);
        
        --code-bg: oklch(0.96 0.005 240);
        --code-text: oklch(0.3 0.1 290);
    }
    
    @media (prefers-color-scheme: dark) {
        :root {
            --color-bg-base: oklch(0.08 0.01 240);
            --color-bg-surface: oklch(0.12 0.01 240);
            --color-bg-subtle: oklch(0.14 0.01 240);
            
            --color-text-main: oklch(0.92 0.005 240);
            --color-text-muted: oklch(0.65 0.01 240);
            
            --color-border: oklch(0.2 0.01 240);
            --color-border-glow: oklch(0.4 0.1 var(--accent-hue) / 0.4);
            
            --glass-bg: rgba(25, 25, 32, 0.7);
            --glass-border: rgba(255, 255, 255, 0.05);
            --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
            
            --code-bg: oklch(0.16 0.01 240);
            --code-text: oklch(0.85 0.08 260);
        }
    }
    
    .dark {
        --color-bg-base: oklch(0.08 0.01 240);
        --color-bg-surface: oklch(0.12 0.01 240);
        --color-bg-subtle: oklch(0.14 0.01 240);
        
        --color-text-main: oklch(0.92 0.005 240);
        --color-text-muted: oklch(0.65 0.01 240);
        
        --color-border: oklch(0.2 0.01 240);
        --color-border-glow: oklch(0.4 0.1 var(--accent-hue) / 0.4);
        
        --glass-bg: rgba(25, 25, 32, 0.7);
        --glass-border: rgba(255, 255, 255, 0.05);
        --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
        
        --code-bg: oklch(0.16 0.01 240);
        --code-text: oklch(0.85 0.08 260);
    }
    
    body {
        background-color: var(--color-bg-base);
        color: var(--color-text-main);
        transition: background-color var(--transition-fast), color var(--transition-fast);
    }
}

@layer layout {
    /* --- Main Layout Grids --- */
    .app-container {
        display: grid;
        grid-template-rows: auto 1fr auto;
        min-height: 100vh;
    }
    
    .main-header {
        position: sticky;
        top: 0;
        z-index: 100;
        background: var(--glass-bg);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
        border-bottom: 1px solid var(--glass-border);
        box-shadow: var(--shadow-soft);
        padding: 0.8rem 2rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    
    .main-content {
        max-width: 1400px;
        width: 100%;
        margin: 0 auto;
        padding: 2.5rem 2rem;
    }
    
    .doc-layout {
        display: grid;
        grid-template-columns: 280px 1fr;
        gap: 3rem;
        margin-top: 2rem;
    }
    
    @media (max-width: 968px) {
        .doc-layout {
            grid-template-columns: 1fr;
            gap: 2rem;
        }
        
        .sidebar {
            display: none; /* Can be toggled with mobile layout */
        }
        .sidebar.active {
            display: block;
            position: fixed;
            top: 60px;
            left: 0;
            width: 100%;
            height: calc(100vh - 60px);
            background: var(--color-bg-base);
            z-index: 90;
            padding: 2rem;
            overflow-y: auto;
        }
    }
    
    .main-footer {
        border-top: 1px solid var(--color-border);
        padding: 2rem;
        text-align: center;
        font-size: 0.9rem;
        color: var(--color-text-muted);
        background-color: var(--color-bg-surface);
    }
}

@layer components {
    /* --- Brand --- */
    .brand {
        display: flex;
        align-items: center;
        gap: 0.8rem;
        font-family: var(--font-family-display);
        font-weight: 700;
        font-size: 1.4rem;
        color: var(--color-text-main);
    }
    
    .brand-icon {
        width: 32px;
        height: 32px;
        background: linear-gradient(135deg, var(--color-accent), oklch(0.7 0.2 300));
        border-radius: var(--radius-sm);
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        font-weight: bold;
    }

    /* --- Search Bar --- */
    .search-box {
        position: relative;
        max-width: 360px;
        width: 100%;
    }
    
    .search-input {
        width: 100%;
        padding: 0.5rem 1rem 0.5rem 2.2rem;
        border-radius: var(--radius-full);
        border: 1px solid var(--color-border);
        background-color: var(--color-bg-subtle);
        color: var(--color-text-main);
        outline: none;
        transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    }
    
    .search-input:focus {
        border-color: var(--color-accent);
        box-shadow: 0 0 0 3px var(--color-border-glow);
    }
    
    .search-icon {
        position: absolute;
        left: 0.8rem;
        top: 50%;
        transform: translateY(-50%);
        color: var(--color-text-muted);
        pointer-events: none;
    }
    
    /* --- Action Controls --- */
    .header-actions {
        display: flex;
        align-items: center;
        gap: 1rem;
    }
    
    .btn {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.6rem 1.2rem;
        border-radius: var(--radius-sm);
        font-weight: 500;
        cursor: pointer;
        transition: all var(--transition-fast);
        border: none;
        outline: none;
    }
    
    .btn-primary {
        background-color: var(--color-accent);
        color: white;
    }
    
    .btn-primary:hover {
        background-color: var(--color-accent-hover);
        box-shadow: 0 4px 12px oklch(0.65 0.22 var(--accent-hue) / 0.3);
    }
    
    .btn-outline {
        border: 1px solid var(--color-border);
        background: transparent;
        color: var(--color-text-main);
    }
    
    .btn-outline:hover {
        background: var(--color-bg-subtle);
        border-color: var(--color-text-muted);
    }
    
    .theme-toggle {
        background: none;
        border: none;
        cursor: pointer;
        color: var(--color-text-main);
        font-size: 1.3rem;
        width: 36px;
        height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: var(--radius-full);
        transition: background-color var(--transition-fast);
    }
    
    .theme-toggle:hover {
        background-color: var(--color-bg-subtle);
    }
    
    /* --- Sidebar & Navigation --- */
    .sidebar {
        position: sticky;
        top: 100px;
        height: fit-content;
    }
    
    .sidebar-title {
        font-size: 0.85rem;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--color-text-muted);
        margin-bottom: 0.8rem;
    }
    
    .sidebar-menu {
        list-style: none;
        display: flex;
        flex-direction: column;
        gap: 0.3rem;
    }
    
    .sidebar-link {
        display: flex;
        align-items: center;
        gap: 0.6rem;
        padding: 0.5rem 0.8rem;
        border-radius: var(--radius-sm);
        color: var(--color-text-muted);
        transition: all var(--transition-fast);
    }
    
    .sidebar-link:hover, .sidebar-link.active {
        color: var(--color-text-main);
        background-color: var(--color-bg-subtle);
    }
    
    .sidebar-link.active {
        font-weight: 500;
        border-left: 3px solid var(--color-accent);
        border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    }
    
    /* --- Features Grid (Homepage) --- */
    .features-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
        gap: 2rem;
        margin-top: 3rem;
    }
    
    .feature-card {
        background-color: var(--color-bg-surface);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        padding: 2rem;
        box-shadow: var(--shadow-soft);
        transition: all var(--transition-medium);
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        position: relative;
        overflow: hidden;
    }
    
    .feature-card::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 4px;
        background: linear-gradient(to right, var(--color-accent), oklch(0.7 0.2 300));
        opacity: 0;
        transition: opacity var(--transition-fast);
    }
    
    .feature-card:hover {
        transform: translateY(-5px);
        box-shadow: var(--shadow-medium);
        border-color: var(--color-accent-subtle);
    }
    
    .feature-card:hover::before {
        opacity: 1;
    }
    
    .feature-icon-wrapper {
        font-size: 1.8rem;
        margin-bottom: 1.2rem;
        width: 48px;
        height: 48px;
        border-radius: var(--radius-sm);
        background-color: var(--color-bg-subtle);
        display: flex;
        align-items: center;
        justify-content: center;
        color: var(--color-accent);
    }
    
    .feature-card h3 {
        font-size: 1.25rem;
        margin-bottom: 0.8rem;
        color: var(--color-text-main);
    }
    
    .feature-card p {
        font-size: 0.95rem;
        color: var(--color-text-muted);
        margin-bottom: 1.5rem;
        flex-grow: 1;
    }
    
    .feature-tag-list {
        display: flex;
        gap: 0.4rem;
        flex-wrap: wrap;
        margin-bottom: 1.5rem;
    }
    
    .feature-tag {
        font-size: 0.75rem;
        padding: 0.2rem 0.6rem;
        background-color: var(--color-bg-subtle);
        border-radius: var(--radius-full);
        color: var(--color-text-muted);
    }
    
    /* --- Glassmorphic Hero Banner --- */
    .hero-banner {
        background: linear-gradient(135deg, oklch(0.2 0.08 270 / 0.9), oklch(0.1 0.04 240 / 0.95)), 
                    repeating-linear-gradient(45deg, rgba(255,255,255,0.02) 0 1px, transparent 0 20px);
        border-radius: var(--radius-lg);
        padding: 4rem 3rem;
        color: white;
        position: relative;
        overflow: hidden;
        box-shadow: var(--shadow-premium);
        margin-bottom: 3rem;
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .hero-banner::after {
        content: '';
        position: absolute;
        right: -10%;
        top: -20%;
        width: 300px;
        height: 300px;
        background: radial-gradient(circle, oklch(0.6 0.2 262 / 0.4) 0%, transparent 70%);
        pointer-events: none;
    }
    
    .hero-banner h1 {
        color: white;
        max-width: 20ch;
        font-weight: 700;
    }
    
    .hero-banner p {
        color: oklch(0.85 0.02 240);
        font-size: 1.15rem;
        max-width: 60ch;
    }
    
    /* --- Content Pages (Features Markdown Style) --- */
    .doc-content {
        max-width: 850px;
    }
    
    .doc-header {
        border-bottom: 1px solid var(--color-border);
        padding-bottom: 1.5rem;
        margin-bottom: 2rem;
    }
    
    .doc-meta {
        display: flex;
        gap: 1.5rem;
        color: var(--color-text-muted);
        font-size: 0.9rem;
        margin-top: 0.8rem;
    }
    
    .doc-article {
        font-size: 1.05rem;
        color: var(--color-text-main);
    }
    
    .doc-article p {
        margin-bottom: 1.2rem;
    }
    
    .doc-article h2 {
        font-size: 1.8rem;
        margin: 2.5rem 0 1rem 0;
        border-bottom: 1px solid var(--color-border);
        padding-bottom: 0.4rem;
    }
    
    .doc-article h3 {
        font-size: 1.35rem;
        margin: 1.8rem 0 0.8rem 0;
    }
    
    .doc-article ul, .doc-article ol {
        margin-left: 2rem;
        margin-bottom: 1.5rem;
    }
    
    .doc-article li {
        margin-bottom: 0.4rem;
    }
    
    .doc-article pre {
        background-color: var(--code-bg);
        color: var(--color-text-main);
        padding: 1.2rem;
        border-radius: var(--radius-md);
        overflow-x: auto;
        font-family: var(--font-family-mono);
        font-size: 0.9rem;
        border: 1px solid var(--color-border);
        margin: 1.5rem 0;
        position: relative;
    }
    
    .doc-article code {
        font-family: var(--font-family-mono);
        font-size: 0.9em;
        background-color: var(--code-bg);
        padding: 0.2rem 0.4rem;
        border-radius: 4px;
        color: var(--code-text);
    }
    
    .doc-article pre code {
        background-color: transparent;
        padding: 0;
        color: inherit;
    }
    
    /* --- VS Code Mockup --- */
    .vscode-mockup {
        background: #1e1e1e;
        border-radius: var(--radius-md);
        border: 1px solid #333;
        overflow: hidden;
        font-family: var(--font-family-mono);
        font-size: 0.85rem;
        color: #d4d4d4;
        box-shadow: var(--shadow-medium);
        margin: 2rem 0;
    }
    
    .vscode-titlebar {
        background: #323232;
        padding: 0.5rem 1rem;
        display: flex;
        align-items: center;
        gap: 0.5rem;
        font-size: 0.75rem;
        color: #8c8c8c;
    }
    
    .vscode-dots {
        display: flex;
        gap: 0.3rem;
    }
    
    .vscode-dot {
        width: 10px;
        height: 10px;
        border-radius: var(--radius-full);
    }
    .vscode-dot.red { background: #ff5f56; }
    .vscode-dot.yellow { background: #ffbd2e; }
    .vscode-dot.green { background: #27c93f; }
    
    .vscode-tabs {
        background: #252526;
        display: flex;
        border-bottom: 1px solid #3c3c3c;
    }
    
    .vscode-tab {
        background: #1e1e1e;
        padding: 0.5rem 1.2rem;
        border-right: 1px solid #252526;
        display: flex;
        align-items: center;
        gap: 0.5rem;
        color: #d4d4d4;
    }
    
    .vscode-tab.active {
        background: #1e1e1e;
        border-top: 1px solid var(--color-accent);
    }
    
    .vscode-editor-body {
        padding: 1.5rem;
        line-height: 1.5;
        white-space: pre-wrap;
    }
    
    .vscode-keyword { color: #569cd6; }
    .vscode-string { color: #ce9178; }
    .vscode-comment { color: #6a9955; }
    .vscode-variable { color: #9cdcfe; }
    .vscode-tag { color: #4ec9b0; }
}

@layer utilities {
    /* --- Utility classes --- */
    .text-center { text-align: center; }
    .mt-1 { margin-top: 1rem; }
    .mt-2 { margin-top: 2rem; }
    .mb-1 { margin-bottom: 1rem; }
    .mb-2 { margin-bottom: 2rem; }
    
    .visually-hidden {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }
    
    .badge {
        display: inline-block;
        padding: 0.25rem 0.6rem;
        font-size: 0.75rem;
        font-weight: 600;
        border-radius: var(--radius-full);
        background-color: var(--color-accent-subtle);
        color: var(--color-accent);
    }
}
