/* ================================
   Base Layout & Typography
================================== */
:root {
  --highlight-color: #f39c12;
  --root-color: #e74c3c;
  --scale-color: #9b59b6;
  --metro-color: #4caf50;
}

body {
  font-family: monospace;
  background-color: #1e1e1e;
  color: #eee;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem;
  touch-action: manipulation;
}

/* ================================
   Buttons & Inputs
================================== */
button {
  margin: 4px;
  padding: 6px 10px;
  background: #444;
  border: 1px solid #888;
  color: #eee;
  border-radius: 4px;
  cursor: pointer;
}

button:hover {
  background: #555;
  border-color: #aaa;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.controls label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.ring-color-controls {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

body:not(.sato-mode-engaged) .ring-color-controls {
  display: none;
}

.ring-color-controls.hidden {
  display: none !important;
}

.ring-color-controls label {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.ring-color-controls > span {
  font-weight: bold;
  width: 100%;
}

.controls .advanced-control {
  display: none;
}

body.sato-mode-engaged .controls .advanced-control {
  display: inline-flex;
}

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

body.sato-mode-engaged .sato-only {
  display: inline-flex !important;
}

body.sato-mode-engaged .tone-column.sato-only {
  display: flex !important;
}

.controls input,
.controls select,
.controls button,
.controls label {
  background-color: #333;
  border: none;
  padding: 8px 12px;
  color: white;
  border-radius: 4px;
}

.controls input[type="color"] {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: none;
  cursor: pointer;
  box-shadow: 0 0 10px var(--current-color, rgba(255, 255, 255, 0.35));
}

.controls input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
  border-radius: 50%;
}

.controls input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}

.controls input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 50%;
}

.controls #scaleRootSelect {
  width: 60px;
}

.controls input[type="text"],
.controls select {
  width: 180px;
}

.controls input:focus,
.controls select:focus,
.controls button:focus {
  outline: 2px solid #4CAF50;
}

/* ================================
   Fretboard Layout
================================== */
.fretboard-wrapper {
  overflow-x: auto;
  max-width: 100%;
  margin-bottom: 1rem;
}

