/* ===========================================================================
   myAFH AI Assistant — "calm clinical warmth"
   Warm humanist serif (Fraunces) for questions, friendly sans (Hanken Grotesk)
   for UI. Sage & clay palette. Designed to feel like a trusted care
   coordinator, not a tech chatbot.
   =========================================================================== */

:root {
  --mafh-sage:        #2a6f4f;
  --mafh-sage-deep:   #1f5a3f;
  --mafh-sage-soft:   #e7f0ea;
  --mafh-clay:        #c08a6e;
  --mafh-canvas:      #faf8f4;
  --mafh-card:        #ffffff;
  --mafh-ink:         #2b2a26;
  --mafh-ink-soft:    #6b6760;
  --mafh-line:        #ece7df;
  --mafh-shadow:      0 24px 60px -18px rgba(31, 45, 38, .35);
  --mafh-radius:      20px;
  --mafh-sans: "Hanken Grotesk", ui-sans-serif, system-ui, sans-serif;
  --mafh-serif: "Fraunces", Georgia, "Times New Roman", serif;
}

/* ----- reset boundary -----------------------------------------------------
   The widget is injected into arbitrary WordPress themes whose `button`/`input`
   rules would otherwise bleed in (e.g. hover color, forced width/radius). Reset
   our controls so only the styles below apply. */
.mafh-launch,
.mafh-panel,
.mafh-panel * {
  box-sizing: border-box;
}
.mafh-panel button,
.mafh-launch {
  margin: 0;
  font-family: var(--mafh-sans);
  text-transform: none;
  letter-spacing: normal;
  box-shadow: none;
  min-width: 0;
  min-height: 0;
  width: auto;
  text-decoration: none;
  line-height: normal;
  -webkit-appearance: none;
  appearance: none;
}
.mafh-panel button:hover,
.mafh-panel button:focus {
  outline: none;
  text-decoration: none;
}

/* ----- launcher ----------------------------------------------------------- */
.mafh-launch {
  position: fixed; bottom: 22px; right: 22px; z-index: 2147483000;
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--mafh-sans); font-weight: 600; font-size: 15px;
  color: #fff; background: var(--mafh-sage);
  border: none; border-radius: 100px; padding: 14px 22px; cursor: pointer;
  box-shadow: 0 12px 30px -8px rgba(42, 111, 79, .55);
  transition: transform .25s cubic-bezier(.2,.9,.3,1.2), background .2s, box-shadow .25s;
}
.mafh-launch:hover { background: var(--mafh-sage-deep); transform: translateY(-2px); box-shadow: 0 18px 38px -8px rgba(42,111,79,.6); }
.mafh-launch-open { transform: scale(.96); opacity: .9; }
.mafh-launch-dot {
  width: 9px; height: 9px; border-radius: 50%; background: #b8e3c9;
  box-shadow: 0 0 0 0 rgba(184,227,201,.7); animation: mafh-pulse 2.4s infinite;
}
@keyframes mafh-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(184,227,201,.7); }
  70%  { box-shadow: 0 0 0 9px rgba(184,227,201,0); }
  100% { box-shadow: 0 0 0 0 rgba(184,227,201,0); }
}

/* ----- panel -------------------------------------------------------------- */
.mafh-panel {
  position: fixed; bottom: 92px; right: 22px; z-index: 2147483000;
  width: 392px; max-width: calc(100vw - 32px);
  height: 600px; max-height: calc(100vh - 130px);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--mafh-canvas);
  border: 1px solid var(--mafh-line);
  border-radius: var(--mafh-radius);
  box-shadow: var(--mafh-shadow);
  font-family: var(--mafh-sans); color: var(--mafh-ink);
  transform-origin: bottom right;
  animation: mafh-pop .42s cubic-bezier(.2,.9,.3,1.15);
}
.mafh-hidden { display: none; }
@keyframes mafh-pop {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* subtle layered atmosphere instead of a flat panel */
.mafh-panel::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(120% 60% at 100% 0%, rgba(192,138,110,.10), transparent 60%),
    radial-gradient(90% 50% at 0% 100%, rgba(42,111,79,.08), transparent 55%);
}
.mafh-header, .mafh-progress, .mafh-body, .mafh-footer { position: relative; z-index: 1; }

