/* ==========================================================================
   유플렉스(UFLEX) — 텔레그램 고객센터
   · 고객 화면 플로팅 버튼 (templates/_telegram_float.html)
   · 로그인 화면 고객센터 카드 + 텔레그램 버튼 (templates/login.html)
   · 종이비행기 아이콘 (.tg-logo — app.css 의 .icon 은 선, 이건 채움)
   색·간격·그림자는 app.css 의 토큰을 쓴다. 텔레그램 브랜드 파랑(#2AABEE → #229ED9)만 여기서 고정한다.
   라이트/다크: 파랑은 그대로, 라벨·카드·툴팁 배경은 토큰이 바꾼다. 그림자만 다크에서 더 깊게.
   ========================================================================== */
:root {
  --tg-blue-1: #2aabee;
  --tg-blue-2: #229ed9;
  --tg-ink: #ffffff;
  --tg-gradient: linear-gradient(135deg, var(--tg-blue-1) 0%, var(--tg-blue-2) 100%);
  --tg-glow: rgba(34, 158, 217, .55);
  --tg-ring: rgba(42, 171, 238, .22);
  --tg-shadow: 0 10px 26px -8px var(--tg-glow), 0 2px 6px rgba(13, 19, 33, .12);
  --tg-shadow-hover: 0 16px 34px -10px var(--tg-glow), 0 4px 10px rgba(13, 19, 33, .14);
  --tg-float-size: 52px;
  --tg-float-gap: 24px;
}
:root[data-theme="dark"] {
  --tg-glow: rgba(42, 171, 238, .42);
  --tg-shadow: 0 10px 28px -8px var(--tg-glow), 0 2px 8px rgba(0, 0, 0, .5);
  --tg-shadow-hover: 0 18px 38px -10px var(--tg-glow), 0 4px 12px rgba(0, 0, 0, .55);
}
/* theme-init.js 가 못 돌아 data-theme 이 없을 때: 시스템 다크 모드를 따른다 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --tg-glow: rgba(42, 171, 238, .42);
    --tg-shadow: 0 10px 28px -8px var(--tg-glow), 0 2px 8px rgba(0, 0, 0, .5);
    --tg-shadow-hover: 0 18px 38px -10px var(--tg-glow), 0 4px 12px rgba(0, 0, 0, .55);
  }
}

/* ── 종이비행기 아이콘 ─────────────────────────────────────────────────── */
.tg-logo { display: block; width: 20px; height: 20px; flex: none; fill: currentColor; stroke: none; }
.tg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ── 플로팅 버튼 ─────────────────────────────────────────────────────────── */
.tg-float {
  position: fixed;
  right: var(--tg-float-gap);
  bottom: calc(var(--tg-float-gap) + env(safe-area-inset-bottom, 0px));
  z-index: 65;                          /* .bulkbar(60) 위 · .drawer(90) · .modal(100) · .toasts(200) 아래 */
  display: flex; align-items: center; gap: 10px;
  color: var(--tg-ink); text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: bottom .28s var(--ease);
}
.tg-float:focus-visible { outline: none; }

.tg-float__btn {
  position: relative; display: grid; place-items: center;
  width: var(--tg-float-size); height: var(--tg-float-size); border-radius: 50%;
  background: var(--tg-gradient); color: var(--tg-ink);
  box-shadow: var(--tg-shadow), inset 0 1px 0 rgba(255, 255, 255, .28), inset 0 -1px 0 rgba(0, 0, 0, .08);
  transition: transform .2s var(--ease), box-shadow .2s var(--ease);
}
/* 은은한 후광: 화면이 뜬 뒤 두 번만 퍼지고 멈춘다 */
.tg-float__btn::before {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: 50%;
  background: var(--tg-gradient); opacity: 0;
  animation: tg-halo 2.4s var(--ease) .8s 2;
}
@keyframes tg-halo {
  0%   { transform: scale(1); opacity: .45; }
  100% { transform: scale(1.7); opacity: 0; }
}
.tg-float__logo {
  width: 28px; height: 28px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .14));
  transition: transform .2s var(--ease);
}
.tg-float:hover .tg-float__btn,
.tg-float:focus-visible .tg-float__btn {
  transform: translateY(-2px) scale(1.04);
  box-shadow: var(--tg-shadow-hover), inset 0 1px 0 rgba(255, 255, 255, .32);
}
.tg-float:focus-visible .tg-float__btn { box-shadow: var(--tg-shadow-hover), 0 0 0 4px var(--surface), 0 0 0 6px var(--tg-blue-1); }
.tg-float:hover .tg-float__logo { transform: translate(1px, -1px) rotate(-8deg); }
.tg-float:active .tg-float__btn { transform: translateY(0) scale(.96); transition-duration: .08s; }

/* 펼쳐지는 라벨 (버튼 왼쪽) */
.tg-float__label {
  display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 999px;
  background: var(--surface); color: var(--text);
  font-weight: 700; font-size: 13.5px; letter-spacing: -.01em; white-space: nowrap;
  border: 1px solid var(--border); box-shadow: var(--shadow-2);
  opacity: 0; transform: translateX(10px); pointer-events: none;
  transition: opacity .2s var(--ease), transform .24s var(--ease);
}
.tg-float:hover .tg-float__label,
.tg-float:focus-visible .tg-float__label { opacity: 1; transform: none; }

