/**
 * モバイル・ボトムナビ（公式 / 通販）と関連モーダル
 */

#tbt-back-btn {
  display: none;
}

/* ボトムナビ関連要素はデフォルト非表示（デスクトップでフッターに露出しないよう） */
#tbt-bottom-nav,
#tbt-slide-menu,
#tbt-slide-menu-overlay,
#tbt-delivery-select-modal,
#tbt-tel-confirm-modal,
#tbt-mobile-footer-nav,
#tbt-mobile-nav-overlay {
  display: none;
}

@media (min-width: 769px) {
  #tbt-bottom-nav,
  #tbt-slide-menu,
  #tbt-slide-menu-overlay,
  #tbt-delivery-select-modal,
  #tbt-tel-confirm-modal,
  #tbt-mobile-footer-nav,
  #tbt-mobile-nav-overlay {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
}

@media (max-width: 768px) {
  #tbt-bottom-nav {
    display: flex;
  }

  #tbt-slide-menu {
    display: block;
    position: fixed;
    bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    left: 0;
    right: 0;
    background: rgba(62, 28, 28, 0.97);
    z-index: 9999;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    border-radius: 16px 16px 0 0;
    overflow-y: auto;
    max-height: 60vh;
  }

  #tbt-slide-menu.is-open {
    transform: translateY(0);
  }

  #tbt-slide-menu-overlay.is-open {
    display: block;
  }

  #tbt-delivery-select-modal.is-active {
    display: flex;
  }

  #tbt-tel-confirm-modal.is-active {
    display: flex;
  }

  #tbt-back-btn {
    display: block;
    position: fixed;
    bottom: calc(56px + env(safe-area-inset-bottom, 0px) + 8px);
    left: 12px;
    z-index: 9997;
    background: rgba(62, 28, 28, 0.85);
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 12px;
    line-height: 1.4;
    cursor: pointer;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  }

  #tbt-back-btn:active {
    opacity: 0.7;
  }
}

@media (max-width: 781px) {
  /* ボトムナビ全体：テーマ赤（臙脂 #7f2629）に統一 */
  .tbt-bottom-nav {
    background: rgba(127, 38, 41, 0.95) !important;
  }

  /* 通販ボトムナビ：バー背景をテーマ赤（公式と同色）に統一 */
  body.tbt-context-shop .tbt-bottom-nav.tbt-bottom-nav--shop {
    background: rgba(127, 38, 41, 0.95) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
  }

  /* メニューボタン：公式側と同じ透明＋アクティブ時ハイライト */
  .tbt-bottom-nav--official .tbt-bottom-nav__toggle,
  .tbt-bottom-nav--shop .tbt-bottom-nav__toggle,
  #nav-menu-btn {
    background: none !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
  }

  .tbt-bottom-nav--official .tbt-bottom-nav__toggle:active,
  .tbt-bottom-nav--official .tbt-bottom-nav__toggle.is-active,
  .tbt-bottom-nav--shop .tbt-bottom-nav__toggle:active,
  .tbt-bottom-nav--shop .tbt-bottom-nav__toggle.is-active,
  #nav-menu-btn:active,
  #nav-menu-btn.is-active {
    background: rgba(255, 255, 255, 0.12) !important;
    background-color: rgba(255, 255, 255, 0.12) !important;
  }

  .tbt-bottom-nav--shop .tbt-bottom-nav__category,
  .tbt-bottom-nav--shop .tbt-bottom-nav__delivery,
  .tbt-bottom-nav--shop .tbt-bottom-nav__btn {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    box-shadow: none !important;
    -webkit-appearance: none !important;
    appearance: none !important;
  }

  /* 受取方法モーダル：キャンセルはテキストボタン */
  .tbt-delivery-select-modal__cancel {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    color: #666 !important;
    text-decoration: underline;
  }

  .tbt-delivery-select-modal__btn.active,
  .tbt-delivery-select-modal__btn.is-selected {
    background: rgba(62, 28, 28, 0.08);
    border-color: rgba(62, 28, 28, 0.5);
  }

  /* 電話確認モーダル */
  .tbt-tel-confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 10003;
    align-items: center;
    justify-content: center;
  }

  .tbt-tel-confirm-modal.is-active {
    display: flex;
  }

  .tbt-tel-confirm-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
  }

  .tbt-tel-confirm-modal__content {
    position: relative;
    background: #faf9f7;
    border-radius: 16px;
    padding: 28px 24px;
    width: min(90vw, 340px);
    z-index: 1;
    text-align: center;
  }

  .tbt-tel-confirm-modal__text {
    font-size: 0.82rem;
    line-height: 1.6;
    color: #3e1c1c;
    margin: 0 0 20px;
    letter-spacing: 0.03em;
    text-align: left;
  }

  .tbt-tel-confirm-modal__text small {
    display: block;
    margin-top: 12px;
    font-size: 0.8rem;
    color: rgba(62, 28, 28, 0.75);
    line-height: 1.55;
  }

  .tbt-tel-confirm-modal__text a {
    color: var(--tbt-enzhi, #7f2629);
    text-decoration: underline;
  }

  .tbt-tel-confirm-modal__buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .tbt-tel-confirm-modal__call-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 14px 20px;
    border-radius: 8px;
    border: none;
    background: var(--tbt-enzhi, #7f2629);
    color: #fff;
    font-size: 1rem;
    font-weight: bold;
    letter-spacing: 0.05em;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s;
  }

  .tbt-tel-confirm-modal__call-btn:active {
    background: #962f33;
  }

  .tbt-tel-confirm-modal__cancel-btn {
    background: transparent !important;
    background-color: transparent !important;
    border: none !important;
    color: #666 !important;
    font-size: 0.9rem;
    padding: 8px 16px;
    cursor: pointer;
    text-decoration: underline;
  }

  /* スライドメニュー内のみアカウント・カートのテキスト表示 */
  #tbt-slide-menu .tbt-menu-icon-label {
    display: inline;
  }

  /* ヘッダー内ではテキストラベルを非表示（アイコンのみ） */
  .site-header .tbt-menu-icon-label,
  #masthead .tbt-menu-icon-label {
    display: none !important;
  }

  /* 受取方法モーダル：選択フィードバック */
  .tbt-delivery-select-modal__btn.active::after {
    content: '✓ 選択中';
    margin-left: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--tbt-enzhi, #7f2629);
  }
}
