/* page-plaza.css — 한옥마을 광장 (에이전트 토론) 전용 스타일.
   village-scene 배경/캐릭터 그림은 아직 없을 수 있음 — .no-art 상태에서 그라데이션
   + 이모지로 예쁘게 대체하고, PLAZA_ASSET_PROMPTS.md의 그림이 assets/plaza/에
   생기면 page-plaza.js가 자동으로 진짜 그림으로 갈아끼운다 (코드 수정 불필요). */

.plaza-hero {
  text-align: center;
  padding: 3rem 1rem 1.5rem;
}
.plaza-hero h1 {
  font-family: var(--serif);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  color: var(--text-primary);
  margin: 0 0 0.5rem;
}
.plaza-hero p {
  color: var(--text-secondary);
  max-width: 42rem;
  margin: 0 auto;
}

/* ── 계절 배경 그라데이션 (그림 없을 때 폴백이자, 로딩 중 배경) ───────────── */
.village-scene {
  position: relative;
  max-width: 1000px;
  margin: 0 auto;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  background-size: cover;
  background-position: center;
  transition: background 0.6s ease;
}
.village-scene.season-spring { background: linear-gradient(180deg, #ffd9e8 0%, #bfe8c9 60%, #8fc99a 100%); }
.village-scene.season-summer { background: linear-gradient(180deg, #bfe3ff 0%, #7fd9a0 60%, #4fae6e 100%); }
.village-scene.season-fall   { background: linear-gradient(180deg, #ffd8a8 0%, #e79a4a 60%, #b5622b 100%); }
.village-scene.season-winter { background: linear-gradient(180deg, #e8f2fb 0%, #cfe0ee 60%, #a9bfd4 100%); }

.village-scene__bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.village-scene__bg[hidden] { display: none; }

/* ── 하루 시간대 색보정 (한국 표준시 기준 자동, 실제 아트 나오기 전까지 CSS로
   낮/저녁 분위기만 톤온톤 표현 — 계절 배경 이미지 위에 얹는 오버레이라 새 그림 불필요) ── */
.village-scene::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  transition: background 0.8s ease, opacity 0.8s ease;
}
.village-scene.time-dawn::after {
  background: linear-gradient(180deg, rgba(255, 170, 130, 0.45), rgba(255, 120, 140, 0.25));
  mix-blend-mode: multiply;
  opacity: 1;
}
.village-scene.time-morning::after {
  background: linear-gradient(180deg, rgba(255, 250, 230, 0.35), rgba(255, 255, 255, 0));
  mix-blend-mode: screen;
  opacity: 0.6;
}
.village-scene.time-midday::after {
  background: transparent;
  opacity: 0;
}
.village-scene.time-evening::after {
  background: linear-gradient(180deg, rgba(70, 40, 90, 0.45), rgba(255, 130, 60, 0.25));
  mix-blend-mode: multiply;
  opacity: 1;
}

.village-scene__time-label {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  z-index: 3;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-md);
}

/* ── 서울 실시간 날씨 (api/plaza-weather → Open-Meteo, 키 불필요) ──────────
   ::before는 흐림/비/안개의 은은한 색보정, 실제 낙하 효과는 아래 파티클 레이어 */
.village-scene::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.8s ease, background 0.8s ease;
}
.village-scene.weather-cloudy::before { background: rgba(120, 130, 140, 0.15); opacity: 1; }
.village-scene.weather-fog::before    { background: rgba(220, 225, 230, 0.35); opacity: 1; }
.village-scene.weather-rain::before {
  background: linear-gradient(180deg, rgba(70, 90, 110, 0.25), rgba(40, 50, 70, 0.35));
  opacity: 1;
}

.village-scene__weather {
  position: absolute;
  inset: 0;
  z-index: 4;
  overflow: hidden;
  pointer-events: none;
}

.village-scene__fountain {
  position: absolute;
  left: 50%;
  top: calc(22% + 23px); /* 이전 위치에서 6px 아래로 내림 (총 +23px) */
  transform: translate(-50%, -50%);
  width: 100px;
  height: 100px;
  z-index: 10; /* 배경 레이어(1, 2) 위로 확실히 올림 */
  pointer-events: none;
}
/* 겨울에는 분수가 얼어있으므로 파티클 숨김 */
.village-scene.season-winter .village-scene__fountain {
  display: none;
}

.fountain-drop {
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 3px;
  height: 8px;
  background: rgba(180, 230, 255, 0.8);
  border-radius: 50%;
  box-shadow: 0 0 4px rgba(255, 255, 255, 0.8);
  animation: fountain-spout 1s cubic-bezier(0.25, 0.46, 0.45, 0.94) infinite;
}

@keyframes fountain-spout {
  0% { transform: translateY(0) scale(1); opacity: 1; }
  40% { transform: translateY(-30px) translateX(var(--x-dir)) scale(1.2); opacity: 0.9; }
  100% { transform: translateY(10px) translateX(calc(var(--x-dir) * 1.5)) scale(0.3); opacity: 0; }
}

.weather-drop {
  position: absolute;
  top: -10%;
  width: 2px;
  height: 14px;
  background: linear-gradient(180deg, rgba(190, 220, 255, 0), rgba(190, 220, 255, 0.75));
  animation-name: plaza-rain-fall;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
@keyframes plaza-rain-fall {
  0%   { transform: translateY(0) translateX(0); opacity: 0; }
  10%  { opacity: 1; }
  100% { transform: translateY(650%) translateX(-6%); opacity: 0.4; }
}

.weather-flake {
  position: absolute;
  top: -6%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  animation-name: plaza-snow-fall;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}
@keyframes plaza-snow-fall {
  0%   { transform: translateY(0) translateX(0); opacity: 0; }
  10%  { opacity: 1; }
  50%  { transform: translateY(300%) translateX(3%); }
  100% { transform: translateY(650%) translateX(-3%); opacity: 0.6; }
}

/* 캐릭터 전체 기반 스타일 */
.village-character {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  width: 9%;
  min-width: 50px;
  transform: translateX(-50%);
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.35));
}

/* [AEGIS] Idle Float: NPC만 적용, user-avatar는 제외 */
.village-character:not(.user-avatar) {
  animation: plaza-idle-float 3.2s ease-in-out infinite;
}
.village-character[data-spot="halmoni"] { left: 22%; top: 88%; z-index: 88; animation-delay: 0s; }
.village-character[data-spot="dr-yoon"] { left: 50%; top: 80%; z-index: 80; animation-delay: -1.1s; }
.village-character[data-spot="jun"]     { left: 76%; top: 90%; z-index: 90; animation-delay: -2.3s; }

/* [FORGE] Idle Float — 싸이월드 DNA: 숨쐌듯 살아있는 아이돤 애니메이션 */
@keyframes plaza-idle-float {
  0%, 100% {
    transform: translateX(-50%) translateY(0px);
    filter: drop-shadow(0 8px 12px rgba(0,0,0,0.35));
  }
  30% {
    transform: translateX(-50%) translateY(-4px) rotate(0.5deg);
    filter: drop-shadow(0 12px 18px rgba(0,0,0,0.25));
  }
  60% {
    transform: translateX(-50%) translateY(-2px) rotate(-0.3deg);
    filter: drop-shadow(0 10px 14px rgba(0,0,0,0.28));
  }
}

/* [AEGIS] Ground Shadow: user-avatar 제외 NPC에만 착지감 */
.village-character:not(.user-avatar)::after {
  content: "";
  display: block;
  width: 70%;
  height: 8px;
  background: radial-gradient(ellipse, rgba(0,0,0,0.3) 0%, transparent 70%);
  border-radius: 50%;
  margin-top: -4px;
  animation: plaza-shadow-pulse 3.2s ease-in-out infinite;
}
.village-character[data-spot="halmoni"]::after { animation-delay: 0s; }
.village-character[data-spot="dr-yoon"]::after { animation-delay: -1.1s; }
.village-character[data-spot="jun"]::after     { animation-delay: -2.3s; }

@keyframes plaza-shadow-pulse {
  0%, 100% { transform: scaleX(1);   opacity: 0.8; }
  30%       { transform: scaleX(0.8); opacity: 0.5; } /* 륬때 그림자 작아짐 */
  60%       { transform: scaleX(0.9); opacity: 0.6; }
}

/* [FORGE] User Avatar Styles */
.village-character.user-avatar {
  left: 50%;
  top: 80%;
  bottom: auto;
  z-index: 10;
  transition: top 0.05s linear, left 0.05s linear;
}
/* [AEGIS] Name label counter-scale: JS scaleX(-1)이 걸려도 텍스트는 바로 보이게 */
.village-character.user-avatar .village-character__name {
  display: inline-block;
  /* JS에서 counterScale 처리 */
}
.village-character.user-avatar.is-walking .village-character__fallback:not(.is-sprite) {
  animation: plaza-walk 0.3s infinite alternate;
}
@keyframes plaza-walk {
  from { transform: translateY(0) rotate(-5deg); }
  to { transform: translateY(-4px) rotate(5deg); }
}

.village-character img {
  width: 100%;
  aspect-ratio: 1 / 1.4;
  object-fit: contain;
}
.village-character img[hidden] { display: none; }

.village-character__fallback {
  width: 100%;
  aspect-ratio: 1 / 1.4;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: var(--bg-elevated);
  border: 2px solid var(--card-border);
}
.village-character__fallback[hidden] { display: none; }

/* [AEGIS] Spritesheet Animation (3-frame) */
.village-character__fallback.is-sprite {
  background-size: 300% 100%;
  background-position: 0% 0;
  background-repeat: no-repeat;
  background-color: transparent;
  border: none;
}
/* NPC and User Avatar Walking/Replying */
.village-character.is-walking .village-character__fallback.is-sprite,
.village-character.is-replying .village-character__fallback.is-sprite {
  animation: plaza-sprite-walk 0.6s step-end infinite;
}

@keyframes plaza-sprite-walk {
  0%   { background-position: 0% 0; }
  25%  { background-position: 50% 0; }
  50%  { background-position: 100% 0; }
  75%  { background-position: 50% 0; }
  100% { background-position: 0% 0; }
}

.village-character__name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-inverse);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.village-character.is-replying .village-character__fallback,
.village-character.is-replying img {
  animation: plaza-bounce 0.5s ease;
}
@keyframes plaza-bounce {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-12px) scale(1.05); }
}
/* 말풍선 팝업 시 idle float 잠시 중지 (NPC만 해당) */
.village-character:not(.user-avatar).is-replying {
  animation-play-state: paused;
}

/* [FORGE] Speech Bubble UI */
.speech-bubble {
  position: absolute;
  bottom: 110%; /* 캐릭터 머리 위 */
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--bg-elevated);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 0.6rem 0.9rem;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  width: max-content;
  max-width: 180px;
  text-align: center;
  box-shadow: var(--card-shadow);
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 20;
  pointer-events: none;
  word-break: keep-all;
}
.speech-bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: var(--card-border) transparent transparent transparent;
}
.speech-bubble::before {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-1px);
  border-width: 5px;
  border-style: solid;
  border-color: var(--bg-elevated) transparent transparent transparent;
  z-index: 1;
}
.speech-bubble.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.speech-bubble.user-bubble {
  background: var(--gradient-primary);
  color: #fff;
  border: none;
}
.speech-bubble.user-bubble::after {
  border-color: #6366f1 transparent transparent transparent; /* 임시 그라데이션 베이스 컬러 */
}
.speech-bubble.user-bubble::before {
  display: none;
}

