/* ============================================================
   CSS Custom Properties
   ============================================================ */
:root {
  --color-bg:        #f8f7f4;
  --color-surface:   #ffffff;
  --color-border:    #e0ddd8;
  --color-text:      #2c2c2c;
  --color-muted:     #7a7670;
  --color-accent:    #4a6fa5;
  --color-accent-h:  #3a5f95;
  --color-tonic-bg:  #e8f0e8;
  --color-tonic-bd:  #b8d4b8;
}

/* ============================================================
   Base
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: Georgia, 'Times New Roman', serif;
  background: var(--color-bg);
  color: var(--color-text);
  margin: 0;
  padding: 1.5rem 1rem;
}

/* ============================================================
   Header
   ============================================================ */
header {
  max-width: 900px;
  margin: 0 auto 2rem;
  text-align: center;
}

h1 {
  font-size: 1.8rem;
  font-weight: bold;
  margin: 0 0 0.3rem;
  letter-spacing: -0.01em;
}

.subtitle {
  font-size: 0.95rem;
  color: var(--color-muted);
  margin: 0;
  font-style: italic;
}

/* ============================================================
   Main layout
   ============================================================ */
main {
  max-width: 900px;
  margin: 0 auto;
}

/* ============================================================
   Controls
   ============================================================ */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 2rem;
  padding: 1.25rem 1.5rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.control-group label {
  font-size: 0.75rem;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-family: system-ui, sans-serif;
}

.control-group select {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 0.95rem;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
  min-width: 100px;
}

.control-group select:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 1px;
}

/* ============================================================
   Buttons
   ============================================================ */
.button-group {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

button {
  font-family: system-ui, sans-serif;
  font-size: 0.9rem;
  border-radius: 6px;
  padding: 0.5rem 1.1rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  line-height: 1.4;
}

#btn-generate,
#btn-regenerate {
  background: var(--color-accent);
  color: #fff;
  border: 1px solid var(--color-accent);
}

#btn-generate:hover,
#btn-regenerate:hover {
  background: var(--color-accent-h);
  border-color: var(--color-accent-h);
}

#btn-generate:active,
#btn-regenerate:active {
  transform: translateY(1px);
}

#btn-copy {
  background: transparent;
  color: var(--color-accent);
  border: 1px solid var(--color-accent);
}

#btn-copy:hover {
  background: var(--color-accent);
  color: #fff;
}

#btn-copy:active {
  transform: translateY(1px);
}

/* ============================================================
   Progression Grid
   ============================================================ */
.bar-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.bar-grid.visible {
  opacity: 1;
}

/* ============================================================
   Bar Cards
   ============================================================ */
.bar-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* Tonic bars (bar 1 and bar 8) get a subtle green tint */
.bar-card.tonic {
  background: var(--color-tonic-bg);
  border-color: var(--color-tonic-bd);
}

.bar-number {
  font-family: system-ui, sans-serif;
  font-size: 0.65rem;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.chord-symbol {
  font-size: 1.9rem;
  font-weight: bold;
  color: var(--color-text);
  line-height: 1.1;
  font-family: Georgia, 'Times New Roman', serif;
}

.roman-numeral {
  font-size: 0.82rem;
  color: var(--color-muted);
  font-style: italic;
  font-family: Georgia, 'Times New Roman', serif;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 800px) {
  .bar-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

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

  h1 {
    font-size: 1.4rem;
  }

  .controls {
    padding: 1rem;
  }
}