.fretboard {
  display: grid;
  background: linear-gradient(90deg, #4a2e1b, #5c3a21);
  border: 4px solid #111;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  width: max-content;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.string-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: #aaa;
  pointer-events: none;
}

/* ================================
   Frets
================================== */
.fret {
  height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  font-size: 14px;
  color: #eee;
  border-right: 4px solid #777;
  position: relative;
  cursor: pointer;
  user-select: none;
}

.fret::after {
  content: attr(data-fret);
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 10px;
  color: #777;
  z-index: 2;
  user-select: none;
}

.fret.ring::after {
  content: "";
  width: 40px;
  height: 40px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 3px solid var(--ring-color, #fff);
  box-shadow: 0 0 10px var(--ring-color, #fff);
  opacity: 0.5;
  z-index: 0;
  pointer-events: none;
}

/* ================================
   Highlight Layers
================================== */
.fret.highlight,
.fret.root-highlight,
.fret.metro-highlight,
.fret.scale-highlight {
  box-shadow: none;
  z-index: 2;
}

.fret.highlight::before,
.fret.root-highlight::before,
.fret.metro-highlight::before,
.fret.scale-highlight::before {
  content: "";
  width: 28px;
  height: 28px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: none;
  z-index: -1;
}

.fret.highlight::before {
  background-color: var(--highlight-color, #f39c12);
  box-shadow: 0 0 10px var(--highlight-color, #f39c12);
}

.fret.root-highlight::before {
  background-color: var(--root-color, #e74c3c);
  box-shadow: 0 0 10px var(--root-color, #e74c3c);
}

.fret.scale-highlight::before {
  background-color: var(--scale-color, #9b59b6);
  box-shadow: 0 0 10px var(--scale-color, #9b59b6);
}

.fret.metro-highlight::before {
  background-color: var(--metro-color, #4caf50);
  box-shadow: 0 0 10px var(--metro-color, #4caf50);
}

/* ================================
   Open Frets
================================== */
.fret.open {
  font-weight: bold;
  background-color: #333;
  border: 2px solid var(--highlight-color, #f39c12);
  box-shadow: inset 0 0 5px var(--highlight-color, #f39c12);
  z-index: 1;
}

.fret.open.highlight {
  box-shadow: inset 0 0 5px var(--highlight-color, #f39c12);
}

.fret.open.scale-highlight {
  box-shadow: inset 0 0 5px var(--scale-color, #9b59b6);
}

.fret.open.root-highlight {
  box-shadow: inset 0 0 5px var(--root-color, #e74c3c);
}

.fret.open.metro-highlight {
  box-shadow: inset 0 0 5px var(--metro-color, #4caf50);
}

/* ================================
   Labels
================================== */
.labels {
  display: grid;
  margin-top: 10px;
  color: #bbb;
  font-size: 12px;
  text-align: center;
}

.labels div {
  padding: 4px 0;
  user-select: none;
}

.selected-scale {
  background-color: #4CAF50 !important;
  color: white !important;
  box-shadow: 0 0 6px #4CAF50;
}

/* ================================
   Footer Banner
================================== */
#footerBanner {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  background: #222;
  color: #eee;
  text-align: center;
  padding: 10px 0;
  font-weight: bold;
  font-family: monospace;
  box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.7);
  z-index: 3;
}

#footerBanner a {
  color: #4CAF50;
  text-decoration: none;
}

#footerBanner .footer-links {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

#footerBanner button {
  background: #333;
  border: 1px solid #4CAF50;
  color: #4CAF50;
}

#satoModeButton {
  width: 120px;
}

#satoModeButton.engaged,
body.sato-mode-engaged #satoModeButton {
  background: #4CAF50;
  border-color: #81C784;
  color: #111;
}

#footerBanner a:hover {
  text-decoration: underline;
}

/* ================================
   Analysis & Metronome Panels
================================== */
.analysis-metro-container {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: nowrap;
  margin-top: 2rem;
}

.analysis-panel,
.metronome-panel {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-grow: 1;
  min-width: 340px;
}

.analysis-panel label {
  font-size: 14px;
}

#analysisOutput {
  flex: 1;
  background: #222;
  border-radius: 8px;
  padding: 1rem 1.5rem;
  font-family: monospace;
  white-space: pre-wrap;
  min-height: 4rem;
}

/* ================================
   Metronome Controls & Measures
================================== */
#metronome-controls {
  display: inline-block;
  flex: 1;
}

#metronome-controls label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.25rem 0;
}

#metronome-controls input[type="number"] {
  background: #333;
  color: white;
  border: 1px solid #666;
  padding: 4px 8px;
  border-radius: 4px;
  width: 80px;
}

.measure {
  display: inline-block;
  margin: 1rem;
  padding: 1rem 1.5rem;
  border: 1px solid #444;
  border-radius: 8px;
  background: #222;
  font-family: monospace;
  vertical-align: top;
  white-space: pre-wrap;
  min-height: 4rem;
}

.measure label {
  display: inline-block;
  margin: 0 8px 0 0;
}

.measure input {
  background: #333;
  color: white;
  border: 1px solid #666;
  padding: 4px 8px;
  margin: 4px;
  border-radius: 4px;
  width: 60px;
}

input.active-beat {
  background: #4CAF50;
  box-shadow: 0 0 6px #4CAF50;
  font-weight: bold;
  border-color: #4CAF50;
  color: #111;
}

.beat {
  margin: 4px;
  padding: 6px 10px;
  border: 1px solid #888;
  color: #fff;
  border-radius: 4px;
  background: #444;
}

/* ================================
   Tone Column
================================== */
.tone-column {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.beat-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.beat-row label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

body.legato-enabled .beat-duration {
  display: none !important;
}

/* ================================
   Responsive Layout
================================== */
@media (max-width: 600px) {
  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .analysis-metro-container {
    flex-direction: column;
    gap: 1rem;
  }

  .analysis-panel,
  .metronome-panel {
    width: 100%;
    min-width: unset;
  }

  .measure {
    width: 100%;
    box-sizing: border-box;
  }
}

@media (max-width: 400px) {
  .controls input[type="text"],
  .controls select {
    width: 100%;
  }

  #footerBanner {
    position: static;
  }
}


