/* ==========================================
   ETHEREMIN - Digital Theremin Styles
   ========================================== */

:root {
    /* Color palette - ethereal/cosmic theme */
    --bg-primary: #0a0a1a;
    --bg-secondary: #12122a;
    --bg-tertiary: #1a1a3a;
    --bg-glass: rgba(20, 20, 50, 0.8);
    
    --accent-primary: #00d4ff;
    --accent-secondary: #ff00d4;
    --accent-tertiary: #d4ff00;
    --accent-glow: rgba(0, 212, 255, 0.5);
    
    --text-primary: #ffffff;
    --text-secondary: #a0a0c0;
    --text-muted: #606080;
    
    --success: #00ff88;
    --warning: #ffaa00;
    --error: #ff4444;
    
    /* Gradients */
    --gradient-main: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-accent: linear-gradient(135deg, #00d4ff 0%, #ff00d4 100%);
    --gradient-bg: radial-gradient(ellipse at center, #1a1a3a 0%, #0a0a1a 100%);
    
    /* Sizing */
    --border-radius: 12px;
    --border-radius-lg: 20px;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    
    /* Animation */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gradient-bg);
    color: var(--text-primary);
    line-height: 1.6;
}

/* Container */
.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* Header */
.header {
    position: absolute;
    top: var(--spacing-md);
    left: var(--spacing-md);
    z-index: 10;
    text-align: left;
    pointer-events: none;
}

.title {
    font-size: 2rem;
    font-weight: 700;
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    text-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
}

.title-icon {
    display: none;
}

@keyframes pulse-glow {
    0%, 100% { 
        filter: drop-shadow(0 0 10px var(--accent-primary));
        transform: scale(1);
    }
    50% { 
        filter: drop-shadow(0 0 20px var(--accent-primary)) drop-shadow(0 0 40px var(--accent-secondary));
        transform: scale(1.1);
    }
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-top: var(--spacing-xs);
}

/* Main Area */
.main-area {
    flex: 1;
    width: 100%;
    height: 100%;
    position: relative;
}

/* Video Container */
.video-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-secondary);
    overflow: hidden;
}

#webcam {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    opacity: 0.9;
}

#hand-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Pitch Guides */
.pitch-guides {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    pointer-events: none;
    opacity: 0.7;
}

.pitch-line {
    position: absolute;
    top: 0;
    width: 2px;
    height: 30%;
    transition: opacity var(--transition-fast);
}

.pitch-line.natural {
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.6), transparent);
}

.pitch-line.sharp {
    background: linear-gradient(to bottom, rgba(150, 150, 170, 0.4), transparent);
    width: 1px;
}

.pitch-line.active {
    background: linear-gradient(to bottom, var(--accent-primary), transparent);
    box-shadow: 0 0 20px var(--accent-glow);
    height: 100%;
}

.pitch-label {
    position: absolute;
    top: 8px;
    transform: translateX(-50%);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
}

/* Hand Indicators */
.hand-indicator {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--spacing-xs);
    transition: all var(--transition-fast);
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, -25%);
}

.hand-indicator.visible {
    opacity: 1;
}

.hand-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 3px solid;
    animation: dot-pulse 1.5s ease-in-out infinite;
}

.pitch-hand .hand-dot {
    border-color: var(--accent-primary);
    background: rgba(0, 212, 255, 0.3);
    box-shadow: 0 0 20px var(--accent-primary);
}

.volume-hand .hand-dot {
    border-color: var(--accent-secondary);
    background: rgba(255, 0, 212, 0.3);
    box-shadow: 0 0 20px var(--accent-secondary);
}

@keyframes dot-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.hand-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
}

.pitch-hand .hand-label {
    color: var(--accent-primary);
}

.volume-hand .hand-label {
    color: var(--accent-secondary);
}

/* Note Display */
.note-display {
    position: absolute;
    top: var(--spacing-lg);
    left: var(--spacing-lg);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--border-radius);
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
    min-width: 120px;
}

.note-name {
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
    transition: all var(--transition-fast);
}

.note-freq {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-family: 'Monaco', 'Consolas', monospace;
}

/* Volume Meter */
.volume-meter {
    position: absolute;
    right: var(--spacing-lg);
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 200px;
    background: var(--bg-glass);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 100;
}

.meter-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--gradient-accent);
    transition: height var(--transition-fast);
    border-radius: 0 0 8px 8px;
}

.meter-label {
    position: absolute;
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 1px;
}

/* Waveform Canvas */
.waveform-canvas {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: transparent;
    pointer-events: none;
}

