/*============================================================
  ショップ（商品一覧）セクション表示用
  編集・プレビュー・公開で共通のデザイン
  - タイトル: 横中央寄せ、weight 700、size 32px
  - カード（2件以上）: 横230px・縦370px、radius 4px
  - カード（公開商品がちょうど1件）: 横640px・縦160px、radius 4px・画像左160×160
  - 画像: 縦横230px（複数件時） / 160×160（1件時）
  - 商品名: weight 700、size 16px
  - 価格: weight 400、size 16px
  - カート追加ボタン: #0AC4DD、86px×32px、左寄せ
  - 商品同士の間隔: gap 32px
*============================================================*/

/* セクション両端の余白はグリッドを中央寄せで確保。商品同士は32px */
.maqe-shop .shop-products-inner {
  padding: 16px 24px;
  max-width: 1016px;
  margin-left: auto;
  margin-right: auto;
}

.maqe-shop .shop-products-title {
  text-align: center;
  font-weight: 700;
  font-size: 32px;
  margin: 0 0 40px;
  padding: 0 8px;
  color: #000;
}

/* 4列×230px + 間隔32px×3 = 1016px（プレビュー・公開ではメディアクエリでレスポンシブ） */
.maqe-shop .shop-products-grid {
  display: grid;
  gap: 32px !important;
  grid-template-columns: repeat(4, 230px);
  justify-content: center;
  width: 1016px;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

/* 公開商品が1件のときのみ付与されるグリッド：Figma 640幅・横長カード1枚 */
.maqe-shop .shop-products-grid--single {
  /* 1列レイアウト */
  grid-template-columns: 1fr;
  /* カードを行の中央に置く */
  justify-items: center;
  /* デザイン指定のグリッド幅 */
  width: 640px;
  /* 狭い画面では親要素内に収める */
  max-width: 100%;
  /* 水平方向センタリング */
  margin-left: auto;
  /* 水平方向センタリング */
  margin-right: auto;
  /* 1枚のみのためカード間 gap は不要 */
  gap: 0;
  /* 幅計算にパディングを含める */
  box-sizing: border-box;
}

/* 1件時の商品カード本体：640×160・横並び・角丸4px */
.maqe-shop .shop-products-grid--single .shop-product-card {
  /* 指定横幅 */
  width: 640px;
  /* ビューポートが狭いときは縮小 */
  max-width: 100%;
  /* 指定高さ */
  height: 160px;
  /* 画像左・テキスト右 */
  flex-direction: row;
  /* Figma の角丸値 */
  border-radius: 4px;
  /* 幅計算の一貫性 */
  box-sizing: border-box;
}

/* 1件時のサムネイル枠：左160×160固定 */
.maqe-shop .shop-products-grid--single .shop-product-card-img-wrap {
  /* 左カラム幅 */
  width: 160px;
  /* カード高に合わせる */
  height: 160px;
  /* 横並びで潰さない */
  flex-shrink: 0;
}

/* 1件時のテキストエリア：右側で縦に積みボタンを下へ */
.maqe-shop .shop-products-grid--single .shop-product-card-body {
  /* 残り幅をテキスト側に割り当て */
  flex: 1;
  /* 長い商品名の省略に必要 */
  min-width: 0;
  /* 高さ内に収める余白 */
  padding: 10px 16px 12px 12px;
  /* 上から順に配置し最後を auto で下押し */
  justify-content: flex-start;
}

/* 1件時は高さ制約のため商品名は最大1行 */
.maqe-shop .shop-products-grid--single .shop-product-card-name,
.maqe-shop .shop-products-grid--single .shop-product-card-link.shop-product-card-name {
  /* 1行で切り詰め */
  -webkit-line-clamp: 1;
  /* 下余白を詰める */
  margin: 0 0 4px 0;
  /* 2行分の min-height を解除 */
  min-height: 0;
}

/* 1件時の価格行の下余白 */
.maqe-shop .shop-products-grid--single .shop-product-card-price {
  /* ボタンとの間隔 */
  margin: 0 0 8px 0;
}

/* 1件時：カートボタンをカード下端付近（右カラム内）に配置 */
.maqe-shop .shop-products-grid--single .shop-product-card-btn {
  /* 上のコンテンツの下に押し下げ */
  margin-top: auto;
  /* 左寄せのまま */
  align-self: flex-start;
}

.maqe-shop .shop-products-grid--row {
  grid-template-columns: repeat(4, 230px);
  width: 1016px;
  margin-left: auto;
  margin-right: auto;
}

.maqe-shop .shop-product-card {
  width: 230px;
  height: 370px;
  background: #fff;
  border-radius: 4px;
  overflow: hidden;
  box-sizing: border-box;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
}

.maqe-shop .shop-product-card-img-wrap {
  width: 230px;
  height: 230px;
  flex-shrink: 0;
  overflow: hidden;
  background: #f5f5f5;
}

.maqe-shop .shop-product-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.maqe-shop .shop-product-card-body {
  flex: 1;
  padding: 8px 8px 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.maqe-shop .shop-product-card-name,
.maqe-shop .shop-product-card-link.shop-product-card-name {
  font-weight: 700;
  font-size: 16px;
  margin: 0 0 8px;
  line-height: 1.4;
  color: #000;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.maqe-shop .shop-product-card-link {
  text-decoration: none;
  color: inherit;
}

.maqe-shop .shop-product-card-link:hover {
  text-decoration: underline;
  color: inherit;
}

.maqe-shop .shop-product-card-price {
  font-weight: 400;
  font-size: 16px;
  margin: 0 0 12px;
  color: #000;
}

.maqe-shop .shop-product-card-btn {
  width: 86px;
  height: 32px;
  padding: 0;
  font-size: 14px;
  font-weight: 400;
  color: #fff;
  background: #0AC4DD;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  margin-top: auto;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  text-decoration: none;
}
.maqe-shop .shop-product-card-btn:hover {
  color: #fff;
  opacity: 0.9;
}

/* 在庫切れ：カート追加をグレーアウトしクリックを CSS でも無効化（JS と併用） */
.maqe-shop .shop-product-card-btn.shop-product-card-btn--out-of-stock {
  background: #c4c4c4 !important;
  color: #666 !important;
  cursor: not-allowed;
  pointer-events: none;
  opacity: 1;
}
.maqe-shop .shop-product-card-btn.shop-product-card-btn--out-of-stock:hover {
  color: #666 !important;
  opacity: 1;
}

/* 12件超：13件目以降カードを非表示（公開は「さらに表示」で JS がクラス除去、編集・プレビューは常にこのまま） */
.maqe-shop .shop-product-card--more-collapsed {
  /* 折りたたみ対象をレイアウトから外す */
  display: none !important;
}

/* 「さらに表示」ブロックをグリッド下に中央配置 */
.maqe-shop .shop-products-show-more-wrap {
  /* 上マージン（グリッドとの間隔） */
  margin-top: 32px;
  /* ボタンを中央に */
  text-align: center;
  /* ラッパーを行全体に伸ばす */
  width: 100%;
}

/* 「さらに表示」ボタン（背景・文字色は HTML インライン style 優先、未設定時はアクセント） */
.maqe-shop .shop-products-show-more-btn {
  /* 既定の塗り（インラインが無い場合） */
  background: #0AC4DD;
  /* 既定の文字色 */
  color: #fff;
  /* Figma 角丸 4px */
  border-radius: 4px;
  /* 境界線なし */
  border: none;
  /* ポインタ表示 */
  cursor: pointer;
  /* クリック領域の最小幅 */
  min-width: 140px;
  /* 高さ */
  height: 44px;
  /* 左右余白 */
  padding: 0 24px;
  /* フォントサイズ */
  font-size: 14px;
  /* 太さ */
  font-weight: 600;
  /* ボックス計算 */
  box-sizing: border-box;
}

.maqe-shop .shop-products-show-more-btn:hover {
  /* ホバー時のフィードバック */
  opacity: 0.9;
}

/* 商品一覧ページへの導線（「最新4つまで」+ チェック時のみ表示） */
.maqe-shop .shop-products-list-link-wrap {
  text-align: center;
  margin-top: 32px;
}

.maqe-shop .shop-products-list-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 140px;
  height: 44px;
  padding: 0 24px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: #0AC4DD;
  border-radius: 8px;
  text-decoration: none;
  box-sizing: border-box;
  transition: background-color 0.2s;
}

.maqe-shop .shop-products-list-link-btn:hover {
  background: #09a9bf;
  color: #fff;
}

/*============================================================
  プレビュー・公開サイト用レスポンシブ（gap 32px 維持）
*============================================================*/

/* タブレット: 2列（230×2 + 32 = 492px） */
@media (max-width: 1024px) {
  .maqe-shop .shop-products-inner {
    max-width: 492px;
  }

  /* 公開1件時：2列用492px上限を外し640カードを載せられる幅にする */
  .maqe-shop .shop-products-inner--single {
    max-width: 1016px;
  }

  /* parts 未再生成時も grid--single があれば inner 幅を広げる */
  .maqe-shop .shop-products-inner:has(.shop-products-grid--single) {
    max-width: 1016px;
  }

  .maqe-shop .shop-products-grid,
  .maqe-shop .shop-products-grid--row {
    grid-template-columns: repeat(2, 230px);
    width: 492px;
    max-width: 100%;
  }
}

/* スマホ: 1列（230px） */
@media (max-width: 560px) {
  .maqe-shop .shop-products-inner {
    max-width: 230px;
    padding-left: 16px;
    padding-right: 16px;
  }

  /* 公開1件時：230px制限を解除して横長カードを表示する */
  .maqe-shop .shop-products-inner--single {
    max-width: 100%;
  }

  /* parts 未再生成時も1件グリッドなら inner を全幅扱いにする */
  .maqe-shop .shop-products-inner:has(.shop-products-grid--single) {
    max-width: 100%;
  }

  .maqe-shop .shop-products-grid,
  .maqe-shop .shop-products-grid--row {
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 230px;
    justify-items: center;
  }

  .maqe-shop .shop-products-title {
    font-size: 24px;
    margin-bottom: 24px;
  }

  .maqe-shop .shop-product-card {
    width: 100%;
    max-width: 230px;
  }

  .maqe-shop .shop-product-card-img-wrap {
    width: 100%;
    aspect-ratio: 1;
    height: auto;
  }

  /* 公開1件：上記230px縦カード用ルールを上書きし640基準の横並びを維持 */
  .maqe-shop .shop-products-grid--single {
    /* 親幅いっぱいに近づける */
    width: 100%;
    /* 230px 上限を外す */
    max-width: 100%;
  }

  .maqe-shop .shop-products-grid--single .shop-product-card {
    /* 230px 上限を外す */
    max-width: 100%;
    /* 狭い画面では親幅に追従 */
    width: 100%;
    /* 極端に潰れる場合に備え最小高さ */
    height: auto;
    min-height: 160px;
    /* 横並びを維持 */
    flex-direction: row;
  }

  .maqe-shop .shop-products-grid--single .shop-product-card-img-wrap {
    /* 縦積み用の 100% 幅を打ち消す */
    width: 160px;
    /* 極窄幅では画像をやや縮小 */
    max-width: 40%;
    min-width: 96px;
    /* 高さはカードに合わせる */
    height: 160px;
    /* aspect-ratio 指定を無効化 */
    aspect-ratio: unset;
    /* 横並びで潰さない */
    flex-shrink: 0;
  }
}

/*============================================================
  ショップ用フッター法務リンク（特定商取引法に基づく表記 | 利用規約）
  フッター背景が白・明るい場合は濃い色、黒帯の場合は .footer-dark で上書き可能
*============================================================*/
.shop-footer-legal-links {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: 20px;
  margin-bottom: 8px;
  color: #333;
  font-size: 14px;
}

.shop-footer-legal-links a {
  color: inherit;
  text-decoration: none;
}

.shop-footer-legal-links a:hover {
  text-decoration: underline;
}

.shop-footer-legal-sep {
  margin: 0 8px;
  opacity: 0.85;
}
