/* ========================================
   右下角浮動聯絡按鈕（inc/floating-contact.php）
   主題配色：主色 #5a8a94、強調 #d77350、深色 #3a3f3b
   ======================================== */
.fc {
  --fc-size: 48px;
  --fc-gap: 10px;
  --fc-step: calc(var(--fc-size) + var(--fc-gap));
  --fc-teal: #5a8a94;
  --fc-teal-dark: #4a7780;
  --fc-ink: #3a3f3b;
  --fc-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --fc-ease-spring: cubic-bezier(0.34, 1.45, 0.64, 1);
  --fc-ease-in: cubic-bezier(0.4, 0, 0.2, 1);

  position: fixed;
  right: 20px;
  bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  /* 低於頁首（1000）、手機選單與搜尋遮罩（1100）：打開選單時不會壓在選單上面 */
  z-index: 900;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--fc-gap);
  /* 容器本身不擋點擊，只有按鈕可以點 —— 收合後空出來的區域不會擋住頁面內容 */
  pointer-events: none;
}

.fc__items {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--fc-gap);
}

/* ---------- 按鈕 ---------- */
.fc__btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--fc-size);
  height: var(--fc-size);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #fff;
  color: var(--fc-teal);
  box-shadow: 0 4px 14px rgba(58, 63, 59, 0.16), 0 1px 3px rgba(58, 63, 59, 0.12);
  cursor: pointer;
  text-decoration: none;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.25s var(--fc-ease-out);
}

.fc__icon {
  display: block;
  width: 24px;
  height: 24px;
}

.fc__btn--line .fc__icon {
  width: 28px;
  height: 28px;
}

/* LINE 圖示裡的字跟按鈕底色相反 */
.fc__line-text {
  fill: #fff;
  transition: fill 0.2s ease;
}

.fc__btn:focus-visible {
  outline: 3px solid rgba(90, 138, 148, 0.45);
  outline-offset: 3px;
}

.fc__btn:active {
  transform: scale(0.94);
}

@media (hover: hover) {
  .fc__btn:hover {
    background: var(--fc-teal);
    color: #fff;
    box-shadow: 0 8px 20px rgba(90, 138, 148, 0.32), 0 2px 4px rgba(58, 63, 59, 0.12);
    transform: translateY(-2px);
  }

  .fc__btn:hover .fc__line-text {
    fill: var(--fc-teal);
  }
}

/* 展開／收合鈕：主色實心，視覺上是這組按鈕的「主按鈕」 */
.fc__btn--toggle {
  background: var(--fc-teal);
  color: #fff;
  box-shadow: 0 6px 18px rgba(90, 138, 148, 0.38), 0 1px 3px rgba(58, 63, 59, 0.14);
}

@media (hover: hover) {
  .fc__btn--toggle:hover {
    background: var(--fc-teal-dark);
  }
}

/* 圖示交叉淡入＋旋轉：耳機 ↔ ✕ */
.fc__toggle-open,
.fc__toggle-close {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  overflow: hidden;
  transition:
    opacity 0.22s ease,
    transform 0.4s var(--fc-ease-out);
}

