/* --------------------------------------------
---------------------------------------- GLOBAL
-------------------------------------------- */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}
:root {
  --oxford-blue: #05204aff;
  --blue-ncs: #1b3970;
  --tea-green: #4ecdc4;
  --orangepeel: #ff9f1cff;
}

/* --------------------------------------------
  --------------------------------- APP STRUCTURE
  -------------------------------------------- */
body {
  width: 100vw;
  min-height: 100vh;
  background-image: linear-gradient(#05204add, #05204abb, #05204add), url("./water.jpg");
  background-blend-mode: normal;
  background-size: cover;
  display: grid;
  place-items: center;
  overflow: hidden;
}
#instrument {
  width: clamp(375px, 100vw, 800px);
  height: clamp(400px, calc(100vh - 2rem), 1000px);
  padding: 0.5rem;
  color: #ffffffcc;
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  overflow: hidden;
}
#instrument > section {
  max-height: 900px;
  min-height: 600px;
  max-width: 400px;
  border-radius: 1rem;
  padding: 0.5rem;
  box-shadow: 0 0 12px #00000088;
  background: #05204a88;

}

#welcome {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  display: grid;
  place-content: center;
  background-image: linear-gradient(#05204add, #05204abb, #05204add), url("./water.jpg");
  background-blend-mode: normal;
  animation: fade 3s both;
}
#welcome h1 {
  color: white;
  font-family:'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
  font-size: 3rem;
  text-shadow: 2px 2px 5px #00000055;
  animation: fade 2s both;
}
#welcome img {
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  z-index: -1;
  scale: 3;
  filter: blur(3px);
  animation: grow 2s both, fade 2s both;
}

@keyframes grow {
  0% {scale: 2}
  50% {scale: 2}
  100% {scale: 8}
}
@keyframes fade {
  0% {opacity: 1}
  50% {opacity: 1}
  100% {opacity: 0}
}

/* --------------------------------------------
  ----------------------------------- HEMISPHERES
  -------------------------------------------- */

#globalControls {
  flex: 100%;
  width: clamp(375px, 100vw, 800px);
  height: 2rem;
  display: flex;
  justify-content: space-evenly;
  color: #ffffffcc;
}

#chords {
  flex: 50%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#control {
  flex: 50%;
  display: grid;
  grid-template-rows: 60% 40%;
}

/* --------------------------------------------
  ------------------------------- GLOBAL CONTROLS
  -------------------------------------------- */
#octaveControls {
  font-size: 0.75rem;
  display: flex;
  width: 50%;
  justify-content: space-evenly;
  align-items: center;
}
#octaveControls button {
  width: 2rem;
  border: 1px solid var(--orangepeel);
  color: #ffffffaa;
  border-radius: 0.5rem;
  box-shadow: 1px 1px 3px #ffffff33 inset, -1px -1px 3px #00000022 inset,
    1px 1px 5px #00000044;
  cursor: pointer;
  background: var(--blue-ncs);
  padding: 0.2rem;
  overflow: hidden;
}
#octaveControls button:disabled {
  border: none;
  color: #00000033;
  box-shadow: none;
}

#globalControls label {
  display: grid;
  font-size: 0.75rem;
  text-align: center;
  accent-color: var(--tea-green);
  width: 50%;
  padding: 0.2rem;
}
#volume {
  width: 100px;
  height: 5px;
  cursor: pointer;
  margin: -0.2rem auto;
}

/* --------------------------------------------
  ------------------------------------ CHORD GRID
  -------------------------------------------- */

.chordRow {
  display: flex;
  align-items: center;
  width: 100%;
  justify-content: space-evenly;
  flex: 1;
  gap: 0.2rem;
}
.chordRow span {
  display: inline-block;
  text-align: center;
  flex: 1;
}
.chordBtn {
  height: 100%;
  flex: 1;
  font-size: 0.7rem;
  display: grid;
  place-items: center;
  border: none;
  padding: 0.25rem;
  border-radius: 0.5rem;
  background: var(--blue-ncs);
  color: #ffffffaa;
  box-shadow: 1px 1px 3px #ffffff33 inset, -1px -1px 3px #00000022 inset,
    1px 1px 5px #00000044;
  cursor: pointer;
}
.chordBtn input {
  display: none;
}
.chordBtn:has(input:checked) {
  background: var(--tea-green);
  color: var(--oxford-blue);
  font-weight: bolder;
  font-size: 0.8rem;
}
.chordBtn:has(.inKey) {
  outline: 1px solid var(--orangepeel);
}
.chordBtn:has(.notInKey) {
  filter: brightness(65%);
}

/* --------------------------------------------
  ---------------------------- TOUCHPAD INTERFACE
  -------------------------------------------- */