/* ── 한국어 전용 안내 배너 ────────────────────────────────────────────── */
.plaza-language-notice {
  max-width: 40rem;
  margin: 0 auto 1.2rem;
  padding: 0.7rem 1rem;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  background: var(--card-bg);
  color: var(--text-secondary);
  font-size: 0.9rem;
  text-align: center;
}
.plaza-language-notice strong { color: var(--text-primary); }

/* ── 주제 입력 폼 ─────────────────────────────────────────────────────── */
.plaza-topic-form {
  display: flex;
  gap: 0.6rem;
  max-width: 40rem;
  margin: 1.5rem auto;
  padding: 0 1rem;
}
.plaza-topic-form input {
  flex: 1;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 1rem;
}
.plaza-topic-form button {
  padding: 0.8rem 1.4rem;
  border-radius: var(--radius-md);
  border: none;
  background: var(--gradient-primary);
  color: var(--text-inverse);
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.plaza-topic-form button:disabled { opacity: 0.5; cursor: wait; }

.plaza-form-error {
  text-align: center;
  color: #e57c7c;
  font-size: 0.85rem;
  margin: -0.8rem auto 0.6rem;
  max-width: 40rem;
}
.plaza-form-error[hidden] { display: none; }

.plaza-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: -0.8rem;
  margin-bottom: 1.5rem;
}

