/**
 * FM Synthesizer Styles
 * Dark synthesizer theme with knobs, faders, and LED indicators
 */

/* ============================================
   CSS CUSTOM PROPERTIES
   ============================================ */

:root {
    /* Background colors */
    --bg-dark: #0a0a0a;
    --bg-panel: #1a1a1a;
    --bg-module: #2a2a2a;
    --bg-module-light: #3a3a3a;

    /* Text colors */
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-dim: #666666;

    /* LED colors */
    --led-off: #333333;
    --led-green: #00ff00;
    --led-orange: #ff6600;
    --led-red: #ff0000;
    --led-blue: #00aaff;

    /* Accent colors */
    --accent-primary: #ff6600;
    --accent-secondary: #00aaff;

    /* Borders */
    --border-light: #444444;
    --border-dark: #1a1a1a;

    /* Shadows */
    --shadow-inset: inset 0 2px 4px rgba(0, 0, 0, 0.5);
    --shadow-outset: 0 4px 8px rgba(0, 0, 0, 0.3);
    --shadow-knob: 0 2px 4px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    --shadow-knob-active: 0 4px 8px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.1);

    /* Fonts */
    --font-primary: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --font-mono: 'Courier New', monospace;
}

/* ============================================
   RESET & BASE STYLES
   ============================================ */

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

body {
    font-family: var(--font-primary);
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    user-select: none;
}

/* ============================================
   START OVERLAY
   ============================================ */

.start-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.5s ease;
}

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

.start-message h1 {
    font-size: 3rem;
    color: var(--led-orange);
    text-shadow: 0 0 20px var(--led-orange);
    margin-bottom: 1rem;
    letter-spacing: 0.3em;
}

.start-message p {
    font-size: 1.2rem;
    color: var(--text-secondary);
    animation: blink 1.5s infinite;
}

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

/* ============================================
   HEADER
   ============================================ */

.synth-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: var(--bg-panel);
    border-bottom: 2px solid var(--border-light);
}

.synth-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.2em;
    color: var(--led-orange);
    text-shadow: 0 0 10px rgba(255, 102, 0, 0.5);
}

.master-controls {
    display: flex;
    align-items: center;
    gap: 20px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-module);
    border-radius: 4px;
    border: 1px solid var(--border-light);
}

.status-led {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--led-off);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

.status-indicator.active .status-led {
    background: var(--led-green);
    box-shadow: 0 0 8px var(--led-green);
}

.status-indicator.error .status-led {
    background: var(--led-red);
    box-shadow: 0 0 8px var(--led-red);
    animation: pulse-error 0.5s infinite;
}

@keyframes pulse-error {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.status-text {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.master-volume-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
}

.master-volume-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

/* ============================================
   MAIN CONTAINER
   ============================================ */

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

/* ============================================
   MODULATION MATRIX
   ============================================ */

.modulation-matrix-section {
    background: var(--bg-panel);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border-light);
}

.section-title {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 15px;
}

.modulation-matrix {
    display: grid;
    grid-template-columns: 60px repeat(5, 1fr);
    gap: 8px;
    max-width: 500px;
}

.matrix-header {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
    padding: 8px 0;
}

.matrix-row-label {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: var(--led-orange);
    font-weight: 600;
}

.matrix-cell {
    aspect-ratio: 1;
    background: var(--bg-module);
    border: 2px solid var(--border-light);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.matrix-cell:hover {
    border-color: var(--led-orange);
    box-shadow: 0 0 10px rgba(255, 102, 0, 0.3);
}

.matrix-cell.active {
    background: var(--led-orange);
    border-color: var(--led-orange);
    box-shadow: 0 0 15px rgba(255, 102, 0, 0.6);
}

.matrix-master-switch {
    aspect-ratio: 1;
    background: var(--bg-module);
    border: 2px solid var(--border-light);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.matrix-master-switch.active {
    background: var(--led-green);
    border-color: var(--led-green);
    box-shadow: 0 0 15px rgba(0, 255, 0, 0.5);
}

/* ============================================
   OPERATORS SECTION
   ============================================ */

.operators-section {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.operator-module {
    background: var(--bg-panel);
    border-radius: 8px;
    padding: 15px;
    border: 1px solid var(--border-light);
}

.operator-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
}

.operator-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--led-blue);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.operator-led {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--led-off);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

.operator-led.active {
    background: var(--led-green);
    box-shadow: 0 0 8px var(--led-green);
}

.operator-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.control-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: center;
}