/* 작은 툴팁 (@아이디, 버튼 위) */
.tg-float__tip {
  position: absolute; right: 0; bottom: calc(100% + 10px);
  padding: 4px 9px; border-radius: 7px;
  background: var(--text); color: var(--bg);
  font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: .01em; white-space: nowrap;
  box-shadow: var(--shadow-2);
  opacity: 0; transform: translateY(4px); pointer-events: none;
  transition: opacity .18s var(--ease), transform .2s var(--ease);
}
.tg-float__tip::after {
  content: ""; position: absolute; top: 100%; right: calc(var(--tg-float-size) / 2 - 5px);
  border: 5px solid transparent; border-top-color: var(--text);
}
.tg-float:hover .tg-float__tip,
.tg-float:focus-visible .tg-float__tip { opacity: 1; transform: none; transition-delay: .22s; }

/* 일괄 작업 바(.bulkbar)가 열리면 그 위로 올라간다 · 토스트는 버튼을 가리지 않고 그 위에 쌓인다 */
body:has(.bulkbar.is-open) .tg-float { bottom: calc(var(--tg-float-gap) + 72px + env(safe-area-inset-bottom, 0px)); }
body:has(.tg-float) .toasts { bottom: calc(var(--tg-float-gap) + var(--tg-float-size) + 14px); }

/* ── 로그인 화면 · 고객센터 카드 ───────────────────────────────────────── */
.tg-card {
  position: relative; overflow: hidden; isolation: isolate;
  display: flex; flex-direction: column; gap: 14px; padding: 18px 18px 16px;
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--shadow-1);
}
.tg-card::before {                        /* 오른쪽 위의 파란 기운 */
  content: ""; position: absolute; z-index: -1; top: -80px; right: -70px; width: 210px; height: 210px; border-radius: 50%;
  background: radial-gradient(closest-side, var(--tg-ring), transparent);
  pointer-events: none;
}
.tg-card__head { display: flex; align-items: flex-start; gap: 12px; }
.tg-card__mark {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: var(--tg-gradient); color: var(--tg-ink);
  box-shadow: 0 6px 14px -6px var(--tg-glow), inset 0 1px 0 rgba(255, 255, 255, .28);
}
.tg-card__mark .tg-logo { width: 22px; height: 22px; }
.tg-card__title { font-size: 14.5px; font-weight: 800; letter-spacing: -.02em; color: var(--text); }
.tg-card__text { margin-top: 4px; font-size: 13px; line-height: 1.6; color: var(--text-2); word-break: keep-all; }
.tg-card__foot { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); word-break: keep-all; }
.tg-card__foot .icon { width: 14px; height: 14px; }

/* 텔레그램 버튼: 강조색 주 버튼(로그인)과 구분되는 브랜드 버튼 */
.tg-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; height: 44px; padding: 0 16px; border-radius: 10px;
  background: var(--tg-gradient); color: var(--tg-ink);
  font-weight: 700; font-size: 14.5px; letter-spacing: -.01em; white-space: nowrap; text-decoration: none;
  border: 1px solid rgba(255, 255, 255, .12);
  box-shadow: 0 8px 18px -8px var(--tg-glow), inset 0 1px 0 rgba(255, 255, 255, .24);
  transition: transform .15s var(--ease), box-shadow .15s var(--ease), filter .15s var(--ease);
}
.tg-btn:hover {
  transform: translateY(-1px); filter: saturate(1.08);
  box-shadow: 0 12px 24px -8px var(--tg-glow), inset 0 1px 0 rgba(255, 255, 255, .28);
}
.tg-btn:active { transform: translateY(0); }
.tg-btn:focus-visible { outline: 2px solid var(--tg-blue-1); outline-offset: 3px; }
.tg-btn .tg-logo { width: 20px; height: 20px; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .12)); }
.tg-btn__handle {
  margin-left: 2px; padding: 2px 8px; border-radius: 999px;
  background: rgba(255, 255, 255, .18); font-family: var(--mono); font-size: 12.5px; font-weight: 600; letter-spacing: .01em;
}

/* ── 모바일 ───────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --tg-float-size: 50px; --tg-float-gap: 16px; }
  .tg-float__label { display: none; }     /* 터치 화면에는 hover 가 없다 - 라벨은 접고 버튼만 */
  /* 모바일 일괄 작업 바는 두 줄이 될 수 있다 */
  body:has(.bulkbar.is-open) .tg-float { bottom: calc(var(--tg-float-gap) + 112px + env(safe-area-inset-bottom, 0px)); }
  /* 로그인 카드 아래 여백: 버튼이 테마 버튼·소개 글을 가리지 않게 */
  body:has(.tg-float) .login__side { padding-bottom: 96px; }
}
@media (max-width: 360px) {
  .tg-btn { font-size: 13.5px; gap: 7px; padding: 0 12px; }
  .tg-btn__handle { display: none; }      /* 아이디는 카드 아래 안내와 플로팅 버튼 툴팁에도 있다 */
}

/* ── 움직임 줄이기 ─────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .tg-float__btn::before { animation: none; }
  .tg-float, .tg-float__btn, .tg-float__logo, .tg-float__label, .tg-float__tip, .tg-btn { transition: none; }
  .tg-float:hover .tg-float__btn, .tg-float:focus-visible .tg-float__btn, .tg-float:hover .tg-float__logo, .tg-btn:hover { transform: none; }
}
