/* ============================================================
   SSSS Admissions Assistant: floating chat widget
   Namespaced .ssc-* so it can't collide with page styles.
   Talks to the ChatService (data-chat-url on the root element).
   Uses site design tokens with safe fallbacks.
   ============================================================ */

.ssc-root {
  --ssc-accent: var(--accent, #af251c);
  --ssc-ink: var(--ink, #16181d);
  --ssc-muted: var(--muted, #6b7280);
  --ssc-line: var(--line, #e7e7ec);
  --ssc-bg: #ffffff;
  --ssc-user: var(--accent, #af251c);
  --ssc-bot: #f4f5f7;
  --ssc-ease: var(--ease, cubic-bezier(.22, .61, .36, 1));
  --ssc-gap: clamp(14px, 2.4vw, 26px);
  /* --ssc-bar is the height of the page's bottom bar showing right now, set by
     chat-widget.js, so the button always sits just above it */
  --ssc-lift: var(--ssc-bar, 0px);
  position: fixed;
  right: var(--ssc-gap);
  bottom: calc(var(--ssc-gap) + max(var(--ssc-bar, 0px), env(safe-area-inset-bottom, 0px)));
  z-index: 2147483000;
  font-family: 'Familjen Grotesk', 'Bricolage Grotesque', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
/* No grey/blue flash box on tap (Android Chrome); each control has its own pressed state. */
.ssc-root button, .ssc-root a { -webkit-tap-highlight-color: transparent; }

/* Out of the way while the menu drawer, a lightbox, the notice or a phone
   keyboard (a form field in focus) has the screen. */
html.ss-menu-lock .ssc-root:not(.is-open),
html.cp-lb-lock .ssc-root:not(.is-open),
html.ss-typing .ssc-root:not(.is-open),
body.ss-caution-lock .ssc-root:not(.is-open) { opacity: 0; visibility: hidden; transition: opacity .2s var(--ssc-ease), visibility 0s .2s; }

/* ---- launcher ---- */
.ssc-launch {
  display: inline-flex; align-items: center; gap: 10px;
  height: 58px; padding: 0 22px 0 18px;
  border: none; border-radius: 100px; cursor: pointer;
  background: var(--ssc-accent); color: #fff;
  font-size: 15.5px; font-weight: 600; letter-spacing: .01em;
  box-shadow: 0 16px 40px -14px rgba(175, 37, 28, .6), 0 4px 14px -6px rgba(0, 0, 0, .3);
  transition: transform .28s var(--ssc-ease), box-shadow .28s var(--ssc-ease), opacity .2s var(--ssc-ease);
}
.ssc-launch:hover { transform: translateY(-2px); box-shadow: 0 22px 50px -14px rgba(175, 37, 28, .7); }
.ssc-launch svg { width: 24px; height: 24px; flex: none; }
.ssc-launch .ssc-launch-label { white-space: nowrap; }
.ssc-root.is-open .ssc-launch { opacity: 0; pointer-events: none; transform: scale(.9); }

/* ---- panel ---- */
.ssc-panel {
  position: absolute; right: 0; bottom: 0;
  width: min(384px, calc(100vw - 28px));
  height: min(600px, calc(100vh - 40px - var(--ssc-lift, 0px)));
  /* dvh follows the iOS toolbar, so the input never sits under it */
  height: min(600px, calc(100dvh - 40px - var(--ssc-lift, 0px)));
  display: flex; flex-direction: column;
  background: var(--ssc-bg); color: var(--ssc-ink);
  border: 1px solid var(--ssc-line);
  border-radius: 20px; overflow: hidden;
  box-shadow: 0 40px 90px -30px rgba(8, 10, 20, .5), 0 10px 30px -12px rgba(0, 0, 0, .25);
  opacity: 0; transform: translateY(16px) scale(.98); pointer-events: none;
  transition: opacity .3s var(--ssc-ease), transform .3s var(--ssc-ease);
}
.ssc-root.is-open .ssc-panel { opacity: 1; transform: none; pointer-events: auto; }

/* ---- header ---- */
.ssc-head {
  display: flex; align-items: center; gap: 12px;
  padding: 15px 16px; color: #fff;
  background:
    radial-gradient(120% 140% at 100% 0%, rgba(255, 255, 255, .16), transparent 55%),
    linear-gradient(135deg, #9c2119 0%, #5e120e 100%);
}
.ssc-head-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .16);
}
.ssc-head-avatar svg { width: 22px; height: 22px; }
.ssc-head-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.ssc-head-title { font-size: 15.5px; font-weight: 700; }
.ssc-head-sub { font-size: 12px; opacity: .82; display: inline-flex; align-items: center; gap: 6px; }
.ssc-dot { width: 7px; height: 7px; border-radius: 50%; background: #57e08a; box-shadow: 0 0 0 3px rgba(87, 224, 138, .25); }
.ssc-close {
  margin-left: auto; width: 44px; height: 44px; flex: none;
  border: none; border-radius: 50%; cursor: pointer;
  background: rgba(255, 255, 255, .14); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background-color .2s var(--ssc-ease);
}
.ssc-close:hover { background: rgba(255, 255, 255, .28); }
.ssc-close svg { width: 18px; height: 18px; }

/* ---- messages ---- */
.ssc-body {
  flex: 1; overflow-y: auto; padding: 16px 14px 8px;
  display: flex; flex-direction: column; gap: 10px;
  background: linear-gradient(180deg, #fafbfc 0%, #ffffff 40%);
  scroll-behavior: smooth;
  /* reaching either end of the conversation never starts scrolling the page */
  overscroll-behavior: contain;
  /* offsetTop of each message is measured from here (see reveal()) */
  position: relative;
}
/* phones: the open chat covers the page, so the page behind it holds still */
html.ssc-lock { overflow: hidden; }
html.ssc-lock body { overflow: visible; }
.ssc-msg { max-width: 84%; padding: 10px 13px; border-radius: 15px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.ssc-msg a { color: inherit; text-decoration: underline; }
.ssc-bot { align-self: flex-start; background: var(--ssc-bot); color: var(--ssc-ink); border-bottom-left-radius: 5px; }
.ssc-user { align-self: flex-end; background: var(--ssc-user); color: #fff; border-bottom-right-radius: 5px; }
.ssc-bot a { color: var(--ssc-accent); }

/* typing indicator */
.ssc-typing { align-self: flex-start; display: inline-flex; gap: 4px; padding: 12px 14px; background: var(--ssc-bot); border-radius: 15px; border-bottom-left-radius: 5px; }
.ssc-typing span { width: 7px; height: 7px; border-radius: 50%; background: #b6bcc6; animation: ssc-bounce 1.2s infinite ease-in-out; }
.ssc-typing span:nth-child(2) { animation-delay: .15s; }
.ssc-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes ssc-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }

/* ---- FAQ chips ---- */
.ssc-chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 2px 2px 6px; }
.ssc-chip {
  border: 1px solid var(--ssc-line); background: #fff; color: var(--ssc-ink);
  border-radius: 100px; padding: 7px 13px; font-size: 12.5px; font-weight: 500;
  cursor: pointer; text-align: left; line-height: 1.3;
  transition: border-color .2s var(--ssc-ease), background-color .2s var(--ssc-ease), transform .2s var(--ssc-ease);
}
.ssc-chip:hover { border-color: var(--ssc-accent); background: #fff5f5; transform: translateY(-1px); }

/* ---- page links under a reply ---- */
.ssc-links { align-self: flex-start; display: flex; flex-direction: column; gap: 6px; width: 84%; margin-top: -2px; }
.ssc-link {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px; border: 1px solid var(--ssc-line); border-radius: 12px;
  background: #fff; color: var(--ssc-ink); text-decoration: none;
  font-size: 13.5px; font-weight: 600; line-height: 1.3;
  transition: border-color .2s var(--ssc-ease), background-color .2s var(--ssc-ease), transform .2s var(--ssc-ease);
}
.ssc-link:hover { border-color: var(--ssc-accent); background: #fff5f5; transform: translateY(-1px); }
.ssc-link:active { transform: scale(.98); }
.ssc-link:focus-visible { outline: 2px solid var(--ssc-accent); outline-offset: 2px; }
.ssc-link svg { width: 16px; height: 16px; flex: none; color: var(--ssc-accent); }

/* ---- inline callback form ---- */
.ssc-form {
  align-self: stretch; display: flex; flex-direction: column; gap: 10px;
  padding: 14px; border: 1px solid var(--ssc-line); border-radius: 15px; background: #fff;
  box-shadow: 0 10px 26px -18px rgba(8, 10, 20, .35);
}
.ssc-form-title { margin: 0; font-size: 14.5px; font-weight: 700; color: var(--ssc-ink); }
.ssc-field { display: flex; flex-direction: column; gap: 4px; margin: 0; }
.ssc-field span { font-size: 12px; font-weight: 600; color: var(--ssc-muted); }
.ssc-field input, .ssc-field select {
  width: 100%; height: 42px; padding: 0 12px; box-sizing: border-box;
  border: 1px solid var(--ssc-line); border-radius: 12px; background: #fff;
  font: inherit; font-size: 16px; color: var(--ssc-ink); outline: none;
  transition: border-color .2s var(--ssc-ease);
}
.ssc-field input:focus, .ssc-field select:focus { border-color: var(--ssc-accent); }
.ssc-form-err { margin: 0; font-size: 12.5px; color: #b00020; }
.ssc-form-btn {
  height: 44px; border: none; border-radius: 100px; cursor: pointer;
  background: var(--ssc-accent); color: #fff; font: inherit; font-size: 15px; font-weight: 600;
  transition: transform .2s var(--ssc-ease), opacity .2s var(--ssc-ease);
}
.ssc-form-btn:hover { transform: translateY(-1px); }
.ssc-form-btn:active { transform: scale(.98); }
.ssc-form-btn:disabled { opacity: .55; cursor: default; transform: none; }
.ssc-form-note { margin: 0; font-size: 11.5px; line-height: 1.4; color: var(--ssc-muted); }

/* ---- teaser above the launcher: one line about the page being read ---- */
.ssc-teaser {
  position: absolute; right: 0; bottom: 70px; width: min(264px, calc(100vw - 32px));
  display: flex; align-items: flex-start; gap: 4px;
  padding: 6px 6px 6px 4px; border: 1px solid var(--ssc-line); border-radius: 16px;
  background: #fff; color: var(--ssc-ink);
  box-shadow: 0 22px 50px -24px rgba(8, 10, 20, .45), 0 6px 16px -10px rgba(8, 10, 20, .25);
  animation: ssc-teaser-in .35s var(--ssc-ease) both;
}
.ssc-teaser-text {
  flex: 1; border: none; background: none; cursor: pointer; text-align: left;
  padding: 8px 6px 8px 10px; font: inherit; font-size: 14px; line-height: 1.45; color: inherit;
}
.ssc-teaser-x {
  width: 32px; height: 32px; flex: none; border: none; border-radius: 50%; cursor: pointer;
  background: var(--ssc-bot); color: var(--ssc-muted);
  display: inline-flex; align-items: center; justify-content: center;
}
.ssc-teaser-x:hover { color: var(--ssc-ink); }
.ssc-teaser-x svg { width: 14px; height: 14px; }
.ssc-root.is-open .ssc-teaser { display: none; }
@keyframes ssc-teaser-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---- input ---- */
.ssc-foot { border-top: 1px solid var(--ssc-line); padding: 10px 12px 12px; background: #fff; }
.ssc-inputrow { display: flex; align-items: flex-end; gap: 8px; }
.ssc-input {
  flex: 1; resize: none; max-height: 110px; min-height: 24px;
  border: 1px solid var(--ssc-line); border-radius: 14px;
  padding: 10px 12px; font: inherit; font-size: 16px; line-height: 1.4; color: var(--ssc-ink);
  outline: none; transition: border-color .2s var(--ssc-ease);
}
.ssc-input:focus { border-color: var(--ssc-accent); }
.ssc-send {
  width: 42px; height: 42px; flex: none; border: none; border-radius: 12px; cursor: pointer;
  background: var(--ssc-accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .2s var(--ssc-ease), opacity .2s var(--ssc-ease);
}
.ssc-send:hover { transform: translateY(-1px); }
.ssc-send:disabled { opacity: .45; cursor: default; transform: none; }
.ssc-send svg { width: 19px; height: 19px; }
.ssc-legal { margin: 8px 2px 0; font-size: 12px; color: var(--ssc-muted); text-align: center; line-height: 1.35; text-wrap: balance; }

/* ---- tablets and phones ----
   The button stays at the bottom right on every screen, a little smaller as
   the screen narrows. Open, the chat covers the screen (the page behind it is
   held still), so it drops to the corner and ignores the bottom bar. */
@media (max-width: 900px) {
  .ssc-root { --ssc-gap: 14px; }
  .ssc-launch { height: 52px; padding: 0 18px 0 15px; font-size: 15px; gap: 8px; }
  .ssc-launch svg { width: 22px; height: 22px; }
  .ssc-root.is-open { right: 10px; bottom: 10px; --ssc-lift: 0px; }
  .ssc-panel { width: calc(100vw - 20px); max-width: 420px; height: calc(100vh - 20px); height: calc(100dvh - 20px); max-height: 680px; }
}
@media (max-width: 600px) {
  .ssc-root { --ssc-gap: 12px; }
  .ssc-launch { width: 56px; height: 56px; padding: 0; justify-content: center; }
  .ssc-launch .ssc-launch-label { display: none; }
  .ssc-launch svg { width: 24px; height: 24px; }
  .ssc-teaser { bottom: 66px; }
}
@media (max-width: 480px) {
  .ssc-panel { max-width: none; border-radius: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .ssc-launch, .ssc-panel, .ssc-chip, .ssc-send, .ssc-link, .ssc-form-btn { transition: none; }
  .ssc-teaser { animation: none; }
  .ssc-typing span { animation: none; }
  .ssc-body { scroll-behavior: auto; }
}
