/* ============================================================
   Physical Formula, Chat With Us widget
   ============================================================ */

:root {
  --pf-chat-black: #0A0A0A;
  --pf-chat-ink:   #141412;
  --pf-chat-white: #FFFFFF;
  --pf-chat-bg:    #F4F2EE;
  --pf-chat-line:  #E2DCD0;
  --pf-chat-text:  #1A1716;
  --pf-chat-soft:  rgba(10,10,10,0.62);
  --pf-chat-faint: rgba(10,10,10,0.42);
  --pf-chat-ghost: rgba(10,10,10,0.22);
  --pf-chat-font:  'Inter', -apple-system, 'Helvetica Neue', Arial, sans-serif;
}

/* ---------- Trigger ----------
   White pill with a dark border, so it reads on both dark heroes and
   cream content backgrounds. */
.pf-chat-trigger {
  position: fixed;
  right: clamp(20px, 3vw, 36px);
  bottom: clamp(20px, 3vw, 36px);
  z-index: 95;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  background: var(--pf-chat-white);
  color: var(--pf-chat-black);
  border: 1px solid var(--pf-chat-black);
  border-radius: 999px;
  font-family: var(--pf-chat-font);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 220ms ease, color 220ms ease, transform 220ms ease, border-color 220ms ease;
  -webkit-tap-highlight-color: transparent;
}
.pf-chat-trigger:hover {
  background: var(--pf-chat-black);
  color: var(--pf-chat-white);
  border-color: var(--pf-chat-black);
  transform: translateY(-1px);
}
.pf-chat-trigger .pf-chat-pulse {
  width: 7px; height: 7px;
  background: var(--pf-chat-black);
  border-radius: 50%;
  opacity: 0.9;
  animation: pf-chat-pulse 2s cubic-bezier(0.22, 1, 0.36, 1) infinite;
}
.pf-chat-trigger:hover .pf-chat-pulse {
  background: var(--pf-chat-white);
}
@keyframes pf-chat-pulse {
  0%, 100% { opacity: 0.9; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(1.3); }
}
.pf-chat-trigger[aria-expanded="true"] {
  opacity: 0;
  pointer-events: none;
}

/* The chat-bubble icon is hidden on desktop (text pill carries the meaning) and
   shown on mobile so the round button reads instantly. */
.pf-chat-icon { display: none; width: 18px; height: 18px; color: currentColor; }

/* On mobile, drop the text label and show a chat-bubble icon inside the round button. */
@media (max-width: 560px) {
  .pf-chat-trigger {
    padding: 0;
    width: 48px;
    height: 48px;
    gap: 0;
    right: clamp(14px, 3vw, 24px);
    bottom: clamp(16px, 3vw, 24px);
    align-items: center;
    justify-content: center;
    position: fixed;
  }
  .pf-chat-trigger > span:last-child { display: none; }
  .pf-chat-trigger .pf-chat-pulse {
    position: absolute;
    top: 8px; right: 8px;
    width: 8px; height: 8px;
    background: var(--pf-chat-black);
  }
  .pf-chat-trigger .pf-chat-icon { display: block; }
}

/* ---------- Panel ---------- */
.pf-chat-panel {
  position: fixed;
  right: clamp(20px, 3vw, 36px);
  bottom: clamp(20px, 3vw, 36px);
  width: min(420px, calc(100vw - 40px));
  height: min(640px, calc(100vh - 80px));
  z-index: 96;
  background: var(--pf-chat-white);
  border: 1px solid var(--pf-chat-line);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 48px rgba(10,10,10,0.12);
  overflow: hidden;
}
.pf-chat-panel[hidden] { display: none; }
.pf-chat-panel.is-entering {
  animation: pf-chat-in 280ms cubic-bezier(0.22, 0.61, 0.36, 1) both;
}
@keyframes pf-chat-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (max-width: 560px) {
  .pf-chat-panel {
    right: 0; bottom: 0; left: 0;
    width: 100vw;
    height: 88vh;
    border-radius: 6px 6px 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }
}

/* ---------- Header ---------- */
.pf-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--pf-chat-line);
  background: var(--pf-chat-white);
}
.pf-chat-head .pf-chat-title {
  font-family: var(--pf-chat-font);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--pf-chat-text);
  display: block;
}
.pf-chat-head .pf-chat-meta {
  display: block;
  font-family: var(--pf-chat-font);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--pf-chat-faint);
  margin-top: 6px;
}
.pf-chat-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.pf-chat-close,
.pf-chat-min {
  background: none;
  border: 0;
  padding: 6px;
  color: var(--pf-chat-text);
  opacity: 0.55;
  cursor: pointer;
  transition: opacity 200ms ease;
  border-radius: 0;
}
.pf-chat-close:hover,
.pf-chat-min:hover { opacity: 1; }
.pf-chat-close svg,
.pf-chat-min svg { display: block; }

