/* Song page: web view (dark) + print layout (A5, light). */

:root {
  color-scheme: dark;
  --bg:      #0d0d0d;
  --surface: #161616;
  --border:  #2a2a2a;
  --text:    #e8e8e8;
  --muted:   #7a7a7a;
  --accent:  #c8a96e;
  --chord:   #e0b870;
  --hl:      rgba(200, 169, 110, 0.22);
  --serif:   "Georgia", "PT Serif", "Times New Roman", serif;
  --mono:    "JetBrains Mono", "Consolas", "DejaVu Sans Mono", monospace;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--serif);
  line-height: 1.5;
}

a { color: inherit; }

.page {
  max-width: 920px;
  margin: 0 auto;
  padding: 2rem 16px 5rem;
}

/* ── Top nav ── */
.top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 2rem;
}
.top a { text-decoration: none; }
.back-links { display: flex; flex-direction: column; gap: 0.35rem; }
.top a:hover { color: var(--text); }
.uilangs { font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.05em; }
.uilangs a { text-decoration: none; }
.uilangs .on { color: var(--accent); }

/* ── Header ── */
.head { display: flex; gap: 1.1rem; align-items: center; margin-bottom: 1.5rem; }
.head-text { flex: 1; min-width: 0; }
.head-pdfs { display: flex; flex-direction: column; gap: 0.45rem; align-self: flex-start; margin-top: 0.3rem; }
.head-pdfs .pdf { display: block; text-align: center; white-space: nowrap; }
.cover {
  width: 88px; height: 88px; object-fit: cover;
  border-radius: 4px; border: 1px solid var(--border); flex: none;
}
.album { font-size: 0.8rem; color: var(--muted); letter-spacing: 0.04em; text-decoration: none; }
a.album:hover { color: var(--accent); }
.head h1 { font-size: 1.9rem; font-weight: normal; line-height: 1.2; margin: 0.1rem 0 0.35rem; }
.credits { font-size: 0.8rem; color: var(--muted); font-style: italic; }
.credits a { text-decoration: none; border-bottom: 1px solid var(--border); }
.credits a:hover { color: var(--text); }

.player { margin-bottom: 1.25rem; }
.player iframe { display: block; border-radius: 4px; }

/* ── Toolbar ── */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.5rem;
  padding: 0.75rem 0; margin-bottom: 1.75rem;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
}
.ctl { display: flex; align-items: center; gap: 0.5rem; }
.lbl { color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.seg button, .reset, .pdf {
  background: none; border: none; color: var(--muted);
  font: 0.75rem var(--mono); padding: 0.3em 0.7em; cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--border); }
.seg button:hover, .reset:hover, .pdf:hover { color: var(--text); }
.seg button.on { color: var(--bg); background: var(--accent); }
.seg--key output {
  font: 0.8rem var(--mono); color: var(--chord); min-width: 3.2em; text-align: center;
  padding: 0.3em 0.2em; border-left: 1px solid var(--border); border-right: 1px solid var(--border);
}
.seg--key button + output { border-left: 1px solid var(--border); }
.shift { font: 0.75rem var(--mono); color: var(--muted); min-width: 2em; }
.reset { border: 1px solid var(--border); border-radius: 4px; }
.pdf { border: 1px solid var(--border); border-radius: 4px;
  text-decoration: none; letter-spacing: 0.08em;
}

.seg button small { font-size: 0.65rem; opacity: 0.75; }
.toggle {
  background: none; border: 1px solid var(--border); border-radius: 4px; color: var(--muted);
  font: 0.75rem var(--mono); padding: 0.3em 0.8em; cursor: pointer;
}
.toggle:hover { color: var(--text); }
.toggle.on { color: var(--bg); background: var(--accent); border-color: var(--accent); }
#chords-toggle::before { content: "♪ "; }
.toggle:disabled { cursor: default; opacity: 0.55; font-style: italic; }
#chords-toggle:disabled::before { content: ""; }
.toggle--play { display: inline-flex; align-items: center; gap: 0.4em; margin-left: auto; }
.toggle--play svg { color: #ff5500; }
.toggle--play.on svg { color: var(--bg); }
.player[hidden] { display: none; }
.version { margin-top: 0.15rem; font-style: normal; }
.auto-note {
  margin: 0 0 1.2rem; padding: 0.55rem 0.8rem;
  border-left: 3px solid var(--accent); background: var(--surface);
  font-size: 0.85rem; font-style: italic; color: var(--text);
}

/* Second toolbar row: capo + transposition, only in chord mode */
.toolbar--chords { border-top: none; margin-top: -1.75rem; }

/* ── Lyrics-only mode (default): hide everything chord-related ── */
.mode-lyrics .toolbar--chords,
.mode-lyrics .chords,
.mode-lyrics .ch,
.mode-lyrics .ln--only { display: none; }
.mode-lyrics .layout { grid-template-columns: minmax(0, 1fr); }
.mode-lyrics .ln--ch { line-height: 1.5; margin-top: 0; }

.print-meta { display: none; }
.print-links { display: none; }

/* ── Layout: sheet + chord panel ── */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 200px;
  gap: 2.5rem;
  align-items: start;
}

