/* 27-assistant.css — the smart assistant (js/ui/assistant.js): a round launcher in
   the bottom corner opposite the menu (right in English, left in Dari/Arabic), and
   the conversation it opens — a chat window rising from that corner on wider
   screens, the whole screen on a phone. Answers reuse the coach's charts (26-coach.css). */

/* Where the launcher sits: the screen's corner, or just above the phone's bottom dock. */
:root{--asst-fab:56px;--asst-fab-x:24px;--asst-fab-y:24px}
@media (max-width:860px){:root{--asst-fab:52px;--asst-fab-x:16px;--asst-fab-y:calc(12px + 70px + 14px + var(--sab))}}

.asst-fab{position:fixed;z-index:99;inset-inline-end:var(--asst-fab-x);bottom:var(--asst-fab-y);width:var(--asst-fab);height:var(--asst-fab);
  border:0;border-radius:50%;display:grid;place-items:center;cursor:pointer;background:var(--acc-fill,var(--acc));color:var(--acc-ink);
  box-shadow:0 14px 32px -12px color-mix(in srgb,var(--acc-fill,var(--acc)) 75%,transparent),0 6px 18px -8px rgba(0,0,0,.5),inset 0 1px 0 rgba(255,255,255,.45);
  transition:transform var(--t2,.18s) var(--spring,ease),box-shadow var(--t2,.18s),opacity .18s}
.asst-fab:hover{transform:translateY(-2px)}
.asst-fab:active{transform:scale(.93)}
.asst-fab:focus-visible{outline:3px solid color-mix(in srgb,var(--acc) 55%,transparent);outline-offset:3px}
.asst-fab .ic{grid-area:1/1;width:24px;height:24px;stroke-width:2.2;transition:transform .22s var(--ease-out,ease),opacity .18s}
.asst-fab .asst-fab-x{opacity:0;transform:rotate(-90deg) scale(.6)}
.asst-fab[aria-expanded="true"] .asst-fab-open{opacity:0;transform:rotate(90deg) scale(.6)}
.asst-fab[aria-expanded="true"] .asst-fab-x{opacity:1;transform:none}
/* Out of the way: while the app is locked, while typing in a form on a phone (the keyboard is up),
   and under a full-screen conversation. */
html.auth-blocked .asst-fab,html.auth-blocked .asst,html.auth-blocked .asst-hint{display:none!important}
@media (max-width:860px){html.asst-typing .asst-fab,html.asst-typing .asst-hint{opacity:0;pointer-events:none}}

/* A one-time hello next to the launcher, so people find it. */
.asst-hint{position:fixed;z-index:98;inset-inline-end:calc(var(--asst-fab-x) + var(--asst-fab) + 10px);bottom:calc(var(--asst-fab-y) + 6px);
  max-width:min(260px,calc(100vw - var(--asst-fab) - var(--asst-fab-x) - 26px));display:flex;align-items:center;gap:2px;padding:4px 4px 4px 12px;
  background:var(--surf3);border:1px solid var(--line2);border-radius:14px;border-end-end-radius:4px;box-shadow:var(--sh-3);animation:asst-hint-in .3s var(--ease-out,ease)}
[dir="rtl"] .asst-hint{padding:4px 12px 4px 4px}
.asst-hint[hidden]{display:none}
.asst-hint-go{flex:1 1 auto;min-width:0;border:0;background:none;color:var(--ink);font:inherit;font-size:13px;font-weight:600;line-height:1.5;text-align:start;cursor:pointer;padding:4px 0}
.asst-hint-x{flex:0 0 auto;width:28px;height:28px;border:0;border-radius:50%;background:none;color:var(--mute);display:grid;place-items:center;cursor:pointer}
.asst-hint-x:hover{background:var(--hover);color:var(--ink)}
.asst-hint-x .ic{width:14px;height:14px}
@keyframes asst-hint-in{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}

/* The conversation: a chat window rising from the launcher's corner… */
.asst{position:fixed;z-index:99;inset-inline-end:var(--asst-fab-x);bottom:calc(var(--asst-fab-y) + var(--asst-fab) + 14px);
  width:min(400px,calc(100vw - 2 * var(--asst-fab-x)));height:min(640px,calc(100vh - var(--asst-fab-y) - var(--asst-fab) - 38px));height:min(640px,calc(100dvh - var(--asst-fab-y) - var(--asst-fab) - 38px));
  display:flex;flex-direction:column;overflow:hidden;background:var(--surf);border:1px solid var(--line2);border-radius:22px;
  box-shadow:0 30px 80px -24px rgba(0,0,0,.6),0 10px 30px -12px rgba(0,0,0,.35);
  transform-origin:bottom right;opacity:0;transform:translateY(14px) scale(.96);transition:opacity .18s ease,transform .24s var(--ease-out,ease)}
[dir="rtl"] .asst{transform-origin:bottom left}
.asst.on{opacity:1;transform:none}
.asst[hidden]{display:none}
/* …and the whole screen on a phone, where the keyboard needs the room. */
@media (max-width:640px){
  .asst{inset:0;width:auto;height:auto;border:0;border-radius:0;transform:translateY(24px);box-shadow:none}
  .asst.on{transform:none}
  html.asst-open .asst-fab{opacity:0;pointer-events:none}
  html.asst-open body{overflow:hidden}
}
@media (prefers-reduced-motion:reduce){.asst,.asst-fab,.asst-fab .ic{transition:none}.asst-hint{animation:none}}
@media print{.asst,.asst-fab,.asst-hint{display:none!important}}

