/**
 * POD ミックス&マッチ（inc/pod-mix-builder.php・template-parts/pod-mix/ と対）。
 * XD mymoods_detail6: 購入バー（PC_detail / SP_detail_1）・フレーバー選択（PC_flavor_3% / 5%_A、
 * SP_flavor_3%_A / 5%）・写真の小窓（PC_flavor_3%_detail・SP_flavor_detail）。
 *
 * 3% は明るい地（#f4f4f4）、5% は黒地（#2c2929・選択の枠は #e8ff01）。色はモーダルの
 * data-strength で変数を切り替える。
 */

/* モーダルは JS が body の直下へ移すので、共通の変数はモーダルにも置く。 */
.mm-pm,
.mm-pm-modal {
  --pm-ink: #111111;
  --pm-sub: #989898;
  --pm-yellow: #e8ff01;
  --pm-save-bg: #f8dce1;
  --pm-save-ink: #ff002c;
  --pm-border: #e5e7eb;
  --pm-muted: #9ca3af;
}

.mm-pm {
  margin: 16px 0 8px;
}

.mm-pm [hidden],
.mm-pm-modal[hidden],
.mm-pm-modal [hidden] {
  display: none !important;
}

/* ─────────── 購入バー ─────────── */

.mm-pm-bar {
  display: block;
  color: var(--pm-ink);
}

.mm-pm-bar__summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.mm-pm-bar__count {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  line-height: 22px;
  color: #1a1a1a;
}

.mm-pm-bar__save {
  display: inline-block;
  padding: 0 12px;
  border-radius: 11px;
  background: var(--pm-save-bg);
  color: var(--pm-save-ink);
  font-size: 11px;
  font-weight: 400;
  line-height: 22px;
  white-space: nowrap;
}

/* モーダルの購入バーの「クリア」（1 個以上選んでいるときだけ出る・2026-11-21） */
.mm-pm-bar__clear {
  padding: 0 2px;
  border: 0;
  background: none;
  color: var(--pm-sub);
  font: inherit;
  font-size: 11px;
  font-weight: 400;
  line-height: 22px;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
  cursor: pointer;
}

.mm-pm-bar__clear:hover {
  color: var(--pm-ink);
}

/*
 * 「あと3個で7%OFFに」などの案内は黒の太字にして、「7%OFF」の部分だけ黄色のマーカーを引く（2026-11-21 A 案）。
 * <em> は assets/pod-mix-builder.js の setHint() と template-parts/pod-mix/purchase-bar.php が付ける。
 */
.mm-pm-bar__hint {
  margin: 2px 0 0;
  font-size: 12px;
  font-weight: 700;
  line-height: 14px;
  color: var(--pm-ink);
}

.mm-pm-bar__hint-em {
  padding: 0 2px;
  background: linear-gradient(transparent 55%, var(--pm-yellow) 55%);
  font-style: normal;
}

