/* 森林食堂 v3 UI - 基于 P1/P2/P4 设计稿 1:1 复刻 */
/* 设计稿基准：592px × 1272px */

/* ========== 色彩系统（从设计稿吸取） ========== */
:root {
  /* 主色调 - 米黄暖色系 */
  --forest-v3-cream-bg: #F7F4EF;        /* 浅米黄背景 */
  --forest-v3-cream-light: #FFF9F0;     /* 最浅米黄 */
  --forest-v3-cream: #FFF4DA;           /* 标准米黄 */
  --forest-v3-cream-card: #FFEFD6;      /* 卡片米黄 */

  /* 棕色系 - 木质和文字 */
  --forest-v3-brown-text: #8B6239;      /* 主文字棕色 */
  --forest-v3-brown-dark: #6B4423;      /* 深棕色 */
  --forest-v3-brown-border: #C9A876;    /* 边框棕色 */
  --forest-v3-brown-light: #D4B896;     /* 浅棕装饰 */

  /* 强调色 */
  --forest-v3-orange: #E8A643;          /* 橙色（进度条、高亮）*/
  --forest-v3-orange-dark: #D89533;     /* 深橙色 */
  --forest-v3-green: #9FB89A;           /* 绿色（岗位标签）*/
  --forest-v3-pink: #E8B5B5;            /* 粉色（岗位标签）*/
  --forest-v3-blue: #B5D4E8;            /* 蓝色（岗位标签）*/
  --forest-v3-red-flag: #D35757;        /* 红旗颜色 */

  /* 圆角规范 */
  --forest-v3-radius-sm: 8px;
  --forest-v3-radius-md: 12px;
  --forest-v3-radius-lg: 16px;
  --forest-v3-radius-xl: 20px;
  --forest-v3-radius-pill: 999px;

  /* 阴影 */
  --forest-v3-shadow-sm: 0 2px 4px rgba(107, 68, 35, 0.08);
  --forest-v3-shadow-md: 0 3px 8px rgba(107, 68, 35, 0.12);
  --forest-v3-shadow-lg: 0 4px 12px rgba(107, 68, 35, 0.16);
  --forest-v3-shadow-inset: inset 0 2px 4px rgba(107, 68, 35, 0.06);

  /* 间距系统（基于 8px 网格）*/
  --forest-v3-space-xs: 4px;
  --forest-v3-space-sm: 8px;
  --forest-v3-space-md: 12px;
  --forest-v3-space-lg: 16px;
  --forest-v3-space-xl: 24px;
  --forest-v3-space-2xl: 32px;
}

/* ========== 首页根容器 ========== */
.forest-ui-v3-page {
  min-height: 100vh;
  background: var(--forest-v3-cream-bg);
  overflow-x: hidden;
}

.forest-ui-v3-home {
  width: clamp(320px, 100vw, 600px);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(12px, 3vw, 20px);
  background:
    /* 树叶装饰背景 */
    url('../assets/forest-kitchen/forest-ui-pages-v3-generated.png') center / cover no-repeat;
  background-position: center;
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 3vw, 20px);
}

/* ========== 顶部区域：树屋背景 + 招牌 + 进度 ========== */
.forest-home-header {
  position: relative;
  width: 100%;
  min-height: clamp(180px, 35vh, 240px);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: clamp(8px, 2vw, 16px);
}

/* 返回按钮 */
.forest-ui-back-v3 {
  position: absolute;
  left: var(--forest-v3-space-sm);
  top: var(--forest-v3-space-sm);
  width: clamp(32px, 8vw, 40px);
  height: clamp(32px, 8vw, 40px);
  display: grid;
  place-items: center;
  border: 2px solid var(--forest-v3-brown-border);
  border-radius: var(--forest-v3-radius-md);
  background: var(--forest-v3-cream-light);
  color: var(--forest-v3-brown-text);
  font-size: clamp(16px, 4vw, 20px);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--forest-v3-shadow-sm);
  z-index: 10;
}

.forest-ui-back-v3:hover {
  transform: translateY(-2px);
  box-shadow: var(--forest-v3-shadow-md);
  background: var(--forest-v3-cream);
}

