/* CosLab の「手ざわり」（2026-10-24 ブルー・Kim「apple-design 実装して」）
   考え方は工房の .claude/skills/apple-design（WWDC の Designing Fluid Interfaces を web に置き換えたもの）。
   yourpcai の site-motion.css 7・8、StyleLab の /style/feel.css と同じ流儀をミントの画面に合わせた。

   守ったこと:
   ・既にある transform を上書きしない。押した手ごたえは個別プロパティ scale、浮く・引くは translate で足す
     （トーストの translateX(-50%)・「最安」札の translateX(-50%) を壊さない）
   ・セレクタは :where() で強さ 0。style.css が決めている所はそちらが勝つ
   ・浮く・光るはマウスの PC だけ（feel.js が html.fx-fine を付けたときだけ）
   ・ずっと回る動きは足さない。「動きを減らす」「透明を減らす」「コントラストを上げる」に従う */

:root {
  --fx-ease-spring: cubic-bezier(0.22, 1, 0.36, 1); /* 臨界減衰のばねに近い（行き過ぎない） */
  --fx-ease-sheet: cubic-bezier(0.32, 0.72, 0, 1); /* iOS のシートに近い曲線 */
}

/* ---------- 1. 押した瞬間に返す（離したときではなく） ---------- */
:where(.chip, .buy-btn, .sp-btn, .cart-buy, .rc-buy, .oy-buy, .cta-main, .go, .opt, .tabbar button,
  .rank-item, .mini-card, .result-card, .room-banner) {
  touch-action: manipulation;
  transition:
    scale 0.45s var(--fx-ease-spring),
    translate 0.5s var(--fx-ease-spring),
    background-color 0.2s ease,
    color 0.2s ease,
    box-shadow 0.4s var(--fx-ease-spring);
}
:where(.chip, .buy-btn, .sp-btn, .cart-buy, .rc-buy, .oy-buy, .cta-main, .go, .opt):active {
  scale: 0.96;
  transition: scale 0.1s ease-out, background-color 0.1s ease, color 0.1s ease;
}
/* 商品の行・カードは大きいので沈みを控えめに */
:where(.rank-item, .mini-card, .result-card, .room-banner):active {
  scale: 0.98;
  transition: scale 0.1s ease-out;
}
/* 下のタブ: 押したタブのアイコンだけ沈む（ボタン全体を縮めると棚の線がずれて見える） */
:where(.tabbar button) .ic {
  transition: scale 0.45s var(--fx-ease-spring);
}
:where(.tabbar button):active .ic {
  scale: 0.86;
  transition: scale 0.1s ease-out;
}

/* ---------- 2. タブを切り替えたら、新しい画面がふっと現れる（不透明度だけ・一度きり） ----------
   translate を使わない: 地図（maplibre）や position: fixed の物の基準が、動いている間だけずれるため */
.view.active {
  animation: fx-view-in 0.24s ease-out backwards;
}
@keyframes fx-view-in {
  from { opacity: 0; }
}

/* ---------- 3. 商品の詳細シート: iOS のシートの曲線で上がり、同じ道を下へ戻る ----------
   .modal.open の付け外しのまま、display の切り替えを遷移の最後へ回す（allow-discrete）。
   もとの slideup（0.25 秒・ease）は止めて、開く・閉じるを同じ曲線にそろえる。
   指で下へ引くと 1:1 で付いてきて、速く払う／半分を越えると閉じる（feel.js の 2）。 */
.modal {
  transition: display 0.42s allow-discrete;
}
.modal .backdrop {
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  transition: opacity 0.36s ease;
}
.modal:not(.open) .backdrop {
  opacity: 0;
}
.modal .sheet {
  animation: none;
  transition: translate 0.42s var(--fx-ease-sheet);
  overscroll-behavior: contain; /* シートの中のスクロールが後ろのページへ抜けない */
}
.modal:not(.open) .sheet {
  translate: 0 100%;
}
@starting-style {
  .modal.open .sheet {
    translate: 0 100%;
  }
  .modal.open .backdrop {
    opacity: 0;
  }
}
/* つかめる所の印（上の ✕ の帯の真ん中に小さな横棒） */
.modal .sheet .close {
  touch-action: none;
  cursor: grab;
}
.modal .sheet .close::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 7px;
  width: 36px;
  height: 5px;
  margin-left: -18px;
  border-radius: 99px;
  background: rgba(28, 43, 43, 0.18);
}
.modal .sheet.fx-dragging {
  transition: none;
  user-select: none;
}
.modal .sheet.fx-dragging .close {
  cursor: grabbing;
}

/* ---------- 4. ヘッダーと下のタブ: すりガラスを少し強く（色を少し濃く見せる saturate） ---------- */
.appbar,
.tabbar {
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
}

/* ---------- 5. マウスが近づくと浮き出る（PC のマウスだけ） ----------
   feel.js が距離から --fx-lift（0→1）を入れる。浮くのは最大 4px、影は近いほど深く、乗っている所に淡いミントの光 */
.fx-fine .fx-prox {
  translate: 0 calc(var(--fx-lift, 0) * -4px);
  box-shadow:
    0 4px 18px rgba(20, 60, 60, 0.07),
    0 calc(var(--fx-lift, 0) * 14px) calc(var(--fx-lift, 0) * 32px) rgba(20, 60, 60, calc(var(--fx-lift, 0) * 0.12));
  background-image: radial-gradient(260px circle at var(--fx-mx, 50%) var(--fx-my, 50%),
    rgba(63, 208, 193, calc(var(--fx-in, 0) * 0.1)), rgba(63, 208, 193, 0) 60%);
}
.fx-fine .fx-prox:active {
  scale: 0.985;
}

/* ---------- 6. 文字: 見出しは約物を詰め（palt）、少し締める。本文はそのまま ---------- */
:where(.row-head h2, .sheet .d-name) {
  font-feature-settings: "palt";
  letter-spacing: -0.01em;
  text-wrap: balance;
}

/* ---------- 7. 設定に従う ---------- */
@media (prefers-reduced-motion: reduce) {
  :where(.chip, .buy-btn, .sp-btn, .cart-buy, .rc-buy, .oy-buy, .cta-main, .go, .opt,
    .rank-item, .mini-card, .result-card, .room-banner):active,
  :where(.tabbar button):active .ic {
    scale: none !important;
  }
  /* シートは上下に動かさず、ふっと出る・消えるだけ */
  .modal .sheet,
  .modal:not(.open) .sheet {
    translate: none;
    transition: opacity 0.2s ease;
  }
  .modal:not(.open) .sheet {
    opacity: 0;
  }
  @starting-style {
    .modal.open .sheet {
      translate: none;
      opacity: 0;
    }
  }
  .view.active {
    animation-duration: 0.15s;
  }
}
@media (prefers-reduced-transparency: reduce) {
  .appbar,
  .tabbar {
    background: #fff;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .modal .backdrop {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}
@media (prefers-contrast: more) {
  .appbar {
    border-bottom-color: var(--ink);
  }
  .tabbar {
    border-top-color: var(--ink);
  }
  .fx-fine .fx-prox {
    box-shadow: 0 0 0 1px var(--ink);
  }
}
