/* ============================================================
   THUNDERWORKFLOW · "SPEAK WITH RAAED" WIDGET
   Floating avatar bottom-right. Idle pulse.
   Click → thunderbolt strikes UP and a chat panel opens.
   ============================================================ */

.raaed{
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 95;
  font-family: 'Inter', system-ui, sans-serif;
  --rd-accent: oklch(0.76 0.19 255);
  --rd-bg:     #0d0f13;
  --rd-fg:     #f6f5f1;
  --rd-line:   rgba(255,255,255,.08);
  --rd-line2:  rgba(255,255,255,.14);
  --rd-dim:    rgba(246,245,241,.62);
  --rd-mute:   rgba(246,245,241,.42);
}

/* ---------- the button ---------- */
.raaed__btn{
  position: relative;
  display: flex; flex-direction: column;
  align-items: flex-end; gap: 10px;
  background: none; border: 0; padding: 0;
  cursor: pointer;
}
.raaed__pill{
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--rd-accent);
  color: #07080a;
  font-weight: 600; font-size: 13px;
  letter-spacing: .005em;
  box-shadow: 0 8px 24px rgba(77,140,255,.35), inset 0 1px 0 rgba(255,255,255,.3);
  white-space: nowrap;
  position: relative;
  transition: transform .25s ease;
}
.raaed__pill::after{
  /* tail pointing down to the avatar */
  content: '';
  position: absolute;
  bottom: -5px; right: 18px;
  width: 10px; height: 10px;
  background: var(--rd-accent);
  transform: rotate(45deg);
}
.raaed__btn:hover .raaed__pill{ transform: translateY(-2px); }

.raaed__avatar{
  position: relative;
  width: 64px; height: 64px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow:
    0 0 0 2px var(--rd-accent),
    0 0 0 4px rgba(7,8,10,1),
    0 0 0 5px var(--rd-accent),
    0 14px 40px rgba(77,140,255,.4);
  background: linear-gradient(135deg, oklch(0.68 0.16 250), oklch(0.45 0.14 280));
  isolation: isolate;
  transition: transform .25s ease;
}
.raaed__btn:hover .raaed__avatar{ transform: scale(1.04); }

