/* The help chatbot (js/chat.js), hosted by Coach Iris: she stands in the bottom-right corner with a greeting bubble,
   and the chat panel opens in her place. Uses the tokens from styles.css; the coach art lives in assets/chat/. */
.chat{position:fixed;right:20px;bottom:0;z-index:900;font-family:var(--font);color:var(--ink)}
.chat svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.chat button:focus-visible,.chat textarea:focus-visible{outline:2px solid var(--ink);outline-offset:2px}

/* ---- the coach strolling in the corner (js/chat.js moves .chat-walker along the stage) ----
   .walking: steps (bob and sway) · .right: walking right, so the art is mirrored · .greet: stops, hops and waves · .say: greeting bubble */
.chat-launch{position:relative;width:280px;height:190px;pointer-events:none}
.chat.on .chat-launch{display:none}
.chat-walker{position:absolute;left:0;bottom:0;will-change:transform}
.chat-walker>*{pointer-events:auto}
.chat-flip{transition:transform .25s ease}
.chat.right .chat-flip{transform:scaleX(-1)}
.chat-coach{position:relative;display:block;padding:0;border:0;background:none;cursor:pointer;line-height:0;transform-origin:50% 100%;filter:drop-shadow(0 6px 8px rgba(18,18,18,.14))}
.chat-coach img{display:block;width:auto;height:132px}
.chat-coach .chat-hand{position:absolute;left:0;top:0;transform-origin:24.2% 30.25%}
.chat-coach:focus-visible{outline-offset:-4px;border-radius:12px}
.chat.walking .chat-coach{animation:chat-step .5s ease-in-out infinite}
.chat.walking .chat-hand{animation:chat-swing .5s ease-in-out infinite}
.chat.greet .chat-coach{animation:chat-hop .7s ease-out 1}
.chat.greet .chat-hand{animation:chat-wave .9s ease-in-out infinite}
@keyframes chat-step{0%,100%{transform:translateY(0) rotate(-2.5deg)}25%{transform:translateY(-5px) rotate(0)}50%{transform:translateY(0) rotate(2.5deg)}75%{transform:translateY(-5px) rotate(0)}}
@keyframes chat-swing{0%,100%{transform:rotate(-6deg)}50%{transform:rotate(6deg)}}
@keyframes chat-hop{0%{transform:none}35%{transform:translateY(-10px) scale(1.02,.98)}65%{transform:translateY(0) scale(1.03,.97)}100%{transform:none}}
@keyframes chat-wave{0%,100%{transform:rotate(0)}25%{transform:rotate(-16deg)}50%{transform:rotate(6deg)}75%{transform:rotate(-14deg)}}
.chat-hi{position:absolute;right:44px;bottom:136px;width:max-content;max-width:190px;padding:9px 13px;border:1.5px solid var(--ink);border-radius:16px 16px 4px 16px;background:var(--bg);color:var(--ink);font:600 14px/1.3 var(--font);text-align:left;cursor:pointer;box-shadow:3px 3px 0 var(--ink);opacity:0;transform:translateY(8px) scale(.9);transform-origin:100% 100%;visibility:hidden;transition:opacity .25s ease,transform .3s cubic-bezier(.2,1.4,.4,1),visibility 0s .3s}
.chat.say .chat-hi{opacity:1;transform:none;visibility:visible;transition:opacity .25s ease,transform .3s cubic-bezier(.2,1.4,.4,1)}
.chat-hi:hover{background:var(--tint-cream)}
@keyframes chat-pop{from{opacity:0;transform:translateY(8px) scale(.9)}to{opacity:1;transform:none}}

