/* ==========================================================================
   SYPHON CHAT WIDGET (scw1): RevivalRO Loki's community in Syphon Chat, at the bottom left of every page.
   Markup: main/syphon_chat.php (and its English copy in 404.html, terms.html, privacy.html). The shared core,
   js/syphon-chat-widget.js, sets these classes on #syphon-chat-widget: scw-collapsed (closed: the round button only),
   scw-has-counts (the chat server's numbers came), scw-someone-online. Every rule but one (the footer's room, below) is
   scoped under #syphon-chat-widget and uses the site's tokens (css/loki.css). Stacking: above the page, under the mobile
   drawer (990), the header and its menus
   (1000), the flash message (2500) and the support modal (3000). Loaded on every page by main/head_styles.php.
   ========================================================================== */
#syphon-chat-widget {
  position: fixed; z-index: 950;
  left: max(22px, env(safe-area-inset-left));
  bottom: calc(22px + env(safe-area-inset-bottom));
  width: 300px; max-width: calc(100vw - 32px);
  font-family: var(--lk-font); font-size: 14px; line-height: 1.45; color: var(--lk-text); text-align: left;
}
#syphon-chat-widget.scw-collapsed { width: auto; }
/* hidden for the moment until the core has chosen open or closed, so a visitor's own choice never flashes the other way;
   shown anyway after 4 s should the core not load (without JavaScript it shows at once, open) */
#syphon-chat-widget.scw-js:not([data-scw-ready]) { visibility: hidden; animation: scw-reveal 0s linear 4s forwards; }
@keyframes scw-reveal { to { visibility: visible; } }

/* ---------- the card (open) ---------- */
#syphon-chat-widget .scw-card {
  position: relative; padding: 14px 18px 12px;
  /* the site's surface gradient at the near-opaque ground of its floating menus (.lk-menu), so the text keeps its
     contrast over any picture behind the card */
  background: linear-gradient(180deg, rgba(33, 24, 60, .98) 0%, rgba(21, 16, 39, .98) 100%);
  border: 1px solid var(--lk-line-2); border-radius: var(--lk-radius-lg);
  box-shadow: var(--lk-shadow-lg), 0 10px 32px rgba(124, 58, 237, .22);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  animation: scw-rise .22s var(--lk-ease);
}
/* the brand line on top, as on the site's accent cards */
#syphon-chat-widget .scw-card::before { content: ''; position: absolute; left: 22px; right: 22px; top: -1px; height: 2px; border-radius: 2px; background: var(--lk-grad-brand); }
#syphon-chat-widget.scw-collapsed .scw-card { display: none; }
@keyframes scw-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* the community's mark: the header's own lockup, the RagnaRevival logo and its LOKI tag */
#syphon-chat-widget .scw-brand { display: flex; align-items: center; gap: 10px; min-height: 26px; margin: 0 0 10px; padding-right: 44px; }
#syphon-chat-widget .scw-brand img { display: block; height: 24px; width: auto; filter: drop-shadow(0 2px 10px rgba(161, 53, 255, .45)); }
#syphon-chat-widget .scw-brand__tag {
  font-family: var(--lk-font-display); font-weight: 800; font-size: 12px; letter-spacing: .12em; line-height: 19px;
  color: var(--lk-gold-300); padding: 1px 7px 0; border: 1px solid rgba(246, 196, 83, .45);
  border-radius: var(--lk-radius-xs); background: rgba(246, 196, 83, .08);
}
#syphon-chat-widget .scw-title {
  display: flex; align-items: center; gap: 9px; margin: 0;
  font-family: var(--lk-font-display); font-size: 1.3rem; font-weight: 800; line-height: 1.15; color: #fff;
}
#syphon-chat-widget .scw-title i { color: var(--lk-purple-400); font-size: .8em; }
#syphon-chat-widget .scw-tagline { margin: 4px 0 0; color: var(--lk-text-2); font-size: 13.5px; }

/* the numbers, or "Join the community" while there are none */
#syphon-chat-widget .scw-stats { display: flex; align-items: center; min-height: 30px; margin: 10px 0 12px; font-size: 13.5px; }
#syphon-chat-widget .scw-counts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
#syphon-chat-widget .scw-online {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 11px; border-radius: var(--lk-radius-pill);
  background: rgba(255, 255, 255, .04); border: 1px solid var(--lk-line-2);
  color: var(--lk-text-2); font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; white-space: nowrap;
}
#syphon-chat-widget .scw-online__dot { width: 8px; height: 8px; flex-shrink: 0; border-radius: 50%; background: var(--lk-text-3); }
#syphon-chat-widget.scw-someone-online .scw-online { background: rgba(52, 211, 153, .08); border-color: rgba(52, 211, 153, .25); color: #fff; }
#syphon-chat-widget.scw-someone-online .scw-online__dot { background: var(--lk-success); animation: lk-pulse 2.2s infinite; }
#syphon-chat-widget .scw-members, #syphon-chat-widget .scw-nocounts {
  display: inline-flex; align-items: center; gap: 8px; color: var(--lk-text-2); font-variant-numeric: tabular-nums;
}
#syphon-chat-widget .scw-members { white-space: nowrap; }
#syphon-chat-widget .scw-nocounts { font-weight: 600; }
#syphon-chat-widget .scw-members i, #syphon-chat-widget .scw-nocounts i { color: var(--lk-purple-400); font-size: 12px; }
#syphon-chat-widget.scw-has-counts .scw-nocounts,
#syphon-chat-widget:not(.scw-has-counts) .scw-counts,
#syphon-chat-widget:not(.scw-has-counts) .scw-toggle__count { display: none; }

