/* Find The Sound — estética alineada con Find The Key */

:root {
  --bg: #0a0a0a;
  --bg-elevated: #101010;
  --panel-top: #121212;
  --panel-bottom: #0c0c0c;
  --border: #222222;
  --border-focus: #ff8000;
  --text: #f5f5f5;
  --text-muted: #9a9a9a;
  --accent: #ff8000;
  --track: #2a2a2a;
  --viz-bg: #050505;
  --key-white: #e0e0e0;
  --key-black: #111111;
  --radius: 6px;
  --font: "Montserrat", system-ui, -apple-system, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* Textura tipo grano cinematográfico */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.06;
  z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.synth-shell {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 1200px;
  height: 100%;
  max-height: 100vh;
  max-height: 100dvh;
  margin: 0 auto;
  padding: clamp(10px, 1.8vh, 22px) clamp(16px, 3vw, 32px) clamp(10px, 1.8vh, 18px);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  overflow: hidden;
}

.site-header {
  text-align: center;
  flex: 0 0 auto;
  margin-bottom: clamp(8px, 1.4vh, 18px);
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.site-header h1 {
  margin: 0;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.brand-accent {
  color: var(--accent);
}

.synth {
  width: 100%;
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1vh, 14px);
  overflow: hidden;
}

.row {
  width: 100%;
}

.row-top {
  flex: 0 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(200px, 220px) repeat(3, minmax(0, 1fr));
  gap: clamp(10px, 1.5vw, 16px);
  align-items: stretch;
}

.row-bottom {
  flex: 1 1 0;
  min-height: 110px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 2.2fr);
  grid-template-rows: 1fr;
  gap: clamp(10px, 1.5vw, 16px);
  align-items: stretch;
}

.row-bottom > * {
  min-height: 0;
}

@media (max-width: 1024px) {
  .row-top {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-xy {
    grid-column: 1 / -1;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }

  .panel-xy #xyPad {
    margin-left: auto;
    margin-right: auto;
  }

  .row-bottom {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(100px, 28vh);
  }

  .visualizer-big {
    min-height: 0;
    max-height: none;
    height: 100%;
  }
}

@media (max-width: 640px) {
  .row-top {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 760px) {
  .mixer .fader input[type="range"] {
    height: 96px;
  }

  .site-header h1 {
    font-size: clamp(1.35rem, 3.5vw, 1.65rem);
  }

  .panel label {
    margin-top: 8px;
  }
}

.panel {
  background: linear-gradient(180deg, var(--panel-top) 0%, var(--panel-bottom) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(10px, 1.4vh, 18px) clamp(12px, 1.6vw, 18px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.panel:focus-within {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent);
}

.panel h3 {
  margin: 0 0 10px;
  width: 100%;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.panel-xy {
  justify-content: center;
}

.panel-xy h3 {
  margin-bottom: 12px;
}

.panel label {
  text-align: center;
  width: 100%;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 12px;
  color: var(--text-muted);
}

.panel input[type="range"] {
  width: 78%;
  max-width: 220px;
  margin-top: 8px;
}

/* ——— Sliders horizontales ——— */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;
  background: transparent;
  cursor: pointer;
}

input[type="range"]:focus {
  outline: none;
}

input[type="range"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 2px;
  background: var(--track);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  box-shadow: none;
}

input[type="range"]::-moz-range-track {
  height: 3px;
  border-radius: 2px;
  background: var(--track);
  border: none;
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  box-shadow: none;
}

/* ——— Selects ——— */
.wave-select {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: 10px 14px;
  width: 100%;
}

.wave-select > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 72px;
}

.wave-select label {
  margin: 0;
  font-size: 9px;
  letter-spacing: 0.1em;
}

select {
  width: 100%;
  max-width: 100px;
  padding: 8px 10px;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
}

select:hover,
select:focus {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  outline: none;
}

select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ——— Mixer faders verticales (solo este panel: pista clara + tirador rectangular naranja/blanco) ——— */
.mixer {
  display: flex;
  gap: clamp(12px, 2vw, 22px);
  justify-content: center;
  margin-top: 12px;
  width: 100%;
}

.mixer .fader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.mixer .fader span {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.mixer .fader input[type="range"] {
  writing-mode: bt-lr;
  -webkit-appearance: slider-vertical;
  width: 28px;
  height: 120px;
  margin-top: 0;
  background: transparent;
  accent-color: #ff8000;
  color: #ff8000;
}

.mixer .fader input[type="range"]::-webkit-slider-runnable-track {
  -webkit-appearance: none;
  appearance: none;
  width: 4px;
  border-radius: 2px;
  background: #2a2a2a;
  border: none;
  box-shadow: none;
}

.mixer .fader input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 14px;
  margin-left: -9px;
  border-radius: 2px;
  background: #ff8000;
  border: 1px solid #cc6600;
  box-shadow: none;
}

.mixer .fader input[type="range"]::-moz-range-track {
  width: 4px;
  background: #2a2a2a;
  border-radius: 2px;
  border: none;
  box-shadow: none;
}

.mixer .fader input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 14px;
  border-radius: 2px;
  background: #ff8000;
  border: 1px solid #cc6600;
  box-shadow: none;
}

/* ——— XY Pad ——— */
#xyPad {
  width: 100%;
  max-width: 200px;
  aspect-ratio: 1;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
  position: relative;
  background: var(--viz-bg);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.04);
  cursor: crosshair;
  flex-shrink: 0;
}

