/* SPメニュー改定専用CSS - 既存CSSと完全分離 */

/* SP時のみ既存メニューを無効化 */
@media only screen and (max-width: 768px) {
  #menu-header_menu {
    display: none !important;
  }

  .menu_bk {
    display: none !important;
  }
}

/* PC時は既存メニューを表示（既存CSSを尊重） */
@media only screen and (min-width: 769px) {
  #menu-header_menu {
    display: flex !important; /* block → flex に変更 */
  }

  .menu_bk {
    display: none !important; /* PC時は非表示 */
  }

  /* PC時は既存のSPメニュー要素を完全無効化 */
  #toggle,
  #sp_close,
  .sp_nav,
  .menu_bk {
    display: none !important;
  }
}

/* メニュー開時のbodyスクロール無効化（スクロール位置保持版） */
body.menu-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  top: 0;
  left: 0;
}

/* 基本設定 */
.sp-menu-redesign {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: #fff;
  z-index: 9999;
  display: block !important; /* 常に存在 */
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-100%); /* 左側に隠す */
  transition: opacity 0.4s ease, visibility 0.4s ease, transform 0.4s ease;
}

/* 表示時の状態 */
.sp-menu-redesign.active {
  opacity: 1;
  visibility: visible;
  transform: translateX(0); /* 左からスライドイン */
}

/* ヘッダー部分 */
.sp-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid #eee;
  background: #f8f8f8;
}

.sp-menu-logo img {
  max-height: 40px;
  width: auto;
}

.sp-menu-close {
  background: linear-gradient(135deg, #4a4a4a 0%, #2c2c2c 100%);
  border: none;
  font-size: 20px;
  color: #fff;
  cursor: pointer;
  width: 45px;
  height: 45px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(74, 74, 74, 0.3);
  position: relative;
  overflow: hidden;
}

.sp-menu-close::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #5a5a5a 0%, #3a3a3a 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: 8px;
}

.sp-menu-close:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(74, 74, 74, 0.4);
}

.sp-menu-close:hover::before {
  opacity: 1;
}

.sp-menu-close:active {
  transform: scale(0.95);
}

/* カスタム×マーク */
.close-icon {
  position: relative;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-line {
  position: absolute;
  width: 18px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
  transition: all 0.3s ease;
}

.close-line-1 {
  transform: rotate(45deg);
}

.close-line-2 {
  transform: rotate(-45deg);
}

.sp-menu-close:hover .close-line {
  background: #fff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
}

.sp-menu-close:active .close-line-1 {
  transform: rotate(45deg) scale(0.9);
}

.sp-menu-close:active .close-line-2 {
  transform: rotate(-45deg) scale(0.9);
}

/* メニューコンテンツ */
.sp-menu-content {
  padding: 0;
}

.sp-menu-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* メインメニュー項目 */
.sp-menu-item {
  border-bottom: 1px solid #eee;
}

.sp-menu-link {
  display: flex;
  align-items: center;
  padding: 15px 20px;
  text-decoration: none;
  color: #333;
  font-size: 16px;
  transition: background-color 0.2s;
}

.sp-menu-link:hover {
  background-color: #f5f5f5;
}

.sp-menu-icon {
  margin-right: 12px;
  font-size: 18px;
  width: 20px;
  text-align: center;
}

.sp-menu-text {
  flex: 1;
  font-weight: 500;
}

.sp-menu-arrow {
  font-size: 12px;
  color: #666;
  transition: transform 0.2s;
}

.sp-menu-has-submenu .sp-menu-arrow {
  transform: rotate(0deg);
}

.sp-menu-has-submenu.active .sp-menu-arrow {
  transform: rotate(180deg);
}

/* サブメニュー */
.sp-submenu {
  list-style: none;
  margin: 0;
  padding: 0;
  background: #f8f8f8;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.3s ease;
}

.sp-submenu.active {
  max-height: 1000px; /* 十分な高さを確保 */
  opacity: 1;
}

.sp-submenu-item {
  border-bottom: 1px solid #e0e0e0;
}

.sp-submenu-link {
  display: flex;
  align-items: center;
  padding: 12px 20px 12px 40px;
  text-decoration: none;
  color: #555;
  font-size: 14px;
  transition: background-color 0.2s;
  position: relative;
  background-color: #4a4a4a; /* 参考元サイトと同じグレー */
  color: #fff; /* 白い文字 */
  font-weight: 500;
}

.sp-submenu-link:hover {
  background-color: #5a5a5a; /* ホバー時は少し明るいグレー */
}

.sp-submenu-link::before {
  content: "▶";
  position: absolute;
  left: 20px;
  color: #fff; /* 白い矢印 */
  font-size: 10px;
}

/* サブメニューの矢印 */
.sp-submenu-toggle::after {
  content: "▼";
  margin-left: auto;
  font-size: 10px;
  color: #fff;
  transition: transform 0.2s;
}

.sp-submenu-has-submenu.active .sp-submenu-toggle::after {
  transform: rotate(180deg);
}

/* レベル2サブメニュー */
.sp-submenu-level2 {
  list-style: none;
  margin: 0;
  padding: 0;
  background: #f0f0f0;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.3s ease;
}

.sp-submenu-level2.active {
  max-height: 1000px; /* 十分な高さを確保 */
  opacity: 1;
}

.sp-submenu-level2 li {
  border-bottom: 1px solid #ddd;
}

.sp-submenu-level2 a {
  display: block;
  padding: 10px 20px 10px 60px;
  text-decoration: none;
  color: #666;
  font-size: 13px;
  transition: background-color 0.2s;
  position: relative;
  background-color: #fff; /* 白い背景を明示的に指定 */
}

.sp-submenu-level2 a:hover {
  background-color: #f5f5f5; /* ホバー時は薄いグレー */
}

.sp-submenu-level2 a::before {
  content: "•";
  position: absolute;
  left: 40px;
  color: #baa180;
  font-size: 12px;
}

/* レスポンシブ対応 */
@media only screen and (max-width: 768px) {
  .sp-menu-redesign {
    /* display制御を削除してtransformアニメーションを有効化 */
    transform: translateX(-100%);
    opacity: 0;
    visibility: hidden;
  }

  .sp-menu-redesign.active {
    /* display制御を削除してtransformアニメーションを有効化 */
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
  }
}

@media only screen and (min-width: 769px) {
  .sp-menu-redesign {
    display: none !important;
  }

  .sp-menu-redesign.active {
    display: none !important; /* PCでは常に非表示 */
  }
}

/* 余白最適化 */
.sp-menu-link {
  padding: 12px 20px; /* 余白削減 */
}

.sp-submenu-link {
  padding: 10px 20px 10px 40px; /* 余白削減 */
}

.sp-submenu-level2 a {
  padding: 8px 20px 8px 60px; /* 余白削減 */
}

/* フォントサイズ最適化 */
.sp-menu-text {
  font-size: 15px; /* 少し小さく */
}

.sp-submenu-link {
  font-size: 13px; /* 少し小さく */
}

.sp-submenu-level2 a {
  font-size: 12px; /* 少し小さく */
}