.mm-pm-bar__total {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  line-height: 26px;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.mm-pm-bar__total .woocommerce-Price-amount {
  font: inherit;
}

.mm-pm-bar__actions {
  display: flex;
  gap: 12px;
  margin-top: 14px;
}

.mm-pm-btn {
  flex: 1 1 0;
  min-height: 52px;
  padding: 0 12px;
  border-radius: 26px;
  border: 1px solid #000;
  background: #fff;
  color: #000;
  font: inherit;
  font-size: 15px;
  line-height: 1.2;
  cursor: pointer;
  transition: opacity 0.15s;
}

.mm-pm-btn--cart {
  border-color: var(--pm-yellow);
  background: var(--pm-yellow);
}

/* 「フレーバーを選ぶ」は 2 段（2026-11-21 B 案）。2 段目で濃度と個数も選べることを伝える。 */
.mm-pm-btn--open {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.mm-pm-btn__main {
  font-weight: 700;
  line-height: 1.2;
}

.mm-pm-btn__sub {
  font-size: 11px;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: 0.02em;
  color: var(--pm-sub);
  white-space: nowrap;
}

.mm-pm-btn:hover:not(:disabled) {
  opacity: 0.85;
}

.mm-pm-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.mm-pm-btn:focus-visible,
.mm-pm button:focus-visible,
.mm-pm-modal button:focus-visible {
  outline: 2px solid #1e6fb8;
  outline-offset: 2px;
}

.mm-pm-bar__msg {
  margin: 8px 0 0;
  font-size: 12px;
  color: #1a1a1a;
}

.mm-pm-bar__msg.is-error {
  color: #c62828;
}

/* SP: 商品ページの購入バーは画面の下に固定（SP_detail_1）。 */
@media screen and (max-width: 989px) {
  .mm-pm-bar--page {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 900;
    padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
    background: #fff;
    border-top: 1px solid var(--pm-border);
  }

  .mm-pm-bar--page .mm-pm-bar__actions {
    gap: 7px;
    margin-top: 12px;
    padding: 0 4px;
  }

  /*
   * 1 画面目に写真の下のドット（・・・）まで入るよう、画面下の購入バーを詰める（2026-11-21）。
   * 131px → 104px（上下の余白 14→10・2 行の行の高さ・ボタンとの間 12→8・ボタン 52→44）。
   * 390px 幅の iPhone の Safari（ツールバーが出ている状態で見える高さ 約 653px）で、
   * ヘッダー＋写真 390px＋ドットがバーの上に収まる。
   */
  .mm-pm-bar--page {
    padding-top: 10px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }

  .mm-pm-bar--page .mm-pm-bar__count {
    line-height: 18px;
  }

  .mm-pm-bar--page .mm-pm-bar__save {
    line-height: 18px;
  }

  .mm-pm-bar--page .mm-pm-bar__hint {
    margin-top: 0;
  }

  .mm-pm-bar--page .mm-pm-bar__total {
    font-size: 20px;
    line-height: 24px;
  }

  .mm-pm-bar--page .mm-pm-bar__actions {
    margin-top: 8px;
  }

  /* SP のモーダルは「（最大10個）」を出さず、「選択中 3 個」「お得」「クリア」を 1 行に収める。 */
  .mm-pm-bar--modal .mm-pm-bar__max {
    display: none;
  }

  .mm-pm-bar--page .mm-pm-btn {
    min-height: 44px;
    border-radius: 22px;
  }

  .mm-pm-bar--page .mm-pm-btn__main {
    font-size: 14px;
  }

  body.mm-pm-has-bar {
    padding-bottom: 150px;
  }

  /* LINE・チャットの浮遊ボタンは、この画面では出さない（template-parts/v2/site-footer.php・2026-11-21）。 */
}

/* ─────────── モーダル ─────────── */

html.mm-pm-lock,
html.mm-pm-lock body {
  overflow: hidden;
}

.mm-pm-modal {
  --pm-bg: #f4f4f4;
  --pm-text: #111111;
  --pm-card: #ffffff;
  --pm-card-border: var(--pm-border);
  --pm-card-active: #111111;
  --pm-step-bg: #ffffff;
  --pm-step-border: var(--pm-border);
  --pm-step-disabled: var(--pm-muted);
  --pm-chip-bg: #ffffff;
  --pm-chip-active: #111111;
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mm-pm-modal[data-strength="5"] {
  --pm-bg: #2c2929;
  --pm-text: #ffffff;
  --pm-card: #000000;
  --pm-card-border: #000000;
  --pm-card-active: var(--pm-yellow);
  --pm-step-bg: #1a1a1a;
  --pm-step-border: #1a1a1a;
  --pm-step-disabled: #6b7280;
  --pm-chip-bg: #000000;
  --pm-chip-active: var(--pm-yellow);
}

/* base.css の div:empty { display:none } に消されないよう :empty 付きでも指定する。 */
.mm-pm-modal__overlay,
.mm-pm-modal__overlay:empty {
  position: absolute;
  inset: 0;
  display: block;
  background: rgba(0, 0, 0, 0.55);
}

.mm-pm-modal__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(1040px, calc(100% - 40px));
  max-height: calc(100% - 96px);
  border-radius: 16px;
  overflow: hidden;
  background: var(--pm-bg);
  color: var(--pm-text);
  transition: background-color 0.2s, color 0.2s;
}

.mm-pm-modal__head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  height: 64px;
  border-bottom: 1px solid rgba(127, 127, 127, 0.18);
}

.mm-pm-modal__title {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
  line-height: 21px;
  color: inherit;
}

.mm-pm-modal__back,
.mm-pm-modal__x {
  position: absolute;
  top: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  cursor: pointer;
  transform: translateY(-50%);
}

.mm-pm-modal__back {
  left: 12px;
  display: none;
  width: 40px;
  height: 40px;
  background: transparent;
  color: inherit;
}

.mm-pm-modal__x {
  right: 32px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #111;
  color: #fff;
}

.mm-pm-modal[data-strength="5"] .mm-pm-modal__x {
  background: #fff;
  color: #111;
}

.mm-pm-modal__body {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 40px 24px;
}

.mm-pm-section {
  margin-top: 24px;
}

.mm-pm-section__title {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 500;
  line-height: 17px;
  color: inherit;
}

/* 濃度の切り替え（白いピルに黒の選択） */
.mm-pm-seg {
  display: inline-flex;
  width: 335px;
  max-width: 100%;
  padding: 4px;
  border-radius: 20px;
  background: #fff;
}

.mm-pm-seg__btn {
  flex: 1 1 0;
  height: 32px;
  border: 0;
  border-radius: 16px;
  background: transparent;
  color: #111;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.mm-pm-seg__btn.is-active {
  background: #111;
  color: #fff;
}

/* 絞り込み */
.mm-pm-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mm-pm-chip {
  min-width: 80px;
  height: 34px;
  padding: 0 20px;
  border: 1px solid var(--pm-chip-bg);
  border-radius: 9px;
  background: var(--pm-chip-bg);
  color: var(--pm-text);
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.mm-pm-modal[data-strength="5"] .mm-pm-chip {
  font-weight: 700;
}

.mm-pm-chip.is-active {
  border-color: var(--pm-chip-active);
}

/* カード */
.mm-pm-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 9px 12px;
  margin: 0;
  padding: 2px;
  list-style: none;
}

.mm-pm-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
  padding: 4px 4px 18px;
  border: 1px solid var(--pm-card-border);
  border-radius: 4px;
  background: var(--pm-card);
}

