@charset "UTF-8";
/* ===================================================
   AIチャット（Dify API連携）スタイル
   読み込み元：/assets/inc/footer.php
   =================================================== */

/* ---------- アニメーション ---------- */
@keyframes aiAskFlow {
  0%   { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}
@keyframes aiAskTwinkle {
  0%, 100% { transform: scale(1) rotate(0deg);   opacity: 1; }
  50%      { transform: scale(.8) rotate(45deg); opacity: .7; }
}
@keyframes aiMsgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
@keyframes aiDot {
  0%, 80%, 100% { transform: translateY(0);    opacity: .35; }
  40%           { transform: translateY(-4px); opacity: 1; }
}

.ai-star path { fill: url(#aiAskGrad); }

/* ---------- 起動ボタン ---------- */
#ai-ask-button {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 2147483647;
  display: inline-flex;
  align-items: center;
  gap: .6em;
  margin: 0;
  padding: 1em 1.7em 1em 1.4em;
  border: 1.5px solid transparent;
  border-radius: 999px;
  background:
    linear-gradient(#2F2725, #2F2725) padding-box,
    linear-gradient(90deg, #A31B1B, #CE726F, #F0CDB8, #CE726F, #A31B1B) border-box;
  background-size: 100% 100%, 200% 100%;
  animation: aiAskFlow 4s linear infinite;
  color: #F7F1EE;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: .12em;
  cursor: pointer;
  box-shadow:
    0 10px 30px -8px rgba(163, 27, 27, .45),
    0 4px 12px rgba(0, 0, 0, .25);
  transition: transform .35s cubic-bezier(.2, .8, .2, 1), box-shadow .35s;
  -webkit-tap-highlight-color: transparent;
}
#ai-ask-button:hover {
  transform: translateY(-3px);
  box-shadow:
    0 16px 40px -8px rgba(206, 114, 111, .6),
    0 6px 16px rgba(0, 0, 0, .3);
}
#ai-ask-button:active { transform: translateY(0) scale(.97); }
#ai-ask-button:focus-visible { outline: 2px solid #CE726F; outline-offset: 4px; }
#ai-ask-button .ai-ask-icon {
  width: 1.15em;
  height: 1.15em;
  flex-shrink: 0;
  animation: aiAskTwinkle 2.4s ease-in-out infinite;
}
#ai-ask-button.is-open {
  background:
    linear-gradient(#F2F2F2, #F2F2F2) padding-box,
    linear-gradient(90deg, #DCCFCB, #DCCFCB) border-box;
  color: #2F2725;
  animation: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}
#ai-ask-button.is-open .ai-ask-icon { display: none; }

/* ---------- チャット画面 ---------- */
.ai-chat {
  position: fixed;
  right: 1.25rem;
  bottom: 5.5rem;
  z-index: 2147483646;
  display: flex;
  flex-direction: column;
  width: 380px;
  max-width: calc(100vw - 2rem);
  height: 640px;
  max-height: calc(var(--ai-vh, 100vh) - 7rem);
  background: #FBF9F8;
  border-radius: 18px;
  overflow: hidden;
  box-shadow:
    0 30px 60px -20px rgba(47, 39, 37, .45),
    0 0 0 1px rgba(47, 39, 37, .06);
  color: #2F2725;
  font-family: inherit;
  text-align: left;
  opacity: 0;
  visibility: hidden;
  transform: translateY(16px) scale(.98);
  transform-origin: bottom right;
  transition:
    opacity .3s ease,
    transform .4s cubic-bezier(.2, .8, .2, 1),
    visibility 0s linear .4s;
}
.ai-chat.is-open {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition:
    opacity .3s ease,
    transform .4s cubic-bezier(.2, .8, .2, 1),
    visibility 0s;
}
.ai-chat *, .ai-chat *::before, .ai-chat *::after { box-sizing: border-box; }
.ai-chat p { margin: 0; }
.ai-chat button { font-family: inherit; }

/* ヘッダー */
.ai-chat__head {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 12px 14px 16px;
  background: #2F2725;
  color: #F7F1EE;
  flex-shrink: 0;
}
.ai-chat__head::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, #A31B1B, #CE726F, #F0CDB8, #CE726F, #A31B1B);
  background-size: 200% 100%;
  animation: aiAskFlow 6s linear infinite;
}
.ai-chat__brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.ai-chat__logo {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(240, 205, 184, .25);
  flex-shrink: 0;
}
.ai-chat__logo svg { width: 18px; height: 18px; animation: aiAskTwinkle 2.4s ease-in-out infinite; }
.ai-chat__title {
  font-family: "Oswald", "Montserrat", sans-serif;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: .16em;
  line-height: 1.2;
}
.ai-chat__sub {
  margin-top: 3px !important;
  font-size: 11px;
  letter-spacing: .06em;
  line-height: 1.3;
  opacity: .65;
}
.ai-chat__tools { display: flex; gap: 2px; flex-shrink: 0; }
.ai-chat__tool {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #F7F1EE;
  opacity: .7;
  cursor: pointer;
  transition: background-color .2s, opacity .2s;
}
.ai-chat__tool:hover { background: rgba(255, 255, 255, .1); opacity: 1; }
.ai-chat__tool:focus-visible { outline: 2px solid #CE726F; outline-offset: 1px; opacity: 1; }
.ai-chat__tool svg { width: 18px; height: 18px; }

/* メッセージ一覧 */
.ai-chat__log {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 16px 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.ai-msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  animation: aiMsgIn .35s ease both;
}
.ai-msg--user { justify-content: flex-end; }
.ai-msg__avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-top: 1px;
  border-radius: 50%;
  background: #2F2725;
  box-shadow: inset 0 0 0 1px rgba(240, 205, 184, .22);
  flex-shrink: 0;
}

/* ---------- 回答アイコン：ロボット ---------- */
@keyframes aiBotBlink {
  0%, 90%, 100% { transform: scaleY(1); }
  94%           { transform: scaleY(.1); }
}
@keyframes aiBotPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .3; }
}
@keyframes aiBotBob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-.8px); }
}
@keyframes aiBotLook {
  0%, 100% { transform: translateX(0); }
  25%      { transform: translateX(-1.3px); }
  75%      { transform: translateX(1.3px); }
}
.ai-bot { width: 20px; height: 20px; overflow: visible; }
.ai-bot * { transform-box: fill-box; transform-origin: center; }
/* 最新の回答アイコンだけ動かす */
.ai-msg.is-live .ai-bot__body { animation: aiBotBob 3s ease-in-out infinite; }
.ai-msg.is-live .ai-bot__eye  { animation: aiBotBlink 4s ease-in-out infinite; }
.ai-msg.is-live .ai-bot__tip  { animation: aiBotPulse 2s ease-in-out infinite; }
/* 回答作成中：キョロキョロ＋アンテナ早めに点滅 */
.ai-msg--typing .ai-bot__eyes { animation: aiBotLook 1.4s ease-in-out infinite; }
.ai-msg--typing .ai-bot__tip  { animation-duration: .8s !important; }
.ai-msg__bubble {
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.75;
  letter-spacing: .02em;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.ai-msg--bot .ai-msg__bubble {
  max-width: calc(100% - 36px);
  background: #fff;
  border: 1px solid #EEE6E2;
  border-radius: 4px 16px 16px 16px;
}
.ai-msg--user .ai-msg__bubble {
  max-width: 85%;
  background: #2F2725;
  color: #F7F1EE;
  border-radius: 16px 16px 4px 16px;
  white-space: pre-wrap;
}
.ai-msg--error .ai-msg__bubble {
  background: #FFF5F3;
  border-color: #F3D3CD;
  color: #A31B1B;
}
/* 回答本文の装飾 */
.ai-msg__bubble p + p,
.ai-msg__bubble p + ul, .ai-msg__bubble p + ol,
.ai-msg__bubble ul + p, .ai-msg__bubble ol + p,
.ai-msg__bubble pre { margin-top: .6em; }
.ai-msg__bubble ul, .ai-msg__bubble ol { margin: .3em 0 0; padding-left: 1.3em; }
.ai-msg__bubble ul li { list-style: disc; }
.ai-msg__bubble ol li { list-style: decimal; }
.ai-msg__bubble li + li { margin-top: .2em; }
.ai-msg__bubble li::marker { color: #CE726F; }
.ai-msg__bubble strong, .ai-msg__bubble .ai-h { font-weight: 700; }
.ai-msg__bubble a { color: #A31B1B; text-decoration: underline; text-underline-offset: 2px; }
.ai-msg__bubble code {
  padding: 1px 5px;
  border-radius: 4px;
  background: #F4EEEB;
  font-size: .9em;
}
.ai-msg__bubble pre {
  margin-bottom: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #2F2725;
  color: #F7F1EE;
  overflow-x: auto;
  white-space: pre;
}
.ai-msg__bubble pre code { padding: 0; background: none; }
/* 入力中アニメーション */
.ai-typing { display: inline-flex; gap: 5px; padding: 6px 2px; }
.ai-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #CE726F;
  animation: aiDot 1.2s infinite ease-in-out;
}
.ai-typing i:nth-child(2) { animation-delay: .15s; }
.ai-typing i:nth-child(3) { animation-delay: .3s; }

/* 質問候補 */
.ai-chat__suggest {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 16px 12px 52px;
}
.ai-chat__suggest:empty { display: none; }
.ai-chip {
  margin: 0;
  padding: 7px 13px;
  border: 1px solid #E6CFC8;
  border-radius: 999px;
  background: #fff;
  color: #A31B1B;
  font-size: 12.5px;
  line-height: 1.4;
  letter-spacing: .03em;
  text-align: left;
  cursor: pointer;
  animation: aiMsgIn .35s ease both;
  transition: background-color .2s, color .2s, border-color .2s;
}
.ai-chip:hover, .ai-chip:focus-visible {
  background: #A31B1B;
  border-color: #A31B1B;
  color: #fff;
  outline: none;
}

/* 入力欄 */
.ai-chat__form {
  margin: 0;
  padding: 10px 12px 8px;
  background: #fff;
  border-top: 1px solid #EEE6E2;
  flex-shrink: 0;
}
.ai-chat__field {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 5px 5px 5px 16px;
  border: 1px solid transparent;
  border-radius: 22px;
  background: #F5F1EF;
  transition: border-color .2s, box-shadow .2s, background-color .2s;
}
.ai-chat__field:focus-within {
  background: #fff;
  border-color: #E8E0DC;
}
#ai-chat-input {
  flex: 1;
  min-width: 0;
  max-height: 120px;
  margin: 0;
  padding: 7px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: #2F2725;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  resize: none;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
#ai-chat-input::placeholder { color: #A89C98; }
.ai-chat__send {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, #A31B1B, #CE726F);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform .2s, opacity .2s, background .2s;
}
.ai-chat__send:hover:not(:disabled) { transform: scale(1.07); }
.ai-chat__send:focus-visible { outline: 2px solid #CE726F; outline-offset: 2px; }
.ai-chat__send:disabled { background: #DDD3CF; cursor: default; }
.ai-chat__send svg { width: 18px; height: 18px; }
.ai-chat__note {
  margin-top: 6px !important;
  color: #9A8E8A;
  font-size: 10.5px;
  letter-spacing: .04em;
  text-align: center;
}

/* ---------- スマホ：全画面表示 ---------- */
@media (max-width: 600px) {
  #ai-ask-button {
    right: 1rem;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
    font-size: 13px;
  }
  .ai-chat {
    top: var(--ai-vt, 0px);
    right: 0;
    bottom: auto;
    left: 0;
    width: 100%;
    max-width: none;
    height: var(--ai-vh, 100vh);
    max-height: none;
    border-radius: 0;
    transform: translateY(24px);
  }
  .ai-chat__head { padding-top: calc(env(safe-area-inset-top, 0px) + 12px); }
  .ai-chat__form { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 8px); }
  #ai-chat-input { font-size: 16px; } /* iPhoneで入力時にズームされないよう16px以上 */
  html.ai-chat-open #ai-ask-button { display: none; }
  html.ai-chat-open, html.ai-chat-open body { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
  #ai-ask-button, #ai-ask-button .ai-ask-icon,
  .ai-chat, .ai-chat *, .ai-chat__head::after {
    animation: none !important;
    transition: none !important;
  }
}
