/* ==========================================================
   components.css — 对话框、选项、按钮、材料卡、线索卡、模态框
   ========================================================== */

/* —— 图标按钮（真实 UI 圆形素材） —— */
.icon-btn {
  width: clamp(38px, 4vw, 60px);
  aspect-ratio: 137 / 143;
  border-radius: 0;
  border: 0;
  background: transparent center / contain no-repeat;
  position: relative;
  padding: 0;
  transition: filter 0.2s var(--ease), transform 0.2s var(--ease);
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.55));
}

.icon-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.14) drop-shadow(0 0 12px rgba(232, 201, 114, 0.5));
}

.icon-btn:active {
  transform: translateY(0) scale(0.96);
}

.icon-clues { background-image: url('../assets/ui-circle-clues.png'); }

/* 调查板图标素材宽高比（167:152）与其它圆形按钮不同，contain 后会矮一截，单独放大对齐 */
.icon-clues { transform: scale(1.08); }
.icon-clues:hover { transform: scale(1.08) translateY(-2px); }
.icon-clues:active { transform: scale(1.02); }
.icon-save { background-image: url('../assets/ui-circle-save.png'); }
.icon-load { background-image: url('../assets/ui-circle-load.png'); }
.icon-settings { background-image: url('../assets/ui-circle-settings.png'); }

.badge-dot {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--c-wine);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--c-gold);
}

/* —— 对话面板（参考图实测坐标放大 1.3 倍） —— */
.dialogue-panel {
  position: absolute;
  left: 4.5%;
  top: 71.6%;
  width: 72%;
  height: 28%;
  background-image: url('../assets/ui-dialogue-wide.png');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  background-position: center;
  border: none;
  padding: 0;
  box-shadow: none;
  z-index: 12;
  overflow: visible;
}

.dialogue-panel::before { display: none; }

/* 角色名：对准素材左上角的深紫色铭牌 */
/* 角色名：对齐素材内深紫色铭牌（实测换算 left 10.08% / width 12.66%） */
.name-tag {
  position: absolute;
  left: 11.09%;
  top: 3.92%;
  width: 13.93%;
  height: 20.39%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  padding: 0;
  font-family: var(--f-serif);
  font-size: clamp(15px, 1.4vw, 26px);
  font-weight: 600;
  color: #F2E3C0;
  letter-spacing: 3px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
  z-index: 2;
}

/* 对话文字：落在羊皮纸正文区 */
.dialogue-panel .dialogue-text {
  position: absolute;
  left: 10.5%;
  top: 30%;
  right: 6%;
  bottom: 8%;
  margin: 0;
  font-size: clamp(14px, 1.5vw, 26px);
  line-height: 1.8;
  color: #3A2820;
  text-shadow: none;
  overflow-y: auto;
}

.dialogue-panel .dialogue-text::-webkit-scrollbar { width: 0; }

/* 逐字光标 */
.dialogue-text.typing::after {
  content: "▌";
  color: #8A5A2A;
  animation: blink 0.8s step-end infinite;
  margin-left: 2px;
}
@keyframes blink { 50% { opacity: 0; } }

/* 继续提示 */
.dialogue-panel .continue-hint {
  position: absolute;
  right: 5%;
  bottom: 8%;
  font-size: clamp(10px, 0.85vw, 14px);
  color: #8A5A2A;
  animation: bounce 1.5s ease-in-out infinite;
}
@keyframes bounce { 0%,100% {transform:translateY(0);opacity:.6} 50% {transform:translateY(3px);opacity:1} }

/* —— 选项按钮（UI-空牌匾 底框，右侧竖排） —— */
.choices {
  position: absolute;
  left: 79%;
  width: 19.5%;
  top: 74.1%;
  bottom: 5.4%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2.2%;
  z-index: 13;
}

/* 2 个选项：居中且靠拢；3 个选项：均匀分布、整体居中 */
.choices.count-3 {
  justify-content: space-between;
  gap: 0;
}

.choice-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  aspect-ratio: 5.53 / 1;
  background: transparent url('../assets/ui-choice-frame.png') center / 100% 100% no-repeat;
  border: none;
  border-radius: 0;
  padding: 0 6%;
  font-size: clamp(14px, 1.2vw, 21px);
  color: #F2E3C0;
  text-align: center;
  transition: filter 0.2s var(--ease), transform 0.2s var(--ease);
  font-family: var(--f-serif);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.85);
  box-shadow: none;
}

.choice-btn:hover:not(:disabled) {
  filter: brightness(1.2) drop-shadow(0 0 8px rgba(232, 201, 114, 0.55));
  transform: translateX(3px);
}