.mm-pm-card.is-selected {
  border-color: var(--pm-card-active);
}

.mm-pm-card.is-oos {
  opacity: 0.5;
}

.mm-pm-card__image {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 0;
  border-radius: 2px;
  overflow: hidden;
  background: #e9e9e9;
  cursor: zoom-in;
}

.mm-pm-card__image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mm-pm-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #111;
  color: #fff;
  font-size: 7px;
  font-weight: 800;
  line-height: 1;
}

.mm-pm-card__name {
  margin: 12px 0 10px;
  min-height: 24px;
  font-size: 10px;
  font-weight: 500;
  line-height: 12px;
  text-align: center;
  color: inherit;
  overflow-wrap: anywhere;
}

.mm-pm-card__oos {
  display: flex;
  align-items: center;
  height: 28px;
  margin: 0;
  font-size: 11px;
  color: inherit;
}

.mm-pm-stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 76px;
  height: 28px;
  border: 1px solid var(--pm-step-border);
  border-radius: 14px;
  background: var(--pm-step-bg);
}

.mm-pm-stepper__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--pm-text);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.mm-pm-stepper__btn:disabled {
  color: var(--pm-step-disabled);
  cursor: default;
}

.mm-pm-stepper__qty {
  min-width: 14px;
  font-size: 13px;
  text-align: center;
  color: var(--pm-text);
}

.mm-pm-empty {
  margin: 24px 0;
  font-size: 13px;
  text-align: center;
}

/* モーダルの下の購入バー（PC: 1 行・SP: カートのボタンを全幅で下に） */
.mm-pm-bar--modal {
  flex: none;
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 100px;
  padding: 16px 40px;
  background: #fff;
  color: var(--pm-ink);
}

.mm-pm-bar--modal .mm-pm-bar__summary {
  flex: 1 1 auto;
  align-items: center;
}

.mm-pm-bar--modal .mm-pm-bar__actions {
  flex: none;
  width: 320px;
  margin: 0;
}

.mm-pm-bar--modal .mm-pm-bar__msg {
  position: absolute;
  bottom: 6px;
  left: 40px;
}

/* 写真の小窓 */
.mm-pm-zoom {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mm-pm-zoom__overlay,
.mm-pm-zoom__overlay:empty {
  position: absolute;
  inset: 0;
  display: block;
  background: rgba(0, 0, 0, 0.4);
}

.mm-pm-zoom__card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(330px, calc(100% - 64px));
  padding: 14px 14px 34px;
  background: var(--pm-card);
  color: var(--pm-text);
}

.mm-pm-zoom__x {
  position: absolute;
  top: -14px;
  right: -14px;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #111;
  color: #fff;
  cursor: pointer;
}

.mm-pm-modal[data-strength="5"] .mm-pm-zoom__x {
  background: #fff;
  color: #111;
}

.mm-pm-zoom__image {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #e9e9e9;
}

.mm-pm-zoom__image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mm-pm-badge--large {
  top: 8px;
  right: 8px;
  width: 54px;
  height: 54px;
  font-size: 20px;
}

.mm-pm-zoom__name {
  margin: 24px 0 18px;
  font-size: 20px;
  font-weight: 500;
  line-height: 24px;
  text-align: center;
  color: inherit;
}

.mm-pm-stepper--large {
  width: 183px;
  height: 39px;
  border-radius: 20px;
}

.mm-pm-stepper--large .mm-pm-stepper__btn {
  width: 46px;
  font-size: 20px;
}

.mm-pm-stepper--large .mm-pm-stepper__qty {
  font-size: 18px;
}

