/* ==========================================================================
   The site chat.
   Brand colours, small footprint, and it must never cover the order button
   on a phone — which is why the panel sits above the sticky bar.
   ========================================================================== */

.chat-fab {
  position: fixed;
  right: 1.15rem;
  bottom: 1.15rem;
  z-index: 60;
  width: 3.6rem;
  height: 3.6rem;
  border-radius: 50%;
  border: none;
  background: var(--oxblood);
  color: var(--gold);
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 22px rgba(46, 16, 18, 0.32);
  transition: transform 200ms ease, background-color 200ms ease;
}
.chat-fab:hover { transform: translateY(-2px); background: var(--oxblood-deep); }
.chat-fab svg { width: 1.6rem; height: 1.6rem; fill: currentColor; }
.chat-fab .badge {
  position: absolute; top: -2px; right: -2px;
  min-width: 1.1rem; height: 1.1rem; padding: 0 0.25rem;
  border-radius: 999px; background: var(--gold); color: var(--oxblood);
  font: 700 0.68rem/1.1rem Karla, sans-serif; text-align: center;
}
.chat-fab[hidden] { display: none; }

@media (max-width: 61.99rem) {
  .chat-fab { bottom: 5.2rem; }   /* clear of the sticky order bar */
}

.chat-panel {
  position: fixed;
  right: 1.15rem;
  bottom: 1.15rem;
  z-index: 61;
  width: min(23rem, calc(100vw - 2rem));
  max-height: min(34rem, calc(100vh - 2.5rem));
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 18px 48px rgba(46, 16, 18, 0.28);
}
.chat-panel[hidden] { display: none; }

@media (max-width: 30rem) {
  .chat-panel {
    right: 0; left: 0; bottom: 0;
    width: 100%;
    max-height: 88vh;
    border-radius: 14px 14px 0 0;
  }
}

.chat-head {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--oxblood);
  color: var(--gold);
}
.chat-head .who { font-family: Fraunces, Georgia, serif; font-size: 1.05rem; line-height: 1.2; }
.chat-head .sub { display: block; font-family: Karla, sans-serif; font-size: 0.72rem;
                  color: rgba(236, 220, 194, 0.75); margin-top: 0.1rem; }
.chat-close {
  background: none; border: none; color: inherit; cursor: pointer;
  font-size: 1.4rem; line-height: 1; padding: 0.2rem 0.35rem; border-radius: 6px;
}
.chat-close:hover { background: rgba(255,255,255,0.12); }

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--paper);
}

