/* ═══════════════════════════════════════════════════════════════
   ZCM — style.css
   Brilliant.org reference · Light mode · Pure B&W grayscale
   ═══════════════════════════════════════════════════════════════ */

/* ── Design Tokens ────────────────────────────────────────── */
:root {
  --bg-base: #F5F5F5;
  --bg-surface: #FFFFFF;
  --bg-elevated: #EBEBEB;
  --bg-intro: #111111;

  --text-primary: #111111;
  --text-body: #333333;
  --text-muted: #8A8A8A;

  --border-subtle: #E0E0E0;
  --border-focus: #111111;

  --accent: #111111;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 60px;

  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.07);
  --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-btn: 0 4px 0 0 #000000;

  --font-display: 'Playfair Display', Georgia, serif;
  --font-mono: 'IBM Plex Mono', 'Menlo', monospace;
  --font-body: 'Inter', system-ui, sans-serif;

  --transition: cubic-bezier(0.4, 0, 0.2, 1);
  --max-width: 1100px;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}

img,
svg {
  display: block;
}

button {
  cursor: pointer;
  font-family: inherit;
}

input,
select {
  font-family: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.hidden {
  display: none !important;
}

/* ── Loading Bar ──────────────────────────────────────────── */
.loading-bar-track {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
  z-index: 9999;
}

.loading-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width 1200ms var(--transition);
}

/* ── Intro Screen ─────────────────────────────────────────── */
.intro-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-intro);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  overflow: hidden;
}

.intro-screen.fade-out {
  opacity: 0;
  transition: opacity 600ms var(--transition);
  pointer-events: none;
}

/* Refined spotlight: soft multi-layer radial glow */
.intro-spotlight {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 0;
  height: 0;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at center,
      rgba(255, 255, 255, 0.18) 0%,
      rgba(255, 255, 255, 0.07) 35%,
      transparent 70%);
  transition: width 300ms cubic-bezier(0.22, 1, 0.36, 1),
    height 300ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 300ms ease;
  pointer-events: none;
  opacity: 0;
}

.intro-spotlight.active {
  width: 800px;
  height: 500px;
  opacity: 1;
  animation: spotlight-pulse 2s ease-in-out infinite;
}

@keyframes spotlight-pulse {

  0%,
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }

  50% {
    opacity: 0.7;
    transform: translate(-50%, -50%) scale(1.05);
  }
}

.intro-keyboard {
  position: absolute;
  bottom: -150px;
  left: 50%;
  transform: translateX(-50%);
  width: 90%;
  max-width: 700px;
  opacity: 0;
  transition: bottom 400ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 400ms ease;
}

.intro-keyboard.visible {
  bottom: 0;
  opacity: 0.45;
}

.intro-logo {
  font-family: var(--font-display);
  font-size: 80px;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: -3px;
  opacity: 0;
  transform: translateY(16px) scale(0.95);
  transition: opacity 200ms ease, transform 250ms cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 1;
}

.intro-logo.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ── Skip Button ──────────────────────────────────────────── */
.skip-btn {
  position: fixed;
  top: 20px;
  right: 24px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.7);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font: 500 13px var(--font-body);
  transition: border-color 150ms, color 150ms;
  z-index: 2000;
}

.skip-btn:hover {
  border-color: rgba(255, 255, 255, 0.7);
  color: #FFFFFF;
}

.app .skip-btn {
  border-color: rgba(17, 17, 17, 0.3);
  color: var(--text-muted);
}

.app .skip-btn:hover {
  border-color: var(--border-focus);
  color: var(--text-primary);
}

/* ── Tutorial Overlay ─────────────────────────────────────── */
.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  pointer-events: none;
}

.tutorial-backdrop {
  position: absolute;
  inset: 0;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(245, 245, 245, 0.6);
  pointer-events: all;
}

.tutorial-card {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: min(480px, calc(100vw - 48px));
  box-shadow: var(--shadow-hover);
  pointer-events: all;
  animation: reveal-up 300ms var(--transition);
}

.tutorial-step-label {
  font: 500 12px var(--font-body);
  color: var(--text-muted);
  margin-bottom: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tutorial-text {
  font: 400 16px var(--font-body);
  color: var(--text-body);
  margin-bottom: 24px;
  line-height: 1.6;
}

/* ── App Layout ───────────────────────────────────────────── */
.app {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px 80px;
  opacity: 0;
  transition: opacity 600ms var(--transition);
}

.app.visible {
  opacity: 1;
}

/* ── Header ───────────────────────────────────────────────── */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 0 24px;
  border-bottom: 1.5px solid var(--border-subtle);
  margin-bottom: 40px;
}

