/* ===== DAAN DE DAS — Mascot Styles v2 ===== */

/*
  States (op #mascot):
    .mascot--state-idle     → subtiele bounce, neutrale kleur
    .mascot--state-active   → groen, lichte glow
    .mascot--state-digging  → schuddende animatie, ring draait
    .mascot--state-alert    → rood accent, pulse

  Highlight (op vacaturekaarten):
    .badger-highlight       → groene rand + glow, auto-verdwijnt via JS
*/


/* ─── Wrapper ─────────────────────────────────────────────────────────────── */

#mascot {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  pointer-events: none;
}

#mascot > * {
  pointer-events: auto;
}


/* ─── Avatar-knop ─────────────────────────────────────────────────────────── */

.mascot__btn {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--color-primary);
  box-shadow: 0 4px 16px rgba(61, 139, 55, 0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  outline-offset: 3px;
  /* Geen transition hier — animaties worden per state gestuurd */
}

.mascot__btn:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 8px 24px rgba(61, 139, 55, 0.45);
  background: var(--color-primary-hover);
}

.mascot__btn:active {
  transform: translateY(-1px) scale(0.97);
}

#mascot.mascot--expanded .mascot__btn {
  background: var(--color-primary-hover);
  animation: none !important;
}


/* ─── SVG das ─────────────────────────────────────────────────────────────── */

.mascot__das {
  width: 36px;
  height: 36px;
  display: block;
  flex-shrink: 0;
  /* transform-origin centraal voor rotatie-animaties */
  transform-origin: center bottom;
}

.mascot__das--sm {
  width: 26px;
  height: 26px;
}


/* ─── State ring (visuele indicator rondom knop) ─────────────────────────── */

.mascot__state-ring {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid transparent;
  pointer-events: none;
  transition: border-color 300ms ease, opacity 300ms ease;
  opacity: 0;
}


/* ─── STATES ──────────────────────────────────────────────────────────────── */

/* Idle — subtiel bounce */
#mascot.mascot--state-idle .mascot__btn {
  animation: mascot-bounce 4s ease-in-out infinite;
}

@keyframes mascot-bounce {
  0%, 100% { transform: translateY(0); }
  45%       { transform: translateY(-6px); }
  55%       { transform: translateY(-6px); }
}

/* Active — groene ring, kort opflitsen */
#mascot.mascot--state-active .mascot__btn {
  animation: none;
  box-shadow: 0 4px 16px rgba(61, 139, 55, 0.45);
}

#mascot.mascot--state-active .mascot__state-ring {
  opacity: 1;
  border-color: var(--color-primary);
  animation: mascot-ring-active 600ms ease-out both;
}

@keyframes mascot-ring-active {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

/* Digging — das schudt, ring draait */
#mascot.mascot--state-digging .mascot__btn {
  animation: none;
}

#mascot.mascot--state-digging .mascot__das {
  animation: mascot-dig 0.55s ease-in-out infinite;
}

#mascot.mascot--state-digging .mascot__state-ring {
  opacity: 1;
  border-color: var(--color-primary);
  border-style: dashed;
  animation: mascot-ring-spin 1.2s linear infinite;
}

@keyframes mascot-dig {
  0%   { transform: rotate(0deg) translateY(0); }
  25%  { transform: rotate(-14deg) translateY(2px); }
  75%  { transform: rotate(10deg) translateY(-1px); }
  100% { transform: rotate(0deg) translateY(0); }
}

@keyframes mascot-ring-spin {
  to { transform: rotate(360deg); }
}

/* Alert — rode ring, pulse */
#mascot.mascot--state-alert .mascot__btn {
  animation: none;
  background: var(--color-primary);
  box-shadow: 0 4px 20px rgba(229, 62, 62, 0.3);
}

#mascot.mascot--state-alert .mascot__state-ring {
  opacity: 1;
  border-color: #e53e3e;
  animation: mascot-ring-pulse 1s ease-in-out 3;
}

@keyframes mascot-ring-pulse {
  0%, 100% { transform: scale(1);    opacity: 1; }
  50%       { transform: scale(1.15); opacity: 0.6; }
}


/* ─── Badge (ongelezen-stipje) ─────────────────────────────────────────────── */

.mascot__badge {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #e53e3e;
  border: 2px solid #fff;
  animation: mascot-badge-pulse 2s ease-in-out infinite;
}

@keyframes mascot-badge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229, 62, 62, 0.45); }
  50%       { box-shadow: 0 0 0 4px rgba(229, 62, 62, 0); }
}


/* ─── Speech bubble ───────────────────────────────────────────────────────── */

.mascot__bubble {
  position: relative;
  max-width: 240px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 0.625rem 2rem 0.625rem 0.875rem;
  font-size: var(--text-sm);
  color: var(--color-text);
  line-height: 1.45;
  cursor: pointer;

  opacity: 0;
  transform: translateY(6px) scale(0.96);
  transition: opacity 220ms ease, transform 220ms ease;
}

.mascot__bubble--visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Pijltje richting de knop */
.mascot__bubble::after {
  content: '';
  position: absolute;
  bottom: -7px;
  right: 18px;
  width: 14px;
  height: 7px;
  background: #fff;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.06));
}

/* State-kleuren voor de bubble */
#mascot.mascot--state-alert .mascot__bubble {
  border-color: #feb2b2;
  background: #fff5f5;
}

#mascot.mascot--state-alert .mascot__bubble::after {
  background: #fff5f5;
}