.choice-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.choice-btn .choice-icon { font-size: 1.05em; width: 1.4em; text-align: center; opacity: 0.95; }
.choice-btn .choice-label { flex: none; text-align: center; }
.choice-btn .choice-hint { font-size: 0.72em; color: #E8C972; opacity: 0.85; }

/* —— 线索获得提示 —— */
.clue-toast {
  position: absolute;
  top: 110px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, var(--c-deep-purple), #2a1b4a);
  border: 2px solid var(--c-gold);
  border-radius: 50px;
  padding: 12px 28px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6);
  animation: toast-in 0.4s var(--ease), toast-out 0.4s var(--ease) 2.6s forwards;
  z-index: 100;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, -20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translate(-50%, -20px); }
}

.toast-ico {
  font-size: 22px;
}

.toast-text {
  font-size: 16px;
  color: var(--c-gold-light);
}

/* ==========================================================
   模态框通用
   ========================================================== */
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in 0.3s var(--ease);
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: linear-gradient(180deg, var(--c-parchment) 0%, var(--c-parchment-dark) 100%);
  border: 3px solid var(--c-gold);
  border-radius: 16px;
  padding: 32px;
  color: var(--c-text-dark);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  animation: modal-in 0.4s var(--ease);
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-title {
  font-family: var(--f-serif);
  font-size: 28px;
  font-weight: 700;
  color: var(--c-deep-purple);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--c-gold);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--c-deep-purple);
  color: var(--c-gold-light);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================
   线索调查界面
   ========================================================== */
.clue-board {
  width: min(1200px, 90vw);
}

.clue-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 20px;
}

