/* ========================================
   ヘッダー・ナビゲーション・メニュー CSS
   ======================================== */

/* --- CSS変数の定義 --- */
:root {
  --elementor-tab-z-index: 1001;
  --modal-menu-z-index: 9999;
  --header-z-index: 1000;
  --primary-color: #667eea;
  --secondary-color: #764ba2;
  --text-color: #333;
  --border-color: rgba(0, 0, 0, 0.08);
  --shadow-light: 0 2px 10px rgba(0, 0, 0, 0.05);
  --shadow-medium: 0 4px 20px rgba(0, 0, 0, 0.08);
  --shadow-strong: 0 10px 40px rgba(0, 0, 0, 0.15);
  --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --transition-smooth: all 0.3s ease;
  --transition-bounce: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font-family: 'Noto Sans JP', sans-serif;
}

/* --- 基本スタイル --- */
html {
  overflow-y: scroll;
}

/* メニュー表示時に背景をスクロールさせない */
body.menu-open {
  overflow: hidden;
}

/* --- Elementorタブの保護 --- */
.elementor-tabs {
  position: relative;
  z-index: var(--elementor-tab-z-index) !important;
}

.elementor-tabs .elementor-tab-title {
  cursor: pointer !important;
  pointer-events: auto !important;
  position: relative !important;
  z-index: 10 !important;
}

.elementor-tabs .elementor-tab-content {
  display: none;
}

.elementor-tabs .elementor-tab-content.elementor-active {
  display: block !important;
}

.elementor-tabs .elementor-tab-title.elementor-active {
  background-color: #007cba !important;
  color: #ffffff !important;
}

.elementor-tabs .elementor-tab-title:hover,
.elementor-tabs .elementor-tab-title:focus {
  text-decoration: none !important;
  transform: none !important;
}

/* --- トップバナー --- */
.top-banner {
  background: var(--gradient-primary);
  color: white;
  padding: 12px 0;
  text-align: center;
  margin-bottom: 0;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
  position: relative;
  overflow: hidden;
}

.top-banner::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  animation: shimmer 3s infinite;
}

@keyframes shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

.banner-text {
  margin: 0;
  font-weight: 600;
  letter-spacing: 1px;
  font-size: 14px;
  font-family: var(--font-family);
}

/* --- ヘッダー --- */
#header {
  padding: 15px 0;
  background-color: #fff;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: var(--header-z-index);
  box-shadow: 0 2px 20px var(--border-color);
  backdrop-filter: blur(10px);
}

#header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

#logo {
  margin: 0;
  line-height: 1;
}

#logo a {
  display: inline-block;
  text-decoration: none;
  color: var(--text-color);
  font-weight: 700;
  font-size: 24px;
  transition: var(--transition-smooth);
  font-family: var(--font-family);
}

#logo a:hover {
  opacity: 0.8;
  transform: translateY(-1px);
}

#logo img {
  max-height: 50px;
  width: auto;
  vertical-align: middle;
}

/* --- ハンバーガーメニューボタン --- */
#header-menu-tog {
  display: none;
}

#header-menu-tog a {
  color: var(--text-color);
  text-decoration: none;
  font-size: 20px;
  padding: 8px;
  border-radius: 8px;
  transition: var(--transition-smooth);
  display: flex;
  align-items: center;
  justify-content: center;
}

#header-menu-tog a:hover {
  background-color: rgba(102, 126, 234, 0.1);
  color: var(--primary-color);
  transform: scale(1.1);
}

/* --- 検索ボックス --- */
.header-search-box {
  margin-left: auto;
  margin-right: 15px;
}

.search-input-container {
  position: relative;
  display: flex;
  align-items: center;
}

#header-search-input {
  width: 220px;
  height: 40px;
  padding: 10px 40px 10px 15px;
  border: 2px solid rgba(102, 126, 234, 0.2);
  border-radius: 20px;
  font-size: 15px;
  background-color: rgba(255, 255, 255, 0.9);
  transition: var(--transition-smooth);
  box-shadow: 0 2px 10px rgba(102, 126, 234, 0.1);
  font-family: var(--font-family);
}

#header-search-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
  outline: none;
  background-color: #fff;
  width: 260px;
}

.search-submit {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--gradient-primary);
  border: none;
  color: white;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: var(--transition-smooth);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-submit:hover {
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
}

/* --- PC用ナビゲーション --- */
#gnav {
  background-color: #fff;
  box-shadow: var(--shadow-light);
}

#gnav .wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

