/* ═══ ROBO ASISTEN — scoped .rb- styles ═══
   Floating robot mascot + chat panel with two choices (Generate Prediksi,
   Panduan Bermain). Uses the landing page violet / fuchsia tokens from
   style.css, so it follows the dark and light themes automatically. */

.rb {
  --rb-size: 156px;
  --rb-right: 22px;
  --rb-bottom: 22px;
  --rb-grad: linear-gradient(135deg, var(--violet-400), var(--violet-500) 45%, var(--fuchsia-500));
  --rb-line: rgba(196, 181, 253, 0.42);
  --rb-glow: rgba(217, 70, 239, 0.38);
  --rb-cyan: #22D3EE;
  position: fixed; z-index: 990;
  right: var(--rb-right); bottom: var(--rb-bottom);
  font-family: var(--font); color: var(--txt);
}
:root[data-theme="light"] .rb {
  --rb-line: rgba(109, 40, 217, 0.30);
  --rb-glow: rgba(162, 28, 175, 0.24);
}
.rb svg {
  width: 18px; height: 18px; flex-shrink: 0;
  fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
}
.rb img { display: block; width: 100%; height: 100%; object-fit: contain; }

/* ═══ Robot button — transparent mascot floating over a ground shadow ═══ */
.rb-fab {
  position: relative; display: block;
  width: var(--rb-size); height: calc(var(--rb-size) * 1.04); padding: 0;
  border: none; border-radius: 24px; background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.rb-fab-bot {
  position: absolute; inset: 0 0 auto; height: var(--rb-size);
  animation: rb-float 3.4s ease-in-out infinite;
  transform-origin: 50% 90%;
}
.rb-fab-bot img {
  object-fit: contain;
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.28)) drop-shadow(0 0 18px var(--rb-glow));
  transition: transform 300ms var(--ease-out), filter 300ms ease;
}
@keyframes rb-float {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50%      { transform: translateY(-14px) rotate(2deg); }
}
/* the shadow shrinks and fades as the robot rises, grows as it comes down */
.rb-fab-shadow {
  position: absolute; left: 50%; bottom: 0;
  width: 54%; height: 18px; margin-left: -27%;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.8);
  filter: blur(4px);
  animation: rb-shadow 3.4s ease-in-out infinite;
}
:root[data-theme="light"] .rb-fab-shadow { background: rgba(46, 16, 101, 0.62); }
@keyframes rb-shadow {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(0.62); opacity: 0.45; }
}
.rb-fab-badge {
  position: absolute; top: 4%; right: 6%;
  display: grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 999px; border: 2px solid var(--bg-0, #0B0614);
  color: var(--on-accent); background: var(--rb-grad);
  font: 800 0.7rem/1 var(--font);
  box-shadow: 0 3px 10px var(--rb-glow);
  transition: transform 260ms var(--ease-out), opacity 200ms ease;
}
.rb-fab:hover .rb-fab-bot img { transform: scale(1.06); filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.3)) drop-shadow(0 0 26px var(--rb-glow)); }
.rb-fab:active .rb-fab-bot img { transform: scale(0.95); }
.rb-fab:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.rb.is-open .rb-fab-badge, .rb.is-seen .rb-fab-badge { transform: scale(0); opacity: 0; }

/* ═══ Hint bubble (until the robot has been opened once) ═══ */
.rb-hint {
  position: absolute; right: calc(100% + 12px); bottom: calc(var(--rb-size) * 0.55);
  width: max-content; max-width: 210px; padding: 10px 14px;
  border: 1px solid var(--rb-line); border-radius: 16px 16px 4px 16px;
  background: var(--g-tinted); color: var(--txt-2);
  -webkit-backdrop-filter: var(--g-blur-sm); backdrop-filter: var(--g-blur-sm);
  box-shadow: var(--g-inset), var(--g-shadow);
  font-size: 0.78rem; line-height: 1.4; pointer-events: none;
  animation: rb-hint-in 600ms var(--ease-out) 1.4s both;
  transition: opacity 200ms ease, transform 200ms ease;
}
.rb-hint b { color: var(--txt); font-weight: 800; }
@keyframes rb-hint-in { from { opacity: 0; transform: translateX(10px) scale(0.95); } }
.rb.is-seen .rb-hint, .rb.is-open .rb-hint { opacity: 0; transform: translateX(8px); visibility: hidden; transition: opacity 200ms ease, transform 200ms ease, visibility 0s 200ms; }

/* ═══ Chat panel ═══ */
.rb-panel {
  position: absolute; right: 0; bottom: calc(var(--rb-size) * 1.04 + 10px);
  width: min(340px, calc(100vw - 28px));
  overflow: hidden;
  border: 1px solid var(--rb-line); border-radius: var(--r-md, 20px);
  background: var(--g-tinted);
  -webkit-backdrop-filter: var(--g-blur); backdrop-filter: var(--g-blur);
  box-shadow: var(--g-inset), var(--g-shadow-hi);
  transform-origin: calc(100% - var(--rb-size) / 2) 100%;
  opacity: 0; transform: translateY(12px) scale(0.92);
  transition: opacity 220ms ease, transform 320ms var(--ease-out);
}
.rb-panel[hidden] { display: none; }
.rb-panel:focus { outline: none; }
.rb.is-open .rb-panel { opacity: 1; transform: none; }
.rb-panel::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--rb-grad);
}

