/* 홈 스페이스 모드 — 코드 진입 애니메이션 + 우주 배경 3D 캐릭터 */

html.wither-space-pending body.wither-space-mode .siteHeader,
html.wither-space-pending body.wither-space-mode .quickTopWrap,
html.wither-space-pending body.wither-space-mode #main,
html.wither-space-pending body.wither-space-mode .footer,
html.wither-space-pending body.wither-space-mode .sound-toggle,
body.wither-space-mode .siteHeader,
body.wither-space-mode .quickTopWrap,
body.wither-space-mode #main,
body.wither-space-mode .footer,
body.wither-space-mode .sound-toggle {
  visibility: hidden !important;
  pointer-events: none !important;
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
}

html.wither-space-pending,
body.wither-space-mode {
  background: #000 !important;
}

body.wither-entry-active {
  overflow: hidden;
}

.wither-entry-ov {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: #000;
  cursor: pointer;
  transition: opacity 0.52s ease;
  font-family: Pretendard, -apple-system, system-ui, sans-serif;
}

.wither-entry-ov--fade {
  opacity: 0;
  pointer-events: none;
}

.wither-entry-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 64px;
}

.wither-entry-tagline {
  font-size: 0.77rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: rgba(137, 191, 255, 0.78);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  text-align: center;
  word-break: keep-all;
  padding: 0 16px;
}

.wither-entry-tagline.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.wither-entry-url {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0;
  margin-top: 14px;
  padding: 10px 22px;
  font-size: clamp(0.82rem, 2.8vw, 1.05rem);
  font-weight: 800;
  letter-spacing: 0.28em;
  text-transform: lowercase;
  font-family: "Segoe UI", "Pretendard", "Avenir Next", system-ui, sans-serif;
  color: #f5e6a8;
  opacity: 0;
  transform: scale(0.86) translateY(16px);
  filter: blur(8px);
  transition:
    opacity 0.45s ease,
    transform 0.55s cubic-bezier(0.2, 1.4, 0.3, 1),
    filter 0.55s ease;
  text-align: center;
  isolation: isolate;
  overflow: hidden;
  border-radius: 999px;
}

.wither-entry-url.is-visible {
  opacity: 1;
  transform: scale(1) translateY(0);
  filter: blur(0);
}

.wither-entry-url.is-animating {
  box-shadow:
    0 0 0 1px rgba(212, 175, 55, 0.35),
    0 0 24px rgba(212, 175, 55, 0.28),
    0 0 48px rgba(255, 200, 80, 0.12),
    inset 0 0 20px rgba(212, 175, 55, 0.08);
  background: linear-gradient(
    105deg,
    rgba(212, 175, 55, 0.06),
    rgba(255, 240, 180, 0.14),
    rgba(212, 175, 55, 0.06)
  );
  animation: witherUrlPulse 1.8s ease-in-out infinite;
}

.wither-entry-url-ch {
  display: inline-block;
  opacity: 0;
  transform: translateY(18px) scale(0.4) rotateX(70deg);
  color: transparent;
  background: linear-gradient(
    120deg,
    #8a6a14 0%,
    #ffe08a 28%,
    #fff8d6 48%,
    #d4af37 68%,
    #8a6a14 100%
  );
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  text-shadow: none;
  filter: drop-shadow(0 0 6px rgba(255, 214, 100, 0.55));
  transition:
    opacity 0.28s ease,
    transform 0.42s cubic-bezier(0.18, 1.45, 0.28, 1);
  will-change: transform, opacity;
}

.wither-entry-url-ch.is-in {
  opacity: 1;
  transform: translateY(0) scale(1) rotateX(0deg);
}

.wither-entry-url.is-shimmer .wither-entry-url-ch {
  animation: witherUrlShimmer 2.2s linear infinite;
}

.wither-entry-url-beam {
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(
    105deg,
    transparent 0%,
    transparent 38%,
    rgba(255, 248, 200, 0.55) 50%,
    transparent 62%,
    transparent 100%
  );
  background-size: 220% 100%;
  mix-blend-mode: screen;
  opacity: 0;
  z-index: 1;
}

.wither-entry-url.is-shimmer .wither-entry-url-beam {
  opacity: 1;
  animation: witherUrlBeam 1.8s ease-in-out infinite;
}

.wither-entry-url-glow {
  position: absolute;
  left: 10%;
  right: 10%;
  bottom: 2px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    transparent,
    #ffe08a,
    #fff8d6,
    #d4af37,
    transparent
  );
  box-shadow:
    0 0 10px rgba(255, 220, 120, 0.9),
    0 0 22px rgba(212, 175, 55, 0.55);
  opacity: 0;
  transform: scaleX(0.2);
  pointer-events: none;
  z-index: 0;
}

