/* ============================================================
   SOUL WAVES: Frieda Chatbot Widget
   Courier Prime only. sw-cream bg, sw-sand border.
   ============================================================ */

.frieda-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 998;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
}

/* ---- Trigger pill ---- */

.frieda-trigger {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: linear-gradient(135deg, #BF953F, #FCF6BA, #B38728, #FBF5B7, #AA771C);
  background-size: 400% 400%;
  animation: gold-shimmer 15s ease infinite;
  color: #44140D;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.2;
  padding: 0.65rem 1.15rem;
  border: none;
  border-radius: 100px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(191, 149, 63, 0.35), 0 2px 6px rgba(68, 20, 13, 0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
  text-decoration: none;
}

.frieda-trigger:hover {
  background: var(--sw-copper-hover);
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(197, 120, 60, 0.45), 0 2px 8px rgba(68, 20, 13, 0.12);
}

.frieda-trigger:focus-visible {
  outline: 2px solid var(--sw-cream);
  outline-offset: 3px;
}

.frieda-trigger.active {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  padding: 0;
  justify-content: center;
  background: linear-gradient(135deg, #BF953F, #FCF6BA, #B38728, #FBF5B7, #AA771C);
  background-size: 400% 400%;
  animation: gold-shimmer 15s ease infinite;
  box-shadow: 0 4px 20px rgba(191, 149, 63, 0.35), 0 2px 6px rgba(68, 20, 13, 0.1);
  font-size: 0;
}

.frieda-trigger.active .frieda-trigger__sparkle {
  font-size: 1.1rem;
}

.frieda-trigger.active:hover {
  background: linear-gradient(135deg, #BF953F, #FCF6BA, #B38728, #FBF5B7, #AA771C);
  background-size: 400% 400%;
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(197, 120, 60, 0.45);
}

.frieda-trigger__sparkle {
  font-style: normal;
  display: inline-block;
  animation: frieda-pulse 3.5s ease-in-out infinite;
}

@keyframes frieda-pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.2); }
}

/* ---- Chat panel ---- */

.frieda-panel {
  width: 340px;
  background: var(--sw-cream);
  border: 1px solid var(--sw-sand);
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(68, 20, 13, 0.14), 0 2px 8px rgba(68, 20, 13, 0.06);
  overflow: hidden;
  display: flex;
  flex-direction: column;

  max-height: 0;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;

  transition:
    max-height 0.42s cubic-bezier(0.16, 1, 0.3, 1),
    opacity    0.28s ease,
    transform  0.38s cubic-bezier(0.16, 1, 0.3, 1);
}

.frieda-panel.open {
  max-height: 520px;
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

/* ---- Panel header ---- */

.frieda-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem 0.875rem 1.125rem;
  background: var(--sw-brown);
  flex-shrink: 0;
}

.frieda-panel__identity {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.frieda-panel__name {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--sw-cream);
  letter-spacing: 0.015em;
  line-height: 1.2;
}

.frieda-panel__status {
  font-family: var(--font-mono);
  font-size: 0.63rem;
  color: var(--sw-sand);
  opacity: 0.65;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.frieda-panel__close {
  background: none;
  border: none;
  color: var(--sw-sand);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.3rem 0.4rem;
  border-radius: 5px;
  opacity: 0.6;
  transition: opacity 0.15s, background 0.15s;
  font-family: sans-serif;
}

.frieda-panel__close:hover {
  opacity: 1;
  background: rgba(255, 248, 236, 0.12);
}

.frieda-panel__close:focus-visible {
  outline: 2px solid var(--sw-copper);
  outline-offset: 2px;
  opacity: 1;
}

/* ---- Messages area ---- */

.frieda-panel__messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 160px;
  max-height: 320px;
  scroll-behavior: smooth;
}

.frieda-panel__messages::-webkit-scrollbar {
  width: 3px;
}

.frieda-panel__messages::-webkit-scrollbar-track {
  background: transparent;
}

.frieda-panel__messages::-webkit-scrollbar-thumb {
  background: var(--sw-sand);
  border-radius: 2px;
}

/* ---- Message bubbles ---- */

.frieda-msg {
  display: flex;
  animation: frieda-msg-in 0.22s ease;
}

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

.frieda-msg--frieda { justify-content: flex-start; }
.frieda-msg--user   { justify-content: flex-end; }

.frieda-msg__bubble {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  max-width: 87%;
  padding: 0.55rem 0.875rem;
  word-break: break-word;
}

.frieda-msg--frieda .frieda-msg__bubble {
  background: var(--sw-cream);
  color: var(--sw-brown);
  border: 1px solid var(--sw-sand);
  border-left: 3px solid var(--sw-copper);
  border-radius: 2px 10px 10px 10px;
}

.frieda-msg--user .frieda-msg__bubble {
  background: var(--sw-sand);
  color: var(--sw-brown);
  border-radius: 10px 2px 10px 10px;
}

.frieda-msg__bubble a {
  color: var(--sw-copper);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-family: var(--font-mono);
}

.frieda-msg__bubble a:hover {
  color: var(--sw-red);
}

.frieda-hl {
  color: var(--sw-copper);
}

/* ---- Typing indicator ---- */

.frieda-msg--typing .frieda-msg__bubble {
  padding: 0.65rem 1rem;
}

.frieda-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 12px;
}

