/* ==========================================================================
   The concierge — a guided chat that walks a visitor from "which emirate?"
   to a specific hoarding, using the same inventory as the rest of the site.

   Its own quiet palette, the same on every page: a white panel, soft grey
   for the concierge's lines, black for the visitor's, black for the one
   main action. The face is the Double Dare "D" in black (assets/img/assistant-mark.svg).
   ========================================================================== */

:root {
  --chat-w: 392px;
  --chat-h: min(640px, calc(100svh - 150px));
}

.chat, .chat-fab {
  --c-bg:    #FFFFFF;
  --c-soft:  #F3F3F1;
  --c-line:  #E9E9E6;
  --c-text:  #121212;
  --c-mute:  #74746F;
  --c-ink:   #121212;
  --c-live:  #1FB964;
}

/* --- Launcher: the "D" mark in a white ring (no presence dot: it is a scripted guide) */
.chat-fab {
  position: fixed;
  inset-inline-end: 22px;
  bottom: 22px;
  z-index: calc(var(--z-chat) - 1);
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  border: 0;
  border-radius: 50%;
  background: var(--c-bg);
  box-shadow: 0 0 0 1px rgba(0,0,0,.06), 0 12px 32px rgba(0,0,0,.28);
  transition: transform var(--t-ui) var(--dare-out), box-shadow var(--t-ui) var(--dare-out), background-color var(--t-ui) var(--dare-out);
}
.chat-fab:hover { transform: translateY(-3px); box-shadow: 0 0 0 1px rgba(0,0,0,.06), 0 18px 40px rgba(0,0,0,.32); }
.chat-fab__face { width: 43px; height: 43px; border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 1px #E6E6E2; }
.chat-fab__face img { display: block; width: 100%; height: 100%; object-fit: cover; }
.chat-fab__close { display: none; width: 18px; height: 18px; color: #fff; }
.chat-fab__close svg { width: 100%; height: 100%; }
.chat-fab.is-open { background: var(--c-ink); width: 44px; height: 44px; inset-inline-end: 25px; bottom: 25px; }
.chat-fab.is-open .chat-fab__face { display: none; }
.chat-fab.is-open .chat-fab__close { display: block; }

/* --- Panel --------------------------------------------------------------- */
.chat {
  position: fixed;
  inset-inline-end: 24px;
  bottom: 96px;
  z-index: var(--z-chat);
  width: var(--chat-w);
  height: var(--chat-h);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--c-text);
  background: var(--c-bg);
  border-radius: 24px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.06), 0 30px 80px rgba(0,0,0,.3);

  opacity: 0;
  visibility: hidden;
  transform: translateY(14px) scale(.98);
  transform-origin: 100% 100%;
  transition: opacity 320ms var(--dare-out),
              transform 320ms var(--dare-out),
              visibility 320ms;
}
.chat.is-open { opacity: 1; visibility: visible; transform: none; }

/* --- Header -------------------------------------------------------------- */
.chat__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 16px 18px;
  border-bottom: 1px solid var(--c-line);
}
.chat__avatar { position: relative; width: 44px; height: 44px; flex: none; }
/* The portrait has a white ground: a hairline ring keeps it from melting into the panel */
.chat__avatar img { display: block; width: 44px; height: 44px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 1px var(--c-line); }
.chat__who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.chat__who b {
  font-family: var(--display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--c-text);
}
.chat__who span { font-size: 12.5px; color: var(--c-mute); }

.chat__tools { margin-inline-start: auto; display: flex; gap: 2px; }
.chat__tool {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: var(--c-mute);
  transition: color var(--t-ui), background-color var(--t-ui);
}
.chat__tool:hover { color: var(--c-text); background: var(--c-soft); }
.chat__tool svg { width: 17px; height: 17px; }