.clue-card {
  background: linear-gradient(180deg, #f5ece0, #e8d8c8);
  border: 2px solid var(--c-gold-dark);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  min-height: 280px;
}

.clue-card:hover {
  transform: translateY(-4px) rotate(-1deg);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
  border-color: var(--c-gold);
}

.clue-card.locked {
  opacity: 0.35;
  cursor: not-allowed;
  filter: grayscale(0.8);
}

.clue-card .clue-thumb {
  width: 100%;
  height: 140px;
  border-radius: 8px;
  background: var(--c-parchment-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 64px;
  margin-bottom: 12px;
}

.clue-card .clue-name {
  font-family: var(--f-serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--c-deep-purple);
  margin-bottom: 6px;
}

.clue-card .clue-desc {
  font-size: 13px;
  color: var(--c-text-dark);
  line-height: 1.6;
}

.clue-card .clue-status {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 12px;
  color: var(--c-gold-dark);
}

/* 线索详情弹层 */
.clue-detail {
  width: min(800px, 85vw);
}

.clue-detail-visual {
  width: 100%;
  height: 260px;
  border-radius: 10px;
  background: var(--c-parchment-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 100px;
  margin-bottom: 20px;
  border: 2px solid var(--c-gold-dark);
}

.clue-detail-content {
  font-size: 16px;
  line-height: 1.9;
  color: var(--c-text-dark);
}

.clue-detail-content h3 {
  font-family: var(--f-serif);
  font-size: 22px;
  color: var(--c-deep-purple);
  margin-bottom: 10px;
}

.clue-detail-content .clue-meta {
  display: flex;
  gap: 16px;
  margin: 12px 0;
  font-size: 14px;
  color: var(--c-gold-dark);
}

/* 调查结论 */
.investigation-result {
  background: rgba(122, 47, 58, 0.1);
  border-left: 4px solid var(--c-wine);
  border-radius: 8px;
  padding: 16px 20px;
  margin-top: 16px;
  font-size: 15px;
  line-height: 1.8;
}

/* ==========================================================
   开始界面 —— 酒馆正门关门 + 暗角光晕 + 16:9
   ========================================================== */
.title-screen {
  position: absolute;
  inset: 0;
  z-index: 200;
  background-image: url('../assets/tavern-front-closed.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  /* 固定 16:9 */
  aspect-ratio: 16 / 9;
  max-width: 100vw;
  max-height: 100vh;
  margin: auto;
}

/* 暗角光晕：四周暗，中间亮 */
.title-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    /* 四周暗角 vignette */
    radial-gradient(ellipse 70% 70% at 50% 50%,
      transparent 30%,
      rgba(0, 0, 0, 0.3) 60%,
      rgba(0, 0, 0, 0.7) 100%);
  pointer-events: none;
  z-index: 0;
}

/* 左侧文字区域额外的半透明渐变，保证 UI 可读性 */
.title-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    rgba(15, 8, 25, 0.7) 0%,
    rgba(15, 8, 25, 0.4) 25%,
    transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.title-inner {
  text-align: left;
  position: relative;
  z-index: 1;
  margin-left: 4.5%;
  max-width: 44%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* 左上角 logo（真实素材，带月光与灯笼光晕） */
.game-logo {
  display: block;
  width: clamp(240px, 27vw, 520px);
  height: auto;
  margin-bottom: clamp(10px, 2vh, 26px);
  filter: drop-shadow(0 6px 22px rgba(0, 0, 0, 0.65));
  animation: logo-float 6s ease-in-out infinite;
}

@keyframes logo-float {
  0%, 100% { transform: translateY(0); filter: drop-shadow(0 6px 22px rgba(0, 0, 0, 0.65)); }
  50% { transform: translateY(-6px); filter: drop-shadow(0 10px 30px rgba(232, 201, 114, 0.35)); }
}

/* 顶栏左上角 logo（复用首页 ui-logo，缩小且低调） */
.top-logo {
  cursor: pointer;
  height: clamp(64px, 8.6vh, 96px);
  width: auto;
  display: block;
  filter: drop-shadow(0 3px 10px rgba(0, 0, 0, 0.55));
  opacity: 0.95;
  transition: filter 0.2s var(--ease);
}
.top-logo:hover { filter: drop-shadow(0 0 12px rgba(232, 201, 114, 0.4)) brightness(1.05); }

.title-buttons {
  display: flex;
  flex-direction: column;
  gap: clamp(6px, 1.1vh, 14px);
  align-items: flex-start;
}

/* —— 首页按钮（真实素材，保持原始比例） —— */
.title-btn {
  display: block;
  width: clamp(180px, 17.5vw, 330px);
  aspect-ratio: 409 / 116;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent center / contain no-repeat;
  box-shadow: none;
  cursor: pointer;
  transition: filter 0.25s var(--ease), transform 0.25s var(--ease);
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.6));
}

.title-btn.btn-start { background-image: url('../assets/ui-btn-start.png'); }
.title-btn.btn-continue { background-image: url('../assets/ui-btn-continue.png'); }
.title-btn.btn-settings { background-image: url('../assets/ui-btn-settings.png'); }

.title-btn.btn-start:hover { background-image: url('../assets/ui-btn-start-glow.png'); }
.title-btn.btn-continue:hover { background-image: url('../assets/ui-btn-continue-glow.png'); }
.title-btn.btn-settings:hover { background-image: url('../assets/ui-btn-settings-glow.png'); }

.title-btn:hover {
  transform: translateX(6px) scale(1.02);
  filter: drop-shadow(0 0 20px rgba(232, 201, 114, 0.5));
}

.title-btn:active {
  transform: translateX(3px) scale(0.99);
}

/* 保留旧类名兼容（已废弃但不影响） */
.primary-btn, .ghost-btn {
  background-image: none;
}


/* ==========================================================
   成品展示 / 饮酒反馈
   ========================================================== */
.result-panel {
  width: min(700px, 85vw);
  text-align: center;
}

.result-glass {
  width: 140px;
  height: 200px;
  margin: 0 auto 20px;
  position: relative;
}

.result-name {
  font-family: var(--f-serif);
  font-size: 32px;
  font-weight: 700;
  color: var(--c-deep-purple);
  margin-bottom: 8px;
}

.result-flavor {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
}

.result-desc {
  font-size: 16px;
  line-height: 1.8;
  color: var(--c-text-dark);
  margin-bottom: 24px;
}

/* 酒杯发光特效 */
.glass-glow {
  animation: glow 1.5s ease-in-out infinite alternate;
}

@keyframes glow {
  from { filter: drop-shadow(0 0 8px rgba(232, 166, 92, 0.5)); }
  to { filter: drop-shadow(0 0 24px rgba(232, 166, 92, 0.9)); }
}

/* ==========================================================
   开场转场 intro 动画
   ========================================================== */

/* —— Step 2: 门开层（关门图 → 开门图 平滑淡入淡出，不再用中间划线展开） —— */
.intro-door-open-layer {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0;                      /* 初始：关门图完全可见 */
  transition: opacity 1.9s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 5;
  pointer-events: none;
}

.intro-door-open-layer.opening {
  opacity: 1;                      /* 平滑淡入为开门图 */
}

/* —— Step 2: 门缝金色光晕 —— */
.intro-door-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.intro-door-glow .glow-beam {
  position: absolute;
  left: 56%;
  bottom: 12%;
  transform: translateX(-50%) scaleY(0);
  width: 220px;
  height: 70vh;
  background: linear-gradient(
    to bottom,
    rgba(255, 230, 160, 0) 0%,
    rgba(255, 230, 160, 0.15) 20%,
    rgba(255, 220, 140, 0.45) 60%,
    rgba(255, 240, 180, 0.8) 100%
  );
  filter: blur(12px);
  transform-origin: bottom center;
  transition: transform 1.5s cubic-bezier(0.3, 0.1, 0.4, 1);
}

.intro-door-glow .glow-ring {
  position: absolute;
  left: 56%;
  bottom: 12%;
  transform: translate(-50%, 50%) scale(0);
  width: 280px;
  height: 280px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 240, 180, 0.5) 0%,
    rgba(255, 220, 140, 0.15) 50%,
    transparent 75%
  );
  filter: blur(8px);
  transition: transform 1.2s ease-out, opacity 1.2s ease-out;
  opacity: 0;
}