#gnav-container {
  width: 100%;
}

#gnav-ul {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
}

#gnav-ul > li {
  position: relative;
}

#gnav-ul > li > a {
  display: block;
  padding: 15px 20px;
  color: var(--text-color);
  text-decoration: none;
  font-weight: 500;
  font-size: 15px;
  transition: var(--transition-smooth);
  position: relative;
  font-family: var(--font-family);
}

#gnav-ul > li > a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 3px;
  background: var(--gradient-primary);
  transition: var(--transition-smooth);
  transform: translateX(-50%);
  border-radius: 2px;
}

#gnav-ul > li > a:hover::after {
  width: 100%;
}

#gnav-ul > li > a:hover {
  color: var(--primary-color);
}

/* --- サブメニュー --- */
#gnav-ul .sub-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background-color: white;
  list-style: none;
  margin: 0;
  padding: 15px 0;
  min-width: 220px;
  z-index: 100;
  visibility: hidden;
  opacity: 0;
  transform: translateY(15px);
  transition: var(--transition-bounce);
  box-shadow: var(--shadow-strong);
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

#gnav-ul > li:hover > .sub-menu {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}

#gnav-ul .sub-menu li a {
  display: block;
  padding: 12px 25px;
  color: #555;
  text-decoration: none;
  font-size: 14px;
  transition: var(--transition-smooth);
  font-family: var(--font-family);
}

#gnav-ul .sub-menu li a:hover {
  background-color: rgba(102, 126, 234, 0.08);
  color: var(--primary-color);
  padding-left: 30px;
}

/* ========================================
   モバイル・タブレット対応
   ======================================== */

@media screen and (max-width: 1024px) {
  /* Elementorタブの優先度調整 */
  .elementor-tabs {
    z-index: 1002 !important;
  }

  .elementor-tabs .elementor-tab-title {
    touch-action: manipulation;
  }

  /* ヘッダー調整 */
  #header .wrap {
    padding: 10px 15px;
    min-height: 60px;
  }

  #logo a {
    font-size: 20px;
  }

  #logo img {
    max-height: 40px;
  }

  /* PC用ナビゲーションを非表示 */
  #gnav {
    display: none;
  }

  /* ハンバーガーメニューボタンを表示 */
  #header-menu-tog {
    display: block;
    margin-top: 10px;
  }

  /* --- モーダルメニュー --- */
  
  /* モーダルコンテナ (オーバーレイ) */
  #modal-menu-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.9) 0%, rgba(118, 75, 162, 0.9) 100%);
    z-index: var(--modal-menu-z-index);
    visibility: hidden;
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }

  /* メニューが開いている時 */
  body.menu-open #modal-menu-container {
    visibility: visible;
    opacity: 1;
  }

  /* メニュー本体 */
  #modal-menu {
    position: fixed;
    top: 0;
    right: 0;
    width: 85%;
    max-width: 360px;
    height: 100%;
    background: #ffffff;
    box-shadow: -10px 0 50px rgba(0, 0, 0, 0.3);
    z-index: calc(var(--modal-menu-z-index) + 1);
    transform: translateX(100%);
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    border-radius: 20px 0 0 20px;
    overflow: hidden;
  }

  /* メニューが開いている時 */
  body.menu-open #modal-menu {
    transform: translateX(0);
  }

  /* メニューヘッダー */
  .modal-menu-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 12px 20px 8px;
    background: #ffffff;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    min-height: 50px;
  }

  .modal-menu-title {
    display: none;
  }

  /* 閉じるボタン */
  #modal-close {
    background: rgba(102, 126, 234, 0.1);
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--primary-color);
    padding: 8px;
    line-height: 1;
    border-radius: 50%;
    transition: var(--transition-bounce);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #modal-close:hover {
    background: rgba(102, 126, 234, 0.2);
    transform: rotate(90deg) scale(1.1);
  }

  #modal-close:active {
    transform: rotate(90deg) scale(0.95);
  }

  /* メニューリストコンテナ */
  .modal-gnav-container {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex-grow: 1;
    padding: 8px 0 40px;
  }

  .modal-menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
  }

  /* メニューアイテム */
  .modal-menu-list li {
    margin: 0 15px 8px;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(102, 126, 234, 0.05);
    border: 1px solid rgba(102, 126, 234, 0.1);
    transition: var(--transition-smooth);
  }

  .modal-menu-list li:hover {
    transform: translateX(3px);
    box-shadow: 0 3px 15px rgba(102, 126, 234, 0.15);
    background: rgba(102, 126, 234, 0.08);
  }

  /* メニューリンク */
  .modal-menu-list li a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: var(--transition-smooth);
    font-family: var(--font-family);
    position: relative;
    overflow: hidden;
    min-height: 42px;
  }

  .modal-menu-list li a::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.1), transparent);
    transition: left 0.5s ease;
  }

  .modal-menu-list li:hover a::before {
    left: 100%;
  }

  .modal-menu-list li a:hover {
    color: var(--primary-color);
  }

  /* アコーディオン機能 */
  .modal-menu-list .sub-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    background: rgba(102, 126, 234, 0.03);
    max-height: 0;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    border-top: 1px solid rgba(102, 126, 234, 0.1);
  }

  .modal-menu-list .menu-item-has-children.open > .sub-menu {
    max-height: 400px;
    padding: 6px 0;
  }

  /* サブメニューアイテム */
  .modal-menu-list .sub-menu li {
    margin: 3px 10px;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(102, 126, 234, 0.08);
  }

  .modal-menu-list .sub-menu li a {
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 400;
    color: #555;
    min-height: 36px;
  }

  .modal-menu-list .sub-menu li:hover {
    transform: translateX(2px);
  }

  /* サブメニュートグルボタン */
  .submenu-toggle {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 28px;
    height: 28px;
    margin-right: -4px;
    color: var(--primary-color);
    flex-shrink: 0;
    position: relative;
    z-index: 2;
    border-radius: 50%;
    background: rgba(102, 126, 234, 0.1);
    transition: var(--transition-smooth);
  }

  .submenu-toggle:hover {
    background: rgba(102, 126, 234, 0.2);
    transform: scale(1.1);
  }

  .submenu-toggle i {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 10px;
  }

  .menu-item-has-children.open .submenu-toggle {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
  }

  .menu-item-has-children.open .submenu-toggle i {
    transform: rotate(180deg);
  }

  .modal-menu-list .menu-item-has-children > a {
    padding-right: 8px;
  }

  /* スクロールバーのカスタマイズ */
  .modal-gnav-container::-webkit-scrollbar {
    width: 3px;
  }

  .modal-gnav-container::-webkit-scrollbar-track {
    background: rgba(102, 126, 234, 0.1);
    border-radius: 2px;
  }

  .modal-gnav-container::-webkit-scrollbar-thumb {
    background: var(--gradient-primary);
    border-radius: 2px;
  }

  .modal-gnav-container::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5a6fd8, #6a4190);
  }
}

