/* ==========================================================================
   左下に常駐させる縦型動画
   ==========================================================================

   全部 .tw8m の中に閉じ込めてある（chat の .tw8c と同じ作法）。
   DOM は assets/js/short-movie.js が組み立てる。クラス名を変えるときは両方直すこと。

   幅で形が変わる。
   　　768px以上 … スマホ枠の小窓（ミュート・ループ。2本を交互に）
   　　768px未満 … 丸いサムネのアイコンだけ。動画はタップされるまで読まない
   どちらもタップで拡大画面（音声つき・予約ボタンつき）を開く。

   **左下に置く。** 右下はチャット（.tw8c-launcher）とページトップ（#page-top-btn）が使っている。
   トップの1280px未満は下端を固定CTAバーが占めるので、その上へ上げる上書きは
   front-top.css にある（バーがあるのはトップだけ）。

   font-size の下限は 16px（1rem）。tests/test-short-movie.php が走査して落とす。
   ========================================================================== */

.tw8m {
  --tw8m-brand: #0075c2;
  --tw8m-brand-dark: #005b96;
  --tw8m-ink: #0f172a;
  --tw8m-gap: 1.5rem;

  font-size: 1rem;
  line-height: 1.6;
}

.tw8m[hidden],
.tw8m [hidden] {
  display: none !important;
}

.tw8m button {
  font: inherit;
  cursor: pointer;
}

.tw8m button:focus-visible {
  outline: 3px solid var(--tw8m-brand-dark);
  outline-offset: 3px;
}

/* ---------------------------------------------------------------- 常駐する器 */

.tw8m-dock {
  position: fixed;
  left: var(--tw8m-gap);
  bottom: calc(var(--tw8m-gap) + env(safe-area-inset-bottom));
  z-index: 44;
  animation: tw8m-in 0.4s ease both;
}

@keyframes tw8m-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

/* 閉じるボタン（小窓・アイコン共通）。押せる大きさは 32px 確保する */
.tw8m-dismiss {
  position: absolute;
  top: -0.75rem;
  right: -0.75rem;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 9999px;
  background: var(--tw8m-ink);
  color: #fff;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.3);
}

.tw8m-dismiss svg {
  width: 0.875rem;
  height: 0.875rem;
}

/* ---------------------------------------------------------------- PC・タブレット：スマホ枠の小窓 */

.tw8m-phone {
  position: relative;
  display: block;
  width: 8rem;
  aspect-ratio: 9 / 16;
  padding: 0;
  border: 5px solid var(--tw8m-ink);
  border-radius: 1.375rem;
  background: var(--tw8m-ink);
  overflow: hidden;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.3);
  transition: transform 0.2s ease;
}

.tw8m-phone:hover {
  transform: translateY(-3px);
}

.tw8m-phone video,
.tw8m-phone img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tw8m-icon {
  display: none;
}

/* ---------------------------------------------------------------- スマホ：丸いサムネのアイコン */

@media (max-width: 767px) {
  .tw8m { --tw8m-gap: 0.75rem; }

  .tw8m-phone { display: none; }

  .tw8m-icon {
    position: relative;
    display: block;
    width: 4rem;
    height: 4rem;
    padding: 0;
    border: 3px solid #fff;
    border-radius: 9999px;
    background: var(--tw8m-ink);
    box-shadow: 0 0 0 3px var(--tw8m-brand), 0 8px 20px rgba(15, 23, 42, 0.3);
    overflow: hidden;
  }

  .tw8m-icon img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 30%;
  }

  .tw8m-icon__play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.25);
    color: #fff;
  }

  .tw8m-icon__play svg {
    width: 1.5rem;
    height: 1.5rem;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
  }

  .tw8m-dock .tw8m-dismiss {
    top: -0.5rem;
    right: -0.75rem;
  }
}

/* ---------------------------------------------------------------- 拡大画面 */

.tw8m-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.82);
}

.tw8m-sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  /* 動画は 9:16。縦に収まる幅を先に決める（ボタン2つと「次の動画」と余白で 14rem を引く） */
  width: min(24rem, calc(100vw - 2rem), calc((100vh - 14rem) * 9 / 16));
  width: min(24rem, calc(100vw - 2rem), calc((100dvh - 14rem) * 9 / 16));
  min-width: 15rem;
}

.tw8m-sheet video {
  display: block;
  width: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 1rem;
  background: #000;
}

.tw8m-close {
  position: absolute;
  top: -0.75rem;
  right: -0.75rem;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 9999px;
  background: var(--tw8m-ink);
  color: #fff;
}

.tw8m-close svg {
  width: 1.125rem;
  height: 1.125rem;
}

.tw8m-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0.75rem 1rem;
  border-radius: 9999px;
  background: var(--tw8m-brand);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 8px 20px rgba(0, 117, 194, 0.35);
}

.tw8m-cta:hover {
  background: var(--tw8m-brand-dark);
  color: #fff;
}

/* 副ボタン（メール相談）。主ボタン（予約）より一段引く。暗い背景の上なので白の枠 */
.tw8m-cta--mail {
  border: 2px solid #fff;
  background: transparent;
  box-shadow: none;
}

.tw8m-cta--mail:hover {
  background: #fff;
  color: var(--tw8m-brand-dark);
}

.tw8m-cta:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.tw8m-next {
  align-self: center;
  padding: 0.25rem 0.75rem;
  border: 0;
  background: none;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* ---------------------------------------------------------------- 動きを減らす設定 */

@media (prefers-reduced-motion: reduce) {
  .tw8m-dock { animation: none; }
  .tw8m-phone { transition: none; }
}
