/* ── Base ───────────────────────────────────────────────────────────────── */
html {
  font-size: 18px;
}
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f4f5;
  margin: 0;
  color: #111827;
  position: relative;
}

/* ── Topbar ─────────────────────────────────────────────────────────────── */
.topbar {
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 1rem 1.25rem;
}
.topbar-inner {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  font-weight: 700;
  text-decoration: none;
  font-size: 1.35rem;
}
.brand:hover {
  text-decoration: underline;
}
.brand-jap {
  color: #b91c1c;
}
.brand-rest {
  color: #111827;
}
.nav-links {
  display: flex;
  gap: 1rem;
  align-items: center;
}
.nav-link {
  display: inline-block;
  color: #2563eb;
  text-decoration: none;
  font-size: 1.05rem;
}
.nav-link:hover {
  text-decoration: underline;
}
.nav-link-brand {
  font-weight: 700;
  color: #111827;
  font-size: 1.35rem;
  text-transform: lowercase;
}
.topbar .nav-link {
  margin-bottom: 0;
}

/* ── Main layout ────────────────────────────────────────────────────────── */
main {
  padding: 3rem 1.25rem;
  max-width: 1000px;
  margin: 0 auto;
}
.content-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  padding: 2.5rem;
}

/* ── Definition popup ───────────────────────────────────────────────────── */
.definition-popup {
  display: none;
  position: absolute;
  z-index: 100;
  max-width: 320px;
  width: max-content;
  padding: 0.6rem 0.75rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0.375rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  font-size: 0.9rem;
  line-height: 1.4;
  color: #111827;
  pointer-events: auto;
}
.definition-popup.visible {
  display: block;
}
.definition-popup.scrollable {
  max-height: 260px;
  overflow-y: auto;
}
.definition-popup::before,
.definition-popup::after {
  content: '';
  position: absolute;
  left: var(--arrow-left, 50%);
  margin-left: -6px;
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
}
.definition-popup::before {
  bottom: -7px;
  border-top: 6px solid #e5e7eb;
}
.definition-popup::after {
  bottom: -6px;
  border-top: 6px solid #fff;
}
.definition-popup .def-head {
  font-size: 1.25rem;
  display: block;
  margin-bottom: 0.5rem;
}
.definition-popup .def-glosses {
  margin-left: 0.25rem;
}

/* ── Lyric display (shared between index & songs) ───────────────────────── */
.song-display-inner {
  padding: 1.5rem;
  background: #f9fafb;
  border-radius: 0.5rem;
  border: 1px solid #e5e7eb;
  text-align: center;
}
.lyric-line {
  margin-bottom: 1rem;
}
.lyric-line.lyric-gap {
  margin-bottom: 3rem;
}
.lyric-line .surface-row {
  font-size: 1.1rem;
  color: #111827;
}
.lyric-line .romaji-row {
  font-size: 1.1rem;
  color: #111827;
  margin-top: 0.2rem;
}
.lyric-line .romaji-group {
  cursor: default;
  border-radius: 2px;
  padding: 0 1px;
  margin: 0 -1px;
  margin-right: 0.2em;
}
.token-clickable {
  cursor: pointer;
  padding: 2px 1px;
  touch-action: manipulation;
}
.token-clickable:hover {
  color: #b91c1c;
}
.lyric-line[data-active-group] .romaji-group[data-group-idx].highlight,
.lyric-line .romaji-group.highlight {
  background: rgba(37, 99, 235, 0.2);
}
.lyric-line .english {
  font-size: 1.05rem;
  color: #111827;
  margin-top: 0.25rem;
}

/* ── Misc shared ────────────────────────────────────────────────────────── */
.empty-state {
  margin-top: 1rem;
  padding: 1rem;
  background: #fef3c7;
  border-radius: 0.5rem;
  color: #92400e;
  font-size: 0.9rem;
}
.artist-link {
  color: #2563eb;
  text-decoration: none;
}
.artist-link:hover {
  text-decoration: underline;
}

/* ── Mobile responsive ──────────────────────────────────────────────────── */
@media (max-width: 600px) {
  html {
    font-size: 14px;
  }
  .topbar {
    padding: 0.75rem 1rem;
  }
  main {
    padding: 1.5rem 0.75rem;
  }
  .content-card {
    padding: 1.25rem 1rem;
    border-radius: 0.5rem;
  }
  .song-display-inner {
    padding: 1rem 0.75rem;
  }
  /* Popup switches to a fixed bottom sheet on narrow screens */
  .definition-popup.mobile-sheet {
    position: fixed !important;
    left: 0.75rem !important;
    right: 0.75rem !important;
    bottom: 1rem !important;
    top: auto !important;
    max-width: none !important;
    width: auto !important;
    transform: none !important;
    border-radius: 0.5rem;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.18);
  }
  /* Hide arrow pseudo-elements when using bottom-sheet mode */
  .definition-popup.mobile-sheet::before,
  .definition-popup.mobile-sheet::after {
    display: none;
  }
}