#touchPad {
  border: 1px solid var(--orangepeel);
  border-radius: 1rem;
  background-image: radial-gradient(#00000022, #000000aa);
  position: relative;
  cursor: move;
}
#point {
  width: 2px;
  height: 2px;
  box-shadow: 0 0 5px #ffffff;
  position: absolute;
  left: 50%;
  top: 50%;
  background: #ffffff;
  display: none;
}
#point::before {
  content: "";
  position: absolute;
  width: 110px;
  height: 110px;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  background-image: radial-gradient(#ffffff88, transparent 60%, transparent);
  display: none;
}
#point.active,
#point.active::before {
  display: inline-block;
}
#xLabel,
#yLabel {
  color: var(--tea-green);
  opacity: 0.3;
  font-size: 0.7rem;
  position: absolute;
}
#xLabel {
  left: 50%;
  translate: -50%;
}
#yLabel {
  top: 50%;
  left: 0;
  writing-mode: vertical-lr;
  rotate: 180deg;
  translate: 0 -50%;
}

/* --------------------------------------------
  ----------------------- OPTIONS & CUSTOMIZATION
  -------------------------------------------- */

#options {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 0.5rem 0rem;
}

/* ----------------------------------
  --------------------------- WAVE TYPE
  ---------------------------------- */

#waveOptBox {
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  height: 40px;
}
.waveOption input {
  display: none;
}
.waveBox {
  width: 30px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px solid #ffffff33;
  border-radius: 50%;
  cursor: pointer;
}

/* SINE WAVE */

.leftCircle,
.rightCircle {
  border: 1px solid white;
  width: 10px;
  aspect-ratio: 1;
  display: inline-block;
  padding: 0;
  margin: 0;
  border-radius: 50%;
}
.rightCircle {
  translate: 48% -75%;
  border-color: transparent transparent white white;
  rotate: -45deg;
}
.leftCircle {
  translate: -42% 80%;
  border-color: white white transparent transparent;
  rotate: -45deg;
}

/* SQUARE WAVE */

.squareWaveLeft,
.squareWaveRight {
  width: 6px;
  height: 5px;
  border: 1px solid white;
  border-color: white white transparent;
}
.squareWaveRight {
  rotate: 180deg;
  translate: 44% -105%;
}
.squareWaveLeft {
  translate: -40% 120%;
}

/* TRIANGLE WAVE */

.triWaveLeft,
.triWaveRight {
  height: 6px;
  aspect-ratio: 1;
  border: 1px solid white;
  border-color: white white transparent transparent;
}
.triWaveLeft {
  rotate: -45deg;
  translate: -58% 130%;
}
.triWaveRight {
  rotate: 135deg;
  translate: 58% -120%;
}
.waveOption:has(input:checked) .waveBox {
  background: var(--blue-ncs);
  box-shadow: 0 0 10px var(--tea-green);
}

/* SAWTOOTH WAVE */

.sawWave {
  width: 7px;
  height: 15px;
  border: 1px solid;
  border-color: white transparent transparent white;
  rotate: 70deg;
  translate: 0 10%;
}

/* ----------------------------------
  ----------------------- ADSR ENVELOPE
  ---------------------------------- */

#envelopeBox {
  display: flex;
  justify-content: space-evenly;
  align-items: baseline;
  width: 100%;
  color: #ffffffcc;
  font-size: 0.7rem;
}
.knobBox {
  flex: 1;
  text-align: center;
  position: relative;
  height: 70px;
}
.knob {
  position: absolute;
  width: 80%;
  aspect-ratio: 1;
  background: var(--blue-ncs);
  left: 0;
  top: 2rem;
  border-radius: 50%;
  translate: 10%;
  box-shadow: 0 0 6px #ffffff33 inset;
  cursor: ns-resize;
}
.knobBox::before {
  content: "";
  position: absolute;
  width: 60%;
  aspect-ratio: 1;
  top: 50%;
  left: 50%;
  background: #ffffff33;
  filter: blur(12px);
  z-index: -1;
  translate: -50% -50%;
}
.knobBox::after {
  content: "";
  position: absolute;
  width: 60%;
  aspect-ratio: 1;
  top: 50%;
  left: 50%;
  background: #00000088;
  filter: blur(12px);
  z-index: -2;
  translate: -40% 0%;
}
.knob.active {
  outline-offset: 0.5rem;
  outline: 2px solid var(--tea-green);
}
.knobMark {
  position: absolute;
  width: 2px;
  border: 2px solid var(--orangepeel);
  border-radius: 50%;
  left: 50%;
  top: 0;
  translate: -50%;
}
.knobDisplay {
  display: none;
  position: absolute;
  bottom: 120%;
  font-size: 2rem;
  padding: 0.5rem;
  border-radius: 0.5rem;
  background: white;
  color: var(--oxford-blue);
  left: 50%;
  translate: -50%;
}
.knob.active+.knobDisplay {
  display: inline-block;
}

/* ----------------------------------
  ----------------------- KEY SIGNATURE
  ---------------------------------- */

#keyBox {
  width: 100%;
  display: flex;
  justify-content: space-evenly;
  gap: 1rem;
  padding: 0 0.5rem;
}
#keyChoice,
#tonality {
  background: transparent;
  border: 1px solid var(--orangepeel);
  border-radius: 1rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.7rem;
  color: #ffffffcc;
  box-shadow: -1px -3px 6px #ffffff55, 1px 3px 6px #00000088;
}
#keySigContainer {
  height: 2.5rem;
  display: flex;
  align-items: center;
}