#mascot.mascot--state-digging .mascot__bubble {
  border-color: var(--color-primary-border);
  background: var(--color-primary-light);
}

#mascot.mascot--state-digging .mascot__bubble::after {
  background: var(--color-primary-light);
}

.mascot__bubble-close {
  position: absolute;
  top: 4px;
  right: 6px;
  width: 20px;
  height: 20px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1rem;
  color: var(--color-text-faint);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: color 140ms, background 140ms;
}

.mascot__bubble-close:hover {
  color: var(--color-text);
  background: var(--color-surface-muted);
}


/* ─── Panel ───────────────────────────────────────────────────────────────── */

.mascot__panel {
  width: 308px;
  max-height: 440px;
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: mascot-panel-in 220ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes mascot-panel-in {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
.mascot__panel-header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-primary-light);
  flex-shrink: 0;
  transition: background 300ms ease;
}

/* Header reageert op state */
#mascot.mascot--state-digging .mascot__panel-header {
  background: var(--color-primary-light);
}

#mascot.mascot--state-alert .mascot__panel-header {
  background: #fff5f5;
}

.mascot__panel-avatar {
  flex-shrink: 0;
}

.mascot__panel-name {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}

.mascot__panel-status {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  transition: color 200ms;
}

#mascot.mascot--state-digging .mascot__panel-status {
  color: var(--color-primary);
}

#mascot.mascot--state-alert .mascot__panel-status {
  color: #e53e3e;
}

.mascot__panel-close {
  margin-left: auto;
  width: 28px;
  height: 28px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--color-text-muted);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 140ms, color 140ms;
  flex-shrink: 0;
}

.mascot__panel-close:hover {
  background: var(--color-border);
  color: var(--color-text);
}

/* Body */
.mascot__panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  scroll-behavior: smooth;
}

.mascot__panel-empty {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  text-align: center;
  margin: auto;
  line-height: 1.5;
}

/* Footer — "Graaf dieper" */
.mascot__panel-footer {
  padding: 0.5rem 0.875rem;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  flex-shrink: 0;
}

.mascot__dig-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background 160ms ease, transform 100ms ease, opacity 200ms ease;
}

.mascot__dig-btn:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
}

.mascot__dig-btn:active {
  transform: translateY(0);
}

.mascot__dig-btn:disabled {
  opacity: 0.6;
  cursor: default;
  transform: none;
}

/* Input placeholder */
.mascot__panel-input-area {
  padding: 0.625rem 0.875rem 0.875rem;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

.mascot__input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  color: var(--color-text-muted);
  background: var(--color-surface-muted);
  box-sizing: border-box;
  cursor: not-allowed;
}

.mascot__input::placeholder {
  color: var(--color-text-faint);
  font-style: italic;
}


/* ─── Berichten ───────────────────────────────────────────────────────────── */

.mascot__msg {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  animation: mascot-msg-in 180ms ease both;
}

@keyframes mascot-msg-in {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

.mascot__msg--daan { flex-direction: row; }
.mascot__msg--user { flex-direction: row-reverse; }

.mascot__msg-avatar {
  flex-shrink: 0;
  margin-top: 2px;
}

.mascot__msg-content {
  background: var(--color-primary-light);
  border: 1px solid var(--color-primary-border);
  border-radius: var(--radius-lg);
  border-top-left-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: var(--text-sm);
  color: var(--color-text);
  max-width: calc(100% - 2.5rem);
  line-height: 1.5;
}

.mascot__msg--user .mascot__msg-content {
  background: var(--color-surface-muted);
  border-color: var(--color-border);
  border-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-sm);
}

.mascot__msg-content p { margin: 0; }

.mascot__msg-content ul {
  margin: 0.4rem 0 0;
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.mascot__msg-content li {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}


/* ─── Highlight — vacaturekaart ───────────────────────────────────────────── */
/*
  Voeg .badger-highlight toe aan een .job-card of .vacature-card element.
  De klasse wordt na 4 seconden automatisch verwijderd door mascot.js.
  Je kunt de kaart-selector aanpassen aan de werkelijke DOM-structuur.
*/

.badger-highlight {
  outline: 2px solid var(--color-primary) !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 4px rgba(61, 139, 55, 0.12) !important;
  transition: outline 300ms ease, box-shadow 300ms ease;
  position: relative;
  z-index: 1;
}

/* Label bovenaan de gehighligte kaart — dynamisch via data-badger-label */
.badger-highlight::before {
  content: attr(data-badger-label);
  position: absolute;
  top: -12px;
  left: 12px;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  pointer-events: none;
  z-index: 2;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ─── Responsiviteit ─────────────────────────────────────────────────────── */

@media (max-width: 480px) {
  #mascot {
    bottom: 1rem;
    right: 1rem;
  }

  .mascot__panel {
    width: calc(100vw - 2rem);
    max-height: 60vh;
  }

  .mascot__bubble {
    max-width: calc(100vw - 6rem);
  }
}


/* ─── Toegankelijkheid ────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  #mascot.mascot--state-idle .mascot__btn,
  #mascot.mascot--state-digging .mascot__das,
  #mascot.mascot--state-digging .mascot__state-ring,
  #mascot.mascot--state-alert .mascot__state-ring,
  #mascot.mascot--state-active .mascot__state-ring,
  .mascot__badge,
  .mascot__panel,
  .mascot__msg,
  .mascot__bubble {
    animation: none !important;
    transition: none !important;
  }

  .mascot__bubble {
    opacity: 1;
    transform: none;
  }

  .mascot__state-ring {
    opacity: 0;
  }
}
