/*
 * GAIA SH‑01 Web Synth styles
 *
 * This stylesheet defines a dark, responsive user interface with neon accents
 * reminiscent of Roland’s GAIA SH‑01 panel. Modules are presented as cards
 * with subtle shadows and grouped controls. Range inputs and select boxes
 * inherit consistent styling. The D‑Beam surface, waveform display and
 * on‑screen keyboard are customised for clarity and ease of use.
 */
/* Add to style.css */
.module[data-hide="true"] {
  display: none !important;
}
:root {
  --bg-color: #111;
  --panel-color: #1a1a1a;
  --accent-color: #00ff66; /* neon green */
  --text-color: #f0f0f0;
  --label-color: #a0a0a0;
  --border-color: #333;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: "Inter", Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
}

header {
  text-align: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--panel-color);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}
header h1 {
  margin: 0;
  font-size: 1.8rem;
  letter-spacing: 0.05em;
}
header .subtitle {
  margin: 0.3rem 0 0;
  font-size: 0.9rem;
  color: var(--label-color);
}

.controls-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  background-color: var(--panel-color);
  border-bottom: 1px solid var(--border-color);
}
.controls-bar > button{ 
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  background-color: var(--accent-color);
  color: #000;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  transition: background-color 0.2s;
}
.controls-bar > button:hover {

}
.controls-bar span {
  font-size: 0.85rem;
  color: var(--label-color);
}

main#synth-ui {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  padding: 1rem;
}

.module {
  background-color: var(--panel-color);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 1rem;
  min-width: 260px;
  flex: 1 1 300px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
.module h2 {
  margin-top: 0;
  font-size: 1.2rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.4rem;
}
.module-description {
  font-size: 0.8rem;
  color: var(--label-color);
  margin: 0 0 0.5rem;
}

label {
  display: flex;
  flex-direction: column;
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
  color: var(--label-color);
}
label input[type="range"],
label input[type="number"],
label select {
  width: 100%;
  margin-top: 0.2rem;
  background-color: #222;
  color: var(--text-color);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  padding: 0.3rem;
  box-sizing: border-box;
  font-size: 0.8rem;
}
label input[type="checkbox"] {
  margin-right: 0.3rem;
}

input[type="range"] {
  -webkit-appearance: none;
  background: transparent;
  height: 22px;
}
input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  background: #444;
  border-radius: 3px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 14px;
  width: 14px;
  border-radius: 50%;
  background: var(--accent-color);
  margin-top: -4px;
  cursor: pointer;
}
input[type="range"]::-moz-range-track {
  width: 100%;
  height: 6px;
  background: #444;
  border-radius: 3px;
}
input[type="range"]::-moz-range-thumb {
  height: 14px;
  width: 14px;
  border-radius: 50%;
  background: var(--accent-color);
  border: none;
  cursor: pointer;
}

.layers {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}
.layer {
  flex: 1 1 180px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.6rem;
  background-color: #181818;
}
.layer h3 {
  margin-top: 0;
  font-size: 1rem;
  margin-bottom: 0.4rem;
  color: var(--accent-color);
}

.env-group {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}
.env {
  flex: 1 1 180px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.6rem;
  background-color: #181818;
}
.env h3 {
  margin-top: 0;
  font-size: 0.95rem;
  margin-bottom: 0.4rem;
  color: var(--accent-color);
}

fieldset.lfo-destinations {
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.5rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  background-color: #181818;
}
fieldset.lfo-destinations legend {
  font-size: 0.9rem;
  color: var(--text-color);
  padding: 0 0.5rem;
}
fieldset.lfo-destinations label {
  display: flex;
  align-items: center;
  margin-right: 1rem;
  margin-bottom: 0;
  color: var(--label-color);
}

.effect-group {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}
.effect {
  flex: 1 1 180px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.6rem;
  background-color: #181818;
}
.effect h3 {
  margin-top: 0;
  font-size: 0.95rem;
  margin-bottom: 0.4rem;
  color: var(--accent-color);
}

#waveform {
  width: 100%;
  display: block;
  background-color: #000;
  border: 1px solid var(--border-color);
}
/* Waveform card becomes a flex container                         */
#waveform-module{
  display:flex;
  flex-direction:column;
}

/* canvas now stretches to fill the card                          */
#waveform{
  flex:1 1 auto;      /* take up all remaining height             */
  width:100%;
  height:100%;
  min-height:150px;    /* keeps it usable on tiny screens          */
}