.chat-msg {
  max-width: 85%;
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg.assistant { align-self: flex-start; background: #fff; border: 1px solid var(--rule); }
.chat-msg.visitor   { align-self: flex-end;   background: var(--gold-pale); color: var(--oxblood); }
.chat-msg.system    { align-self: center; background: none; color: var(--ink-faint);
                      font-size: 0.8rem; text-align: center; }

.chat-typing { align-self: flex-start; display: flex; gap: 0.22rem; padding: 0.7rem 0.8rem; }
.chat-typing span {
  width: 0.4rem; height: 0.4rem; border-radius: 50%; background: var(--ink-faint);
  animation: chat-bounce 1.1s infinite ease-in-out;
}
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chat-bounce { 0%,80%,100% { transform: translateY(0); opacity:.5 } 40% { transform: translateY(-4px); opacity:1 } }

.chat-foot { border-top: 1px solid var(--rule); padding: 0.7rem; background: var(--paper); }

.chat-form { display: flex; gap: 0.5rem; align-items: flex-end; }
.chat-form textarea {
  flex: 1; resize: none; min-height: 2.4rem; max-height: 6rem;
  padding: 0.55rem 0.7rem; border: 1px solid var(--rule); border-radius: 10px;
  font: inherit; font-size: 16px; background: #fff; color: var(--ink);
}
.chat-form button {
  flex: none; width: 2.4rem; height: 2.4rem; border-radius: 50%; border: none;
  background: var(--oxblood); color: var(--gold); cursor: pointer; display: grid; place-items: center;
}
.chat-form button:disabled { opacity: 0.45; cursor: not-allowed; }
.chat-form button svg { width: 1.05rem; height: 1.05rem; fill: currentColor; }

.chat-note { font-size: 0.74rem; color: var(--ink-faint); margin: 0.45rem 0 0; text-align: center; }

/* --- the details / OTP step ---------------------------------------------- */
.chat-gate { padding: 0.2rem 0 0; }
.chat-gate label { display: block; font-size: 0.78rem; font-weight: 600; margin: 0.5rem 0 0.2rem; }
.chat-gate input {
  width: 100%; padding: 0.5rem 0.65rem; border: 1px solid var(--rule);
  border-radius: 8px; font: inherit; font-size: 16px; background: #fff; color: var(--ink);
}
.chat-gate .row { display: flex; gap: 0.5rem; }
.chat-gate .btn {
  margin-top: 0.7rem; width: 100%; padding: 0.6rem; border: none; border-radius: 9px;
  background: var(--oxblood); color: var(--gold); font: inherit; font-weight: 600; cursor: pointer;
}
.chat-gate .btn.secondary { background: none; color: var(--ink-soft); font-weight: 400; font-size: 0.82rem; }
.chat-err { color: #a33323; font-size: 0.78rem; margin-top: 0.45rem; }
.chat-ok  { color: #2f7a55; font-size: 0.78rem; margin-top: 0.45rem; }

.chat-otp { letter-spacing: 0.4em; text-align: center; font-size: 1.15rem !important; }

@media (prefers-reduced-motion: reduce) {
  .chat-fab, .chat-typing span { transition: none; animation: none; }
}

/* ---- tappable answers -----------------------------------------------------
   Suggested replies. Nobody should have to type "mocha" when three colours
   exist and we know all three. */
.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.15rem 0 0.2rem;
}

.chat-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.38rem 0.7rem;
  border: 1px solid var(--oxblood);
  border-radius: 999px;
  background: transparent;
  color: var(--oxblood);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
}
.chat-chip:hover { background: var(--oxblood); color: var(--gold); }

/* A colour chip carries a scrap of the actual stripe. */
.chat-chip.has-swatch::before {
  content: "";
  width: 0.85rem; height: 0.85rem; border-radius: 50%;
  background-image: repeating-linear-gradient(90deg, var(--cs-a) 0 3px, var(--cs-b) 3px 6px);
  flex: none;
}
.chat-chip[data-swatch="mocha"] { --cs-a: #9d4130; --cs-b: #cf9184; }
.chat-chip[data-swatch="blue"]  { --cs-a: #4a7bb5; --cs-b: #c3dbd6; }
.chat-chip[data-swatch="peach"] { --cs-a: #d9502a; --cs-b: #f4b9a4; }

/* ---- cards ---------------------------------------------------------------
   Measurements and colours read terribly as prose; they get real structure. */
.chat-card {
  align-self: flex-start;
  width: 100%;
  background: #fff;
  border: 1px solid var(--rule);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
}
.chat-card-title {
  font-family: Fraunces, Georgia, serif;
  font-size: 0.95rem;
  color: var(--oxblood);
  margin-bottom: 0.5rem;
}
.chat-card-note { font-size: 0.74rem; color: var(--ink-faint); margin: 0.5rem 0 0; }

.chat-sizes { display: grid; gap: 0.1rem; }
.chat-size-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 0.32rem 0;
  border-bottom: 1px solid var(--rule);
  font-size: 0.86rem;
}
.chat-size-row:last-child { border-bottom: none; }
.chat-size-row strong { font-variant-numeric: tabular-nums; color: var(--oxblood); }

.chat-colours { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.45rem; }
.chat-colour {
  border: 1px solid var(--rule);
  border-radius: 9px;
  background: none;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  font: inherit;
  font-size: 0.72rem;
  color: var(--ink-soft);
  text-align: center;
  transition: border-color 160ms ease, transform 160ms ease;
}
.chat-colour:hover:not(:disabled) { border-color: var(--oxblood); transform: translateY(-2px); }
.chat-colour img { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; }
.chat-colour span { display: block; padding: 0.3rem 0.15rem; }
.chat-colour.is-out { opacity: 0.5; cursor: not-allowed; }

@media (prefers-reduced-motion: reduce) {
  .chat-chip, .chat-colour { transition: none; }
}
