/* Shared print-preview page styling for the A4 renderer (js/songbook_render_preview.js
   + js/song_ordering.js). Used by songbook.php (full songbook export) and song.php
   (single-song PDF export) so both go through the exact same rendering/export path. */

.a4-page {
  font-family: 'Fira Mono', monospace;
  font-size: 14px;
  line-height: 1.5;
  color: #111;
  background: white;
  page-break-after: always;

  /* Printed/exported pages must always look light, regardless of the site's
     active theme. styles.css's dark-mode layer re-styles shared classes used
     inside a rendered page (e.g. .song-header) via var(--surface)/var(--text)
     with !important. Fighting that with more !important rules would mean
     tracking every shared class that might ever end up inside a page.
     Instead, redefine the theme variables here: custom properties resolve by
     inheritance from the nearest ancestor that defines them, so any
     descendant's var(--surface)/var(--text)/etc. resolves to these light
     values, regardless of [data-theme="dark"] on <html>. This also survives
     doExportLogic() cloning the page into a detached wrapper for html2canvas,
     since the variables travel with the .a4-page element itself. */
  --page-bg: #f5f7fb;
  --surface: #ffffff;
  --surface-muted: #f8f9fa;
  --text: #212529;
  --muted: #6c757d;
  --border: #dee2e6;
  --hover: #f0f5ff;
  color-scheme: light;
}

.split-song {
  display: flex;
  justify-content: space-between;
}

.left-column, .right-column {
  width: 48%; /* just under half to fit nicely */
  white-space: pre-wrap;
  word-break: break-word;
}

.a4-page pre {
  font-family: inherit;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  /* styles.css has an unscoped `[data-theme="dark"] pre { background-color:
     var(--surface-muted) }` rule with no !important. Since the variable
     redefinition above only changes what that resolves to (not whether it
     applies), pre still ended up a shade off from the page's white
     background. Same specificity + declared later here wins outright. */
  background-color: white;
  color: #111;
}

/* Proportional-font ("Songbook font" render option) song bodies - built by
   renderSongProportional() in js/chord_font_layout.js via
   buildSongBodyElement() in js/songbook_render_preview.js, same
   chord-row/lyric-row structure as the per-song font choice
   (styles/songs_styles.css), just scoped under .a4-page instead - songbook.php
   doesn't load songs_styles.css (that file is for $website == "songs" pages),
   so these rules are self-contained here rather than shared.

   Row heights are em/ratio-based (font-size-relative), deliberately: they
   need to shrink together with font-size, since buildSongBodyElement
   measures each body's real rendered height against the Fira Mono target
   song_ordering.js already paginated against, then scales font-size down
   until the two match - relying on these rows scaling proportionally along
   with it, rather than being pinned to some fixed number of pixels
   independent of font-size. chord-row's 0.85em (vs. lyric-row's inherited
   1.5 line-height) is intentionally shorter than a full line, so a chord
   sits snug above its lyric line instead of a whole line's worth of empty
   space away from it. */
.a4-page .song-body-proportional {
  color: #111;
}

.a4-page .chord-row {
  position: relative;
  height: 0.85em;
}

.a4-page .chord-row .chord-token {
  position: absolute;
  top: 0;
  line-height: 0.85;
  font-weight: bold;
  white-space: nowrap;
}

/* --a4-row-scale (set inline by buildProportionalBody, songbook_render_
   preview.js) compresses ONLY .lyric-row's line-height, not .chord-row's
   own height above - chord-row's 0.85em is already close to the minimum a
   bold glyph at the page's font-size needs without visually clipping, so
   compressing it further risks the chord symbol overlapping the lyric line
   below it. .lyric-row's nominal 1.5 line-height (matching .a4-page's own,
   now explicit here instead of just inherited, so it can be multiplied)
   has real slack - plain text doesn't need nearly that much breathing room
   to stay legible - so it's the primary way a chunk's height is brought
   down to fit its page/column budget, before font-size is touched at all
   (see computeGlobalRowScale/computeRequiredRowScale). Defaults to 1 (no
   compression) - unset for the non-A4 (song.php) use of this same engine,
   which has no fixed page budget to compress for in the first place. */
.a4-page .lyric-row {
  white-space: pre;
  line-height: calc(1.5 * var(--a4-row-scale, 1));
}

/* ® chorus-marker glyph - see chord_font_layout.js's renderChordRow/
   renderLyricRow (isMarkerToken) and the matching rule in
   styles/songs_styles.css for the non-A4 (song.php) use of the same engine.
   No font-size here deliberately: how much bigger ® needs to render varies
   per font (Calibri's native ® is tiny and needs a big boost; Verdana's is
   already large and needs none), so that's set as an inline style
   per-instance instead (markerScaleStyle, SONG_FONT_MARKER_SCALE in
   song_render.js) - this rule only carries the parts that don't vary by
   font. vertical-align below doesn't actually do the centering (that glyph
   is positioned manually via top:50%/translateY(-50%), same technique as a
   real chord token - see renderChordRow/renderLyricRow) but is left in
   place as a harmless default for wherever this class is used without that
   wrapper. */
.a4-page .chorus-marker-symbol,
.a4-page .chord-token-marker {
  line-height: 1;
  vertical-align: middle;
}