.intro-door-glow.active .glow-beam {
  transform: translateX(-50%) scaleY(1);
}

.intro-door-glow.active .glow-ring {
  transform: translate(-50%, 50%) scale(1);
  opacity: 1;
  animation: pulse-glow 1.2s ease-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { opacity: 0.8; transform: translate(-50%, 50%) scale(1); }
  50% { opacity: 1; transform: translate(-50%, 50%) scale(1.15); }
}

/* —— Step 5: 门口闪光 —— */
.intro-door-flash {
  position: absolute;
  left: 50%;
  top: 30%;
  transform: translate(-50%, -50%);
  width: 1000px;
  height: 1000px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(255, 250, 220, 0.55) 0%,
    rgba(255, 230, 170, 0.18) 30%,
    transparent 60%
  );
  opacity: 0;
  pointer-events: none;
  z-index: 14;
}

.intro-door-flash.active {
  animation: door-flash 1.1s ease-out forwards;
}

@keyframes door-flash {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
  30% { opacity: 0.5; transform: translate(-50%, -50%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.5); }
}

/* —— 角色滑入 + 呼吸动画（实测参考图：头顶 y=26%，水平居中） —— */
.intro-portrait {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  transform-origin: 50% 100%;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.6));
  pointer-events: none;
  z-index: 10;
  object-fit: contain;
}

.intro-portrait::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8%;
  width: 60%;
  height: 14%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0.2) 50%, transparent 80%);
  filter: blur(4px);
  border-radius: 50%;
}

/* 初始：从画面外右侧滑入 */
.elin-slide-in {
  left: 120%;
  transform: translateX(0);
  transition: left 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              transform 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.elin-slide-in-active {
  left: 50%;
  transform: translateX(-50%);
}

/* 呼吸动画 */
.portrait-breath {
  animation: portrait-breath 3.2s ease-in-out infinite;
  left: 50%;
  transform: translateX(-50%);
}
/* 呼吸：以身体下部为支点，头部轻微左右摇晃（横向摆动，不做上下浮动） */
@keyframes portrait-breath {
  0%   { transform: translateX(-50%) rotate(-0.7deg); }
  50%  { transform: translateX(-50%) rotate(0.7deg); }
  100% { transform: translateX(-50%) rotate(-0.7deg); }
}

/* 立绘容器：负责定位 + 摇晃（img 自身不参与动画）
   height/top 由 render.js 按素材内容包围盒换算，保证各角色头顶与底边对齐 */
.portrait-wrap {
  position: absolute;
  aspect-ratio: 3 / 2;
  transform: translateX(-50%);
  transform-origin: 50% 100%;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.6));
  pointer-events: none;
  z-index: 10;
  animation: portrait-breath 9s ease-in-out infinite;
  animation-delay: var(--breath-delay, 0s);
}
.portrait-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* 换表情时的旧图替身：垫在新图下面，交叉淡入结束即移除 */
.portrait-ghost {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.portrait-wrap .portrait-img:not(.portrait-ghost) {
  position: relative;
  z-index: 1;
}

/* 闭眼立绘叠加层：眨眼瞬间硬切（每轮只眨一次） */
.portrait-closed {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  animation: blink-fade 7s linear infinite;
}

@keyframes blink-fade {
  0%, 91%   { opacity: 0; }
  92.2%     { opacity: 1; }
  94.4%     { opacity: 0; }
  100%      { opacity: 0; }
}

/* 对话中的立绘摇晃（与 .portrait-wrap 同一节奏） */
#portrait-layer img.portrait-breath {
  animation: portrait-breath 9s ease-in-out infinite;
}

#portrait-layer img.portrait-fade-in {
  animation: portrait-fade-in 0.5s ease-out;
}

@keyframes portrait-fade-in {
  from { opacity: 0; transform: translateY(12px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
