/*
 * gold-chat.css -- Gold Kit chat pill + panel, Chai / Sula Cafe palette
 *
 * Warm chai brown + cream. Distinctly different from Sula's plum/gold palette.
 * Variables override the Gold Kit defaults so every token matches the brand.
 * No em dashes or en dashes. No horizontal scroll possible.
 */

/* ============================================================
   CHAI BRAND TOKENS (override Gold Kit defaults)
   ============================================================ */
:root {
  --gold-accent:       #8B4513;   /* saddle brown, the chai colour */
  --gold-accent-deep:  #5C2E0A;   /* deep roast */
  --gold-accent-light: #B5703A;   /* warm cinnamon */
  --gold-ink:          #FDF6EC;   /* cream text on chai button */
  --gold-bg:           #2A1208;   /* deep espresso panel bg */
  --gold-bg-end:       #3D1C0E;   /* richer roast at bottom */
  --gold-border:       rgba(139, 69, 19, 0.35);
  --gold-halo-1:       rgba(181, 112, 58, 0.50);   /* cinnamon halo */
  --gold-halo-2:       rgba(181, 112, 58, 0.95);
  --gold-shimmer:      rgba(253, 222, 168, 0.92);   /* cream shimmer */
  --gold-cream:        #FDF6EC;
  --gold-cream-dim:    rgba(253, 246, 236, 0.62);
  --gold-rec:          #e87b5a;   /* mic recording pulse */
}

/* ============================================================
   FAB (Floating Action Button / Pill)
   ============================================================ */

@property --gk-fab-angle {
  syntax:        '<angle>';
  initial-value: 0deg;
  inherits:      false;
}

.gk-fab {
  position:        fixed;
  right:           24px;
  bottom:          24px;
  z-index:         97;
  display:         inline-flex;
  align-items:     center;
  gap:             10px;
  padding:         0 18px 0 0;
  height:          64px;
  background:      linear-gradient(
                     135deg,
                     var(--gold-accent-deep)  0%,
                     var(--gold-accent)       50%,
                     var(--gold-accent-light) 100%
                   );
  background-size: 200% 100%;
  border:          none;
  border-radius:   999px;
  cursor:          pointer;
  color:           var(--gold-ink);
  font-size:       15px;
  font-weight:     600;
  letter-spacing:  0.3px;
  box-shadow:
    0 8px 28px rgba(42, 18, 8, 0.40),
    0 0 24px rgba(139, 69, 19, 0.45);
  transition:
    transform       0.35s cubic-bezier(0.4, 0, 0.2, 1),
    box-shadow      0.35s cubic-bezier(0.4, 0, 0.2, 1),
    background-position 0.5s ease;
  isolation:       isolate;
  touch-action:    manipulation;
  -webkit-tap-highlight-color: transparent;
  animation: gk-fab-pulse 2.4s ease-in-out infinite;
}

.gk-fab:hover {
  transform:           translateY(-2px);
  background-position: 100% 0;
  box-shadow:
    0 14px 36px rgba(42, 18, 8, 0.50),
    0 0 32px var(--gold-halo-1);
}

.gk-fab-icon {
  width:         36px;
  height:        36px;
  border-radius: 50%;
  display:       block;
  background:    rgba(20, 8, 3, 0.88);
  padding:       4px;
  flex-shrink:   0;
  margin:        6px 0 6px 6px;
  box-shadow:    inset 0 0 0 1px rgba(253, 222, 168, 0.45);
  object-fit:    contain;
}

.gk-fab-label {
  white-space: nowrap;
  font-style:  normal;
}

.gk-fab-halo {
  position:       absolute;
  inset:          -4px;
  border-radius:  999px;
  pointer-events: none;
  border:         1px solid var(--gold-halo-1);
  opacity:        0;
  animation:      gk-fab-halo 3.6s ease-in-out infinite;
}

