/*
  Chat widget.

  Uses the site's existing tokens, the two fonts already loaded, and the same
  square-cornered, shadowless, hairline-bordered treatment as the rest of the
  site — no new colours, no new webfont requests.

  The tokens are redeclared here rather than inherited because the widget also
  loads on the homepage, which defines its palette in its own inline <style>
  block. Falling back to var(--navy-950, #061426) form keeps it correct on every page
  whether or not blog.css is present.

  z-index: the site's ladder tops out at 35 (.nav-toggle), with the mobile nav
  overlay at 30. The launcher sits above both and hides itself while the mobile
  menu is open (body.nav-open), so the two never fight for the corner.
*/

.ss-chat {
--c-ink: var(--navy-950, #061426);
  --c-ink-2: var(--navy-900, #0a1d36);
  --c-parchment: var(--ivory-100, #f7f2e9);
  --c-dim: var(--ivory-50, #fcfaf6);
  --c-gold-bright: var(--gold-400, #e5c16e);
  --c-line: var(--navy-800, #102a4c);
  font-family: 'Source Serif 4', Georgia, serif;
}

/* ------------------------------- launcher -------------------------------- */

.ss-chat-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 45;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 12px 18px;
  background: var(--c-gold);
  color: var(--c-ink);
  border: 1px solid var(--c-gold);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1rem;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease;
}

.ss-chat-launcher:hover {
  background: var(--c-gold-bright);
  border-color: var(--c-gold-bright);
}

.ss-chat-launcher svg { width: 18px; height: 18px; flex-shrink: 0; }

/* The mobile nav is a fullscreen overlay; the launcher would float on top. */
body.nav-open .ss-chat-launcher { display: none; }

.ss-chat-launcher[hidden] { display: none; }

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

.ss-chat-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 46;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 560px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  background: var(--c-ink);
  border: 1px solid var(--c-line);
  color: var(--c-parchment);
}

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

.ss-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 16px;
  background: var(--c-ink-2);
  border-bottom: 1px solid var(--c-line);
  flex-shrink: 0;
}

.ss-chat-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.05rem;
  color: var(--c-gold-bright);
  margin: 0;
}

.ss-chat-sub { font-size: 0.72rem; color: var(--c-dim); display: block; }

.ss-chat-close {
  background: none;
  border: 1px solid transparent;
  color: var(--c-dim);
  font-size: 1.3rem;
  line-height: 1;
  padding: 4px 9px;
  cursor: pointer;
}

.ss-chat-close:hover { color: var(--c-gold-bright); border-color: var(--c-line); }

/* ------------------------------- messages -------------------------------- */

.ss-chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ss-msg { max-width: 85%; padding: 10px 13px; font-size: 0.92rem; line-height: 1.55; }

.ss-msg-bot {
  align-self: flex-start;
  background: var(--c-ink-2);
  border: 1px solid var(--c-line);
  white-space: pre-wrap;
}

.ss-msg-user {
  align-self: flex-end;
  background: var(--c-gold-dim, #8a6c30);
  color: #1a1710;
  border: 1px solid var(--c-gold-dim, #8a6c30);
  white-space: pre-wrap;
}

.ss-msg-error {
  align-self: stretch;
  max-width: 100%;
  background: transparent;
  border: 1px solid #b5502f;
  color: #e8a58c;
  font-size: 0.85rem;
}

/* Three dots that also carry a screen-reader label — see chat.js. */
.ss-typing { display: inline-flex; gap: 4px; align-items: center; }
.ss-typing i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--c-gold-bright); opacity: 0.35;
  animation: ss-blink 1.3s infinite ease-in-out;
}
.ss-typing i:nth-child(2) { animation-delay: 0.18s; }
.ss-typing i:nth-child(3) { animation-delay: 0.36s; }

@keyframes ss-blink { 0%, 60%, 100% { opacity: 0.25; } 30% { opacity: 1; } }

/* ----------------------------- suggestions ------------------------------- */

.ss-suggestions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }

.ss-suggestion {
  background: transparent;
  border: 1px solid var(--c-line);
  color: var(--c-dim);
  font-family: inherit;
  font-size: 0.8rem;
  padding: 6px 11px;
  cursor: pointer;
}

.ss-suggestion:hover { border-color: var(--c-gold-bright); color: var(--c-gold-bright); }

/* -------------------------------- cards ---------------------------------- */

.ss-card {
  align-self: stretch;
  max-width: 100%;
  background: var(--c-ink-2);
  border: 1px solid var(--c-line);
  padding: 14px;
  font-size: 0.9rem;
}

.ss-card h4 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1rem;
  margin: 0 0 4px;
  color: var(--c-gold-bright);
  font-weight: 500;
}