/* ----- header ------------------------------------------------------------- */
.mafh-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; padding: 20px 20px 14px;
}
.mafh-title {
  font-family: var(--mafh-serif); font-weight: 500; font-size: 21px;
  line-height: 1.15; letter-spacing: -.01em; color: var(--mafh-ink);
}
.mafh-subtitle { margin-top: 4px; font-size: 13.5px; color: var(--mafh-ink-soft); line-height: 1.4; }
.mafh-close {
  flex: 0 0 30px; width: 30px; height: 30px; min-width: 30px; max-width: 30px;
  padding: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--mafh-line); background: var(--mafh-card);
  color: var(--mafh-ink-soft); font-size: 20px; line-height: 1; cursor: pointer;
  transition: background .15s, color .15s, transform .15s;
}
.mafh-close:hover { background: var(--mafh-sage-soft); color: var(--mafh-sage-deep); transform: rotate(90deg); }

/* ----- progress ----------------------------------------------------------- */
.mafh-progress { height: 4px; margin: 0 20px; background: var(--mafh-line); border-radius: 100px; overflow: hidden; }
.mafh-progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--mafh-sage), var(--mafh-clay)); border-radius: 100px; transition: width .5s cubic-bezier(.4,0,.2,1); }

/* ----- body / step -------------------------------------------------------- */
.mafh-body { flex: 1; overflow-y: auto; padding: 22px 20px 8px; }
.mafh-step { animation: mafh-rise .5s cubic-bezier(.2,.8,.2,1) both; }
@keyframes mafh-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

.mafh-kicker {
  font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--mafh-clay); margin-bottom: 10px;
}
.mafh-question {
  font-family: var(--mafh-serif); font-weight: 500; font-size: 25px; line-height: 1.18;
  letter-spacing: -.015em; color: var(--mafh-ink); margin: 0 0 8px;
}
.mafh-hint { font-size: 13.5px; color: var(--mafh-ink-soft); line-height: 1.5; margin: 0 0 18px; }