/* ── Sheet ── */
.sheet { font-size: 1.05rem; }
.sec { margin-bottom: 1.4rem; break-inside: avoid; }
.sec--chorus { padding-left: 0.9rem; border-left: 2px solid var(--accent); }
.sec-label {
  font-size: 0.72rem; letter-spacing: 0.12em; text-transform: lowercase;
  color: var(--accent); margin-bottom: 0.25rem;
}
.sec--ref .sec-label { font-style: italic; font-size: 0.85rem; letter-spacing: 0.04em; }
.gap { height: 0.8rem; }
.cmt { color: var(--muted); font-size: 0.85rem; margin: 0.2rem 0; }
.cmt--i { font-style: italic; }

.ln { min-height: 1.5em; }
.ln--ch { line-height: 1.25; margin-top: 0.15rem; }
.w { white-space: nowrap; }
.c { display: inline-block; vertical-align: baseline; }
.c .ly { display: block; white-space: pre; }
.ch {
  display: block;
  font: 700 0.8rem var(--mono);
  color: var(--chord);
  padding-right: 0.45em;
  line-height: 1.35;
  cursor: pointer;
  user-select: none;
}
.ch:hover { text-decoration: underline; text-underline-offset: 3px; }
.ch--none { padding: 0; cursor: auto; }
.ch--none::before { content: "\200b"; }
.ln--only .ly { display: none; }
.ln--only .ch { padding-right: 0.9em; }
.ch.hl { background: var(--hl); border-radius: 2px; }

/* ── Chord panel ── */
.chords { position: sticky; top: 1rem; }
.chords h2 {
  font-size: 0.72rem; font-weight: normal; letter-spacing: 0.12em;
  text-transform: lowercase; color: var(--accent); margin-bottom: 0.6rem;
}
.dg-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.4rem; }
.dg-card {
  display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 4px;
  color: var(--text); padding: 0.45rem 0.2rem 0.35rem; cursor: pointer;
}
.dg-card:hover { border-color: #555; }
.dg-name { font: 700 0.8rem var(--mono); color: var(--chord); }
.dg-img { display: block; line-height: 0; }
.dg { display: block; }
.dg-finger { fill: var(--bg); }
.dg-fret { font-family: var(--mono); }
.dg-none { font: 0.8rem var(--mono); color: var(--muted); line-height: 70px; }

/* ── Popover ── */
.pop {
  position: absolute; z-index: 10;
  background: var(--surface); border: 1px solid #444; border-radius: 6px;
  padding: 0.5rem 0.6rem 0.4rem; color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
}
.pop[hidden] { display: none; }
.pop .dg { width: 110px; height: auto; }

/* ── Mobile: chord panel becomes a strip above the sheet ── */
@media (max-width: 720px) {
  .page { padding-top: 1.25rem; }
  .head h1 { font-size: 1.5rem; }
  .cover { width: 64px; height: 64px; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 1.25rem; }
  .chords { order: -1; position: static; }
  .dg-grid { display: flex; overflow-x: auto; gap: 0.4rem; padding-bottom: 0.3rem; }
  .dg-card { flex: none; width: 84px; }
  .head { flex-wrap: wrap; }
  .head-pdfs { flex-direction: row; width: 100%; }
  .head-pdfs .pdf { flex: 1; }
}

/* ── Songbook (print only): title page, contents, one song per page ── */
.subtitle { font-size: 0.85rem; font-style: italic; color: var(--muted); margin-bottom: 0.2rem; }
.sb-song { break-before: page; }
.sb-title { text-align: center; padding-top: 22mm; }
.sb-photo { width: 26mm; height: 26mm; border-radius: 50%; object-fit: cover; }
.sb-author { font-size: 11pt; color: var(--muted); margin-top: 4mm; letter-spacing: 0.04em; }
.sb-title h1 { font-size: 26pt; font-weight: normal; margin: 2mm 0 1mm; }
.sb-meta { font-size: 8.5pt; font-style: italic; color: var(--muted); }
.sb-toc-title {
  font-size: 9pt; font-weight: normal; letter-spacing: 0.14em; text-transform: lowercase;
  color: var(--accent); margin: 14mm 0 3mm;
}
.sb-toc { list-style: none; text-align: left; max-width: 100mm; margin: 0 auto; font-size: 10pt; }
.sb-toc li { display: flex; gap: 2mm; align-items: baseline; padding: 1.2mm 0; border-bottom: 0.3pt dotted var(--border); }
.sb-toc a { color: var(--text); text-decoration: none; }
.toc-sub { color: var(--muted); font-style: italic; font-size: 8.5pt; }
.toc-year { margin-left: auto; color: var(--muted); font-size: 8.5pt; }

/* ── Compact song header on screen (S1): navigation in one line, credits in one line, PDFs in a row ── */
@media screen {
  .top { margin-bottom: 1rem; }
  .back-links { flex-direction: row; flex-wrap: wrap; gap: 0 0.4rem; }
  .back-links a + a::before { content: "/ "; color: var(--border); }
  .head { margin-bottom: 1rem; gap: 0.9rem; }
  .cover { width: 64px; height: 64px; }
  .head h1 { font-size: 1.6rem; margin: 0 0 0.2rem; }
  .credits > div { display: inline; }
  .credits > div + div::before { content: " · "; font-style: normal; }
  .head-pdfs { flex-direction: row; align-self: center; margin-top: 0; }
}
@media screen and (max-width: 640px) {
  .credits > div { display: block; }
  .credits > div + div::before { content: none; }
}

/* ── Light theme (screen only: print keeps its own palette) ── */
@media screen {
  :root[data-theme="light"] {
    color-scheme: light;
    --bg:      #faf8f4;
    --surface: #f1ede5;
    --border:  #dcd4c6;
    --text:    #1d1b18;
    --muted:   #7a7266;
    --accent:  #8c6a2c;
    --chord:   #9b6a14;
    --hl:      rgba(200, 169, 110, 0.35);
  }
  [data-theme="light"] .pop { border-color: var(--border); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15); }
}

