/* =========================================================
   Bloomy Floating TOC — スマホ記事の追従目次（右下フロート）
   2026-06-23 新規。記事(post)ページのみ読み込み。
   スマホ(<=900px)のみ表示。PCは既存の追従サイドバー(.bloomy-toc)を使う。
   既存の本文内目次(.bloomy-toc)はスマホでは非表示にして置換（削除はしない＝表示条件で調整）。
========================================================= */

/* 既定は非表示（PC含む）。スマホでだけ出す。 */
.bloomy-ftoc,
.bloomy-ftoc-panel { display: none; }

@media (max-width: 900px) {

  /* 既存の本文内目次はフロートに置き換えるため非表示（PCサイドバーは温存） */
  .post_content .bloomy-toc { display: none !important; }

  /* 見出しが固定ヘッダーに隠れないように */
  .post_content h2[id] { scroll-margin-top: 90px; }

  /* ---- フロート目次ボタン ---- */
  .bloomy-ftoc {
    display: inline-flex; align-items: center; gap: 6px;
    position: fixed; right: 16px;
    bottom: calc(50px + env(safe-area-inset-bottom));
    z-index: 1080;
    min-height: 58px; padding: 0 20px;
    background: #fff; color: #15315f;
    border: 1px solid rgba(210,225,255,.9);
    box-shadow: 0 10px 30px rgba(20,40,80,.14);
    border-radius: 999px;
    font-size: 16.5px; font-weight: 700; line-height: 1;
    cursor: pointer; -webkit-tap-highlight-color: transparent;
    transition: transform .15s ease, box-shadow .2s ease;
  }
  .bloomy-ftoc:active { transform: scale(.96); }
  .bloomy-ftoc__icon { width: 20px; height: 20px; flex: none; color: #2F6BFF; }
  .bloomy-ftoc[aria-expanded="true"] { box-shadow: 0 6px 18px rgba(20,40,80,.12); }

  /* ---- フロート目次パネル ---- */
  .bloomy-ftoc-panel {
    display: none; flex-direction: column;
    position: fixed; right: 16px;
    bottom: calc(112px + env(safe-area-inset-bottom));
    z-index: 1090;
    width: min(300px, calc(100vw - 32px));
    max-height: 45vh;
    background: rgba(255,255,255,.92);
    -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
    border: 1px solid rgba(210,225,255,.9);
    box-shadow: 0 16px 40px rgba(20,40,80,.16);
    border-radius: 20px; overflow: hidden;
    opacity: 0; transform: translateY(12px) scale(.98);
    transition: opacity .2s ease, transform .22s cubic-bezier(.22,1,.36,1);
    pointer-events: none;
  }
  .bloomy-ftoc-panel.is-open {
    display: flex; opacity: 1; transform: none; pointer-events: auto;
  }

  .bloomy-ftoc-panel__head {
    flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
    gap: 8px; padding: 11px 8px 9px 16px;
    border-bottom: 1px solid rgba(210,225,255,.55);
  }
  .bloomy-ftoc-panel__title { font-size: 12.5px; font-weight: 800; color: #15315f; letter-spacing: .01em; }
  .bloomy-ftoc-panel__close {
    flex: none; width: 34px; height: 34px; border: 0; background: none;
    color: #5b6b86; font-size: 21px; line-height: 1; cursor: pointer; border-radius: 50%;
    -webkit-tap-highlight-color: transparent;
  }
  .bloomy-ftoc-panel__close:active { background: rgba(47,107,255,.08); }

  .bloomy-ftoc-panel__list {
    flex: 1 1 auto; overflow-y: auto; -webkit-overflow-scrolling: touch;
    list-style: none; margin: 0; padding: 6px; overscroll-behavior: contain;
  }
  .bloomy-ftoc-panel__item { margin: 0; }
  .bloomy-ftoc-panel__link {
    position: relative;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    min-height: 44px; box-sizing: border-box; padding: 11px 12px 11px 14px;
    font-size: 13.5px; line-height: 1.45; color: #5B6B84;
    text-decoration: none; border-radius: 8px;
    -webkit-tap-highlight-color: transparent;
    transition: background .15s ease, color .15s ease;
  }
  /* 非アクティブ：hover/focus時だけごく薄い背景（アクティブとは競合させない） */
  .bloomy-ftoc-panel__link:hover:not(.is-active),
  .bloomy-ftoc-panel__link:focus-visible:not(.is-active) {
    background: rgba(47,107,255,.045);
    color: #3f4d62;
  }
  /* アクティブ＝現在地マーカー。柔らかい角丸＋左→右へ淡く消えるグラデ＋短く丸い縦ライン(::before)で、
     カード/ボタンに見せず、でも一目で現在地が分かる“洗練と柔らかさの中間”に。 */
  .bloomy-ftoc-panel__link.is-active {
    background: linear-gradient(90deg,
      rgba(47,107,255,.075) 0%,
      rgba(47,107,255,.035) 52%,
      rgba(47,107,255,0) 100%);
    border-radius: 10px;
    color: #102A5C; font-weight: 600;
  }
  .bloomy-ftoc-panel__link.is-active::before {
    content: ""; position: absolute; left: 0; top: 9px; bottom: 9px;
    width: 2px; border-radius: 999px; background: rgba(47,107,255,.85);
  }
  /* 目次移動中はヘッダーを抑制（上スクロールで出てきて見出しを隠すのを防ぐ）2026-06-23 */
  html.bloomy-ftoc-nav .site-header {
    transform: translateY(-150%) !important; transition: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bloomy-ftoc, .bloomy-ftoc-panel, .bloomy-ftoc-panel__link { transition: none !important; }
}