.app-logo {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.app-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.key-select {
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font: 500 14px var(--font-body);
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 150ms;
}

.key-select:hover {
  border-color: var(--border-focus);
}

.transpose-controls {
  display: flex;
  gap: 8px;
}

.btn-icon {
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  width: 40px;
  height: 40px;
  font: 500 18px var(--font-mono);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 150ms, background 150ms;
}

.btn-icon:hover {
  border-color: var(--border-focus);
  background: var(--bg-elevated);
}

.btn-icon:active {
  transform: scale(0.95);
}

/* ── Chord Input ──────────────────────────────────────────── */
.chord-input-section {
  margin-bottom: 40px;
}

.chord-input-wrap {
  position: relative;
  max-width: 480px;
}

.chord-input {
  width: 100%;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  font: 600 28px var(--font-mono);
  color: var(--text-primary);
  outline: none;
  transition: border-color 150ms var(--transition), box-shadow 150ms var(--transition);
}

.chord-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.chord-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.08);
}

.chord-input.shake {
  animation: shake 300ms var(--transition);
}

.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  box-shadow: var(--shadow-card);
  list-style: none;
  z-index: 100;
  max-height: 240px;
  overflow-y: auto;
}

.autocomplete-list li {
  padding: 12px 20px;
  font: 500 16px var(--font-mono);
  cursor: pointer;
  transition: background 100ms;
}

.autocomplete-list li:hover,
.autocomplete-list li[aria-selected="true"] {
  background: var(--bg-elevated);
}

/* ── Voicing Section ──────────────────────────────────────── */
.voicing-section {
  margin-bottom: 48px;
}

.voicing-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

