/**
 * Print Studio CSS.
 *
 * Owns ALL color and layout for the printed chart. No chart JS runs on this
 * page, so no cp-theme-* class is ever added to .lyric-sheet-container — the
 * runtime override that defeated every prior CSS fix cannot happen here.
 *
 * The chart markup is the same filter-chain output the screen uses. The
 * chord-over-lyric positioning is therefore the SAME scoped contract the
 * on-screen CSS uses:
 *   - Only chords inside a LYRIC line (.lyrics / .style-lyrics) float above
 *     the text (position:absolute, lifted by --ctop).
 *   - Chords inside a CHORD row (.chords / .style-chords) or a perf-note
 *     (.songmsg / .style-songmsg) stay INLINE (position:static). Standalone
 *     orange chord rows like "D C F D x2" must NOT lift — getting this
 *     scoping wrong is what detached them in the first test print.
 *
 * Token values are the live Clean-theme defaults:
 *   --clh 2.0  --ctop -0.45em  --cfont 0.85em
 */

.ps-page {
  --clh: 2.0;
  --ctop: -0.45em;
  --cfont: 0.85em;
}

/* ── Screen (setup) shell ──────────────────────────────────────────── */
body:has(.ps-page) { background: #f3f3f0; }

.ps-page {
  max-width: 8.5in;
  margin: 0 auto;
  padding: 0.5in 0.6in;
  color: #111;
  font-family: Georgia, 'Times New Roman', serif;
}

.ps-actions { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.ps-print-btn {
  border: 0; border-radius: 6px; padding: 8px 16px;
  background: #2c5f8a; color: #fff; font-size: 14px; cursor: pointer;
}
.ps-print-btn:hover { background: #234c6e; }
.ps-actions-hint { font-size: 12px; color: #666; }

/* ── Song block ────────────────────────────────────────────────────── */
.ps-song { background: #fff; padding: 0.35in 0.45in; margin-bottom: 0.3in; border-radius: 4px; }
.ps-song-head {
  display: flex; align-items: baseline; gap: 14px;
  border-bottom: 2px solid #000; padding-bottom: 6px; margin-bottom: 14px;
}
.ps-song-title { margin: 0; font-size: 18pt; color: #000; flex: 1; }
.ps-song-key, .ps-song-singer { font-size: 12pt; color: #000; white-space: nowrap; }
.ps-song-key { font-weight: 700; }
.ps-song-key::before { content: "Key "; font-weight: 400; color: #777; }
.ps-song-singer { font-style: italic; color: #444; }

/* ── The chart (filter-chain markup) ───────────────────────────────── */
.ps-song-chart .lyric-sheet-container,
.ps-song-chart .lyric-sheet-container * {
  color: #000; background: transparent; background-color: transparent;
}
.ps-song-chart .lyric-sheet-container {
  font-family: 'Courier New', Courier, monospace;
  font-size: 12pt;
}

/* Lyric lines: chords FLOAT above the text. */
.ps-song-chart .lyrics,
.ps-song-chart .style-lyrics,
.ps-song-chart .harmonies,
.ps-song-chart .style-harmonies { line-height: var(--clh); }

.ps-song-chart .lyrics span.chord,
.ps-song-chart .style-lyrics span.chord,
.ps-song-chart .harmonies span.chord,
.ps-song-chart .style-harmonies span.chord {
  height: 1.2em; display: inline-block; position: relative; vertical-align: baseline;
}
.ps-song-chart .lyrics span.chord span.chord-text,
.ps-song-chart .style-lyrics span.chord span.chord-text,
.ps-song-chart .harmonies span.chord span.chord-text,
.ps-song-chart .style-harmonies span.chord span.chord-text {
  position: absolute; display: block; top: var(--ctop); left: 0;
  font-weight: bold; font-size: var(--cfont); line-height: 1; white-space: nowrap;
}

/* Chord rows + perf-notes: chords stay INLINE (standalone orange rows). */
.ps-song-chart .chords span.chord,
.ps-song-chart .style-chords span.chord,
.ps-song-chart .songmsg span.chord,
.ps-song-chart .style-songmsg span.chord {
  height: auto; display: inline; position: static;
}
.ps-song-chart .chords span.chord span.chord-text,
.ps-song-chart .style-chords span.chord span.chord-text,
.ps-song-chart .songmsg span.chord span.chord-text,
.ps-song-chart .style-songmsg span.chord span.chord-text {
  position: static; display: inline; top: auto;
  font-weight: bold; font-size: 0.95em; white-space: nowrap;
}
.ps-song-chart .chords,
.ps-song-chart .style-chords { font-weight: 700; }
.ps-song-chart .songmsg,
.ps-song-chart .style-songmsg { font-style: italic; }

/* Section markers — bold label, own line; surface repeat count via ::after
   so the raw data-section-repeat attribute never leaks as text. */
.ps-song-chart .section-marker {
  display: block; margin: 0.16in 0 0.05in;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
}
.ps-song-chart .section-marker .section-marker__name { background: none; color: #000; }
/* The filter already emits a .section-marker__repeat span (×N) and a
   .section-marker__note span; style them inline, do NOT synthesize a repeat
   via ::after or it would double. */
.ps-song-chart .section-marker__repeat,
.ps-song-chart .section-marker__note {
  font-weight: 700;
  margin-left: 0.4em;
}
.ps-song-chart .section-marker__note { font-style: italic; font-weight: 400; }

/* Personal notes flatten to plain text on paper. */
.ps-song-chart .personal-note {
  background: none; border: 0; color: #000; font-size: 0.9em; padding: 0;
}

/* Suppress interactive chrome that might ride along in the markup. */
.ps-page .lyric-controls,
.ps-page .tools-toggle,
.ps-page .lyric-meta-strip,
.ps-page .lyric-section-ribbon,
.ps-page .lyric-section-rail,
.ps-page .lyric-chord-cheats,
.ps-page .archive-play-button,
.ps-page .setlist-archive-play,
.ps-page .add-note-button,
.ps-page .note-add-affordance,
.ps-page .lyric-note-add,
.ps-page .lyric-title-plate,
.ps-page .metronome,
.ps-page .setlist-song-view-modes,
.ps-page .setlist-song-totop {
  display: none !important;
}

/* ── Paper ─────────────────────────────────────────────────────────── */
@media print {
  @page { margin: 0.35in 0.5in; }
  body, body:has(.ps-page) { background: #fff; }

  /* Strip ALL site/admin chrome so only the chart prints. */
  .toolbar, .toolbar-bar, .toolbar-tray, .toolbar-menu,
  .gin-secondary-toolbar, #toolbar-administration, #toolbar-bar,
  nav.tabs, .tabs, ul.tabs, .block-local-tasks-block,
  .breadcrumb, .messages, .skip-link,
  body > header, body > footer, .site-header, .site-footer,
  .region-header, .region-footer, .region-primary-menu,
  .region-secondary-menu, .mailing-list-banner, .dragonfly-header,
  .primary-nav, .social-links, header[role="banner"],
  .region-highlighted, .region-breadcrumb,
  .ps-actions {
    display: none !important;
  }

  .ps-page { max-width: 100% !important; margin: 0 !important; padding: 0 !important; }

  /* Defensive: the theme wraps content in regions/main that may carry top
     margin/padding. Zero them in the print context so content starts right
     at the page margin — no dead band above the title. The title itself
     stays visible; only the empty space above it is removed. */
  main, .region-content, .layout-content, .page-content, .content,
  [role="main"] {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }
  .page-title, h1.page-title {
    margin-top: 0 !important;
    padding-top: 0 !important;
  }
  .setlist-print-page { margin-top: 0 !important; padding-top: 0 !important; }

  .ps-song {
    border: none !important; border-radius: 0 !important;
    background: #fff !important; padding: 0 !important; margin: 0 !important;
  }
  /* Summary sheet styling is owned entirely by setlist_print CSS so the
     combined view's first page matches the standalone Print Setlist. We only
     force the page break after it (below). */

  /* Force the chart book onto a fresh page after the summary sheet. */
  .ps-summary-sheet { break-after: page; page-break-after: always; }
  .ps-song {
    break-before: page; page-break-before: always;
    margin-top: 0 !important; break-inside: auto;
  }
  .ps-song:first-of-type { break-before: auto; page-break-before: auto; }
  .ps-song-head {
    break-after: avoid; page-break-after: avoid;
    border-bottom: 2px solid #000 !important;
    display: flex !important; visibility: visible !important; color: #000 !important;
  }

  .ps-song-chart .lyric-sheet-container { border: 0 !important; border-radius: 0 !important; }
  .ps-song-chart .lyric-sheet-container,
  .ps-song-chart .lyric-sheet-container * {
    color: #000 !important; background: transparent !important; background-color: transparent !important;
  }

  /* ── Minimize wasted vertical space on paper ───────────────────────
     The single biggest space sink is leading/trailing blank lines and
     generous section gaps. Collapse them here (in CSS, not JS):
       - kill the chart container's own top margin/padding,
       - tighten the gap above each section marker,
       - drop the first section marker's top gap entirely (no dead band
         between the song head and the first section). */
  .ps-song-chart { margin: 0 !important; padding: 0 !important; }
  .ps-song-chart .lyric-sheet-container { margin: 0 !important; padding: 0 !important; }
  .ps-song-chart .lyric-sheet-container > br:first-child { display: none; }
  .ps-song-chart .section-marker {
    margin-top: 0.10in !important;
    margin-bottom: 0.02in !important;
  }
  .ps-song-chart .section-marker:first-child,
  .ps-song-chart .lyric-sheet-container > .section-marker:first-of-type {
    margin-top: 0 !important;
  }
  .ps-song-head { margin-bottom: 8px !important; padding-bottom: 4px !important; }
}
