/* =============================================
   神农尝百草 · 本草图鉴
   国风水墨主题样式
   ============================================= */

/* ---------- CSS Variables ---------- */
:root {
  /* ===== 还神·水墨丹青 品牌色板（百草设计） ===== */

  /* 水墨基底层 */
  --ink-paper:       #F5F0E8;  /* 宣纸白 — 页面底色 */
  --ink-paper-card:  #EDE8DD;  /* 宣纸深 — 卡片/模块背景 */
  --ink-black:       #2C2C2C;  /* 浓墨黑 — 标题/主文字 */
  --ink-gray:        #8B8B8B;  /* 淡墨灰 — 正文/二级信息 */
  --ink-gray-light:  #B8B2A8;  /* 淡墨浅 — 占位符/禁用 */
  --ink-light:       #D4C5A9;  /* 麻纸色 — 装饰背景/分隔区 */

  /* 草木生机层 */
  --herb-green:      #5B8C5A;  /* 草木绿 — 正向反馈/生机 */
  --herb-green-light:#7BAE7E;  /* 嫩草色 — 按钮悬停/激活态 */
  --herb-green-dark: #3D6A3D;  /* 深草绿 — 按压状态 */
  --herb-dry:        #C4A77D;  /* 秋草黄 — 辅助装饰/季节色 */

  /* 点睛色 */
  --cinnabar:        #C23B22;  /* 朱砂红 — 重要提示/等级标识 */
  --cinnabar-light:  #D4604A;  /* 朱砂浅 — 悬停态 */
  --gold-leaf:       #D4A74A;  /* 金箔色 — 成就/徽章/高光 */
  --gold-leaf-light: #E4C87A;  /* 金箔浅 — 勋章底色 */

  /* 功能色 */
  --text-primary:    var(--ink-black);
  --text-secondary:  var(--ink-gray);
  --text-on-dark:    #F0EAE0;  /* 深色底上的文字 */
  --text-link:       var(--herb-green);
  --bg-primary:      var(--ink-paper);
  --bg-card:         var(--ink-paper-card);
  --bg-overlay:      rgba(44,44,44,0.6);
  --shadow:          rgba(44,44,44,0.08);
  --shadow-heavy:    rgba(44,44,44,0.18);
  --border:          var(--ink-light);
  --border-light:    #E5DCCB;

  /* 尺寸 */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --header-height: 56px;
  --nav-height: 64px;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Noto Sans SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg-primary);
  color: #2C2C2C;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Ink Wash Background ---------- */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(107, 142, 78, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(201, 169, 110, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(192, 57, 43, 0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4 {
  font-weight: 700;
  line-height: 1.3;
}

.text-cinnabar { color: var(--cinnabar); }
.text-herb { color: var(--herb-green); }
.text-gold { color: var(--gold-leaf); }

/* ---------- Layout ---------- */
.app-container {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  z-index: 1;
  padding-top: var(--header-height);
  padding-bottom: var(--nav-height);
}

.page {
  display: none;
  padding: 16px;
  animation: fadeIn 0.3s ease;
}

.page.active {
  display: block;
}

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

/* ---------- Header ---------- */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  max-width: 480px;
  margin: 0 auto;
  height: var(--header-height);
  background: linear-gradient(180deg, var(--ink-paper) 0%, rgba(245, 240, 232, 0.95) 100%);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
}

