/* VNMini floating contact: frosted vertical pill (Telegram + WeChat).
   Style reference: zumac.ai contact-float (2026-11 redesign). Original implementation. */

.contact-float {
  --cf-blue: #1c93d2;
  --cf-blue-hi: #3bbcf6;
  --cf-green: #07b457;
  --cf-green-hi: #2bd46f;
  --cf-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  position: fixed;
  z-index: 60;
  right: calc(16px + env(safe-area-inset-right, 0px));
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px;
  margin: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 10px 28px -10px rgba(0, 0, 0, 0.28);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.22s var(--cf-ease), visibility 0s linear 0s, transform 0.22s var(--cf-ease);
}
@media (min-width: 701px) {
  .contact-float {
    right: calc(22px + env(safe-area-inset-right, 0px));
    bottom: calc(22px + env(safe-area-inset-bottom, 0px));
    padding: 7px;
    gap: 7px;
  }
}

.contact-float.is-tucked,
body:has(#dialog[open]) .contact-float,
body:has(#dialog[open]) .cf-layer {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.2s var(--cf-ease), transform 0.2s var(--cf-ease), visibility 0s linear 0.2s;
}

.contact-float__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.22s var(--cf-ease), filter 0.22s var(--cf-ease);
}
@media (min-width: 701px) {
  .contact-float__btn { width: 48px; height: 48px; }
}
.contact-float__btn svg {
  width: 22px;
  height: 22px;
  display: block;
}
@media (min-width: 701px) {
  .contact-float__btn svg { width: 24px; height: 24px; }
}
.contact-float__btn--tg {
  background: linear-gradient(180deg, var(--cf-blue-hi), var(--cf-blue));
  box-shadow: 0 4px 12px -4px rgba(28, 147, 210, 0.85);
}
.contact-float__btn--wechat {
  background: linear-gradient(180deg, var(--cf-green-hi), var(--cf-green));
  box-shadow: 0 4px 12px -4px rgba(7, 180, 87, 0.85);
}
.contact-float__btn:hover { transform: scale(1.07); filter: brightness(1.05); }
.contact-float__btn:active { transform: scale(0.96); }
.contact-float__btn:focus-visible {
  outline: 2px solid #0071e3;
  outline-offset: 3px;
}

/* WeChat layer: desktop popover, mobile sheet */
.cf-layer {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  pointer-events: none;
}
.cf-layer[hidden] { display: none; }
.cf-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.36);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  pointer-events: auto;
  animation: cf-fade-in 0.22s var(--cf-ease, ease) both;
}
.cf-sheet {
  position: relative;
  z-index: 1;
  pointer-events: auto;
  width: 100%;
  max-width: 420px;
  max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px));
  overflow: auto;
  margin: 0;
  padding: 10px 24px calc(24px + env(safe-area-inset-bottom, 0px));
  background: #f5f5f7;
  color: #1d1d1f;
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.18);
  animation: cf-sheet-in 0.32s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.cf-handle {
  display: block;
  width: 36px;
  height: 5px;
  margin: 4px auto 16px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.18);
}
.cf-sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 18px;
}
.cf-sheet__title {
  margin: 0;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.2;
}
.cf-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.08);
  color: #1d1d1f;
  cursor: pointer;
}
.cf-close svg { width: 12px; height: 12px; }
.cf-close:hover { background: rgba(0, 0, 0, 0.14); }
.cf-close:focus-visible { outline: 2px solid #0071e3; outline-offset: 2px; }

.cf-qr {
  display: flex;
  justify-content: center;
  margin: 0;
  padding: 12px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.cf-qr img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: min(46dvh, 380px);
  border-radius: 8px;
  -webkit-touch-callout: default;
}
.cf-hint {
  margin: 14px 0 0;
  text-align: center;
  font-size: 14px;
  line-height: 1.45;
  color: #6e6e73;
}

.cf-hint--touch { display: none; margin-top: 4px; margin-bottom: 2px; font-size: 13px; color: #86868b; }
@media (hover: none) and (pointer: coarse) { .cf-hint--touch { display: block; } }

@keyframes cf-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes cf-sheet-in {
  from { opacity: 0.4; transform: translateY(24px); }
  to { opacity: 1; transform: none; }
}
@keyframes cf-pop-in {
  from { opacity: 0; transform: translateY(8px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

/* Desktop: compact popover above the pill, light dim */
@media (min-width: 701px) {
  .cf-layer {
    align-items: unset;
    justify-content: unset;
  }
  .cf-backdrop {
    background: rgba(0, 0, 0, 0.18);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .cf-sheet {
    position: absolute;
    right: calc(22px + env(safe-area-inset-right, 0px));
    bottom: calc(22px + 8px + 126px + env(safe-area-inset-bottom, 0px));
    width: 320px;
    max-width: calc(100vw - 44px);
    padding: 22px 22px 20px;
    border-radius: 22px;
    background: #fff;
    box-shadow:
      0 0 0 1px rgba(0, 0, 0, 0.04),
      0 16px 48px -12px rgba(0, 0, 0, 0.28);
    animation: cf-pop-in 0.28s cubic-bezier(0.16, 1, 0.3, 1) both;
  }
  .cf-handle { display: none; }
  .cf-sheet__title { font-size: 20px; }
  .cf-qr { padding: 10px; border-radius: 16px; background: #f5f5f7; box-shadow: none; }
  .cf-qr img { max-height: min(52dvh, 360px); }
}

@media (prefers-reduced-motion: reduce) {
  .contact-float,
  .contact-float__btn,
  .cf-close {
    transition: none;
  }
  .contact-float.is-tucked,
  body:has(#dialog[open]) .contact-float,
  body:has(#dialog[open]) .cf-layer {
    transform: none;
  }
  .contact-float__btn:hover,
  .contact-float__btn:active { transform: none; }
  .cf-backdrop,
  .cf-sheet { animation: none; }
}

/* Keep footer copyright clear of the pill */
@media (max-width: 700px) {
  footer { padding-bottom: calc(36px + 120px + env(safe-area-inset-bottom, 0px)); }
}
