/*
  Floating support widget (public pages only — see templates/partials/_support_widget.html
  and base_public.html). Loaded together with tokens.css/base.css/public.css.
*/

.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;
}

.support-widget {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 1000;
}

@media (min-width: 768px) {
  .support-widget {
    right: max(24px, env(safe-area-inset-right));
    bottom: max(24px, env(safe-area-inset-bottom));
  }
}

/* The 481-768px tablet band used to get a taller bottom offset here to dodge the
   calculator card vertically. That approach broke as soon as card content grew (it
   just traded one overlapping control for another — moving through the card instead
   of clearing it) and depended on exact content height, which is fragile. At 481-768px,
   public.css reserves extra right padding inside .calculator-card so the fixed launcher
   can sit over the card background without covering labels, controls, results, CTA or
   disclaimer — see the "Reserve an internal rail for the fixed support widget" rule
   there. No vertical offset trick needed here as a result; the widget uses its normal
   20/24px corner offset at every width. */

/* Launcher

   Sized close to the artwork's own aspect ratio (~1.48) so object-fit: contain only
   ever letterboxes a sliver — the launcher background below is set to the image's own
   teal (#0badba) so that sliver is invisible rather than showing the dark card color.
   static/images/support/support-robot.png was regenerated with a deliberate
   teal-matched margin around the robot (antenna/ears/mic all comfortably inside the
   oval mask) — the original asset had almost no margin, so this couldn't be fixed with
   CSS alone. */
.support-widget-launcher {
  display: block;
  width: 66px;
  height: 46px;
  padding: 0;
  border-radius: 50%;
  overflow: hidden;
  background: #0badba;
  border: 2px solid var(--border-subtle);
  box-shadow: inset 0 0 0 1.5px var(--accent), 0 6px 16px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  position: relative;
  z-index: 1;
}

.support-widget-launcher img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.support-widget-launcher:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

@media (max-width: 480px) {
  .support-widget-launcher {
    width: 60px;
    height: 44px;
  }
}

/* Hover/focus greeting bubbles — purely visual, position:absolute so they never affect
   document layout, and pointer-events:none so a hidden bubble can never intercept a
   click meant for the page underneath it. */

.support-widget-bubbles {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  max-width: min(200px, calc(100vw - 40px));
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
  z-index: 0;
}

.support-widget-launcher:hover ~ .support-widget-bubbles,
.support-widget-launcher:focus-visible ~ .support-widget-bubbles {
  opacity: 1;
  transform: translateY(0);
}

.support-widget-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 12px;
  line-height: 1.3;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

@media (prefers-reduced-motion: reduce) {
  .support-widget-bubbles {
    transition: none;
  }
}

/* Once the guest panel is open (JS sets data-panel-open on the root), the bubbles are
   just noise — keep them hidden even if the pointer happens to rest over the launcher.
   A descendant selector keyed off the root avoids depending on DOM sibling order. */
.support-widget[data-panel-open="true"] .support-widget-bubbles {
  opacity: 0 !important;
  transform: translateY(6px) !important;
}

/* Guest panel */

.support-widget-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  width: min(340px, calc(100vw - 40px));
  max-height: min(520px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  z-index: 2;
}

.support-widget-panel[hidden] {
  display: none;
}

.support-widget-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.support-widget-panel-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-heading);
}

.support-widget-close {
  background: none;
  border: 0;
  padding: 4px;
  margin: -4px;
  cursor: pointer;
  color: var(--text-secondary);
  display: inline-flex;
}

.support-widget-close:hover {
  color: var(--text-primary);
}

.support-widget-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.support-widget-close .icon {
  width: 18px;
  height: 18px;
}

.support-widget-panel-body {
  padding: 16px;
  overflow-y: auto;
}

.support-widget-intro {
  margin-bottom: 12px;
}

.support-widget-success {
  color: var(--success);
  font-size: 13px;
  margin-bottom: 12px;
}

.support-widget-closed-note {
  margin-bottom: 12px;
}

.support-widget-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
  max-height: 240px;
  overflow-y: auto;
}

/* Message thread — shared visual language with dashboard.css's .support-thread, but
   redefined here since dashboard.css isn't loaded on public pages. Also reused as-is
   by templates/support/guest_thread.html (the standalone secure-link page). */

.support-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.support-message {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-inset);
  font-size: 13px;
}

.support-message-admin {
  border-color: var(--accent);
  background: var(--accent-tint);
}

.support-message-meta {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.support-message-body {
  color: var(--text-primary);
  white-space: pre-line;
}

@media (max-width: 480px) {
  .support-widget-panel {
    max-height: min(70vh, calc(100vh - 100px));
  }
}