/* options */
.mafh-options { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.mafh-option {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; text-align: left; cursor: pointer;
  font-family: var(--mafh-sans); font-size: 15.5px; font-weight: 500; color: var(--mafh-ink);
  background: var(--mafh-card); border: 1.5px solid var(--mafh-line);
  border-radius: 14px; padding: 15px 17px;
  transition: border-color .18s, transform .18s, box-shadow .18s, background .18s;
  animation: mafh-rise .45s cubic-bezier(.2,.8,.2,1) both;
  animation-delay: calc(var(--i, 0) * 60ms + 80ms);
}
.mafh-option:hover {
  border-color: var(--mafh-sage); background: #fff; color: var(--mafh-ink);
  transform: translateX(3px); box-shadow: 0 10px 22px -12px rgba(42,111,79,.45);
}
.mafh-option:active { transform: translateX(3px) scale(.99); }
.mafh-option-label { color: var(--mafh-ink); flex: 1 1 auto; }
.mafh-option:hover .mafh-option-label { color: var(--mafh-ink); }
.mafh-option-arrow { flex: none; color: var(--mafh-sage); font-size: 18px; opacity: 0; transform: translateX(-6px); transition: opacity .18s, transform .18s; }
.mafh-option:hover .mafh-option-arrow { opacity: 1; transform: translateX(0); color: var(--mafh-sage); }

/* free-text input step */
.mafh-input-form { display: flex; gap: 8px; margin-top: 6px; }
.mafh-input {
  flex: 1; font-family: var(--mafh-sans); font-size: 15.5px; color: var(--mafh-ink);
  background: var(--mafh-card); border: 1.5px solid var(--mafh-line);
  border-radius: 12px; padding: 14px 15px; outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.mafh-input:focus { border-color: var(--mafh-sage); box-shadow: 0 0 0 4px var(--mafh-sage-soft); }
.mafh-input-go {
  font-family: var(--mafh-sans); font-weight: 600; font-size: 14.5px; color: #fff;
  background: var(--mafh-sage); border: none; border-radius: 12px; padding: 0 18px; cursor: pointer;
  transition: background .18s;
}
.mafh-input-go:hover { background: var(--mafh-sage-deep); }

/* finish card */
.mafh-finish { text-align: center; padding-top: 28px; }
.mafh-finish-check {
  width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; color: #fff; background: var(--mafh-sage);
  box-shadow: 0 12px 26px -10px rgba(42,111,79,.6);
  animation: mafh-check .5s cubic-bezier(.2,1.3,.4,1) both;
}
@keyframes mafh-check { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ----- footer ------------------------------------------------------------- */
.mafh-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 20px 18px; }
.mafh-spacer { display: inline-block; }
.mafh-text-btn {
  font-family: var(--mafh-sans); font-size: 13.5px; font-weight: 500; color: var(--mafh-ink-soft);
  background: none; border: none; cursor: pointer; padding: 6px 4px; border-radius: 8px;
  transition: color .15s;
}
.mafh-text-btn:hover { color: var(--mafh-sage-deep); }
.mafh-skip { text-decoration: underline; text-underline-offset: 3px; text-decoration-color: var(--mafh-line); }

/* ----- chat --------------------------------------------------------------- */
.mafh-body-chat { display: flex; flex-direction: column; padding-bottom: 0; }
.mafh-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-bottom: 8px; }
.mafh-msg {
  max-width: 86%; font-size: 14.5px; line-height: 1.5; padding: 11px 15px;
  border-radius: 16px; white-space: pre-wrap; word-wrap: break-word;
  animation: mafh-rise .35s ease both;
}
.mafh-user { align-self: flex-end; background: var(--mafh-sage); color: #fff; border-bottom-right-radius: 5px; }
.mafh-assistant { align-self: flex-start; background: var(--mafh-card); color: var(--mafh-ink); border: 1px solid var(--mafh-line); border-bottom-left-radius: 5px; }
.mafh-assistant strong { font-weight: 700; color: var(--mafh-ink); }
.mafh-link {
  color: var(--mafh-sage-deep); font-weight: 600; text-decoration: underline;
  text-underline-offset: 2px; text-decoration-color: rgba(42,111,79,.4);
  word-break: break-word; cursor: pointer;
}
.mafh-link:hover { color: var(--mafh-sage); text-decoration-color: var(--mafh-sage); }

.mafh-typing { display: inline-flex; gap: 5px; align-items: center; }
.mafh-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--mafh-ink-soft); opacity: .5; animation: mafh-bounce 1.2s infinite; }
.mafh-typing span:nth-child(2) { animation-delay: .18s; }
.mafh-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes mafh-bounce { 0%,60%,100% { transform: translateY(0); opacity:.4; } 30% { transform: translateY(-5px); opacity:.9; } }

.mafh-chat-form { display: flex; gap: 8px; padding: 12px 0 16px; border-top: 1px solid var(--mafh-line); margin-top: 4px; }
.mafh-chat-input {
  flex: 1; font-family: var(--mafh-sans); font-size: 14.5px; color: var(--mafh-ink);
  background: var(--mafh-card); border: 1.5px solid var(--mafh-line); border-radius: 12px;
  padding: 12px 14px; outline: none; transition: border-color .18s, box-shadow .18s;
}
.mafh-chat-input:focus { border-color: var(--mafh-sage); box-shadow: 0 0 0 4px var(--mafh-sage-soft); }
.mafh-chat-send {
  font-family: var(--mafh-sans); font-weight: 600; font-size: 14px; color: #fff;
  background: var(--mafh-sage); border: none; border-radius: 12px; padding: 0 18px; cursor: pointer;
  transition: background .18s;
}
.mafh-chat-send:hover { background: var(--mafh-sage-deep); }

/* scrollbar */
.mafh-body::-webkit-scrollbar, .mafh-log::-webkit-scrollbar { width: 7px; }
.mafh-body::-webkit-scrollbar-thumb, .mafh-log::-webkit-scrollbar-thumb { background: #ddd6cb; border-radius: 100px; }

/* responsive: take the full screen on small devices */
@media (max-width: 480px) {
  .mafh-panel { right: 0; bottom: 0; width: 100vw; max-width: 100vw; height: 88vh; max-height: 88vh; border-radius: 20px 20px 0 0; }
  .mafh-launch { bottom: 16px; right: 16px; }
}

/* respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  .mafh-panel, .mafh-step, .mafh-option, .mafh-msg, .mafh-finish-check { animation: none !important; }
  .mafh-launch-dot { animation: none; }
  .mafh-progress-fill { transition: none; }
}
