/* ============================================================
   未来马 · 展示页样式
   三层独立切换：场景背景 / 角色表情 / 滤镜风格
   9:16 竖屏 · H5 手机适配
   ============================================================ */

/* ===== Reset ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, "PingFang SC", "Noto Sans SC", "Helvetica Neue", sans-serif;
  background: #1a1a2e;
  color: #333;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

/* ===== 9:16 Container ===== */
.app {
  width: 100%;
  max-width: calc(100vh * 9 / 16);
  height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 0 40px rgba(0,0,0,0.08);
}

@media (min-width: calc(100vh * 9 / 16 + 40px)) {
  body { padding: 0 20px; }
}

@supports (padding: env(safe-area-inset-top)) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ============================================================
   HEADER
   ============================================================ */
.header {
  flex-shrink: 0;
  padding: 10px 20px 6px;
  text-align: center;
  position: relative;
  z-index: 10;
}

.header-badge {
  display: inline-block;
  padding: 2px 12px;
  background: rgba(196, 144, 96, 0.18);
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  color: #8b6914;
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.header-title {
  font-size: 22px;
  font-weight: 700;
  color: #5a3e2b;
  text-shadow: 0 1px 4px rgba(255, 200, 100, 0.2);
  letter-spacing: 2px;
}

.header-subtitle {
  font-size: 12px;
  color: #8a7a6a;
  margin-top: 1px;
}

/* ============================================================
   SHOWCASE AREA (65% vh)
   ============================================================ */
.showcase {
  flex: 0 0 65vh;
  max-height: 65vh;
  position: relative;
  overflow: hidden;
  transition: filter 0.4s ease;
}

/* ===== Scene Background Layer ===== */
.scene-bg {
  position: absolute;
  inset: 0;
  z-index: 1;
  transition: background 0.5s ease;
}

/* Scene: Garden */
.scene-bg.garden {
  background: linear-gradient(180deg, #a8d8c8 0%, #d4c4a8 50%, #e8d4b8 100%);
}

/* Scene: Indoor */
.scene-bg.indoor {
  background: linear-gradient(180deg, #f5e6d3 0%, #e8d0b8 50%, #d4b896 100%);
}

/* Scene: Starry — CSS generated */
.scene-bg.starry {
  background: linear-gradient(180deg, #0a1628 0%, #14142e 40%, #1a0a2e 100%);
}

/* Stars floating dots */
.scene-bg.starry .star-particle {
  position: absolute;
  width: 3px;
  height: 3px;
  background: #fff;
  border-radius: 50%;
  animation: twinkle var(--dur, 2s) ease-in-out infinite;
  pointer-events: none;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50%      { opacity: 1;   transform: scale(1.3); }
}

/* Moon glow for starry scene */
.scene-bg.starry::before {
  content: '';
  position: absolute;
  top: 10%;
  right: 15%;
  width: 50px;
  height: 50px;
  background: radial-gradient(circle, rgba(255,240,200,0.5) 0%, rgba(255,240,200,0) 70%);
  border-radius: 50%;
  pointer-events: none;
}

/* Scene: Seaside */
.scene-bg.seaside {
  background: linear-gradient(180deg, #87CEEB 0%, #b0d4e8 35%, #f0d8a0 75%, #d4b896 100%);
}

/* Wave lines for seaside */
.scene-bg.seaside::after {
  content: '';
  position: absolute;
  bottom: 15%;
  left: -10%;
  width: 120%;
  height: 30px;
  background: repeating-linear-gradient(
    90deg,
    rgba(255,255,255,0.25) 0px,
    rgba(255,255,255,0.25) 8px,
    transparent 8px,
    transparent 20px
  );
  border-radius: 50%;
  animation: waveMove 3s ease-in-out infinite;
  pointer-events: none;
}

@keyframes waveMove {
  0%, 100% { transform: translateX(0) scaleY(1); }
  50%      { transform: translateX(10px) scaleY(0.85); }
}

/* ===== Character Layer (双图叠层 crossfade + 缩放) ===== */
.character-wrap {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  pointer-events: none;
}

.char-crossfade {
  position: absolute;
  height: 82%;
  max-width: 88%;
  object-fit: contain;
  filter: drop-shadow(0 8px 30px rgba(0,0,0,0.12));
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: center center;
  will-change: opacity, transform;
}

.char-crossfade[data-active="true"] {
  opacity: 1;
  z-index: 2;
  transform: scale(1);
}
.char-crossfade[data-active="false"] {
  opacity: 0;
  z-index: 1;
  transform: scale(0.92);
}

/* 浮动呼吸动画只用于active的图 */
.char-crossfade[data-active="true"] {
  animation: floatIdle 4.5s ease-in-out infinite;
}
.char-crossfade[data-active="false"] {
  animation: none;
}

@keyframes floatIdle {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-8px) scale(1.01); }
}

/* ===== Emotion Indicator ===== */
.emotion-indicator {
  position: absolute;
  top: 7%;
  right: 10%;
  font-size: 28px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.88);
  border-radius: 50%;
  box-shadow: 0 2px 12px rgba(0,0,0,0.10);
  z-index: 5;
  pointer-events: none;
  animation: indicatorFloat 3s ease-in-out infinite;
  transition: transform 0.3s;
}

@keyframes indicatorFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-3px); }
}