#dbeam_surface {
  width: 100%;
  height: 150px;
  margin-top: 0.5rem;
  background: radial-gradient(circle at center, rgba(0, 255, 102, 0.3) 0%, rgba(0, 255, 102, 0.05) 100%);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: ns-resize;
}

/* Keyboard styling */
#keyboard-container {
  padding: 1rem;
  text-align: center;
}
#keyboard {
  display: flex;
  justify-content: center;
  position: relative;
  user-select: none;
}
.white-key,
.black-key {
  position: relative;
  border: 1px solid var(--border-color);
  box-sizing: border-box;
  cursor: pointer;
}
.white-key {
  width: 30px;
  height: 140px;
  background: #f7f7f7;
  margin: 0 1px;
  z-index: 1;
}
.white-key.active {
  background: var(--accent-color);
}
.black-key {
  width: 18px;
  height: 90px;
  background: #101010;
  position: absolute;
  top: 0;
  z-index: 2;
  margin-left: -9px;
  border-radius: 0 0 3px 3px;
}
.black-key.active {
  background: var(--accent-color);
}
.note {
  font-size: 0.8rem;
  color: var(--label-color);
  margin-top: 0.5rem;
}

@media (max-width: 768px) {
  .module {
    flex: 1 1 100%;
  }
  .layer,
  .env,
  .effect {
    flex: 1 1 100%;
  }
}




/* Top bar for preset selection */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #2c2c2c;
    padding: 10px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.preset-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.preset-container label {
    font-size: 16px;
    font-weight: bold;
    color: #ffffff;
}

#preset {
    background-color: #3a3a3a;
    color: #ffffff;
    border: 1px solid #555;
    border-radius: 4px;
    padding: 8px;
    font-size: 14px;
    outline: none;
    cursor: pointer;
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="white" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 30px;
    min-width: 200px;
}

#preset:hover {
    background-color: #4a4a4a;
}

#preset:focus {
    border-color: #00aaff;
    box-shadow: 0 0 5px rgba(0, 170, 255, 0.5);
}

#init_preset_bank, #save-preset {
    background-color: #00aaff;
    border: none;
    border-radius: 4px;
    padding: 8px 16px;
    color: #ffffff;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#init_preset_bank:hover, #save-preset:hover {
    background-color: #0088cc;
}

/* Responsive design for smaller screens */
@media (max-width: 600px) {
    .top-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    #preset {
        width: 100%;
    }
}


/* === COMPACT LAYOUT ADJUSTMENTS === */

main#synth-ui {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.5rem;
  padding: 0.5rem;
}

.module {
  min-width: 0;
  padding: 0.6rem;
}

/* Make form elements smaller */
label input[type="range"],
label input[type="number"],
label select {
  font-size: 0.75rem;
  padding: 0.2rem;
}

/* Responsive oscillator layers */
.layers {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
@media (min-width: 700px) {
  .layers {
    flex-direction: row;
  }
}

/* <details> collapsible UI section */
details.collapsible summary {
  cursor: pointer;
  font-weight: bold;
  margin-bottom: 0.5rem;
  color: var(--accent-color);
}


/* === COMPACT LAYOUT ADJUSTMENTS === */

main#synth-ui {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.5rem;
  padding: 0.5rem;
}

.module {
  min-width: 0;
  padding: 0.6rem;
}

/* Make form elements smaller */
label input[type="range"],
label input[type="number"],
label select {
  font-size: 0.75rem;
  padding: 0.2rem;
}