#xyPad:hover,
#xyPad:focus-within {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}

#xyDot {
  position: absolute;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 55%, transparent);
}

/* ——— Visualizer ——— */
.visualizer-big {
  width: 100%;
  min-height: 0;
  height: 100%;
  max-height: none;
  background: var(--viz-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: block;
  box-shadow: inset 0 0 24px rgb(0 0 0 / 0.5);
  align-self: stretch;
}

/* ——— Recorder ——— */
.recorder-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.rec-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.rec-btn:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

#record {
  font-size: 26px;
  color: var(--accent);
}

.recording #record {
  background: color-mix(in srgb, var(--accent) 18%, var(--bg-elevated));
  color: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 20px color-mix(in srgb, var(--accent) 40%, transparent);
  animation: recBlink 1s ease-in-out infinite;
}

@keyframes recBlink {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.75;
    transform: scale(1.06);
  }
}

.download-icon svg {
  width: 22px;
  height: 22px;
}

/* ——— Octave ——— */
.octave-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(12px, 2vw, 22px);
  margin-top: 4px;
  flex-wrap: wrap;
  flex: 0 0 auto;
}

.octave-controls button {
  font-family: var(--font);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 10px 18px;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}

.octave-controls button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.octave-controls button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#octaveIndicator {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  min-width: 9em;
  text-align: center;
}

/* ——— Teclado (sin scrollbar; escala al ancho del contenedor) ———
   Ancho lógico 1680px = 4 octavas × 7 teclas blancas × 60px (Keyboard.js) */
.keyboard-wrapper {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  padding: 4px 0 0;
  container-type: inline-size;
  container-name: synth-kb;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  flex: 0 0 auto;
  height: min(180px, calc(100cqi * 180 / 1680));
}

.keyboard-inner {
  width: 1680px;
  height: 180px;
  flex: 0 0 auto;
  transform-origin: top center;
  transform: scale(min(1, calc(100cqi / 1680px)));
}

#keyboard,
.keyboard {
  position: relative;
  height: 180px;
  width: max-content;
  margin: 8px 0 0;
}

.white.key,
.white {
  width: 60px;
  height: 180px;
  background: var(--key-white);
  border: 1px solid #2a2a2a;
  border-radius: 0 0 4px 4px;
  position: absolute;
  z-index: 1;
  cursor: pointer;
  box-shadow:
    inset 0 -6px 10px rgb(0 0 0 / 0.12),
    inset 0 2px 4px rgb(255 255 255 / 0.35);
}

.black.key,
.black {
  width: 40px;
  height: 110px;
  background: var(--key-black);
  border: 1px solid #000;
  border-radius: 0 0 5px 5px;
  position: absolute;
  z-index: 2;
  cursor: pointer;
  box-shadow:
    inset 0 -8px 14px rgb(255 255 255 / 0.06),
    inset 0 4px 8px rgb(0 0 0 / 0.45);
}

.white.active,
.white.key.active {
  background: color-mix(in srgb, var(--accent) 35%, var(--key-white));
  box-shadow:
    inset 0 2px 8px rgb(0 0 0 / 0.2),
    inset 0 -4px 12px color-mix(in srgb, var(--accent) 25%, transparent);
}

.black.active,
.black.key.active {
  background: color-mix(in srgb, var(--accent) 55%, var(--key-black));
  box-shadow:
    inset 0 4px 12px rgb(0 0 0 / 0.5),
    inset 0 -2px 8px color-mix(in srgb, var(--accent) 20%, transparent);
}