.rb-head { display: flex; align-items: center; gap: 12px; padding: 16px 14px 12px 16px; }
.rb-head-avatar {
  flex-shrink: 0; width: 44px; height: 44px; overflow: hidden; border-radius: 50%;
  background: radial-gradient(circle at 50% 30%, rgba(167, 139, 250, 0.35), rgba(139, 92, 246, 0.12));
  border: 1.5px solid var(--rb-line);
}
.rb-head-avatar img { transform: scale(1.5) translateY(14%); transform-origin: 50% 25%; }
.rb-head-text { flex: 1; min-width: 0; display: grid; gap: 3px; }
.rb-head-text strong { font-size: 0.95rem; font-weight: 800; letter-spacing: 0.01em; }
.rb-status { display: inline-flex; align-items: center; gap: 6px; font-size: 0.72rem; color: var(--txt-3); }
.rb-status i { width: 7px; height: 7px; border-radius: 50%; background: #22C55E; box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2); }
.rb-close {
  display: grid; place-items: center; width: 34px; height: 34px; padding: 0;
  border: 1px solid transparent; border-radius: 50%;
  background: transparent; color: var(--txt-3); cursor: pointer;
  transition: background 200ms ease, color 200ms ease;
}
.rb-close:hover { background: var(--g-regular); color: var(--txt); }
.rb-close:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.rb-body { padding: 0 14px 16px; display: grid; gap: 12px; }

.rb-msg {
  position: relative; justify-self: start; max-width: 92%;
  padding: 11px 14px; border-radius: 4px 16px 16px 16px;
  background: rgba(139, 92, 246, 0.16); border: 1px solid rgba(196, 181, 253, 0.18);
  font-size: 0.86rem; line-height: 1.5; color: var(--txt-2);
}
:root[data-theme="light"] .rb-msg { background: rgba(139, 92, 246, 0.09); border-color: rgba(109, 40, 217, 0.14); }
.rb-msg strong { color: var(--txt); }
.rb-msg-text { margin: 0; }
.rb-typing { display: none; gap: 4px; padding: 4px 2px; }
.rb-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--violet-300); animation: rb-dot 1s ease-in-out infinite; }
.rb-typing i:nth-child(2) { animation-delay: 0.15s; }
.rb-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes rb-dot { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }
.rb-msg:not(.is-ready) .rb-typing { display: inline-flex; }
.rb-msg:not(.is-ready) .rb-msg-text { display: none; }
.rb-msg.is-ready .rb-msg-text { animation: rb-pop 320ms var(--ease-out); }

.rb-options { display: grid; gap: 8px; }
.rb-opt {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 10px 12px 10px 10px; text-align: left;
  border: 1px solid var(--rb-line); border-radius: var(--r-sm, 14px);
  background: var(--g-regular); color: var(--txt);
  font: inherit; cursor: pointer;
  transition: transform 260ms var(--ease-out), border-color 200ms ease, background 200ms ease, box-shadow 260ms var(--ease-out);
}
.rb:not(.is-ready) .rb-opt { opacity: 0; transform: translateY(8px); pointer-events: none; }
.rb.is-ready .rb-opt { animation: rb-pop 380ms var(--ease-out) both; }
.rb.is-ready .rb-opt:nth-child(2) { animation-delay: 90ms; }
@keyframes rb-pop { from { opacity: 0; transform: translateY(8px) scale(0.97); } }
.rb-opt-icon {
  display: grid; place-items: center; flex-shrink: 0; width: 40px; height: 40px; border-radius: 12px;
  color: var(--on-accent); background: var(--rb-grad);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 4px 14px var(--rb-glow);
}
.rb-opt-icon svg { width: 20px; height: 20px; stroke-width: 2.1; }
.rb-opt-text { flex: 1; min-width: 0; display: grid; gap: 2px; }
.rb-opt-text strong { font-size: 0.88rem; font-weight: 800; letter-spacing: 0.02em; }
.rb-opt-text small { font-size: 0.74rem; color: var(--txt-3); }
.rb-opt-arrow { color: var(--txt-3); transition: transform 260ms var(--ease-out), color 200ms ease; }
.rb-opt:hover { border-color: var(--violet-400); background: rgba(139, 92, 246, 0.14); box-shadow: 0 8px 24px var(--rb-glow); }
.rb-opt:hover .rb-opt-arrow { transform: translateX(3px); color: var(--txt); }
.rb-opt:active { transform: scale(0.98); }
.rb-opt:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ═══ Responsive — sit above the mobile bottom tab bar (bottom-nav.html) ═══ */
@media (max-width: 768px) {
  .rb {
    --rb-size: 116px;
    --rb-right: 12px;
    --rb-bottom: calc(var(--nav-height, 64px) + var(--nav-gap, 12px) * 2 + env(safe-area-inset-bottom));
  }
  .rb-hint { max-width: 170px; font-size: 0.74rem; padding: 8px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .rb-fab-bot, .rb-fab-shadow, .rb-typing i { animation: none; }
  .rb-hint, .rb-msg.is-ready .rb-msg-text, .rb.is-ready .rb-opt { animation: none; }
  .rb-panel, .rb-opt, .rb-fab-bot img { transition: none; }
}