.forest-ui-back-v3:active {
  transform: translateY(0);
}

/* 木质招牌 */
.forest-wooden-sign {
  width: clamp(200px, 50vw, 280px);
  padding: clamp(12px, 3vw, 20px) clamp(16px, 4vw, 28px);
  background: linear-gradient(180deg, #F5E5C8 0%, #E8D4B0 100%);
  border: 3px solid var(--forest-v3-brown-border);
  border-radius: var(--forest-v3-radius-xl);
  box-shadow:
    var(--forest-v3-shadow-md),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  text-align: center;
  position: relative;
}

/* 招牌顶部"耳朵"装饰 */
.forest-wooden-sign::before,
.forest-wooden-sign::after {
  content: '';
  position: absolute;
  top: -8px;
  width: 16px;
  height: 16px;
  background: var(--forest-v3-brown-border);
  border-radius: 50%;
  box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.15);
}

.forest-wooden-sign::before {
  left: 20px;
}

.forest-wooden-sign::after {
  right: 20px;
}

.forest-wooden-sign h1 {
  margin: 0 0 var(--forest-v3-space-xs);
  font-size: clamp(18px, 4.5vw, 24px);
  font-weight: 700;
  color: var(--forest-v3-brown-dark);
  letter-spacing: 0.5px;
}

.forest-partner-selector {
  width: 100%;
  padding: var(--forest-v3-space-xs) var(--forest-v3-space-md);
  background: rgba(255, 255, 255, 0.6);
  border: 1px dashed var(--forest-v3-brown-border);
  border-radius: var(--forest-v3-radius-pill);
  color: var(--forest-v3-brown-text);
  font-size: clamp(12px, 3vw, 14px);
  cursor: pointer;
  transition: all 0.2s ease;
}

.forest-partner-selector:hover {
  background: rgba(255, 255, 255, 0.9);
  border-style: solid;
}

/* 进度轨道：红旗 → 圆点 → 星星圆盘 */
.forest-progress-track {
  position: absolute;
  left: clamp(12px, 3vw, 24px);
  bottom: clamp(8px, 2vw, 16px);
  display: flex;
  align-items: center;
  gap: var(--forest-v3-space-sm);
}

/* 红旗图标 */
.forest-flag-icon {
  width: clamp(20px, 5vw, 28px);
  height: clamp(20px, 5vw, 28px);
  display: block;
  background: var(--forest-v3-red-flag);
  clip-path: polygon(0 0, 85% 0, 85% 65%, 100% 50%, 85% 35%, 85% 100%, 75% 100%, 75% 0);
  box-shadow: 0 2px 4px rgba(211, 87, 87, 0.3);
}

/* 关卡圆点 */
.forest-level-dots {
  display: flex;
  align-items: center;
  gap: var(--forest-v3-space-xs);
}

.forest-level-dot {
  width: clamp(16px, 4vw, 22px);
  height: clamp(16px, 4vw, 22px);
  display: grid;
  place-items: center;
  background: var(--forest-v3-cream-light);
  border: 2px solid var(--forest-v3-brown-border);
  border-radius: 50%;
  color: var(--forest-v3-brown-text);
  font-size: clamp(10px, 2.5vw, 12px);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.forest-level-dot.is-locked {
  opacity: 0.4;
  cursor: not-allowed;
}

.forest-level-dot.is-active {
  background: var(--forest-v3-orange);
  border-color: var(--forest-v3-orange-dark);
  color: white;
  transform: scale(1.15);
  box-shadow: 0 0 0 3px rgba(232, 166, 67, 0.3);
}

/* 虚线连接 */
.forest-level-dot:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 100%;
  top: 50%;
  width: var(--forest-v3-space-xs);
  height: 2px;
  background: repeating-linear-gradient(
    90deg,
    var(--forest-v3-brown-border) 0,
    var(--forest-v3-brown-border) 3px,
    transparent 3px,
    transparent 6px
  );
  transform: translateY(-50%);
}

