/* ================================================
   MOOG MODULATOR - Retro Analog Synthesizer UI
   ================================================ */

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Share+Tech+Mono&display=swap');

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

:root {
  --panel-bg: #1a1a1a;
  --panel-surface: #222;
  --panel-border: #333;
  --module-bg: linear-gradient(180deg, #2a2a2a 0%, #1e1e1e 100%);
  --accent: #ff8c00;
  --accent-dim: #aa5500;
  --accent-glow: rgba(255, 140, 0, 0.4);
  --text-primary: #e0d8cc;
  --text-dim: #888;
  --knob-outer: #111;
  --knob-body: linear-gradient(145deg, #444 0%, #222 50%, #333 100%);
  --knob-indicator: #ff8c00;
  --key-white: linear-gradient(180deg, #f5f0e8 0%, #d8d0c4 100%);
  --key-black: linear-gradient(180deg, #333 0%, #111 100%);
  --key-active: #ff8c00;
}

body {
  background: #0d0d0d;
  color: var(--text-primary);
  font-family: 'Share Tech Mono', monospace;
  min-height: 100vh;
  overflow-x: hidden;
}

#app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px;
  opacity: 0.6;
  transition: opacity 0.5s ease;
}

#app.powered-on {
  opacity: 1;
}

/* ---- Top Bar ---- */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: linear-gradient(90deg, #1a1a1a, #222, #1a1a1a);
  border: 1px solid var(--panel-border);
  border-radius: 8px 8px 0 0;
  border-bottom: 2px solid var(--accent-dim);
}

.logo {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 28px;
  letter-spacing: 6px;
  color: var(--accent);
  text-shadow: 0 0 20px var(--accent-glow), 0 0 40px rgba(255, 140, 0, 0.2);
}

.logo-sub {
  font-weight: 400;
  font-size: 14px;
  letter-spacing: 8px;
  color: var(--text-dim);
  margin-left: 4px;
}

.power-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

.power-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid #444;
  background: #1a1a1a;
  color: #666;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.power-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.power-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: #2a1a00;
  box-shadow: 0 0 15px var(--accent-glow), inset 0 0 10px rgba(255, 140, 0, 0.1);
}

.power-label {
  font-family: 'Orbitron', sans-serif;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 2px;
}

/* ---- Main Container ---- */
.synth-container {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ---- Visualization ---- */
.viz-section {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.viz-panel {
  background: #0a0a0a;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  padding: 10px;
  position: relative;
}

.viz-panel-wide {
  grid-column: 1 / -1;
}

.viz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.viz-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--text-dim);
}

.viz-led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 140, 0, 0.2);
  transition: all 0.1s;
}

canvas {
  width: 100%;
  display: block;
  border-radius: 3px;
}