/* ---- the panel ---- */
.chat-panel{position:absolute;right:0;bottom:20px;width:392px;height:min(640px,calc(100vh - 40px));display:flex;flex-direction:column;background:var(--bg);border:1.5px solid var(--ink);border-radius:16px;box-shadow:6px 6px 0 rgba(18,18,18,.9);overflow:hidden;animation:chat-pop .25s both ease-out}
.chat-panel[hidden]{display:none}
.chat-h{display:flex;align-items:center;gap:12px;padding:12px 12px 12px 14px;background:var(--red);color:#fff}
.chat-av{position:relative;flex:none;width:44px;height:44px;border-radius:50%;background:#fff;border:1.5px solid var(--ink);overflow:hidden}
.chat-av img{display:block;width:100%;height:100%}
.chat-on{position:absolute;right:1px;bottom:1px;width:11px;height:11px;border-radius:50%;background:#3FB46B;border:2px solid #fff}
.chat-who{flex:1;min-width:0}
.chat-who b{display:block;font-size:16px;line-height:1.2}
.chat-sub{display:block;font-size:12px;opacity:.85;margin-top:2px}
.chat-x{display:grid;place-items:center;width:34px;height:34px;flex:none;border:0;border-radius:17px;background:rgba(255,255,255,.16);color:#fff;cursor:pointer}
.chat-x:hover{background:rgba(255,255,255,.28)}
.chat-x:focus-visible{outline-color:#fff}

.chat-log{flex:1;overflow-y:auto;padding:16px 14px;display:flex;flex-direction:column;gap:12px;background:var(--bg)}
.chat-hero{display:flex;align-items:flex-end;gap:8px;padding:16px 0 0 16px;border-radius:14px;background:var(--tint-cream);overflow:hidden}
.chat-hero>div{flex:1;padding-bottom:16px}
.chat-hero img{flex:none;width:120px;height:auto;margin-right:-6px}
.chat-kick{display:block;font-size:11px;font-weight:700;letter-spacing:.12em;text-transform:uppercase;color:var(--red)}
.chat-hero h3{margin:6px 0 6px;font:600 21px/1.2 var(--font-display)}
.chat-hero p{margin:0;font-size:13.5px;line-height:1.45;color:var(--ink-2)}
.chat-sugg{display:flex;flex-direction:column;gap:6px}
.chat-sugg small{font-size:12px;font-weight:600;color:var(--muted);margin:2px 2px 2px}
.chat-sugg button{display:flex;align-items:center;justify-content:space-between;gap:10px;width:100%;padding:11px 12px 11px 14px;border:1px solid var(--line-2);border-radius:12px;background:var(--bg);color:var(--ink);font:500 14px/1.3 var(--font);text-align:left;cursor:pointer}
.chat-sugg button svg{width:16px;height:16px;flex:none;color:var(--red)}
.chat-sugg button:hover{border-color:var(--red);background:var(--red-soft)}

.chat-row{display:flex;align-items:flex-end;gap:8px}
.chat-row.me{justify-content:flex-end}
.chat-face{flex:none;width:32px;height:32px;border-radius:50%;border:1.5px solid var(--ink);background:#fff}
.chat-m{max-width:82%;padding:10px 13px;border-radius:14px;font-size:14.5px;line-height:var(--lh-text);overflow-wrap:anywhere}
.chat-row.bot .chat-m{background:var(--bg-2);border-bottom-left-radius:4px}
.chat-row.me .chat-m{background:var(--red);color:#fff;border-bottom-right-radius:4px}
.chat-m a{color:var(--red);text-decoration:underline}
.chat-row.wait .chat-m{display:flex;gap:4px;padding:15px 14px}
.chat-row.wait i{width:6px;height:6px;border-radius:3px;background:var(--muted);animation:chat-dot 1s infinite ease-in-out}
.chat-row.wait i:nth-child(2){animation-delay:.15s}.chat-row.wait i:nth-child(3){animation-delay:.3s}
@keyframes chat-dot{0%,80%,100%{opacity:.25}40%{opacity:1}}

.chat-f{display:flex;align-items:flex-end;gap:8px;margin:0 12px;padding:6px 6px 6px 14px;border:1.5px solid var(--line-2);border-radius:24px;background:var(--bg)}
.chat-f:focus-within{border-color:var(--ink)}
.chat-f textarea{flex:1;resize:none;border:0;outline:0;padding:8px 0;font:15px/1.4 var(--font);color:var(--ink);background:transparent;max-height:120px}
.chat-f textarea:focus-visible{outline:0}
.chat-go{display:grid;place-items:center;width:38px;height:38px;flex:none;border:0;border-radius:19px;background:var(--red);color:#fff;cursor:pointer}
.chat-go:hover{background:var(--red-dark)}
.chat-f.busy .chat-go{opacity:.4;cursor:wait}
.chat-foot{display:flex;justify-content:center;align-items:center;gap:8px;margin:0;padding:8px 12px 10px;color:var(--muted);font-size:12.5px}
.chat-foot button{border:0;background:none;padding:2px;color:var(--muted);font:500 12.5px/1.3 var(--font);text-decoration:underline;cursor:pointer}
.chat-foot button:hover{color:var(--red)}

@media (max-width:520px){
  .chat{right:12px}
  .chat-launch{width:180px;height:124px}
  .chat-coach img{height:104px}
  .chat-hi{bottom:108px;right:34px;max-width:150px;font-size:13px;padding:8px 12px}
  .chat-panel{position:fixed;left:0;right:0;bottom:0;width:auto;height:88vh;height:88dvh;border-radius:18px 18px 0 0;border-width:1.5px 0 0;box-shadow:0 -8px 30px rgba(18,18,18,.2)}
  .chat-hero img{width:104px}
}
@media (prefers-reduced-motion:reduce){.chat *,.chat{animation:none!important;transition:none!important}}
@media print{.chat{display:none}}
