/* ============================================================
   game-assistant.css – Interactieve spelassistent
   Geïnspireerd op Clippy; herbruikbaar in alle escape room-spellen.
   ============================================================ */

/* ---- Hoofdcontainer (fixed, rechtsonder) ---- */
.game-assistant {
  position: fixed;
  bottom: 20px;
  right: 14px;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  pointer-events: none;
}

.game-assistant.asst-hidden,
.game-assistant[hidden] {
  display: none;
}

.game-assistant.asst-entering .asst-character {
  animation: asst-enter 1.4s ease-out forwards, asst-float 3s ease-in-out 1.4s infinite;
}

.game-assistant.asst-entering[data-emotion="curious"] .asst-character {
  animation: asst-enter 1.4s ease-out forwards, asst-look-around 1.8s ease-in-out 1.2s 1, asst-float 3s ease-in-out 3s infinite;
}

.asst-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  pointer-events: auto;
}

.game-assistant.asst-minimized .asst-wrap {
  display: none;
}

/* ---- Tekstballon ---- */
.asst-bubble {
  position: relative;
  max-width: 220px;
  min-width: 110px;
  padding: 11px 13px;
  border: 1px solid rgba(200, 175, 115, .32);
  border-radius: 14px 14px 4px 14px;
  background: #20281e;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .45);
  color: #f3ead6;
  font: .82rem/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  word-break: break-word;
  animation: asst-bubble-in 220ms ease-out;
}

.asst-bubble-text {
  margin: 0;
  white-space: pre-line;
}

.asst-bubble[hidden] {
  display: none;
}

/* Pijl naar beneden-rechts, richting karakter */
.asst-bubble::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 22px;
  border: 8px solid transparent;
  border-top-color: #20281e;
  border-bottom: 0;
  border-right: 0;
}

/* ---- Hintknop in de ballon ---- */
.asst-hint-btn {
  display: block;
  width: 100%;
  margin-top: 9px;
  padding: 7px 10px;
  border: 1px solid rgba(209, 174, 98, .65);
  border-radius: 9px;
  background: transparent;
  color: #d1ae62;
  font: 700 .78rem/1.2 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  cursor: pointer;
  transition: background .18s;
}

.asst-hint-btn:hover {
  background: rgba(209, 174, 98, .12);
}

.asst-hint-btn[hidden] {
  display: none;
}

/* ---- Rij met karakter + minimaliseerknop ---- */
.asst-char-row {
  position: relative;
  display: inline-flex;
  align-items: flex-end;
}

/* ---- Minimaliseerknop ---- */
.asst-minimize {
  position: absolute;
  top: 4px;
  right: -4px;
  z-index: 2;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid rgba(200, 175, 115, .28);
  border-radius: 50%;
  background: rgba(17, 21, 15, .85);
  color: #b9b09d;
  font-size: .75rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: .5;
  transition: opacity .18s;
}

.asst-minimize:hover {
  opacity: 1;
}

.asst-minimize:focus-visible {
  outline: 2px solid rgba(209, 174, 98, .5);
  outline-offset: 1px;
}

/* ---- Herstelknop (zichtbaar als geminimaliseerd) ---- */
.asst-restore {
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(200, 175, 115, .30);
  border-radius: 50%;
  background: #20281e;
  font-size: 1.22rem;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .44);
  transition: transform .2s, border-color .2s;
}

.asst-restore[hidden] {
  display: none;
}

.asst-restore:hover {
  transform: scale(1.12);
  border-color: #d1ae62;
}

.asst-restore:focus-visible {
  outline: 2px solid rgba(209, 174, 98, .5);
  outline-offset: 2px;
}

/* ---- Vlam-karakter ---- */
.asst-character {
  position: relative;
  width: 72px;
  height: 88px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  animation: asst-float 3s ease-in-out infinite;
  filter:
    drop-shadow(0 8px 14px rgba(0, 0, 0, .55))
    drop-shadow(0 0 12px rgba(200, 80, 0, .38));
}

.asst-character:focus-visible {
  outline: 3px solid rgba(209, 174, 98, .55);
  outline-offset: 4px;
  border-radius: 50%;
}

/* Vlamlichaam */
.asst-body {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 20px;
  bottom: 0;
  border-radius: 50% 50% 36% 36% / 54% 54% 40% 40%;
  background: radial-gradient(ellipse at 50% 68%,
    #8b2200 0%,
    #c84500 34%,
    #e07000 64%,
    #f5a020 86%,
    #f5c030 100%
  );
}

/* Binnenste gloed */
.asst-body::after {
  content: '';
  position: absolute;
  inset: 22% 22% 12%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 230, 150, .22), transparent 72%);
}

/* Vlamtip (boven het lichaam) */
.asst-body::before {
  content: '';
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 28px;
  background: linear-gradient(to top, #e07000 0%, #f5c030 55%, #fffde7 100%);
  clip-path: polygon(50% 0%, 10% 100%, 90% 100%);
  animation: asst-tip 1.9s ease-in-out infinite;
}

/* Ogen */
.asst-eye {
  position: absolute;
  top: 46px;
  width: 13px;
  height: 14px;
  border-radius: 50%;
  background: #1a0a02;
  animation: asst-blink 3.8s ease-in-out infinite;
}

/* Reflectie in het oog */
.asst-eye::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 3px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .72);
}

