/* ── Coffee Tales — unified chat + weather widget ── */

/* Outer wrapper: fixed anchor, contains chat panel + weather */
#ct-widget {
  position: fixed;
  bottom: 32px;
  left: 32px;
  width: 300px;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  background: var(--ink, #140e0a);
  border: 1px solid rgba(201, 165, 115, .18);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transform: translateY(calc(100% + 64px));
  transition: transform .8s cubic-bezier(.16, 1, .3, 1), opacity .4s, border-color .3s, background .3s, border-radius .3s;
}

#ct-widget.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* Minimize: slide left, leaving a tab visible */
#ct-widget.weather-mini {
  transform: translateX(calc(-100% + 8px));
  cursor: pointer;
  border-right-color: rgba(201, 165, 115, .4);
  border-radius: 0 8px 8px 0;
  background: rgba(20, 14, 10, 0.95);
  backdrop-filter: blur(5px);
}

#ct-widget.weather-mini:hover {
  transform: translateX(calc(-100% + 28px));
  transition: transform .3s cubic-bezier(.16, 1, .3, 1), border-color .3s;
  background: rgba(20, 14, 10, 1);
}

/* Hide header contents when minimized */
#ct-widget.weather-mini .ct-chat-head {
  opacity: 0;
  pointer-events: none;
}

/* Vertical label that fades in once the strip is visible */
#ct-widget::after {
  content: 'CHAT';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  color: rgba(201, 165, 115, 0);
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  letter-spacing: .25em;
  text-transform: uppercase;
  pointer-events: none;
  transition: color .2s .35s;
}

#ct-widget.weather-mini::after {
  color: var(--gold, #c9a573);
}

/* ── Chat panel ── */

/* Hidden until weather intro is dismissed */
#ct-panel {
  overflow: hidden;
  height: 0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

/* Once weather is dismissed: panel header is always visible */
#ct-widget.ct-intro-done #ct-panel {
  height: auto;
  overflow: visible;
}

/* Chat body: the collapsible messages + input area */
.ct-chat-body {
  overflow: hidden;
  height: 0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: height .5s cubic-bezier(.16, 1, .3, 1);
}

.ct-chat-body.ct-body-open {
  height: 400px;
}

/* Header is clickable as a reopen trigger once chat has been used */
#ct-widget.ct-intro-done .ct-chat-head {
  cursor: pointer;
}

/* ── "Ask →" trigger inside weather section ── */
.ct-weather-trigger {
  display: block;
  background: transparent;
  border: none;
  padding: 0;
  margin-top: 16px;
  color: var(--gold, #c9a573);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color .2s, transform .2s;
  line-height: 1;
  white-space: nowrap;
}

.ct-weather-trigger:hover {
  color: var(--cream, #f2ebdf);
  transform: translateX(3px);
}

/* ── Weather — neutralise its own fixed positioning ── */
#ct-widget #weather,
#ct-widget #weather.show {
  position: relative !important;
  bottom: auto !important;
  left: auto !important;
  transform: none !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  max-width: none !important;
  width: auto !important;
  z-index: auto !important;
}

/* ── Chat header ── */
.ct-chat-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: 18px 20px 16px;
  border-bottom: 1px solid rgba(201, 165, 115, .1);
  flex-shrink: 0;
  transition: opacity 0.3s ease;
}

.ct-chat-head-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ct-chat-name {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 20px;
  font-weight: 300;
  font-style: italic;
  color: var(--cream, #f2ebdf);
  line-height: 1;
}

.ct-chat-status {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: rgba(201, 165, 115, .6);
}

.ct-chat-close {
  background: transparent;
  border: none;
  color: rgba(242, 235, 223, .35);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 2px 0 2px 12px;
  transition: color .2s;
  line-height: 1;
  flex-shrink: 0;
}

.ct-chat-close:hover {
  color: var(--gold, #c9a573);
}

/* ── Messages ── */
.ct-chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(201, 165, 115, .12) transparent;
}

.ct-chat-messages::-webkit-scrollbar {
  width: 3px;
}

.ct-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.ct-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(201, 165, 115, .12);
}

.ct-msg {
  display: flex;
  max-width: 88%;
}

.ct-msg span {
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.6;
}

.ct-msg-bot {
  align-self: flex-start;
}

.ct-msg-user {
  align-self: flex-end;
}

