/* CSS Custom Properties for Design System */
:root {
    /* Primary Colors */
    --color-primary: #0066CC;
    --color-primary-dark: #0052A3;
    --color-primary-light: #3385D6;

    /* Secondary Colors */
    --color-secondary: #1a1a1a;
    --color-secondary-light: #4a4a4a;

    /* Accent Colors */
    --color-accent: #00D4AA;
    --color-accent-dark: #00B391;
    --color-accent-light: #33DDBB;

    /* Background Colors */
    --color-background: #f8fafc;
    --color-surface: #ffffff;
    --color-surface-elevated: #ffffff;

    /* Code Block Colors */
    --color-code-bg: #2d3748;
    --color-code-text: #e2e8f0;
    --color-code-keyword: #93c5fd;
    --color-code-string: #86efac;
    --color-code-comment: #94a3b8;
    --color-code-function: #fbbf24;
    --color-code-number: #f472b6;
    --color-code-type: #67e8f9;

    /* Typography */
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', Menlo, Monaco, monospace;

    /* Spacing */
    --section-padding: clamp(3rem, 8vw, 6rem);
    --container-max: 1280px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 300ms ease;
    --transition-slow: 500ms ease;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-base: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-base: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
}

/* Dark Mode */
.dark {
    --color-background: #0f172a;
    --color-surface: #1e293b;
    --color-surface-elevated: #334155;
    --color-secondary: #f1f5f9;
    --color-secondary-light: #cbd5e1;
}

.dark body {
    color: var(--color-secondary);
    background-color: var(--color-background);
}

/* Base Styles */
* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    color: var(--color-secondary);
    background-color: var(--color-background);
    line-height: 1.6;
}

/* Code Block Styling */
code, pre {
    font-family: var(--font-mono);
}

.code-block {
    background-color: var(--color-code-bg);
    color: var(--color-code-text);
    border-radius: var(--radius-lg);
    overflow-x: auto;
}

/* Syntax Highlighting Classes */
.syntax-keyword { color: var(--color-code-keyword); }
.syntax-string { color: var(--color-code-string); }
.syntax-comment { color: var(--color-code-comment); font-style: italic; }
.syntax-function { color: var(--color-code-function); }
.syntax-number { color: var(--color-code-number); }
.syntax-type { color: var(--color-code-type); }

/* Animation Delays */
.delay-100 { animation-delay: 100ms; }
.delay-200 { animation-delay: 200ms; }
.delay-300 { animation-delay: 300ms; }
.delay-400 { animation-delay: 400ms; }
.delay-500 { animation-delay: 500ms; }
.delay-600 { animation-delay: 600ms; }
.delay-700 { animation-delay: 700ms; }
.delay-800 { animation-delay: 800ms; }

/* Initially Hidden for Animation */
.animate-on-scroll {
    opacity: 0;
    will-change: opacity, transform;
}

.animate-on-scroll.is-visible {
    animation: fadeInUp 0.6s ease-out forwards;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-background);
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Selection */
::selection {
    background-color: var(--color-primary);
    color: white;
}

/* Focus Styles */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Enhanced focus styles for interactive elements */
a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Focus ring for nav links */
nav a:focus-visible {
    background-color: rgba(0, 102, 204, 0.1);
    border-radius: 6px;
}

/* Focus ring for feature cards and interactive cards */
.feature-card:focus-within,
.example-card:focus-within {
    outline: 2px solid var(--color-primary);
    outline-offset: 4px;
}

/* Focus styles for playground tabs */
.playground-tab:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: -2px;
}

/* Skip to Content Link - Accessibility */
.skip-to-content {
    position: absolute;
    top: -100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--color-primary);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-lg);
    font-weight: 600;
    z-index: 9999;
    transition: top 0.3s ease;
}

.skip-to-content:focus {
    top: 1rem;
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
}

/* Gradient Utilities */
.gradient-primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
}

.gradient-accent {
    background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-dark) 100%);
}

.gradient-hero {
    background: linear-gradient(180deg, var(--color-background) 0%, white 100%);
}

.dark .gradient-hero {
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
}

.text-gradient-primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Feature Card Animations */
.feature-card {
    opacity: 0;
    transform: translateY(30px);
    will-change: opacity, transform;
}

.feature-card.is-visible {
    animation: featureCardIn 0.6s ease-out forwards;
}

@keyframes featureCardIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger delays for feature cards */
.feature-card:nth-child(1) { animation-delay: 0ms; }
.feature-card:nth-child(2) { animation-delay: 100ms; }
.feature-card:nth-child(3) { animation-delay: 200ms; }
.feature-card:nth-child(4) { animation-delay: 300ms; }
.feature-card:nth-child(5) { animation-delay: 400ms; }
.feature-card:nth-child(6) { animation-delay: 500ms; }
.feature-card:nth-child(7) { animation-delay: 600ms; }
.feature-card:nth-child(8) { animation-delay: 700ms; }

/* Example Card Animations */
.example-card {
    opacity: 0;
    transform: translateY(30px);
    will-change: opacity, transform;
}