.app-header h1 {
  font-size: 1.2rem;
  letter-spacing: 4px;
  background: linear-gradient(135deg, var(--ink-black), var(--ink-brown));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.app-header .subtitle {
  font-size: 0.7rem;
  color: #B8B2A8;
  letter-spacing: 2px;
  margin-left: 8px;
  -webkit-text-fill-color: #B8B2A8;
}

/* ---------- Bottom Navigation ---------- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  max-width: 480px;
  margin: 0 auto;
  height: var(--nav-height);
  background: linear-gradient(0deg, var(--ink-paper) 0%, rgba(245, 240, 232, 0.95) 100%);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 6px 8px;
  border: none;
  background: none;
  color: #B8B2A8;
  font-size: 0.6rem;
  cursor: pointer;
  transition: color 0.2s;
  -webkit-tap-highlight-color: transparent;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.nav-item .nav-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.nav-item.active {
  color: var(--cinnabar);
}

.nav-item.active .nav-icon {
  text-shadow: 0 0 8px rgba(192, 57, 43, 0.3);
}

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: 0 2px 8px var(--shadow);
  margin-bottom: 12px;
  border: 1px solid var(--border);
}

.card-title {
  font-size: 1rem;
  color: #2C2C2C;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  letter-spacing: 1px;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: linear-gradient(135deg, var(--cinnabar), var(--cinnabar-dark));
  color: white;
  box-shadow: 0 2px 8px rgba(192, 57, 43, 0.3);
}

.btn-primary:hover {
  box-shadow: 0 4px 12px rgba(192, 57, 43, 0.4);
}

.btn-secondary {
  background: var(--bg-card);
  color: #2C2C2C;
  border: 1px solid var(--border);
}

.btn-herb {
  background: linear-gradient(135deg, var(--herb-green), var(--herb-green-dark));
  color: white;
  box-shadow: 0 2px 8px rgba(107, 142, 78, 0.3);
}

.btn-gold {
  background: linear-gradient(135deg, var(--gold-leaf), var(--gold-leaf));
  color: white;
  box-shadow: 0 2px 8px rgba(201, 169, 110, 0.3);
}

.btn-block {
  display: flex;
  width: 100%;
}

/* ---------- Ink Wash Decorative Elements ---------- */
.ink-divider {
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--ink-light), var(--ink-dark), var(--ink-light), transparent);
  margin: 16px 0;
  opacity: 0.3;
}

.ink-seal {
  display: inline-block;
  padding: 2px 8px;
  border: 2px solid var(--cinnabar);
  color: var(--cinnabar);
  font-size: 0.75rem;
  border-radius: 2px;
  letter-spacing: 1px;
  transform: rotate(-2deg);
}

.bamboo-border {
  position: relative;
  border: 1px solid var(--border);
}

.bamboo-border::before,
.bamboo-border::after {
  content: '◆';
  position: absolute;
  color: var(--gold-leaf);
  font-size: 0.6rem;
  opacity: 0.3;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--ink-light);
  border-radius: 2px;
}

/* ---------- Utility ---------- */
.text-center { text-align: center; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Media Queries ---------- */
@media (max-width: 480px) {
  .app-container {
    max-width: 100%;
  }
  .app-header, .bottom-nav {
    max-width: 100%;
  }
}

@media (min-width: 481px) {
  body {
    background: #E8E0D0;
    display: flex;
    justify-content: center;
  }
  .app-container {
    box-shadow: 0 0 40px var(--shadow);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}

/* ===== 药材详情弹窗（升级版·真实草药展示） ===== */
.detail-overlay, .celebration-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.detail-overlay.active, .celebration-overlay.active {
  display: flex;
}
.detail-card {
  background: var(--ink-paper-card);
  border-radius: var(--radius-lg);
  padding: 24px 24px 20px;
  width: 300px;
  max-width: 90vw;
  text-align: center;
  position: relative;
  box-shadow: 0 8px 32px var(--shadow-heavy);
  border: 1px solid var(--border);
}
.detail-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 80px;
  background: linear-gradient(180deg, rgba(107, 142, 78, 0.08), transparent);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  pointer-events: none;
}
.detail-close {
  position: absolute;
  top: 8px; right: 8px;
  width: 28px; height: 28px;
  border: none;
  background: var(--cinnabar);
  color: white;
  border-radius: 50%;
  font-size: 0.9rem;
  cursor: pointer;
  z-index: 2;
  box-shadow: 0 2px 6px rgba(192,57,43,0.3);
}
.detail-image {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin: 0 auto 10px;
  object-fit: cover;
  background: var(--ink-light);
  border: 3px solid var(--ink-paper);
  box-shadow: 0 4px 12px var(--shadow);
  position: relative;
  z-index: 1;
}
.detail-name {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--ink-black);
  letter-spacing: 2px;
}
.detail-latin {
  font-size: 0.7rem;
  color: #B8B2A8;
  font-style: italic;
  margin-bottom: 6px;
  letter-spacing: 1px;
}
.detail-tag {
  display: inline-block;
  padding: 3px 14px;
  border-radius: 12px;
  font-size: 0.75rem;
  background: linear-gradient(135deg, var(--gold-leaf), var(--gold-leaf));
  color: white;
  margin: 4px 0 10px;
  letter-spacing: 1px;
  box-shadow: 0 2px 6px rgba(201,169,110,0.3);
}
.detail-desc {
  font-size: 0.9rem;
  color: #8B8B8B;
  line-height: 1.6;
  padding: 0 4px;
}

