/* Kamiji home page chat widget (site/chat-widget.js): floating Kamikin mochi button + right-side drawer.
   Prototype: the conversation is scripted. Colours come from the page tokens in style.css. */

.kj-fab {
  position: fixed; z-index: 30;
  right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  width: 88px; height: 88px; padding: 0; margin: 0; border: 0; border-radius: 50%;
  background: transparent; color: var(--fg, #1f2a22); cursor: pointer;
  transition: transform .18s ease; -webkit-tap-highlight-color: transparent;
}
.kj-fab:hover { transform: translateY(-2px); }
.kj-fab:active { transform: scale(.96); }
.kj-fab.is-hidden { visibility: hidden; pointer-events: none; }
/* the canvas overhangs the 88 px button (headroom for jumps, room for the bubble); it never takes clicks */
.kj-fab { overflow: visible; }
.kj-fab canvas { position: absolute; left: -36px; right: -10px; top: -34px; bottom: 0; width: calc(100% + 46px); height: calc(100% + 34px); display: block; pointer-events: none; }
.kj-fab svg.kj-flat { position: absolute; right: 4px; bottom: 2px; width: 66px; height: 66px; display: block; pointer-events: none; filter: drop-shadow(0 8px 10px rgba(31, 42, 34, .18)); animation: kj-bob 3.6s ease-in-out infinite; }
.kj-fab.is-3d svg.kj-flat { display: none; }
.kj-fab.has-bubble .kj-glyph { display: none; }
.kj-fab:focus-visible { outline: 3px solid var(--sel, #1d1d1b); outline-offset: 2px; }
/* tiny speech-bubble glyph on the mochi's upper-left corner: keeps the launcher reading as "chat" */
.kj-glyph { position: absolute; top: 4px; left: 0; width: 30px; height: 30px; transform: scaleX(-1); /* mirrored: the tail points down-right, at the character */ display: block; pointer-events: none; filter: drop-shadow(0 2px 3px rgba(31, 42, 34, .22)); transition: transform .18s ease; }
.kj-fab:hover .kj-glyph, .kj-fab:focus-visible .kj-glyph { transform: scaleX(-1) rotate(-8deg) scale(1.1); }
.kj-dot {
  position: absolute; top: 8px; right: 6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px;
  background: #ff5a4d; color: #fff; font: 700 11px/20px var(--sans, system-ui, sans-serif); text-align: center;
  box-shadow: 0 0 0 2px var(--bg, #f0efe7); pointer-events: none; animation: kj-pulse 2.4s ease-in-out infinite;
}
.kj-dot[hidden] { display: none; }
@keyframes kj-bob { 0%, 100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-4px) rotate(2deg); } }
@keyframes kj-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.14); } }

