/* ==========================================================================
   TFW Chat widget · sitewide AI assistant
   Mobile-first. Tokens from tfw-design-system-final.css only.
   z-index: FAB 430, panel 440 — both UNDER #cartDrawer (450) and modals (9999).
   ========================================================================== */

/* --- Launcher ----------------------------------------------------------- */
/* Same slot the Zendesk launcher occupied (bottom 90px clears the mobile
   sticky bars on PDP / shop / comparison pages sitewide). */
.tfwc-fab {
  position: fixed;
  right: 12px;
  bottom: 90px;
  z-index: 430;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  color: var(--white);
  border: 1px solid var(--ink);
  border-radius: 0;              /* buttons never round */
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,.14), 0 6px 20px rgba(0,0,0,.10);
  transition: transform 200ms ease, background 200ms ease;
}
.tfwc-fab:hover { transform: translateY(-1px); background: var(--pitch); }
.tfwc-fab:active { transform: translateY(0); }
.tfwc-fab .tfwc-fab-close { display: none; }
.tfwc-fab[aria-expanded="true"] .tfwc-fab-open { display: none; }
.tfwc-fab[aria-expanded="true"] .tfwc-fab-close { display: block; }

/* Cart drawer takes priority — hide chat while it is open (mirrors the
   treatment the Zendesk launcher had). */
body.cart-drawer-open .tfwc-fab,
body.cart-drawer-open .tfwc-panel {
  display: none !important;
}

/* --- Panel: full sheet on mobile ---------------------------------------- */
.tfwc-panel {
  position: fixed;
  inset: 0;
  z-index: 440;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  background: var(--bg);
  font-family: var(--fb);
  color: var(--ink);
}
.tfwc-panel[hidden] { display: none; }

.tfwc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--bd);
  flex: 0 0 auto;
}
.tfwc-title {
  font-family: var(--fd);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.1;
}
/* Audit 6 Aug 2026: sentence case. "AI ASSISTANT · REPLIES IN SECONDS" is a
   33-character sentence, not a label — uppercase strips the word shapes we
   read by, and the chat header sits on every page on the site. */
.tfwc-status {
  font-size: 12px;
  letter-spacing: .04em;
  margin-top: 3px;
}
.tfwc-close {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 0;
  color: var(--ink);
  cursor: pointer;
}

/* --- Messages ------------------------------------------------------------ */
.tfwc-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.tfwc-msg {
  max-width: 85%;
  padding: 10px 13px;
  font-size: 14px;
  line-height: 1.55;
  border-radius: var(--radius-unit);
  word-wrap: break-word;
}
.tfwc-msg--user {
  align-self: flex-end;
  background: var(--ink);
  color: var(--white);
}
.tfwc-msg--assistant {
  align-self: flex-start;
  background: var(--bg);
  border: 1px solid var(--bd);
  box-shadow: var(--shadow-unit-sm);
}

/* Typing indicator */
.tfwc-typing { display: flex; gap: 5px; padding: 14px 16px; }
.tfwc-typing span {
  width: 6px; height: 6px;
  background: var(--ink);
  animation: tfwc-blink 1.2s infinite both;
}
.tfwc-typing span:nth-child(2) { animation-delay: .2s; }
.tfwc-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes tfwc-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* Starter chips */
.tfwc-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tfwc-chip {
  min-height: 44px;
  padding: 10px 14px;
  background: transparent;
  border: 1px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  font-family: var(--fb);
  font-size: 13px;
  cursor: pointer;
  transition: background 200ms ease, color 200ms ease;
}
.tfwc-chip:hover { background: var(--ink); color: var(--white); }