.fc[data-open="true"] .fc__toggle-open,
.fc:not([data-open]) .fc__toggle-open {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

.fc[data-open="false"] .fc__toggle-close {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

/* 後台上傳的自訂圖示：填滿整顆按鈕 */
.fc__btn--custom {
  overflow: hidden;
  background: transparent;
}

.fc__img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

/* ---------- 桌機 hover 提示文字 ---------- */
.fc__tip {
  position: absolute;
  top: 50%;
  right: calc(100% + 12px);
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 4px 14px rgba(58, 63, 59, 0.14);
  font-family: 'Noto Sans TC', sans-serif;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--fc-ink);
  white-space: nowrap;
  opacity: 0;
  transform: translate(6px, -50%);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.25s var(--fc-ease-out);
}

@media (hover: hover) {
  .fc__btn:hover .fc__tip,
  .fc__btn:focus-visible .fc__tip {
    opacity: 1;
    transform: translate(0, -50%);
  }
}

@media (hover: none) {
  .fc__tip {
    display: none;
  }
}

/* 客服鈕展開時是 ✕，這時不顯示「聯絡我們」之類的提示 */
.fc[data-open="true"] .fc__btn--toggle .fc__tip,
.fc:not([data-open]) .fc__btn--toggle .fc__tip {
  display: none;
}

/* ---------- 展開／收合動畫 ----------
   每顆按鈕各自往展開鈕的位置縮回去（--fc-d：離展開鈕幾格），不是整排淡出；
   只用 transform／opacity，不動版面高度，所以不會卡頓也不會推擠其他元素。 */
.fc--has-toggle .fc__btn--item {
  transition:
    opacity 0.2s ease,
    transform 0.42s var(--fc-ease-spring),
    visibility 0s linear 0s,
    background-color 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease;
}

/* 展開：離展開鈕近的先出來，由下往上依序彈出 */
.fc--has-toggle.fc--animating[data-open="true"] .fc__btn--item {
  transition-delay: calc((var(--fc-d) - 1) * 45ms), calc((var(--fc-d) - 1) * 45ms), 0s, 0s, 0s, 0s;
}

/* 收合狀態 */
.fc--has-toggle[data-open="false"] .fc__btn--item {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(calc(var(--fc-d) * var(--fc-step))) scale(0.4);
  transition:
    opacity 0.18s ease,
    transform 0.32s var(--fc-ease-in),
    visibility 0s linear 0.32s,
    background-color 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease;
}

/* 收合：離展開鈕遠的先收，由上往下依序收進去 */
.fc--has-toggle.fc--animating[data-open="false"] .fc__btn--item {
  transition-delay:
    calc((var(--fc-count) - var(--fc-d)) * 35ms),
    calc((var(--fc-count) - var(--fc-d)) * 35ms),
    calc(0.32s + (var(--fc-count) - var(--fc-d)) * 35ms),
    0s, 0s, 0s;
}

/* ---------- 回到頂端：捲動一段距離才出現 ----------
   沒出現時用負的 margin 把自己疊到展開鈕底下，整組按鈕不會多空一格；
   出現時 margin 回正，上面的按鈕會平順地往上讓位。 */
.fc__btn--top {
  margin-top: calc(-1 * var(--fc-step));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(0.6);
  transition:
    margin-top 0.35s var(--fc-ease-out),
    opacity 0.2s ease,
    transform 0.35s var(--fc-ease-out),
    visibility 0s linear 0.35s,
    background-color 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease;
}

.fc.is-scrolled .fc__btn--top {
  margin-top: 0;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
  transition:
    margin-top 0.35s var(--fc-ease-out),
    opacity 0.25s ease 0.05s,
    transform 0.4s var(--fc-ease-spring) 0.05s,
    visibility 0s,
    background-color 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease;
}

/* 其他按鈕全部停用、只剩置頂鈕時，沒有東西需要讓位 */
.fc > .fc__btn--top:first-child {
  margin-top: 0;
}

/* ---------- 手機 ---------- */
@media (max-width: 768px) {
  .fc {
    --fc-size: 42px;
    --fc-gap: 8px;

    right: 12px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .fc__icon {
    width: 21px;
    height: 21px;
  }

  .fc__btn--line .fc__icon {
    width: 25px;
    height: 25px;
  }

  /* 手機預設收合（JS 還沒執行前也先收好，不會閃一下展開再收起來） */
  .fc--has-toggle:not([data-open]) .fc__btn--item {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(calc(var(--fc-d) * var(--fc-step))) scale(0.4);
  }

  .fc:not([data-open]) .fc__toggle-open {
    opacity: 1;
    transform: none;
  }

  .fc:not([data-open]) .fc__toggle-close {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
  }
}

/* 使用者在系統設定「減少動態效果」：直接切換，不做動畫 */
@media (prefers-reduced-motion: reduce) {
  .fc,
  .fc * {
    transition-duration: 0.01ms !important;
    transition-delay: 0s !important;
  }
}

@media print {
  .fc {
    display: none !important;
  }
}
