/* 14차: 빠른 후원 바 · 바텀시트 결제 · 완료 하트 (public/paysheet.js). 테마 색은 style.css 변수만 씀 */

/* 빠른 후원 바: PC = 오른쪽 아래 고정 카드 · 폰(≤768px) = 하단 고정 (탭바 위) */
.qbar { position: fixed; right: 20px; bottom: 20px; z-index: 39; width: 236px; display: flex; flex-direction: column; gap: 8px; padding: 12px; background: var(--card); border-radius: var(--radius); box-shadow: 0 0 0 1px var(--line), 0 14px 36px rgba(0, 0, 0, .14); }
.qb-h { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.qb-amts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.qb-a { height: 44px; border: 0; border-radius: 12px; background: var(--soft); color: var(--text); font-weight: 800; font-size: 16px; cursor: pointer; transition: background .15s, transform .15s; }
.qb-a:hover { background: var(--accent-soft); }
.qb-a:active { transform: scale(.96); }
.qb-a[aria-checked="true"] { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.qb-row { display: flex; flex-direction: column; gap: 6px; }
/* 모바일 점검: 누르는 곳 44px 이상 · 입력칸 16px (아이폰 확대 방지) */
.qbar .input { height: 44px; font-size: 16px; }
.qb-send { height: 44px; font-size: 16px; }
@media (max-width: 768px) {
  .qbar { left: 0; right: 0; bottom: 0; width: auto; gap: 6px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); border-radius: 18px 18px 0 0; box-shadow: 0 -1px 0 var(--line), 0 -8px 24px rgba(0, 0, 0, .08); }
  .qb-h { display: none; }
  .qb-amts { grid-template-columns: repeat(4, 1fr); }
  .qb-row { flex-direction: row; }
  .qb-msg { flex: 1; min-width: 0; }
  .qb-send { flex: none; padding: 0 18px; }
  /* 바 높이만큼 페이지 아래 여백 (--qbar-h 는 paysheet.js 가 잼) — 마지막 글·후원자 벽·푸터가 바 뒤에 안 숨게 */
  body:has(.qbar) { padding-bottom: calc(var(--qbar-h, 112px) + env(safe-area-inset-bottom)); }
  body:has(.qbar) .toast { bottom: calc(var(--qbar-h, 112px) + 16px + env(safe-area-inset-bottom)); }
  body.sheet-open .qbar { display: none; }
  /* 키보드가 올라오면 키보드 바로 위 (paysheet.js 가 --kb 계산) */
  .qbar.kb { bottom: var(--kb) !important; padding-bottom: 8px; }
  /* 바텀시트가 열려 있으면 토스트는 위쪽 (시트 내용 안 가리게) */
  body.sheet-open .toast { top: 16px; bottom: auto !important; }
}
@media (max-width: 700px) {
  .qbar { bottom: calc(58px + env(safe-area-inset-bottom)); padding-bottom: 8px; border-radius: 18px 18px 0 0; }
  body:has(.qbar) { padding-bottom: calc(58px + var(--qbar-h, 104px) + env(safe-area-inset-bottom)); }
  body:has(.qbar) .toast { bottom: calc(58px + var(--qbar-h, 104px) + 16px + env(safe-area-inset-bottom)); }
}

/* 결제 바텀시트: 주문 요약 · 수단 5개 아이콘 한 줄 · (첫 결제만) 동의 · 결제하기 */
.sheet.ps-sheet { max-height: 90dvh; overscroll-behavior: contain; transition: transform .22s ease-out; }
.sheet.ps-sheet:focus { outline: none; }
.ps-sheet .x { width: 44px; height: 44px; font-size: 16px; }
.ps-sheet .vp-sheet-h { padding: 8px 8px 8px 16px; touch-action: none; }
.ps-grab { display: none; }
.sheet.ps-drag { transition: none; }
/* 닫힐 때: 시트는 아래로, 배경은 흐려지며 0.22초 (움직임 줄이기면 paysheet.js 가 바로 닫음) */
.sheet-bg.ps-out { opacity: 0; transition: opacity .22s ease-in; }
.sheet-bg.ps-out .ps-sheet { transform: translateY(100%) !important; transition: transform .22s ease-in; }
@media (max-width: 768px) {
  .ps-grab { display: block; height: 18px; touch-action: none; cursor: grab; }
  .ps-grab::before { content: ''; display: block; width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 8px auto 0; }
  .ps-sheet .vp-sheet-h { padding-top: 0; }
}
.ps { display: flex; flex-direction: column; gap: 12px; }
.ps-sum { display: flex; align-items: center; gap: 10px; }
.ps-sum b { font-size: 16px; }
.ps-amt { font-size: 20px !important; white-space: nowrap; }
.ps-msg { color: var(--sub); font-size: 16px; background: var(--soft); border-radius: 12px; padding: 8px 12px; }
.ps-pm { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.ps-m { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 2px; border: 0; border-radius: 12px; background: var(--soft); color: var(--text); font-size: 11px; font-weight: 800; cursor: pointer; min-width: 0; transition: background .15s, transform .15s; }
.ps-m:active { transform: scale(.96); }
.ps-m span:last-child { white-space: nowrap; }
.ps-m .pm-logo { width: 40px; height: 28px; font-size: 12px; }
.ps-m .pm-logo.tpay { width: 46px; font-size: 9px; }
.ps-m[aria-checked="true"] { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.ps-hint { text-align: center; }
.ps-agree { margin: 0; min-height: 44px; align-items: center; font-size: 14px; color: var(--sub); }
.ps-agree input { width: 22px; height: 22px; }
.ps-pay { height: 50px; font-size: 16px; }
.ps-foot { text-align: center; }
.ps-foot a { text-decoration: underline; }
.ps .err:empty { display: none; }

/* 완료 */
.ps-done { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 6px 0 4px; }
.ps-done h2 { font-size: 20px; }
.ps-done .btn { width: 100%; }
.ps-thanks { display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left; background: var(--accent-soft); border-radius: 14px; padding: 12px; }
.ps-thanks p { margin-top: 2px; font-size: 16px; color: var(--text); }
body.sheet-open .toast { z-index: 950; }

/* 하트 1.2초 (prefers-reduced-motion 이면 JS 가 안 만들고, CSS 로도 숨김) */
.ps-hearts { position: fixed; inset: 0; z-index: 960; pointer-events: none; overflow: hidden; }
.ps-hearts i { position: absolute; bottom: -40px; font-style: normal; animation: ps-heart 1.1s ease-out forwards; }
@keyframes ps-heart { 0% { transform: translateY(0) scale(.6); opacity: 0; } 15% { opacity: 1; } 100% { transform: translateY(-75vh) scale(1.15); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .ps-hearts { display: none; } }
