/* ============================================
   Scale Picker — style.css
   ============================================ */

:root {
  --bg:           #0f1117;
  --surface:      #1a1d27;
  --surface-2:    #252836;
  --surface-3:    #2e3347;
  --primary:      #6c63ff;
  --primary-light:#9b95ff;
  --accent:       #f5a623;
  --accent-dim:   #c47f0e;
  --success:      #4ade80;
  --error:        #f87171;
  --text:         #f0f1f6;
  --text-muted:   #7c82a0;
  --border:       #2e3347;
  --radius:       8px;
  --radius-lg:    14px;
  --transition:   0.18s ease;
  --font-mono:    'SF Mono', 'Cascadia Code', 'Consolas', 'Courier New', monospace;
}

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

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ── App Shell ─────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* ── Header ─────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 20;
}

.app-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-light);
  letter-spacing: 0.03em;
}

.hamburger-btn {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.25rem;
  line-height: 1;
  padding: 0.3rem 0.55rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
}
.hamburger-btn:hover { background: var(--surface-3); }

/* ── Layout ─────────────────────────────────── */
.layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Settings Panel ─────────────────────────── */
.settings-panel {
  width: 210px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.settings-scroll {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.settings-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  font-style: italic;
}

.settings-divider {
  height: 1px;
  background: var(--border);
  margin: 0.75rem 0 0.5rem;
}

.setting-group {
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  transition: opacity var(--transition);
}
.setting-group.disabled {
  opacity: 0.38;
  pointer-events: none;
}
.setting-group:last-of-type { border-bottom: none; }

.setting-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.setting-checkbox {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.setting-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
}

.setting-select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius);
  font-size: 0.82rem;
  width: 100%;
  cursor: pointer;
  transition: border-color var(--transition), opacity var(--transition);
}
.setting-select:not(:disabled):hover  { border-color: var(--primary); }
.setting-select:not(:disabled):focus  { outline: none; border-color: var(--primary); }
.setting-select:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── Option Chips (Direction / Register sub-options) ── */
.option-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 0.6rem;
  padding: 0.05rem 0 0.1rem;
  transition: opacity var(--transition);
}
.option-chips.disabled {
  opacity: 0.28;
  pointer-events: none;
}
.chip-label {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.76rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.chip-checkbox {
  width: 12px;
  height: 12px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

/* ── Error ──────────────────────────────────── */
.error-msg {
  color: var(--error);
  font-size: 0.78rem;
  padding: 0.45rem 0.6rem;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.25);
  border-radius: var(--radius);
  margin-top: 0.5rem;
}

/* ── Main Content ───────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Preset Screen ──────────────────────────── */
.preset-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.preset-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.preset-content {
  text-align: center;
  padding: 2rem 1.5rem;
  max-width: 520px;
  width: 100%;
}

.preset-title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary-light);
  margin-bottom: 0.3rem;
  letter-spacing: 0.02em;
}

.preset-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  margin-bottom: 1.5rem;
}

.preset-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.2rem 0.9rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  transition: all var(--transition);
  text-align: center;
  color: var(--text);
  font-family: inherit;
  font-size: inherit;
}
.preset-card:hover {
  background: var(--surface-2);
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(108, 99, 255, 0.25);
}
.preset-card:active { transform: translateY(0); }

.preset-card-icon {
  font-size: 2rem;
  display: block;
  margin-bottom: 0.2rem;
}

.preset-card-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.preset-card-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.preset-customise {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  transition: color var(--transition);
}
.preset-customise:hover { color: var(--primary-light); }

@media (max-width: 400px) {
  .preset-grid { grid-template-columns: 1fr; }
}

/* ── Output Area ────────────────────────────── */
.output-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
  padding: 2rem;
  transition: background var(--transition);
  overflow: auto;
}
.output-area:hover        { background: rgba(108, 99, 255, 0.04); }
.output-area:focus-visible{ background: rgba(108, 99, 255, 0.07); outline: 2px solid var(--primary); outline-offset: -2px; }
.output-area:active       { background: rgba(108, 99, 255, 0.1); }

.output { text-align: center; width: 100%; }

/* ── Output Lines ───────────────────────────── */
.output-line {
  animation: popIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  margin: 0.1rem 0;
  line-height: 1.25;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.92) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Root note — large, bold, sans-serif */
.output-root {
  font-size: clamp(2.8rem, 9vw, 5.5rem);
  font-weight: 900;
  color: var(--text);
  letter-spacing: -0.03em;
  margin-bottom: 0;
  line-height: 1.1;
}

/* Quality — cursive/script font for visual distinction */
.output-quality {
  font-family: 'Dancing Script', cursive;
  font-size: clamp(1.6rem, 4.5vw, 2.8rem);
  font-weight: 700;
  margin-bottom: 0.15em;
  line-height: 1.2;
}

/* Quality colouring — Major in warm gold, minor in cool purple, modes in green */
.quality-major { color: var(--accent); }
.quality-minor { color: var(--primary-light); }
.quality-mode  { color: var(--success); }

/* CAGED shape label ("E shape") — geometric/mono font for contrast */
.output-caged-shape {
  font-size: clamp(1rem, 2.8vw, 1.6rem);
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  margin: 0.05rem 0;
  line-height: 1.2;
}

/* CAGED row */
.output-caged-row {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: clamp(0.25rem, 1.2vw, 0.7rem);
  flex-wrap: wrap;
  margin: 0.25rem 0;
}