/* ── Theme switch (☀ / ☾ next to the UI language switch) ── */
.theme-toggle {
  background: none; border: none; cursor: pointer; color: var(--muted);
  font-size: 0.95rem; line-height: 1; padding: 0 0 0 0.6rem; vertical-align: baseline;
}
.theme-toggle:hover { color: var(--accent); }
.theme-toggle .to-dark { display: none; }
[data-theme="light"] .theme-toggle .to-light { display: none; }
[data-theme="light"] .theme-toggle .to-dark { display: inline; }

/* ── Print (A5) ── */
@page { size: A5; margin: 12mm 11mm 12mm; }

@media print {
  :root {
    --bg: #fff; --surface: #fff; --border: #ccc; --text: #111;
    --muted: #666; --accent: #555; --chord: #1f3f8f;
  }
  body { font-size: 10pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .page { max-width: none; padding: 0; }
  .top, .player, .toolbar, .pop, .head-pdfs { display: none !important; }
  .head { margin-bottom: 0.4rem; gap: 0.8rem; }
  .cover { width: 52px; height: 52px; border: none; }
  .head h1 { font-size: 15pt; margin: 0; }
  .album, .credits { font-size: 7.5pt; }
  .album .back { display: none; }
  .credits a { border: none; }
  .print-links { display: block; font-size: 7pt; color: var(--muted); margin-top: 0.15rem; line-height: 1.35; }
  .print-links a { color: var(--chord); text-decoration: none; }
  .auto-note { font-size: 8pt; padding: 0.3rem 0.5rem; margin-bottom: 0.6rem; }
  .print-meta {
    display: block; font-size: 8pt; font-style: italic; color: var(--muted);
    border-top: 0.4pt solid var(--border); padding-top: 0.35rem; margin: 0.35rem 0 0.5rem;
  }
  .print-meta b { font-style: normal; color: var(--text); }
  .layout { display: flex; flex-direction: column; gap: 0; }
  .chords { order: -1; position: static; margin-bottom: 0.8rem; }
  .chords h2 { display: none; }
  .dg-grid { display: flex; flex-wrap: wrap; gap: 0.3rem 0.5rem; }
  .dg-card { border: none; padding: 0; background: none; }
  .dg-name { font-size: 8pt; }
  .dg { width: 58px; height: auto; }
  .sheet { font-size: 10.5pt; }
  .ch { font-size: 8pt; }
  .ch:hover { text-decoration: none; }
  .sec { margin-bottom: 0.9rem; }
  .sec--chorus { border-left-width: 1.5px; }
  .page-break { break-after: page; }
}
