/**
 * Hermès完全準拠ヘッダー
 * DOM構造とクラス名をHermès公式サイトから完全コピー
 */

/* ============================================
   CSS変数
   ============================================ */
:root {
  --header-height-mobile: 60px;
  --header-height-desktop: 72px;
  --header-height-desktop-with-menu: 114px;
}

/* ============================================
   ヘッダーメインコンテナ
   ============================================ */
.header-main-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background-color: #fcf7f1ba; /* 元の半透明背景 */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* スクロール時: ヘッダーを隠す（モバイル・タブレットのみ） */
@media (max-width: 1023px) {
  .header-main-container.hide-header-bar {
    transform: translateY(calc(-1 * var(--header-height-mobile)));
  }
}

/* スクロール時: ヘッダーバー（上段）を隠す、メニューバーは残す（デスクトップ） */
@media (min-width: 1024px) {
  /* スクロール時のヘッダー全体の高さ調整（Hermès実装） */
  .header-main-container.scrolled {
    /* メニューバーの高さ（42px）のみになる */
  }

  /* 上段（検索・ロゴ・アイコン）を隠す */
  .header-main-container.scrolled .header-bar {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    padding: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
  }

  /* メニューバー（下段）は残る（Hermès実装） */
  .header-main-container.scrolled .header-menu-bar {
    /* 変更なし、常に表示 */
  }
}

/* トランジション無効化 */
.header-main-container.no-transition {
  transition: none;
}

/* ============================================
   ヘッダーメイン
   ============================================ */
.header-main {
  max-width: 1920px;
  margin: 0 auto;
}

@media (min-width: 1306px) {
  .header-main {
    max-width: 1258px;
  }
}

/* ============================================
   ヘッダーバー（検索・ロゴ・アイコン）
   ============================================ */
.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--header-height-mobile);
  padding: 0 15px;
  position: relative; /* ロゴの絶対配置のため */
}

@media (min-width: 768px) {
  .header-bar {
    height: var(--header-height-desktop);
    padding: 7px 24px;
  }
}

/* 検索ボタンを左端に配置（Hermès実装） */
.header-bar > .search-btn {
  margin-right: auto; /* ロゴとの間にスペース */
}

/* アイコングループを右端に配置（Hermès実装） */
.header-bar > .header-bar-icons {
  margin-left: auto; /* ロゴとの間にスペース */
}

/* ============================================
   ロゴ（透過型）
   ============================================ */
.h-logo {
  position: absolute;
  left: 50%;
  transform: translateX(-50%); /* 中央配置 */
  display: flex;
  align-items: center;
}

.h-logo img {
  width: 100px;
  height: 34px;
  transition: opacity 0.2s ease;
}

@media (min-width: 768px) {
  .h-logo img {
    width: 140px;
    height: 48px;
  }
}

.h-logo:hover img {
  opacity: 0.7;
}

/* ============================================
   ヘッダーバーアイコン
   ============================================ */
.header-bar-icons {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-left: auto; /* 右端に配置 */
}

.button-icon {
  width: auto; /* テキスト分の幅を確保 */
  height: 18px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  position: relative;
  color: #444444;
  transition: opacity 0.2s ease;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px; /* アイコンとテキストの間隔 */
}

.button-icon:hover {
  opacity: 0.7;
}

.button-icon svg {
  width: 18px; /* アイコンサイズを小さく */
  height: 18px;
  flex-shrink: 0; /* アイコンサイズ固定 */
}

/* ============================================
   検索コンテナ（Hermès準拠 - インライン展開）
   ============================================ */
.search-container {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  height: 18px; /* アイコンサイズ（18px）に統一 */
}

/* 検索ボタン（テキスト付き） */
.search-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600; /* 太文字 */
  letter-spacing: 0.05em;
  font-family: 'Helvetica Neue', Arial, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  transition: opacity 0.2s ease;
  height: 18px; /* アイコンサイズ（18px）に統一 */
  line-height: 1;
}

.search-btn span {
  display: inline-block;
  white-space: nowrap;
  position: relative;
  padding-bottom: 2px;
}

.search-btn span::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background-color: #444444;
}

/* 検索ボタンを非表示（検索展開時） */
.search-container.active .search-btn {
  opacity: 0;
  pointer-events: none;
}

/* 検索入力ラッパー（Hermès実装） */
.search-input-wrapper {
  position: relative;
  width: 0;
  opacity: 0;
  overflow: hidden;
  transition: width 0.2s ease-out, opacity 0.2s ease-out;
  display: flex;
  align-items: center;
}

.search-container.active .search-input-wrapper {
  width: 266px; /* Hermès準拠 */
  opacity: 1;
}

