/* SWELL既存のページトップボタンを無効化（UI触らずに併存回避）
   既にUIでOFFなら、この行は消してOK */
.c-pageTop,
.p-fixBtn__totop,
.pagetop,
.l-fixBtn .c-btn--pagetop {
  display: none !important;
}

/* カスタム：フラット四角 */
.tdc-pagetop {
  --tdc-size: 50px;
  /* 変数初期値 */
  --tdc-ty: 8px;
  /* 出現アニメ用の下方向 */
  --tdc-jx: 0px;
  /* クリック中の左右ジッター */
  --tdc-rot: 0deg;
  /* クリック中の回転 */

  position: fixed;
  right: clamp(12px, 2vw, 20px);
  bottom: calc(50px + env(safe-area-inset-bottom));
  /* iOSセーフエリア */
  z-index: 10000;

  inline-size: var(--tdc-size);
  block-size: var(--tdc-size);
  display: grid;
  place-items: center;
  padding: 0;

  border: 1px solid var(--swell-color_border, #e5e5e5);
  background: var(--swell-color_bg, #fff);
  color: var(--swell-color_text, #222);
  border-radius: 20px;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: .02em;

  /* インタラクション */
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  backface-visibility: hidden;

  /* ふわっと出現 */
  opacity: 0;
  /* transform は変数で合成（出現TY × クリック時JX/ROT）*/
  transform: translateY(var(--tdc-ty)) translateX(var(--tdc-jx)) rotate(var(--tdc-rot));
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}


/* 表示状態はそのまま */
.tdc-pagetop.is-show {
  opacity: 1;
  --tdc-ty: 0px;
  pointer-events: auto;
}


/* 表示状態：変数だけを更新（transformを直接上書きしない） */
.tdc-pagetop.is-show {
  opacity: 1;
  --tdc-ty: 0px;
  pointer-events: auto;
}

/* “ふわふわ”小さめモーション（主張控えめ）*/
@keyframes tdc-floaty {
  0% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-3px);
  }

  100% {
    transform: translateY(0);
  }
}

.tdc-pagetop.is-show .tdc-pagetop__label {
  animation: tdc-floaty 2.6s ease-in-out infinite;
}

/* クリック中（回転中）はふわふわ停止＆rAF制御に最適化 */
.tdc-pagetop.is-animating .tdc-pagetop__label {
  animation: none;
  /* 既存のふわふわを止める */
}

.tdc-pagetop.is-animating {
  will-change: transform;
  transition: opacity .25s ease, transform 0s linear;
  /* rAFのtransform更新に遅延を入れない */
}

/* ラベル（フラットに「TOP」）*/
.tdc-pagetop__label {
  font-size: 14px;
  font-weight: bold;
  line-height: 1;
}

/* スマホ：下部UIを避けて +80px */
@media (max-width: 767px) {
  .tdc-pagetop {
    bottom: calc(20px + 12px + env(safe-area-inset-bottom));
  }
}

/* キーボード操作の可視化 */
.tdc-pagetop:focus-visible {
  outline: 2px solid #000;
  outline-offset: 3px;
}

/* 省モーション対応 */
@media (prefers-reduced-motion: reduce) {
  .tdc-pagetop {
    transition: none;
  }

  .tdc-pagetop__label {
    animation: none;
  }
}

.tdc-pagetop__label .c1 {
  color: #1e73be;
}

.tdc-pagetop__label .c2 {
  color: #f74a4a;
}

.tdc-pagetop__label .c3 {
  color: #81d742;
}