/**
 * UpPay — global floating support chip (Telegram), canonical shared chrome.
 *
 * SHARED CHROME CONTRACT
 * This file is the ONLY source of truth for support chip geometry and visuals.
 * Rules are scoped under #uppay-support-root, so page stylesheets cannot
 * restyle the chip. The single documented page input is
 * --uppay-support-dock-offset, which a page may set on an ancestor to lift the
 * chip above its own fixed bottom dock.
 *
 * Requires css/uppay-design-tokens.css first.
 */

/* ------------------------------------------------------------------ *
 * 1. COMPONENT ISOLATION
 * ------------------------------------------------------------------ */
#uppay-support-root,
#uppay-support-root *,
#uppay-support-root *::before,
#uppay-support-root *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border-width: 0;
  border-style: solid;
  border-color: transparent;
  border-radius: 0;
  outline: 0;
  min-width: 0;
  min-height: 0;
  max-width: none;
  max-height: none;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  font-style: inherit;
  line-height: inherit;
  letter-spacing: inherit;
  text-transform: none;
  text-decoration: none;
  text-align: inherit;
  background: transparent;
  box-shadow: none;
  transform: none;
  transition: none;
  opacity: 1;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

#uppay-support-root a {
  color: inherit;
  cursor: pointer;
}

#uppay-support-root svg {
  display: block;
  flex-shrink: 0;
}

/* ------------------------------------------------------------------ *
 * 2. CANONICAL TOKENS + WRAPPER
 * ------------------------------------------------------------------ */
#uppay-support-root.uppay-support-chip {
  --uppay-support-right: 1rem;
  --uppay-support-bottom: 1rem;
  --uppay-support-gap: 0.42rem;
  --uppay-support-icon-size: 1.65rem;
  --uppay-support-icon-glyph: 0.88rem;
  --uppay-support-label-font: 0.68rem;
  --uppay-support-label-min-h: 1.55rem;
  --uppay-support-label-padding: 0.22rem 0.55rem;

  position: fixed;
  right: var(--uppay-support-right);
  bottom: calc(var(--uppay-support-bottom) + var(--uppay-support-dock-offset, 0px));
  z-index: 40;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--uppay-support-gap);
  padding: 0.2rem;
  color: #e6ebf2;
  font-family: var(--uppay-font);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: normal;
  text-align: center;
  pointer-events: none;
}

#uppay-support-root .uppay-support-chip__icon,
#uppay-support-root .uppay-support-chip__label {
  pointer-events: auto;
}

/* ------------------------------------------------------------------ *
 * 3. ICON
 * ------------------------------------------------------------------ */
#uppay-support-root .uppay-support-chip__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--uppay-support-icon-size);
  height: var(--uppay-support-icon-size);
  min-width: var(--uppay-support-icon-size);
  min-height: var(--uppay-support-icon-size);
  flex: 0 0 auto;
  border-radius: 999px;
  background: #2aabee;
  color: #ffffff;
  box-shadow:
    0 0 0 1px rgba(42, 171, 238, 0.35),
    0 0 10px rgba(42, 171, 238, 0.38),
    0 0 18px rgba(42, 171, 238, 0.16);
  transition: box-shadow 0.2s ease, background 0.2s ease, filter 0.2s ease;
}

#uppay-support-root .uppay-support-chip__icon svg {
  width: var(--uppay-support-icon-glyph);
  height: var(--uppay-support-icon-glyph);
}

/* ------------------------------------------------------------------ *
 * 4. LABEL
 * ------------------------------------------------------------------ */
#uppay-support-root .uppay-support-chip__label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--uppay-support-label-min-h);
  padding: var(--uppay-support-label-padding);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  font-size: var(--uppay-support-label-font);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: #e6ebf2;
  white-space: nowrap;
  transition:
    border-color 0.2s ease,
    background 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease,
    filter 0.2s ease;
}

/* ------------------------------------------------------------------ *
 * 5. HOVER / FOCUS — colour and glow only, never movement
 * ------------------------------------------------------------------ */
#uppay-support-root.uppay-support-chip:hover .uppay-support-chip__icon,
#uppay-support-root.uppay-support-chip:focus-within .uppay-support-chip__icon {
  background: #33b5f5;
  filter: brightness(1.05);
  box-shadow:
    0 0 0 1px rgba(51, 181, 245, 0.5),
    0 0 16px rgba(42, 171, 238, 0.55),
    0 0 28px rgba(42, 171, 238, 0.24);
}

#uppay-support-root.uppay-support-chip:hover .uppay-support-chip__label,
#uppay-support-root.uppay-support-chip:focus-within .uppay-support-chip__label {
  border-color: rgba(42, 171, 238, 0.5);
  background: rgba(42, 171, 238, 0.18);
  color: #ffffff;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 0 14px rgba(42, 171, 238, 0.2);
}

#uppay-support-root .uppay-support-chip__icon:focus-visible,
#uppay-support-root .uppay-support-chip__label:focus-visible {
  outline: 2px solid #5ec8ff;
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ *
 * 6. RESPONSIVE
 * ------------------------------------------------------------------ */
@media (max-width: 639px) {
  #uppay-support-root.uppay-support-chip {
    --uppay-support-right: max(1rem, env(safe-area-inset-right, 0px));
    --uppay-support-bottom: calc(1.75rem + env(safe-area-inset-bottom, 0px));
    --uppay-support-gap: 0.34rem;
    --uppay-support-icon-size: 1.72rem;
    --uppay-support-icon-glyph: 0.9rem;
    --uppay-support-label-font: 0.625rem;
    --uppay-support-label-min-h: 1.5rem;
    --uppay-support-label-padding: 0.2rem 0.52rem;

    max-width: calc(100% - 1.25rem);
    padding: 0;
  }

  #uppay-support-root .uppay-support-chip__label {
    background: rgba(20, 27, 40, 0.68);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
    color: rgba(255, 255, 255, 0.92);
  }
}

@media (min-width: 640px) {
  #uppay-support-root.uppay-support-chip {
    --uppay-support-right: 1.25rem;
    --uppay-support-bottom: 1.25rem;
    --uppay-support-icon-size: 1.75rem;
    --uppay-support-icon-glyph: 0.92rem;
    --uppay-support-label-font: 0.7rem;
    --uppay-support-label-min-h: 1.6rem;
    --uppay-support-label-padding: 0.24rem 0.62rem;
  }
}
