/* ナビゲーションバー（固定位置に設定） */
nav {
  display: flex;
  align-items: center;
  justify-content: flex-start; /* 左寄せに変更 */
  background-color: rgba(255, 255, 255, 0.5); /* 半透明の白色 */
  padding: 20px clamp(10px, 2vw, 20px);
  width: 100%; /* ナビゲーションバーは全幅を使用 */
  height: 60px; /* 高さを60pxに設定 */
  position: fixed; /* 位置を固定 */
  top: 0; /* 上端から0pxの位置に設定 */
  left: 0; /* 左端から0pxの位置に設定 */
  z-index: 1000; /* 他の要素より前面に表示 */
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2); /* 軽い影を追加して、ナビゲーションバーを際立たせる */
}

.navbar-header {
  flex-grow: 0; /* ロゴのサイズが拡大しないように制御 */
  flex-shrink: 1; /* 必要に応じて縮小可能にする */
  margin-right: 20px; /* ロゴとナビゲーションアイテムの間にスペースを設ける（縮小） */
  position: relative;
  min-width: 0; /* flexアイテムが縮小できるようにする */
}

/* レスポンシブ対応：navbar-headerのマージンを調整 */
@media (max-width: 750px) {
  .navbar-header {
    margin-right: 10px !important;
  }
}

@media (min-width: 751px) and (max-width: 1199px) {
  .navbar-header {
    margin-right: 15px !important;
  }
}

@media (min-width: 1200px) and (max-width: 1399px) {
  .navbar-header {
    margin-right: 20px !important;
  }
}

@media (min-width: 1400px) {
  .navbar-header {
    margin-right: 20px !important;
  }
}

.logo-link {
  position: relative;
  display: inline-block;
  height: 50px;
  line-height: 0;
  max-width: 250px; /* デフォルトの最大幅を制限 */
  width: 173px; /* ロゴ画像の実際の幅に合わせる */
  overflow: hidden;
}

.logo {
  height: 50px;
  width: auto;
  max-width: 100%;
  padding-top: 5px;
  display: block;
  object-fit: contain;
}

/* ロゴの切り替え：デフォルトでは大きいロゴを表示、小さいロゴを非表示 */
.logo-large {
  display: block !important;
  position: absolute;
  top: 0;
  left: 0;
}

.logo-small {
  display: none !important;
  position: absolute;
  top: 0;
  left: 0;
}

/* 750px以下で小さいロゴを表示、大きいロゴを非表示 */
@media (max-width: 750px) {
  .logo-large {
    display: none !important;
  }
  
  .logo-small {
    display: block !important;
  }
  
  .logo-link {
    max-width: 120px !important;
    width: 45px !important; /* 小さいロゴの実際の幅（45px）に合わせる */
  }
}

nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  flex-grow: 0; /* 左寄せにするため、flex-growを0に変更 */
  flex-shrink: 1; /* 必要に応じて縮小可能にする */
  min-width: 0; /* flexアイテムが縮小できるようにする */
}

nav ul li {
  margin-right: clamp(2px, 1vw, 15px);
}

nav ul li a {
  color: #555;
  font-weight: bold;
  text-decoration: none;
  padding: 10px clamp(4px, 1.2vw, 15px);
  background-color: transparent;
  border-radius: 5px;
  transition: background-color 0.3s ease;
}

/* すべてのナビゲーションリンクの1行表示を強制（Xリンクは除く） */
nav ul li > a:not(.x-link) {
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

nav ul li a:hover {
  background-color: #999;
}

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: #f9f9f9;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
  z-index: 1001;
}

.dropdown-content a {
  color: #555;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  text-align: left;
}

.dropdown:hover .dropdown-content {
  display: block;
}

/* nav-extras: Xロゴ・会員リンクの常時表示コンテナ */
.nav-extras {
  display: flex;
  align-items: center;
  gap: clamp(5px, 0.8vw, 10px);
  flex-shrink: 0;
  margin-left: clamp(5px, 1vw, 15px);
}

/* ナビゲーションバーのXのロゴのスタイリング */
.x-link {
  display: inline-flex;
  align-items: center;
}

.x-link img {
  transition: opacity 0.3s ease;
}

.x-link:hover img {
  opacity: 0.8;
}

/* すべてのナビゲーションリンクのフォントサイズをレスポンシブに（Xリンクは除く） */
nav ul li > a:not(.x-link) {
  font-size: clamp(11px, 1.5vw, 16px) !important;
}

/* ドロップダウンメニューのリンクにも同じフォントサイズを適用 */
.dropdown-content a {
  font-size: clamp(11px, 1.5vw, 16px) !important;
}

/* 会員ページ/会員ログインリンクのスタイル */
a.member-link {
  padding: 8px clamp(8px, 1.2vw, 16px);
  background-color: #b7282e;
  color: white !important;
  border: none;
  border-radius: 4px;
  font-size: clamp(12px, 1.3vw, 14px);
  font-weight: normal;
  text-decoration: none;
  display: inline-block;
  white-space: nowrap;
  transition: background-color 0.3s ease;
}

a.member-link:hover {
  background-color: #c41e3a;
}

/* ========================================
   ハンバーガーメニュー
   ======================================== */

.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px;
  z-index: 1002;
  flex-shrink: 0;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background-color: #555;
  margin: 3px 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.hamburger.active span:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

.hamburger.active span:nth-child(2) {
  opacity: 0;
}

.hamburger.active span:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

/* デスクトップ: メニューは常に表示 */
@media (min-width: 769px) {
  .nav-menu {
    display: flex !important;
  }
}

/* モバイル: ハンバーガーメニュー表示 */
@media (max-width: 768px) {
  .hamburger {
    display: flex;
  }

  .nav-menu {
    display: none !important;
    position: fixed;
    top: 60px;
    left: 0;
    width: 100%;
    flex-direction: column;
    align-items: stretch !important;
    background-color: rgba(255, 255, 255, 0.98);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    padding: 0;
    margin: 0;
    z-index: 999;
  }

  .nav-menu.open {
    display: flex !important;
  }

  .nav-menu li {
    margin-right: 0 !important;
    border-bottom: 1px solid #eee;
  }

  .nav-menu li:last-child {
    border-bottom: none;
  }

  .nav-menu li a {
    display: block !important;
    padding: 14px 20px !important;
    white-space: normal !important;
  }

  .nav-menu li > a:not(.x-link) {
    font-size: 14px !important;
  }

  .nav-menu li a:hover {
    background-color: #f0f0f0;
  }

  /* モバイル: ドロップダウンをインライン展開（クリックでトグル） */
  .nav-menu .dropdown-content {
    position: static !important;
    box-shadow: none !important;
    background-color: #f5f5f5 !important;
    min-width: auto !important;
    display: none !important;
  }

  .nav-menu .dropdown.open > .dropdown-content {
    display: block !important;
  }

  .nav-menu .dropdown-content a {
    padding: 12px 20px 12px 36px !important;
    font-size: 14px !important;
    border-bottom: none;
    color: #555;
  }

  /* Xロゴ縮小 */
  .x-link img {
    transform: scale(0.8) !important;
    transform-origin: center center !important;
  }

  /* nav-extrasを右端へ */
  .nav-extras {
    margin-left: auto;
  }
}