/* ============================================================
   STYLE FILTERS — applied to .showcase
   ============================================================ */
.showcase.style-standard {
  filter: none;
}
.showcase.style-warm {
  filter: brightness(1.06) saturate(1.2) hue-rotate(-5deg);
}
.showcase.style-cool {
  filter: brightness(0.96) saturate(0.85) hue-rotate(8deg);
}

/* ============================================================
   CONTROL AREA (remaining ~35%)
   ============================================================ */
.control-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  z-index: 10;
  position: relative;
  background: #fcf9f6;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.05);
  overflow: hidden;
}

/* ===== Tab Headers ===== */
.control-tabs {
  display: flex;
  padding: 14px 16px 0;
  gap: 2px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(0,0,0,0.05);
}

.control-tab {
  flex: 1;
  padding: 10px 8px;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  color: #999;
  background: transparent;
  border: none;
  border-bottom: 2.5px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}
.control-tab.active {
  color: #c49060;
  border-bottom-color: #c49060;
  font-weight: 600;
}
.control-tab:active {
  transform: scale(0.96);
}

/* ===== Tab Content ===== */
.control-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  -webkit-overflow-scrolling: touch;
}
.control-content::-webkit-scrollbar {
  width: 3px;
}
.control-content::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.1);
  border-radius: 3px;
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 14px;
  animation: fadeUp 0.3s ease;
}
.tab-panel.active {
  display: flex;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panel-label {
  font-size: 13px;
  color: #8a7a6a;
  text-align: center;
  margin-bottom: 2px;
}

/* ===== Scene Dots ===== */
.scene-dots {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 6px 0;
}

.scene-dot {
  width: 60px;
  height: 72px;
  border-radius: 14px;
  border: 2px solid transparent;
  background: #f5ede4;
  cursor: pointer;
  transition: all 0.25s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.scene-dot .dot-icon {
  font-size: 26px;
  line-height: 1;
}
.scene-dot span:last-child {
  font-size: 11px;
  color: #8a7a6a;
  font-weight: 500;
}
.scene-dot.active {
  border-color: #c49060;
  background: #f5ede4;
  transform: translateY(-4px);
  box-shadow: 0 4px 14px rgba(196, 144, 96, 0.25);
}
.scene-dot.active span:last-child {
  color: #5a3e2b;
  font-weight: 600;
}
.scene-dot:active {
  transform: scale(0.92);
}

/* ===== Emotion Buttons ===== */
.emotion-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  padding: 4px 0;
}

.emotion-btn {
  padding: 10px 20px;
  border-radius: 20px;
  border: 2px solid #e8e0d8;
  background: #faf7f4;
  color: #666;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.emotion-btn.active {
  background: #c49060;
  border-color: #c49060;
  color: #fff;
  box-shadow: 0 2px 8px rgba(196, 144, 96, 0.3);
}
.emotion-btn:active {
  transform: scale(0.94);
}

/* ===== Style Tags ===== */
.style-tags {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding: 8px 0;
}

.style-tag {
  padding: 12px 28px;
  border-radius: 24px;
  border: 2px solid #e8e0d8;
  background: #faf7f4;
  color: #666;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.style-tag.active {
  background: #c49060;
  border-color: #c49060;
  color: #fff;
  box-shadow: 0 2px 8px rgba(196, 144, 96, 0.3);
}
.style-tag:active {
  transform: scale(0.94);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 374px) {
  .header-title { font-size: 18px; }
  .char-crossfade { height: 78%; }
  .scene-dot { width: 52px; height: 64px; }
  .scene-dot .dot-icon { font-size: 22px; }
  .emotion-btn { padding: 8px 14px; font-size: 13px; }
  .style-tag { padding: 10px 20px; font-size: 13px; }
  .emotion-indicator { width: 36px; height: 36px; font-size: 22px; }
}

@media (min-width: 768px) {
  .app { border-radius: 24px; margin-top: 20px; max-height: calc(100vh - 40px); height: calc(100vh - 40px); }
}