.ss-card p { margin: 0 0 10px; color: var(--c-dim); font-size: 0.83rem; }

.ss-step { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--c-dim); }

.ss-options { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }

.ss-option {
  text-align: left;
  background: var(--c-ink);
  border: 1px solid var(--c-line);
  color: var(--c-parchment);
  font-family: inherit;
  font-size: 0.87rem;
  padding: 9px 11px;
  cursor: pointer;
}

.ss-option:hover, .ss-option[aria-pressed='true'] {
  border-color: var(--c-gold-bright);
  color: var(--c-gold-bright);
}

.ss-option small { display: block; color: var(--c-dim); font-size: 0.76rem; margin-top: 2px; }

.ss-times { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.ss-times .ss-option { flex: 0 0 auto; padding: 7px 12px; }

.ss-field { margin-bottom: 9px; }
.ss-field label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--c-dim);
  margin-bottom: 3px;
}
.ss-field input, .ss-field textarea, .ss-field select {
  width: 100%;
  padding: 8px 9px;
  background: var(--c-ink);
  border: 1px solid var(--c-line);
  color: var(--c-parchment);
  font-family: inherit;
  font-size: 0.88rem;
}
.ss-field textarea { min-height: 60px; resize: vertical; }
.ss-field input:focus, .ss-field textarea:focus, .ss-field select:focus {
  outline: none;
  border-color: var(--c-gold-bright);
}

.ss-summary { list-style: none; margin: 0 0 10px; padding: 0; font-size: 0.86rem; }
.ss-summary li { display: flex; gap: 8px; padding: 3px 0; }
.ss-summary span { color: var(--c-dim); flex: 0 0 78px; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }

.ss-ref {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 1.05rem;
  color: var(--c-gold-bright);
  letter-spacing: 0.06em;
}

.ss-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.ss-btn {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.92rem;
  letter-spacing: 0.03em;
  padding: 8px 16px;
  background: var(--c-gold);
  color: var(--c-ink);
  border: 1px solid var(--c-gold);
  cursor: pointer;
}
.ss-btn:hover:not(:disabled) { background: var(--c-gold-bright); border-color: var(--c-gold-bright); }
.ss-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ss-btn-ghost { background: transparent; color: var(--c-dim); border-color: var(--c-line); }
.ss-btn-ghost:hover:not(:disabled) { background: transparent; color: var(--c-gold-bright); border-color: var(--c-gold-bright); }

.ss-card-error { color: #e8a58c; font-size: 0.82rem; margin: 0 0 8px; }

/* ------------------------------- composer -------------------------------- */

.ss-chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--c-line);
  background: var(--c-ink-2);
  flex-shrink: 0;
}

.ss-chat-input {
  flex: 1;
  padding: 9px 11px;
  background: var(--c-ink);
  border: 1px solid var(--c-line);
  color: var(--c-parchment);
  font-family: inherit;
  font-size: 0.9rem;
  resize: none;
  max-height: 96px;
}

.ss-chat-input:focus { outline: none; border-color: var(--c-gold-bright); }

.ss-chat-send {
  background: var(--c-gold);
  border: 1px solid var(--c-gold);
  color: var(--c-ink);
  padding: 0 15px;
  cursor: pointer;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 0.95rem;
}
.ss-chat-send:hover:not(:disabled) { background: var(--c-gold-bright); border-color: var(--c-gold-bright); }
.ss-chat-send:disabled { opacity: 0.45; cursor: not-allowed; }

.ss-chat-foot {
  padding: 0 12px 10px;
  background: var(--c-ink-2);
  font-size: 0.68rem;
  color: var(--c-dim);
  text-align: center;
}

/* Matches the site's existing focus treatment. */
.ss-chat :focus-visible,
.ss-chat-launcher:focus-visible {
  outline: 2px solid var(--c-gold-bright);
  outline-offset: 3px;
}

.ss-sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------ responsive ------------------------------- */

/* 720px is the site's main mobile breakpoint (see blog.css). */
@media (max-width: 720px) {
  .ss-chat-panel {
    right: 0; bottom: 0; left: 0; top: 0;
    width: 100%; max-width: 100%; height: 100%; max-height: 100%;
    border: 0;
  }
  .ss-chat-launcher { right: 16px; bottom: 16px; padding: 11px 16px; }
  .ss-msg { max-width: 90%; }
}

@media (prefers-reduced-motion: reduce) {
  .ss-chat-launcher { transition: none; }
  .ss-typing i { animation: none; opacity: 0.6; }
}