/* ===== 庆祝弹窗 ===== */
.celebration-card {
  background: linear-gradient(135deg, #FFF8F0, #FFF0D0);
  border: 2px solid var(--gold-leaf);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 300px;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 8px 40px rgba(201,169,110,0.3);
  animation: celebrationPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes celebrationPop {
  0% { transform: scale(0.3); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.celebration-fireworks {
  font-size: 2rem;
  animation: fireworkSpark 1s ease infinite;
}
@keyframes fireworkSpark {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}
.celebration-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--gold-leaf);
  margin: 8px 0;
}
.celebration-list {
  font-size: 1rem;
  color: var(--ink-brown);
  padding: 8px 0;
  line-height: 1.6;
}
.celebration-desc {
  font-size: 0.8rem;
  color: #B8B2A8;
  font-style: italic;
}

/* ===== 图鉴真图样式 ===== */
.herb-image {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: contain;
  background: var(--ink-light);
  border: 1px solid var(--border);
  margin-bottom: 4px;
}
.collection-card.unlocked .herb-image {
  box-shadow: 0 2px 8px var(--shadow);
}

/* ===== 存档指示灯 ===== */
.save-indicator-container {
  position: fixed;
  top: 8px;
  right: 8px;
  z-index: 100;
}
.save-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--herb-green);
  opacity: 0.5;
  transition: all 0.3s;
}
.save-indicator.saving {
  opacity: 1;
  box-shadow: 0 0 6px var(--herb-green-light);
}

/* ===== 国风装饰：竹节角花 ===== */
.bamboo-corner {
  position: relative;
}
.bamboo-corner::before,
.bamboo-corner::after {
  content: '◆';
  position: absolute;
  color: var(--ink-light);
  font-size: 0.5rem;
  opacity: 0.25;
}
.bamboo-corner::before { top: -4px; left: -4px; }
.bamboo-corner::after { bottom: -4px; right: -4px; }

/* ===== 水墨进度条优化 ===== */
.ink-progress {
  height: 4px;
  background: linear-gradient(90deg, var(--ink-light), var(--ink-light));
  border-radius: 2px;
  overflow: hidden;
  margin: 8px 0;
}
.ink-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--herb-green), var(--herb-green-light));
  border-radius: 2px;
  transition: width 0.5s ease;
}

/* ===== 图鉴统计摘要 ===== */
.collection-summary {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin: 12px 0;
  font-size: 0.75rem;
  color: var(--ink-gray);
}
.collection-summary span {
  display: flex;
  align-items: center;
  gap: 4px;
}
.collection-summary .num {
  font-weight: 700;
  color: var(--cinnabar);
}

/* ===== 回合首页动画指示器 ===== */
.scroll-indicator {
  display: flex;
  justify-content: center;
  padding: 4px 0;
  margin-bottom: 8px;
}
.scroll-indicator span {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ink-light);
  animation: scrollIndicator 1.5s ease-in-out infinite;
}
.scroll-indicator span:nth-child(2) { animation-delay: 0.3s; }
.scroll-indicator span:nth-child(3) { animation-delay: 0.6s; }
@keyframes scrollIndicator {
  0%, 100% { transform: translateY(0); opacity: 0.3; }
  50% { transform: translateY(-4px); opacity: 0.6; }
}

/* ===== 新手引导 ===== */
.tutorial-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}
.tutorial-card {
  background: linear-gradient(135deg, #FFF8F0 0%, #FAF0E6 100%);
  border-radius: 20px;
  padding: 32px 24px;
  margin: 0 20px;
  max-width: 340px;
  width: 100%;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.3);
  border: 1px solid #D4C5B0;
  animation: slideUp 0.4s ease;
}
.tutorial-emoji {
  font-size: 56px;
  margin-bottom: 12px;
  animation: float 2s ease-in-out infinite;
}
.tutorial-title {
  font-size: 22px;
  font-weight: 700;
  color: #5D4037;
  margin-bottom: 12px;
}
.tutorial-desc {
  font-size: 15px;
  color: #6D5C4E;
  line-height: 1.8;
  margin-bottom: 20px;
}
.tutorial-highlight {
  color: #C0392B;
  font-weight: 600;
}
.tutorial-progress {
  font-size: 13px;
  color: #A09080;
  margin-bottom: 16px;
}
.tutorial-progress span {
  font-weight: 700;
  color: #8D6E63;
  font-size: 16px;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ===== 体力说明提示 ===== */
.energy-tooltip {
  font-size: 11px;
  color: #8D8D8D;
  text-align: center;
  padding: 2px 0 6px;
}

/* ===== 药篓菜单（神农增强） ===== */
.basket-menu-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: var(--bg-overlay, rgba(44,44,44,0.6));
  z-index: 1000;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}
