/* Shared styles for the home page and every song page. */

:root {
  --tint: #ffffff;           /* replaced per song from song.txt */
  --ink: #1f242b;            /* main text */
  --ink-soft: rgba(31, 36, 43, 0.72);
  --ink-faint: rgba(31, 36, 43, 0.5);
  --rule: rgba(31, 36, 43, 0.18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  --gutter: clamp(16px, 4vw, 40px);
  color-scheme: light;
}
/* Dark tints switch to light text automatically (set by song.js). */
:root.dark-tint {
  --ink: #f4f2ee;
  --ink-soft: rgba(244, 242, 238, 0.76);
  --ink-faint: rgba(244, 242, 238, 0.5);
  --rule: rgba(244, 242, 238, 0.24);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--tint);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 400;
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 3px; }
[hidden] { display: none !important; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.text-button {
  background: none; border: 0; padding: 6px 2px; cursor: pointer;
  color: var(--ink-soft); font-size: 16px;
  text-decoration: underline; text-decoration-color: var(--rule);
  text-underline-offset: 4px; text-decoration-thickness: 1px;
}
.text-button:hover { color: var(--ink); text-decoration-color: var(--ink-soft); }

/* ---------- Song page ---------- */

.backdrop { position: fixed; inset: 0; z-index: 0; overflow: hidden; }
.backdrop-img {
  position: absolute; inset: -4%;
  background: var(--tint) center / cover no-repeat;
  transform: scale(1);
  transition: transform 40s linear;
}
body.playing .backdrop-img { transform: scale(1.06); }
.backdrop-tint {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 50% 45%, color-mix(in srgb, var(--tint) 35%, transparent), color-mix(in srgb, var(--tint) 80%, transparent) 75%),
    color-mix(in srgb, var(--tint) 30%, transparent);
}

.frame {
  position: relative; z-index: 1;
  min-height: 100vh; min-height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(260px, 1fr) auto auto auto auto;
  padding: max(12px, env(safe-area-inset-top)) var(--gutter) max(20px, env(safe-area-inset-bottom));
  max-width: 54rem; margin: 0 auto;
}
.top { display: flex; align-items: center; min-height: 44px; }
.home-link {
  text-decoration: none; color: var(--ink-soft); font-size: 16px; letter-spacing: 0.01em;
  padding: 6px 0;
}
.home-link:hover { color: var(--ink); }

.song-main { position: relative; display: grid; min-height: 0; }

/* The stage: one line at a time. */
.stage {
  position: relative; display: grid; place-items: center; text-align: center;
  min-height: 260px;
}
.stage > * { grid-area: 1 / 1; margin: 0; }
.line, .idle {
  width: min(100%, 30rem);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 900ms ease, transform 1200ms ease;
}
.line {
  font-weight: 400;
  font-size: clamp(27px, 5.4vw, 42px);
  line-height: 1.25;
  text-wrap: balance;
}
.line.on, .idle.on { opacity: 1; transform: none; }
.line.off { transform: translateY(-8px); }
.idle-title {
  margin: 0; font-weight: 400;
  font-size: clamp(34px, 7vw, 56px); line-height: 1.12; text-wrap: balance;
}