.ct-msg-bot span {
  background: rgba(201, 165, 115, .06);
  color: rgba(242, 235, 223, .82);
  border: 1px solid rgba(201, 165, 115, .1);
  border-left: 2px solid rgba(201, 165, 115, .32);
}

.ct-msg-user span {
  background: var(--espresso, #2a1f1a);
  color: var(--cream, #f2ebdf);
  border: 1px solid rgba(201, 165, 115, .18);
}

/* ── Typing indicator ── */
.ct-msg-typing span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.ct-dot {
  width: 5px;
  height: 5px;
  background: rgba(201, 165, 115, .45);
  border-radius: 50%;
  animation: ctBounce 1.1s infinite ease-in-out;
}

.ct-dot:nth-child(1) {
  animation-delay: 0s;
}

.ct-dot:nth-child(2) {
  animation-delay: .18s;
}

.ct-dot:nth-child(3) {
  animation-delay: .36s;
}

@keyframes ctBounce {

  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: .3;
  }

  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* ── Input row ── */
.ct-chat-input-row {
  flex-shrink: 0;
  padding: 0 20px 16px;
  border-top: 1px solid rgba(201, 165, 115, .1);
}

.ct-input-line {
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(201, 165, 115, .22);
  transition: border-color .2s;
}

.ct-input-line:focus-within {
  border-color: rgba(201, 165, 115, .5);
}

.ct-input-line input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 14px 0;
  color: var(--cream, #f2ebdf);
  font-size: 13.5px;
  font-family: 'Inter', sans-serif;
  outline: none;
  min-width: 0;
}

.ct-input-line input::placeholder {
  color: rgba(242, 235, 223, .22);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: .15em;
  text-transform: uppercase;
}

.ct-input-line input:disabled {
  opacity: .4;
}

.ct-send-btn {
  background: transparent;
  border: none;
  padding: 14px 0 14px 12px;
  color: var(--gold, #c9a573);
  font-family: 'JetBrains Mono', monospace;
  font-size: 16px;
  cursor: pointer;
  transition: color .2s, transform .2s;
  flex-shrink: 0;
  line-height: 1;
}

.ct-send-btn:hover {
  color: var(--cream, #f2ebdf);
  transform: translateX(3px);
}

.ct-send-btn:disabled {
  opacity: .3;
  cursor: not-allowed;
  transform: none;
}

/* ── Mobile ── */
@media (max-width: 600px) {
  /* By default (weather state), keep it small and left-aligned */
  #ct-widget {
    bottom: 16px;
    left: 16px;
    right: auto;
    width: auto;
    min-width: 240px;
    max-width: calc(100% - 32px);
    border-left: 1px solid rgba(201, 165, 115, .18);
    border-right: 1px solid rgba(201, 165, 115, .18);
    border-bottom: 1px solid rgba(201, 165, 115, .18);
    border-radius: 12px;
    transition: all .4s cubic-bezier(.16, 1, .3, 1);
  }

  /* When the chat is opened, expand to full width minus margins */
  #ct-widget.ct-chat-open {
    left: 16px;
    width: calc(100% - 32px);
    border-radius: 16px;
  }

  /* Make weather content more compact on phone */
  #ct-widget #weather {
    padding: 12px 14px 16px;
  }

  #ct-widget #weather .text span {
    font-size: 12px;
    line-height: 1.4;
  }

  #ct-widget #weather .text small {
    margin-bottom: 6px;
  }

  #ct-widget .ct-weather-trigger {
    margin-top: 10px;
    font-size: 9px;
  }

  .ct-chat-body.ct-body-open {
    height: 55vh;
  }

  /* Minimized state: bottom-left floating circle */
  #ct-widget.weather-mini {
    bottom: 20px;
    left: 20px;
    right: auto;
    width: 56px;
    min-width: 0;
    height: 56px;
    border-radius: 28px;
    transform: none;
    border: 1px solid rgba(201, 165, 115, .4);
    overflow: hidden;
  }

  #ct-widget.weather-mini:hover {
    transform: scale(1.05);
    transition: transform .3s;
  }

  /* Replace "CHAT" text with an elegant speech bubble icon */
  #ct-widget.weather-mini::after {
    content: '';
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23c9a573"><path d="M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2z"/></svg>') no-repeat center center;
    background-size: 26px 26px;
    width: 100%;
    height: 100%;
    right: 0;
    left: 0;
    top: 0;
    bottom: 0;
  }
}