/* ============================================================
   help-tooltip.css
   入力欄ごとの説明ふきだし + 改善要望送信ボックス
   - 各 [data-help] 入力欄の横に「？」ボタンを自動挿入
   - 「？」クリックでふきだしを開く（再クリックで閉じる）
   ============================================================ */

/* 「？」トリガーボタン */
.helptip-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: 6px;
  padding: 0;
  border: 1px solid #C77DFF;
  background: #fff;
  color: #C77DFF;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
  vertical-align: middle;
  flex-shrink: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s ease, color 0.12s ease, transform 0.12s ease;
}
.helptip-trigger:hover,
.helptip-trigger:focus {
  background: #C77DFF;
  color: #fff;
  outline: none;
}
.helptip-trigger:active {
  transform: scale(0.92);
}
/* ラベルが無い入力欄を包む wrap + 絶対配置の「？」 */
.helptip-input-wrap {
  position: relative;
  display: block;
}
.helptip-trigger.helptip-trigger-floating {
  position: absolute;
  top: 50%;
  right: 8px;
  margin: 0;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.95);
  z-index: 2;
}
.helptip-trigger.helptip-trigger-floating:active {
  transform: translateY(-50%) scale(0.92);
}
/* textarea は中央寄せだとボタンが本文に被るので上寄せ */
.helptip-input-wrap > textarea ~ .helptip-trigger.helptip-trigger-floating {
  top: 10px;
  transform: none;
}
.helptip-input-wrap > textarea ~ .helptip-trigger.helptip-trigger-floating:active {
  transform: scale(0.92);
}
/* wrap 内の input/select は右側に「？」分の余白を確保（文字が被らない） */
.helptip-input-wrap > input,
.helptip-input-wrap > select {
  padding-right: 36px;
}

/* flex 親内に兄弟として挿入されたケース */
.helptip-trigger.helptip-trigger-flex {
  flex-shrink: 0;
  align-self: center;
  margin-left: 6px;
}

.helptip {
  position: fixed;
  z-index: 99999;
  max-width: 340px;
  min-width: 220px;
  background: #2D3436;
  color: #FFF;
  border-radius: 12px;
  padding: 12px 14px 10px;
  font-size: 0.85rem;
  line-height: 1.55;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(4px) scale(0.97);
  transition: opacity 0.14s ease, transform 0.14s ease;
  font-family: inherit;
  word-wrap: break-word;
  white-space: pre-wrap;
}
.helptip.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.helptip-arrow {
  position: absolute;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
}
.helptip[data-pos="bottom"] .helptip-arrow {
  top: -7px;
  left: 24px;
  border-bottom: 8px solid #2D3436;
}
.helptip[data-pos="top"] .helptip-arrow {
  bottom: -7px;
  left: 24px;
  border-top: 8px solid #2D3436;
}

.helptip-title {
  font-weight: 700;
  font-size: 0.82rem;
  margin: 0 0 5px;
  color: #FFD56B;
  letter-spacing: 0.02em;
}

.helptip-body {
  font-size: 0.85rem;
  line-height: 1.6;
  color: #F4F4F4;
}
.helptip-body code {
  background: rgba(255, 255, 255, 0.13);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
  word-break: break-all;
}
.helptip-body b, .helptip-body strong {
  color: #FFD56B;
}

.helptip-actions {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.helptip-feedback-btn {
  background: rgba(255, 213, 107, 0.12);
  color: #FFD56B;
  border: 1px solid rgba(255, 213, 107, 0.4);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
}
.helptip-feedback-btn:hover {
  background: rgba(255, 213, 107, 0.22);
}
.helptip-close-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.85rem;
  cursor: pointer;
  margin-left: auto;
  padding: 2px 6px;
  font-family: inherit;
}

.helptip-fb-form {
  margin-top: 8px;
  display: none;
}
.helptip-fb-form.show {
  display: block;
}
.helptip-fb-form textarea {
  width: 100%;
  min-height: 64px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 0.82rem;
  color: #FFF;
  font-family: inherit;
  resize: vertical;
  box-sizing: border-box;
}
.helptip-fb-form textarea::placeholder {
  color: rgba(255, 255, 255, 0.4);
}
.helptip-fb-form textarea:focus {
  outline: none;
  border-color: #FFD56B;
}
.helptip-fb-submit {
  margin-top: 6px;
  background: #FFD56B;
  color: #2D3436;
  border: none;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.helptip-fb-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.helptip-fb-status {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
  margin-left: 8px;
}

/* 初回オンボーディング・シート（下からスライドアップ） */
.helptip-onboard {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  transform: translateY(110%);
  background: #2D3436;
  color: #FFF;
  padding: 20px 22px calc(20px + env(safe-area-inset-bottom, 0px)) 22px;
  border-radius: 22px 22px 0 0;
  font-size: 0.95rem;
  line-height: 1.65;
  box-shadow: 0 -10px 32px rgba(0, 0, 0, 0.28);
  z-index: 99998;
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-family: inherit;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.helptip-onboard.show { transform: translateY(0); }
.helptip-onboard b { color: #FFD56B; }
.helptip-onboard > div { word-wrap: break-word; }
.helptip-onboard button {
  align-self: stretch;
  background: #FFD56B;
  color: #2D3436;
  border: none;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
}
.helptip-onboard button:active { transform: scale(0.98); }

/* オンボード中の「？」ボタン強調（赤丸＋パルス） */
.helptip-trigger.helptip-trigger-pulse {
  border-color: #FF4D6D;
  color: #FF4D6D;
  background: #fff;
  animation: helptip-pulse 1.4s ease-in-out infinite;
}
@keyframes helptip-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 77, 109, 0.55); }
  50%      { box-shadow: 0 0 0 8px rgba(255, 77, 109, 0); }
}
/* floating（input wrap 内の絶対配置）は translateY を壊さないよう個別アニメ */
.helptip-trigger.helptip-trigger-pulse.helptip-trigger-floating {
  animation: helptip-pulse-floating 1.4s ease-in-out infinite;
}
@keyframes helptip-pulse-floating {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 77, 109, 0.55); transform: translateY(-50%) scale(1); }
  50%      { box-shadow: 0 0 0 8px rgba(255, 77, 109, 0); transform: translateY(-50%) scale(1.06); }
}

/* スマホで長押し中に文字選択が出るのを抑制 */
[data-help] {
  -webkit-touch-callout: none;
}