.gk-fab::before {
  content:        '';
  position:       absolute;
  inset:          -3px;
  border-radius:  inherit;
  padding:        3px;
  background:     conic-gradient(
                    from var(--gk-fab-angle, 0deg),
                    rgba(139, 69, 19, 0.00)  0deg,
                    var(--gold-halo-2)        90deg,
                    rgba(92, 46, 10, 0.85)   180deg,
                    var(--gold-halo-1)        270deg,
                    rgba(139, 69, 19, 0.00)  360deg
                  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
  animation:      gk-fab-spin 8s linear infinite;
}

@keyframes gk-fab-pulse {
  0%, 100% {
    box-shadow:
      0 8px 28px rgba(42, 18, 8, 0.45),
      0 0 24px rgba(139, 69, 19, 0.45);
  }
  50% {
    box-shadow:
      0 10px 34px rgba(42, 18, 8, 0.55),
      0 0 44px var(--gold-halo-2),
      0 0 68px rgba(139, 69, 19, 0.35);
  }
}

@keyframes gk-fab-halo {
  0%, 100% { opacity: 0;   transform: scale(1);    }
  50%       { opacity: 0.7; transform: scale(1.04); }
}

@keyframes gk-fab-spin {
  to { --gk-fab-angle: 360deg; }
}

body.gk-open .gk-fab {
  opacity:        0;
  pointer-events: none;
  transform:      translateY(20px);
}

/* ============================================================
   CHAT PANEL (modal)
   ============================================================ */

.gk-modal {
  position:        fixed;
  inset:           0;
  z-index:         998;
  display:         flex;
  align-items:     center;
  justify-content: center;
  opacity:         0;
  pointer-events:  none;
  transition:      opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.gk-modal.active {
  opacity:        1;
  pointer-events: auto;
}

.gk-modal-backdrop {
  position:                 absolute;
  inset:                    0;
  background:               rgba(20, 8, 3, 0.68);
  backdrop-filter:          blur(6px);
  -webkit-backdrop-filter:  blur(6px);
}

.gk-modal-card {
  position:    relative;
  width:       420px;
  max-width:   calc(100vw - 32px);
  height:      640px;
  max-height:  calc(100vh - 48px);
  background:  linear-gradient(180deg, var(--gold-bg) 0%, var(--gold-bg-end) 100%);
  border:      1px solid var(--gold-border);
  border-radius: 18px;
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.60),
    0 0 0 1px rgba(253, 222, 168, 0.07);
  display:      flex;
  flex-direction: column;
  overflow:     hidden;
  transform:    translateY(20px) scale(0.98);
  transition:   transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.gk-modal.active .gk-modal-card {
  transform: translateY(0) scale(1);
}

/* ============================================================
   HEADER
   ============================================================ */

.gk-header {
  display:         flex;
  align-items:     center;
  justify-content: space-between;
  padding:         18px 18px 16px;
  border-bottom:   1px solid var(--gold-border);
  flex-shrink:     0;
}

.gk-header-id {
  display:     flex;
  align-items: center;
  gap:         12px;
}

.gk-avatar {
  width:         42px;
  height:        42px;
  border-radius: 50%;
  background:    rgba(20, 8, 3, 0.95);
  display:       inline-flex;
  align-items:   center;
  justify-content: center;
  border:        1px solid rgba(253, 222, 168, 0.40);
  overflow:      hidden;
  flex-shrink:   0;
}

.gk-avatar img {
  width:         30px;
  height:        30px;
  border-radius: 50%;
  object-fit:    contain;
}

.gk-header-name {
  color:          var(--gold-cream);
  font-size:      22px;
  font-weight:    700;
  line-height:    1;
  margin:         0 0 4px;
  letter-spacing: 0.3px;
  display:        flex;
  align-items:    center;
  gap:            6px;
}

.gk-voice-dot {
  display:       none;
  width:         7px;
  height:        7px;
  border-radius: 50%;
  background:    var(--gold-shimmer);
  animation:     gk-voice-dot-pulse 2.4s ease-in-out infinite;
}

.gk-voice-active .gk-voice-dot {
  display: inline-block;
}

.gk-voice-dot.listening {
  background: var(--gold-rec);
  animation:  gk-voice-dot-listen 1.1s ease-in-out infinite;
}

@keyframes gk-voice-dot-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(253, 222, 168, 0.65); }
  50%       { box-shadow: 0 0 0 6px rgba(253, 222, 168, 0); }
}

@keyframes gk-voice-dot-listen {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232, 123, 90, 0.75); }
  50%       { box-shadow: 0 0 0 7px rgba(232, 123, 90, 0);  }
}

.gk-header-sub {
  color:          var(--gold-accent-light);
  font-size:      14px;
  line-height:    1;
  margin:         0;
  letter-spacing: 0.3px;
}

.gk-header-actions {
  display:     flex;
  align-items: center;
  gap:         6px;
}

.gk-icon-btn {
  background:    transparent;
  border:        none;
  cursor:        pointer;
  width:         36px;
  height:        36px;
  display:       inline-flex;
  align-items:   center;
  justify-content: center;
  border-radius: 50%;
  color:         var(--gold-accent-light);
  transition:    background 0.3s ease, color 0.3s ease, transform 0.3s ease;
  touch-action:  manipulation;
  -webkit-tap-highlight-color: transparent;
}

.gk-icon-btn:hover {
  background: rgba(139, 69, 19, 0.18);
  color:      var(--gold-shimmer);
}

