/*
  Grace Assembly of God brand, sampled from graceag.sg (the same palette as go.graceag.sg):
  slate text #334155, headings #1e293b, the red of the round logo #CF2127 as the accent,
  light grey panels, the system font stack. Dark mode is our own: the same slate family, with the
  red lightened so it stays readable on dark (5.6:1).
*/
:root {
  --bg: #ffffff;
  --surface: #f9fafb;
  --text: #334155;
  --strong: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --accent: #cf2127;
  --accent-hover: #b01c21;
  --on-accent: #ffffff;
  --chord: #cf2127;
  --chorus: rgba(207, 33, 39, 0.06);
  --shadow: 0 8px 24px rgba(30, 41, 59, 0.16);
  --radius: 10px;
  --radius-btn: 10px;
  --gutter: 12px;
  --tap: 44px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #0f172a;
    --surface: #1e293b;
    --text: #e2e8f0;
    --strong: #f8fafc;
    --muted: #94a3b8;
    --border: #334155;
    --border-strong: #475569;
    --accent: #f26065;
    --accent-hover: #ff7b80;
    --on-accent: #0f172a;
    --chord: #f26065;
    --chorus: rgba(242, 96, 101, 0.1);
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --bg: #0f172a;
  --surface: #1e293b;
  --text: #e2e8f0;
  --strong: #f8fafc;
  --muted: #94a3b8;
  --border: #334155;
  --border-strong: #475569;
  --accent: #f26065;
  --accent-hover: #ff7b80;
  --on-accent: #0f172a;
  --chord: #f26065;
  --chorus: rgba(242, 96, 101, 0.1);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  /* graceag.sg's system stack, then CJK faces for the Mandarin and Japanese songs */
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', 'Noto Sans SC', 'PingFang SC', 'Hiragino Sans', 'Yu Gothic', 'Microsoft YaHei', sans-serif;
}

h1,
h2 {
  color: var(--strong);
  font-weight: 600;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

a {
  color: var(--accent);
}

.muted {
  color: var(--muted);
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 max(var(--gutter), env(safe-area-inset-left)) 64px max(var(--gutter), env(safe-area-inset-right));
}

/* ---- top bar: white (slate in dark) with the round logo, as on graceag.sg ---- */
.bar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 720px;
  margin: 0 auto;
  padding: 6px max(var(--gutter), env(safe-area-inset-left));
  min-height: 56px;
}

.brand,
.back {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--strong);
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand img {
  width: 32px;
  height: 32px;
  display: block;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.site-link {
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
}

.site-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

@media (max-width: 440px) {
  .site-link {
    display: none;
  }
}

.crumb {
  margin: 6px 0 0;
}

.crumb a {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  color: var(--muted);
  font-size: 0.9rem;
  text-decoration: none;
}

.crumb a:hover {
  color: var(--accent);
}

.foot {
  border-top: 1px solid var(--border);
  margin-top: 40px;
  padding: 20px max(var(--gutter), env(safe-area-inset-left));
  text-align: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.foot a {
  color: inherit;
}

.foot img {
  width: 28px;
  height: 28px;
  display: block;
  margin: 0 auto 8px;
}

.icon-btn {
  width: var(--tap);
  height: var(--tap);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background: var(--surface);
  font-size: 1.2rem;
  cursor: pointer;
}

/* ---- home ---- */
.intro {
  margin: 4px 0 20px;
}

.album {
  margin-bottom: 28px;
  scroll-margin-top: 8px;
}

.album-head {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 8px;
}

.album-head h2 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.25;
}

.album-head p {
  margin: 2px 0 6px;
}

.cover {
  width: 96px;
  height: 96px;
  flex: none;
  border-radius: var(--radius);
  object-fit: cover;
  background: var(--surface);
  border: 1px solid var(--border);
}

.cover.ph {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-weight: 700;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background: var(--surface);
  text-decoration: none;
  font-size: 0.9rem;
}

.songs {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border);
}

.songs li {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

.song-link {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  color: var(--text);
  text-decoration: none;
}

.song-title {
  overflow-wrap: anywhere;
}

.key {
  flex: none;
  min-width: 2.4em;
  text-align: center;
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--chorus);
  color: var(--chord);
  font: 600 0.85rem/1.4 ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

.lang-chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0 8px;
  font-size: 0.85rem;
  text-decoration: none;
}