/* TOGGLE SWITCH FOR FLATS VS SHARPS */

label:has(#enharmonic) {
  width: 1.25rem;
  height: 2.5rem;
  border: 1px solid var(--orangepeel);
  border-radius: 1rem;
  position: relative;
  background: var(--blue-ncs);
  cursor: pointer;
}
label:has(#enharmonic):after {
  content: "\266F";
  position: absolute;
  font-size: 0.7rem;
  left: 130%;
}
label:has(#enharmonic):before {
  content: "\266D";
  font-style: italic;
  position: absolute;
  left: 130%;
  font-size: 0.7rem;
  bottom: 0;
}
#enharmonic {
  display: none;
}
#flatSlider {
  position: absolute;
  width: calc(100% - 4px);
  aspect-ratio: 1;
  background: var(--tea-green);
  border-radius: 50%;
  bottom: 2px;
  left: 2px;
  box-shadow: 0 -6px 10px #000000aa, 0 0 3px inset #00000088;
  transition: all 0.1s;
}
label:has(#enharmonic:checked) #flatSlider {
  translate: 0 -140%;
  box-shadow: 0 6px 10px #000000aa, 0 0 3px inset #00000088;
}

/* ----------------------------------
  --------------------------- SEQUENCER
  ---------------------------------- */

#patternBox {
  display: flex;
  justify-content: space-evenly;
  flex-wrap: wrap;
  gap: 0.1rem;
  border: 1px solid var(--orangepeel);
  padding: 1.5rem 0.25rem 0rem;
  border-radius: 0.5rem;
  position: relative;
  background: transparent;
  opacity: 0.8;
}
#patternBox:has(#patternToggle:checked) {
  background: var(--blue-ncs);
  opacity: 1;
}
#patternBox label:has(#patternToggle) {
  flex: 100%;
  display: flex;
  justify-content: center;
  position: absolute;
  top: 2px;
  left: 2px;
}
#patternToggle {
  display: none;
}
#patternBox .toggleMark {
  width: 0.7rem;
  height: 0.7rem;
  background: #000000aa;
  border: 1px solid var(--orangepeel);
  border-radius: 50%;
}
#patternToggle:checked ~ .toggleMark {
  background: var(--orangepeel);
}
#pulseLight {
  position: absolute;
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  background: #000000aa;
  top: 2px;
  right: 2px;
  border-radius: 50%;
}
.beatMark {
  height: 1rem;
  min-width: 1rem;
  background: #000000aa;
  border-radius: 0.25rem;
  display: inline-block;
}
.beatCheck {
  display: none;
}
#patternBox:has(#patternToggle:checked) .beatMark {
  border: 1px solid var(--tea-green);
}
.beatCheck:checked + .beatMark {
  background: var(--tea-green);
}
.beatCheck:disabled + .beatMark {
  background: transparent;
  border: 1px solid #000000aa;
}
#tempoBox {
  position: absolute;
  color: var(--tea-green);
  font-size: 0.7rem;
  top: 0.1rem;
  display: flex;
  gap: 0.5rem;
  width: 80%;
  justify-content: center;
}
#moreTempo,
#lessTempo {
  background: transparent;
  font-size: 0.7rem;
  color: var(--orangepeel);
  border: none;
  translate: 0 -10%;
}
#tempoBig {
  display: none;
  position: absolute;
  bottom: 200%;
  font-size: 2rem;
  padding: 0.5rem;
  border-radius: 0.5rem;
  background: white;
  color: var(--oxford-blue);
  left: 50%;
  translate: -50%;
}

#touchLock {
  position: absolute;
  top: 1rem;
  right: 1rem;
  border-radius: 50%;
  width: 1.8rem;
  height: 1.8rem;
  display: grid;
  place-content: center;
  border: 1px solid var(--orangepeel);
  cursor: pointer;
  z-index: 20;
}
#touchLock.locked {
  background-color: var(--blue-ncs);
  box-shadow: 0 0 15px var(--orangepeel);
  filter: brightness(140%);
}

#planBlock {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  justify-content: center;
  position: relative;
  width: 100%;
}
#planBlock:has(.tiny) {
  height: 1rem;
  margin-bottom: 0.25rem;
}
#planBlock div {
  border-radius: 50%;
  border: 1px solid var(--orangepeel);
  width: 1.5rem;
  height: 1.5rem;
  display: grid;
  place-content: center;
  flex: 0 1 15%;
}
#planBlock div.active {
  background: white;
  color: var(--orangepeel)
}
#planBlock div.hidden {
  display: none;
}
#clearPlan,
#planToggle {
  font-size: 0.5rem;
  grid-column: 1 / 2;
}
#clearPlan {
  grid-row: 2 / 3;
}
#planToggle.tiny {
  position: absolute;
  width: 100%;
  grid-column: 1 / 6;
  border-radius: 0.25rem;
  font-size: 0.75rem;

}

@media screen and (min-width: 600px) {
  body {
    align-items: center;
  }
  body>section {
    height: 1000px;
  }
  #globalControls {
    scale: 1.6;
    width: 50vw;
  }
}