/* =========================================================
   PRIME GEAR セールナビ v2.0.6.5（最強完全版 / 配布向け）
   - 直リンク / モーダル両対応
   - SP/PC出し分け（重複排除）
   - SP: ピル（可変幅・確実に消える・3演出は競合しない）
   - PC: サイドタブ（テーマ差で埋もれない・3演出）
   - モーダル（見出し白固定・×ボタン・スクロールで×非表示）
========================================================= */

/* =========================
   1. ボタン自体の PC / SP 出し分け
========================= */
.pg-sm-sp-only { display: none !important; }
.pg-sm-pc-only { display: none !important; }

@media screen and (max-width: 959px) {
  .pg-sm-sp-only { display: block !important; }
}
@media screen and (min-width: 960px) {
  .pg-sm-pc-only { display: block !important; }
}

/* =========================
   2. SP: 下部ピルボタン（文字数に合わせて可変）
   - 位置決めは .pg-sm-pill
   - アニメは .pg-sm-pill__inner / .pg-sm-pill__icon に寄せる（transform競合防止）
========================= */
@media screen and (max-width: 959px) {

  .pg-sm-pill {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: calc(var(--pg-sm-pill-bottom, 24px) + env(safe-area-inset-bottom, 0px));
    z-index: 9999;

    display: inline-flex;
    width: auto;
    min-width: 120px;
    max-width: 92vw;
    white-space: nowrap;

    align-items: center;
    padding: 12px 24px;
    border-radius: 999px;

    background: var(--pg-sm-accent-bg, #000);
    color: var(--pg-sm-accent-text, #fff);
    text-decoration: none;

    transition: transform .28s ease, opacity .28s ease, visibility .28s ease;
    -webkit-tap-highlight-color: transparent;
  }

  /* button のデフォルト見た目を抑える（a / button 両対応） */
  button.pg-sm-pill{
    border: none;
    cursor: pointer;
    background: var(--pg-sm-accent-bg, #000);
    color: var(--pg-sm-accent-text, #fff);
  }

  .pg-sm-pill__inner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    will-change: transform;
  }

  .pg-sm-pill__label {
    line-height: 1.2;
    font-size: clamp(13px, 3.8vw, 15px);
  }

  .pg-sm-pill__icon {
    font-size: 16px;
    display: inline-block;
    line-height: 1;
    margin-top: 1px; /* 視覚中央微調整（transformでやらない） */
    will-change: transform;
  }

  /* 確実に消える（transform競合しても opacity/visibility で勝つ） */
  .pg-sm-pill.is-hidden {
    transform: translateX(-50%) translateY(20px) !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    animation: none !important;
  }
}

/* =========================
   3. PC: 右サイドタブ（配布向けの堅牢版）
   - position基準を作り、::beforeが確実に効く
   - z-indexを強めて埋もれにくく
========================= */
@media screen and (min-width: 960px) {
  .pg-sm-sidebar {
    position: fixed !important;
    right: 0 !important;
    top: 50% !important;

    /* 基本姿勢はここで固定（wiggleは keyframes 内で -50% を維持） */
    transform: translateY(-50%);

    z-index: 999;
    display: flex;
    align-items: center;

    background: var(--pg-sm-accent-bg, #000);
    color: var(--pg-sm-accent-text, #fff);

    padding: 1em .5em;
    border-radius: 10px 0 0 10px;

    writing-mode: vertical-rl;
    text-decoration: none;

    /* 光演出用 */
    overflow: hidden;
  }

  .pg-sm-sidebar__label {
    display: block;
    transform-origin: center;
  }
}

/* =========================
   4. モーダル本体
========================= */
.pg-sm-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
}
.pg-sm-modal.is-open { display: flex !important; }

.pg-sm-modal__overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.62);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity .3s ease;
}
.pg-sm-modal.is-visible .pg-sm-modal__overlay { opacity: 1; }

.pg-sm-modal__dialog {
  position: relative;
  width: min(920px, 92vw);
  max-height: min(86vh, 820px);
  background: var(--pg-sm-accent-bg, #000);
  color: var(--pg-sm-accent-text, #fff);
  border-radius: 18px;
  opacity: 0;
  transform: translateY(12px);
  transition: all .3s ease;
}
.pg-sm-modal.is-visible .pg-sm-modal__dialog { opacity: 1; transform: translateY(0); }

/* =========================
   5. 閉じるボタン（成功版）
========================= */
.pg-sm-modal__close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 48px;
  height: 48px;
  background: transparent;
  color: inherit;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all 0.3s ease !important;
}

.pg-sm-modal__close:hover {
  transform: rotate(90deg);
}

.pg-sm-modal.is-scrolled .pg-sm-modal__close {
  opacity: 0 !important;
  pointer-events: none !important;
  transform: scale(0.8);
}

.pg-sm-modal__close-x { position: relative; width: 18px; height: 18px; }
.pg-sm-modal__close-x::before,
.pg-sm-modal__close-x::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
  transform: translate(-50%,-50%) rotate(45deg);
}
.pg-sm-modal__close-x::after {
  transform: translate(-50%,-50%) rotate(-45deg);
}

/* =========================
   6. モーダル内部デザイン（見出し白固定）
========================= */
.pg-sm-modal__inner {
  padding: 56px 22px 18px;
  max-height: min(86vh, 820px);
  overflow-y: auto;
  color: var(--pg-sm-accent-text, #fff) !important;
}

.pg-sm-modal__inner :where(h1, h2, h3, h4, h5, h6) {
  color: var(--pg-sm-accent-text, #fff) !important;
  margin: 1.5em 0 0.8em !important;
  border: none !important;
  background: transparent !important;
}

.pg-sm-modal__inner a {
  color: #64b5f6 !important;
  text-decoration: none;
  font-weight: 600;
}
.pg-sm-modal__inner a:hover { text-decoration: underline; }

/* =========================
   7. ★コンテンツの重複を強制排除★
========================= */
@media screen and (max-width: 959px) {
  .pg-sm-modal__content--pc { display: none !important; }
}
@media screen and (min-width: 960px) {
  .pg-sm-modal__content--sp { display: none !important; }
}

/* =========================================================
   8. アニメーション（最強版）
   - タグ依存を排除（aでもbuttonでもOK）
   - transform競合を避ける（SPはinner/icon、PCはkeyframesで-50%維持）
========================================================= */

/* --- [PC] 1. タブ全体を左右に揺らす --- */
.pg-sm-sidebar.pg-anim-pc-wiggle {
  animation: pgPcWiggle 2.8s ease-in-out infinite !important;
}

@keyframes pgPcWiggle {
  0%, 100% { transform: translateY(-50%) translateX(0); }
  50%      { transform: translateY(-50%) translateX(-4px); }
}

/* --- [PC] 2. 高級感：左エッジのシーン(光) --- */
.pg-sm-sidebar.pg-anim-pc-scene {
  /* ::before の position基準 */
  position: fixed !important;
  overflow: hidden;
}

.pg-sm-sidebar.pg-anim-pc-scene::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 3px;
  height: 78%;
  border-radius: 3px;
  background: linear-gradient(to bottom, transparent, rgba(255,255,255,.95), transparent);
  opacity: .35;
  filter: blur(.2px);
  animation: pgPcSheen 2.4s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
}

@keyframes pgPcSheen {
  0%, 100% { transform: translateY(-50%) translateY(-16px); opacity: .25; }
  50%      { transform: translateY(-50%) translateY(16px);  opacity: .62; }
}

/* --- [PC] 3. タブ文字ポップ（現状維持） --- */
.pg-anim-pc-pop .pg-sm-sidebar__label,
.pg-sm-sidebar.pg-anim-pc-pop .pg-sm-sidebar__label {
  display: inline-block;
  animation: pgPcPop 4.0s ease-in-out infinite;
  will-change: transform;
}
@keyframes pgPcPop {
  0%, 90%, 100% { transform: scale(1); }
  92% { transform: scale(1.045); }
  95% { transform: scale(1); }
}

/* =========================================================
   [SP] 3つの動き（チェックボックス連動）
   - 矢印：iconだけ
   - バウンド/ピョコ：innerだけ（本体transformと競合しない）
========================================================= */

/* ① 矢印スライド（アイコンだけ） */
.pg-sm-pill.pg-anim-sp-arrow .pg-sm-pill__icon,
.pg-anim-sp-arrow .pg-sm-pill__icon {
  animation: pgSpArrow 1.2s infinite;
}
@keyframes pgSpArrow {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(4px); }
}

/* ② 軽くバウンド（inner） */
.pg-sm-pill.pg-anim-sp-breathe .pg-sm-pill__inner,
.pg-anim-sp-breathe .pg-sm-pill__inner,
.pg-sm-pill.pg-anim-sp-bounce .pg-sm-pill__inner,
.pg-anim-sp-bounce .pg-sm-pill__inner {
  animation: pgSpBounceInner 3.5s infinite ease-in-out !important;
}

@keyframes pgSpBounceInner {
  0%, 10%, 20%, 100% { transform: translateY(0); }
  5%  { transform: translateY(-3px); }
  15% { transform: translateY(-10px) scale(1.03); }
}

/* ③ 時々ピョコッ（inner） */
.pg-sm-pill.pg-anim-sp-blink .pg-sm-pill__inner,
.pg-anim-sp-blink .pg-sm-pill__inner {
  animation: pgSpPopInner 4.2s ease-in-out infinite !important;
  will-change: transform;
}
@keyframes pgSpPopInner {
  0%, 88%, 100% { transform: translateY(0) scale(1); }
  92%           { transform: translateY(-3px) scale(1.035); }
  96%           { transform: translateY(0) scale(1); }
}

/* 非表示時：確実に止める（inner/icon含めて止める） */
@media screen and (max-width: 959px) {
  .pg-sm-pill.is-hidden,
  .pg-sm-pill.is-hidden .pg-sm-pill__inner,
  .pg-sm-pill.is-hidden .pg-sm-pill__icon {
    animation: none !important;
  }
}

/* モーション軽減（上品で安全） */
@media (prefers-reduced-motion: reduce) {
  .pg-sm-sidebar,
  .pg-sm-sidebar__label,
  .pg-sm-pill,
  .pg-sm-pill__inner,
  .pg-sm-pill__icon {
    animation: none !important;
    transition: none !important;
  }
}

/* 背景スクロール抑止（必須） */
body.pg-sm-modal-open {
  overflow: hidden !important;
}