.wither-entry-url.is-shimmer .wither-entry-url-glow {
  opacity: 1;
  transform: scaleX(1);
  animation: witherUrlUnderline 1.6s ease-in-out infinite;
  transition: transform 0.5s cubic-bezier(0.2, 1.3, 0.3, 1), opacity 0.4s ease;
}

@keyframes witherUrlPulse {
  0%,
  100% {
    box-shadow:
      0 0 0 1px rgba(212, 175, 55, 0.3),
      0 0 18px rgba(212, 175, 55, 0.22),
      0 0 36px rgba(255, 200, 80, 0.08),
      inset 0 0 16px rgba(212, 175, 55, 0.06);
  }
  50% {
    box-shadow:
      0 0 0 1px rgba(255, 230, 140, 0.55),
      0 0 32px rgba(255, 214, 100, 0.45),
      0 0 64px rgba(255, 200, 80, 0.22),
      inset 0 0 24px rgba(255, 230, 140, 0.12);
  }
}

@keyframes witherUrlShimmer {
  0% {
    background-position: 200% 50%;
  }
  100% {
    background-position: -40% 50%;
  }
}

@keyframes witherUrlBeam {
  0% {
    background-position: 160% 50%;
    opacity: 0.15;
  }
  40% {
    opacity: 0.85;
  }
  100% {
    background-position: -60% 50%;
    opacity: 0.15;
  }
}

@keyframes witherUrlUnderline {
  0%,
  100% {
    opacity: 0.55;
    filter: brightness(1);
  }
  50% {
    opacity: 1;
    filter: brightness(1.45);
  }
}

@media (prefers-reduced-motion: reduce) {
  .wither-entry-url,
  .wither-entry-url-ch,
  .wither-entry-url-beam,
  .wither-entry-url-glow {
    animation: none !important;
    transition: opacity 0.3s ease !important;
  }
  .wither-entry-url.is-visible {
    opacity: 1;
    filter: none;
    transform: none;
  }
  .wither-entry-url-ch {
    opacity: 1;
    transform: none;
    color: #d4af37;
    background: none;
    -webkit-background-clip: unset;
    background-clip: unset;
  }
}

.wither-entry-skip {
  position: absolute;
  right: 20px;
  bottom: 22px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(15, 23, 42, 0.55);
  color: rgba(248, 250, 252, 0.88);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.wither-entry-skip:hover {
  background: rgba(30, 41, 59, 0.75);
  border-color: rgba(212, 175, 55, 0.45);
  color: #f8fafc;
}

#wither-space-root {
  position: fixed;
  inset: 0;
  z-index: 9800;
  overflow: hidden;
  background: #000;
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  color: #f8fafc;
}

#wither-space-root.ws-submenu-active {
  background: #160725;
}

#wither-space-root .ws-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

#wither-space-root .ws-fallback-orb {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  z-index: 1;
  font-size: clamp(72px, 18vw, 140px);
  line-height: 1;
  filter: drop-shadow(0 0 28px rgba(167, 139, 250, 0.65));
  animation: ws-orb-float 2.8s ease-in-out infinite;
  pointer-events: none;
  user-select: none;
}

@keyframes ws-orb-float {
  0%,
  100% {
    transform: translate(-50%, -50%);
  }
  50% {
    transform: translate(-50%, calc(-50% - 14px));
  }
}

#wither-space-root .ws-ui {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: 24px 16px 28px;
  pointer-events: none;
  box-sizing: border-box;
}

#wither-space-root .ws-brand {
  position: absolute;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  font-family: "Playfair Display", serif;
  font-size: clamp(22px, 5vw, 34px);
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #f8fafc;
  text-shadow: 0 0 24px rgba(137, 191, 255, 0.35);
  pointer-events: none;
}

#wither-space-root .ws-model-status {
  position: absolute;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(226, 232, 240, 0.58);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
}

#wither-space-root .ws-model-status.is-loaded {
  color: rgba(103, 214, 200, 0.82);
}

#wither-space-root .ws-model-status.is-error {
  color: rgba(251, 191, 36, 0.9);
}

#wither-space-root .ws-bubble-stack {
  position: absolute;
  top: 50%;
  right: clamp(18px, 5vw, 84px);
  width: min(380px, 31vw);
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  pointer-events: auto;
}

#wither-space-root .ws-speech {
  position: relative;
  align-self: center;
  width: fit-content;
  max-width: 100%;
  min-height: 1.55em;
  padding: 14px 22px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: #0f172a;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.55;
  word-break: keep-all;
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.35);
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

#wither-space-root .ws-speech::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -10px;
  width: 19px;
  height: 19px;
  background: rgba(255, 255, 255, 0.94);
  clip-path: polygon(100% 0, 100% 100%, 0 50%);
  transform: translateY(-50%);
}

