/* Buhdi, its speech bubble and its chat box. Shared by the Mac app's overlay (index.html) and the website. */
:root {
  --win: #FBF9F5;
  --win-bar: #F0EBE4;
  --win-line: rgba(34, 29, 24, .13);
  --win-ink: #221D18;
  --win-ink-2: #7B7167;
  --hover: rgba(34, 29, 24, .06);
  --accent: #B8582A;
  --bubble: #FFF8EC;
  --bubble-ink: #2A1E16;
  --bubble-line: rgba(90, 55, 20, .18);
  --font-ui: -apple-system, "SF Pro Text", system-ui, sans-serif;
  --font-buhdi: ui-rounded, "SF Pro Rounded", -apple-system, system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --win: #25211D; --win-bar: #2F2A25; --win-line: rgba(255, 236, 214, .12);
    --win-ink: #EFE7DD; --win-ink-2: #A69C90; --hover: rgba(255, 236, 214, .07);
    color-scheme: dark;
  }
}
#stage { position: fixed; inset: 0; overflow: hidden; }
button { font: inherit; color: inherit; }

#bear { position: absolute; left: 0; top: 0; z-index: 40; width: 200px; height: 244px; pointer-events: none; visibility: hidden; will-change: transform; outline: none; }
#bearCanvas { position: absolute; left: 0; top: 0; width: 200px; height: 244px; display: block; }
#bearContact {
  position: absolute; width: 130px; height: 16px; margin: -8px 0 0 -65px; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(30, 18, 8, .38), rgba(30, 18, 8, 0)); transition: opacity .2s ease;
}
#bear.held #bearContact { opacity: 0; }
#bearHit { position: absolute; border-radius: 46% 46% 40% 40%; pointer-events: auto; cursor: grab; touch-action: none; }
#bear.held #bearHit { cursor: grabbing; }
.no-gl { position: absolute; left: 30px; top: 90px; width: 140px; padding: 8px 10px; border-radius: 10px; background: var(--bubble); color: var(--bubble-ink); font-size: 12px; line-height: 1.35; }
#bear .z, #bear .spk { position: absolute; opacity: 0; pointer-events: none; line-height: 1; }
#bear .z { font-family: var(--font-buhdi); font-weight: 700; color: #EEF0FF; text-shadow: 0 1px 0 #47507A, 0 0 8px rgba(90, 100, 180, .6); }
#bear.sleeping .z { animation: zfloat 3.3s ease-out infinite; }
#bear.sleeping .z2 { animation-delay: 1.1s; }
#bear.sleeping .z3 { animation-delay: 2.2s; }
#bear .spk { font-size: 20px; color: #FFD45E; text-shadow: 0 0 8px rgba(255, 190, 60, .9); }
#bear.sparkle .spk { animation: spark .95s ease-out; }
#bear.sparkle .spk2 { animation-delay: .12s; }
#bear.sparkle .spk3 { animation-delay: .24s; }
#smoke { position: absolute; left: 0; top: 0; z-index: 44; pointer-events: none; }
.fxtext {
  position: absolute; z-index: 46; pointer-events: none; white-space: nowrap;
  font-family: var(--font-buhdi); font-weight: 700; font-size: 19px; color: #FFF6E6;
  text-shadow: 0 1px 0 #3A2414, 0 0 8px rgba(40, 20, 0, .55);
  animation: fxup 1.45s ease-out forwards;
}
@keyframes fxup { 0% { opacity: 0; transform: translateY(6px) scale(.8); } 15% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-36px) rotate(-6deg); } }
@keyframes zfloat { 0% { opacity: 0; transform: translate(0, 0) scale(.6); } 20% { opacity: 1; } 100% { opacity: 0; transform: translate(18px, -40px) scale(1.2); } }
@keyframes spark { 0% { opacity: 0; transform: scale(.2) rotate(0deg); } 40% { opacity: 1; transform: scale(1.25) rotate(30deg); } 100% { opacity: 0; transform: scale(.6) rotate(70deg); } }

#bubble {
  position: absolute; z-index: 45; max-width: 260px; padding: 9px 13px 10px;
  background: var(--bubble); color: var(--bubble-ink); border-radius: 16px;
  font-family: var(--font-buhdi); font-size: 15px; line-height: 1.3; font-weight: 600;
  box-shadow: 0 10px 28px rgba(40, 25, 10, .28), 0 0 0 1px var(--bubble-line);
  opacity: 0; transform: translateY(6px) scale(.96); transition: opacity .18s ease, transform .18s ease;
  pointer-events: none; white-space: pre-wrap;
}
#bubble.show { opacity: 1; transform: none; }
#bubble::after {
  content: ""; position: absolute; top: 22px; width: 14px; height: 14px; background: var(--bubble);
  transform: rotate(45deg); box-shadow: 1px -1px 0 var(--bubble-line);
}
#bubble.to-right::after { left: -6px; box-shadow: -1px 1px 0 var(--bubble-line); }
#bubble.to-left::after { right: -6px; }

#chat {
  position: absolute; z-index: 50; width: 330px; display: flex; flex-direction: column;
  background: var(--win); color: var(--win-ink); border-radius: 16px; overflow: hidden;
  box-shadow: 0 24px 60px rgba(20, 12, 4, .35), 0 0 0 1px var(--win-line);
  -webkit-user-select: text; user-select: text;
}
#chat[hidden] { display: none; }
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 11px 14px 9px; border-bottom: 1px solid var(--win-line); }
.chat-head strong { font-family: var(--font-buhdi); font-size: 16px; }
#chatStatus { margin-left: 8px; font-size: 12px; color: var(--win-ink-2); }
#chatClose { border: 0; background: none; width: 26px; height: 26px; border-radius: 6px; font-size: 18px; cursor: pointer; color: var(--win-ink-2); }
#chatClose:hover { background: var(--hover); }
.chat-log { padding: 12px 14px 4px; display: flex; flex-direction: column; gap: 8px; max-height: 280px; min-height: 40px; overflow-y: auto; }
.msg { max-width: 86%; padding: 7px 11px 8px; border-radius: 14px; font-size: 13.5px; line-height: 1.4; overflow-wrap: anywhere; }
.msg.you { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 5px; }
.msg.buhdi { align-self: flex-start; background: var(--bubble); color: var(--bubble-ink); font-family: var(--font-buhdi); font-size: 14.5px; font-weight: 500; border-bottom-left-radius: 5px; box-shadow: inset 0 0 0 1px var(--bubble-line); }
.msg.act { align-self: flex-start; padding: 0 2px; font-size: 12.5px; font-style: italic; color: var(--win-ink-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 14px 8px; }
.chips[hidden] { display: none; }
.chips button { border: 1px solid var(--win-line); background: var(--win-bar); border-radius: 999px; padding: 4px 10px; font-size: 12.5px; cursor: pointer; }
.chips button:hover { border-color: var(--accent); }
.chat-form { display: flex; gap: 8px; padding: 8px 12px 12px; }
#chatInput {
  flex: 1; min-width: 0; font: inherit; font-size: 13.5px; padding: 8px 11px; border-radius: 10px;
  border: 1px solid var(--win-line); background: var(--win-bar); color: var(--win-ink); outline: none;
}
#chatInput:focus { border-color: var(--accent); }
#chatSend { border: 0; border-radius: 10px; padding: 0 14px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
#chatSend:disabled { opacity: .5; cursor: default; }

@media (prefers-reduced-motion: reduce) {
  #bear.sleeping .z, #bear.sparkle .spk, .fxtext { animation: none; }
  #bubble { transition: none; }
}
