/* Main styles for Song Notes */

:root {
  --primary-color: #4CAF50;
  --text-color: #333;
  --bg-color: #fff;
  --border-color: #ddd;
  --chord-color: #0066cc;
  --section-bg: #f9f9f9;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--bg-color);
  padding: 1rem;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--border-color);
}

.header h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.subtitle {
  color: #666;
  font-size: 1.1rem;
}

.header-actions {
  margin-top: 1rem;
}

/* Navigation */
.nav-back {
  text-align: left;
  margin-bottom: 1rem;
}

.back-link {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
}

.back-link:hover {
  text-decoration: underline;
}

/* Song Header */
.song-header {
  text-align: center;
}

.song-title-main {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.song-artist {
  font-size: 1.3rem;
  color: #666;
  margin-bottom: 1rem;
}

.song-metadata {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  font-size: 0.9rem;
  color: #666;
}

.meta-item {
  padding: 0.25rem 0;
}

/* Controls */
.controls {
  background: var(--section-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.control-group label {
  font-weight: 600;
  font-size: 0.9rem;
}

.transpose-controls {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

#transpose-display {
  min-width: 2rem;
  text-align: center;
  font-weight: bold;
}

.key-display {
  margin-left: 0.5rem;
  font-size: 0.9rem;
}

/* Buttons */
.btn {
  padding: 0.5rem 1rem;
  background: white;
  border: 2px solid var(--primary-color);
  color: var(--primary-color);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
}

.btn:hover {
  background: var(--primary-color);
  color: white;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background: #45a049;
  border-color: #45a049;
}

.btn-small {
  padding: 0.25rem 0.75rem;
  font-size: 0.85rem;
}

select {
  padding: 0.5rem;
  border: 2px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
}

select:focus {
  outline: none;
  border-color: var(--primary-color);
}

/* Song Library */
.library-info {
  text-align: center;
  margin-bottom: 2rem;
  font-size: 1.1rem;
}

.song-library {
  display: grid;
  gap: 2rem;
}

.artist-group {
  background: var(--section-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
}

.artist-name {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--primary-color);
}

.song-list {
  list-style: none;
}

.song-item {
  margin-bottom: 0.5rem;
}

.song-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  text-decoration: none;
  color: var(--text-color);
  transition: all 0.2s;
}

.song-link:hover {
  border-color: var(--primary-color);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.song-title {
  font-weight: 600;
  font-size: 1.1rem;
}

.song-meta {
  font-size: 0.85rem;
  color: #666;
}

/* Song Content */
.song-content {
  background: white;
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 1rem;
}

.song-layout {
  display: flex;
  gap: 1.25rem;
  align-items: start;
}

.song-main {
  flex: 1 1 auto;
  min-width: 0;
}

.song-sidebar {
  flex: 0 0 18rem;
  width: min(18rem, 30vw);
  align-self: start;
}

.song-sidebar-panel {
  position: sticky;
  top: 1rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.song-sidebar-heading {
  margin-bottom: 0.75rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #666;
}

.structure-overview {
  padding: 1rem;
  background: var(--section-bg);
  border-radius: 4px;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  text-align: center;
}

.song-body {
  font-family: 'Courier New', monospace;
}

.song-content .paragraph {
  margin-bottom: 0.75rem;
  padding: 0.75rem;
  border-radius: 4px;
}

.song-line-mobile {
  display: none !important;
}

.chord-run {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  margin: 0 0 0.65rem;
}

.chord-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 1.8rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(0, 102, 204, 0.16);
  background: rgba(0, 102, 204, 0.08);
  color: var(--chord-color);
  font-size: 0.82em;
  font-weight: 700;
  line-height: 1;
}

.song-line-pair {
  display: flex;
  gap: 0.6rem;
  align-items: start;
}

.song-line-slot {
  flex: 0 1 auto;
  min-width: 0;
}

.song-line-slot + .song-line-slot {
  padding-left: 0.55rem;
  border-left: 1px solid rgba(0, 0, 0, 0.08);
}

.song-line-pair .song-line-slot .row-lyrics-only {
  margin-top: 0.96rem;
}

.hide-chords .song-line-pair .song-line-slot .row-lyrics-only {
  margin-top: 0;
}

.section-label {
  display: inline-flex;
  align-items: center;
  margin-bottom: 0.65rem;
  padding: 0.2rem 0.6rem;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #4d4d4d;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 999px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.45) inset;
}

.song-content .paragraph.verse .section-label {
  color: #2f7d32;
}

.song-content .paragraph.chorus .section-label {
  color: #b26a00;
}

.song-content .paragraph.bridge .section-label {
  color: #1769aa;
}

.song-content .paragraph.verse {
  background: #f8f9fa;
  border-left: 3px solid #4CAF50;
}

.song-content .paragraph.chorus {
  background: #fff3e0;
  border-left: 3px solid #ff9800;
}

.song-content .paragraph.bridge {
  background: #e3f2fd;
  border-left: 3px solid #2196f3;
}

.song-content table.row {
  width: auto;
  border-collapse: collapse;
  border-spacing: 0;
  margin-bottom: 0.5rem;
  font-family: 'Courier New', monospace;
}

.song-content table.row tr {
  vertical-align: top;
}

.song-content td {
  padding: 0;
  vertical-align: top;
  white-space: pre;
}

.song-content td:not(:last-child) {
  padding-right: 0.75ch;
}

.song-content td.chord {
  color: var(--chord-color);
  font-weight: bold;
  font-size: 0.85em;
  line-height: 1.2;
  padding-bottom: 0.1rem;
}

.song-content td.lyrics {
  color: var(--text-color);
  line-height: 1.4;
}

.song-content .lyric-fragment {
  display: inline-block;
}

.song-content .lyric-fragment.continues-word {
  margin-left: -0.45ch;
}

.song-content .comment {
  color: #666;
  font-style: italic;
  display: block;
  margin: 0.5rem 0;
}

.song-section[data-repeat-first="false"] .section-repeat-callout {
  display: none;
}

.section-repeat-callout {
  display: inline-block;
  margin-bottom: 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #555;
  background: rgba(255, 255, 255, 0.8);
  border: 1px dashed var(--border-color);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
}

.structure-overview {
  display: none;
}

.structure-only .structure-overview {
  display: block;
}

.structure-only .song-body,
.structure-only .song-sidebar {
  display: none;
}

.structure-only .structure-overview {
  font-size: 1.2rem;
  padding: 2rem;
}

.compact-repeats .song-section[data-repeat-first="false"] .section-repeat-callout {
  display: inline-block;
}

.compact-repeats .song-section[data-repeat-first="false"] .section-body {
  display: none;
}

/* Font Size Classes */
.font-small {
  font-size: 0.75rem;
}

.font-medium {
  font-size: 0.85rem;
}

.font-large {
  font-size: 1rem;
}

.font-xlarge {
  font-size: 1.15rem;
}

/* Display Modes */
/* Chord Diagrams */
.chord-diagrams {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(5rem, 1fr));
  gap: 0.75rem;
  align-items: flex-start;
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--section-bg);
}

.chord-diagrams svg,
.chord-diagrams .chord-diagram {
  width: 5rem;
  max-width: 5rem;
  height: auto;
  justify-self: center;
  display: block;
}

.hide-chords .song-sidebar {
  display: none;
}

.hide-chords .song-layout.has-sidebar,
.structure-only .song-layout.has-sidebar {
  display: block;
}

/* Hide Chords Toggle */
.hide-chords .song-content .row-with-chords .chords-row,
.hide-chords .song-content .row-chords-only {
  display: none;
}

.hide-chords .song-content .chord-run {
  display: none;
}

.hide-chords .song-content .lyric-fragment.continues-word {
  margin-left: -0.6ch;
}

.hide-chords .chord {
  display: none;
}

/* Two Column Layout */
.two-columns .song-body {
  column-count: 2;
  column-gap: 2rem;
}

.two-columns .song-layout.has-sidebar {
  display: block;
}

.two-columns .song-sidebar {
  width: 100%;
  margin-top: 1.5rem;
}

.two-columns .song-sidebar-panel {
  position: static;
  max-height: none;
  overflow: visible;
}

.two-columns .song-content table.row {
  break-inside: avoid;
}

.two-columns .song-content table.row:has(.label-wrapper) {
  break-after: avoid;
}

@media (max-width: 768px) {
  body {
    padding: 0.75rem;
  }

  .container {
    max-width: none;
  }

  .header {
    margin-bottom: 1.5rem;
    padding-bottom: 0.85rem;
  }

  .song-title-main {
    font-size: 1.8rem;
  }

  .song-artist {
    font-size: 1.15rem;
    margin-bottom: 0.85rem;
  }

  .song-metadata {
    justify-content: flex-start;
    gap: 0.35rem 1rem;
    text-align: left;
  }

  .controls {
    padding: 0.85rem;
    gap: 0.75rem;
    align-items: stretch;
  }

  .control-group {
    width: 100%;
    min-width: 0;
    flex-wrap: wrap;
    align-items: center;
  }

  .control-group--transpose {
    gap: 0.5rem 0.75rem;
  }

  .control-group--font {
    gap: 0.5rem;
  }

  .control-group--actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .control-group--actions .btn {
    width: 100%;
    min-width: 0;
  }

  .key-display {
    margin-left: 0;
  }

  .song-content {
    padding: 0.85rem;
  }

  .song-content .paragraph {
    padding: 0.65rem;
  }

  .song-line-desktop {
    display: none;
  }

  .song-line-mobile {
    display: flex !important;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.25rem 0.45rem;
    margin-bottom: 0.5rem;
    font-family: 'Courier New', monospace;
  }

  .song-line-mobile--lyrics-only {
    display: block !important;
  }

  .mobile-lyrics-full {
    display: block;
    white-space: normal;
    line-height: 1.4;
  }

  .mobile-segment {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    max-width: 100%;
    min-width: 0;
  }

  .mobile-chord {
    color: var(--chord-color);
    font-weight: bold;
    font-size: 0.85em;
    line-height: 1.2;
    min-height: 1.15em;
  }

  .mobile-lyrics {
    display: block;
    white-space: normal;
    line-height: 1.4;
  }

  .mobile-lyrics.continues-word {
    margin-left: -0.2ch;
  }

  .song-layout {
    flex-direction: column;
  }

  .song-line-pair {
    flex-direction: column;
    gap: 0;
  }

  .song-line-slot + .song-line-slot {
    padding-left: 0;
    border-left: 0;
  }

  .song-sidebar {
    flex: 1 1 auto;
    width: 100%;
  }

  .song-sidebar-panel {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .two-columns .song-body {
    column-count: 1;
  }

  .hide-chords .song-line-mobile .mobile-chord {
    display: none;
  }

  .hide-chords .song-line-mobile .mobile-segment--chord-only {
    display: none;
  }
}

/* Footer */
.footer {
  text-align: center;
  padding: 2rem 0;
  color: #666;
  font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 400px) {
  body {
    padding: 0.5rem;
  }

  .header h1 {
    font-size: 1.8rem;
  }

  .song-title-main {
    font-size: 1.5rem;
  }

  .controls {
    padding: 0.75rem;
  }

  .control-group--actions {
    grid-template-columns: 1fr;
  }

  .song-content {
    padding: 0.75rem;
  }

  .song-metadata {
    flex-direction: column;
    gap: 0.5rem;
  }
}

/* No Print */
@media print {
  .no-print {
    display: none !important;
  }
}