/* 星星圆盘（最佳成绩）*/
.forest-star-badge {
  width: clamp(40px, 10vw, 56px);
  height: clamp(40px, 10vw, 56px);
  display: grid;
  place-items: center;
  background: var(--forest-v3-cream);
  border: 3px solid var(--forest-v3-brown-border);
  border-radius: 50%;
  box-shadow: var(--forest-v3-shadow-sm);
  padding: var(--forest-v3-space-xs);
}

.forest-star-badge-inner {
  display: flex;
  gap: 2px;
  font-size: clamp(8px, 2vw, 10px);
}

.forest-star-icon {
  width: 1em;
  height: 1em;
  display: inline-block;
}

.forest-star-icon.filled {
  color: #F5C842;
  filter: drop-shadow(0 1px 2px rgba(245, 200, 66, 0.5));
}

.forest-star-icon.empty {
  color: var(--forest-v3-brown-border);
  opacity: 0.5;
}

/* ========== 4 格圆形占位框 ========== */
.forest-circle-slots {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(8px, 2vw, 12px);
  padding: var(--forest-v3-space-md) 0;
}

.forest-slot {
  aspect-ratio: 1;
  background: var(--forest-v3-cream-light);
  border: 2px dashed var(--forest-v3-brown-border);
  border-radius: 50%;
  display: grid;
  place-items: center;
  position: relative;
  transition: all 0.2s ease;
}

.forest-slot:hover {
  background: var(--forest-v3-cream);
  border-style: solid;
}

/* 第4格的刷新按钮 */
.forest-refresh-btn {
  width: clamp(24px, 6vw, 32px);
  height: clamp(24px, 6vw, 32px);
  border: none;
  background: var(--forest-v3-cream-card);
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--forest-v3-shadow-sm);
  transition: all 0.2s ease;
}

.forest-refresh-btn::before {
  content: '↻';
  font-size: clamp(14px, 3.5vw, 18px);
  color: var(--forest-v3-brown-text);
  font-weight: 600;
}

.forest-refresh-btn:hover {
  transform: rotate(90deg) scale(1.1);
  box-shadow: var(--forest-v3-shadow-md);
}

/* ========== 12 格角色选择网格 ========== */
.forest-portrait-grid-v3 {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: clamp(6px, 1.5vw, 10px);
  padding: var(--forest-v3-space-md);
  background: var(--forest-v3-cream-card);
  border: 2px solid var(--forest-v3-brown-border);
  border-radius: var(--forest-v3-radius-lg);
  box-shadow: var(--forest-v3-shadow-sm);
}