@media (max-width: 768px) {
  .voicing-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

.voicing-card {
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px 16px;
  cursor: pointer;
  transition:
    border-color 150ms var(--transition),
    transform 150ms var(--transition),
    box-shadow 150ms var(--transition);
  animation: reveal-up 300ms var(--transition) backwards;
}

.voicing-card:hover {
  border-color: var(--border-focus);
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.voicing-card.active {
  border: 2px solid var(--border-focus);
  box-shadow: var(--shadow-card);
}

.voicing-card:active {
  transform: scale(0.97) translateY(0);
}

.voicing-card-label {
  font: 500 11px var(--font-body);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

.voicing-card-keyboard {
  width: 100%;
}

.voicing-card-notes {
  font: 500 12px var(--font-mono);
  color: var(--text-body);
  margin-top: 10px;
  letter-spacing: 0.03em;
}

.voicing-card-bass {
  font: 400 11px var(--font-body);
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Harmony Section ──────────────────────────────────────── */
.harmony-section {
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 40px;
}

.harmony-notes-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.harmony-label {
  font: 500 11px var(--font-body);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.harmony-notes,
.harmony-intervals {
  font: 600 14px var(--font-mono);
  color: var(--text-primary);
  letter-spacing: 0.1em;
}

.harmony-separator {
  color: var(--border-subtle);
  font-size: 18px;
}

/* SVG Overlay */
.harmony-svg-wrap {
  position: relative;
  min-height: 80px;
  margin-bottom: 16px;
}

.harmony-svg {
  width: 100%;
  overflow: visible;
}

.harmony-pattern-row {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.harmony-chord-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.harmony-roman {
  font: 600 16px var(--font-mono);
  color: var(--text-primary);
}

.harmony-function {
  font: 400 11px var(--font-body);
  color: var(--text-muted);
}

/* Tension Block */
.tension-block {
  background: var(--bg-base);
  border-left: 3px solid var(--border-focus);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 16px 20px;
  margin-top: 16px;
  animation: reveal-up 200ms var(--transition);
}

.tension-chord-name {
  font: 600 14px var(--font-mono);
  color: var(--text-primary);
  margin-bottom: 6px;
}

.tension-description {
  font: 400 13px var(--font-body);
  color: var(--text-body);
  line-height: 1.6;
}

.tension-link {
  display: inline-block;
  margin-top: 10px;
  font: 500 12px var(--font-body);
  color: var(--text-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.tension-link:hover {
  opacity: 0.7;
}

/* ── Progression Section ──────────────────────────────────── */
.progression-section {
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 28px;
}

.progression-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.progression-title {
  font: 600 15px var(--font-body);
  color: var(--text-body);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.progression-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* YouTube Input */
.youtube-analyze-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.youtube-url-input {
  flex: 1;
  background: var(--bg-base);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font: 400 14px var(--font-body);
  color: var(--text-primary);
  outline: none;
  transition: border-color 150ms;
}

.youtube-url-input:focus {
  border-color: var(--border-focus);
}

.youtube-url-input::placeholder {
  color: var(--text-muted);
}

/* Key Detection Panel */
.key-detection-panel {
  background: var(--bg-base);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 16px;
  animation: reveal-up 300ms var(--transition);
}

.key-detection-label {
  font: 500 11px var(--font-body);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: block;
  margin-bottom: 10px;
}

.key-candidates {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.key-candidate-btn {
  background: var(--bg-surface);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  font: 500 13px var(--font-body);
  color: var(--text-body);
  cursor: pointer;
  transition: border-color 150ms, background 150ms;
}

.key-candidate-btn:hover,
.key-candidate-btn.selected {
  border-color: var(--border-focus);
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* Timeline */
.progression-timeline {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  min-height: 56px;
  margin-bottom: 14px;
}

.chord-node {
  background: var(--bg-base);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font: 600 15px var(--font-mono);
  color: var(--text-primary);
  cursor: pointer;
  position: relative;
  transition: border-color 150ms, background 150ms, transform 100ms;
  user-select: none;
}

.chord-node:hover {
  border-color: var(--border-focus);
  background: var(--bg-elevated);
}

.chord-node.active {
  background: var(--accent);
  color: #FFFFFF;
  border-color: var(--accent);
}

.chord-node .remove-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  background: var(--accent);
  color: #FFFFFF;
  border: none;
  border-radius: 50%;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  display: none;
}

.chord-node:hover .remove-btn {
  display: block;
}

.btn-add-chord {
  background: transparent;
  border: 1.5px dashed var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 20px;
  font: 500 13px var(--font-body);
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 150ms, color 150ms;
}

.btn-add-chord:hover {
  border-color: var(--border-focus);
  color: var(--text-primary);
}

/* YouTube Results */
.youtube-results {
  margin-top: 20px;
  border-top: 1.5px solid var(--border-subtle);
  padding-top: 20px;
}

.youtube-results-title {
  font: 500 11px var(--font-body);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

.youtube-video-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.youtube-video-item {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: border-color 150ms;
  text-decoration: none;
  color: var(--text-body);
}

.youtube-video-item:hover {
  border-color: var(--border-focus);
}

.youtube-video-thumb {
  width: 64px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.youtube-video-title {
  font: 400 13px var(--font-body);
  color: var(--text-body);
  line-height: 1.4;
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-pill);
  padding: 14px 32px;
  font: 600 15px var(--font-body);
  box-shadow: var(--shadow-btn);
  transition: transform 80ms, box-shadow 80ms;
  white-space: nowrap;
}

.btn-primary:hover {
  opacity: 0.88;
}

.btn-primary:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 0 #000;
}

.btn-secondary {
  background: transparent;
  color: var(--text-body);
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  padding: 10px 20px;
  font: 500 13px var(--font-body);
  transition: border-color 150ms, color 150ms;
  white-space: nowrap;
}

.btn-secondary:hover {
  border-color: var(--border-focus);
  color: var(--text-primary);
}

/* ── SVG Piano Keys ───────────────────────────────────────── */
.pkey-white {
  fill: #FAFAFA;
  stroke: #CCCCCC;
  stroke-width: 0.8;
}

.pkey-white.active {
  fill: #1A1A1A;
}

.pkey-black {
  fill: #1A1A1A;
  stroke: #000;
  stroke-width: 0.5;
}

.pkey-black.active {
  fill: #444;
}

.pkey-dot {
  fill: #FFFFFF;
  pointer-events: none;
}

.pkey-dot--black {
  fill: #CCCCCC;
}

/* Keep backward-compat aliases just in case */
.piano-key-white {
  fill: #FAFAFA;
  stroke: #CCCCCC;
  stroke-width: 0.8;
}

.piano-key-white.active {
  fill: #1A1A1A;
}

.piano-key-black {
  fill: #1A1A1A;
  stroke: #000;
  stroke-width: 0.5;
}

.piano-key-black.active {
  fill: #444;
}

.piano-key-label {
  fill: #FFF;
  font: 500 9px var(--font-mono);
  text-anchor: middle;
  pointer-events: none;
}

/* Inline add-chord input */
.add-chord-inline {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
  animation: reveal-up 150ms ease;
}

.add-chord-inline input {
  flex: 1;
  background: var(--bg-base);
  border: 1.5px solid var(--border-focus);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  font: 600 15px var(--font-mono);
  color: var(--text-primary);
  outline: none;
}

.add-chord-confirm {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 8px 16px;
  font: 500 13px var(--font-body);
  cursor: pointer;
}

.add-chord-cancel {
  background: transparent;
  border: 1.5px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font: 500 13px var(--font-body);
  cursor: pointer;
  color: var(--text-muted);
}

/* ── Animations ───────────────────────────────────────────── */
@keyframes reveal-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  20% {
    transform: translateX(-6px);
  }

  40% {
    transform: translateX(6px);
  }

  60% {
    transform: translateX(-4px);
  }

  80% {
    transform: translateX(4px);
  }
}

@keyframes pulse-border {

  0%,
  100% {
    border-color: var(--border-subtle);
  }

  50% {
    border-color: var(--border-focus);
  }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 600px) {
  .app {
    padding: 0 16px 60px;
  }

  .app-header {
    padding: 20px 0 16px;
    flex-wrap: wrap;
    gap: 12px;
  }

  .chord-input {
    font-size: 22px;
    padding: 14px 16px;
  }

  .harmony-section,
  .progression-section {
    padding: 20px 16px;
  }

  .progression-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .youtube-analyze-row {
    flex-direction: column;
  }

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