/* ========================================
   Professional Frontend Specifications
   Mobile-first, WCAG 2.2 AA Compliant
   ======================================== */

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

:root {
    /* Color System - WCAG AA Compliant */
    --primary: #667eea;
    --secondary: #764ba2;
    --accent: #f093fb;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --bg-light: #f7fafc;
    --border-color: #e2e8f0;
    
    /* Spacing Grid (8px) */
    --space-xs: 8px;
    --space-sm: 16px;
    --space-md: 24px;
    --space-lg: 32px;
    --space-xl: 48px;
    
    /* Typography */
    --font-base: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'Courier New', monospace;
    
    /* Performance: Use will-change sparingly */
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: var(--font-base);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-light);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   Layout - Mobile First
   ======================================== */

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-md);
}

.header {
    text-align: center;
    margin-bottom: var(--space-lg);
}

.header h1 {
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
}

.layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-md);
}

/* Tablet: 768px+ */
@media (min-width: 768px) {
    .layout {
        grid-template-columns: 320px 1fr;
    }
}

/* Desktop: 1024px+ */
@media (min-width: 1024px) {
    .layout {
        grid-template-columns: 360px 1fr;
        gap: var(--space-lg);
    }
}

/* ========================================
   Controls Panel
   ======================================== */

.controls-panel {
    background: white;
    border-radius: 16px;
    padding: var(--space-md);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    height: fit-content;
    position: sticky;
    top: var(--space-md);
}

.control-section {
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-color);
}

.control-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.control-section h2 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: var(--space-sm);
    color: var(--text-primary);
}

.control-group {
    margin-bottom: var(--space-sm);
}

.control-group label {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.control-group label span {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ========================================
   Form Inputs - WCAG 2.2 AA Compliant
   ======================================== */

input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
}

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

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
    transition: var(--transition-smooth);
}

/* Focus indicators for accessibility */
input[type="range"]:focus-visible::-webkit-slider-thumb {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

input[type="range"]:focus-visible::-moz-range-thumb {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

input[type="color"] {
    width: 100%;
    height: 44px; /* WCAG touch target */
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-smooth);
}

input[type="color"]:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
    border-color: var(--primary);
}

output {
    font-weight: 600;
    color: var(--primary);
    min-width: 50px;
    text-align: right;
}

/* ========================================
   Preset Buttons
   ======================================== */

.preset-buttons {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-xs);
}

.preset-btn {
    padding: var(--space-xs) var(--space-sm);
    min-height: 44px; /* WCAG touch target */
    background: var(--bg-light);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.preset-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-2px);
}

.preset-btn:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.preset-btn:active {
    transform: translateY(0);
}

/* ========================================
   Preview Section
   ======================================== */

.preview-section {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.preview-container {
    min-height: 500px;
    border-radius: 16px;
    padding: var(--space-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    position: relative;
    overflow: hidden;
}

/* Animated background elements for depth */
.preview-container::before {
    content: '';
    position: absolute;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    top: -50px;
    right: -50px;
    animation: float 6s ease-in-out infinite;
}

.preview-container::after {
    content: '';
    position: absolute;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    bottom: -30px;
    left: -30px;
    animation: float 8s ease-in-out infinite reverse;
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(5deg); }
}

/* ========================================
   Preview Card - Glassmorphism + Neumorphism
   ======================================== */

.preview-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px); /* Safari support */
    border-radius: 24px;
    padding: var(--space-lg);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 
        20px 20px 40px rgba(0, 0, 0, 0.1),
        -20px -20px 40px rgba(255, 255, 255, 0.1);
    max-width: 400px;
    width: 100%;
    position: relative;
    z-index: 1;
    transition: var(--transition-smooth);
    /* Performance optimization */
    will-change: transform;
    transform: translateZ(0);
}

.preview-card h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    margin-bottom: var(--space-xs);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.preview-card p {
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: var(--space-md);
    font-size: 0.95rem;
    line-height: 1.6;
}

.card-content {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.stat {
    background: rgba(255, 255, 255, 0.1);
    padding: var(--space-sm);
    border-radius: 12px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    margin-bottom: 4px;
}

.stat-label {
    display: block;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cta-button {
    width: 100%;
    min-height: 44px; /* WCAG touch target */
    padding: 12px 24px;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.cta-button:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.cta-button:focus-visible {
    outline: 3px solid white;
    outline-offset: 2px;
}

.cta-button:active {
    transform: translateY(0);
}

/* ========================================
   Code Section
   ======================================== */

.code-section {
    background: white;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-color);
}

.code-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.copy-btn {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 8px 16px;
    min-height: 44px; /* WCAG touch target */
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.copy-btn:hover {
    background: #5568d3;
    transform: translateY(-2px);
}

.copy-btn:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}

.copy-btn:active {
    transform: translateY(0);
}

.copy-btn.copied {
    background: #48bb78;
}

.code-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-light);
}

.tab-btn {
    flex: 1;
    padding: var(--space-sm);
    min-height: 44px; /* WCAG touch target */
    background: transparent;
    border: none;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-smooth);
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    background: rgba(102, 126, 234, 0.05);
    color: var(--primary);
}

.tab-btn:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: -3px;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: white;
}

.code-content {
    position: relative;
    max-height: 500px;
    overflow-y: auto;
}

.code-block {
    display: none;
    margin: 0;
    padding: var(--space-md);
    background: #1e293b;
    color: #e2e8f0;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.7;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.code-block.active {
    display: block;
}

/* Scrollbar styling */
.code-content::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.code-content::-webkit-scrollbar-track {
    background: #f1f5f9;
}

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

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

/* ========================================
   Responsive Design - Mobile Optimization
   ======================================== */

@media (max-width: 767px) {
    .container {
        padding: var(--space-sm);
    }
    
    .controls-panel {
        position: static;
    }
    
    .preview-container {
        min-height: 400px;
        padding: var(--space-md);
    }
    
    .preview-card {
        padding: var(--space-md);
    }
    
    .card-content {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   Accessibility - High Contrast Mode
   ======================================== */

@media (prefers-contrast: high) {
    .preview-card {
        border: 2px solid white;
    }
    
    .cta-button {
        border: 2px solid white;
    }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}