/* Fajer UR — site assistant: robot in the corner, speech bubble, chat panel.
   Sized in the same design unit (--u) as the rest of the page. */

.bot{position:fixed;z-index:8;inset-inline-end:calc(30 * var(--u));bottom:max(calc(14 * var(--u)),env(safe-area-inset-bottom,0px));display:flex;flex-direction:column;align-items:center;pointer-events:none}
.bot > *{pointer-events:auto}
.bot-body{all:unset;box-sizing:border-box;cursor:pointer;position:relative;display:block;width:calc(230 * var(--u));height:calc(300 * var(--u));min-width:150px;min-height:196px;border-radius:18px}
.bot-body:focus-visible{outline:2px solid var(--or);outline-offset:4px}
#botStage{position:absolute;inset:0;width:100%;height:100%;display:block;opacity:0;transition:opacity .8s ease}
html.bot-ready #botStage{opacity:1}
.bot-still{position:absolute;inset:0;width:100%;height:100%;object-fit:contain;object-position:50% 85%;transition:opacity .6s ease}
html.bot-ready .bot-still{opacity:0}
.bot-plinth{position:absolute;left:50%;bottom:9%;width:74%;height:13%;transform:translateX(-50%);border-radius:50%;border:1.5px solid rgba(255,138,0,.75);box-shadow:0 0 22px rgba(255,138,0,.45),inset 0 0 18px rgba(255,138,0,.35);background:radial-gradient(closest-side,rgba(255,138,0,.28),rgba(255,138,0,0))}
.bot-plinth::after{content:"";position:absolute;inset:-22%;border-radius:50%;border:1px dashed rgba(255,138,0,.45);animation:plinth 3.2s ease-in-out infinite}
@keyframes plinth{0%,100%{opacity:.25;transform:scale(.94)}50%{opacity:.8;transform:scale(1.04)}}
.bot-tag{position:absolute;left:50%;bottom:-2px;transform:translateX(-50%);display:inline-flex;align-items:center;gap:6px;white-space:nowrap;padding:4px 11px;border-radius:99px;background:rgba(6,11,22,.86);border:1px solid rgba(255,138,0,.45);font:600 12.5px/1.2 var(--sans);color:var(--txt)}
.bot-tag::before{content:"";width:7px;height:7px;border-radius:50%;background:#3ddc84;box-shadow:0 0 8px #3ddc84}
.bot-body:hover .bot-tag{background:var(--or);color:#1A0E00;border-color:var(--or)}
html.chat-open .bot-tag{opacity:0}

/* speech bubble with chapter tips */
.bot-bubble{position:relative;margin-bottom:10px;max-width:min(300px,70vw);padding:11px 14px;border-radius:14px;background:rgba(9,16,30,.94);border:1px solid rgba(255,138,0,.5);color:var(--txt);font:500 14px/1.45 var(--sans);box-shadow:0 18px 40px -16px rgba(0,0,0,.7);cursor:pointer}
.bot-bubble::after{content:"";position:absolute;bottom:-7px;inset-inline-end:40%;width:12px;height:12px;background:inherit;border-right:1px solid rgba(255,138,0,.5);border-bottom:1px solid rgba(255,138,0,.5);transform:rotate(45deg)}
.bot-bubble.show{animation:bubble .35s cubic-bezier(.2,.8,.2,1)}
@keyframes bubble{from{opacity:0;transform:translateY(8px) scale(.96)}to{opacity:1;transform:none}}
.bot-bubble[hidden]{display:none}

/* chat panel */
.chat{position:fixed;z-index:9;inset-inline-end:calc(250 * var(--u) + 24px);bottom:max(calc(24 * var(--u)),env(safe-area-inset-bottom,0px));width:min(410px,calc(100vw - 32px));height:min(620px,calc(100vh - 140px));display:flex;flex-direction:column;background:rgba(8,14,27,.95);border:1px solid rgba(255,138,0,.4);border-radius:16px;box-shadow:0 40px 80px -24px rgba(0,0,0,.8);backdrop-filter:blur(12px);overflow:hidden;animation:chatIn .25s cubic-bezier(.2,.8,.2,1);color:var(--txt);font:15px/1.5 var(--sans)}
.chat[hidden]{display:none}
@keyframes chatIn{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:none}}
.chat-head{display:flex;align-items:center;gap:10px;padding:12px 12px 12px 14px;border-bottom:1px solid rgba(255,255,255,.08);background:linear-gradient(180deg,rgba(255,138,0,.08),transparent)}
.chat-av{width:40px;height:40px;border-radius:12px;background:#0B1424;border:1px solid rgba(255,138,0,.4);overflow:hidden;flex:none}
.chat-av img{width:100%;height:130%;object-fit:cover;object-position:50% 12%}
.chat-id{flex:1;min-width:0;display:grid}
.chat-id b{font-size:16px}
.chat-id small{display:flex;align-items:center;gap:6px;font-size:12px;color:var(--tag);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.chat-id small i{width:7px;height:7px;border-radius:50%;background:#3ddc84;flex:none}
.chat-btn{all:unset;cursor:pointer;display:grid;place-items:center;width:36px;height:36px;border-radius:9px;color:var(--sub);flex:none}
.chat-btn:hover,.chat-btn:focus-visible{background:rgba(255,255,255,.07);color:var(--txt);outline:none}
.chat-btn .ic{width:20px;height:20px}
#chatVoice .wv{opacity:.25}
#chatVoice[aria-pressed=true]{color:var(--or);background:rgba(255,138,0,.12)}
#chatVoice[aria-pressed=true] .wv{opacity:1}
.chat-log{flex:1;overflow-y:auto;padding:16px 14px;display:flex;flex-direction:column;gap:10px;overscroll-behavior:contain}
.msg{display:flex;flex-direction:column;align-items:flex-start;gap:6px;max-width:88%}
.msg.me{align-self:flex-end;align-items:flex-end}
.bub{padding:10px 13px;border-radius:14px;background:rgba(255,255,255,.06);border:1px solid rgba(255,255,255,.07);overflow-wrap:anywhere}
.msg.ai .bub{border-start-start-radius:4px}
.msg.me .bub{background:var(--or);color:#1A0E00;border-color:var(--or);border-start-end-radius:4px}
.bub b{color:var(--amber)} .msg.me .bub b{color:inherit}
.bub a{color:var(--amber)}
.msg.typing .bub{color:var(--tag);font-style:italic;animation:pulseT 1.4s ease-in-out infinite}
@keyframes pulseT{50%{opacity:.5}}
.msg-wa{display:inline-flex;align-items:center;gap:8px;padding:9px 14px;border-radius:99px;background:#25D366;color:#062b15;font-weight:600;font-size:14px;text-decoration:none}
.msg-wa .ic{width:18px;height:18px}
.chat-chips{display:flex;flex-wrap:wrap;gap:6px;padding:0 14px 10px}
.chat-chips[hidden]{display:none}
.chat-chips button{all:unset;cursor:pointer;font-size:13px;padding:7px 12px;border-radius:99px;border:1px solid rgba(255,138,0,.45);color:var(--txt);background:rgba(255,138,0,.06)}
.chat-chips button:hover,.chat-chips button:focus-visible{background:rgba(255,138,0,.18)}
.chat-form{display:flex;align-items:center;gap:6px;padding:10px;border-top:1px solid rgba(255,255,255,.08)}
.chat-form input{flex:1;min-width:0;height:44px;padding:0 14px;border-radius:12px;border:1px solid rgba(255,255,255,.12);background:rgba(255,255,255,.05);color:var(--txt);font:inherit;font-size:16px}
.chat-form input:focus{outline:none;border-color:var(--or)}
.chat-send{all:unset;cursor:pointer;display:grid;place-items:center;width:44px;height:44px;border-radius:12px;background:var(--or);color:#1A0E00;flex:none}
.chat-send .ic{width:20px;height:20px}
html[dir=rtl] .chat-send .ic{transform:scaleX(-1)}
.chat-mic.rec{color:#fff;background:#d93a3a;animation:pulseT 1s ease-in-out infinite}
.chat-mic[hidden]{display:none}
.chat-note{margin:0;padding:0 14px 10px;font-size:11.5px;color:var(--tag)}

/* phones: small launcher in the corner, chat takes the whole screen.
   Width is part of the test so the layout stays put when the keyboard shortens the screen. */
@media (max-aspect-ratio:4/5),(max-width:760px){
  .bot{inset-inline-end:10px;bottom:calc(10px + env(safe-area-inset-bottom,0px))}
  .bot-body{width:92px;height:120px;min-width:92px;min-height:120px}
  .bot-tag{font-size:11px;padding:3px 8px}
  .bot-bubble{max-width:min(240px,64vw);font-size:13px}
  .ch .copy{padding-inline-end:84px}
  .chat{inset:0;width:auto;height:auto;border-radius:0;border:0;padding-top:env(safe-area-inset-top,0px);padding-bottom:env(safe-area-inset-bottom,0px)}
  html.chat-open .bot{display:none}
}
@media (prefers-reduced-motion:reduce){.bot-plinth::after,.bot-bubble.show,.chat{animation:none}}
/* the button's "all:unset" would inherit pointer-events:none from .bot — clicks must land on him */
.bot .bot-body,.bot .bot-bubble{pointer-events:auto}

/* while his 3D body loads: an orange scan line builds him, like the site itself.
   The still picture is only for devices that never load the 3D body. */
.bot-still{opacity:0}
html.bot-static .bot-still,html.bot-failed .bot-still{opacity:1}
.bot-load{position:absolute;left:50%;bottom:16%;width:56%;height:70%;transform:translateX(-50%);pointer-events:none;transition:opacity .5s ease}
html.bot-ready .bot-load,html.bot-static .bot-load,html.bot-failed .bot-load{opacity:0}
.bot-load::before{content:"";position:absolute;inset:0;border-radius:40% 40% 12% 12%;border:1px dashed rgba(255,138,0,.35);background:linear-gradient(0deg,rgba(255,138,0,.12),rgba(255,138,0,0) 70%)}
.bot-load i{position:absolute;left:-8%;right:-8%;height:2px;bottom:0;background:var(--or);box-shadow:0 0 12px var(--or),0 0 26px rgba(255,138,0,.6);animation:botScan 1.6s cubic-bezier(.45,0,.55,1) infinite}
@keyframes botScan{0%{bottom:0;opacity:0}12%{opacity:1}88%{opacity:1}100%{bottom:100%;opacity:0}}
.bot-load b{position:absolute;left:50%;top:44%;transform:translateX(-50%);font:500 12px/1 var(--mono);letter-spacing:.12em;color:var(--or)}
@media (prefers-reduced-motion:reduce){.bot-load i{animation:none;bottom:50%}}
/* phones: the chat fills only the visible area above the keyboard (set by assistant.js from visualViewport) */
@media (max-aspect-ratio:4/5),(max-width:760px){
  .chat{inset:auto 0 auto 0;top:var(--vvt,0px);height:var(--vvh,100dvh);max-height:none}
  .chat-log{min-height:0}
  html.chat-open,html.chat-open body{overflow:hidden;overscroll-behavior:none}
}