/* [AEGIS] 구버전 잔재 제거: 말풍선 UI로 전환했으므로 .plaza-reply 더이상 미사용 */
/* .plaza-reply, .plaza-reply__name, .plaza-reply__text 스타일 삭제됨 */

@media (max-width: 640px) {
  .village-character__name { display: none; }
  .plaza-topic-form { flex-direction: column; }
}

/* ── [FORGE] 공사 중 (준비 중) 오버레이 ───────────────────────────────────────── */
.village-scene__construction-overlay {
  position: absolute;
  inset: 0;
  z-index: 999;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-align: center;
}
.construction-content {
  background: rgba(255, 255, 255, 0.1);
  padding: 2.5rem 3.5rem;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 15px 35px rgba(0,0,0,0.4);
  animation: construction-fade-in 0.8s ease-out;
}
.construction-icon {
  font-size: 3.5rem;
  display: block;
  margin-bottom: 0.8rem;
  animation: construction-bounce 2s infinite;
}
.construction-content h2 {
  font-size: 1.8rem;
  margin: 0 0 0.8rem;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
.construction-content p {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}
@keyframes construction-fade-in {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes construction-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* ── 활동 대화창 (js/plaza/activity-dialogue.js) ──────────────────────────
   캐릭터 그림이 아직 없어서 이름표 붙은 사각 박스로 대신한다(placeholder).
   나중에 sprite_forge 아트가 들어오면 .npc-box-emoji 자리를 그림으로 교체하면 됨. */
.activity-overlay {
  position: fixed; inset: 0; z-index: 400;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  gap: 12px; padding: 16px; padding-bottom: 48px;
  background: rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.activity-panel {
  background: var(--bg-elevated); border: 1px solid var(--card-border);
  border-radius: 16px; box-shadow: var(--card-shadow);
  padding: 16px 20px; max-width: 420px; width: 100%;
  cursor: default;
}
.npc-dialogue { display: flex; gap: 14px; align-items: flex-start; }
.npc-box, .companion-box {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  flex-shrink: 0; width: 68px;
}
.companion-box {
  background: var(--body-bg); border: 1px solid var(--card-border); border-radius: 12px;
  padding: 10px 6px; cursor: pointer; font: inherit;
}
.companion-box:hover { border-color: var(--accent-primary); }
.npc-box-emoji {
  width: 52px; height: 52px; display: flex; align-items: center; justify-content: center;
  font-size: 26px; background: var(--body-bg); border: 1px solid var(--card-border);
  border-radius: 10px;
}
.npc-box-label { font-size: 11.5px; color: var(--text-muted); text-align: center; }
.npc-line { flex: 1; min-width: 0; }
.npc-line-ko { font-size: 15.5px; font-weight: 700; color: var(--text-primary); }
.npc-line-en { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.npc-line-nuance { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

.companion-panel { text-align: center; }
.guide-bubble { font-size: 14.5px; color: var(--text-primary); margin-bottom: 14px; }
.companion-choices { display: flex; gap: 14px; justify-content: center; }
.companion-recommend { margin-top: 14px; font-size: 13px; color: var(--text-muted); }

/* ── 활동 대화창 유저 응답줄 (마이크+텍스트) ── */
.response-panel { cursor: default; }
.response-row { display: flex; gap: 8px; align-items: center; }
.response-input {
  flex: 1; min-width: 0; padding: 10px 12px; font-size: 14.5px;
  border: 1px solid var(--card-border); border-radius: 10px;
  background: var(--body-bg); color: var(--text-primary);
}
.mic-btn {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--card-border); background: var(--body-bg);
  font-size: 18px; cursor: pointer;
}
.mic-btn.is-listening { background: var(--accent-primary); animation: mic-pulse 1s infinite; }
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(255,255,255,0); }
}
.response-submit { flex-shrink: 0; }
.response-feedback { margin-top: 10px; font-size: 13.5px; }
.response-feedback.ok { color: var(--accent-primary); }
.response-feedback.miss { color: var(--text-muted); }