/* ============================================
   WAVEFORM SELECTOR
   ============================================ */

.waveform-select {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-module);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.7rem;
    font-family: var(--font-primary);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23b0b0b0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 28px;
}

.waveform-select:focus {
    outline: none;
    border-color: var(--led-orange);
}

/* ============================================
   KNOB
   ============================================ */

.knob-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.knob {
    width: 50px;
    height: 50px;
    background: linear-gradient(145deg, #333333, #222222);
    border-radius: 50%;
    position: relative;
    cursor: ns-resize;
    box-shadow: var(--shadow-knob);
    border: 2px solid var(--border-dark);
    transition: box-shadow 0.2s ease;
}

.knob:hover {
    box-shadow: 0 0 10px rgba(255, 102, 0, 0.3);
}

.knob.active {
    box-shadow: var(--shadow-knob-active);
}

.knob-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin-left: -20px;
    margin-top: -20px;
    background: conic-gradient(
        from 225deg,
        var(--led-orange) 0deg,
        var(--led-orange) var(--rotation, 0deg),
        transparent var(--rotation, 0deg),
        transparent 270deg
    );
    border-radius: 50%;
    mask: radial-gradient(transparent 45%, black 46%);
    -webkit-mask: radial-gradient(transparent 45%, black 46%);
}

.knob-pointer {
    position: absolute;
    top: 5px;
    left: 50%;
    width: 2px;
    height: 8px;
    background: var(--led-orange);
    transform: translateX(-50%) rotate(var(--pointer-rotation, -135deg));
    border-radius: 1px;
    box-shadow: 0 0 4px var(--led-orange);
    pointer-events: none;
}

.knob-value {
    font-size: 0.6rem;
    color: var(--text-dim);
    font-family: var(--font-mono);
    min-width: 50px;
    text-align: center;
}

/* ============================================
   SWITCH
   ============================================ */

.switch-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.switch-label {
    font-size: 0.6rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.switch {
    width: 40px;
    height: 20px;
    background: var(--bg-module);
    border-radius: 10px;
    position: relative;
    cursor: pointer;
    border: 1px solid var(--border-light);
    transition: all 0.2s ease;
}

.switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    background: var(--text-dim);
    border-radius: 50%;
    transition: all 0.2s ease;
}

.switch.on {
    background: rgba(255, 102, 0, 0.3);
    border-color: var(--led-orange);
}

.switch.on::after {
    left: 22px;
    background: var(--led-orange);
    box-shadow: 0 0 8px var(--led-orange);
}

/* ============================================
   LFO SECTION
   ============================================ */

.lfo-section {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.lfo-module {
    background: var(--bg-panel);
    border-radius: 8px;
    padding: 15px;
    border: 1px solid var(--border-light);
}

.lfo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
}

.lfo-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--led-green);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.lfo-led {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--led-off);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

.lfo-led.active {
    background: var(--led-green);
    box-shadow: 0 0 8px var(--led-green);
    animation: pulse-led 1s infinite;
}

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

.lfo-target-select {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-module);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.65rem;
    font-family: var(--font-primary);
    cursor: pointer;
    appearance: none;
}

/* ============================================
   ADSR SECTION
   ============================================ */

.adsr-section {
    background: var(--bg-panel);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border-light);
}