.gk-speaker .gk-speaker-on  { display: none; }
.gk-speaker[aria-pressed="true"] .gk-speaker-on  { display: block; }
.gk-speaker[aria-pressed="true"] .gk-speaker-off { display: none;  }
.gk-speaker[aria-pressed="true"] {
  color:      var(--gold-shimmer);
  background: rgba(139, 69, 19, 0.20);
}

/* ============================================================
   MESSAGE LIST
   ============================================================ */

.gk-messages {
  flex:           1;
  overflow-y:     auto;
  overflow-x:     hidden;
  padding:        18px 18px 8px;
  display:        flex;
  flex-direction: column;
  gap:            12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(139, 69, 19, 0.45) transparent;
}

.gk-messages::-webkit-scrollbar       { width: 6px; }
.gk-messages::-webkit-scrollbar-thumb {
  background:    rgba(139, 69, 19, 0.40);
  border-radius: 3px;
}

.gk-msg {
  max-width:     84%;
  padding:       12px 16px;
  border-radius: 14px;
  line-height:   1.55;
  animation:     gk-fade-up 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.gk-msg p { margin: 0; font-size: 15px; }
.gk-msg p + p { margin-top: 8px; }

.gk-msg-bot {
  align-self:    flex-start;
  background:    rgba(61, 28, 14, 0.65);
  border:        1px solid var(--gold-border);
  color:         var(--gold-cream);
  border-bottom-left-radius: 4px;
  font-size:     16px;
}

.gk-msg-user {
  align-self:    flex-end;
  background:    linear-gradient(
                   135deg,
                   rgba(139, 69, 19, 0.20),
                   rgba(181, 112, 58, 0.10)
                 );
  border:        1px solid rgba(139, 69, 19, 0.28);
  color:         var(--gold-cream);
  border-bottom-right-radius: 4px;
  font-size:     14.5px;
}

.gk-msg a {
  color:                var(--gold-shimmer);
  text-decoration:      underline;
  text-decoration-color: rgba(253, 222, 168, 0.40);
  text-underline-offset: 2px;
}

@keyframes gk-fade-up {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0);   }
}

/* ============================================================
   TYPING INDICATOR
   ============================================================ */

.gk-typing {
  display:     none;
  padding:     0 22px 8px;
  align-items: center;
  gap:         6px;
  flex-shrink: 0;
}

.gk-typing.active { display: flex; }

.gk-typing span {
  width:         7px;
  height:        7px;
  border-radius: 50%;
  background:    var(--gold-accent-light);
  opacity:       0.5;
  animation:     gk-typing-dot 1.2s ease-in-out infinite;
}

.gk-typing span:nth-child(2) { animation-delay: 0.15s; }
.gk-typing span:nth-child(3) { animation-delay: 0.30s; }

@keyframes gk-typing-dot {
  0%, 80%, 100% { transform: translateY(0);    opacity: 0.4; }
  40%            { transform: translateY(-4px); opacity: 1.0; }
}

/* ============================================================
   INPUT ROW
   ============================================================ */

.gk-input-row {
  display:      flex;
  align-items:  center;
  gap:          8px;
  padding:      14px 16px 16px;
  border-top:   1px solid var(--gold-border);
  flex-shrink:  0;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.gk-input-row input[type="text"] {
  flex:           1;
  background:     rgba(20, 8, 3, 0.65);
  border:         1px solid rgba(139, 69, 19, 0.28);
  border-radius:  999px;
  padding:        11px 16px;
  color:          var(--gold-cream);
  font-size:      14.5px;
  letter-spacing: 0.2px;
  outline:        none;
  transition:     border-color 0.3s ease, box-shadow 0.3s ease;
  min-width:      0;
}

.gk-input-row input[type="text"]:focus {
  border-color: var(--gold-accent);
  box-shadow:
    0 0 0 3px rgba(139, 69, 19, 0.20),
    0 0 18px rgba(139, 69, 19, 0.18);
}

.gk-input-row input[type="text"]::placeholder {
  color: rgba(253, 246, 236, 0.38);
}

.gk-send {
  flex-shrink:  0;
  width:        42px;
  height:       42px;
  border-radius: 50%;
  border:       none;
  background:   linear-gradient(
                  135deg,
                  var(--gold-accent-deep),
                  var(--gold-accent) 50%,
                  var(--gold-accent-light)
                );
  color:        var(--gold-ink);
  cursor:       pointer;
  display:      inline-flex;
  align-items:  center;
  justify-content: center;
  transition:   transform 0.3s ease, box-shadow 0.3s ease;
}

.gk-send:hover {
  transform:  translateY(-1px);
  box-shadow: 0 8px 18px rgba(139, 69, 19, 0.45);
}

.gk-send:disabled {
  opacity:   0.5;
  cursor:    not-allowed;
  transform: none;
}

.gk-mic {
  flex-shrink:  0;
  border:       1px solid rgba(139, 69, 19, 0.55);
  background:   rgba(61, 28, 14, 0.55);
  color:        var(--gold-accent-light);
}

.gk-mic:hover {
  background:   rgba(139, 69, 19, 0.20);
  color:        var(--gold-shimmer);
  border-color: var(--gold-shimmer);
}

.gk-mic.recording {
  color:        var(--gold-rec);
  border-color: var(--gold-rec);
  background:   rgba(232, 123, 90, 0.16);
  animation:    gk-mic-rec 1.2s ease-in-out infinite;
}

@keyframes gk-mic-rec {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232, 123, 90, 0.55); }
  50%       { box-shadow: 0 0 0 6px rgba(232, 123, 90, 0); }
}