/* Controls Panel */
.controls-panel {
    position: absolute;
    bottom: 200px;
    left: var(--spacing-lg);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border-radius: var(--border-radius);
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 320px;
    z-index: 100;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-group:first-child {
    flex-direction: row;
    gap: var(--spacing-xs);
}

.collapsible-content {
    max-height: 1000px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 1;
}

.controls-panel.collapsed .collapsible-content {
    max-height: 0;
    opacity: 0;
}

#collapse-icon {
    transition: all var(--transition-normal);
}

.controls-panel.collapsed #collapse-icon {
    transform: none;
}

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

/* Buttons */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 6px 12px;
    border: none;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    flex: 1;
}

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

.btn-primary {
    background: var(--gradient-accent);
    color: white;
    box-shadow: 0 4px 20px rgba(0, 212, 255, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px rgba(0, 212, 255, 0.5);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-secondary);
    border-color: rgba(255, 255, 255, 0.3);
}

.btn-icon {
    font-size: 0.8rem;
}

/* Wave Selector */
.wave-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    background: var(--bg-secondary);
    padding: 4px;
    border-radius: 8px;
}

.wave-btn {
    padding: 6px 8px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.wave-btn:hover {
    color: var(--text-primary);
}

.wave-btn.active {
    background: var(--gradient-accent);
    color: white;
    box-shadow: 0 2px 10px rgba(0, 212, 255, 0.3);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
}

.toggle-switch input {
    display: none;
}

.toggle-switch label {
    display: flex;
    width: 100%;
    height: 32px;
    background: var(--bg-secondary);
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.toggle-switch label::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: calc(50% - 3px);
    height: calc(100% - 6px);
    background: var(--gradient-accent);
    border-radius: 8px;
    transition: transform var(--transition-normal);
}

.toggle-switch input:checked + label::before {
    transform: translateX(100%);
}

.toggle-off, .toggle-on {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 1;
    transition: color var(--transition-fast);
}

.toggle-off {
    color: white;
}

.toggle-on {
    color: var(--text-muted);
}

.toggle-switch input:checked + label .toggle-off {
    color: var(--text-muted);
}

.toggle-switch input:checked + label .toggle-on {
    color: white;
}

/* Slider */
.slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-secondary);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--gradient-accent);
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 212, 255, 0.4);
    transition: transform var(--transition-fast);
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--gradient-accent);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 10px rgba(0, 212, 255, 0.4);
}

/* Status Bar */
.status-bar {
    display: none;
}

/* Status Indicators in Control Panel */
.status-indicators {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.status-item-compact {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.status-item-compact.info {
    font-family: 'Monaco', 'Consolas', monospace;
}

/* Startup Overlay */
.startup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 26, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    opacity: 1;
    transition: opacity var(--transition-normal);
    cursor: pointer;
}

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

.startup-message {
    text-align: center;
}

.startup-message p {
    font-size: 1.8rem;
    font-weight: 300;
    color: var(--text-primary);
    margin: 0 0 8px 0;
    text-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}

.startup-message p:first-child {
    font-weight: 400;
    font-size: 2rem;
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.startup-subtitle {
    font-size: 1rem !important;
    color: var(--text-secondary) !important;
    font-weight: 300 !important;
}

/* Instructions Overlay */
.instructions-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 26, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity var(--transition-normal);
}

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

.instructions-card {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    padding: var(--spacing-xl);
    border-radius: var(--border-radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 500px;
    text-align: center;
}

.instructions-card h2 {
    font-size: 1.8rem;
    margin-bottom: var(--spacing-lg);
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.instruction-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    text-align: left;
}

.instruction-item {
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
}

.instruction-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.instruction-text {
    display: flex;
    flex-direction: column;
}

.instruction-text strong {
    color: var(--text-primary);
}

.instruction-text span {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: var(--spacing-sm);
    }
    
    .title {
        font-size: 1.8rem;
    }
    
    .subtitle {
        font-size: 0.85rem;
    }
    
    .controls-panel {
        gap: var(--spacing-md);
        padding: var(--spacing-sm);
    }
    
    .control-group {
        flex: 1 1 40%;
    }
    
    .note-display {
        padding: var(--spacing-sm);
    }
    
    .note-name {
        font-size: 1.8rem;
    }
    
    .volume-meter {
        height: 120px;
    }
}

/* Playing state animations */
.video-container.playing {
    box-shadow: 
        0 0 0 1px rgba(255, 255, 255, 0.1),
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 100px rgba(0, 212, 255, 0.3),
        0 0 200px rgba(255, 0, 212, 0.1);
}

/* Smooth color transitions for note changes */
.note-display.note-change {
    animation: note-flash 0.15s ease;
}

@keyframes note-flash {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}