.caged-letter {
  font-size: clamp(1.3rem, 3.5vw, 2.2rem);
  font-weight: 700;
  color: var(--text-muted);
  transition: font-size var(--transition), color var(--transition);
  line-height: 1;
  display: inline-block;
}

.caged-letter.caged-selected {
  font-size: clamp(2.2rem, 6vw, 3.8rem);
  /* colour is applied by the letter-specific rule below */
}

/* Per-letter CAGED colours — Sakura palette */
.caged-letter.caged-letter-C { color: #f8b9ce; text-shadow: 0 0 20px rgba(248,185,206,0.5); }
.caged-letter.caged-letter-A { color: #f490b1; text-shadow: 0 0 20px rgba(244,144,177,0.5); }
.caged-letter.caged-letter-G { color: #f06090; text-shadow: 0 0 20px rgba(240, 96,144,0.5); }
.caged-letter.caged-letter-E { color: #ec417a; text-shadow: 0 0 20px rgba(236, 65,122,0.5); }
.caged-letter.caged-letter-D { color: #da1b61; text-shadow: 0 0 20px rgba(218, 27, 97,0.5); }

.output-direction-line,
.output-register-line {
  font-size: clamp(1rem, 3vw, 1.8rem);
  color: var(--text-muted);
  font-weight: 400;
  margin: 0.05rem 0;
}

.output-order-line {
  font-size: clamp(0.95rem, 2.5vw, 1.5rem);
  font-family: var(--font-mono);
  color: var(--primary-light);
  letter-spacing: 0.06em;
  margin-top: 0.4rem;
}

/* ── Hint (initial state) ───────────────────── */
.output-hint {
  pointer-events: none;
  color: var(--text-muted);
}
.hint-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 0.5rem;
  opacity: 0.3;
}
.output-hint p { font-size: 0.95rem; }
.output-hint kbd {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.4em;
  font-size: 0.85em;
  font-family: inherit;
}

/* ── Count-in Display ───────────────────────── */
.countin-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 1rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  gap: 1rem;
  min-height: 3.5rem;
}

.countin-label {
  font-size: 1.1rem;
  font-weight: 700;
  flex: 1;
  transition: opacity 0.08s linear, color var(--transition);
  white-space: nowrap;
}

.countin-label.state-countdown { color: var(--text-muted); }
.countin-label.state-ready     { color: var(--text-muted); font-style: italic; }
.countin-label.state-getready  { color: var(--accent); }
.countin-label.state-playing   { color: var(--success); font-size: 1.25rem; }

/* Beat dots */
.beat-dots {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-shrink: 0;
}

.beat-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--surface-3);
  transition: background 0.06s ease, transform 0.06s ease, box-shadow 0.06s ease;
}

.beat-dot.active {
  background: var(--accent);
  transform: scale(1.45);
  box-shadow: 0 0 14px rgba(245, 166, 35, 0.65);
}

.beat-dot.active.is-playing {
  background: var(--success);
  box-shadow: 0 0 14px rgba(74, 222, 128, 0.65);
}

/* ── Scale Staff Graphic ────────────────────── */
.scale-staff-wrap {
  display: flex;
  justify-content: center;
  margin-top: 0.5rem;
  margin-bottom: 0.25rem;
  width: 100%;
}

.scale-staff {
  width: 100%;
  max-width: 520px;
  border-radius: 7px;
  overflow: visible;
  animation: popIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Controls Bar ───────────────────────────── */
.controls-bar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 1rem;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.btn {
  padding: 0.48rem 1.1rem;
  border-radius: var(--radius);
  border: none;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  line-height: 1.4;
}
.btn:disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn-generate {
  background: var(--primary);
  color: #fff;
}
.btn-generate:hover {
  background: var(--primary-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(108, 99, 255, 0.45);
}
.btn-generate:active { transform: translateY(0); }

.btn-play {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-play:not(:disabled):hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #111;
  transform: translateY(-1px);
}
.btn-play.playing {
  background: var(--error);
  border-color: var(--error);
  color: #fff;
}
.btn-play.playing:hover {
  background: #f05050;
  border-color: #f05050;
  color: #fff;
}

.bpm-wrapper {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
}
.bpm-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}
.bpm-input {
  width: 68px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.38rem 0.5rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  text-align: center;
}
.bpm-input:focus { outline: none; border-color: var(--primary); }

/* ── Overlay (mobile) ───────────────────────── */
.settings-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 30;
  backdrop-filter: blur(2px);
}
.settings-overlay.visible { display: block; }

/* ── Mobile ─────────────────────────────────── */
@media (max-width: 640px) {
  .hamburger-btn { display: inline-flex; }

  .settings-panel {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: min(85vw, 300px);
    z-index: 40;
    transform: translateX(-105%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: 1px solid var(--border);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
    padding-top: 3.5rem; /* clear the header */
  }
  .settings-panel.open { transform: translateX(0); }

  .output-area { min-height: 55vh; padding: 1.5rem 1rem; }

  .controls-bar { gap: 0.5rem; padding: 0.6rem 0.75rem; }

  .btn-generate,
  .btn-play { flex: 1 1 0; min-width: 0; text-align: center; }

  .bpm-wrapper { flex: 0 0 100%; margin-left: 0; }

  .output-root { font-size: clamp(2.2rem, 14vw, 4rem); }

  .caged-letter         { font-size: clamp(1.1rem, 5vw, 1.8rem); }
  .caged-letter.caged-selected { font-size: clamp(1.8rem, 9vw, 3rem); }
}