/* Responsive oscillator layers */
.layers {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
@media (min-width: 700px) {
  .layers {
    flex-direction: row;
  }
}

/* <details> collapsible UI section */
details.collapsible summary {
  cursor: pointer;
  font-weight: bold;
  margin-bottom: 0.5rem;
  color: var(--accent-color);
}

/* === INLINE SLIDERS === */

label {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

label span {
  flex: 1;
}

label input[type="range"],
label input[type="number"],
label select {
  flex: 2;
  margin-left: 0.5rem;
}

.effect {
  position: relative;
  cursor: pointer;
  transition: background-color 0.3s, border-color 0.3s;
  opacity: 0.6;
}
.effect.active {
  border-color: var(--accent-color);
  background-color: #222;
  opacity: 1;
}
.effect-toggle {
  position: absolute;
  top: 6px;
  right: 8px;
  transform: scale(1.2);
  cursor: pointer;
}
.effect h3 {
  margin-right: 1.5rem; /* make space for checkbox */
}
.wave-dbeam-row {
  display: flex;
  gap: 1rem;
  padding: 0 1rem 1rem;
}

.waveform-module {
  flex: 2;   /* twice as wide as D-Beam */
}

.dbeam-module {
  flex: 1;   /* one unit wide */
  min-width: 250px;
}

/* Make the Oscillators section span every column */
section.module.oscillators {
  grid-column: 1 / -1;
}

/* target the Oscillators module */
section.module.oscillators .layers {
  display: flex;
  flex-wrap: nowrap;      /* keep them side by side */
  justify-content: space-between;
  gap: 1rem;
}

/* ensure each layer shrinks/grows evenly */
section.module.oscillators .layer {
  flex: 1 1 0;            /* equal widths */
  min-width: 180px;       /* or your preferred minimum */
}

/* Keep D-Beam a reasonable width next to waveform */
.wave-dbeam-row .dbeam-module {
  flex: 1 1 250px;
  max-width: 250px;
}
.wave-dbeam-row .waveform-module {
  flex: 2 1 0;
}

.wave-dbeam-row {
  display: flex;
  gap: 1rem;
  padding: 0 1rem 1rem;
}


/* 1) Make #synth-ui a 2-column grid */
main#synth-ui {
  display: grid;
  grid-template-columns: 2fr 1fr;  /* waveform wide, d-beam narrower */
  grid-auto-rows: auto;
  gap: 1rem;
  padding: 1rem;
  box-sizing: border-box;
}

/* 2) Force Waveform into col 1, row 1 */
.waveform-module {
  grid-column: 1 / 2;
  grid-row: 1;
}

/* 3) Force D-Beam into col 2, row 1 */
.dbeam-module {
  grid-column: 2 / 3;
  grid-row: 1;
  min-width: 200px; /* cap its width */
}

/* 4) Force Oscillators to span both cols on row 2 */
.oscillators {
  grid-column: 1 / -1;
  grid-row: 2;
}

/* 5) Lay out the three layers left→right inside the Oscillators card */
.oscillators .layers {
  display: flex;
  gap: 1rem;
}
.oscillators .layer {
  flex: 1 1 0;
  min-width: 160px;
}

/* force a new grid row wherever <div class="row-break"> appears */
.row-break {
  grid-column: 1 / -1;  /* span entire grid width */
  height: 0;            /* invisible spacer */
}

/* 6) Everything else (Filter, Amp, etc.) will flow into row 3+ across the two columns */


/* ───── GRID LAYOUT FOR THE MAIN PANEL ───────────────────────── */

/* 1. Four-column grid: first column 2× wider for Waveform         */
main#synth-ui{
  display:grid;
  grid-template-columns:repeat(4, 1fr);  /* 4 equal columns */
  grid-auto-rows:auto;
  gap:1rem;
  padding:1rem;
  box-sizing:border-box;
}


/* 2. Place Waveform (wide) and D-Beam (narrow) on row-1           */
.waveform-module{grid-column:1/2;grid-row:1;}
.dbeam-module   {grid-column:2/3;grid-row:1;min-width:200px;}

/* 3. Force a fresh grid line wherever you put <div class="row-break"></div> */
.row-break      {grid-column:1/-1;height:0;}

/* 4. Oscillators should always start on a new full-width row      */
section.module.oscillators{grid-column:1/-1;}

/* 5. (Optional) tidy up the three Layer cards inside Oscillators  */
.oscillators .layers{display:flex;gap:1rem;}
.oscillators .layer {flex:1 1 0;min-width:160px;}

#waveform-module { grid-column:1 / 4; grid-row:1; }   /* spans cols 1-3 */
#dbeam-module    { grid-column:4 / 5; grid-row:1; }   /* col 4 */

#filter-module   { grid-column:1 / 2; grid-row:3; }   /* col 1 */
#amp-module      { grid-column:2 / 3; grid-row:3; }   /* col 2 */
#lfo-module      { grid-column:3 / 4; grid-row:3; }   /* col 3 */
#effects-module  { grid-column:4 / 5; grid-row:3; }   /* col 4 */

section.module.oscillators{
  grid-column:1 / -1;  /* full width */
  grid-row:2;
}

/* 1 ▼  make the Waveform section itself a flex-column container           */
.waveform-module{
  display:flex;               /* column is default direction             */
}

