/* Thirdy's website companion — Bantay is the one and only mascot. */
#site-companion {
  position: fixed;
  left: 20px;
  bottom: 22px;
  z-index: 470;
  font-family: 'Jost', sans-serif;
  color: var(--ink, #24211e);
}

.companion-launcher {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
#site-companion.is-open .companion-launcher { visibility: visible; pointer-events: auto; }
#site-companion.is-open .companion-mascot-btn {
  filter: drop-shadow(0 12px 16px rgba(28, 18, 12, .28));
}

.companion-mascot-btn {
  position: relative;
  width: 104px;
  height: 96px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 10px 12px rgba(28, 18, 12, .22));
  transition: transform .2s ease;
}

.companion-mascot-btn:hover,
.companion-mascot-btn:focus-visible { transform: translateY(-4px); }
.companion-mascot-btn:focus-visible { outline: 2px solid var(--gold, #b5860a); outline-offset: 3px; border-radius: 18px; }

#companion-sprite {
  display: block;
  width: 104px;
  height: 92px;
  object-fit: contain;
  object-position: center bottom;
  user-select: none;
  pointer-events: none;
}

.companion-unread {
  position: absolute;
  top: 2px;
  right: 2px;
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 99px;
  background: var(--burgundy, #7a2535);
  color: #fff;
  border: 2px solid #fff;
  font-size: 11px;
  font-weight: 700;
}
.companion-unread[hidden] { display: none !important; }

.companion-speech {
  position: relative;
  max-width: 190px;
  margin-bottom: 40px;
  padding: 10px 13px;
  border: 1px solid rgba(122, 37, 53, .18);
  border-radius: 14px 14px 14px 4px;
  background: rgba(255, 255, 255, .96);
  box-shadow: 0 10px 28px rgba(28, 18, 12, .14);
  color: var(--ink-soft, #4f4b46);
  font-size: 12px;
  line-height: 1.45;
  cursor: pointer;
}

.companion-speech strong { color: var(--burgundy, #7a2535); font-weight: 650; }
.companion-speech::after {
  content: '';
  position: absolute;
  left: 12px;
  bottom: -7px;
  width: 13px;
  height: 13px;
  border-right: 1px solid rgba(122, 37, 53, .18);
  border-bottom: 1px solid rgba(122, 37, 53, .18);
  background: rgba(255, 255, 255, .96);
  transform: rotate(45deg);
}
.companion-speech.is-fresh { animation: companionNudge .42s cubic-bezier(.2,.8,.2,1); }
@keyframes companionNudge {
  0% { opacity: .3; transform: translateY(7px) scale(.97); }
  100% { opacity: 1; transform: none; }
}

.companion-panel {
  position: absolute;
  padding: 0 !important;
  left: 8px;
  bottom: 106px;
  width: min(360px, calc(100vw - 32px));
  max-height: min(650px, calc(100vh - 145px));
  overflow: hidden;
  border: 1px solid rgba(122, 37, 53, .18);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(32, 20, 15, .24);
  transform-origin: left bottom;
  animation: companionOpen .22s ease-out both;
}

.companion-panel[hidden] { display: none !important; }

@keyframes companionOpen {
  from { opacity: 0; transform: translateY(10px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.companion-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 15px;
  background: linear-gradient(135deg, #6b1f30, #8c3545);
  color: #fff;
}

.companion-head-avatar {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  overflow: hidden;
  border-radius: 50%;
  background: rgba(255,255,255,.95);
  border: 2px solid rgba(255,255,255,.75);
}

.companion-head-avatar img { width: 48px; height: 43px; object-fit: contain; object-position: center bottom; }
.companion-head-copy { flex: 1; min-width: 0; }
.companion-head-copy strong { display: block; font-size: 14px; letter-spacing: .01em; }
.companion-head-copy span { display: flex; align-items: center; gap: 6px; margin-top: 1px; color: rgba(255,255,255,.76); font-size: 11px; }
.companion-status-dot {
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: #83d69f;
  box-shadow: 0 0 0 3px rgba(131,214,159,.16);
}

.companion-close {
  width: 36px;
  height: 36px;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.companion-close:hover { background: rgba(255,255,255,.22); }

.companion-body {
  display: flex;
  flex-direction: column;
  max-height: calc(min(650px, 100vh - 145px) - 70px);
}

.companion-messages {
  min-height: 142px;
  max-height: 260px;
  overflow-y: auto;
  padding: 15px;
  background: #faf8f5;
  scrollbar-width: thin;
}

.companion-msg {
  width: fit-content;
  max-width: 88%;
  margin: 0 0 9px;
  padding: 10px 12px;
  border-radius: 13px;
  font-size: 12.5px;
  line-height: 1.55;
  white-space: pre-line;
  animation: companionMessageIn .2s ease-out both;
}
@keyframes companionMessageIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: none; }
}

.companion-msg.bot { border: 1px solid #e8e1da; border-radius: 4px 13px 13px 13px; background: #fff; color: #4b4641; }
.companion-msg.user { margin-left: auto; border-radius: 13px 13px 4px 13px; background: var(--burgundy, #7a2535); color: #fff; }
.companion-msg.thinking { color: #8d857e; font-style: italic; }

.companion-jump {
  display: inline-flex;
  margin-top: 8px;
  padding: 6px 10px;
  border: 1px solid rgba(122,37,53,.25);
  border-radius: 99px;
  background: #fff;
  color: var(--burgundy, #7a2535);
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.companion-jump:hover { background: #f7eff1; }

.companion-quick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  max-height: 150px;
  overflow-y: auto;
  padding: 12px 15px;
  border-top: 1px solid #eee8e2;
}

.companion-topic {
  min-height: 40px;
  padding: 8px 9px;
  border: 1px solid #e5ddd5;
  border-radius: 9px;
  background: #fff;
  color: #514b45;
  font: inherit;
  font-size: 11.5px;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
}
.companion-topic:hover,
.companion-topic:focus-visible,
.companion-topic.is-active { border-color: var(--burgundy, #7a2535); color: var(--burgundy, #7a2535); background: #fcf7f8; }
.companion-topic.is-active { box-shadow: inset 3px 0 0 var(--burgundy, #7a2535); }

.companion-form {
  display: flex;
  gap: 7px;
  padding: 12px 15px 15px;
  border-top: 1px solid #eee8e2;
  background: #fff;
}

.companion-form input {
  min-width: 0;
  flex: 1;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #ddd5cd;
  border-radius: 9px;
  background: #faf8f5;
  font: inherit;
  font-size: 12px;
}
.companion-form input:focus { outline: 2px solid rgba(122,37,53,.2); border-color: var(--burgundy, #7a2535); }
.companion-form button {
  width: 44px;
  min-height: 42px;
  border: 0;
  border-radius: 9px;
  background: var(--burgundy, #7a2535);
  color: #fff;
  font-size: 17px;
  cursor: pointer;
}

.companion-note {
  padding: 0 15px 12px;
  background: #fff;
  color: #948b82;
  font-size: 10px;
  line-height: 1.4;
}

.companion-answer-sources { display: none; }

/* The visual CMS adds body.__reveal when "Show hidden parts" is active.
   Move the fixed widget into the document flow so every prepared answer can
   be selected, edited, duplicated, reordered, or deleted like other blocks. */
body.__reveal #site-companion {
  position: relative !important;
  left: 0 !important;
  bottom: auto !important;
  z-index: 2147483646 !important;
  width: auto !important;
  margin: 36px 24px !important;
  pointer-events: auto !important;
}
body.__reveal #site-companion .companion-launcher,
body.__reveal #site-companion .companion-panel { display: none !important; }
body.__reveal #site-companion .companion-answer-sources {
  position: static !important;
  visibility: visible !important;
  width: auto !important;
  padding: 22px !important;
  border: 2px dashed #b5860a !important;
  border-radius: 12px !important;
  background: #fffaf0 !important;
}
body.__reveal #site-companion .companion-answer-source {
  display: block !important;
  margin: 0 0 12px !important;
  padding: 14px !important;
  pointer-events: auto !important;
  border: 1px solid #e6d7ae !important;
  border-radius: 8px !important;
  background: #fff !important;
}
body.__reveal #site-companion .companion-answer-source:last-child { margin-bottom: 0 !important; }
body.__reveal #site-companion .companion-answer-source h3 { margin: 0 0 7px !important; font-size: 18px !important; }
body.__reveal #site-companion .companion-answer-source p { margin: 0 !important; color: #5c554d !important; }

@media (max-width: 720px) {
  #site-companion { left: 10px; bottom: 76px; }
  .companion-mascot-btn { width: 82px; height: 78px; }
  #companion-sprite { width: 82px; height: 74px; }
  .companion-speech { display: none; }
  .companion-panel {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 154px;
    width: auto;
    max-height: calc(100dvh - 176px);
  }
  .companion-body { max-height: calc(100dvh - 246px); }
  .companion-messages { max-height: 31dvh; }
}

@media (max-width: 390px) {
  .companion-quick { grid-template-columns: 1fr; max-height: 128px; }
}

@media (prefers-reduced-motion: reduce) {
  .companion-panel,
  .companion-speech.is-fresh,
  .companion-msg { animation: none; }
  .companion-mascot-btn { transition: none; }
}