.frieda-dots span {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--sw-copper);
  opacity: 0.7;
  animation: frieda-dot-bounce 1.2s ease-in-out infinite;
}

.frieda-dots span:nth-child(2) { animation-delay: 0.2s; }
.frieda-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes frieda-dot-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%            { transform: translateY(-5px); }
}

/* ---- Input row ---- */

.frieda-panel__input-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0.875rem;
  border-top: 1px solid var(--sw-sand);
  background: var(--sw-cream);
  flex-shrink: 0;
}

.frieda-panel__input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--sw-brown);
  background: transparent;
  border: 1px solid var(--sw-sand);
  border-radius: 6px;
  padding: 0.5rem 0.7rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  line-height: 1.4;
}

.frieda-panel__input::placeholder {
  color: var(--sw-brown);
  opacity: 0.35;
}

.frieda-panel__input:focus {
  border-color: var(--sw-copper);
  box-shadow: 0 0 0 2px rgba(197, 120, 60, 0.15);
}

.frieda-panel__send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  background: var(--sw-copper);
  color: var(--sw-cream);
  border: none;
  border-radius: 7px;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.15s;
}

.frieda-panel__send:hover {
  background: var(--sw-copper-hover);
  transform: scale(1.06);
}

.frieda-panel__send:focus-visible {
  outline: 2px solid var(--sw-copper);
  outline-offset: 2px;
}

/* ---- Mobile ---- */

@media (max-width: 480px) {
  .frieda-widget {
    bottom: 1rem;
    right: 1rem;
    left: auto;
    align-items: flex-end;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .frieda-trigger {
    font-size: 0.7rem;
    padding: 0.45rem 0.85rem;
    gap: 0.35rem;
  }

  .frieda-panel {
    width: min(300px, calc(100vw - 2rem));
  }

  .frieda-panel.open {
    max-height: 440px;
  }

  .frieda-panel__messages {
    max-height: 240px;
  }
}

@media (max-height: 600px) and (max-width: 768px) {
  .frieda-panel.open { max-height: 42vh; }
}

/* ---- GDPR consent overlay ---- */

.frieda-consent {
  position: absolute;
  inset: 0;
  background: var(--sw-cream, #FFF8EC);
  z-index: 10;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  border-radius: 16px;
}

.frieda-consent__box {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 100%;
  overflow-y: auto;
}

.frieda-consent__title {
  font-family: 'Tsukimi Rounded', sans-serif;
  font-size: 1rem;
  font-weight: 500;
  color: var(--sw-brown, #44140D);
  margin: 0;
}

.frieda-consent__body {
  font-family: 'Courier Prime', monospace;
  font-size: 0.72rem;
  line-height: 1.55;
  color: var(--sw-brown, #44140D);
  margin: 0;
  opacity: 0.85;
}

.frieda-consent__actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.frieda-consent__start {
  background: var(--sw-copper, #C5783C);
  color: var(--sw-cream, #FFF8EC);
  border: none;
  border-radius: 6px;
  padding: 0.55rem 1rem;
  font-family: 'Tsukimi Rounded', sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
}

.frieda-consent__start:hover {
  background: var(--sw-red, #8C1C13);
}

.frieda-consent__privacy {
  font-family: 'Courier Prime', monospace;
  font-size: 0.7rem;
  color: var(--sw-red, #8C1C13);
  text-align: center;
  text-decoration: underline;
  opacity: 0.75;
}

/* ---- Quick reply buttons ---- */

.frieda-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.5rem 0 0.25rem;
}

.frieda-quick-reply {
  background: transparent;
  border: 1px solid var(--sw-copper, #C5783C);
  color: var(--sw-copper, #C5783C);
  border-radius: 20px;
  padding: 0.3rem 0.75rem;
  font-family: 'Courier Prime', monospace;
  font-size: 0.72rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

.frieda-quick-reply:hover {
  background: var(--sw-copper, #C5783C);
  color: var(--sw-cream, #FFF8EC);
}

/* ---- Reduced motion ---- */

@media (prefers-reduced-motion: reduce) {
  .frieda-trigger__sparkle {
    animation: none;
  }

  .frieda-panel {
    transition: opacity 0.15s ease;
    transform: none !important;
  }

  .frieda-msg {
    animation: none;
  }

  .frieda-dots span {
    animation: none;
    opacity: 0.6;
  }
}