/* --- Log ----------------------------------------------------------------- */
.chat__log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
  scrollbar-color: #D9D9D5 transparent;
}
.chat__log::-webkit-scrollbar { width: 5px; }
.chat__log::-webkit-scrollbar-thumb { background: #D9D9D5; border-radius: 3px; }

.chat__row { display: flex; gap: 8px; align-items: flex-end; }
.chat__row--me { flex-direction: row-reverse; margin-top: 6px; }
/* A new speaker leaves a little air above */
.chat__row--me + .chat__row:not(.chat__row--me) { margin-top: 6px; }

.chat__pic { width: 28px; height: 28px; flex: none; }
.chat__pic img { display: block; width: 28px; height: 28px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 1px var(--c-line); }
.chat__row--me .chat__pic { display: none; }
/* In a run of the concierge's lines, her face sits by the last one only */
.chat__row--cont .chat__pic { visibility: hidden; }

.chat__bubble {
  max-width: 80%;
  padding: 10px 14px;
  font-size: 14.5px;
  line-height: 1.5;
  font-weight: 400;
  color: var(--c-text);
  background: var(--c-soft);
  border-radius: 18px 18px 18px 6px;
  animation: chatIn 300ms var(--dare-out) both;
}
.chat__row--cont .chat__bubble { border-radius: 18px 18px 18px 6px; }
.chat__bubble b { font-weight: 600; }
.chat__row--me .chat__bubble {
  color: #FFFFFF;
  background: var(--c-ink);
  border-radius: 18px 18px 6px 18px;
}
@keyframes chatIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Typing */
.chat__typing { display: flex; gap: 4px; padding: 14px 15px; }
.chat__typing i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #A3A39E;
  animation: chatDot 1.1s ease-in-out infinite;
}
.chat__typing i:nth-child(2) { animation-delay: .15s; }
.chat__typing i:nth-child(3) { animation-delay: .3s; }
@keyframes chatDot { 0%,60%,100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* --- Site card inside the log -------------------------------------------- */
.chat__card {
  display: block;
  width: 80%;
  overflow: hidden;
  color: var(--c-text);
  background: var(--c-bg);
  border-radius: 18px 18px 18px 6px;
  box-shadow: 0 0 0 1px var(--c-line), 0 6px 18px rgba(0,0,0,.06);
  animation: chatIn 300ms var(--dare-out) both;
  transition: box-shadow var(--t-ui) var(--dare-out), transform var(--t-ui) var(--dare-out);
}
.chat__card:hover { box-shadow: 0 0 0 1px #CFCFCA, 0 10px 26px rgba(0,0,0,.1); transform: translateY(-1px); }
.chat__card-media { position: relative; display: block; aspect-ratio: 16 / 9; overflow: hidden; }
.chat__card-media img { width: 100%; height: 100%; object-fit: cover; }
.chat__card-no {
  position: absolute; top: 9px; inset-inline-start: 9px;
  font-family: var(--display);
  font-size: 12px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 999px;
  color: var(--c-text);
  background: rgba(255,255,255,.92);
}
.chat__card-body { display: block; padding: 12px 14px 14px; }
.chat__card-body h4 {
  font-family: var(--display);
  font-weight: 600;
  font-size: 16px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin-bottom: 5px;
}
.chat__card-body p { font-size: 12.5px; color: var(--c-mute); line-height: 1.5; }
.chat__card-go {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 10px;
  font-size: 13px; font-weight: 600;
  color: var(--c-text);
}
.chat__card-go svg { width: 15px; height: 15px; transition: transform var(--t-ui) var(--dare-out); }
.chat__card:hover .chat__card-go svg { transform: translateX(3px); }

/* --- Quick replies ------------------------------------------------------- */
.chat__replies {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--c-line);
  background: var(--c-bg);
}
.chat__replies:empty { display: none; }
.chat__reply {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 15px;
  font-size: 13.5px;
  font-weight: 500;
  text-align: start;
  cursor: pointer;
  color: var(--c-text);
  background: var(--c-bg);
  border: 1px solid #E0E0DC;
  border-radius: 999px;
  transition: background-color var(--t-ui) var(--dare-out), color var(--t-ui) var(--dare-out),
              border-color var(--t-ui) var(--dare-out), scale 120ms ease-out;
  animation: chatIn 260ms var(--dare-out) both;
}
.chat__reply:hover { background: var(--c-soft); border-color: #D2D2CD; }
.chat__reply:active { scale: .97; }
.chat__reply:focus-visible { outline: 2px solid var(--c-ink); outline-offset: 2px; }
@media (pointer: coarse) { .chat__reply { min-height: 44px; } .chat__tool { width: 44px; height: 44px; } }
/* The one main action: filled black */
.chat__reply--go { color: #FFFFFF; background: var(--c-ink); border-color: var(--c-ink); }
.chat__reply--go:hover { background: #2C2C2A; border-color: #2C2C2A; }
.chat__reply--quiet { color: var(--c-mute); }
.chat__reply em { font-style: normal; font-weight: 400; color: var(--c-mute); }
.chat__reply--go em { color: rgba(255,255,255,.7); }

/* --- Mobile -------------------------------------------------------------- */
@media (max-width: 560px) {
  .chat-fab { inset-inline-end: 14px; bottom: 14px; width: 46px; height: 46px; }
  .chat-fab__face { width: 40px; height: 40px; }
  /* Full screen on a phone: inset beats height:100svh, which leaves a gap
     once the browser chrome is counted */
  .chat {
    inset: 0;
    width: auto;
    height: auto;
    border-radius: 0;
  }
  .chat__bubble, .chat__card { max-width: 86%; }
  .chat__card { width: 86%; }
  .chat-fab.is-open { display: none; }
}

/* Room for the launcher above the footer's legal line on short screens */
@media (max-height: 560px) {
  .chat { height: calc(100svh - 120px); bottom: 84px; }
}

@media (prefers-reduced-motion: reduce) {
  .chat, .chat__bubble, .chat__card, .chat__reply { animation: none; transition: none; }
  .chat__typing i { animation: none; }
}
