/* Shared styles for SingLink pages. Page-specific rules are scoped by the body
   class (audience / login / manage) so their generic selectors don't collide. */

:root { color-scheme: dark; }
* { box-sizing: border-box; }

body {
  margin: 0;
  background: #0b0b0f;
  color: #f4f4f5;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---- Audience page ---- */
body.audience {
  min-height: 100vh;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
.audience main {
  max-width: 44rem;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}
/* Optional runtime logo, shown at the top of the audience page (welcome + song). */
.audience #logo {
  display: block;
  max-width: min(200px, 60vw);
  height: auto;
  margin: 0.5rem 0 1.5rem;
}
/* Metadata sits directly under the title as a subtitle line. */
.audience #meta {
  font-size: 0.95rem;
  color: #a1a1aa;
}
.audience #meta:not(:empty) { margin-bottom: 1.25rem; }
.audience #now-playing:not(:empty) {
  margin-top: 1rem;
  font-style: italic;
  color: #a1a1aa;
}
.audience #song-title {
  margin: 0.5rem 0 0.3rem;
  font-size: clamp(1.75rem, 1.2rem + 4.5vw, 3rem);
  font-weight: 700;
  line-height: 1.1;
}
.audience #song-title:empty { display: none; }
/* Lyric size scales with the reader's chosen --text-scale (see #text-size). */
.audience #content { font-size: calc(clamp(1rem, 1rem + 2vw, 1.75rem) * var(--text-scale, 1)); }
.audience #content h2 {
  font-size: 0.9em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #71717a;
  margin: 1.5em 0 0.4em;
}
.audience #content p { margin: 0 0 0.6em; }
/* Persistent footer below the lyrics (rendered from _footer.md). */
.audience #site-footer {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid #26262e;
  font-size: 0.9rem;
  color: #a1a1aa;
}
.audience #site-footer a { color: #86efac; }
.audience #site-footer p { margin: 0 0 0.4em; }
.audience #status {
  position: fixed;
  bottom: 0.5rem;
  right: 0.75rem;
  font-size: 0.75rem;
  color: #52525b;
}
/* Per-reader text-size control, fixed opposite the status text. */
.audience #text-size {
  position: fixed;
  bottom: 0.6rem;
  left: 0.75rem;
  z-index: 2;
  display: flex;
  gap: 0.35rem;
  opacity: 0.75;
}
.audience #text-size button {
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid #26262e;
  border-radius: 0.55rem;
  background: rgba(22, 22, 28, 0.9);
  color: #d4d4d8;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.audience #text-size button:active { background: #26262e; }

/* ---- Login page ---- */
body.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login form {
  width: min(22rem, 90vw);
  padding: 2rem 1.75rem;
  background: #16161c;
  border-radius: 1rem;
}
.login h1 { margin: 0 0 1.25rem; font-size: 1.25rem; }
.login input[type=password] {
  width: 100%;
  padding: 0.85rem 1rem;
  font-size: 1.25rem;
  border: 1px solid #3f3f46;
  border-radius: 0.6rem;
  background: #0b0b0f;
  color: #f4f4f5;
  text-align: center;
  letter-spacing: 0.3em;
}
.login button {
  width: 100%;
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  font-size: 1.05rem;
  border: 0;
  border-radius: 0.6rem;
  background: #4f46e5;
  color: #fff;
  cursor: pointer;
}
.login .error { margin: 0 0 1rem; color: #f87171; font-size: 0.95rem; }

/* ---- Manage page ---- */
.manage header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.9rem 1rem;
  background: #16161c;
  border-bottom: 1px solid #26262e;
}
.manage header h1 { margin: 0; font-size: 1.1rem; }
.manage header h1 img { display: block; height: 2rem; width: auto; }
.manage .status-group {
  margin-right: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.manage #listeners {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  color: #a1a1aa;
  background: #0b0b0f;
  border: 1px solid #26262e;
  border-radius: 999px;
}
.manage #listeners::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #22c55e;
}
/* Countdown until the live song auto-reverts to the welcome page. The ::before
   is a depleting fill whose width tracks --progress (1 → 0), set each second by
   manage.js via CSSOM (inline styles are forbidden by the CSP). */
