﻿/* Blute - overlay/stage/avatar engine styles (character, bubble, grow, aura). */
/* blute - 미리보기/스테이지/엔진/반응형 (styles.css에서 분리) */
/* ══════════════════ 미리보기 패널 ══════════════════ */
.preview-panel { display: flex; flex-direction: column; overflow: hidden; background: var(--ink); min-width: 0; }
.preview-toolbar {
  display: flex; align-items: center; gap: 10px 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.025), transparent 60%), var(--shell);
  box-shadow: inset 0 -1px 0 rgba(0,0,0,.25);
  flex-shrink: 0; flex-wrap: wrap;
}
.preview-toolbar > .eyebrow { flex-shrink: 0; align-self: center; padding: 4px 10px; border-radius: var(--r-pill); color: var(--sub); background: var(--panel2); border: 1px solid var(--line); font-size: 9.5px; letter-spacing: .16em; }
.test-row { display: flex; gap: 7px; flex: 1; flex-wrap: wrap; }
.test-group {
  display: flex; gap: 0; align-items: stretch;
  background: var(--panel2); border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.test-group:hover { border-color: var(--line-2); }
.test-group:focus-within { border-color: var(--accent); background: var(--shell-2); box-shadow: var(--focus-ring); }
.test-group .tg-ico { display: flex; align-items: center; padding: 0 8px; font-size: 12.5px; background: transparent; color: var(--sub); border-right: 1px solid var(--line); transition: color var(--t-fast) var(--ease); }
.test-group:focus-within .tg-ico { color: var(--accent-2); }
.test-group input { border: none; border-radius: 0; background: transparent; padding: 8px 9px; font-size: 11.5px; box-shadow: none !important; }
.test-group input:focus { background: transparent; }
.test-group input.w-nick { width: 66px; }
.test-group input.w-msg { width: 84px; }
.test-group input.w-num { width: 48px; text-align: center; font-family: var(--mono); }
.test-group .tg-go {
  border: none; border-radius: 0; border-left: 1px solid var(--line);
  background: var(--accent-soft); color: var(--accent-2); font-size: 11.5px; font-weight: 800; letter-spacing: .02em; padding: 0 11px;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), transform .08s var(--ease);
}
.test-group .tg-go:hover, .test-group:focus-within .tg-go { background: var(--grad-iris); color: var(--on-accent); }
.test-group .tg-go:active { transform: scale(.94); }

