/* ========================================================
   カラオケ楽曲リスト - スタイルシート (style.css)
   Bootstrap 5 準拠のシンプル・質素なデザイン
   ======================================================== */

html {
  scroll-behavior: smooth;
  background-color: var(--bs-body-bg);
}

body {
  min-height: 100vh;
  background-color: var(--bs-body-bg);
  padding-bottom: calc(60px + env(safe-area-inset-bottom, 20px));
}

/* アプリ中央コンテナ */
.app-container {
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
}

main.app-container {
  padding-bottom: calc(40px + env(safe-area-inset-bottom, 20px));
}

header .app-container {
  padding-bottom: 0;
}

.search-box-wrapper {
  margin-top: 1.5px;
}

/* 上部固定ヘッダー（操作ボタン・検索窓・カテゴリを常時フローティング表示） */
header.sticky-top {
  background-color: var(--bs-body-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 1020;
}

/* ヘッダー操作ボタン（サイズを抑えてスリム化・文字が切り替わっても変わらない固定幅） */
header .btn-sm {
  font-size: 0.75rem;
  padding: 3px 6px;
  height: 28px;
  line-height: 1.3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.header-toggle-btn {
  font-size: 0.75rem;
  padding: 3px 4px;
  white-space: nowrap;
  text-align: center;
  font-weight: 500;
}

#headerSortToggleBtn {
  width: 82px;
  min-width: 82px;
  max-width: 82px;
}

#headerFoldToggleBtn {
  width: 48px;
  min-width: 48px;
  max-width: 48px;
}

#manualSyncBtn.has-update {
  background-color: var(--bs-danger) !important;
  border-color: var(--bs-danger) !important;
  color: #ffffff !important;
  font-weight: 700;
  animation: updatePulse 1.4s infinite;
}

@keyframes updatePulse {
  0% {
    box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(220, 53, 69, 0);
    transform: scale(1.06);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(220, 53, 69, 0);
    transform: scale(1);
  }
}

#syncBadge {
  width: 9px;
  height: 9px;
  background-color: #ffc107; /* 赤いボタンの上でもはっきり見える黄色 */
  border-radius: 50%;
  position: absolute;
  top: -3px;
  right: -3px;
  box-shadow: 0 0 0 2px var(--bs-body-bg);
  animation: syncBadgePulse 1.4s ease-in-out infinite;
}

@keyframes syncBadgePulse {
  0% { transform: scale(0.9); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
  100% { transform: scale(0.9); opacity: 1; }
}

/* 検索バー（高さを抑えてスリムに、左右対称の完全な角丸・枠線、内部クリアボタン） */
/* iOS Safariでタップ時に勝手な画面拡大（ズーム）を防ぐためフォントサイズを16pxに設定 */
.search-box-wrapper .form-control {
  height: 34px;
  min-height: 34px;
  padding: 4px 34px 4px 10px;
  border-radius: 6px;
  font-size: 16px;
  line-height: 1.4;
}

/* ブラウザ標準の検索キャンセルボタンを非表示（自作クリアボタンと二重表示されるのを防ぐ） */
#searchInput::-webkit-search-cancel-button,
#searchInput::-webkit-search-decoration,
#searchInput::-webkit-search-results-button,
#searchInput::-webkit-search-results-decoration {
  -webkit-appearance: none;
  display: none;
}