.manage #auto-revert {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  color: #fcd34d;
  background: #0b0b0f;
  border: 1px solid #3f3a1f;
  border-radius: 999px;
}
.manage #auto-revert[hidden] { display: none; }
.manage #auto-revert::before {
  content: "";
  position: absolute;
  inset: 0;
  width: calc(var(--progress, 1) * 100%);
  background: rgba(245, 158, 11, 0.16);
  transition: width 1s linear;
}
.manage #auto-revert > * { position: relative; }
.manage #auto-revert svg { width: 0.95rem; height: 0.95rem; }
/* Under a minute: switch to a red alert palette. */
.manage #auto-revert.warning {
  color: #fca5a5;
  border-color: #7f1d1d;
}
.manage #auto-revert.warning::before { background: rgba(239, 68, 68, 0.2); }
.manage header .actions { display: flex; gap: 0.5rem; }
.manage header form { margin: 0; }
.manage .btn {
  padding: 0.6rem 0.9rem;
  font-size: 0.95rem;
  cursor: pointer;
  border: 1px solid #3f3f46;
  border-radius: 0.55rem;
  background: #0b0b0f;
  color: #f4f4f5;
}
.manage #welcome-btn.active { background: #4f46e5; border-color: #4f46e5; }
.manage #filter-bar { padding: 0.75rem 0.75rem 0; }
.manage #song-filter {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-size: 1rem;
  border: 1px solid #3f3f46;
  border-radius: 0.6rem;
  background: #0b0b0f;
  color: #f4f4f5;
}
.manage #song-filter::placeholder { color: #71717a; }
.manage #filter-empty { margin: 0.75rem 0.25rem 0; color: #a1a1aa; }
.manage ul {
  list-style: none;
  margin: 0;
  padding: 0.75rem;
  display: grid;
  gap: 0.6rem;
}
.manage .song-row { position: relative; }
/* Ghost icon button: overlaid inside the select card, at the right edge. It sits
   above the card in the DOM, so taps on it preview and taps elsewhere select. */
.manage .preview-btn {
  position: absolute;
  top: 50%;
  right: 0.55rem;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #a1a1aa;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.manage .preview-btn svg { width: 1.35rem; height: 1.35rem; }
.manage .preview-btn:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }
.manage .preview-btn:active { color: #fff; background: rgba(255, 255, 255, 0.18); }
/* On the active (purple) card, lift the eye so it stays legible. */
.manage .song.active ~ .preview-btn { color: #dcdcff; }
.manage .song {
  width: 100%;
  text-align: left;
  cursor: pointer;
  padding: 1.05rem 3.75rem 1.05rem 1.1rem; /* right room for the overlaid eye */
  border: 1px solid #26262e;
  border-radius: 0.8rem;
  background: #16161c;
  color: #f4f4f5;
  display: grid;
  gap: 0.2rem;
}
.manage .song:active { transform: scale(0.99); }
.manage .song.active { background: #4f46e5; border-color: #6366f1; }
.manage .song .title { font-size: 1.25rem; font-weight: 600; }
.manage .song .sub { font-size: 0.85rem; color: #a1a1aa; }
.manage .song.active .sub { color: #dcdcff; }
.manage .empty { padding: 2rem 1rem; color: #a1a1aa; }

/* Lyrics preview modal. */
.manage #preview {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.6);
}
.manage #preview[hidden] { display: none; }
.manage #preview-panel {
  width: 100%;
  max-width: 44rem;
  margin: 2rem 0;
  padding: 1.25rem 1.25rem 2rem;
  background: #0b0b0f;
  border: 1px solid #26262e;
  border-radius: 0.9rem;
  height: max-content;
}
.manage #preview-close { float: right; }
.manage #preview-title { margin: 0 0 0.3rem; font-size: 1.5rem; }
.manage #preview-meta { margin-bottom: 1.25rem; font-size: 0.9rem; color: #a1a1aa; }
.manage #preview-body { font-size: 1.1rem; line-height: 1.5; }
.manage #preview-body h2 {
  font-size: 0.9em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #71717a;
  margin: 1.3em 0 0.3em;
}
.manage #preview-body p { margin: 0 0 0.5em; }
.manage #preview-empty { color: #a1a1aa; }