.test-obs-row { flex-basis: 100%; display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-1); padding: var(--sp-2) var(--sp-3); border-radius: var(--r-sm); background: var(--panel); border: 1px solid var(--line); }
.tobs-label { font-size: var(--fs-1); color: var(--sub); font-weight: 600; }
.tobs-label b { color: var(--text); font-weight: 700; }
.tobs-toggle { min-width: 60px; padding: var(--sp-1) var(--sp-4); border-radius: var(--r-pill); border: 1px solid var(--line-2); background: var(--panel2); color: var(--sub); font-size: var(--fs-1); font-weight: 800; letter-spacing: .12em; cursor: pointer; transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast); }
.tobs-toggle:hover { border-color: var(--line-2); color: var(--text); background: var(--panel3); }
.tobs-toggle.on { background: linear-gradient(160deg, #3fe6ad, var(--good)); border-color: var(--good); color: var(--on-good); box-shadow: 0 0 0 3px rgba(52,217,160,.18), 0 4px 14px -6px var(--good); }
#tobs-hint { color: var(--faint); }

.stage-wrapper {
  flex: 1; position: relative; overflow: hidden;
  background:
    radial-gradient(120% 78% at 50% 120%, rgba(123,108,255,.24), transparent 58%),
    radial-gradient(74% 52% at 50% -10%, rgba(123,108,255,.07), transparent 62%),
    linear-gradient(180deg, #0b0c14 0%, #0d0f18 56%, #08090f 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.03), inset 0 1px 0 rgba(255,255,255,.05);
}
.stage-wrapper::before {
  content: ""; position: absolute; inset: 0; z-index: 5; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 42%, transparent 52%, rgba(0,0,0,.32) 100%);
}
.stage-wrapper::after {
  content: ""; position: absolute; left: 50%; bottom: -2px; width: 240%; height: 48%;
  transform: translateX(-50%) perspective(420px) rotateX(66deg); transform-origin: bottom center;
  z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(90deg, rgba(154,139,255,.22) 1px, transparent 1px),
    linear-gradient(0deg, rgba(154,139,255,.22) 1px, transparent 1px),
    radial-gradient(60% 38% at 50% 100%, rgba(123,108,255,.22), transparent 70%);
  background-size: 48px 48px, 48px 48px, 100% 100%;
  -webkit-mask-image: radial-gradient(86% 100% at 50% 100%, #000 4%, transparent 76%);
  mask-image: radial-gradient(86% 100% at 50% 100%, #000 4%, transparent 76%);
}
.tally {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 6;
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 10px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase;
  color: #dfe3f2;
  background: linear-gradient(180deg, rgba(255,255,255,.07), rgba(8,9,15,.5));
  backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4);
  border: 1px solid rgba(255,255,255,.14); padding: 6px 12px 6px 10px; border-radius: var(--r-pill);
  box-shadow: 0 8px 24px -10px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.12);
  pointer-events: none;
}
.tally-led { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 10px var(--accent-glow), 0 0 0 3px rgba(123,108,255,.16); animation: tally-pulse 2s ease-in-out infinite; }
@keyframes tally-pulse { 0%,100% { opacity: 1; box-shadow: 0 0 10px var(--accent-glow), 0 0 0 3px rgba(123,108,255,.16); } 50% { opacity: .55; box-shadow: 0 0 6px var(--accent-glow), 0 0 0 5px rgba(123,108,255,.06); } }

/* ══════════════════ 오버레이 캐릭터 (엔진 — 출력 유지) ══════════════════ */
#stage { position: absolute; left: 50%; bottom: 0; transform-origin: bottom center; z-index: 1; will-change: transform; }
.avatar { position: absolute; bottom: 14px; width: 162px; height: 210px; transform-origin: bottom center; pointer-events: none; }
.avatar .body { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; gap: var(--name-gap, 2px); }
/* char: 전역·개체별 랜덤 크기 스케일 전용(이미지만). 발끝(50% 100%) 기준이라 어떤 크기든 지면 위. 닉네임은 .char 밖이라 안 커짐. */
.char { display: flex; align-items: flex-end; justify-content: center; transform-origin: 50% 100%; transition: transform .4s cubic-bezier(.34,1.4,.55,1); will-change: transform; }
.img-wrap { width: 157px; display: flex; align-items: flex-end; justify-content: center; }
/* grow-box: 커지기 스케일 전용 래퍼. 발끝 기준 + 끝날 때 천천히 줄어드는 transition. */
.grow-box { width: 100%; display: flex; align-items: flex-end; justify-content: center; transform-origin: 50% 100%; transition: transform .85s cubic-bezier(.33, 0, .2, 1); }
.img-wrap img { max-width: 100%; max-height: 178px; object-fit: contain; display: block; filter: drop-shadow(0 6px 6px rgba(0,0,0,.35)); transform-origin: center bottom; }
.name-tag { position: relative; z-index: 2; font-size: var(--name-size, 12px); font-family: var(--name-font, inherit); font-weight: 700; line-height: 1; color: #fff; background: rgba(0,0,0,.45); padding: 3px 9px; border-radius: 11px; white-space: nowrap; text-shadow: 0 1px 2px rgba(0,0,0,.5); }
#stage.name-above .body, #overlay-stage.name-above .body { flex-direction: column-reverse; }

@keyframes spawn-pop { from { transform: scale(0) translateY(20px); opacity: 0; } to { transform: scale(1) translateY(0); opacity: 1; } }
.avatar.spawn-in .body { animation: spawn-pop .4s cubic-bezier(.34,1.56,.64,1); }
@keyframes leave-fall { to { transform: translateY(30px) scale(.75); opacity: 0; } }
.avatar.leaving .body { animation: leave-fall .55s ease-in forwards; }
@keyframes bounce-jump { 0% { transform: translateY(0) scale(1,1);} 30% { transform: translateY(-16px) scale(1,1.05);} 55% { transform: translateY(0) scale(1.05,.92);} 75% { transform: translateY(-4px);} 100% { transform: translateY(0);} }
.img-wrap.jump img { animation: bounce-jump .5s ease-out; }
@keyframes dono-pulse { 0%,100% { transform: scale(1); filter: drop-shadow(0 0 10px #ffd166) drop-shadow(0 0 4px #fff);} 50% { transform: scale(1.18); filter: drop-shadow(0 0 22px #ff8c42) drop-shadow(0 0 8px #fff);} }
.donation-glow .img-wrap img { animation: dono-pulse .55s ease-in-out infinite; }
@keyframes sub-glow { 0%,100% { filter: drop-shadow(0 0 8px #7dd3fc);} 50% { filter: drop-shadow(0 0 20px #a78bfa);} }
.sub-sparkle .img-wrap img { animation: sub-glow .9s ease-in-out infinite; }

.bubble {
  position: absolute; z-index: 4; top: calc(-1 * var(--bubble-offset, 8px)); left: 50%;
  transform-origin: bottom center; transform: translate(-50%, -100%) scale(.85);
  box-sizing: border-box;
  min-width: calc(var(--bubble-width, 440px) * 0.4); max-width: var(--bubble-width, 440px); min-height: var(--bubble-height, 50px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--bubble-bg, #fff); color: var(--bubble-fg, #222);
  font-size: 21px; font-weight: 600; line-height: 1.35; padding: 10px 16px; border-radius: 16px;
  text-align: center; box-shadow: 0 4px 14px rgba(0,0,0,.25); opacity: 0;
  /* --char-lift(랜덤·전역 크기) + --grow-lift(키우기): 캐릭터가 커진 만큼 말풍선을 위로 올려 항상 머리 위 */
  transform: translate(-50%, calc(-100% - var(--char-lift, 0px) - var(--grow-lift, 0px))) scale(.85);
  transition: opacity .25s ease, transform .25s ease; pointer-events: none;
}
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -7px; transform: translateX(-50%); border-width: 8px 7px 0 7px; border-style: solid; border-color: var(--bubble-bg, #fff) transparent transparent transparent; }
.bubble.show { opacity: 1; transform: translate(-50%, calc(-100% - var(--char-lift, 0px) - var(--grow-lift, 0px))) scale(1); }
#stage.bubble-sharp .bubble, #overlay-stage.bubble-sharp .bubble { border-radius: 3px; }

.effect-layer { position: absolute; z-index: 3; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; }
.confetti-piece { position: absolute; top: 30%; width: 9px; height: 14px; opacity: 1; animation: confetti-fall 1s ease-out forwards; }
@keyframes confetti-fall { to { transform: translate(var(--dx), 140px) rotate(var(--rot)); opacity: 0; } }
.sparkle-piece { position: absolute; color: #fff7ae; font-size: 20px; text-shadow: 0 0 6px #fff, 0 0 10px #a78bfa; opacity: 0; animation: sparkle-pop 1s ease-out forwards; }
@keyframes sparkle-pop { 0% { opacity: 0; transform: scale(.2) translateY(0);} 30% { opacity: 1; transform: scale(1.2) translateY(-6px);} 100% { opacity: 0; transform: scale(.6) translateY(-30px);} }

/* ══════════════════ 오버레이 모드 ══════════════════ */
#overlay-mode { position: fixed; inset: 0; }
#overlay-stage-wrapper { position: absolute; inset: 0; overflow: hidden; }
#overlay-stage { position: absolute; left: 0; bottom: 0; transform-origin: bottom left; pointer-events: none; }
#overlay-badge {
  position: fixed; left: 10px; bottom: 10px; z-index: 9999;
  font-size: 11px; padding: 5px 10px; border-radius: 8px; font-weight: 600;
  background: rgba(8,9,15,.72); color: #fff; font-family: var(--sans);
  border: 1px solid rgba(255,255,255,.12);
  opacity: 0; transition: opacity .3s; pointer-events: none;
}
#overlay-badge.show { opacity: 1; }

/* ══════════════════ 진입 모션 ══════════════════ */
@media (prefers-reduced-motion: no-preference) {
  .app-shell { animation: shell-in .5s cubic-bezier(.22,.61,.36,1) both; }
  @keyframes shell-in { from { opacity: 0; transform: translateY(10px) scale(.995); } to { opacity: 1; transform: none; } }
  .sidebar > * { animation: card-in .45s ease both; }
  .sidebar > *:nth-child(1) { animation-delay: .06s; }
  .sidebar > *:nth-child(2) { animation-delay: .12s; }
  .sidebar > *:nth-child(3) { animation-delay: .18s; }
  .sidebar > *:nth-child(4) { animation-delay: .24s; }
  .sidebar > *:nth-child(5) { animation-delay: .30s; }
  .sidebar > *:nth-child(n+6) { animation-delay: .36s; }   /* Step-2 카드 승격으로 자식이 늘어 4번째+ 도 스태거 (팝 방지) */
  @keyframes card-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}

@media (prefers-reduced-motion: reduce) {
  .tally-led { animation: none; }
  .platform-fields.show { animation: none; }
  * { scroll-behavior: auto; }
}

/* ══════════════════ 반응형 ══════════════════ */
@media (max-width: 1180px) { .ad-rail { display: none; } .middle-row { grid-template-columns: 1fr; } }
@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; grid-template-rows: 60px auto 1fr; }
  .preview-panel { min-height: 320px; }
  .middle-row { padding: 12px; }
}
@media (max-width: 520px) {
  .platform-seg { grid-template-columns: 1fr; }
  .brand-sub { display: none; }
}

/* ── 클릭/집기 상호작용: 클릭 스프링(무료) 또는 집기(Plus) 시 포인터 활성 ── */
/* .avatar 와 #overlay-stage 는 평소 pointer-events:none(클릭 통과)이므로, pokeable 일 때만 되살린다. */
body.pokeable #overlay-stage { pointer-events: auto; }
body.pokeable .avatar { pointer-events: auto; cursor: pointer; }
body.is-plus .avatar { cursor: grab; }
body.pokeable .avatar .bubble { pointer-events: none; }   /* 말풍선은 통과 유지 */
body.is-plus .avatar.grabbed { cursor: grabbing; }
.avatar.grabbed { z-index: 50; }
.avatar.grabbed .body { filter: drop-shadow(0 12px 18px rgba(0,0,0,.55)); transition: filter .12s var(--ease); }

/* ── 착지 스프링(Plus 토글): 이미지가 위아래로 통통(스쿼시·스트레치) ── */
@keyframes land-squash {
  0%   { transform: scale(1.16, 0.74); }
  40%  { transform: scale(0.92, 1.14); }
  70%  { transform: scale(1.04, 0.97); }
  100% { transform: scale(1, 1); }
}
.img-wrap img.land-squash { animation: land-squash .42s var(--ease-out); transform-origin: 50% 100%; }

/* ── 캐릭터 키우기(Plus) ──
   키우기는 grow-box(이미지만)에 인라인 animation을 적용 → 닉네임은 안 커지고(보기 좋게 별도 소폭), 발끝(50% 100%) 기준이라 바닥과 일정.
   원복은 인라인 animation 제거 → grow-box의 transition으로 부드럽게. */
.grow-box.grow-fx { will-change: transform; }
/* 키운 상태: 닉네임은 보기 좋을 정도로만 소폭 + 볼드(폰트가 볼드 지원할 때만) */
.avatar.is-grown .name-tag { transform: scale(1.22); transform-origin: center; transition: transform .35s var(--ease-out); }
body.name-boldable .avatar.is-grown .name-tag { font-weight: 800; }
/* 일정시간 키우기: 캐릭터 뒤에서 위로 타오르는 검붉은 화염 오라. 크기는 --grow-peak(키운 배율)에 맞춰 캐릭터와 매칭. */
.avatar.grow-aura::before {
  content: ""; position: absolute; left: 50%; bottom: 2px; z-index: -1; pointer-events: none;
  width: calc(95% * var(--char-scale, 1) * var(--grow-peak, 1)); height: calc(132% * var(--char-scale, 1) * var(--grow-peak, 1));
  transform: translateX(-50%); transform-origin: 50% 100%;
  background:
    radial-gradient(55% 70% at 50% 100%, rgba(255,150,40,.55), transparent 68%),
    radial-gradient(48% 88% at 50% 100%, rgba(190,28,18,.6), transparent 72%),
    radial-gradient(40% 100% at 50% 100%, rgba(95,2,10,.6), transparent 76%);
  filter: blur(5px);
  -webkit-mask-image: radial-gradient(58% 100% at 50% 100%, #000 24%, transparent 82%);
  mask-image: radial-gradient(58% 100% at 50% 100%, #000 24%, transparent 82%);
  animation: flame-rise 1.05s ease-in-out infinite;
}
@keyframes flame-rise {
  0%,100% { transform: translateX(-50%)   scale(1, 1);     opacity: .72; }
  30%     { transform: translateX(-50.5%) scale(.92, 1.16); opacity: 1; }
  62%     { transform: translateX(-49.5%) scale(1.04, 1.05); opacity: .82; }
}
/* 슈퍼커지기: 금빛이 섞인 더 거센 화염 (잭팟 강조) */
.avatar.is-super.grow-aura::before {
  background:
    radial-gradient(55% 70% at 50% 100%, rgba(255,225,80,.62), transparent 68%),
    radial-gradient(48% 88% at 50% 100%, rgba(255,120,0,.6), transparent 72%),
    radial-gradient(40% 100% at 50% 100%, rgba(150,16,0,.58), transparent 76%);
  animation-duration: .72s;
}