/* ---- buttons and icons ---- */
.ico {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  --cut: var(--surface);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover,
.icon-link:hover {
  border-color: var(--accent);
}

.btn.spotify-btn {
  background: #1db954;
  border-color: #1db954;
  color: #0b0b0b;
}

.btn.spotify-btn .ico {
  --cut: #1db954;
}

.btn.spotify-btn:hover {
  background: #1ed760;
  border-color: #1ed760;
}

.btn.pdf {
  flex: none;
  padding: 0 12px;
  gap: 6px;
}

.icon-link {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background: var(--surface);
  color: var(--text);
}

.icon-link .ico {
  width: 1.4em;
  height: 1.4em;
}

.icon-link.spotify {
  color: #1db954;
}

.icon-link.youtube {
  color: #e5342a;
}

/* ---- rows without a chord chart yet ---- */
.songs li.pending .song-title {
  color: var(--muted);
}

.song-link.disabled {
  cursor: default;
}

.soon {
  display: block;
  font-size: 0.8rem;
  font-style: italic;
  color: var(--muted);
}

.cover-link {
  flex: none;
  display: block;
  border-radius: var(--radius);
}

/* ---- resources on the song page ---- */
.resources {
  margin-top: 12px;
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.featured {
  margin-top: 12px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.featured h2 {
  margin: 0 0 2px;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.featured ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.yt {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
}

.yt .ico {
  color: #e5342a;
  --cut: var(--surface);
}

.yt:hover span {
  text-decoration: underline;
}

.lang-chip.current {
  color: var(--text);
  font-weight: 700;
  border-bottom: 2px solid var(--accent);
}

/* ---- song page ---- */
.song-head h1 {
  margin: 8px 0 2px;
  font-size: 1.5rem;
  line-height: 1.25;
}

.song-head p {
  margin: 0;
}

.langs {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.controls {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin: 12px calc(-1 * var(--gutter)) 0;
  padding: 8px var(--gutter);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.ctl,
.key-pick select {
  min-height: var(--tap);
  min-width: var(--tap);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background: var(--surface);
  font-size: 1.1rem;
  cursor: pointer;
}

.ctl.text {
  padding: 0 14px;
  font-size: 0.9rem;
}

.key-pick select {
  padding: 0 12px;
  font-weight: 600;
}

#notation {
  margin-left: auto;
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* ---- sheet ---- */
.sheet {
  margin-top: 8px;
}

.sec {
  margin: 18px 0;
  padding: 2px 0;
}

.sec h2 {
  margin: 0 0 6px;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.sec-chorus {
  background: var(--chorus);
  border-left: 4px solid var(--accent);
  margin-left: calc(-1 * var(--gutter));
  margin-right: calc(-1 * var(--gutter));
  padding: 8px var(--gutter);
}

.sec-chorus h2 {
  color: var(--accent);
}

.sec-instrumental h2,
.sec-pre h2 {
  font-style: italic;
}

.para + .para {
  margin-top: 10px;
}

.line {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  line-height: 1.35;
  margin: 2px 0;
}

.line.plain {
  display: block;
  padding-top: 0.2em;
  white-space: pre-wrap;
}

.grp {
  display: inline-flex;
  align-items: flex-end;
  max-width: 100%;
}

.seg {
  display: flex;
  flex-direction: column;
  max-width: 100%;
}

.chord {
  align-self: flex-start;
  min-height: 1.5em;
  padding: 0 0.5em 0 0;
  color: var(--chord);
  font: 700 0.95em/1.5 ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  cursor: pointer;
  border-radius: 4px;
}

.chord.blank {
  display: block;
  padding: 0;
  cursor: default;
}

.chord:not(.blank):hover {
  background: var(--chorus);
}

.lyr {
  white-space: pre-wrap;
  min-height: 1.35em;
}

.links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 28px;
}

.credit {
  margin-top: 16px;
  font-size: 0.85rem;
}

/* ---- chord popover ---- */
.pop {
  position: fixed;
  z-index: 20;
  width: 160px;
  padding: 10px 12px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
  text-align: center;
}

.pop[hidden] {
  display: none;
}

.pop-name {
  font: 700 1.1rem/1.3 ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color: var(--chord);
}

.pop svg {
  display: block;
  width: 108px;
  margin: 4px auto 0;
  overflow: visible;
}

.pop .fr {
  font: 600 11px sans-serif;
  fill: currentColor;
  stroke: none;
}

.pop p {
  margin: 6px 0;
  font-size: 0.85rem;
}

@media (min-width: 640px) {
  .wrap {
    padding-bottom: 96px;
  }

  .sec-chorus {
    margin-left: 0;
    margin-right: 0;
    border-radius: 0 var(--radius) var(--radius) 0;
  }
}

@media print {
  .top,
  .controls,
  .links,
  .pop {
    display: none;
  }
}
