/* "Quick answers" chat assistant. Uses the brand tokens from styles.css.
   Layouts: floating panel on desktop, tall side sheet on tablets, full screen on phones. */

/* ---------- Launcher ---------- */
/* Fixed padding (16px each side of a 20px icon = a 52px circle); only the label's width animates,
   so expanding and shrinking is one smooth motion. */
.dac-launch {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 900;
  display: inline-flex; align-items: center;
  height: 52px; padding: 0 16px; border: 0; border-radius: 999px;
  background: var(--pine, #1F4A43); color: #fff;
  font: 600 15px/1 'Figtree', system-ui, sans-serif;
  box-shadow: 0 10px 28px -8px rgba(22, 55, 50, .45), 0 2px 6px rgba(22, 55, 50, .18);
  cursor: pointer;
  transition: background-color .2s, box-shadow .2s;
}
.dac-launch:hover { background: var(--pine-dark, #163732); box-shadow: 0 14px 32px -8px rgba(22, 55, 50, .5), 0 2px 6px rgba(22, 55, 50, .2); }
.dac-launch svg { width: 20px; height: 20px; flex: none; }
.dac-launch-label {
  display: inline-block; overflow: hidden; white-space: nowrap;
  max-width: 200px; margin-left: 9px; opacity: 1;
  transition: max-width .32s cubic-bezier(.22, 1, .36, 1), margin-left .32s cubic-bezier(.22, 1, .36, 1), opacity .18s ease .08s;
}
.dac-launch.is-compact .dac-launch-label {
  max-width: 0; margin-left: 0; opacity: 0;
  transition: max-width .3s cubic-bezier(.22, 1, .36, 1), margin-left .3s cubic-bezier(.22, 1, .36, 1), opacity .12s ease;
}
.dac-launch.appear { animation: dac-pop .26s cubic-bezier(.22, 1, .36, 1); }
@keyframes dac-pop { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }

.dac-launch:focus-visible,
.dac-panel button:focus-visible,
.dac-panel textarea:focus-visible,
.dac-panel a:focus-visible { outline: 3px solid var(--gold, #D89A5B); outline-offset: 2px; }

/* ---------- Panel ---------- */
.dac-panel {
  position: fixed; z-index: 901;
  right: 24px; bottom: 24px;
  width: clamp(440px, 34vw, 560px);
  height: min(860px, calc(100dvh - 108px)); /* starts below the site header */
  display: none; flex-direction: column; overflow: hidden;
  background: var(--ivory, #FCFAF7); color: var(--ink, #22332F);
  border: 1px solid rgba(31, 74, 67, .12); border-radius: 22px;
  box-shadow: 0 28px 70px -18px rgba(20, 40, 36, .35), 0 4px 14px rgba(20, 40, 36, .08);
  font: 15.5px/1.6 'Figtree', system-ui, sans-serif;
  transform-origin: 100% 100%;
}
.dac-panel.open { display: flex; }

.dac-head {
  position: relative; flex: none;
  padding: 18px 64px 16px 22px;
  background: var(--pine, #1F4A43); color: #fff;
}
.dac-head h2 { margin: 0; font: 600 20px/1.2 'Fraunces', Georgia, serif; color: #fff; letter-spacing: -.005em; }
.dac-head p { margin: 5px 0 0; font-size: 12.5px; line-height: 1.45; color: rgba(255, 255, 255, .82); }
.dac-close {
  position: absolute; top: 12px; right: 12px; width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 50%; background: transparent; color: #fff; cursor: pointer;
}
.dac-close svg { width: 20px; height: 20px; }
.dac-close:hover { background: rgba(255, 255, 255, .12); }

.dac-log {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 22px 22px 12px;
  display: flex; flex-direction: column; gap: 18px;
  scroll-padding-bottom: 12px;
}

/* Answers read like a document: full width, no bubble. Questions are pine bubbles. */
.dac-msg { word-wrap: break-word; }
.dac-msg.bot { align-self: stretch; }
.dac-text { white-space: pre-wrap; }
.dac-msg.user {
  align-self: flex-end; max-width: 85%;
  padding: 10px 15px; border-radius: 18px 18px 5px 18px;
  background: var(--pine, #1F4A43); color: #fff;
}
.dac-msg.bot.urgent {
  padding: 14px 16px; border-radius: 14px;
  background: #fdf1f0; border-left: 3px solid #b3261e;
}

/* Typing dots shown until the first words arrive */
.dac-msg.pending { min-height: 24px; display: flex; align-items: center; }
.dac-dots { display: inline-flex; gap: 5px; }
.dac-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--pine, #1F4A43); opacity: .3; animation: dac-dot 1.1s infinite ease-in-out; }
.dac-dots i:nth-child(2) { animation-delay: .15s; }
.dac-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes dac-dot { 0%, 80%, 100% { opacity: .25; transform: none; } 40% { opacity: .9; transform: translateY(-3px); } }

/* Source cards under an answer */
.dac-sources { margin-top: 14px; white-space: normal; }
.dac-sources-h { margin: 0 0 8px; font-size: 12.5px; font-weight: 600; color: var(--gold-text, #875621); }
.dac-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 8px; }
.dac-card {
  display: flex; align-items: center; gap: 10px; min-width: 0; padding: 7px;
  border-radius: 12px; background: #fff; border: 1px solid rgba(31, 74, 67, .13);
  color: inherit; text-decoration: none;
  transition: border-color .15s, box-shadow .15s;
}
.dac-card:hover { border-color: var(--pine, #1F4A43); box-shadow: 0 4px 14px -6px rgba(31, 74, 67, .3); }
.dac-thumb {
  position: relative; flex: none; width: 60px; height: 46px; border-radius: 8px; overflow: hidden;
  background: var(--sage, #DCE7E2);
}
.dac-thumb.is-media { width: 38px; height: 54px; }
.dac-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.dac-thumb.no-img { display: flex; align-items: center; justify-content: center; font: 600 20px/1 'Fraunces', Georgia, serif; color: var(--pine, #1F4A43); }
.dac-play { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 12px; text-shadow: 0 1px 4px rgba(0, 0, 0, .6); }
.dac-card-text { display: flex; flex-direction: column; min-width: 0; }
.dac-kind { font-size: 11.5px; line-height: 1.3; color: #5b6b67; }
.dac-title {
  font-size: 13.5px; font-weight: 600; line-height: 1.3; color: var(--pine, #1F4A43);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* Booking nudge */
.dac-book {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
  padding: 14px 16px; border-radius: 16px;
  background: var(--dawn, #F8EEE6); border: 1px solid rgba(216, 154, 91, .45);
}
.dac-book p { margin: 0; flex: 1 1 220px; font-size: 14.5px; line-height: 1.5; }
.dac-book a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 18px; border-radius: 999px;
  background: var(--gold, #D89A5B); color: var(--pine-dark, #163732); font-weight: 600; font-size: 14.5px; text-decoration: none;
}
.dac-book a:hover { background: var(--gold-deep, #C07F3E); color: #fff; }

/* Suggested first questions */
.dac-starters { display: flex; flex-wrap: wrap; gap: 8px; }
.dac-starters button {
  min-height: 40px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid rgba(31, 74, 67, .28); background: #fff; color: var(--pine, #1F4A43);
  font: 14px/1.3 'Figtree', system-ui, sans-serif; text-align: left; cursor: pointer;
}
.dac-starters button:hover { background: var(--sage, #DCE7E2); }

/* Composer */
.dac-form {
  flex: none; display: flex; align-items: flex-end; gap: 10px;
  padding: 12px 14px 8px; border-top: 1px solid rgba(31, 74, 67, .1); background: #fff;
}
.dac-form textarea {
  flex: 1; resize: none; min-height: 48px; max-height: 140px; padding: 12px 14px; overflow-y: hidden;
  border: 1px solid rgba(31, 74, 67, .22); border-radius: 14px; background: var(--ivory, #FCFAF7);
  color: var(--ink, #22332F);
  font: 16px/1.4 'Figtree', system-ui, sans-serif; /* 16px stops iOS zooming into the field */
}
.dac-form textarea:focus { outline: none; border-color: var(--pine, #1F4A43); box-shadow: 0 0 0 3px rgba(31, 74, 67, .12); background: #fff; }
.dac-send {
  flex: none; width: 48px; height: 48px; border: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--pine, #1F4A43); color: #fff; cursor: pointer; transition: background-color .15s, opacity .15s;
}
.dac-send svg { width: 20px; height: 20px; }
.dac-send:hover { background: var(--pine-dark, #163732); }
.dac-send:disabled { opacity: .45; cursor: default; }
.dac-note {
  flex: none; margin: 0; padding: 0 16px calc(10px + env(safe-area-inset-bottom));
  background: #fff; font-size: 11.5px; line-height: 1.45; color: #5b6b67;
}

/* ---------- Tablets: tall side sheet ---------- */
@media (max-width: 1023px) and (min-width: 600px) {
  .dac-panel { top: 16px; right: 16px; bottom: 16px; width: min(480px, calc(100vw - 32px)); height: auto; }
}

/* ---------- Phones: full screen ---------- */
@media (max-width: 599px) {
  /* Phones: icon-only launcher; a labelled pill would sit on top of the content */
  .dac-launch { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); height: 54px; padding: 0 16px; }
  .dac-launch .dac-launch-label { max-width: 0; margin-left: 0; opacity: 0; transition: none; }
  .dac-launch svg { width: 22px; height: 22px; }
  .dac-panel {
    inset: 0; width: 100%; height: var(--dac-vh, 100dvh);
    border: 0; border-radius: 0; box-shadow: none; font-size: 16px;
  }
  .dac-head { padding: calc(14px + env(safe-area-inset-top)) 60px 14px 18px; }
  .dac-head h2 { font-size: 19px; }
  .dac-close { top: calc(8px + env(safe-area-inset-top)); right: 8px; }
  .dac-log { padding: 18px 18px 10px; gap: 16px; }
  .dac-form { padding: 10px 12px 6px; }
  .dac-msg.user { max-width: 88%; }
}
/* The page behind the full-screen chat stays put */
html.dac-locked, html.dac-locked body { overflow: hidden; }

@media (prefers-reduced-motion: no-preference) {
  .dac-panel.open { animation: dac-in .24s cubic-bezier(.22, 1, .36, 1); }
  .dac-panel.closing { animation: dac-out .17s ease-in forwards; }
  @keyframes dac-in { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: none; } }
  @keyframes dac-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(12px) scale(.97); } }
}
@media (prefers-reduced-motion: no-preference) and (max-width: 599px) {
  /* Full-screen sheet slides up from the bottom on phones */
  .dac-panel.open { animation-name: dac-up; }
  .dac-panel.closing { animation-name: dac-down; }
  @keyframes dac-up { from { transform: translateY(100%); } to { transform: none; } }
  @keyframes dac-down { from { transform: none; } to { transform: translateY(100%); } }
}
@media (prefers-reduced-motion: reduce) {
  .dac-dots i { animation: none; opacity: .5; }
  .dac-launch, .dac-launch-label { transition: none !important; }
  .dac-launch.appear { animation: none; }
}