.btn-clear-search {
  border: none;
  background: transparent;
  color: var(--bs-secondary-color);
  width: 36px;
  height: 100%;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  z-index: 10;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn-clear-search:hover,
.btn-clear-search:active {
  color: var(--bs-body-color);
  background-color: transparent;
}

/* 横スクロール対応（カテゴリタブ） */
.category-scroll-wrapper {
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  padding: 2px 0 4px;
  scrollbar-width: none;
}

.category-scroll-wrapper::-webkit-scrollbar {
  display: none;
}

/* カテゴリナビ（背景色がスクロール追従するスリムなスライドデザイン） */
.category-nav {
  display: inline-flex;
  align-items: center;
  position: relative;
  list-style: none;
  padding: 2px;
  margin: 0;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 5px;
  gap: 1px;
  min-width: max-content;
}

[data-bs-theme="dark"] .category-nav {
  background: rgba(255, 255, 255, 0.07);
}

/* スライドする背景色（グライダー：角丸は少しだけ） */
.category-glider {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  pointer-events: none;
  border-radius: 4px;
  background-color: var(--bs-primary);
  box-shadow: 0 1px 4px rgba(13, 110, 253, 0.3);
  transition: transform 0.25s cubic-bezier(0.25, 1, 0.5, 1),
              width 0.22s cubic-bezier(0.25, 1, 0.5, 1),
              height 0.22s cubic-bezier(0.25, 1, 0.5, 1),
              background-color 0.22s ease,
              box-shadow 0.22s ease;
  will-change: transform, width, background-color;
  transform: translate3d(0, 0, 0);
  opacity: 0;
}

.category-glider.is-ready {
  opacity: 1;
}

.category-nav .nav-item {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  position: relative;
  z-index: 2;
}

/* 以前の「|」仕切り線は非表示 */
.category-nav .nav-item::after {
  display: none !important;
}

.category-nav .nav-link {
  position: relative;
  z-index: 2;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 2px 5px !important;
  margin: 0;
  border: none !important;
  border-bottom: none !important;
  border-radius: 4px !important;
  background: transparent !important;
  line-height: 1.35;
  white-space: nowrap;
  cursor: pointer;
  opacity: 0.72;
  transition: color 0.18s ease, opacity 0.18s ease, font-weight 0.18s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.category-nav .nav-link:hover {
  opacity: 0.95;
}

/* 選択中のタブ（アンダーバーではなく背景色グライダーが敷かれる） */
.category-nav .nav-link.active {
  opacity: 1 !important;
  font-weight: 700;
  color: #ffffff !important;
  border-bottom: none !important;
  background: transparent !important;
}

/* 明るい背景色のタブ（★、練習曲、初見）は文字の視認性のため黒文字 */
.category-nav .nav-link.active.cat-btn-fav,
.category-nav .nav-link.active[data-category="練習曲"],
.category-nav .nav-link.active[data-category="初見"] {
  color: #212529 !important;
}

[data-bs-theme="dark"] .category-nav .nav-link.active[data-category="外部"] {
  color: #212529 !important;
}

/* 「外部」タブ（非選択時は本文色） */
.category-nav .nav-link.cat-btn-external {
  color: var(--bs-body-color);
}

/* 「★」お気に入りタブ（非選択時も黄色スターを強調） */
.category-nav .nav-link.cat-btn-fav {
  color: #ffc107 !important;
  font-size: 0.95rem;
  padding: 2px 5px !important;
  opacity: 0.88;
}

/* 五十音行・日付行のセクションラッパー */
.row-section {
  position: relative;
  margin-top: 0.5rem;
}

.row-section:first-of-type {
  margin-top: 0.25rem;
}

/* 五十音行・日付行の見出し（h2.row_name：見やすいブルー・スクロール中もヘッダー直下に固定追従） */
h2.row_name {
  scroll-margin-top: calc(var(--header-height, 130px) + 8px);
  position: relative;
  top: 0;
  z-index: 1010;
  margin: 0;
  padding: 8px 14px;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff !important;
  background-color: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

/* iOS 26 Safari は下部バーの色を固定/sticky要素の背景から決めるため、青は絶対配置の子に持たせる */
h2.row_name::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-color: var(--bs-primary);
  border-radius: 6px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}

h2.row_name:hover {
  opacity: 0.92;
}

h2.row_name:active {
  transform: scale(0.99);
}

.row_count {
  font-size: 0.75rem;
  font-weight: 600;
  color: #fff;
  background-color: rgba(0, 0, 0, 0.2);
  padding: 3px 9px;
  border-radius: 12px;
}



/* アーティスト別表示ブロック */
.artist-group {
  margin: 0.6rem 0 1rem 0.25rem;
  border-left: 3px solid var(--bs-primary-border-subtle);
  padding-left: 0.6rem;
}

.artist-header {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--bs-body-color);
  margin-bottom: 0.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  padding: 4px 6px;
  border-radius: 4px;
}

.artist-header:hover {
  background-color: var(--bs-tertiary-bg);
}

.artist-header .artist-count {
  font-size: 0.75rem;
  font-weight: normal;
  color: var(--bs-secondary-color);
}

.artist-songs {
  margin-left: 0.25rem;
}

/* アニメ作品別表示ブロック（特別枠：テーマカラー赤系のアクセント） */
.anime-group {
  margin: 0.6rem 0 1rem 0.25rem;
  border-left: 3px solid var(--bs-danger-border-subtle);
  padding-left: 0.6rem;
}

.anime-header {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--bs-body-color);
  margin-bottom: 0.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  padding: 4px 6px;
  border-radius: 4px;
}

