/* MechanicsDSL Web Demo - Premium Styling */

:root {
    /* Colors */
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #06b6d4;
    --accent: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;

    /* Backgrounds */
    --bg-primary: #0a0a0f;
    --bg-secondary: #111118;
    --bg-tertiary: #1a1a24;
    --bg-card: #16161f;
    --bg-elevated: #1e1e2a;

    /* Text */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Borders */
    --border-color: #2e2e3a;
    --border-light: #3f3f50;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #06b6d4 100%);
    --gradient-hero: linear-gradient(180deg, #0a0a0f 0%, #111118 100%);
    --gradient-glow: radial-gradient(ellipse at center, rgba(99, 102, 241, 0.15) 0%, transparent 70%);

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.3);

    /* Fonts */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Spacing */
    --section-padding: 120px;
}

/* Light Theme */
[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #f1f5f9;
    --bg-tertiary: #e2e8f0;
    --bg-card: #ffffff;
    --bg-elevated: #f8fafc;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --border-color: #cbd5e1;
    --border-light: #e2e8f0;
    --gradient-hero: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    --gradient-glow: radial-gradient(ellipse at center, rgba(99, 102, 241, 0.1) 0%, transparent 70%);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    transition: background 0.3s, color 0.3s;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    line-height: 1.2;
}

.gradient-text {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 15px;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
    border: none;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 60px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 2px solid var(--border-light);
}

.btn-secondary:hover {
    background: var(--bg-elevated);
    border-color: var(--primary);
}

/* Theme Toggle */
.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-elevated);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s;
}

.theme-toggle:hover {
    border-color: var(--primary);
    transform: scale(1.05);
}

/* ======================== */
/* HERO SECTION */
/* ======================== */

.hero {
    min-height: 100vh;
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--gradient-hero);
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 150%;
    height: 100%;
    background: var(--gradient-glow);
    pointer-events: none;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 48px;
    position: relative;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 24px;
    font-weight: 700;
}

.logo-icon {
    font-size: 32px;
}

.nav-links {
    display: flex;
    gap: 32px;
    align-items: center;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

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

.github-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bg-elevated);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.github-link:hover {
    border-color: var(--primary);
}

/* Hero Content */
.hero-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0 24px;
    position: relative;
    z-index: 10;
}

.hero-badge {
    display: inline-block;
    padding: 8px 16px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 50px;
    font-size: 14px;
    font-weight: 500;
    color: var(--primary-light);
    margin-bottom: 24px;
}

.hero-title {
    font-size: clamp(48px, 8vw, 80px);
    font-weight: 800;
    margin-bottom: 24px;
    letter-spacing: -2px;
}

.hero-subtitle {
    font-size: 20px;
    color: var(--text-secondary);
    max-width: 600px;
    margin-bottom: 40px;
}

.hero-cta {
    display: flex;
    gap: 16px;
}

/* Hero Visual */
.hero-visual {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    height: 100%;
    opacity: 0.4;
    pointer-events: none;
}

#hero-canvas {
    width: 100%;
    height: 100%;
}

/* Scroll Indicator */
.scroll-indicator {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 14px;
    animation: bounce 2s infinite;
}

.scroll-arrow {
    width: 24px;
    height: 24px;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transform: rotate(45deg);
}

@keyframes bounce {

    0%,
    100% {
        transform: translateX(-50%) translateY(0);
    }

    50% {
        transform: translateX(-50%) translateY(10px);
    }
}

/* ======================== */
/* STATS BAR */
/* ======================== */

.stats-bar {
    display: flex;
    justify-content: center;
    gap: 80px;
    padding: 40px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.stat {
    text-align: center;
}

.stat-number {
    display: block;
    font-size: 36px;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

/* ======================== */
/* SECTION HEADERS */
/* ======================== */

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

.section-header h2 {
    font-size: 42px;
    margin-bottom: 16px;
}

.section-header p {
    color: var(--text-secondary);
    font-size: 18px;
}

/* ======================== */
/* PLAYGROUND SECTION */
/* ======================== */

.playground-section {
    padding: var(--section-padding) 48px;
    background: var(--bg-primary);
}

.playground-container {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 24px;
    max-width: 1800px;
    margin: 0 auto;
}

.visualization-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Editor Panel */
.editor-panel,
.visualization-panel,
.phase-panel {
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-color);
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 14px;
}

.file-icon {
    font-size: 16px;
}

.panel-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--gradient-primary);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s;
}

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

.action-btn:last-child,
.action-btn.secondary {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.play-icon {
    font-size: 10px;
}

/* Code Editor */
.code-editor {
    display: flex;
    height: 300px;
    overflow: hidden;
}

.line-numbers {
    padding: 16px 8px;
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    text-align: right;
    user-select: none;
    min-width: 50px;
    overflow-y: auto;
}

#code-input {
    flex: 1;
    padding: 16px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    resize: none;
    outline: none;
}

/* Parameter Sliders */
.parameter-panel {
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    margin-top: 16px;
    overflow: hidden;
}

.sliders-container {
    padding: 16px 20px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.slider-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.slider-group label {
    font-size: 13px;
    color: var(--text-secondary);
}

.slider-group label span {
    color: var(--primary);
    font-weight: 600;
}

.slider-group input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-tertiary);
    appearance: none;
    cursor: pointer;
}

.slider-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    transition: transform 0.2s;
}

.slider-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

/* Visualization Panel */
.sim-controls {
    display: flex;
    gap: 4px;
}

.control-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.control-btn:hover,
.control-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.canvas-wrapper {
    position: relative;
    height: 350px;
    background: #050508;
}

[data-theme="light"] .canvas-wrapper {
    background: #e2e8f0;
}

#sim-canvas {
    width: 100%;
    height: 100%;
}