/* 2 ▼  let the canvas grow to fill the remaining space                    */
#waveform{
  flex:1 1 auto;              /* take all the vertical space that’s left */
  width:100%;
  height:100%;                /* remove the old 120 px lock              */
  /* (keep background / border rules as they are)                         */
}

/* make both cards vertical flex-boxes */
.waveform-module,
.dbeam-module {
  display: flex;
  flex-direction: column;
}

/* canvas fills whatever height the card gets */
.waveform-module canvas {
  flex: 1 1 auto;     /* grow + shrink */
  width: 100%;        /* already full-width */
  height: 100%;       /* keep pixels sharp */
}

/* D-Beam surface fills its card too */
#dbeam_surface {
  flex: 1 1 auto;
  min-height: 150px;  /* safety so it never gets *too* short */
}

/* D-Beam surface fills its card */
#dbeam_surface {
  flex: 1 1 auto;          /* stretch with the card */
  /* height: 150px;  <--  ✖ delete this line */
  min-height: 150px;       /* safety on tiny viewports */
  width: 100%;
  margin-top: 0.5rem;
  background: radial-gradient(circle at center,
              rgba(0,255,102,.3) 0%, rgba(0,255,102,.05) 100%);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: ns-resize;
}

/* 1️⃣  make the whole D-Beam card a flex-column container */
.dbeam-module{
  display:flex;
  flex-direction:column;   /* header + surface stacked vertically */
}

.dbeam-module{display:flex;flex-direction:column;}
#dbeam_surface{
  flex:1 1 auto;          /* grow / shrink with its card   */
  min-height:150px;       /* safety floor on phones        */

  /* NEW: release the hard lock that causes the gap */
  height:auto !important; /* or simply remove the old line */
}

/* ====  PRESET POP-OVER  =================================================== */
.preset-container { position: relative; }      /* anchor for the panel        */

#preset_panel {
  position: absolute;
  top: 100%; left: 0;
  min-width: 32rem;               /* grow wider than the button             */
  max-height: 60vh;
  overflow-y: auto;
  padding: .75rem 1rem;
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: .5rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: .5rem 1.25rem;             /* row / column gaps                      */
  z-index: 1000;
}

css #preset_panel[hidden]{display:none !important;}

.preset-col > h4 {
  margin: .25rem 0 .5rem;
  font-weight: 600;
  text-transform: capitalize;
}

.preset-col > ul { list-style: none; margin: 0; padding: 0; }

css .preset-btn{ background:#222; /* default fill */ color:#ddd; border:1px solid transparent; border-radius:.25rem; padding:.25rem .5rem; text-align:left; width:100%; transition:background .12s,color .12s; } .preset-btn:hover, .preset-btn[aria-selected="true"]{ background:var(--accent-color,#3a7cff); color:#fff; }



/* ---------------  preset trigger in the top bar --------------- */
.preset-trigger{
  background:#333;
  color:var(--text-color);
  border:1px solid var(--border-color);
  border-radius:4px;
  padding:.4rem .8rem;
}
.preset-trigger:hover,
.preset-trigger[aria-expanded="true"]{
  background:var(--accent-color);
  color:#000;
}

/* ---------------  buttons *inside* the pop-over --------------- */
.preset-btn{
  background:#222;
  color:var(--text-color);
  border:none;
  padding:.25rem .5rem;
  width:100%;
  text-align:left;
  border-radius:4px;
}
.preset-btn:hover,
.preset-btn[aria-selected="true"]{
  background:var(--accent-color);
  color:#000;
}

/* Utility – any element carrying ‘hidden’ should vanish */
[hidden]{display:none!important;}


/* live name field --------------------------------------------------- */
.preset-display{
  min-width:12rem;
  padding:.4rem .6rem;
  background:#222;
  color:var(--text-color);
  border:1px solid var(--border-color);
  border-radius:4px;
  font-size:.85rem;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

/* ▲ ▼ buttons ------------------------------------------------------- */
.preset-nav{
  width:2.2rem;  height:2.2rem;
  display:flex;  align-items:center;  justify-content:center;
  background:#333;
  color:var(--text-color);
  border:1px solid var(--border-color);
  border-radius:4px;
  cursor:pointer;
  line-height:1;
}
.preset-nav:hover{
  background:var(--accent-color);
  color:#000;
}


.preset-display { cursor: pointer; }