/* ========================================
   レスポンシブ調整
   ======================================== */

/* タブレット用検索ボックス調整 */
@media screen and (min-width: 768px) and (max-width: 1024px) {
  .header-search-box {
    margin-right: 10px;
    margin-left: -35px;
  }

  #header-search-input {
    width: 180px;
    font-size: 15px;
  }

  #header-search-input:focus {
    width: 200px;
  }

  /* 関連商品レイアウト調整 */
  .gift-item-sidebar {
    display: none !important;
  }

  .gift-item-related-mobile {
    display: block;
    margin-top: 40px;
    padding: 20px;
    background-color: #fff;
    border-radius: 15px;
    box-shadow: var(--shadow-medium);
  }

  .gift-item-main {
    width: 100%;
  }

  .gift-item-container {
    flex-direction: column;
  }

  .gift-item-related-mobile .related-gift-items {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
  }
}

/* スマートフォン用調整 */
@media screen and (max-width: 767px) {
  .header-search-box {
    margin-right: 0px;
    margin-left: -35px;
  }

  #header-search-input {
    width: 160px;
    height: 36px;
    font-size: 16px;
    border-radius: 18px;
  }

  #header-search-input:focus {
    width: 180px;
  }

  .search-submit {
    width: 28px;
    height: 28px;
    right: 6px;
  }
}

/* 小さい画面でのモーダルメニュー調整 */
@media screen and (max-width: 480px) {
  #modal-menu {
    width: 90%;
    max-width: 320px;
  }

  .modal-menu-list li {
    margin: 0 12px 6px;
  }

  .modal-menu-list li a {
    padding: 10px 14px;
    font-size: 14px;
    min-height: 38px;
  }

  .modal-menu-header {
    padding: 10px 16px 6px;
    min-height: 45px;
  }

  .modal-gnav-container {
    padding: 6px 0 35px;
  }
}

/* PC用でモーダルメニューを非表示 */
@media screen and (min-width: 1025px) {
  #modal-menu-container {
    display: none;
  }
}