/* ---------- Body / messages ---------- */
.pf-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  background: var(--pf-chat-white);
  scrollbar-width: thin;
  scrollbar-color: var(--pf-chat-line) transparent;
}
.pf-chat-body::-webkit-scrollbar { width: 6px; }
.pf-chat-body::-webkit-scrollbar-thumb { background: var(--pf-chat-line); border-radius: 3px; }

.pf-msg {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 92%;
}
.pf-msg .pf-msg-eyebrow {
  font-family: var(--pf-chat-font);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--pf-chat-faint);
}
.pf-msg .pf-msg-body {
  font-family: var(--pf-chat-font);
  font-weight: 400;
  font-size: 14px;
  line-height: 1.7;
  color: var(--pf-chat-text);
  white-space: pre-wrap;
}
.pf-msg .pf-msg-body a {
  color: var(--pf-chat-text);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.pf-msg.is-user {
  align-self: flex-end;
  align-items: flex-end;
}
.pf-msg.is-user .pf-msg-body {
  background: var(--pf-chat-bg);
  padding: 12px 14px;
  border: 1px solid var(--pf-chat-line);
  border-radius: 4px;
}
.pf-msg.is-bot .pf-msg-body { padding-right: 8px; }

/* ---------- Typing ---------- */
.pf-typing {
  display: inline-flex;
  gap: 6px;
  padding: 6px 2px;
}
.pf-typing span {
  width: 5px; height: 5px;
  background: var(--pf-chat-text);
  opacity: 0.45;
  border-radius: 50%;
  animation: pf-chat-blink 1.2s infinite ease-in-out;
}
.pf-typing span:nth-child(2) { animation-delay: 0.18s; }
.pf-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes pf-chat-blink {
  0%, 80%, 100% { opacity: 0.2; }
  40%           { opacity: 0.9; }
}

/* ---------- Starter prompts ---------- */
.pf-starters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.pf-starter {
  background: var(--pf-chat-white);
  border: 1px solid var(--pf-chat-line);
  border-radius: 999px;
  padding: 9px 14px;
  font-family: var(--pf-chat-font);
  font-weight: 500;
  font-size: 12px;
  color: var(--pf-chat-text);
  cursor: pointer;
  transition: background 200ms ease, color 200ms ease, border-color 200ms ease;
  text-align: left;
}
.pf-starter:hover {
  background: var(--pf-chat-black);
  color: var(--pf-chat-white);
  border-color: var(--pf-chat-black);
}

/* ---------- Link cards (page references) ---------- */
.pf-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}
.pf-card {
  display: flex;
  gap: 14px;
  align-items: stretch;
  border: 1px solid var(--pf-chat-line);
  border-radius: 4px;
  background: var(--pf-chat-bg);
  text-decoration: none;
  color: var(--pf-chat-text);
  transition: background 200ms ease, border-color 200ms ease;
  overflow: hidden;
}
.pf-card:hover {
  background: var(--pf-chat-white);
  border-color: var(--pf-chat-ghost);
}
.pf-card-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  min-width: 0;
}
.pf-card .pf-msg-eyebrow {
  font-family: var(--pf-chat-font);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--pf-chat-faint);
}
.pf-card .pf-card-title {
  font-family: var(--pf-chat-font);
  font-weight: 600;
  font-size: 13px;
  line-height: 1.4;
  color: var(--pf-chat-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.pf-card .pf-card-excerpt {
  font-family: var(--pf-chat-font);
  font-weight: 400;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--pf-chat-soft);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- Composer ---------- */
.pf-chat-foot {
  border-top: 1px solid var(--pf-chat-line);
  padding: 14px 18px 16px;
  background: var(--pf-chat-white);
}
.pf-chat-form {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--pf-chat-line);
  padding: 6px 0;
}
.pf-chat-input {
  flex: 1;
  border: 0;
  background: transparent;
  outline: none;
  font-family: var(--pf-chat-font);
  font-weight: 400;
  font-size: 14px;
  color: var(--pf-chat-text);
  padding: 8px 0;
}
.pf-chat-input::placeholder { color: var(--pf-chat-faint); }
.pf-chat-send {
  border: 0;
  background: transparent;
  color: var(--pf-chat-text);
  padding: 6px 4px;
  font-family: var(--pf-chat-font);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 200ms ease;
}
.pf-chat-send:hover,
.pf-chat-input:not(:placeholder-shown) ~ .pf-chat-send { opacity: 1; }
.pf-chat-foot .pf-chat-fine {
  display: block;
  font-family: var(--pf-chat-font);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--pf-chat-faint);
  margin-top: 10px;
}

/* Restore native cursor while the chat is open (the main site uses cursor:none) */
body.pf-chat-open,
body.pf-chat-open a,
body.pf-chat-open button { cursor: auto !important; }
.pf-chat-input { cursor: text; }
.pf-chat-trigger,
.pf-chat-close,
.pf-chat-send,
.pf-starter,
.pf-card { cursor: pointer; }

@media print {
  .pf-chat-trigger, .pf-chat-panel { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  .pf-chat-trigger, .pf-chat-panel { transition: none; }
  .pf-typing span, .pf-chat-pulse { animation: none; }
}
