/* ---------- WhatsApp button ---------- */
.whatsapp-btn {
  position: fixed;
  left: var(--gutter);
  bottom: var(--gutter);
  z-index: 240;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #25d366;
  color: #0a0a0b;
  box-shadow: 0 8px 24px rgba(37, 211, 102, 0.35);
  transition: transform var(--duration-fast) var(--ease-out-expo);
}

.whatsapp-btn svg {
  width: 26px;
  height: 26px;
}

.whatsapp-btn:hover {
  transform: scale(1.08);
}

@media (max-width: 480px) {
  .whatsapp-btn {
    width: 44px;
    height: 44px;
    left: var(--space-sm);
    bottom: var(--space-sm);
  }
  .whatsapp-btn svg { width: 22px; height: 22px; }
}

/* ---------- AI chat widget: mascot entry point ---------- */
.mascot {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 250;
  padding: 0;
  border: none;
  background: none;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.45));
  transition: filter var(--duration-fast) var(--ease-out-expo);
}

.mascot.is-hovering {
  filter: drop-shadow(0 10px 24px rgba(255, 78, 47, 0.4));
}

.mascot-layer {
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  opacity: 0;
  pointer-events: none;
}

.mascot-layer[data-layer='a'] {
  opacity: 1;
}

.mascot-bubble {
  position: absolute;
  left: 50%;
  bottom: 100%;
  width: 168px;
  height: auto;
  margin-bottom: 4px;
  opacity: 0;
  pointer-events: none;
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.4));
  /* the tail tip sits ~13% in from the image's left edge, not centered in
     the asset, so offset by that instead of -50% to align the tip with the
     mascot's horizontal center */
  transform: translate(-13%, 8px) scale(0.85);
  transform-origin: bottom 13%;
  transition: opacity var(--duration-normal) var(--ease-out-expo),
    transform var(--duration-normal) var(--ease-out-expo);
}

.mascot.is-hovering .mascot-bubble {
  opacity: 1;
  transform: translate(-13%, -4px) scale(1);
}

.mascot.is-open {
  opacity: 0;
  pointer-events: none;
}

.chat-panel {
  position: fixed;
  right: var(--gutter);
  bottom: calc(var(--gutter) + 72px);
  z-index: 249;
  width: min(380px, calc(100vw - 2 * var(--gutter)));
  height: min(560px, calc(100vh - 160px));
  background: var(--color-bg-raised);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  pointer-events: none;
  transition: opacity var(--duration-normal) var(--ease-out-expo),
    transform var(--duration-normal) var(--ease-out-expo);
}

.chat-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.chat-header {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-sm);
}

.chat-close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--color-text-muted);
  transition: background var(--duration-fast), color var(--duration-fast);
}

.chat-close svg { width: 16px; height: 16px; }

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

.chat-header-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
}

.chat-header-sub {
  font-size: var(--text-xs);
  color: var(--color-text-dim);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-sm) var(--space-md);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.chat-msg {
  max-width: 88%;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  line-height: 1.55;
  white-space: pre-wrap;
}

.chat-msg.user {
  align-self: flex-end;
  background: var(--color-accent);
  color: var(--color-on-accent);
  border-bottom-right-radius: 2px;
}

.chat-msg.assistant {
  align-self: flex-start;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-bottom-left-radius: 2px;
}

.chat-msg pre {
  margin: 0.5rem 0 0;
  padding: 0.6rem 0.7rem;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow-x: auto;
}

.chat-msg pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.85em;
}

.chat-msg code {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 0.1em 0.35em;
}

.chat-msg.assistant.pending::after {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  margin-left: 4px;
  border-radius: 50%;
  background: var(--color-text-dim);
  animation: chatPulse 1s ease-in-out infinite;
}

@keyframes chatPulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.chat-form {
  display: flex;
  gap: 0.5rem;
  padding: var(--space-sm);
  border-top: 1px solid var(--color-border);
}

.chat-input {
  flex: 1;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.75rem;
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  resize: none;
}

.chat-input::placeholder { color: var(--color-text-dim); }
.chat-input:focus { border-color: var(--color-accent); }

.chat-send {
  width: 40px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--color-accent);
  color: var(--color-on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--duration-fast);
}

.chat-send:disabled { opacity: 0.5; cursor: default; }
.chat-send svg { width: 16px; height: 16px; }

.chat-error {
  font-size: var(--text-xs);
  color: var(--color-accent);
  padding: 0 var(--space-md) var(--space-sm);
}

@media (max-width: 480px) {
  .chat-panel {
    right: var(--gutter);
    left: var(--gutter);
    width: auto;
  }
}
