/* Stowe Holdings: help assistant pop-up (every page). Behaviour: assets/js/assistant.js
   Every class starts with "sa-" so nothing here touches the rest of the site. */
.sa {
  --sa-navy: #102936;
  --sa-deep: #0a1d26;
  --sa-teal: #75b9b0;
  --sa-teal-deep: #2f6d63;
  --sa-gold: #d8b979;
  --sa-ink: #1d2b36;
  --sa-muted: #5d6b78;
  --sa-line: #e3e9ee;
  --sa-paper: #f6f8f8;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 85;
  font-family: Inter, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--sa-ink);
}
.sa .sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Launcher ---------- */
.sa-launch {
  display: inline-flex;
  align-items: center;
  gap: 0;
  min-height: 52px;
  padding: 0 7px;
  border: 1px solid rgba(117, 185, 176, 0.45);
  border-radius: 999px;
  background: linear-gradient(135deg, #16394a, var(--sa-deep));
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 14px 34px -12px rgba(10, 29, 38, 0.6), 0 0 0 4px rgba(117, 185, 176, 0.12);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.sa-launch-text {
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  opacity: 0;
  transition: max-width 0.3s ease, opacity 0.2s ease, margin 0.3s ease;
}
/* Round icon until hovered or focused, then the label slides out */
.sa-launch:hover .sa-launch-text,
.sa-launch:focus-visible .sa-launch-text { max-width: 220px; opacity: 1; margin: 0 12px 0 10px; }
.sa-launch:hover { transform: translateY(-2px); box-shadow: 0 18px 38px -12px rgba(10, 29, 38, 0.65), 0 0 0 5px rgba(117, 185, 176, 0.2); }
.sa-launch:focus-visible { outline: 2px solid var(--sa-gold); outline-offset: 3px; }
.sa-launch-ico {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--sa-gold);
  color: var(--sa-navy);
}
.sa-launch-ico svg { width: 20px; height: 20px; }
.sa.is-open .sa-launch { display: none; }

/* ---------- Panel ---------- */
.sa-panel {
  display: flex;
  flex-direction: column;
  width: 370px;
  height: min(580px, calc(calc(100 * var(--vh)) - 110px));
  height: min(580px, calc(calc(100 * var(--dvh)) - 110px));
  border-radius: 20px;
  overflow: hidden;
  background: #fff;
  border: 1px solid rgba(16, 41, 54, 0.1);
  box-shadow: 0 30px 70px -24px rgba(10, 29, 38, 0.55), 0 2px 8px rgba(10, 29, 38, 0.08);
  animation: sa-in 0.28s cubic-bezier(0.2, 0.7, 0.2, 1);
  transform-origin: bottom right;
}
.sa-panel[hidden] { display: none; }
@keyframes sa-in { from { opacity: 0; transform: translateY(12px) scale(0.97); } }

.sa-head {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  background:
    radial-gradient(120% 140% at 100% 0, rgba(117, 185, 176, 0.28), transparent 55%),
    linear-gradient(135deg, #16394a, var(--sa-deep));
  color: #fff;
}
.sa-head::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--sa-gold), var(--sa-teal));
}
.sa-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--sa-gold);
  color: var(--sa-navy);
}
.sa-avatar svg { width: 20px; height: 20px; }
.sa-head-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.sa-head-text b { font-family: Archivo, Inter, sans-serif; font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.sa-head-text small { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: #c7d6e0; }
.sa-dot { width: 7px; height: 7px; border-radius: 50%; background: #5fd3a8; box-shadow: 0 0 0 3px rgba(95, 211, 168, 0.22); }
.sa-close {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
}
.sa-close svg { width: 18px; height: 18px; }
.sa-close:hover { background: rgba(255, 255, 255, 0.16); }
.sa-close:focus-visible { outline: 2px solid var(--sa-gold); outline-offset: 2px; }

/* ---------- Messages ---------- */
.sa-log {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 14px 8px;
  background: var(--sa-paper);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.sa-msg { display: flex; flex-direction: column; gap: 8px; max-width: 92%; }
.sa-msg.is-new { animation: sa-msg 0.3s ease both; }
@keyframes sa-msg { from { opacity: 0; transform: translateY(6px); } }
.sa-msg--user { align-self: flex-end; align-items: flex-end; }
.sa-bubble {
  margin: 0;
  padding: 10px 13px;
  border-radius: 14px 14px 14px 4px;
  background: #fff;
  border: 1px solid var(--sa-line);
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.sa-msg--user .sa-bubble {
  border-radius: 14px 14px 4px 14px;
  border-color: transparent;
  background: var(--sa-navy);
  color: #fff;
}

.sa-links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.sa-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--sa-line);
  color: var(--sa-ink);
  text-decoration: none;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.sa-link:hover { border-color: var(--sa-teal); transform: translateX(2px); box-shadow: 0 6px 16px -10px rgba(16, 41, 54, 0.4); }
.sa-link:focus-visible { outline: 2px solid var(--sa-teal-deep); outline-offset: 2px; }
.sa-link-ico {
  display: grid;
  place-items: center;
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: rgba(117, 185, 176, 0.16);
  color: var(--sa-teal-deep);
}
.sa-link-ico svg { width: 15px; height: 15px; }
.sa-link--video .sa-link-ico { background: var(--sa-navy); color: var(--sa-gold); }
.sa-link--video .sa-link-ico svg { width: 11px; height: 11px; margin-left: 2px; }
.sa-link--portal .sa-link-ico { background: rgba(216, 185, 121, 0.22); color: #8a6d2f; }
.sa-link-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sa-link-body b { font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.sa-link-body small { font-size: 12px; color: var(--sa-muted); line-height: 1.3; }

.sa-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.sa-chip {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(47, 109, 99, 0.35);
  background: #fff;
  color: var(--sa-teal-deep);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.sa-chip:hover { background: var(--sa-teal-deep); border-color: var(--sa-teal-deep); color: #fff; }
.sa-chip:focus-visible { outline: 2px solid var(--sa-gold); outline-offset: 2px; }

.sa-typing .sa-bubble { display: inline-flex; gap: 4px; padding: 13px 14px; }
.sa-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--sa-teal-deep); opacity: 0.4; animation: sa-dot 1s infinite ease-in-out; }
.sa-typing span:nth-child(2) { animation-delay: 0.15s; }
.sa-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes sa-dot { 50% { opacity: 1; transform: translateY(-2px); } }

/* ---------- Input ---------- */
.sa-form {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid var(--sa-line);
}
.sa-input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid #cfd8df;
  border-radius: 999px;
  background: #fff;
  color: var(--sa-ink);
  font-family: inherit;
  font-size: 16px; /* 16px stops iPhones zooming in on tap */
}
.sa-input::placeholder { color: #8795a1; }
.sa-input:focus { outline: none; border-color: var(--sa-teal-deep); box-shadow: 0 0 0 3px rgba(117, 185, 176, 0.25); }
.sa-send {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--sa-gold);
  color: var(--sa-navy);
  cursor: pointer;
  transition: background 0.2s ease;
}
.sa-send svg { width: 18px; height: 18px; }
.sa-send:hover { background: #e2c68e; }
.sa-send:focus-visible { outline: 2px solid var(--sa-teal-deep); outline-offset: 2px; }
.sa-foot { margin: 0; padding: 0 14px 10px; background: #fff; font-size: 11px; color: var(--sa-muted); text-align: center; }
.sa-foot a { color: var(--sa-teal-deep); font-weight: 600; }

/* ---------- Phones: compact launcher, panel as a bottom sheet ---------- */
@media (max-width: 600px) {
  .sa { right: 12px; bottom: 12px; }
  .sa-launch { padding: 0 7px; min-height: 52px; }
  .sa.is-open { left: 0; right: 0; bottom: 0; }
  .sa-panel {
    width: 100%;
    height: min(calc(88 * var(--vh)), 640px);
    height: min(calc(88 * var(--dvh)), 640px);
    border-radius: 20px 20px 0 0;
    border-bottom: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sa-panel, .sa-msg.is-new, .sa-typing span { animation: none; }
  .sa-launch, .sa-link, .sa-chip, .sa-launch-text { transition: none; }
}

@media print { .sa { display: none; } }