/* Raaed avatar — placeholder. SWAP with <img> when you have a real photo */
.raaed__avatar__img,
.raaed__avatar img{
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.raaed__initials{
  width: 100%; height: 100%;
  display: none;
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  color: #f6f5f1;
  font-size: 28px;
  letter-spacing: -.01em;
}

/* online dot */
.raaed__online{ display:none;
  position: absolute; bottom: 0; right: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #2da965;
  box-shadow: 0 0 0 3px #07080a, 0 0 12px rgba(45,169,101,.6);
  z-index: 2;
  animation: rdBreath 2s ease-in-out infinite;
}
@keyframes rdBreath {
  0%, 100% { box-shadow: 0 0 0 3px #07080a, 0 0 12px rgba(45,169,101,.6); }
  50%      { box-shadow: 0 0 0 3px #07080a, 0 0 18px rgba(45,169,101,.9); }
}

/* idle electric pulse ring */
.raaed__pulse{
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid var(--rd-accent);
  opacity: 0;
  animation: rdPulse 3s ease-out infinite;
  pointer-events: none;
}
.raaed__pulse:nth-child(2){ animation-delay: 1s; }
.raaed__pulse:nth-child(3){ animation-delay: 2s; }
@keyframes rdPulse {
  0%   { transform: scale(1); opacity: .8; }
  70%  { transform: scale(1.6); opacity: 0; }
  100% { transform: scale(1.7); opacity: 0; }
}

/* tiny lightning bolt that sits on the pill */
.raaed__pill svg{ width:12px; height:14px; }

/* ---------- launching bolt animation ---------- */
.raaed__strike{
  position: fixed;
  pointer-events: none;
  z-index: 99;
  opacity: 0;
}
.raaed__strike.is-striking{
  animation: rdStrike .9s cubic-bezier(.2,.7,.2,1) forwards;
}
@keyframes rdStrike {
  0%   { opacity: 0; transform: translateY(0) scale(.6); }
  15%  { opacity: 1; transform: translateY(-20px) scale(1); }
  100% { opacity: 0; transform: translateY(-100vh) scale(1.4); }
}
.raaed__strike svg{
  width: 80px; height: 100px;
  filter: drop-shadow(0 0 20px var(--rd-accent)) drop-shadow(0 0 40px var(--rd-accent));
}

/* full screen flash */
.raaed__flash{
  position: fixed; inset: 0;
  background: #fff;
  opacity: 0;
  z-index: 97;
  pointer-events: none;
  mix-blend-mode: screen;
}
.raaed__flash.is-flashing{
  animation: rdFlash .6s ease-out forwards;
}
@keyframes rdFlash {
  0%   { opacity: 0; }
  10%  { opacity: .35; }
  20%  { opacity: .1; }
  30%  { opacity: .25; }
  100% { opacity: 0; }
}

/* arcing electricity trail (multiple bolts shoot up) */
.raaed__trail{
  position: fixed;
  pointer-events: none;
  z-index: 98;
  width: 1px;
  background: linear-gradient(to top, var(--rd-accent), transparent);
  filter: drop-shadow(0 0 6px var(--rd-accent));
  opacity: 0;
  transform-origin: bottom center;
}
.raaed__trail.is-going{
  animation: rdTrail .6s ease-out forwards;
}
@keyframes rdTrail {
  0%   { opacity: 1; height: 0; }
  60%  { opacity: 1; height: 80vh; }
  100% { opacity: 0; height: 80vh; }
}

/* ---------- chat panel ---------- */
.raaed__panel{
  position: fixed;
  bottom: 24px; right: 24px;
  width: 360px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  background: rgba(13,15,19,.92);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border: 1px solid var(--rd-line2);
  border-radius: 20px;
  box-shadow:
    0 0 0 1px rgba(77,140,255,.16),
    0 30px 80px rgba(0,0,0,.5),
    0 0 60px rgba(77,140,255,.2);
  z-index: 100;
  display: flex; flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(40px) scale(.96);
  pointer-events: none;
  transition: opacity .35s ease, transform .45s cubic-bezier(.2,.7,.2,1);
}
.raaed__panel.is-open{
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.raaed__panel__head{ flex-wrap: nowrap; overflow: visible;
  display: flex; align-items: center; gap: 12px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--rd-line);
  background: linear-gradient(180deg, rgba(77,140,255,.08), transparent);
}
.raaed__panel__avatar{
  width: 44px; height: 44px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 0 2px var(--rd-accent), 0 0 0 4px var(--rd-bg);
  background: linear-gradient(135deg, oklch(0.68 0.16 250), oklch(0.45 0.14 280));
  position: relative; flex-shrink: 0;
}
.raaed__panel__avatar img{ width:100%; height:100%; object-fit:cover; display:block; }
.raaed__panel__avatar .raaed__initials{ font-size: 20px; }
.raaed__panel__title{ flex: 1; }
.raaed__panel__title b{
  display: block;
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  font-weight: 400;
  font-size: 19px;
  letter-spacing: -.01em;
  color: var(--rd-fg);
}
.raaed__panel__title span{
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px; letter-spacing: .12em;
  color: var(--rd-dim);
  display: flex; align-items: center; gap: 6px;
}
.raaed__panel__title span::before{
  content:''; width:6px; height:6px; border-radius:50%;
  background:#2da965; box-shadow: 0 0 8px rgba(45,169,101,.7);
}
.raaed__close{ display: grid !important; place-items: center !important; flex-shrink: 0 !important;
  width: 32px; height: 32px;
  display: none;
  border-radius: 50%;
  background: rgba(255,255,255,.04);
  border: 0; color: var(--rd-dim);
  cursor: pointer;
  transition: background .2s, color .2s;
}
.raaed__close:hover{ background: rgba(255,255,255,.1); color: var(--rd-fg); }

.raaed__panel__body{
  padding: 20px 18px;
  display: flex; flex-direction: column; gap: 10px;
  overflow-y: auto;
  flex: 1;
}
.raaed__msg{
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  opacity: 0;
  animation: rdMsgIn .4s ease forwards;
}
@keyframes rdMsgIn { to { opacity: 1; transform: none; } }
.raaed__msg--in{
  align-self: flex-start;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--rd-line);
  color: var(--rd-fg);
  border-bottom-left-radius: 4px;
  transform: translateY(4px);
}
.raaed__msg--out{
  align-self: flex-end;
  background: var(--rd-accent);
  color: #07080a;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}
.raaed__msg--out{ transform: translateY(4px); }
.raaed__msg__ar{
  display: block;
  margin-top: 4px;
  font-family: 'IBM Plex Sans Arabic', sans-serif;
  direction: rtl;
  font-size: 13px;
  color: var(--rd-dim);
}
.raaed__msg--in .raaed__msg__ar{ color: var(--rd-dim); }
.raaed__msg--out .raaed__msg__ar{ color: rgba(7,8,10,.7); }

.raaed__typing{
  align-self: flex-start;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--rd-line);
  padding: 10px 14px;
  border-radius: 14px;
  display: flex; gap: 5px;
  border-bottom-left-radius: 4px;
}
.raaed__typing span{
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--rd-dim);
  animation: rdDot 1s infinite;
}
.raaed__typing span:nth-child(2){ animation-delay: .15s; }
.raaed__typing span:nth-child(3){ animation-delay: .3s; }
@keyframes rdDot {
  0%, 60%, 100% { opacity: .3; transform: translateY(0); }
  30%           { opacity: 1; transform: translateY(-3px); }
}

.raaed__quick{
  display: flex; flex-direction: column; gap: 8px;
  padding: 8px 18px 0;
}
.raaed__quick__btn{
  text-align: left;
  padding: 12px 14px;
  background: transparent;
  border: 1px solid var(--rd-line2);
  border-radius: 12px;
  color: var(--rd-fg);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all .2s ease;
  display: flex; align-items: center; gap: 10px;
  opacity: 0; transform: translateY(8px);
  animation: rdQuickIn .4s ease forwards;
}
.raaed__quick__btn:hover{
  background: rgba(77,140,255,.08);
  border-color: var(--rd-accent);
}
.raaed__quick__btn svg{
  flex-shrink: 0;
  color: var(--rd-accent);
}
@keyframes rdQuickIn { to { opacity: 1; transform: none; } }

.raaed__panel__foot{
  padding: 14px 18px 18px;
  border-top: 1px solid var(--rd-line);
  background: rgba(7,8,10,.4);
}
.raaed__cta{
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%;
  padding: 14px 18px;
  background: #25d366;
  color: #07080a;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  transition: transform .2s, box-shadow .2s;
  box-shadow: 0 8px 24px rgba(37,211,102,.3);
}
.raaed__cta:hover{
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(37,211,102,.5);
}
.raaed__hint{
  display: block; text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: .12em;
  color: var(--rd-mute);
  margin-top: 10px;
}

/* ---------- responsive ---------- */
@media (max-width: 600px){
  .raaed{ bottom: 18px; right: 18px; }
  .raaed__panel{
    width: calc(100vw - 32px);
    bottom: 18px; right: 16px; left: 16px;
  }
  .raaed__pill{ display: none; } /* keep just the avatar on mobile */
  .raaed__pill::after{ display:none; }
}

/* hide button while panel is open (less clutter) */
.raaed.is-open .raaed__btn{
  opacity: 0;
  pointer-events: none;
  transform: scale(.5);
  transition: all .3s ease;
}

/* reduced motion */
@media (prefers-reduced-motion: reduce){
  .raaed__pulse{ animation: none; opacity: 0; }
  .raaed__strike.is-striking{ animation-duration: .3s; }
  .raaed__flash.is-flashing{ animation: none; }
  .raaed__online{ display:none; animation: none; display: none; }
}