/* ---- Module Panel ---- */
.module {
  background: var(--module-bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  overflow: hidden;
}

.module-header {
  font-family: 'Orbitron', sans-serif;
  font-size: 10px;
  letter-spacing: 4px;
  color: var(--accent);
  padding: 8px 14px;
  background: linear-gradient(90deg, rgba(255, 140, 0, 0.08), transparent);
  border-bottom: 1px solid rgba(255, 140, 0, 0.15);
}

.module-body {
  padding: 14px;
}

/* ---- Oscillators ---- */
.oscillators {
  grid-column: 1 / -1;
}

.oscillators .module-body {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.osc-group {
  flex: 1;
}

.osc-label {
  font-family: 'Orbitron', sans-serif;
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.osc-divider {
  width: 1px;
  align-self: stretch;
  background: linear-gradient(180deg, transparent, var(--panel-border), transparent);
}

/* ---- Knobs ---- */
.knob-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

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

.knob {
  width: 52px;
  height: 52px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.knob.knob-large {
  width: 68px;
  height: 68px;
}

.knob.knob-small {
  width: 42px;
  height: 42px;
}

.knob-outer {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--knob-outer);
  border: 2px solid #333;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.knob-inner {
  width: 78%;
  height: 78%;
  border-radius: 50%;
  background: var(--knob-body);
  position: relative;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.08);
  transition: transform 0.02s linear;
}

.knob-indicator {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 3px;
  height: 30%;
  background: var(--knob-indicator);
  border-radius: 2px;
  box-shadow: 0 0 6px var(--accent-glow);
}

.knob-active .knob-outer {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

.knob-label {
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.knob-value {
  font-size: 10px;
  color: var(--accent);
  font-family: 'Share Tech Mono', monospace;
}

/* ---- Wave Select Buttons ---- */
.wave-select {
  display: flex;
  gap: 4px;
  margin-top: 10px;
  justify-content: center;
}

.wave-btn {
  width: 36px;
  height: 26px;
  border: 1px solid #444;
  border-radius: 4px;
  background: #1a1a1a;
  color: #666;
  cursor: pointer;
  padding: 3px;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wave-btn:hover {
  border-color: var(--accent-dim);
  color: var(--accent-dim);
}

.wave-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(255, 140, 0, 0.1);
  box-shadow: 0 0 8px rgba(255, 140, 0, 0.2);
}

.wave-btn svg {
  width: 100%;
  height: 100%;
}

/* ---- Filter ---- */
.filter-type-select {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  justify-content: center;
}

.filter-btn {
  padding: 4px 16px;
  border: 1px solid #444;
  border-radius: 4px;
  background: #1a1a1a;
  color: #888;
  font-family: 'Orbitron', sans-serif;
  font-size: 10px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-btn:hover {
  border-color: var(--accent-dim);
}

.filter-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(255, 140, 0, 0.1);
}

/* ---- Envelopes ---- */
.envelopes .module-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.env-group {
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.env-group:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.env-label {
  font-family: 'Orbitron', sans-serif;
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--text-dim);
  margin-bottom: 8px;
  text-align: center;
}

/* ---- LFO ---- */
.lfo .module-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.lfo-dest-select {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.lfo-dest-label {
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--text-dim);
}

.lfo-dest-btn {
  padding: 3px 10px;
  border: 1px solid #444;
  border-radius: 3px;
  background: #1a1a1a;
  color: #888;
  font-family: 'Share Tech Mono', monospace;
  font-size: 9px;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.lfo-dest-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(255, 140, 0, 0.1);
}

/* ---- Master ---- */
.master .module-body {
  display: flex;
  justify-content: center;
}

/* ---- Keyboard ---- */
.keyboard-section {
  grid-column: 1 / -1;
  background: linear-gradient(180deg, #1a1a1a, #111);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  padding: 14px 10px 10px;
}

.keyboard {
  display: flex;
  justify-content: center;
  height: 120px;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}

.octave-group {
  display: flex;
  position: relative;
  height: 100%;
}

.key {
  position: relative;
  cursor: pointer;
  transition: background 0.05s;
}

.key-white {
  width: 36px;
  height: 100%;
  background: var(--key-white);
  border: 1px solid #999;
  border-radius: 0 0 4px 4px;
  z-index: 1;
  margin-right: 1px;
}

.key-white:hover {
  background: linear-gradient(180deg, #fff 0%, #e8e0d4 100%);
}

.key-white.active {
  background: linear-gradient(180deg, var(--accent) 0%, #cc7000 100%) !important;
  box-shadow: 0 0 15px var(--accent-glow);
  transform: scaleY(0.98);
  transform-origin: top;
}

.key-black {
  width: 22px;
  height: 65%;
  background: var(--key-black);
  border: 1px solid #000;
  border-radius: 0 0 3px 3px;
  position: absolute;
  z-index: 2;
  box-shadow: 0 3px 5px rgba(0, 0, 0, 0.5);
}

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

.key-black.active {
  background: linear-gradient(180deg, var(--accent) 0%, #995500 100%) !important;
  box-shadow: 0 0 12px var(--accent-glow);
  height: 63%;
}

/* Position black keys */
.octave-group .key-black:nth-of-type(1) { left: 24px; }   /* C# */
.octave-group .key-black:nth-of-type(2) { left: 61px; }   /* D# */
.octave-group .key-black:nth-of-type(3) { left: 135px; }  /* F# */
.octave-group .key-black:nth-of-type(4) { left: 172px; }  /* G# */
.octave-group .key-black:nth-of-type(5) { left: 209px; }  /* A# */

.key-label {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 8px;
  color: #999;
  pointer-events: none;
}

.keyboard-info {
  text-align: center;
  margin-top: 8px;
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 1px;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: #111;
}

::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 3px;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .synth-container {
    grid-template-columns: 1fr;
  }

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

  .oscillators .module-body {
    flex-direction: column;
  }

  .osc-divider {
    width: 100%;
    height: 1px;
  }

  .keyboard {
    height: 90px;
  }

  .key-white {
    width: 28px;
  }

  .key-black {
    width: 18px;
  }

  .octave-group .key-black:nth-of-type(1) { left: 19px; }
  .octave-group .key-black:nth-of-type(2) { left: 48px; }
  .octave-group .key-black:nth-of-type(3) { left: 106px; }
  .octave-group .key-black:nth-of-type(4) { left: 135px; }
  .octave-group .key-black:nth-of-type(5) { left: 164px; }
}

@media (max-width: 600px) {
  .knob-row {
    gap: 10px;
  }

  .knob {
    width: 42px;
    height: 42px;
  }

  .knob.knob-large {
    width: 54px;
    height: 54px;
  }

  .key-white {
    width: 22px;
  }

  .keyboard {
    height: 75px;
  }
}

/* ---- Ambient animation ---- */
@keyframes glowPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.powered-on .logo {
  animation: glowPulse 3s ease-in-out infinite;
}

.powered-on .module-header {
  text-shadow: 0 0 8px var(--accent-glow);
}

/* ================================================
   MOBILE PLAY MODE
   ================================================ */

.mobile-play {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 16px 10px 30px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  min-height: calc(100vh - 80px);
  min-height: calc(100dvh - 80px);
  justify-content: center;
}

/* Mobile visualization */
.mobile-viz {
  width: 100%;
  max-width: 400px;
  aspect-ratio: 1;
  border-radius: 50%;
  overflow: hidden;
  background: #0a0a0a;
  border: 2px solid #2a2a2a;
  position: relative;
}

.mobile-viz canvas {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

/* Note display */
.mobile-note-display {
  font-family: 'Orbitron', sans-serif;
  font-size: 42px;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 4px;
  text-shadow: 0 0 30px var(--accent-glow);
  min-width: 120px;
  text-align: center;
}

/* Big play button */
.mobile-sound-btn {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.mobile-sound-btn-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid #444;
  transition: all 0.2s ease;
}

.mobile-sound-btn-inner {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: linear-gradient(145deg, #2a2a2a, #1a1a1a);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #888;
  transition: all 0.15s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.mobile-sound-btn:active .mobile-sound-btn-inner,
.mobile-sound-btn.playing .mobile-sound-btn-inner {
  background: linear-gradient(145deg, #3a2000, #1a0e00);
  color: var(--accent);
  box-shadow: 0 0 30px var(--accent-glow), inset 0 0 20px rgba(255, 140, 0, 0.1);
}

.mobile-sound-btn.playing .mobile-sound-btn-ring {
  border-color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
}

@keyframes ringPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.06); opacity: 0.7; }
}

.mobile-sound-btn.playing .mobile-sound-btn-ring {
  animation: ringPulse 1.5s ease-in-out infinite;
}

/* Key switcher */
.mobile-key-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mobile-key-arrow {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid #444;
  background: #1a1a1a;
  color: #888;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.mobile-key-arrow:active {
  border-color: var(--accent);
  color: var(--accent);
}

.mobile-key-list {
  display: flex;
  gap: 4px;
}

.mobile-key-item {
  width: 38px;
  height: 38px;
  border-radius: 6px;
  border: 1px solid #444;
  background: #1a1a1a;
  color: #888;
  font-family: 'Orbitron', sans-serif;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.mobile-key-item.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(255, 140, 0, 0.12);
  box-shadow: 0 0 10px rgba(255, 140, 0, 0.2);
}

/* Octave switcher */
.mobile-octave-switcher {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mobile-oct-btn {
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid #444;
  background: #1a1a1a;
  color: #888;
  font-family: 'Orbitron', sans-serif;
  font-size: 10px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.mobile-oct-btn:active {
  border-color: var(--accent);
  color: var(--accent);
}

.mobile-oct-display {
  font-family: 'Orbitron', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  min-width: 30px;
  text-align: center;
}

/* Waveform switcher */
.mobile-wave-switcher {
  display: flex;
  gap: 8px;
}

.mobile-wave-btn {
  width: 50px;
  height: 36px;
  border: 1px solid #444;
  border-radius: 6px;
  background: #1a1a1a;
  color: #666;
  cursor: pointer;
  padding: 6px;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.mobile-wave-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(255, 140, 0, 0.1);
  box-shadow: 0 0 10px rgba(255, 140, 0, 0.2);
}

.mobile-wave-btn svg {
  width: 100%;
  height: 100%;
}

/* Show mobile, hide desktop on small screens */
@media (max-width: 600px) {
  .mobile-play {
    display: flex;
  }

  .desktop-only {
    display: none !important;
  }

  .keyboard-section {
    display: none !important;
  }

  .top-bar {
    padding: 10px 16px;
  }

  .logo {
    font-size: 18px;
    letter-spacing: 3px;
  }

  .logo-sub {
    font-size: 10px;
    letter-spacing: 4px;
  }

  #app {
    padding: 0;
  }

  .top-bar {
    border-radius: 0;
  }

  .mobile-play {
    border-radius: 0;
  }
}