.gk-voice-loop {
  flex-shrink:  0;
  border:       1px solid rgba(139, 69, 19, 0.55);
  background:   rgba(61, 28, 14, 0.55);
  color:        var(--gold-accent-light);
}

.gk-voice-loop:hover {
  background:   rgba(139, 69, 19, 0.20);
  color:        var(--gold-shimmer);
  border-color: var(--gold-shimmer);
}

.gk-voice-loop.active {
  color:      var(--gold-ink);
  background: linear-gradient(
                135deg,
                var(--gold-accent-deep),
                var(--gold-accent)       50%,
                var(--gold-accent-light)
              );
  border-color: var(--gold-accent);
  animation:    gk-loop-pulse 1.8s ease-in-out infinite;
}

.gk-voice-loop.active .gk-waveform-bar {
  animation: gk-loop-bars 1.2s ease-in-out infinite;
}

.gk-voice-loop.active .gk-waveform-bar:nth-child(2) { animation-delay: 0.15s; }
.gk-voice-loop.active .gk-waveform-bar:nth-child(3) { animation-delay: 0.30s; }
.gk-voice-loop.active .gk-waveform-bar:nth-child(4) { animation-delay: 0.45s; }
.gk-voice-loop.active .gk-waveform-bar:nth-child(5) { animation-delay: 0.60s; }

@keyframes gk-loop-pulse {
  0%, 100% {
    box-shadow:
      0 0 0 0 rgba(253, 222, 168, 0.55),
      0 4px 14px rgba(139, 69, 19, 0.45);
  }
  50% {
    box-shadow:
      0 0 0 5px rgba(253, 222, 168, 0),
      0 4px 14px rgba(139, 69, 19, 0.45);
  }
}

@keyframes gk-loop-bars {
  0%, 100% { transform: scaleY(1);    }
  50%       { transform: scaleY(0.45); }
}

.gk-waveform-bar {
  transform-origin: center;
  transform-box:    fill-box;
}

/* ============================================================
   PRIVACY LINE
   ============================================================ */

.gk-privacy {
  margin:         0;
  padding:        6px 16px 12px;
  text-align:     center;
  font-style:     italic;
  font-size:      11px;
  color:          var(--gold-accent-light);
  opacity:        0.6;
  letter-spacing: 0.3px;
  flex-shrink:    0;
}

/* ============================================================
   REDUCED-MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  .gk-fab,
  .gk-fab::before,
  .gk-fab-halo {
    animation: none;
  }
  .gk-fab {
    box-shadow:
      0 8px 28px rgba(42, 18, 8, 0.40),
      0 0 30px rgba(139, 69, 19, 0.50);
  }
  .gk-typing span,
  .gk-mic.recording,
  .gk-voice-loop.active,
  .gk-voice-loop.active .gk-waveform-bar,
  .gk-voice-dot,
  .gk-voice-dot.listening {
    animation: none;
  }
}

/* ============================================================
   MOBILE (full-screen slide-up)
   ============================================================ */

@media (max-width: 600px) {
  .gk-fab {
    right:     18px;
    bottom:    18px;
    height:    56px;
    font-size: 14px;
    padding-right: 16px;
  }

  .gk-fab-icon {
    width:  32px;
    height: 32px;
    margin: 6px 0 6px 6px;
  }

  .gk-modal-card {
    width:         100%;
    max-width:     100%;
    height:        100%;
    max-height:    100%;
    border-radius: 0;
    border-left:   none;
    border-right:  none;
    transform:     translateY(100%) scale(1);
  }

  .gk-modal.active .gk-modal-card {
    transform: translateY(0) scale(1);
  }

  .gk-header  { padding: 16px 14px 14px; }
  .gk-messages { padding: 14px 14px 6px; }
  .gk-input-row { padding: 12px 12px 14px; }
}