/* Example Card Dark Mode Backgrounds */
.dark .example-card {
    background: linear-gradient(#1e293b, #1e293b) padding-box, var(--card-gradient) border-box !important;
}

.example-card.is-visible {
    animation: exampleCardIn 0.6s ease-out forwards;
}

@keyframes exampleCardIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Stagger delays for example cards */
.example-card:nth-child(1) { animation-delay: 0ms; }
.example-card:nth-child(2) { animation-delay: 100ms; }
.example-card:nth-child(3) { animation-delay: 200ms; }
.example-card:nth-child(4) { animation-delay: 300ms; }
.example-card:nth-child(5) { animation-delay: 400ms; }

/* Code Playground Styles */
.playground-tab {
    background-color: transparent;
    color: var(--color-secondary);
    opacity: 0.7;
    border: 1px solid transparent;
}

.playground-tab:hover {
    background-color: rgba(0, 102, 204, 0.05);
    opacity: 1;
}

.playground-tab.active {
    background-color: var(--color-primary);
    color: white;
    opacity: 1;
    border-color: var(--color-primary);
}

.playground-panel {
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}

.playground-panel.hidden {
    display: none;
}

.playground-panel.fade-out {
    opacity: 0;
}

.playground-panel.fade-in {
    opacity: 1;
}

/* Prism.js overrides for code blocks */
.code-playground-block pre {
    margin: 0;
    padding: 1.25rem;
    background-color: #1e1e1e;
    font-size: 0.875rem;
    line-height: 1.7;
    overflow-x: auto;
    max-height: 500px;
}

.code-playground-block pre code {
    font-family: 'JetBrains Mono', Menlo, Monaco, monospace;
}

/* Line numbers styling */
.code-playground-block pre.line-numbers {
    padding-left: 3.5rem;
}

.code-playground-block .line-numbers-rows {
    border-right: 1px solid rgba(255,255,255,0.1);
    padding-right: 0.75rem;
}

/* Copy button states */
.copy-btn {
    position: relative;
    transition: all 0.2s ease;
}

.copy-btn:hover {
    transform: scale(1.05);
}

.copy-btn:active {
    transform: scale(0.95);
}

.copy-btn.copied {
    color: #10b981 !important;
}

.copy-btn.copied .copy-text {
    color: #10b981;
}

.copy-btn.copying {
    pointer-events: none;
}

.copy-btn .spinner {
    display: none;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.copy-btn.copying .spinner {
    display: inline-block;
}

.copy-btn.copying .copy-icon,
.copy-btn.copying .copy-text {
    display: none;
}

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

/* Scroll to Top Button */
.scroll-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 3rem;
    height: 3rem;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease, background-color 0.2s ease;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.3);
}

.scroll-to-top:hover {
    background: var(--color-primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 102, 204, 0.4);
}

.scroll-to-top:focus-visible {
    outline: 3px solid var(--color-accent);
    outline-offset: 2px;
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-to-top svg {
    width: 1.5rem;
    height: 1.5rem;
    transition: transform 0.2s ease;
}

.scroll-to-top:hover svg {
    transform: translateY(-2px);
}

/* Hero Parallax Effect */
.parallax-layer {
    will-change: transform;
    transition: transform 0.1s ease-out;
}

.parallax-bg-1 {
    transform: translateY(var(--parallax-offset-1, 0));
}

.parallax-bg-2 {
    transform: translateY(var(--parallax-offset-2, 0));
}

.parallax-bg-3 {
    transform: translateY(var(--parallax-offset-3, 0));
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .parallax-layer {
        transform: none !important;
    }

    .animate-on-scroll,
    .feature-card,
    .example-card,
    .arch-component,
    .arch-arrow,
    .tech-badge {
        opacity: 1 !important;
        transform: none !important;
        animation: none !important;
    }

    .scroll-to-top,
    .scroll-to-top:hover {
        transform: none !important;
    }

    html {
        scroll-behavior: auto;
    }
}

/* Print Styles */
@media print {
    /* Hide non-essential elements */
    .skip-to-content,
    .scroll-to-top,
    #header,
    #mobile-menu,
    .copy-btn,
    .playground-tab,
    nav,
    button {
        display: none !important;
    }

    /* Reset body styling */
    body {
        background: white !important;
        color: black !important;
        font-size: 12pt;
        line-height: 1.5;
    }

    /* Show all content */
    .playground-panel.hidden {
        display: block !important;
    }

    /* Ensure sections are visible */
    section {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    /* Reset colors for printing */
    h1, h2, h3, h4, h5, h6 {
        color: black !important;
    }

    p, li, span {
        color: #333 !important;
    }

    /* Show links */
    a {
        color: var(--color-primary) !important;
        text-decoration: underline;
    }

    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }

    a[href^="#"]::after,
    a[href^="javascript"]::after {
        content: "";
    }

    /* Code blocks */
    .code-block, pre {
        background: #f5f5f5 !important;
        border: 1px solid #ddd;
        padding: 1rem;
        overflow: visible;
        white-space: pre-wrap;
        word-wrap: break-word;
    }

    code {
        color: black !important;
    }

    /* Full width */
    .max-w-7xl {
        max-width: 100% !important;
    }

    /* Remove animations */
    *, *::before, *::after {
        animation: none !important;
        transition: none !important;
    }

    /* Footer */
    footer {
        background: white !important;
        color: black !important;
        border-top: 2px solid #333;
    }

    footer a {
        color: #333 !important;
    }
}