.anime-header:hover {
  background-color: var(--bs-tertiary-bg);
}

.anime-header .anime-count {
  font-size: 0.75rem;
  font-weight: normal;
  color: var(--bs-secondary-color);
}

.anime-songs {
  margin-left: 0.25rem;
}

/* 楽曲リストアイテム */
.song-list-group {
  margin-bottom: 1.5rem;
}

.song-item {
  padding: 8px 12px;
  border-bottom: 1px solid var(--bs-border-color-translucent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: background-color 0.1s;
}

.song-item:hover {
  background-color: var(--bs-tertiary-bg);
}

.song-info {
  flex: 1;
  min-width: 0;
}

.song-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.song-title {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0;
  color: var(--bs-body-color);
}

.song-kana {
  font-size: 0.75rem;
  color: var(--bs-secondary-color);
}

.song-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  flex-wrap: wrap;
}

.song-artist {
  font-size: 0.8125rem;
  color: var(--bs-secondary-color);
}

.badge-category {
  font-size: 0.6875rem;
  font-weight: normal;
  padding: 2px 6px;
}

.badge-anime {
  font-size: 0.6875rem;
  background-color: var(--bs-danger-bg-subtle);
  color: var(--bs-danger-text-emphasis);
  border: 1px solid var(--bs-danger-border-subtle);
  padding: 1px 6px;
  border-radius: 4px;
}

.song-date {
  font-size: 0.75rem;
  color: var(--bs-tertiary-color);
}

.song-action {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

/* お気に入りボタン（☆/★） */
.btn-fav {
  border: none;
  background: transparent;
  color: var(--bs-secondary-color);
  font-size: 1.25rem;
  line-height: 1;
  padding: 3px 6px;
  cursor: pointer;
  border-radius: 4px;
  user-select: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, color 0.15s ease;
}

.btn-fav:hover {
  transform: scale(1.2);
}

.btn-fav.active {
  color: #ffc107 !important; /* シンプルな黄色 */
  text-shadow: 0 0 3px rgba(255, 193, 7, 0.4);
}

/* リクエストボタン（質素で押しやすい） */
.btn-request {
  padding: 4px 10px;
  font-size: 0.75rem;
  white-space: nowrap;
  border-radius: 4px;
}

/* 五十音縦型クイックジャンプバー（ドット付きで押しやすくスマートに追従） */
.quick-index-bar {
  position: fixed;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  /* ヘッダーの下・下部バーの上に収める（足りなければドットが縮む） */
  max-height: calc(100vh - 2 * var(--header-height, 130px) - 24px);
  max-height: calc(100dvh - 2 * var(--header-height, 130px) - 24px);
  z-index: 1015;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(128, 128, 128, 0.08);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: 12px;
  padding: 4px 1px;
  user-select: none;
  touch-action: none;
}

.quick-index-bar span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 17px;
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--bs-secondary-color);
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.1s ease;
}

.quick-index-bar span:hover,
.quick-index-bar span:active {
  background-color: var(--bs-primary);
  color: #ffffff !important;
  transform: scale(1.25);
}

/* 文字間のドット（・） */
.quick-index-bar .index-dot {
  width: 18px;
  flex: 0 1 26px;
  flex-shrink: 1;
  min-height: 0;
  overflow: hidden;
  font-size: 0.45rem;
  line-height: 1;
  color: var(--bs-secondary-color);
  opacity: 0.55;
  border-radius: 0;
  pointer-events: none;
}

@media (max-width: 576px) {
  main.app-container {
    padding-right: 28px !important;
    padding-left: 12px !important;
  }
}

/* ページトップボタン（透けずにくっきり浮かび上がる） */
#page_top {
  display: none;
  position: fixed;
  right: 18px;
  bottom: calc(30px + env(safe-area-inset-bottom, 16px));
  z-index: 1016;
  isolation: isolate;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 1.05rem;
  background-color: transparent !important;
  color: #ffffff !important;
  border: none !important;
  box-shadow: none !important;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

#page_top::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: 50%;
  background-color: var(--bs-primary);
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
}

#page_top.show {
  display: flex;
}

#page_top:active {
  transform: scale(0.92);
}

/* ポコポコ波打つドットアニメーション (...) */
.wave-dots {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 28px;
}