/* the join button is the site's own primary button (.lk-btn .lk-btn--block) */
#syphon-chat-widget .scw-join i { font-size: .8em; opacity: .85; }
#syphon-chat-widget .scw-where { margin: 8px 0 0; text-align: center; color: var(--lk-text-3); font-size: 12.5px; line-height: 1.4; }

/* ---------- the toggle: the card's hide button while open, the round chat button while closed ---------- */
#syphon-chat-widget .scw-toggle {
  position: absolute; z-index: 1; top: 10px; right: 10px;
  display: inline-grid; place-items: center; width: 34px; height: 34px; margin: 0; padding: 0;
  border: 1px solid transparent; border-radius: 10px; background: rgba(255, 255, 255, .05); color: var(--lk-text-2);
  font: inherit; cursor: pointer; -webkit-appearance: none; appearance: none;
  transition: background .15s var(--lk-ease), color .15s var(--lk-ease), transform .15s var(--lk-ease), box-shadow .15s var(--lk-ease);
}
#syphon-chat-widget .scw-toggle:hover { background: rgba(255, 255, 255, .1); color: #fff; }
#syphon-chat-widget .scw-toggle:focus-visible { border-radius: 10px; box-shadow: var(--lk-ring); }
#syphon-chat-widget .scw-toggle__caret { font-size: 13px; }
#syphon-chat-widget .scw-toggle__chat, #syphon-chat-widget .scw-toggle__dot, #syphon-chat-widget .scw-toggle__open { display: none; }

#syphon-chat-widget.scw-collapsed .scw-toggle {
  position: relative; top: auto; right: auto; width: 56px; height: 56px; border-radius: 50%;
  border-color: rgba(255, 255, 255, .14); background: var(--lk-grad-brand); color: #fff;
  box-shadow: 0 10px 30px rgba(124, 58, 237, .45), inset 0 1px 0 rgba(255, 255, 255, .25);
  animation: scw-pop .2s var(--lk-ease);
}
#syphon-chat-widget.scw-collapsed .scw-toggle:hover { background: var(--lk-grad-brand-hover); transform: translateY(-2px); box-shadow: 0 14px 34px rgba(124, 58, 237, .55), inset 0 1px 0 rgba(255, 255, 255, .3); }
#syphon-chat-widget.scw-collapsed .scw-toggle:focus-visible { border-radius: 50%; box-shadow: var(--lk-ring), 0 10px 30px rgba(124, 58, 237, .45); }
#syphon-chat-widget.scw-collapsed .scw-toggle__chat { display: block; font-size: 22px; }
#syphon-chat-widget.scw-collapsed .scw-toggle__open { display: block; }
#syphon-chat-widget.scw-collapsed .scw-toggle__caret, #syphon-chat-widget.scw-collapsed .scw-toggle__hide { display: none; }
/* someone is online: the site's green dot, with its soft pulse */
#syphon-chat-widget.scw-collapsed.scw-someone-online .scw-toggle__dot {
  display: block; position: absolute; top: 1px; right: 1px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--lk-success); border: 2px solid var(--lk-bg); animation: lk-pulse 2.2s infinite;
}
@keyframes scw-pop { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: none; } }

/* ---------- room at the very end of every page ----------
   The one rule here outside the widget itself: the footer's last row (the copyright line, Terms, Privacy, Rules,
   Sitemap) gets room under it, so the closed round button never lies over those links once a visitor has scrolled to
   the end of a page (on phones and tablets they start where the button sits). */
body:has(> #syphon-chat-widget) .lk-footer__bar { padding-bottom: calc(28px + 64px + env(safe-area-inset-bottom)); }

/* ---------- phones, motion, print ---------- */
@media (max-width: 640px) {
  #syphon-chat-widget { left: max(16px, env(safe-area-inset-left)); bottom: calc(16px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  #syphon-chat-widget .scw-card, #syphon-chat-widget .scw-toggle, #syphon-chat-widget .scw-toggle__dot, #syphon-chat-widget .scw-online__dot { animation: none !important; transition: none !important; }
}
@media print { #syphon-chat-widget { display: none !important; } }