.adsr-modules {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.adsr-module {
    background: var(--bg-module);
    border-radius: 6px;
    padding: 15px;
}

.adsr-title {
    font-size: 0.75rem;
    color: var(--led-blue);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 15px;
    text-align: center;
}

.adsr-controls {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.adsr-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.adsr-label {
    font-size: 0.55rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

/* ============================================
   FADER (Vertical Slider)
   ============================================ */

.fader-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: ns-resize;
}

.fader-track {
    width: 8px;
    height: 80px;
    background: var(--bg-dark);
    border-radius: 4px;
    position: relative;
    border: 1px solid var(--border-light);
}

.fader-thumb {
    position: absolute;
    left: 50%;
    width: 20px;
    height: 10px;
    background: linear-gradient(180deg, #555, #333);
    border: 1px solid var(--border-light);
    border-radius: 2px;
    transform: translateX(-50%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    transition: border-color 0.2s ease;
}

.fader-thumb:hover {
    border-color: var(--led-orange);
}

.fader-thumb::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 4px;
    background: var(--text-dim);
}

.fader-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(180deg, var(--led-orange), transparent);
    border-radius: 4px;
    opacity: 0.3;
    pointer-events: none;
}

.fader-value {
    font-size: 0.55rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    min-width: 40px;
    text-align: center;
}

/* ============================================
   VIRTUAL KEYBOARD
   ============================================ */

.keyboard-section {
    background: var(--bg-panel);
    border-radius: 8px;
    padding: 20px;
    border: 1px solid var(--border-light);
}

.piano-keyboard {
    display: flex;
    position: relative;
    height: 120px;
    overflow-x: auto;
}

.piano-key {
    flex: 1;
    min-width: 40px;
    height: 100%;
    background: linear-gradient(180deg, #f0f0f0, #d0d0d0);
    border: 1px solid #999;
    border-radius: 0 0 4px 4px;
    cursor: pointer;
    position: relative;
    transition: all 0.1s ease;
}

.piano-key:hover {
    background: linear-gradient(180deg, #ffffff, #e0e0e0);
}

.piano-key.active {
    background: linear-gradient(180deg, #ff9933, #ff6600);
    transform: translateY(2px);
    box-shadow: 0 0 15px rgba(255, 102, 0, 0.5);
}

.piano-key.black {
    background: linear-gradient(180deg, #333, #111);
    border-color: #000;
    width: 30px;
    min-width: 30px;
    height: 70%;
    position: absolute;
    z-index: 10;
    border-radius: 0 0 3px 3px;
}

.piano-key.black:hover {
    background: linear-gradient(180deg, #444, #222);
}

.piano-key.black.active {
    background: linear-gradient(180deg, #cc5500, #993300);
}

.piano-key .note-label {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.65rem;
    color: var(--text-dim);
    pointer-events: none;
}

.piano-key.black .note-label {
    color: #666;
    bottom: 5px;
}

/* ============================================
   KEYBOARD HINT
   ============================================ */

.keyboard-hint {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 15px;
    padding: 10px;
    background: var(--bg-module);
    border-radius: 6px;
}

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

.hint-key {
    padding: 4px 8px;
    background: var(--bg-module-light);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-weight: 600;
}

/* ============================================
   PANIC BUTTON
   ============================================ */

.panic-button {
    width: 100%;
    padding: 12px;
    background: linear-gradient(180deg, #aa0000, #880000);
    border: 2px solid #ff0000;
    border-radius: 6px;
    color: white;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.panic-button:hover {
    background: linear-gradient(180deg, #cc0000, #aa0000);
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.5);
}

.panic-button:active {
    transform: scale(0.98);
}

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

@media (max-width: 1024px) {
    .operators-section {
        grid-template-columns: repeat(2, 1fr);
    }

    .lfo-section {
        grid-template-columns: repeat(2, 1fr);
    }

    .adsr-modules {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .synth-container {
        padding: 10px;
    }

    .operators-section,
    .lfo-section {
        grid-template-columns: 1fr;
    }

    .adsr-modules {
        grid-template-columns: 1fr;
    }

    .synth-title {
        font-size: 1rem;
    }

    .piano-key {
        min-width: 30px;
    }

    .piano-key.black {
        min-width: 22px;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.hidden {
    display: none !important;
}

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

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* ============================================
   SCROLLBAR
   ============================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--bg-module-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}
