/* Craft Podium chat widget (task #29) — floats above every page.
   Tokens follow the site palette with hard fallbacks, so a page that
   forgets a variable still renders legibly. */

.cp-chat-launcher {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  border: 1px solid var(--line, #232837);
  border-radius: 50%;
  background: var(--card, #12151d);
  color: var(--text, #e8eaf0);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .45);
}

.cp-chat-launcher:focus-visible,
.cp-chat-close:focus-visible,
.cp-chat-send:focus-visible,
.cp-chat-input:focus-visible {
  outline: 2px solid var(--accent2, #6ea8fe);
  outline-offset: 2px;
}

.cp-chat-launcher svg { width: 24px; height: 24px; }

.cp-chat-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--accent, #f5a623);
  color: #0b0d12;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

.cp-chat-panel {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 68px);
  width: min(360px, calc(100vw - 32px));
  height: min(520px, calc(100vh - 110px));
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line, #232837);
  border-radius: 14px;
  background: var(--bg, #0b0d12);
  color: var(--text, #e8eaf0);
  z-index: 61;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .55);
  overflow: hidden;
}

.cp-chat-panel[hidden] { display: none; }

.cp-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line, #232837);
}

.cp-chat-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.cp-chat-close {
  width: 44px;
  height: 44px;
  margin: -8px -8px -8px 0;
  border: 0;
  background: none;
  color: var(--text, #e8eaf0);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.cp-chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 12px;
  list-style: none;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cp-chat-msg {
  max-width: 88%;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: .92rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.cp-chat-msg--visitor {
  align-self: flex-end;
  background: var(--accent, #f5a623);
  color: #0b0d12;
}

.cp-chat-msg--bot,
.cp-chat-msg--raft {
  align-self: flex-start;
  background: var(--card, #12151d);
  border: 1px solid var(--line, #232837);
}

.cp-chat-who {
  display: block;
  margin-bottom: 2px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted, #9aa3b5);
}

.cp-chat-msg--visitor .cp-chat-who { color: rgba(11, 13, 18, .7); }

.cp-chat-status {
  margin: 0;
  padding: 6px 14px;
  font-size: .82rem;
  color: var(--muted, #9aa3b5);
  border-top: 1px solid var(--line, #232837);
}

.cp-chat-status[hidden] { display: none; }

.cp-chat-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--line, #232837);
}

.cp-chat-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.cp-chat-input {
  flex: 1 1 auto;
  min-height: 44px;
  max-height: 96px;
  padding: 10px 12px;
  border: 1px solid var(--line, #232837);
  border-radius: 10px;
  background: var(--card, #12151d);
  color: var(--text, #e8eaf0);
  font: inherit;
  font-size: .95rem;
  resize: none;
  box-sizing: border-box;
}

.cp-chat-send {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border: 0;
  border-radius: 10px;
  background: var(--accent2, #6ea8fe);
  color: #0b0d12;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cp-chat-send:disabled { opacity: .6; cursor: default; }
.cp-chat-send svg { width: 20px; height: 20px; }

.cp-chat-result {
  margin: 0;
  padding: 0 14px;
  font-size: .85rem;
  color: var(--accent, #f5a623);
  min-height: 0;
}

.cp-chat-result:empty { display: none; }

/* Phones (≤640px): a bottom sheet that keeps every target ≥44px and obeys the
   safe area under the home indicator. */
@media (max-width: 640px) {
  .cp-chat-panel {
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: min(80vh, calc(100vh - 56px));
    border-radius: 16px 16px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .cp-chat-launcher { bottom: calc(max(16px, env(safe-area-inset-bottom)) + 8px); }
}