/* keep the last lines of the page (footer contact) clear of the floating button */
.site-footer { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

@media (max-width: 700px) {
  .kj-fab { width: 84px; height: 84px; }
}

/* ---- drawer ---------------------------------------------------------------------------- */
.kj-panel {
  position: fixed; z-index: 40; top: 0; right: 0; bottom: 0; width: min(400px, 100vw);
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; background: var(--card, #fafaf3); color: var(--fg, #1f2a22);
  border-left: 1px solid var(--faint, rgba(31, 42, 34, .13));
  box-shadow: -18px 0 50px -24px var(--shadow, rgba(31, 42, 34, .3));
  transform: translateX(105%); transition: transform .26s cubic-bezier(.2, .8, .2, 1);
  padding-right: env(safe-area-inset-right); padding-bottom: env(safe-area-inset-bottom);
  font: 16px/1.5 var(--sans, system-ui, sans-serif);
}
.kj-panel[hidden] { display: none; }
.kj-panel.is-open { transform: none; }
.kj-panel:focus { outline: none; }
@media (max-width: 700px) {
  .kj-panel { width: 100vw; border-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .kj-panel { transition: none; }
  .kj-fab, .kj-fab svg.kj-flat, .kj-dot, .kj-glyph { transition: none; animation: none; }
}
html.kj-lock, html.kj-lock body { overflow: hidden; }

.kj-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px 12px 16px; border-bottom: 1px solid var(--faint, rgba(31, 42, 34, .13)); flex: none; }
.kj-avatar { position: relative; width: 52px; height: 52px; flex: none; border-radius: 50%; background: var(--pill, #e7e6e1); overflow: hidden; }
.kj-avatar canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.kj-avatar svg { position: absolute; inset: 6px; width: calc(100% - 12px); height: calc(100% - 12px); }
.kj-titles { min-width: 0; flex: 1; }
.kj-title { margin: 0; font-size: 1.1rem; line-height: 1.2; }
.kj-mood:empty { display: none; }
.kj-mood { margin: 2px 0 0; font: .66rem/1.2 var(--mono, monospace); text-transform: uppercase; letter-spacing: .12em; color: var(--muted, #5f665a); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kj-ibtn {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 12px;
  background: transparent; color: var(--fg, #1f2a22); cursor: pointer;
}
.kj-ibtn:hover { background: var(--pill, #e7e6e1); }
.kj-ibtn[aria-pressed="true"] { background: var(--sel, #1d1d1b); color: var(--sel-fg, #fff); }
.kj-ibtn svg { width: 22px; height: 22px; }
.kj-ibtn .kj-off { display: none; }
.kj-ibtn[aria-pressed="false"] .kj-on { display: none; }
.kj-ibtn[aria-pressed="false"] .kj-off { display: inline; }

.kj-log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 16px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: auto; }
.kj-msg { max-width: 88%; padding: 9px 13px; border-radius: 18px; overflow-wrap: anywhere; }
.kj-msg p { margin: 0 0 .55em; }
.kj-msg p:last-child { margin-bottom: 0; }
.kj-agent { align-self: flex-start; background: var(--pill, #e7e6e1); border-bottom-left-radius: 6px; }
.kj-user { align-self: flex-end; background: var(--sel, #1d1d1b); color: var(--sel-fg, #fff); border-bottom-right-radius: 6px; }
.kj-msg code { font-size: .82em; }
.kj-msg a { color: inherit; }
.kj-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.kj-act, .kj-chip {
  font: inherit; font-size: .88rem; line-height: 1.2; padding: 8px 13px; min-height: 36px; border-radius: 14px;
  border: 1px solid var(--faint, rgba(31, 42, 34, .13)); background: var(--card, #fafaf3); color: var(--fg, #1f2a22);
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center;
}
.kj-act:hover, .kj-chip:hover { background: var(--bg, #f0efe7); }
.kj-typing { display: inline-flex; gap: 4px; align-items: center; height: 1.2em; }
.kj-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted, #5f665a); animation: kj-dots 1s ease-in-out infinite; }
.kj-typing i:nth-child(2) { animation-delay: .15s; } .kj-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes kj-dots { 0%, 100% { opacity: .3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }

.kj-note { margin: 0; padding: 6px 16px 0; font: .7rem/1.4 var(--mono, monospace); color: var(--muted, #5f665a); flex: none; }
.kj-note:empty { display: none; }
.kj-chips { flex: none; display: flex; gap: 6px; padding: 8px 16px; overflow-x: auto; scrollbar-width: thin; }
.kj-chips .kj-chip { flex: none; white-space: nowrap; }
.kj-form { flex: none; display: flex; gap: 8px; padding: 4px 16px 10px; }
.kj-input { flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 10px 14px; border-radius: 14px; border: 1px solid var(--faint, rgba(31, 42, 34, .2)); background: var(--bg, #f0efe7); color: var(--fg, #1f2a22); }
.kj-send { flex: none; font: inherit; font-weight: 600; padding: 0 16px; min-height: 44px; border: 0; border-radius: 14px; background: var(--sel, #1d1d1b); color: var(--sel-fg, #fff); cursor: pointer; }
.kj-send:hover { filter: brightness(1.12); }
.kj-foot { flex: none; margin: 0; padding: 0 16px 12px; font-size: .74rem; line-height: 1.4; color: var(--muted, #5f665a); }
.kj-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.kj-ibtn[hidden] { display: none; }

/* voice settings button in the drawer header: an icon button like its neighbours (voice-settings.css supplies the popover) */
.kj-voiceslot { flex: none; display: inline-block; }
.kj-voiceslot .kv-wrap { display: block; }
.kj-head .kv-btn.kj-ibtn { min-height: 0; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 12px; background: transparent; justify-content: center; gap: 0; }
.kj-head .kv-btn.kj-ibtn:hover { background: var(--pill, #e7e6e1); }
.kj-head .kv-btn.kj-ibtn[aria-expanded="true"] { background: var(--sel, #1d1d1b); color: var(--sel-fg, #fff); }
.kj-head .kv-btn.kj-ibtn span { display: none; }
.kj-head { gap: 6px; }
.kj-head .kv-btn.kj-ibtn svg { width: 22px; height: 22px; }

/* captions: a transparent stage over the conversation; nothing in it (and no space taken) unless a reply is being spoken with captions on */
.kj-logwrap { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.kj-logwrap .kj-log { flex: 1; }
.kj-caps { position: absolute; inset: 0; pointer-events: none; }
.kj-ibtn[id="kj-cc"] svg { width: 22px; height: 22px; }
