/* チュートリアル共通スタイル */

#dtf-tutorial-root {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
}

/* オーバーレイ */
.dtf-tutorial__overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 105;
  pointer-events: none;
}

#dtf-tutorial-root.active .dtf-tutorial__overlay {
  opacity: 1;
}

/* ハイライト */
.dtf-tutorial__highlight {
  position: absolute;
  border-radius: 8px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
  z-index: 106;
  transition: all 0.3s ease;
  pointer-events: none;
  display: none;
}

#dtf-tutorial-root.active .dtf-tutorial__highlight {
  display: block;
}

#dtf-tutorial-root:not(.active) .dtf-tutorial__highlight {
  display: none !important;
}

.dtf-tutorial__highlight-pulse {
  position: absolute;
  inset: -4px;
  border: 2px solid rgba(255, 208, 107, 0.8);
  border-radius: 10px;
  animation: dtf-tutorial-pulse 1.5s infinite;
  pointer-events: none;
}

@keyframes dtf-tutorial-pulse {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.08); opacity: 0; }
}

/* ピコ */
.dtf-tutorial__pico {
  position: fixed;
  width: 140px;
  height: 140px;
  background-repeat: no-repeat;
  background-size: 300% 300%;
  image-rendering: pixelated;
  z-index: 108;
  pointer-events: none;
  opacity: 0;
  display: none;
  transform: translateY(20px);
  transition: opacity 0.25s ease, transform 0.25s ease, left 0.25s ease, right 0.25s ease, bottom 0.25s ease, top 0.25s ease;
  /* 初期表示位置を左上に */
  bottom: 20px;
  left: 20px;
}

#dtf-tutorial-root.active .dtf-tutorial__pico {
  display: block;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#dtf-tutorial-root:not(.active) .dtf-tutorial__pico {
  display: none !important;
}

/* 吹き出し */
.dtf-tutorial__balloon {
  position: fixed;
  z-index: 109;
  width: 340px;
  height: auto;
  min-height: 120px;
  max-height: 170px;
  background: rgba(30, 35, 50, 0.98);
  border: 1px solid rgba(255, 208, 107, 0.35);
  border-radius: 14px;
  padding: 12px 16px;
  color: #fff;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  opacity: 0;
  display: none;
  transform: translateY(12px) scale(0.98);
  transition: opacity 0.25s ease, transform 0.25s ease;
  flex-direction: column;
  justify-content: space-between;
  box-sizing: border-box;
  pointer-events: none;
}

#dtf-tutorial-root.active .dtf-tutorial__balloon {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

#dtf-tutorial-root:not(.active) .dtf-tutorial__balloon {
  display: none !important;
}

/* 吹き出し内のボタンも確実にクリック可能 */
.dtf-tutorial__balloon-actions,
.dtf-tutorial__balloon-actions button {
  pointer-events: auto;
}

.dtf-tutorial__balloon-text {
  font-size: 13px;
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
}

@media (min-width: 641px) {
  .dtf-tutorial__balloon-text {
    font-size: 14px;
    line-height: 1.6;
    -webkit-line-clamp: 5;
  }
}

.dtf-tutorial__balloon-name {
  font-size: 12px;
  color: rgba(255, 208, 107, 0.85);
  margin-bottom: 4px;
  font-weight: 600;
  flex-shrink: 0;
}

.dtf-tutorial__balloon-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
  margin-top: 8px;
}