/* --- Product cards inside chat ------------------------------------------ */
/* Self-contained row layout — does not depend on shop.css being loaded. */
.tfwc-cards { display: flex; flex-direction: column; gap: 8px; max-width: 92%; }
.tfwc-cards .pc {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  background: var(--bg);
  border: 1px solid var(--bd);
  border-radius: var(--radius-unit);
  box-shadow: var(--shadow-unit-sm);
  text-decoration: none;
  color: var(--ink);
  transition: transform 200ms ease;
}
.tfwc-cards .pc:hover { transform: translateY(-1px); }
.tfwc-cards .pc-img {
  flex: 0 0 64px;
  width: 64px;
  position: relative;
  background: var(--bg2);
  overflow: hidden;
}
.tfwc-cards .pc-img img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 4; object-fit: cover; }
.tfwc-cards .pc-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tfwc-cards .pc-name-block { margin: 0; display: flex; flex-direction: column; gap: 1px; }
.tfwc-cards .pc-insp {
  font-size: 12px;
  letter-spacing:.03em;
  text-transform: uppercase;
  font-weight: 500;
}
.tfwc-cards .pc-name {
  font-family: var(--fd);
  font-size: 17px;
  font-weight: 600;
  line-height: 1.15;
}
.tfwc-cards .pc-price-link { font-size: 13px; font-weight: 600; }
.tfwc-cards .pc-badge--oos {
  position: absolute;
  top: 4px; left: 4px;
  padding: 2px 6px;
  background: var(--ink);
  color: var(--white);
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* --- Leave-a-message form (shown when the assistant cannot answer) -------- */
.tfwc-leave {
  align-self: flex-start;
  width: 92%;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--bd);
  border-radius: var(--radius-unit);
  box-shadow: var(--shadow-unit-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tfwc-leave-title {
  font-size: 13px;
  font-weight: 600;
}
.tfwc-leave input,
.tfwc-leave textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--bd);
  border-radius: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--fb);
  font-size: 16px;
  line-height: 1.4;
}
.tfwc-leave input:focus,
.tfwc-leave textarea:focus { outline: none; border-color: var(--ink); }
.tfwc-leave textarea { min-height: 72px; resize: vertical; }
.tfwc-leave-send {
  min-height: 48px;
  padding: 0 18px;
  background: var(--ink);
  color: var(--white);
  border: 1px solid var(--ink);
  border-radius: 0;
  font-family: var(--fb);
  font-size: 13px;
  letter-spacing: .04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 200ms ease, background 200ms ease;
}
.tfwc-leave-send:hover { transform: translateY(-1px); background: var(--pitch); }
.tfwc-leave-send:disabled { cursor: default; transform: none; }
.tfwc-leave-error { font-size: 12px; }

/* --- Composer ------------------------------------------------------------ */
.tfwc-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--bd);
  flex: 0 0 auto;
}
.tfwc-input {
  flex: 1 1 auto;
  min-height: 48px;
  max-height: 110px;
  padding: 13px 14px;
  border: 1px solid var(--bd);
  border-radius: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--fb);
  font-size: 16px;   /* prevents iOS zoom */
  line-height: 1.4;
  resize: none;
}
.tfwc-input:focus { outline: none; border-color: var(--ink); }
.tfwc-send {
  flex: 0 0 auto;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  color: var(--white);
  border: 1px solid var(--ink);
  border-radius: 0;
  cursor: pointer;
  transition: transform 200ms ease, background 200ms ease;
}
.tfwc-send:hover { transform: translateY(-1px); background: var(--pitch); }
.tfwc-send:disabled { cursor: default; transform: none; }

.tfwc-note {
  margin: 0;
  padding: 8px 16px 12px;
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
  flex: 0 0 auto;
}
.tfwc-note a { color: var(--ink); text-decoration: underline; }

/* --- Desktop: docked panel ------------------------------------------------ */
@media (min-width: 640px) {
  .tfwc-panel {
    inset: auto 16px 156px auto;   /* clears the FAB at bottom 90px + 56px */
    width: 380px;
    height: min(600px, calc(100dvh - 186px));
    border-radius: var(--radius-unit);
    box-shadow: 0 4px 16px rgba(0,0,0,.10), 0 12px 40px rgba(0,0,0,.12);
    overflow: hidden;
  }
}

/* Links inside chat bubbles (own-site paths, e.g. /quiz/, and mailto). */
.tfwc-msg .tfwc-link {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 2px;
	font-weight: 500;
}
