/* ===== momo: 商品ページの画像ギャラリー・購入バー ===== */
.single-product {
  --mpg-rose: #c96b82;
  --mpg-rose-dark: #7c4352;
  --mpg-text: #3b3532;
  --mpg-sub: #7a716c;
  --mpg-line: #eadfdc;
  --mpg-tint: #fbf1f3;
}

/* 共通: 写真を切り取らず全体を表示(正方形の枠に収め、余白は白) */
.single-product .woocommerce-product-gallery .ct-media-container,
.single-product .woocommerce-product-gallery .ct-media-container img {
  aspect-ratio: 1 / 1 !important;
}
.single-product .woocommerce-product-gallery .ct-media-container img {
  object-fit: contain !important;
  background: #fff;
}

/* パソコン: 画像が大きくなりすぎないようにする */
@media (min-width: 690px) {
  .single-product .woocommerce-product-gallery {
    max-width: 520px;
  }
  .single-product .woocommerce-product-gallery .flexy-pills {
    max-height: 210px;
    overflow-y: auto;
  }
  .mpg-bar, .mpg-sheet, .mpg-overlay { display: none !important; }
}

/* スマホ */
@media (max-width: 689.98px) {
  /* 大きい画像1枚 + 下にサムネイルを横スクロールで並べる */
  .single-product .woocommerce-product-gallery .flexy-pills {
    display: block !important;
    margin-top: 10px;
  }
  .single-product .woocommerce-product-gallery .flexy-pills ol {
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin: 0;
    padding: 0 0 2px;
    grid-template-columns: none !important;
  }
  .single-product .woocommerce-product-gallery .flexy-pills ol::-webkit-scrollbar { display: none; }
  .single-product .woocommerce-product-gallery .flexy-pills li {
    flex: 0 0 64px !important;
    width: 64px !important;
    max-width: 64px !important;
    border: 2px solid transparent;
    border-radius: 6px;
    overflow: hidden;
    opacity: 1 !important;
  }
  .single-product .woocommerce-product-gallery .flexy-pills li.active {
    border-color: var(--mpg-rose);
  }
  .single-product .woocommerce-product-gallery [class*="flexy-arrow"] {
    display: none !important;
  }

  /* Apple Pay・Google Pay・Link のボタンはスマホでは出さない(購入は下の購入バーから) */
  .single-product #wc-stripe-express-checkout-element,
  .single-product .wcpay-express-checkout-wrapper {
    display: none !important;
  }

  /* 購入バーが使えるときは、元のカート欄(選択肢・数量・ボタン)を隠す。選択肢が2つ以上の軸の商品は元のまま */
  body.mpg-on .entry-summary .ct-product-add-to-cart {
    position: absolute !important;
    width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  body.mpg-on { padding-bottom: calc(var(--mpg-nav-h, 58px) + 76px) !important; }

  /* 画面下の購入バー(下部メニューの上に固定) */
  .mpg-bar {
    position: fixed; left: 0; right: 0; bottom: var(--mpg-nav-h, 58px); z-index: 998;
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; background: #fff; border-top: 1px solid var(--mpg-line);
    box-shadow: 0 -4px 14px rgba(0, 0, 0, .05);
  }
  .mpg-fav {
    flex: 0 0 46px; height: 46px; border-radius: 50%;
    border: 1px solid var(--mpg-line); background: #fff; color: var(--mpg-rose);
    display: flex; align-items: center; justify-content: center; padding: 0; cursor: pointer;
  }
  .mpg-fav svg { width: 22px; height: 22px; }
  .mpg-fav.is-added svg { fill: currentColor; }
  .mpg-price { flex: 1; min-width: 0; font-weight: 700; font-size: 17px; color: var(--mpg-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mpg-price del { font-weight: 400; font-size: 13px; color: var(--mpg-sub); }
  .mpg-cta {
    flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
    min-height: 46px; padding: 0 22px; border: 0; border-radius: 999px;
    background: var(--mpg-rose-dark); color: #fff; font-weight: 700; font-size: 15px; cursor: pointer;
  }
  .mpg-cta svg { width: 20px; height: 20px; }
  .mpg-cta[disabled], .mpg-row-add[disabled] { background: #c9c2bf; cursor: default; }

  /* 選択肢シート */
  .mpg-overlay {
    position: fixed; inset: 0; z-index: 1000; background: rgba(0, 0, 0, .45);
    opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  .mpg-sheet {
    position: fixed; left: 8px; right: 8px; bottom: 0; z-index: 1001;
    max-height: 78vh; display: flex; flex-direction: column;
    background: #fff; border-radius: 18px 18px 0 0;
    transform: translateY(105%); transition: transform .25s ease;
    padding-bottom: env(safe-area-inset-bottom);
  }
  body.mpg-sheet-open .mpg-overlay { opacity: 1; pointer-events: auto; }
  body.mpg-sheet-open .mpg-sheet { transform: translateY(0); }
  body.mpg-sheet-open { overflow: hidden; }
  .mpg-sheet-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 18px; border-bottom: 1px solid var(--mpg-line);
    font-weight: 700; color: var(--mpg-rose-dark); font-size: 16px;
  }
  .mpg-close { background: none; border: 0; padding: 4px; color: var(--mpg-sub); cursor: pointer; }
  .mpg-close svg { width: 22px; height: 22px; }
  .mpg-list { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px 18px 18px; }
  .mpg-row { padding: 16px 0; border-bottom: 1px solid var(--mpg-line); }
  .mpg-row:last-child { border-bottom: 0; }
  .mpg-row-top { display: flex; gap: 14px; }
  .mpg-row-img {
    flex: 0 0 92px; width: 92px; height: 92px; border: 1px solid var(--mpg-line); border-radius: 8px;
    background: #fff; object-fit: contain;
  }
  .mpg-row-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
  .mpg-row-name { font-size: 15px; color: var(--mpg-text); line-height: 1.35; }
  .mpg-row-price { font-weight: 700; font-size: 18px; color: var(--mpg-text); }
  .mpg-row-stock { font-size: 12px; color: var(--mpg-sub); }
  .mpg-row-stock.is-out { color: #b3261e; font-weight: 700; }
  .mpg-qty { display: flex; align-items: center; gap: 8px; }
  .mpg-qty button {
    width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--mpg-line);
    background: #fff; color: var(--mpg-text); font-size: 18px; line-height: 1; padding: 0; cursor: pointer;
  }
  .mpg-qty button[disabled] { opacity: .4; cursor: default; }
  .mpg-qty output { min-width: 28px; text-align: center; font-size: 16px; }
  .mpg-row-add {
    margin-top: 12px; width: 100%; min-height: 46px; display: flex; align-items: center; justify-content: center; gap: 8px;
    border: 0; border-radius: 999px; background: var(--mpg-rose-dark); color: #fff; font-weight: 700; font-size: 15px; cursor: pointer;
  }
  .mpg-row-add svg { width: 20px; height: 20px; }
}