.asst-head{flex:0 0 auto;display:flex;align-items:center;gap:10px;padding:10px 8px 10px 14px;border-bottom:1px solid var(--line)}
@media (max-width:640px){.asst-head{padding-top:calc(10px + env(safe-area-inset-top))}}
.asst-mark{width:34px;height:34px;flex:0 0 auto;border-radius:50%;display:grid;place-items:center;background:var(--acc-dim);color:var(--acc)}
.asst-mark .ic{width:18px;height:18px}
.asst-id{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;line-height:1.35}
.asst-id b{font-size:14px;color:var(--ink)}
.asst-id small{font-size:11px;color:var(--mute);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

.asst-log{flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:14px 12px 8px;display:flex;flex-direction:column;gap:10px}
.asst-msg{max-width:88%;padding:9px 12px;border-radius:16px;font-size:13px;line-height:1.85;overflow-wrap:anywhere}
.asst-msg.me{align-self:flex-end;background:var(--acc-fill,var(--acc));color:var(--acc-ink);border-end-end-radius:6px}
.asst-msg.bot{align-self:flex-start;width:92%;max-width:92%;background:var(--surf2);color:var(--ink);border:1px solid var(--line);border-end-start-radius:6px}
.asst-msg p{margin:0 0 6px}
.asst-msg p:last-child{margin-bottom:0}
.asst-h{font-weight:800}
.asst-insight{color:var(--dim)}
.asst-note{font-size:11.5px;color:var(--mute)}
.asst-scope{display:flex;flex-wrap:wrap;gap:4px;margin-bottom:6px}
.asst-tag{font-size:10.5px;font-weight:700;line-height:1.6;padding:1px 8px;border-radius:999px;background:var(--acc-dim);color:var(--acc)}
.asst-tag.f{background:var(--surf3);color:var(--dim)}
.asst-viz{margin:6px 0 2px}
.asst-viz .coach-viz{padding:4px 0 2px;border:0;gap:10px;grid-template-columns:1fr}
.asst-viz .cv-meters{justify-content:flex-start;gap:14px}
.asst-acts{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}
.asst-acts .btn .ic{width:13px;height:13px}
.asst-list{margin:4px 0 6px;padding-inline-start:1.2em;display:flex;flex-direction:column;gap:5px}
.asst-list li span{display:block;font-size:11.5px;color:var(--dim)}
.asst-trades{display:flex;flex-direction:column;gap:4px;margin:6px 0}
.asst-tr{display:grid;grid-template-columns:auto minmax(0,1fr) auto auto;align-items:center;gap:8px;padding:6px 9px;border:1px solid var(--line);border-radius:10px;
  background:var(--surf);color:inherit;font:inherit;font-size:12px;text-align:start;cursor:pointer}
.asst-tr:hover{background:var(--hover)}
.asst-tr.static{grid-template-columns:minmax(0,1fr) auto auto;cursor:default}
.asst-tr .d{font-size:11px;color:var(--mute)}
.asst-tr .side{font-size:11px;color:var(--dim)}
.asst-tr b{font-variant-numeric:tabular-nums;color:var(--ink)}
.asst-tr b.up{color:var(--up)}
.asst-tr b.dn{color:var(--dn)}

.asst-msg.typing{display:flex;gap:4px;width:auto;padding:12px 14px}
.asst-msg.typing span{width:7px;height:7px;border-radius:50%;background:var(--mute);animation:asst-dot 1s infinite ease-in-out}
.asst-msg.typing span:nth-child(2){animation-delay:.15s}
.asst-msg.typing span:nth-child(3){animation-delay:.3s}
@keyframes asst-dot{0%,80%,100%{opacity:.3;transform:translateY(0)}40%{opacity:1;transform:translateY(-3px)}}
@media (prefers-reduced-motion:reduce){.asst-msg.typing span{animation-duration:2.4s}}

.asst-chips{flex:0 0 auto;display:flex;gap:6px;overflow-x:auto;padding:6px 12px 2px;scrollbar-width:none}
.asst-chips::-webkit-scrollbar{display:none}
/* A soft edge where the row runs on, so it reads as "scroll for more", not "cut off". */
.asst-chips{-webkit-mask-image:linear-gradient(to right,transparent 0,#000 12px,#000 calc(100% - 28px),transparent 100%);mask-image:linear-gradient(to right,transparent 0,#000 12px,#000 calc(100% - 28px),transparent 100%)}
[dir="rtl"] .asst-chips{-webkit-mask-image:linear-gradient(to left,transparent 0,#000 12px,#000 calc(100% - 28px),transparent 100%);mask-image:linear-gradient(to left,transparent 0,#000 12px,#000 calc(100% - 28px),transparent 100%)}
.asst-chips:empty{display:none}
.asst-chip{flex:0 0 auto;padding:6px 11px;border-radius:999px;border:1px solid var(--line2);background:var(--surf2);color:var(--ink);font:inherit;font-size:12px;white-space:nowrap;cursor:pointer;transition:background var(--t1)}
.asst-chip:hover{background:var(--hover)}
.asst-in{flex:0 0 auto;display:flex;align-items:center;gap:8px;padding:8px 12px 10px;border-top:1px solid var(--line)}
@media (max-width:640px){.asst-in{padding-bottom:calc(10px + env(safe-area-inset-bottom))}}
.asst-in input{flex:1 1 auto;min-width:0;height:44px;padding:0 16px;border-radius:999px;border:1px solid var(--line2);background:var(--surf2);color:var(--ink);font:inherit;font-size:14px}
.asst-in input:focus{outline:none;border-color:var(--acc)}
.asst-send{flex:0 0 44px;width:44px;height:44px;border-radius:50%;border:0;display:grid;place-items:center;background:var(--acc-fill,var(--acc));color:var(--acc-ink);cursor:pointer}
.asst-send .ic{width:18px;height:18px}
