/* Touch Navi 基本スタイル */

/* トグルボタン */
.touchnavi#toggleMenu {
  position: relative;
  bottom: 15px;
  z-index: 10000;
  cursor: pointer;
  text-align: center;
  color: var(--tn-toggle-text, #ffffff);
  background-color: var(--tn-toggle-bg, rgb(162 112 217));
  border-top-right-radius: 8px;
  border-top-left-radius: 8px;
  padding: 8px;
}

/* メニューコンテナ（初期は隠す） */
#tn-menu-container {
  width: var(--tn-menu-width, 450px);
  position: fixed;
  bottom: 40px;
  right: var(--tn-container-right, 20px);
  z-index: 9999;
  background-color: var(--tn-container-bg, rgba(255, 255, 255, 0.5));
  transform: translateY(calc(100% + 8px));
  transition: transform 0.2s ease, opacity 0.2s ease;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 12px;
}

/* open クラスでスライドアップ + 表示 */
#tn-menu-container.open {
  transform: translateY(0);
  bottom: 0;
  opacity: 1;
  pointer-events: auto;
}

/* メニューベーススタイル（全パターン共通） */
#tn-menu-list.tn-list {
  width: 100%;
  position: relative;
  display: grid;
  gap: var(--tn-list-gap, 8px);
  padding-left: var(--tn-list-pad-left, 5px);
  padding-right: var(--tn-list-pad-right, 5px);
  margin: 0;
  list-style: none;
  max-height: 100vh;
  overflow-y: auto;
  box-sizing: border-box;
}

/* パターン1〜6 */
#tn-menu-list.pattern1 { grid-template-columns: repeat(1, 1fr); justify-items: center; }
#tn-menu-list.pattern2 { grid-template-columns: repeat(2, 1fr); }
#tn-menu-list.pattern3,
#tn-menu-list.pattern5,
#tn-menu-list.pattern6 { grid-template-columns: repeat(3, 1fr); }
#tn-menu-list.pattern4 { grid-template-columns: repeat(2, 1fr); }

/* 各ボタン（アイテム） */
#tn-menu-list.tn-list li.tn-menu-item {
  position: relative;
  background-size: cover;
  background-position: center;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease;
  aspect-ratio: 1 / 1;
  min-height: 0;
}

/* ホバー時の拡大効果 */
#tn-menu-list.tn-list li.tn-menu-item:hover {
  transform: scale(1.05);
}

/* アクティブ状態のスタイル */
#tn-menu-list.tn-list li.tn-menu-item.active {
  outline: 2px solid var(--tn-active-outline, #ffa500);
  box-shadow: 0 0 8px rgba(255, 165, 0, 0.7);
}

/* ボタン内リンク（画像なしは従来どおり中央1行） */
#tn-menu-list.tn-list li.tn-menu-item a {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 0;
  color: #ffffff;
  text-decoration: none;
  background: transparent;
  font-size: 14px;
  text-align: center;
  padding: 6px 4px;
  box-sizing: border-box;
  white-space: nowrap;
}

#tn-menu-list.tn-list li.tn-menu-item a .tn-button-label {
  display: block;
  min-width: 0;
  max-width: 100%;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 画像あり：ラベルは alt のみ・画像がタイル全体を覆う */
#tn-menu-list.tn-list li.tn-menu-item a:has(> img) {
  display: block;
  padding: 0;
  line-height: 0;
}

#tn-menu-list.tn-list li.tn-menu-item a:has(> img) img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

/* フォーカス時（アクセシビリティ対応） */
#tn-menu-list.tn-list li.tn-menu-item a:focus {
  outline: 2px dashed #ffffff;
  outline-offset: -4px;
}

/* アイコン用（動画・ダウンロード）※ tn-menu-item にはマッチさせない */
#tn-menu-list.tn-list li.tn-video a::before,
#tn-menu-list.tn-list li.tn-download a::before {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 16px;
  height: 16px;
  background-size: contain;
  background-repeat: no-repeat;
}

/* メニュー表示中は背景スクロールを防ぐ */
body.tn-menu-open {
  overflow: hidden;
}

/* レスポンシブ対応 */
@media (max-width: 450px) {

  .touchnavi#toggleMenu,
  #tn-menu-container {
    max-width: 100vw;
    bottom: 25px;
    right: 0;
    border-radius: 0;
  }

  #tn-menu-list.tn-list {
    gap: 4px;
  }

  #tn-menu-list.pattern1 { grid-template-columns: repeat(1, 1fr); justify-items: center; }
  #tn-menu-list.pattern2 { grid-template-columns: repeat(2, 1fr); }
  #tn-menu-list.pattern3,
  #tn-menu-list.pattern5,
  #tn-menu-list.pattern6 { grid-template-columns: repeat(3, 1fr); }
  #tn-menu-list.pattern4 { grid-template-columns: repeat(2, 1fr); }

  #tn-menu-list.tn-list li.tn-menu-item a {
    font-size: 12px;
    white-space: normal;
  }

  footer {
    margin-bottom: 40px;
  }
}
