/* Base styles inspired by Distill.pub */
:root {
    --primary-color: #2e7cd6;
    --text-primary: #1a1a1a;
    --text-secondary: #666;
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --border-color: #e0e0e0;
    --success-color: #4caf50;
    --warning-color: #ff9800;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
    --font-mono: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
}

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

body {
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    text-align: center;
    padding: 3rem 0 2rem;
    border-bottom: 1px solid var(--border-color);
}

h1 {
    font-size: 2.5rem;
    font-weight: 300;
    letter-spacing: -0.5px;
    margin-bottom: 0.5rem;
}

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

/* Status Card */
.status-card {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1rem;
    margin: 2rem 0;
    display: flex;
    align-items: center;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--warning-color);
    animation: pulse 2s ease-in-out infinite;
}

.status-dot.ready {
    background: var(--success-color);
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Controls Section */
.controls-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

.control-group {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1.5rem;
}

.control-group h3 {
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.control-description {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* Layer Selection */
.layer-select {
    width: 100%;
    padding: 0.5rem;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    cursor: pointer;
}

.layer-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Channel Controls */
.channel-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.channel-input {
    flex: 1;
    padding: 0.5rem;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
}

.channel-max {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.channel-slider {
    width: 100%;
    margin-top: 0.5rem;
}

/* Settings Grid */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.setting {
    display: flex;
    flex-direction: column;
}

.setting label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.setting input {
    padding: 0.375rem;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
}

/* Checkboxes */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

/* Buttons */
.visualize-btn {
    width: 100%;
    padding: 1rem 2rem;
    font-size: 1.125rem;
    font-weight: 500;
    color: white;
    background: linear-gradient(135deg, var(--primary-color), #1e5db3);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
}

.visualize-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(46, 124, 214, 0.3);
}

.visualize-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.visualize-btn.running {
    background: linear-gradient(135deg, var(--warning-color), #e68900);
}

.btn-secondary {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    color: var(--primary-color);
    background: white;
    border: 1px solid var(--primary-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

/* Visualization Section */
.visualization-section {
    margin: 3rem 0;
}

.canvas-container {
    position: relative;
    width: 512px;
    height: 512px;
    margin: 0 auto;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

#visualizationCanvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: crisp-edges;
}

/* Progress Overlay */
.progress-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.progress-content {
    width: 80%;
    max-width: 300px;
}

.progress-bar {
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Result Controls */
.result-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.result-controls.hidden {
    display: none;
}

/* Info Panel */
.info-panel {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 2rem;
}

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

.info-panel h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.info-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1rem;
}

.info-list dt {
    font-weight: 500;
    color: var(--text-secondary);
}

.info-list dd {
    font-family: var(--font-mono);
    color: var(--text-primary);
}

/* Gallery Section */
.gallery-section {
    margin: 3rem 0;
}

.gallery-section.hidden {
    display: none;
}

.gallery-section h3 {
    font-size: 1.5rem;
    font-weight: 400;
    margin-bottom: 1.5rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.gallery-item {
    position: relative;
    aspect-ratio: 1;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.gallery-item:hover {
    transform: scale(1.05);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    color: white;
    padding: 0.5rem;
    font-size: 0.75rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 3rem 0;
    border-top: 1px solid var(--border-color);
    margin-top: 4rem;
}

footer p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

.tech-note {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    opacity: 0.7;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }

    h1 {
        font-size: 2rem;
    }

    .controls-section {
        grid-template-columns: 1fr;
    }

    .canvas-container {
        width: 100%;
        max-width: 512px;
        height: auto;
        aspect-ratio: 1;
    }

    .settings-grid {
        grid-template-columns: 1fr 1fr;
    }
}