/* All lyrics: hidden from view in synced mode, but always readable by screen readers. */
.all-lyrics {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
body.static .stage { display: none; }
body.static .all-lyrics {
  position: relative !important; width: auto; height: auto; clip: auto; white-space: normal;
  overflow-y: auto; overscroll-behavior: contain;
  padding: 8px 0 16px;
}
.all-lyrics-inner { width: min(100%, 34rem); margin: 0 auto; }
.all-title { margin: 0 0 1em; font-weight: 400; font-size: 1.35em; line-height: 1.2; }
.all-text { font-size: var(--lyric-size, 20px); line-height: 1.5; user-select: text; }
.all-text p { margin: 0 0 1.1em; }
.all-text .label { color: var(--ink-soft); }

/* Controls */
.controls { display: flex; align-items: center; gap: 16px; padding: 18px 0 6px; }
.play {
  flex: none; width: 56px; height: 56px; border-radius: 50%;
  border: 1px solid var(--ink-soft); background: color-mix(in srgb, var(--tint) 40%, transparent);
  display: grid; place-items: center; cursor: pointer; padding: 0;
  transition: background-color 200ms ease, border-color 200ms ease;
}
.plays.problem { color: #b3261e; }
:root.dark-tint .plays.problem { color: #ffb4ab; }
.play:hover { border-color: var(--ink); background: color-mix(in srgb, var(--ink) 10%, transparent); }
.play svg { width: 24px; height: 24px; fill: var(--ink); }
.play .icon-pause { display: none; }
body.playing .play .icon-play { display: none; }
body.playing .play .icon-pause { display: block; }
.progress { flex: 1; display: flex; align-items: center; gap: 12px; min-width: 0; }
.time { flex: none; font-size: 14px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.seek {
  -webkit-appearance: none; appearance: none; flex: 1; min-width: 0; height: 28px;
  background: transparent; cursor: pointer; margin: 0;
  --pct: 0%;
}
.seek::-webkit-slider-runnable-track {
  height: 2px; border-radius: 2px;
  background: linear-gradient(to right, var(--ink) var(--pct), var(--rule) var(--pct));
}
.seek::-moz-range-track { height: 2px; border-radius: 2px; background: var(--rule); }
.seek::-moz-range-progress { height: 2px; border-radius: 2px; background: var(--ink); }
.seek::-webkit-slider-thumb {
  -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%;
  background: var(--ink); margin-top: -5px; border: 0;
}
.seek::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--ink); border: 0; }

.actions { display: flex; flex-wrap: wrap; gap: 4px 22px; padding: 4px 0 0; }
.plays { margin: 10px 0 0; font-size: 15px; color: var(--ink-soft); }

.credits {
  margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--rule);
  font-size: 14px; line-height: 1.6; color: var(--ink-faint);
}
.credits p { margin: 0; }

@media (prefers-reduced-motion: reduce) {
  .line, .idle { transition: opacity 200ms linear; transform: none !important; }
  .backdrop-img { transition: none; }
  body.playing .backdrop-img { transform: none; }
}

/* ---------- Home page ---------- */

.home-page { background: #ffffff; --tint: #ffffff; }
.home {
  max-width: 40rem; margin: 0 auto;
  padding: clamp(48px, 12vh, 120px) var(--gutter) 48px;
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
}
.home-name { margin: 0; font-weight: 400; font-size: 18px; line-height: 1.4; color: var(--ink-soft); }
.home-tagline { margin: 0; color: var(--ink-soft); font-size: 18px; }
.song-list { list-style: none; margin: clamp(32px, 7vh, 64px) 0 0; padding: 0; border-top: 1px solid var(--rule); }
.song-list li { border-bottom: 1px solid var(--rule); }
.song-list a {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px;
  padding: 18px 0; text-decoration: none;
}
.song-list .t { font-size: clamp(22px, 4.5vw, 28px); font-weight: 400; line-height: 1.25; }
.song-list a:hover .t { text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 5px; }
.song-list .d { flex: none; font-size: 14px; color: var(--ink-faint); }
.home-empty { margin-top: 48px; color: var(--ink-soft); }
.home-foot { margin-top: auto; padding-top: 56px; font-size: 14px; color: var(--ink-faint); display: flex; flex-wrap: wrap; gap: 6px 22px; }
.home-foot a { color: var(--ink-soft); }

/* Static view keeps the page to one screen; the lyrics area scrolls only if it must. */
body.static .frame { height: 100vh; height: 100dvh; }
body.static .song-main { min-height: 0; }
body.static .all-lyrics { height: 100%; }
/* ---------- Words pages ---------- */
.piece-page .home { padding-top: 24px; }
.piece-back { color: var(--ink-soft); text-decoration: none; font-size: 16px; padding: 6px 0; }
.piece-back:hover { color: var(--ink); }
.piece-title { margin: 48px 0 24px; font-weight: 400; font-size: clamp(26px, 5vw, 34px); line-height: 1.25; }
.piece-text { white-space: pre-wrap; overflow-wrap: break-word; font-size: 19px; line-height: 1.65; }