.wave-dots span {
  display: inline-block;
  font-size: 1.2rem;
  line-height: 0.6;
  font-weight: 900;
  animation: waveDot 1.2s infinite ease-in-out both;
}

.wave-dots span:nth-child(1) {
  animation-delay: 0s;
}

.wave-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.wave-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes waveDot {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 0.25;
  }
  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* ==========================================
   スプラッシュ画面（起動演出：システムテーマ連動）
   ========================================== */
.splash-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: var(--bs-body-bg);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.45s ease, visibility 0.45s ease;
  user-select: none;
}

.splash-screen.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: splashFadeIn 0.5s ease-out;
}

@keyframes splashFadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.splash-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--bs-body-color);
  letter-spacing: 0.05em;
}

.splash-subtitle {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--bs-primary) !important;
  animation: splashPulse 1.8s ease-in-out infinite;
}

@keyframes splashPulse {
  0%, 100% {
    opacity: 0.65;
  }
  50% {
    opacity: 1;
  }
}

/* イコライザーアニメーション（音の波形） */
.splash-equalizer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 32px;
}

.splash-bar {
  width: 3.5px;
  height: 14px;
  background-color: var(--bs-primary);
  border-radius: 3px;
  animation: splashBarBounce 1s ease-in-out infinite alternate;
}

.splash-bar:nth-child(1) { animation-delay: 0.0s; height: 12px; }
.splash-bar:nth-child(2) { animation-delay: 0.25s; height: 24px; }
.splash-bar:nth-child(3) { animation-delay: 0.45s; height: 18px; }
.splash-bar:nth-child(4) { animation-delay: 0.15s; height: 28px; }
.splash-bar:nth-child(5) { animation-delay: 0.35s; height: 15px; }

@keyframes splashBarBounce {
  0% {
    transform: scaleY(0.35);
  }
  100% {
    transform: scaleY(1.15);
  }
}

/* ヘッダー直下に張り付いている見出し1つだけをstickyにする（JSで is-current を付与） */
h2.row_name.is-current {
  top: var(--header-height, 130px);
  position: -webkit-sticky;
  position: sticky;
}

/* タッチ端末ではホバー色を出さない（スワイプ後にiOSがホバー状態を残し、ボタンが塗りつぶされて見えるのを防ぐ） */
@media (hover: none) {
  header .btn:hover:not(:active) {
    --bs-btn-hover-bg: var(--bs-btn-bg);
    --bs-btn-hover-color: var(--bs-btn-color);
    --bs-btn-hover-border-color: var(--bs-btn-border-color);
  }
}

/* タブ切り替え時のコンテンツスライドアニメーション（左右スワイプ＆タブ移動の動いてる感を演出） */
@keyframes tabContentSlideRight {
  0% {
    opacity: 0.35;
    transform: translateX(28px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes tabContentSlideLeft {
  0% {
    opacity: 0.35;
    transform: translateX(-28px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

.data-list.slide-from-right {
  animation: tabContentSlideRight 0.22s cubic-bezier(0.25, 1, 0.5, 1) backwards;
}

.data-list.slide-from-left {
  animation: tabContentSlideLeft 0.22s cubic-bezier(0.25, 1, 0.5, 1) backwards;
}


/* PC（マウス操作）では、Macのオーバーレイ式スクロールバーと重ならないよう右に余白を取る */
@media (hover: hover) and (pointer: fine) {
  .quick-index-bar {
    right: 18px;
  }
}

/* タブレット（iPadなど）：文字を大きくし、画面端から離して押しやすくする */
@media (min-width: 768px) and (pointer: coarse) {
  .quick-index-bar {
    right: 10px;
    padding: 6px 4px;
    border-radius: 14px;
  }

  .quick-index-bar span {
    width: 34px;
    height: 26px;
    font-size: 0.85rem;
    border-radius: 8px;
    position: relative;
    isolation: isolate;
  }

  /* 押した文字の背景は、押せる範囲ではなく正方形で塗る */
  .quick-index-bar span:not(.index-dot):hover,
  .quick-index-bar span:not(.index-dot):active {
    background-color: transparent !important;
    transform: none;
  }

  .quick-index-bar span:not(.index-dot):hover::before,
  .quick-index-bar span:not(.index-dot):active::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 26px;
    height: 26px;
    transform: translate(-50%, -50%);
    border-radius: 8px;
    background-color: var(--bs-primary);
    z-index: -1;
  }

  .quick-index-bar .index-dot {
    width: 34px;
    flex-basis: 12px;
  }
}