.forest-portrait-btn-v3 {
  aspect-ratio: 1;
  padding: var(--forest-v3-space-xs);
  background: var(--forest-v3-cream-light);
  border: 2px solid var(--forest-v3-brown-border);
  border-radius: var(--forest-v3-radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: visible;
}

.forest-portrait-btn-v3:hover {
  transform: translateY(-3px);
  box-shadow: var(--forest-v3-shadow-md);
  background: var(--forest-v3-cream);
}

.forest-portrait-btn-v3.is-active {
  background: var(--forest-v3-cream);
  border-color: var(--forest-v3-orange);
  border-width: 3px;
  box-shadow:
    0 0 0 3px rgba(232, 166, 67, 0.3),
    var(--forest-v3-shadow-md);
}

.forest-portrait-btn-v3.is-active::after {
  content: '✓';
  position: absolute;
  top: -6px;
  right: -6px;
  width: clamp(16px, 4vw, 20px);
  height: clamp(16px, 4vw, 20px);
  background: var(--forest-v3-orange);
  color: white;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: clamp(10px, 2.5vw, 12px);
  font-weight: 700;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* 角色头像容器（继续使用现有的 sprite 系统）*/
.forest-portrait-art-v3 {
  width: 100%;
  aspect-ratio: 1;
  background-size: 400% 100%;
  background-repeat: no-repeat;
  background-position: center;
}

/* 复用现有的角色立绘 sprite 类 */
.forest-portrait-art-v3.forest-character-art {
  background-size: 400% 100%;
}

.forest-portrait-art-v3.forest-character-paper-sheet-a,
.forest-portrait-art-v3.forest-character-paper-sheet-b,
.forest-portrait-art-v3.forest-character-paper-sheet-c {
  background-image: url('../assets/forest-kitchen/forest-characters-v3-transparent.png');
  background-size: 400% 300%;
}

.forest-portrait-art-v3.forest-character-paper-sheet-a { background-position-y: 0; }
.forest-portrait-art-v3.forest-character-paper-sheet-b { background-position-y: 50%; }
.forest-portrait-art-v3.forest-character-paper-sheet-c { background-position-y: 100%; }

.forest-portrait-art-v3.forest-character-slot-0 { background-position: 0 center; }
.forest-portrait-art-v3.forest-character-slot-1 { background-position: 33.333% center; }
.forest-portrait-art-v3.forest-character-slot-2 { background-position: 66.667% center; }
.forest-portrait-art-v3.forest-character-slot-3 { background-position: 100% center; }

/* 角色名称标签 */
.forest-portrait-label-v3 {
  margin-top: var(--forest-v3-space-xs);
  font-size: clamp(9px, 2.2vw, 11px);
  color: var(--forest-v3-brown-text);
  text-align: center;
  font-weight: 500;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ========== 3 张场景卡片（岗位选择）========== */
.forest-station-cards-v3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(8px, 2vw, 12px);
}

.forest-station-card-v3 {
  background: var(--forest-v3-cream-light);
  border: 2px solid var(--forest-v3-brown-border);
  border-radius: var(--forest-v3-radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
}

.forest-station-card-v3:hover {
  transform: translateY(-3px);
  box-shadow: var(--forest-v3-shadow-md);
}

.forest-station-card-v3.is-active {
  border-color: var(--forest-v3-orange);
  border-width: 3px;
  box-shadow:
    0 0 0 3px rgba(232, 166, 67, 0.3),
    var(--forest-v3-shadow-lg);
}

/* 顶部彩色标签 */
.forest-station-tag {
  height: clamp(16px, 4vw, 24px);
  display: grid;
  place-items: center;
  font-size: clamp(10px, 2.5vw, 12px);
  font-weight: 600;
  color: var(--forest-v3-brown-dark);
  letter-spacing: 0.5px;
}

.forest-station-tag.prep {
  background: linear-gradient(180deg, #E8BFD4 0%, #D5A5C0 100%);
}

.forest-station-tag.front {
  background: linear-gradient(180deg, #F5E5A8 0%, #E8D48B 100%);
}

.forest-station-tag.kitchen {
  background: linear-gradient(180deg, #B5D4E8 0%, #9BBCD4 100%);
}

/* 场景插画区 */
.forest-station-illustration {
  flex: 1;
  min-height: clamp(80px, 20vw, 120px);
  background-size: cover;
  background-position: center;
  position: relative;
}

/* 底部文本说明 */
.forest-station-desc {
  padding: var(--forest-v3-space-sm);
  background: var(--forest-v3-cream);
  border-top: 1px dashed var(--forest-v3-brown-border);
  min-height: clamp(36px, 9vw, 48px);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.forest-station-desc strong {
  font-size: clamp(11px, 2.8vw, 13px);
  color: var(--forest-v3-brown-dark);
  font-weight: 600;
}

.forest-station-desc small {
  font-size: clamp(9px, 2.2vw, 10px);
  color: var(--forest-v3-brown-text);
  line-height: 1.3;
  opacity: 0.85;
}

/* ========== 底部大按钮 ========== */
.forest-start-btn-v3 {
  width: 100%;
  height: clamp(48px, 12vw, 64px);
  background: linear-gradient(180deg, #F5E5C8 0%, #E8D4B0 50%, #D4BC96 100%);
  border: 3px solid var(--forest-v3-brown-border);
  border-radius: var(--forest-v3-radius-pill);
  box-shadow: var(--forest-v3-shadow-md);
  color: var(--forest-v3-brown-dark);
  font-size: clamp(14px, 3.5vw, 18px);
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: visible;
  margin-top: var(--forest-v3-space-md);
}

.forest-start-btn-v3:hover {
  transform: translateY(-3px);
  box-shadow: var(--forest-v3-shadow-lg);
  background: linear-gradient(180deg, #F8E8CB 0%, #EBD7B3 50%, #D7BF99 100%);
}

.forest-start-btn-v3:active {
  transform: translateY(0);
}

.forest-start-btn-v3:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* 按钮装饰（蘑菇 + 小草）*/
.forest-btn-decoration {
  position: absolute;
  right: clamp(12px, 3vw, 20px);
  bottom: -8px;
  display: flex;
  gap: var(--forest-v3-space-xs);
  pointer-events: none;
}

.forest-btn-decoration .mushroom {
  width: clamp(16px, 4vw, 20px);
  height: clamp(16px, 4vw, 20px);
  background: radial-gradient(circle at 30% 30%, #E87A7A, #D35757);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  position: relative;
}

.forest-btn-decoration .mushroom::before {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 40%;
  height: 8px;
  background: #F5E5C8;
  border-radius: 2px;
}

.forest-btn-decoration .mushroom::after {
  content: '';
  position: absolute;
  top: 30%;
  left: 25%;
  width: 4px;
  height: 4px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
}

.forest-btn-decoration .grass {
  width: 3px;
  height: clamp(12px, 3vw, 16px);
  background: linear-gradient(180deg, #9FB89A 0%, #7A9675 100%);
  border-radius: 1px 1px 0 0;
  transform: rotate(-8deg);
}

/* ========== 联系人选择浮层 ========== */
.forest-ui-contact-layer {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: var(--forest-v3-space-lg);
}

.forest-ui-contact-layer.is-open {
  display: flex;
}

.forest-ui-contact-backdrop {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  cursor: pointer;
}

.forest-ui-contact-sheet {
  position: relative;
  width: clamp(300px, 85vw, 500px);
  max-height: 60vh;
  background: var(--forest-v3-cream-light);
  border: 3px solid var(--forest-v3-brown-border);
  border-radius: var(--forest-v3-radius-xl) var(--forest-v3-radius-xl) 0 0;
  box-shadow: var(--forest-v3-shadow-lg);
  padding: var(--forest-v3-space-lg);
  overflow-y: auto;
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.forest-ui-contact-sheet h3 {
  margin: 0 0 var(--forest-v3-space-md);
  font-size: clamp(16px, 4vw, 20px);
  color: var(--forest-v3-brown-dark);
  text-align: center;
}

.forest-partner-row {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--forest-v3-space-md);
  padding: var(--forest-v3-space-md);
  background: var(--forest-v3-cream);
  border: 2px solid var(--forest-v3-brown-border);
  border-radius: var(--forest-v3-radius-md);
  margin-bottom: var(--forest-v3-space-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.forest-partner-row:hover {
  transform: translateX(4px);
  box-shadow: var(--forest-v3-shadow-sm);
}

.forest-partner-row.is-active {
  background: var(--forest-v3-cream-card);
  border-color: var(--forest-v3-orange);
  box-shadow: 0 0 0 3px rgba(232, 166, 67, 0.3);
}

.forest-partner-avatar {
  width: clamp(40px, 10vw, 48px);
  height: clamp(40px, 10vw, 48px);
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--forest-v3-brown-border);
}

.forest-partner-row span {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.forest-partner-row strong {
  font-size: clamp(13px, 3.2vw, 15px);
  color: var(--forest-v3-brown-dark);
}

.forest-partner-row small {
  font-size: clamp(11px, 2.7vw, 12px);
  color: var(--forest-v3-brown-text);
  opacity: 0.8;
}

/* ========== 响应式适配 ========== */
@media (max-width: 380px) {
  .forest-portrait-grid-v3 {
    grid-template-columns: repeat(4, 1fr);
  }

  .forest-station-cards-v3 {
    grid-template-columns: 1fr;
  }

  .forest-circle-slots {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 600px) {
  .forest-ui-v3-home {
    padding: var(--forest-v3-space-2xl);
  }
}

/* ========== 无障碍和动画性能 ========== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 焦点可见性 */
button:focus-visible,
.forest-portrait-btn-v3:focus-visible,
.forest-station-card-v3:focus-visible {
  outline: 3px solid var(--forest-v3-orange);
  outline-offset: 2px;
}