/* ─────────── SP: 全画面 ─────────── */
@media screen and (max-width: 989px) {
  .mm-pm-modal {
    align-items: stretch;
  }

  .mm-pm-modal__panel {
    width: 100%;
    max-height: none;
    height: 100%;
    border-radius: 0;
  }

  .mm-pm-modal__head {
    height: 64px;
    border-bottom: 0;
  }

  .mm-pm-modal__back {
    display: inline-flex;
  }

  .mm-pm-modal__x {
    display: none;
  }

  .mm-pm-modal__body {
    padding: 0 20px 24px;
  }

  .mm-pm-section:first-child {
    margin-top: 4px;
  }

  .mm-pm-seg {
    display: flex;
    width: 100%;
  }

  /* 絞り込みは横にスクロール（SP_flavor_3%_A） */
  .mm-pm-chips {
    flex-wrap: nowrap;
    margin: 0 -20px;
    padding: 0 20px 2px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .mm-pm-chips::-webkit-scrollbar {
    display: none;
  }

  .mm-pm-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 9px 8px;
    margin: 0 -4px;
  }

  .mm-pm-bar--modal {
    display: block;
    min-height: 0;
    padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--pm-border);
  }

  .mm-pm-bar--modal .mm-pm-bar__actions {
    width: auto;
    margin-top: 12px;
    padding: 0 4px;
  }

  .mm-pm-bar--modal .mm-pm-bar__msg {
    position: static;
  }
}

@media screen and (min-width: 990px) and (max-width: 1199px) {
  .mm-pm-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

/* ─────────── 2026-11-20: 選択中の一覧・人気順の順位・写真の小窓のスライド ─────────── */

/* 商品ページの購入バー: 選んだフレーバーの一覧（JS が書く） */
.mm-pm-picked {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.mm-pm-picked__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border: 1px solid var(--pm-border);
  border-radius: 13px;
  background: #fafafa;
  font-size: 11px;
  line-height: 24px;
  white-space: nowrap;
  color: var(--pm-ink);
}

.mm-pm-picked__qty {
  font-weight: 700;
}

/* 人気順: 説明の1行と、カードの順位 */
.mm-pm-chips__note {
  margin: 10px 0 0;
  font-size: 11px;
  line-height: 16px;
  color: inherit;
  opacity: 0.7;
}

/* 4 位以降は小さな数字だけ（写真の上に白）。 */
.mm-pm-rank {
  position: absolute;
  top: 5px;
  left: 6px;
  z-index: 1;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

/* 1〜3 位は黄色の帯で「BEST 01」（カートのボタンと同じ黄色・角は付けない）。 */
.mm-pm-rank[data-rank="1"],
.mm-pm-rank[data-rank="2"],
.mm-pm-rank[data-rank="3"] {
  top: 0;
  left: 0;
  padding: 0 8px;
  background: var(--pm-yellow);
  color: #111;
  font-size: 10px;
  font-weight: 800;
  line-height: 20px;
  letter-spacing: 0.08em;
  text-shadow: none;
}

/* 写真の小窓: 画像を横に送る（スクロールスナップ。スワイプ・矢印・点・← → キー） */
.mm-pm-zoom__card {
  width: min(440px, calc(100% - 64px));
  max-height: calc(100% - 48px);
}

.mm-pm-zoom__image {
  flex: none;
}

.mm-pm-zoom__track {
  display: flex;
  width: 100%;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior: contain;
  scrollbar-width: none;
  outline: 0;
}

.mm-pm-zoom__track::-webkit-scrollbar {
  display: none;
}

.mm-pm-zoom__slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

/* 訴求画像には文字があるので、切らずに全体を出す。 */
.mm-pm-zoom__image .mm-pm-zoom__slide img {
  object-fit: contain;
}

.mm-pm-zoom__nav {
  position: absolute;
  top: 50%;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #111;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  transform: translateY(-50%);
}

.mm-pm-zoom__nav--prev {
  left: 8px;
}

.mm-pm-zoom__nav--next {
  right: 8px;
}

.mm-pm-zoom__nav:disabled {
  opacity: 0;
  pointer-events: none;
}

.mm-pm-zoom__dots,
.mm-pm-zoom__dots:empty {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  min-height: 8px;
  margin: 12px 0 0;
}

.mm-pm-zoom__dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--pm-text);
  opacity: 0.25;
  cursor: pointer;
}

.mm-pm-zoom__dot.is-active {
  opacity: 1;
}

.mm-pm-zoom.is-single .mm-pm-zoom__nav,
.mm-pm-zoom.is-single .mm-pm-zoom__dots {
  display: none;
}

.mm-pm-zoom__name {
  margin: 14px 0 14px;
}

@media screen and (max-width: 989px) {
  /* SP は購入バーが画面下に固定なので、一覧は1行で横に送る（バーの高さを増やしすぎない）。 */
  .mm-pm-picked {
    flex-wrap: nowrap;
    margin: 8px -16px 0;
    padding: 0 16px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .mm-pm-picked::-webkit-scrollbar {
    display: none;
  }

  body.mm-pm-has-bar {
    padding-bottom: 184px;
  }

  .mm-pm-zoom__card {
    width: min(440px, calc(100% - 40px));
  }
}