.three-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.three-container.hidden {
    display: none;
}

.canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 15, 0.8);
    color: var(--text-muted);
    font-size: 16px;
    transition: opacity 0.3s;
}

.canvas-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.sim-info {
    display: flex;
    gap: 24px;
    padding: 16px 20px;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-label {
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 600;
}

/* Phase Portrait */
.phase-panel {
    height: 200px;
}

.phase-wrapper {
    height: calc(100% - 52px);
    background: #050508;
}

[data-theme="light"] .phase-wrapper {
    background: #e2e8f0;
}

#phase-canvas {
    width: 100%;
    height: 100%;
}

/* Action Bar */
.action-bar {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* ======================== */
/* EXAMPLES SECTION */
/* ======================== */

.examples-section {
    padding: var(--section-padding) 48px;
    background: var(--bg-secondary);
}

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

.example-card {
    background: var(--bg-card);
    border-radius: 16px;
    border: 2px solid var(--border-color);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s;
}

.example-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}

.example-card.active {
    border-color: var(--primary);
}

.example-preview {
    height: 160px;
    background: #050508;
    position: relative;
}

[data-theme="light"] .example-preview {
    background: #e2e8f0;
}

.example-info {
    padding: 20px;
}

.example-info h3 {
    font-size: 18px;
    margin-bottom: 4px;
}

.example-info p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 12px;
}

.difficulty {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 600;
}

.difficulty.easy {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.difficulty.medium {
    background: rgba(245, 158, 11, 0.2);
    color: var(--accent);
}

.difficulty.hard {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

/* ======================== */
/* FEATURES SECTION */
/* ======================== */

.features-section {
    padding: var(--section-padding) 48px;
    background: var(--bg-primary);
}

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

.feature-card {
    padding: 32px;
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    transition: all 0.3s;
}

.feature-card:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
}

.feature-icon {
    font-size: 40px;
    margin-bottom: 20px;
}

.feature-card h3 {
    font-size: 20px;
    margin-bottom: 12px;
}

.feature-card p {
    color: var(--text-secondary);
    font-size: 15px;
}

/* ======================== */
/* EXPORT SECTION */
/* ======================== */

.export-section {
    padding: var(--section-padding) 48px;
    background: var(--bg-secondary);
}

.export-tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 32px;
}

.export-tab {
    padding: 12px 24px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.export-tab:hover,
.export-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.export-code {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
}

.export-code pre {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    overflow-x: auto;
}

.export-code code {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--text-primary);
}

.copy-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* ======================== */
/* CTA SECTION */
/* ======================== */

.cta-section {
    padding: var(--section-padding) 48px;
    background: var(--bg-primary);
    text-align: center;
}

.cta-content h2 {
    font-size: 36px;
    margin-bottom: 16px;
}

.cta-content p {
    color: var(--text-secondary);
    font-size: 18px;
    margin-bottom: 32px;
}

.install-command {
    display: inline-flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-bottom: 32px;
}

.install-command code {
    font-family: var(--font-mono);
    font-size: 16px;
    color: var(--secondary);
}

.install-command .copy-btn {
    position: static;
    padding: 8px;
    background: transparent;
    border: none;
}

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

/* ======================== */
/* FOOTER */
/* ======================== */

.footer {
    padding: 40px 48px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
}

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

.footer-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.footer-links {
    display: flex;
    gap: 24px;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--text-primary);
}

.footer-copyright {
    color: var(--text-muted);
    font-size: 14px;
}

/* ======================== */
/* MODAL */
/* ======================== */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 500px;
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 18px;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
}

.modal-close:hover {
    background: var(--danger);
    color: white;
}

.modal-body {
    padding: 24px;
}

.share-url-container {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.share-url-container input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 13px;
}

.share-url-container .copy-btn {
    position: static;
}

/* ======================== */
/* TOAST */
/* ======================== */

#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1001;
}

.toast {
    padding: 12px 24px;
    background: var(--success);
    color: white;
    border-radius: 8px;
    font-weight: 600;
    margin-top: 8px;
    animation: slideIn 0.3s;
}

@keyframes slideIn {
    from {
        transform: translateX(100px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ======================== */
/* RESPONSIVE */
/* ======================== */

@media (max-width: 1024px) {
    .playground-container {
        grid-template-columns: 1fr;
    }

    .stats-bar {
        gap: 40px;
        flex-wrap: wrap;
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: 16px 24px;
    }

    .nav-links {
        display: none;
    }

    .hero-title {
        font-size: 36px;
    }

    .hero-cta {
        flex-direction: column;
    }

    .section-header h2 {
        font-size: 32px;
    }

    .playground-section,
    .examples-section,
    .features-section,
    .export-section,
    .cta-section {
        padding: 60px 24px;
    }

    .footer-content {
        flex-direction: column;
        gap: 24px;
        text-align: center;
    }

    .sliders-container {
        grid-template-columns: 1fr;
    }
}

/* ======================== */
/* PYTHON MODE */
/* ======================== */

.mode-toggle {
    background: var(--bg-tertiary) !important;
    border: 1px solid var(--border-color) !important;
    color: var(--text-secondary) !important;
}

.mode-toggle.active {
    background: linear-gradient(135deg, #306998 0%, #FFD43B 100%) !important;
    border-color: #306998 !important;
    color: white !important;
}

.mode-toggle.loading {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 15, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    color: var(--text-primary);
}

.loading-overlay.hidden {
    display: none;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

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

.loading-text {
    font-size: 16px;
    margin-bottom: 10px;
}

.loading-progress {
    width: 200px;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
}

.loading-progress-bar {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 3px;
    transition: width 0.3s;
}

.python-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: linear-gradient(135deg, #306998 0%, #FFD43B 100%);
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    color: white;
    margin-left: 8px;
}