.dtf-tutorial__btn {
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.dtf-tutorial__btn:active {
  transform: scale(0.96);
}

.dtf-tutorial__btn-next {
  background: linear-gradient(135deg, rgba(255, 208, 107, 0.9), rgba(255, 178, 60, 0.9));
  color: #1a1510;
}

.dtf-tutorial__btn-skip {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
}

.dtf-tutorial__btn-skip:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* デスクトップ配置 */
@media (min-width: 641px) {
  .dtf-tutorial__pico {
    left: 16px;
    bottom: 16px;
    width: 170px;
    height: 170px;
  }

  .dtf-tutorial__pico.dtf-tutorial__pico--upper {
    bottom: auto;
    top: 16px;
  }

  .dtf-tutorial__balloon {
    left: 196px;
    bottom: 16px;
    width: 360px;
    height: auto;
    min-height: 150px;
    max-height: 190px;
  }

  .dtf-tutorial__balloon.dtf-tutorial__balloon--upper {
    bottom: auto;
    top: 16px;
  }
}

/* モバイル配置 */
@media (max-width: 640px) {
  .dtf-tutorial__pico {
    left: 8px;
    bottom: 8px;
    width: 100px;
    height: 100px;
  }

  .dtf-tutorial__balloon {
    left: 116px;
    right: 8px;
    bottom: 8px;
    width: auto;
    height: auto;
    min-height: 100px;
    max-height: 170px;
    padding: 10px 12px;
    max-width: none;
    min-width: auto;
  }

  .dtf-tutorial__balloon-actions {
    margin-top: 6px;
  }
}

/* モバイルで下メニュー説明時：ピコと吹き出しを上に移動 */
@media (max-width: 640px) {
  .dtf-tutorial__pico.dtf-tutorial__pico--upper {
    bottom: auto;
    top: 8px;
  }

  .dtf-tutorial__balloon.dtf-tutorial__balloon--upper {
    bottom: auto;
    top: 8px;
    left: 116px;
    right: 8px;
    max-height: 170px;
  }
}

.dtf-tutorial__reward-toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(30, 35, 50, 0.98);
  border: 1px solid rgba(255, 208, 107, 0.5);
  color: #ffd06b;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  z-index: 115;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.dtf-tutorial__reward-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* チュートリアル表示中は背景のクリックを無効化。ただしハイライト対象と吹き出しは除く */
/* NOTE: body 全体に pointer-events:none をかけると、チュートリアルUI自身も
   タップできなくなるケースがあったため、以下のルールは無効化。
   背景クリックの吸収は .dtf-tutorial__overlay の pointer-events:auto で行う。 */
/*
body:has(#dtf-tutorial-root.active) {
  pointer-events: none !important;
}
*/

/* チュートリアルルートはクリックを透過し、必要な子要素のみクリック可能に */
/* 注: #dtf-tutorial-root 自身を pointer-events:none にすることで、
   移動パネル等の背後にある要素へのクリックを通す */

/* ハイライト対象が interactive な場合のみ操作可能 */
.dtf-tutorial__target-elevated--interactive,
.dtf-tutorial__target-elevated--interactive * {
  pointer-events: auto !important;
}

/* ハイライト対象の祖先（固定ナビ等）も interactive 時のみ操作可能 */
.dtf-tutorial__ancestor-elevated--interactive {
  pointer-events: auto !important;
}

/* チュートリアル表示中はハンバーガーメニューを背面に */
body:has(#dtf-tutorial-root.active) .shared-header__menu {
  z-index: 1 !important;
}

body:has(#dtf-tutorial-root.active) .shared-header__hamburger {
  z-index: 1 !important;
}

body:has(#dtf-tutorial-root.active) .shared-header__backdrop {
  z-index: 0 !important;
}

/* チュートリアル表示中はフッターメニューを背面に（ハイライト枠を手前に出すため） */
body:has(#dtf-tutorial-root.active) #bottom-nav {
  z-index: 1 !important;
}

/* クリック可能な対象要素をハイライト上で操作可能に */
.dtf-tutorial__target-elevated {
  z-index: 120 !important;
}

/* ハイライト対象の祖先（固定ナビ等）も z-index を上げる */
.dtf-tutorial__ancestor-elevated {
  z-index: 120 !important;
}

/* チュートリアル中の背景スクロール抑止 */
body.dtf-tutorial-lock {
  overflow: hidden !important;
}

/* ハイライト対象がボタン/リンクのときのカーソル */
.dtf-tutorial__target-elevated[role="button"],
.dtf-tutorial__target-elevated button,
.dtf-tutorial__target-elevated a {
  cursor: pointer;
}

/* スキップ確認モーダル */
.dtf-tutorial__skip-modal {
  position: fixed;
  inset: 0;
  z-index: 115;
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.dtf-tutorial__skip-modal.active {
  display: flex;
  opacity: 1;
}

.dtf-tutorial__skip-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

.dtf-tutorial__skip-modal-box {
  position: relative;
  width: 320px;
  max-width: calc(100% - 32px);
  background: rgba(30, 35, 50, 0.98);
  border: 1px solid rgba(255, 208, 107, 0.35);
  border-radius: 14px;
  padding: 20px;
  color: #fff;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
  text-align: center;
  box-sizing: border-box;
}

.dtf-tutorial__skip-modal-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 10px;
}

.dtf-tutorial__skip-modal-text {
  font-size: 14px;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 20px;
}

.dtf-tutorial__skip-modal-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}