/* 検索入力フィールド */
.search-input-inline {
  width: 100%;
  padding: 0 30px 2px 0; /* 下線用の余白 */
  border: none;
  border-bottom: 1px solid #000;
  background-color: transparent;
  font-size: 13px;
  font-family: 'Helvetica Neue', Arial, 'Hiragino Sans', sans-serif;
  outline: none;
  height: 18px; /* アイコンサイズ（18px）に統一 */
  line-height: 18px;
}

.search-input-inline::placeholder {
  color: #999999;
}

/* 検索クローズアイコン */
.search-close-icon {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: none;
  background: none;
  font-size: 20px;
  color: #444444;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
}

.search-close-icon:hover {
  opacity: 0.7;
}

/* アイコンラベル（アカウント・カート） */
.icon-label {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
  font-family: 'Helvetica Neue', Arial, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
  white-space: nowrap;
}

/* カート数量バッジ */
.cart-count {
  position: absolute;
  top: -8px;
  right: -18px;
  background-color: #fd780f;
  color: #ffffff;
  font-size: 10px;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0 4px;
}

/* ============================================
   ヘッダーメニューバー（デスクトップのみ）
   ============================================ */
.header-menu-bar {
  display: none;
  max-height: 42px; /* デフォルト表示 */
  opacity: 1;
  transition: max-height 0.3s ease, opacity 0.3s ease; /* Hermès: スムーズな表示/非表示 */
}

@media (min-width: 1024px) {
  .header-menu-bar {
    display: block;
  }
}

.header-links-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 48px;
  height: 42px;
  padding: 0 24px;
  width: 100%; /* 幅100%でセンタリング確実に */
  margin: 0 auto; /* 中央配置 */
}

.header-link {
  position: relative;
  font-size: 13px;
  font-weight: 600; /* より太く（Hermès準拠） */
  letter-spacing: 0.05em;
  color: #444444;
  text-decoration: none;
  transition: color 0.2s ease;
  font-family: 'Helvetica Neue', Arial, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
}

.header-link:hover {
  color: #222222;
}

/* ホバー時のアンダーライン */
.header-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background-color: #222222;
  transition: width 0.3s ease;
}

.header-link:hover::after {
  width: 100%;
}

/* ============================================
   モバイルメニュートレイ
   ============================================ */
.tray-wrapper {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  max-width: 400px;
  height: 100vh;
  background-color: #ffffff;
  z-index: 2000;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.1);
}

.tray-wrapper.active {
  transform: translateX(0);
}

.tray-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid rgba(226, 216, 206, 0.3);
  background-color: #fcf7f1;
}

.tray-title {
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.05em;
}

.tray-close-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  font-size: 24px;
  cursor: pointer;
  color: #666666;
  transition: color 0.2s ease;
}

.tray-close-btn:hover {
  color: #222222;
}

.tray-menu {
  padding: 16px;
}

.tray-menu-item {
  display: block;
  padding: 16px 0;
  font-size: 15px;
  font-weight: 400;
  letter-spacing: 0.05em;
  color: #444444;
  border-bottom: 1px solid rgba(226, 216, 206, 0.3);
  transition: color 0.2s ease, padding-left 0.2s ease;
  text-decoration: none;
}

.tray-menu-item:hover {
  color: #222222;
  padding-left: 8px;
}

.tray-menu-item:last-child {
  border-bottom: none;
}

.tray-menu-item-small {
  font-size: 14px;
  color: #666666;
}

.tray-menu-divider {
  height: 1px;
  background-color: rgba(226, 216, 206, 0.5);
  margin: 16px 0;
}

/* ============================================
   オーバーレイ
   ============================================ */
.menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 1999;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.menu-overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ============================================
   スキップリンク
   ============================================ */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 3000;
  padding: 16px;
  background-color: #222222;
  color: #ffffff;
  font-size: 14px;
  text-decoration: none;
}

.skip-link:focus {
  left: 0;
}

/* ============================================
   モバイル/デスクトップ表示切替
   ============================================ */
.mobile-only {
  display: block;
}

@media (min-width: 1024px) {
  .mobile-only {
    display: none;
  }
}

.desktop-only {
  display: none;
}

@media (min-width: 1024px) {
  .desktop-only {
    display: block;
  }
}

/* ============================================
   レスポンシブ調整
   ============================================ */
@media (max-width: 1023px) {
  .header-bar-icons {
    gap: 16px;
  }

  .button-icon {
    width: 20px; /* タブレット・モバイルはアイコンのみなので固定幅 */
    height: 20px;
  }

  /* タブレット・モバイル版ではテキストラベルを非表示 */
  .button-icon .icon-label {
    display: none;
  }
}