.basket-menu-overlay.active {
  display: flex;
}
.basket-menu-card {
  background: var(--parchment, #F5F0E8);
  border: 2px solid var(--ink-brown, #5D4037);
  border-radius: 16px;
  padding: 20px 24px;
  min-width: 220px;
  max-width: 300px;
  text-align: center;
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  animation: scaleIn 0.2s ease;
}
.basket-menu-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink-black, #2C2C2C);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--ink-light, #D4C5A9);
}
.basket-menu-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.basket-menu-actions .btn {
  width: 100%;
  padding: 10px 16px;
  font-size: 0.9rem;
}
.basket-menu-close {
  position: absolute;
  top: 8px; right: 12px;
  background: none;
  border: none;
  font-size: 1.1rem;
  color: var(--ink-gray, #8B8B8B);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}
.basket-menu-close:hover { color: var(--ink-black, #2C2C2C); }

/* 药篓slot右上角更多按钮 */
.slot-more {
  position: absolute;
  top: 2px; right: 4px;
  font-size: 0.7rem;
  color: var(--ink-gray-light, #B8B2A8);
  opacity: 0;
  transition: opacity 0.15s;
}
.inventory-slot.filled:hover .slot-more { opacity: 0.8; }

@keyframes scaleIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ===== 体质测试引流卡片 ===== */
.constitution-card {
  background: linear-gradient(135deg, #F5F0E8 0%, #FFF8F0 100%);
  border-color: var(--gold, #C9A96E) !important;
}
.constitution-card .btn-primary {
  background: linear-gradient(135deg, var(--cinnabar, #C0392B), #E74C3C);
}

/* ===== 丹方搜索框 ===== */
.recipe-search-bar {
  padding: 0 12px 8px;
}
.recipe-search-bar .search-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--ink-light, #D4C5A9);
  border-radius: 24px;
  background: var(--ink-paper-card, #EDE8DD);
  color: var(--ink-black, #2C2C2C);
  font-size: 0.85rem;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.2s;
}
.recipe-search-bar .search-input:focus {
  border-color: var(--herb-green, #5B8C5A);
}
.recipe-search-bar .search-input::placeholder {
  color: var(--ink-gray-light, #B8B2A8);
}

/* ===== 配药品级动画 ===== */
.disp-tier-良品 { color: #66BB6A; }
.disp-tier-珍品 { color: #AB47BC; }
.disp-tier-极品 { color: #FF9800; }

.disp-tier-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}

@keyframes tierPerfect {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.7); }
  50% { transform: scale(1.08); box-shadow: 0 0 20px 4px rgba(255, 215, 0, 0.4); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 215, 0, 0); }
}

#ch-r-tier:has(.disp-tier-极品) {
  animation: tierPerfect 1s ease-in-out 2;
  display: inline-block !important;
}

/* 火候火焰动画增强 */
.disp-fire {
  transition: background 0.4s ease, height 0.3s ease;
}

/* 通关结果品级光晕 */
.result-title-tier3 {
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.6), 0 0 20px rgba(255, 180, 0, 0.3);
}
.result-title-tier2 {
  text-shadow: 0 0 6px rgba(171, 71, 188, 0.4);
}

/* ===== 采集反馈动画 ===== */
@keyframes collectPop {
  0% { opacity:0; transform:translate(-50%,-50%) scale(0.5); }
  30% { opacity:1; transform:translate(-50%,-50%) scale(1.15); }
  100% { opacity:0; transform:translate(-50%,-70%) scale(1); }
}

/* 挑战目标栏收集完成样式 */
.ch-herb-item.collected {
  background: rgba(46,125,50,0.1) !important;
  border-color: #66BB6A !important;
  transform: scale(1.05);
  transition: all 0.3s ease;
}
