/* ============================================================
   試聴プレーヤー (test-site専用)
   ・スマホ: 下部固定バー (案A: 上下2段レイアウト)
   ・PC:    右サイドパネル (案P3)
   ============================================================ */

/* ====== ツールチップ内の試聴ボタン ====== */
.tip-play-row {
  display: flex;
  gap: 6px;
  margin: 8px 0 4px;
  flex-wrap: wrap;
}
.tip-play-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 11px;
  min-width: 96px;   /* Apple Music（最長テキスト）に合わせて3ボタン幅統一 */
  border-radius: 14px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  color: #fff;
  letter-spacing: 0.03em;
  transition: opacity 0.15s, transform 0.15s;
  text-decoration: none;
  font-family: inherit;
  box-sizing: border-box;
  white-space: nowrap;
}
.tip-play-btn:hover { opacity: 0.85; transform: translateY(-1px); }
.tip-play-btn:active { transform: translateY(0); }
.tip-play-btn.is-applemusic { background: #000000; }  /* Apple Music Black */
.tip-play-btn.is-spotify    { background: #1db954; }  /* Spotify Green */
.tip-play-btn.is-youtube    { background: #ff0000; }  /* YouTube Red */
.tip-play-btn::before { content: none; }  /* ▶ 不使用 */

/* ============================================================
   プレーヤー本体 — 共通ベース
   ============================================================ */
.tplayer {
  position: fixed;
  z-index: 10000;
  background: #111;
  box-shadow: 0 -6px 24px rgba(0,0,0,0.6);
  display: none;
  font-family: -apple-system, "Helvetica Neue", sans-serif;
  color: #fff;
  transition: transform 0.3s ease;
}
.tplayer.is-active { display: flex; }

.tplayer-media {
  flex-shrink: 0;
  background: #000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: width 0.25s, height 0.25s;
}
.tplayer-media iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

.tplayer-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.tplayer-title {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}
.tplayer-artist {
  font-size: 11px;
  color: #999;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tplayer-source {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-top: 4px;
  padding: 3px 8px;
  border-radius: 8px;
  background: #2a2a2a;
  color: #ccc;
  width: fit-content;
}
.tplayer.is-applemusic .tplayer-source { background: #fa243c; color: #fff; }
.tplayer.is-spotify    .tplayer-source { background: #1db954; color: #fff; }
.tplayer.is-youtube    .tplayer-source { background: #ff0000; color: #fff; }

.tplayer-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ── ドラッグハンドル (PCのみ・視覚的シグナル) ── */
.tplayer-drag {
  display: none;  /* スマホでは非表示。PC側メディアクエリで表示 */
  font-size: 16px;
  color: #888;
  padding: 4px 8px;
  user-select: none;
  line-height: 1;
  letter-spacing: -2px;
  transition: color 0.15s;
  pointer-events: none; /* 親(.tplayer-controls) がドラッグハンドルなのでイベントは透過 */
}
.tplayer.is-dragging { transition: none !important; }

/* ── ドラッグ中の全画面オーバーレイ ──
   iframe を含むあらゆる場所での mouseup/touchend を確実に拾うため */
.tplayer-drag-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 10002;          /* .tplayer (10000) より上 */
  background: transparent;
  cursor: grabbing;
  /* タッチ動作を完全に取得 */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

/* ── 初回案内ツールチップ ── */
.tplayer-tip {
  position: absolute;
  top: 44px;
  left: 14px;
  background: #fc3c44;
  color: #fff;
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.3s, transform 0.3s;
  z-index: 10001;
  box-shadow: 0 4px 14px rgba(252,60,68,0.4);
}
.tplayer-tip.is-visible { opacity: 1; transform: translateY(0); }
.tplayer-tip::before {
  content: '';
  position: absolute;
  top: -5px;
  left: 14px;
  border: 5px solid transparent;
  border-bottom-color: #fc3c44;
  border-top: 0;
}

/* ── サイズ切替ボタン群 (PCのみ) ── */
.tplayer-sizes {
  display: none;  /* スマホでは非表示。PC側メディアクエリで表示 */
  gap: 2px;
  background: #1a1a1a;
  border-radius: 6px;
  padding: 2px;
  margin-right: 4px;
}
.tplayer-size-btn {
  width: 24px;
  height: 22px;
  border: none;
  background: transparent;
  color: #999;
  font-size: 10px;
  cursor: pointer;
  border-radius: 4px;
  font-family: inherit;
  padding: 0;
  transition: background 0.15s, color 0.15s;
}
.tplayer-size-btn:hover { color: #fff; background: #2a2a2a; }
.tplayer.is-size-small  .tplayer-size-btn[data-size="small"],
.tplayer.is-size-medium .tplayer-size-btn[data-size="medium"],
.tplayer.is-size-large  .tplayer-size-btn[data-size="large"] {
  background: #fc3c44;
  color: #fff;
}
.tplayer-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #2a2a2a;
  border: none;
  color: #ccc;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
  padding: 0;
}
.tplayer-btn:hover { background: #fc3c44; color: #fff; }
.tplayer-btn .icon-collapse { display: inline; }
.tplayer-btn .icon-expand   { display: none; }
.tplayer.is-collapsed .tplayer-btn .icon-collapse { display: none; }
.tplayer.is-collapsed .tplayer-btn .icon-expand   { display: inline; }

/* ============================================================
   スマホ: 下部固定バー (案A)
   ・狭い画面 OR タッチ専用デバイス (iPhoneを横向きにしてもスマホUIを維持)
   ============================================================ */
@media (max-width: 599px), (hover: none) and (pointer: coarse) {
  .tplayer {
    left: 0;
    right: 0;
    bottom: 0;
    border-top: 2px solid #fc3c44;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0;
    gap: 0;
    align-items: stretch;
    transform: translateY(100%);
  }
  .tplayer.is-visible { transform: translateY(0); }

  /* 上段: メディア横幅いっぱい */
  .tplayer-media {
    flex: 0 0 100%;
    width: 100%;
    border-radius: 0;
  }
  .tplayer.is-youtube    .tplayer-media { height: calc(100vw * 9 / 16); max-height: 240px; }
  .tplayer.is-applemusic .tplayer-media { height: 200px; }
  .tplayer.is-spotify    .tplayer-media { height: 152px; }

  /* 下段: info(左) + controls(右) */
  .tplayer-info {
    flex: 1 1 0;
    padding: 8px 10px;
  }
  .tplayer-controls {
    padding: 6px 10px;
    gap: 8px;
  }

  /* 折りたたみ時: 再生を止めずに視覚的にだけ隠す */
  .tplayer.is-collapsed .tplayer-media { height: 0 !important; }

  .tplayer-title  { font-size: 13px; }
  .tplayer-source { display: inline-block; }
  .tplayer-btn    { width: 36px; height: 36px; font-size: 14px; }
}

/* ============================================================
   PC: 右下フローティングウィンドウ (案P3 + 案1サイズ + 案2ドラッグ)
   ・サイズ切替: 小 / 中 / 大
   ・ドラッグで自由配置
   ・▼で最小化 (再生継続)
   ・マウス操作デバイス限定 (タッチデバイスは横画面でもスマホUI維持)
   ============================================================ */
@media (min-width: 600px) and (hover: hover) and (pointer: fine) {
  .tplayer {
    right: 20px;
    bottom: 20px;
    top: auto;
    left: auto;
    /* width はサイズクラスで設定 */
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
    border: 2px solid #fc3c44;
    border-radius: 10px;
    box-shadow: 0 10px 36px rgba(0,0,0,0.7);
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    transform: translateY(20px);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease, width 0.25s ease;
  }
  .tplayer.is-visible {
    transform: translateY(0);
    opacity: 1;
  }

  /* ドラッグハンドルとサイズボタンをPCで表示 */
  .tplayer-drag  { display: inline-block; margin-right: auto; }
  .tplayer-sizes { display: inline-flex; }

  /* 上段: コントロール (⠿ サイズ ▼ ×) — エリア全体がドラッグハンドル */
  .tplayer-controls {
    order: 0;
    justify-content: flex-end;
    padding: 8px 10px 4px;
    gap: 6px;
    cursor: grab;
  }
  .tplayer.is-dragging .tplayer-controls { cursor: grabbing; }
  /* ボタン上ではドラッグカーソルを出さない (誤認識防止) */
  .tplayer-controls .tplayer-btn,
  .tplayer-controls .tplayer-size-btn { cursor: pointer; }

  /* メディア — パネル幅いっぱい (16:9や標準サイズ) */
  .tplayer-media {
    order: 1;
    width: 100%;
    border-radius: 0;
    transition: height 0.25s ease;
  }

  /* 下段: 曲情報 */
  .tplayer-info {
    order: 2;
    padding: 12px 18px 16px;
    flex: 0 0 auto;
  }
  .tplayer-title { font-size: 14px; white-space: normal; line-height: 1.3; }
  .tplayer-source { font-size: 10px; padding: 4px 10px; margin-top: 8px; }

  .tplayer-btn { width: 30px; height: 30px; font-size: 12px; }

  /* ── サイズ別: 幅とメディア高さ ── */
  /* 小 (デフォルト) */
  .tplayer.is-size-small  { width: 420px; }
  .tplayer.is-size-small.is-youtube    .tplayer-media { height: calc(420px * 9 / 16); }  /* ≈236px */
  .tplayer.is-size-small.is-applemusic .tplayer-media { height: 175px; }
  .tplayer.is-size-small.is-spotify    .tplayer-media { height: 152px; }

  /* 中 */
  .tplayer.is-size-medium { width: 600px; }
  .tplayer.is-size-medium.is-youtube    .tplayer-media { height: calc(600px * 9 / 16); }  /* ≈338px */
  .tplayer.is-size-medium.is-applemusic .tplayer-media { height: 450px; }
  .tplayer.is-size-medium.is-spotify    .tplayer-media { height: 352px; }

  /* 大 (画面幅の50%) */
  .tplayer.is-size-large  { width: 50vw; }
  .tplayer.is-size-large.is-youtube    .tplayer-media { height: calc(50vw * 9 / 16); max-height: 70vh; }
  .tplayer.is-size-large.is-applemusic .tplayer-media { height: 450px; max-height: 70vh; }
  .tplayer.is-size-large.is-spotify    .tplayer-media { height: 352px; max-height: 70vh; }

  /* ── 最小化状態: タイトルバーのみ表示 ── */
  /* iframe を残したまま視覚的にだけ隠す → 再生継続 */
  .tplayer.is-collapsed .tplayer-media {
    height: 0 !important;
  }
  .tplayer.is-collapsed .tplayer-controls {
    padding: 6px 10px;
  }
  .tplayer.is-collapsed .tplayer-info {
    padding: 6px 14px 8px;
  }
  .tplayer.is-collapsed .tplayer-title { font-size: 12px; margin-bottom: 2px; }
  .tplayer.is-collapsed .tplayer-source { display: none; }
}

/* ============================================================
   クリエイターページ: Apple Musicプレイリスト埋め込みプレーヤー
   ============================================================ */
.creator-am-player {
  padding: 0 30px 30px;
}
.creator-am-player iframe {
  width: 100%;
  border-radius: 10px;
  display: block;
  border: 0;
}
@media screen and (max-width: 600px) {
  .creator-am-player {
    padding: 0 15px 20px;
  }
}

/* ============================================================
   曲リスト（PICK UP など）：プレーヤーの上にくっつくパネル
   ============================================================ */
.tplayer-btn-list { display: none; font-size: 16px; }
.tplayer.has-list .tplayer-btn-list { display: inline-flex; align-items: center; justify-content: center; }
.tplayer.is-list-open .tplayer-btn-list { color: #fa243c; }
.tplayer-list {
  display: none; position: fixed; z-index: 10001;
  max-height: min(300px, 45vh); overflow-y: auto; background: #111; color: #fff;
  font-family: -apple-system, "Helvetica Neue", sans-serif;
  border-radius: 8px 8px 0 0; box-shadow: 0 -8px 20px rgba(0,0,0,0.35);
  overscroll-behavior: contain;
}
.tplayer-list.is-open { display: block; }
.tplayer-list.is-below { border-radius: 0 0 8px 8px; box-shadow: 0 8px 20px rgba(0,0,0,0.35); }
.tplayer-list.is-side  { border-radius: 8px; box-shadow: 0 6px 24px rgba(0,0,0,0.45); }
.tplayer-list-head {
  position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; gap: 10px;
  padding: 10px 14px; background: #111; border-bottom: 1px solid #262626;
  font-size: 11px; letter-spacing: 0.08em; color: #aaa;
}
.tplayer-list-row { display: flex; align-items: center; gap: 10px; padding: 7px 14px; cursor: pointer; transition: background-color .15s ease; }
.tplayer-list-row:hover { background: #1c1d20; }
.tplayer-list-row.is-now { background: #26282b; box-shadow: inset 3px 0 0 #fa243c; }
.tplayer-list-row img, .tplayer-list-row i { width: 36px; height: 36px; border-radius: 3px; object-fit: cover; flex-shrink: 0; background: #333; }
.tplayer-list-txt { min-width: 0; }
.tplayer-list-name, .tplayer-list-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tplayer-list-name { font-size: 12.5px; color: #fff; }
.tplayer-list-sub  { font-size: 11px; color: #999; margin-top: 2px; }
@media screen and (max-width: 600px) {
  .tplayer-list { max-height: 35vh; }
}

/* ============================================================
   PC：プレーヤー全体を縮小（--tp-s で倍率を指定・大中小とも同じ比率）
   外枠のサイズは実寸で小さくし、埋め込み（Apple Music等）は本来の大きさで描いて
   見た目だけ縮小する → 中身が切れず、ドラッグや画面端の補正もそのまま動く
   ============================================================ */
@media (min-width: 600px) and (hover: hover) and (pointer: fine) {
  .tplayer { --tp-s: 0.85; }

  .tplayer.is-size-small  { width: calc(420px * var(--tp-s)); }
  .tplayer.is-size-small.is-youtube    .tplayer-media { height: calc(420px * 9 / 16 * var(--tp-s)); }
  .tplayer.is-size-small.is-applemusic .tplayer-media { height: calc(175px * var(--tp-s)); }
  .tplayer.is-size-small.is-spotify    .tplayer-media { height: calc(152px * var(--tp-s)); }

  .tplayer.is-size-medium { width: calc(600px * var(--tp-s)); }
  .tplayer.is-size-medium.is-youtube    .tplayer-media { height: calc(600px * 9 / 16 * var(--tp-s)); }
  .tplayer.is-size-medium.is-applemusic .tplayer-media { height: calc(450px * var(--tp-s)); }
  .tplayer.is-size-medium.is-spotify    .tplayer-media { height: calc(352px * var(--tp-s)); }

  .tplayer.is-size-large  { width: calc(50vw * var(--tp-s)); }
  .tplayer.is-size-large.is-youtube    .tplayer-media { height: calc(50vw * 9 / 16 * var(--tp-s)); }
  .tplayer.is-size-large.is-applemusic .tplayer-media { height: calc(450px * var(--tp-s)); }
  .tplayer.is-size-large.is-spotify    .tplayer-media { height: calc(352px * var(--tp-s)); }

  .tplayer-media { position: relative; }
  .tplayer-media iframe {
    position: absolute; left: 0; top: 0;
    width: calc(100% / var(--tp-s)) !important; height: calc(100% / var(--tp-s)) !important;
    transform: scale(var(--tp-s)); transform-origin: 0 0;
  }
  /* 上段（ボタン）・下段（曲名）も同じ比率で縮小 */
  .tplayer-controls, .tplayer-info { zoom: var(--tp-s); }
}

/* ============================================================
   ミニプレーヤー：Spotify・YouTube の曲を最小化したとき
   （曲名の下に 再生/停止・再生位置・シークバー だけを表示）
   ============================================================ */
.tplayer-mini { display: none; align-items: center; gap: 8px; margin-top: 6px; }
.tplayer.is-collapsed.is-controllable .tplayer-mini { display: flex; }
.tplayer-mini-play {
  flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; border: 0; cursor: pointer;
  background: #fa243c; color: #fff; font-size: 11px; line-height: 1; display: flex; align-items: center; justify-content: center; padding: 0;
}
.tplayer-mini-time, .tplayer-mini-dur { flex-shrink: 0; font-size: 10px; color: #aaa; font-variant-numeric: tabular-nums; min-width: 28px; }
.tplayer-mini-dur { text-align: right; }
.tplayer-mini-seek { flex: 1; min-width: 0; height: 4px; accent-color: #fa243c; cursor: pointer; }

/* API で埋め込んだ iframe（Spotify・YouTube）も枠いっぱいに */
.tplayer-media > div { width: 100%; height: 100%; }

/* Apple Music の曲単体は、中・大でも高さを曲用の埋め込み（175px）にする
   （アルバム用の 450px だと下が黒い余白だらけになるため。幅は各サイズのまま） */
@media (min-width: 600px) and (hover: hover) and (pointer: fine) {
  .tplayer.is-size-medium.is-applemusic.is-am-track .tplayer-media,
  .tplayer.is-size-large.is-applemusic.is-am-track  .tplayer-media { height: calc(175px * var(--tp-s)); }
}

/* ページを開いた時の演出：曲リストがふわっと畳まれる → ≡ボタンが5回光る */
.tplayer-list.is-open { transition: opacity .3s ease, transform .3s ease; }
.tplayer-list.is-folding { opacity: 0; transform: translateY(12px) scale(0.98); }
.tplayer-btn-list.is-hint { animation: tplayer-hint 1.1s ease-out 8; }  /* 8回光る */
@keyframes tplayer-hint {
  0%   { box-shadow: 0 0 0 0 rgba(250,36,60,0.75); color: #fff; background: #fa243c; }
  70%  { box-shadow: 0 0 0 10px rgba(250,36,60,0); }
  100% { box-shadow: 0 0 0 0 rgba(250,36,60,0); }
}

/* ============================================================
   プレーヤーを「掴んで動かせる」ことを分かりやすく（PCのみ・2026-09-28）
   ============================================================ */
.tplayer-grabber { display: none; }
.tplayer-grip, .tplayer-drag-label { display: none; }
@media (min-width: 600px) and (hover: hover) and (pointer: fine) {
  /* 上端中央のつまみ（iPhoneのシートと同じ形） */
  .tplayer-grabber {
    display: block; position: absolute; top: 5px; left: 50%; transform: translateX(-50%);
    width: 40px; height: 4px; border-radius: 2px; background: #4a4a4a; z-index: 2; pointer-events: none;
    transition: background-color .2s ease, width .2s ease;
  }
  .tplayer-controls { padding-top: 13px !important; transition: background-color .2s ease; }
  /* マウスを乗せると上部が明るくなり、つまみ・文字が浮かび上がる */
  .tplayer-controls:hover { background: #1c1c1f; }
  .tplayer:has(.tplayer-controls:hover) .tplayer-grabber { background: #9a9a9a; width: 52px; }
  .tplayer-drag { display: inline-flex !important; align-items: center; gap: 7px; letter-spacing: 0; padding: 4px 6px; color: #777; }
  .tplayer-controls:hover .tplayer-drag { color: #ddd; }
  /* 6点のつまみマーク */
  .tplayer-grip {
    display: inline-block; width: 10px; height: 16px; flex-shrink: 0;
    background-image: radial-gradient(circle, currentColor 1.4px, transparent 1.6px);
    background-size: 5px 5.5px; background-position: 0 0;
  }
  .tplayer-drag-label {
    display: inline-block; font-size: 11px; letter-spacing: 0.04em; white-space: nowrap;
    opacity: 0; transform: translateX(-4px); transition: opacity .2s ease, transform .2s ease;
  }
  .tplayer-controls:hover .tplayer-drag-label { opacity: 1; transform: translateX(0); }
  .tplayer.is-dragging .tplayer-drag-label { opacity: 1; }
  /* 最初の1回だけ：左右に小さく揺れる */
  .tplayer.is-nudge { animation: tplayer-nudge 1.2s ease-in-out 1; }
  @keyframes tplayer-nudge {
    0%, 100% { translate: 0 0; }
    15% { translate: -9px 0; } 35% { translate: 7px 0; } 55% { translate: -4px 0; } 75% { translate: 2px 0; }
  }
  .tplayer-tip { top: 50px; }
  .tplayer-tip::before { left: 22px; }
}