.asst-eye-l {
  left: 14px;
}

.asst-eye-r {
  right: 14px;
  animation-delay: .2s;
}

/* Mondje */
.asst-mouth {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  width: 18px;
  height: 7px;
  border-bottom: 2.5px solid rgba(26, 10, 2, .6);
  border-radius: 0 0 50% 50%;
}

/* ---- Hint-tegel highlight in de puzzel ---- */
.tile.asst-hint-tile {
  animation: asst-pulse 1s ease-in-out 4 !important;
  position: relative;
  z-index: 2;
}

/* ---- Confetti-deeltjes ---- */
.asst-confetti {
  position: fixed;
  z-index: 200;
  pointer-events: none;
  animation: asst-confetti-fall linear forwards;
}

/* ============================================================
   Emoties (via data-emotion op het hoofdcontainer-element)
   ============================================================ */

/* Ogen aanpassen per emotie */
.game-assistant[data-emotion="thinking"] .asst-eye {
  transform: scaleY(.6);
}

.game-assistant[data-emotion="happy"] .asst-eye,
.game-assistant[data-emotion="excited"] .asst-eye {
  transform: scaleY(1.15);
}

/* Karakter-animaties per emotie */
.game-assistant[data-emotion="happy"]    .asst-character { animation: asst-bounce .55s ease-in-out 3; }
.game-assistant[data-emotion="excited"]  .asst-character { animation: asst-jump   .42s ease-in-out 4; }
.game-assistant[data-emotion="win"]      .asst-character { animation: asst-win    .48s ease-in-out 5; }
.game-assistant[data-emotion="surprised"] .asst-character { animation: asst-surprise .28s ease-out 1 forwards; }
.game-assistant[data-emotion="curious"]  .asst-body { transform: rotate(-7deg); transition: transform .3s; }

/* ============================================================
   Keyframes
   ============================================================ */

/* Rustig zweven (idle) */
@keyframes asst-float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

@keyframes asst-enter {
  0%   { transform: translate(108px, 54px) scale(.82) rotate(-10deg); opacity: 0; }
  60%  { transform: translate(-8px, -6px) scale(1.02) rotate(2deg); opacity: 1; }
  100% { transform: translateY(0) scale(1) rotate(0deg); opacity: 1; }
}

@keyframes asst-look-around {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  24%      { transform: translateY(-4px) rotate(-8deg); }
  56%      { transform: translateY(-6px) rotate(8deg); }
  78%      { transform: translateY(-2px) rotate(-4deg); }
}

/* Vlamtip wiegelen */
@keyframes asst-tip {
  0%, 100% { transform: translateX(-50%) scaleX(1) rotate(0deg); }
  50%       { transform: translateX(-50%) scaleX(.72) rotate(4deg); }
}

/* Knipperen */
@keyframes asst-blink {
  0%, 88%, 100% { transform: scaleY(1); }
  92%, 96%      { transform: scaleY(.06); }
}

/* Vrolijk stuiteren */
@keyframes asst-bounce {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  38%       { transform: translateY(-13px) scale(1.06, .94); }
  68%       { transform: translateY(-4px) scale(.98, 1.03); }
}

/* Enthousiast springen */
@keyframes asst-jump {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  28%       { transform: translateY(-20px) scale(1.08, .92); }
  58%       { transform: translateY(-7px) scale(.97, 1.04); }
}

/* Win-dans */
@keyframes asst-win {
  0%, 100% { transform: translateY(0) rotate(0deg) scale(1); }
  22%       { transform: translateY(-22px) rotate(-10deg) scale(1.12); }
  72%       { transform: translateY(-16px) rotate(10deg) scale(1.1); }
}

/* Verrassing */
@keyframes asst-surprise {
  0%   { transform: scale(1); }
  38%  { transform: scale(1.28) translateY(-5px); }
  100% { transform: scale(1.05); }
}

/* Ballon verschijnt */
@keyframes asst-bubble-in {
  from { opacity: 0; transform: translateY(8px) scale(.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Tegel-hint pulseren */
@keyframes asst-pulse {
  0%, 100% {
    filter: brightness(1);
    box-shadow: none;
  }
  50% {
    filter: brightness(1.55);
    box-shadow: 0 0 0 3px rgba(209, 174, 98, .75), 0 0 14px rgba(209, 174, 98, .5);
  }
}

/* Confetti vallen */
@keyframes asst-confetti-fall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(140px) rotate(540deg); opacity: 0; }
}

/* ============================================================
   Verminderde beweging
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .asst-character,
  .asst-body::before,
  .asst-eye,
  .asst-confetti {
    animation: none !important;
  }

  .game-assistant[data-emotion] .asst-character,
  .game-assistant.asst-entering .asst-character {
    animation: none !important;
  }

  .asst-bubble {
    animation: none;
  }
}