#wither-space-root .ws-speech.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

#wither-space-root .ws-speech.is-expanding {
  animation: ws-speech-expand 0.52s cubic-bezier(0.2, 0.9, 0.25, 1.12);
}

@keyframes ws-speech-expand {
  0% {
    transform: translateY(12px) scale(0.78);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

#wither-space-root .ws-menu {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.5s ease 0.15s, transform 0.5s ease 0.15s;
  pointer-events: none;
}

#wither-space-root .ws-menu.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#wither-space-root .ws-menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(15, 23, 42, 0.72);
  color: #f8fafc;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.01em;
  word-break: keep-all;
  text-align: center;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

#wither-space-root .ws-menu-label {
  background: linear-gradient(
    100deg,
    var(--ws-text-a, #c4b5fd) 0%,
    var(--ws-text-b, #f8fafc) 42%,
    var(--ws-text-a, #c4b5fd) 84%
  );
  background-size: 220% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: ws-menu-text-flow 3.6s linear infinite;
}

#wither-space-root .ws-menu-btn--tone-1 {
  --ws-text-a: #a7f3d0;
  --ws-text-b: #fef3c7;
}

#wither-space-root .ws-menu-btn--tone-2 {
  --ws-text-a: #c4b5fd;
  --ws-text-b: #f9a8d4;
}

#wither-space-root .ws-menu-btn--tone-3 {
  --ws-text-a: #93c5fd;
  --ws-text-b: #e0f2fe;
}

#wither-space-root .ws-menu-btn--tone-4 {
  --ws-text-a: #fcd34d;
  --ws-text-b: #fecdd3;
}

#wither-space-root .ws-menu-btn--tone-5 {
  --ws-text-a: #67e8f9;
  --ws-text-b: #ddd6fe;
}

#wither-space-root .ws-menu-btn--tone-6 {
  --ws-text-a: #fde68a;
  --ws-text-b: #fbcfe8;
}

@keyframes ws-menu-text-flow {
  to {
    background-position: -220% 0;
  }
}

#wither-space-root .ws-menu-btn:hover,
#wither-space-root .ws-menu-btn:focus-visible {
  background: rgba(124, 92, 255, 0.42);
  border-color: rgba(212, 175, 55, 0.55);
  outline: none;
  transform: translateY(-1px);
}

#wither-space-root .ws-menu-btn--wide {
  grid-column: 1 / -1;
}

#wither-space-root .ws-menu-btn--back {
  border-color: rgba(196, 181, 253, 0.45);
  background: rgba(49, 18, 76, 0.74);
  color: #ddd6fe;
}

#wither-space-root .ws-hint {
  margin-top: 4px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: rgba(226, 232, 240, 0.55);
  pointer-events: none;
}

@media (max-width: 640px) {
  /* 모바일: 상하 분리 — 캐릭터(위) / UI 패널(아래) */
  #wither-space-root {
    display: flex;
    flex-direction: column;
  }

  /* 캔버스는 상단 56% 차지, position을 relative로 전환 */
  #wither-space-root .ws-canvas {
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    height: 56svh !important;
    flex-shrink: 0;
  }

  /* UI 패널: 나머지 공간 */
  #wither-space-root .ws-ui {
    position: relative !important;
    inset: auto !important;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 14px 16px;
    background: rgba(2, 2, 22, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-sizing: border-box;
    overflow: hidden;
  }

  /* 브랜드명: 패널 상단 */
  #wither-space-root .ws-brand {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    font-size: 18px;
    margin-bottom: 6px;
    flex-shrink: 0;
  }

  /* 모델 상태 텍스트: 패널 내 */
  #wither-space-root .ws-model-status {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    font-size: 10px;
    margin-bottom: 4px;
    flex-shrink: 0;
  }

  /* 버블+메뉴 스택: 패널 중앙 */
  #wither-space-root .ws-bubble-stack {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    bottom: auto !important;
    left: auto !important;
    width: 100%;
    transform: none !important;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  #wither-space-root .ws-speech {
    font-size: 13px;
    padding: 10px 16px;
    flex-shrink: 0;
  }

  /* 말풍선 꼬리: 위쪽(캐릭터 방향)으로 */
  #wither-space-root .ws-speech::before {
    top: -10px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    clip-path: polygon(0 100%, 100% 100%, 50% 0);
  }

  #wither-space-root .ws-menu {
    grid-template-columns: 1fr 1fr;
    flex-shrink: 0;
    overflow-y: auto;
  }

  #wither-space-root .ws-hint {
    flex-shrink: 0;
  }

  .wither-entry-ltr {
    width: 44px !important;
    height: 44px !important;
    font-size: 1.45rem !important;
  }
}
