/* ==========================================================================
   BINGO GO 学 · 简约科技主题系统
   品牌色：BINGO 亮黄；6 套成套主题；全站动画体系
   ========================================================================== */

/* ==========================================================================
   T0. 设计 Token（默认主题：云白）
   ========================================================================== */
:root {
  /* —— 品牌色（全主题固定，不随主题变化）—— */
  --brand: #FFE100;
  --brand-deep: #E6CA00;
  --on-brand: #1C1C1E;

  /* —— 背景 —— */
  --bg: #F5F5F3;
  --bg-neutral: #F5F5F3;   /* 中性默认背景：番茄钟等工具页固定使用，不随彩色主题变化 */
  --bg-raised: #FCFCFB;
  --card: #FFFFFF;  --card-hover: #FFFFFF;
  --fill: rgba(28, 28, 30, 0.05);
  --fill-strong: rgba(28, 28, 30, 0.09);

  /* —— 文字 —— */
  --text: #1C1C1E;
  --text-secondary: #6E6E73;
  --text-muted: #AEAEB2;

  /* —— 主题色（按钮填充 / active 态）—— */
  --accent: #FFE100;
  --accent-deep: #E6CA00;
  --on-accent: #1C1C1E;
  --accent-soft: rgba(255, 214, 10, 0.16);
  --accent-text: #8a6d00;   /* 小字强调链接用，保证白底可读 */

  /* —— 功能色 —— */
  --green: #34C759;
  --green-soft: rgba(52, 199, 89, 0.13);
  --red: #FF3B30;
  --red-soft: rgba(255, 59, 48, 0.11);
  --blue: #0A84FF;
  --blue-soft: rgba(10, 132, 255, 0.11);
  --orange: #FF9500;
  --orange-soft: rgba(255, 149, 0, 0.12);
  --purple: #AF52DE;
  --purple-soft: rgba(175, 82, 222, 0.11);
  --teal: #30B0C7;
  --teal-soft: rgba(48, 176, 199, 0.12);

  /* —— 线条 / 阴影 —— */
  --border: rgba(28, 28, 30, 0.08);
  --border-strong: rgba(28, 28, 30, 0.14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.12);
  --shadow-brand: 0 6px 20px rgba(240, 185, 11, 0.35);

  /* —— 字体 —— */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
          "Helvetica Neue", "Segoe UI", "Microsoft YaHei", sans-serif;
  --font-num: "SF Pro Rounded", -apple-system, "PingFang SC", sans-serif;

  /* —— 圆角 —— */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;
  --r-full: 999px;

  /* —— 尺寸 —— */
  --tab-height: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --max-width: 480px;
  --px: clamp(8px, 2.5vw, 14px);

  --z-modal: 900;

  /* —— legacy 变量映射（旧页面引用的 style.css 变量，运行时解析、全主题自动跟随）—— */
  --bg-system: var(--bg);
  --bg-deep: var(--bg);
  --bg-champagne: var(--bg);
  --bg-cream: var(--card);
  --bg-white: var(--card);
  --bg-warm: var(--bg);
  --bg-card: var(--card);
  --bg-card-hover: var(--card-hover);
  --bg-glass: var(--card);
  --bg-input: var(--fill-strong);
  --text-primary: var(--text);
  --text-tertiary: var(--text-muted);
  --border-subtle: var(--border);
  --border-medium: var(--border-strong);
  --brand-blue: var(--accent-deep);
  --brand-blue-light: var(--accent);
  --accent-primary: var(--accent);

  /* —— ios legacy 局部变量映射（translate/oral/essay 等旧页面用）—— */
  --ios-bg: var(--bg);
  --ios-card: var(--card);
  --ios-blue: var(--accent-deep);
  --ios-blue-light: var(--accent);
  --ios-blue-bg: var(--accent-soft);
  --ios-green: var(--green);
  --ios-green-bg: var(--green-soft);
  --ios-red: var(--red);
  --ios-red-bg: var(--red-soft);
  --ios-orange: var(--orange);
  --ios-purple: var(--purple);
  --ios-yellow: var(--brand);
  --ios-yellow-bg: var(--accent-soft);
  --ios-gray: var(--text-muted);
  --ios-gray2: var(--text-muted);
  --ios-gray3: var(--text-muted);
  --ios-gray4: var(--border);
  --ios-gray5: var(--fill);
  --ios-gray6: var(--bg);
  --ios-label: var(--text);
  --ios-label-secondary: var(--text-secondary);
  --ios-label-tertiary: var(--text-muted);
  --ios-separator: var(--border);
  --ios-shadow: var(--shadow-sm);
  --ios-shadow-md: var(--shadow-md);
  --ios-radius: var(--r-lg);
  --ios-radius-sm: var(--r-md);
  --ios-radius-xs: var(--r-sm);
  --ios-radius-pill: var(--r-full);
}

/* ==========================================================================
   T1. 主题包（背景与配色成套）
   ========================================================================== */

/* 云白（默认）：暖白纸感 + BINGO 亮黄，品牌原生主题 */
[data-theme="cloud"] { }

/* 墨黑：深灰石墨 + 亮黄，黄黑经典，最酷的一版 */
[data-theme="ink"] {
  --bg: #131315;
  --bg-neutral: #131315;
  --bg-raised: #1B1B1E;
  --card: #222225;
  --card-hover: #2A2A2E;
  --fill: rgba(255, 255, 255, 0.07);
  --fill-strong: rgba(255, 255, 255, 0.12);
  --text: #F2F2F5;
  --text-secondary: #9C9CA3;
  --text-muted: #63636B;
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --accent: #FFE100;
  --accent-deep: #FFE100;
  --on-accent: #1C1C1E;
  --accent-soft: rgba(255, 214, 10, 0.16);
  --accent-text: #FFE100;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.55);
}

/* 静谧蓝：雾蓝底 + 科技蓝 */
[data-theme="ocean"] {
  --bg: #EFF4F9;
  --bg-raised: #F7FAFD;
  --card: #F6F9FE;
  --fill: rgba(15, 60, 110, 0.05);
  --fill-strong: rgba(15, 60, 110, 0.1);
  --accent: #0A84FF;
  --accent-deep: #0066D6;
  --on-accent: #FFFFFF;
  --accent-soft: rgba(10, 132, 255, 0.12);
  --accent-text: #0A84FF;
}

/* 薄荷：浅青底 + 青翠绿 */
[data-theme="mint"] {
  --bg: #EFF7F3;
  --bg-raised: #F7FBF9;
  --card: #F4FBF7;  --fill: rgba(0, 110, 70, 0.05);
  --fill-strong: rgba(0, 110, 70, 0.1);
  --accent: #00A86B;
  --accent-deep: #008A58;
  --on-accent: #FFFFFF;
  --accent-soft: rgba(0, 168, 107, 0.12);
  --accent-text: #00885A;
}

/* 樱粉：淡粉底 + 玫瑰红 */
[data-theme="sakura"] {
  --bg: #FAF1F4;
  --bg-raised: #FDF8FA;
  --card: #FDF6F9;  --fill: rgba(150, 30, 70, 0.05);
  --fill-strong: rgba(150, 30, 70, 0.1);
  --accent: #FF2D78;
  --accent-deep: #E01B63;
  --on-accent: #FFFFFF;
  --accent-soft: rgba(255, 45, 120, 0.11);
  --accent-text: #E01B63;
}

/* 暖沙：燕麦米白 + 活力橙 */
[data-theme="sand"] {
  --bg: #F8F4EC;
  --bg-raised: #FCFAF4;
  --card: #FCF9F2;  --fill: rgba(130, 90, 20, 0.06);
  --fill-strong: rgba(130, 90, 20, 0.11);
  --accent: #FF9500;
  --accent-deep: #E88300;
  --on-accent: #FFFFFF;
  --accent-soft: rgba(255, 149, 0, 0.13);
  --accent-text: #C26E00;
}

/* ==========================================================================
   T2. 全局基底
   ========================================================================== */
html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  transition: background-color 0.35s ease, color 0.35s ease;
}

/* 覆盖旧版 style.css 中各 page-* 写死的浅色渐变背景 */
body[class*="page-"] {
  background: var(--bg) !important;
}

.app-container {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: calc(var(--tab-height) + var(--safe-bottom) + 20px);
}

::selection { background: var(--accent-soft); }

/* ==========================================================================
   T3. 全局组件扁平化（覆盖旧 iOS 样式）
   ========================================================================== */

/* —— 卡片 —— */
.card, .stat-card, .feature-card, .tool-card, .practice-card,
.dashboard-card, .word-card, .setting-item, .list-card {
  background: var(--card) !important;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  color: var(--text);
}

/* —— 按钮 —— */
.btn, button[class*="btn"], .submit-btn {
  font-family: var(--font);
  border-radius: var(--r-md);
  transition: transform 0.18s cubic-bezier(0.34, 1.4, 0.64, 1),
              box-shadow 0.22s ease, background-color 0.2s ease, opacity 0.2s;
}
.btn:active, button[class*="btn"]:active, .submit-btn:active,
.practice-card:active, .feature-card:active, .tool-card:active {
  transform: scale(0.965);
}

.btn-primary, .submit-btn, [class*="primary-btn"] {
  background: var(--accent) !important;
  color: var(--on-accent) !important;
  box-shadow: none;
  border: none;
}
.btn-primary:active { box-shadow: none; }

/* —— 输入 —— */
input, textarea, select {
  font-family: var(--font);
  color: var(--text);
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent-deep) !important;
  outline: none;
}

/* —— 旧毛玻璃/渐变清理 —— */
[class*="glass"], [class*="blur"] {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* —— 全局 .page-header 覆盖（旧 iOS 白色毛玻璃 flex 头 → 简单 block 头）—— */
.page-header {
  display: block !important;
  background: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  position: relative !important;
}

/* —— 文字色统一走 token —— */
h1, h2, h3, h4, h5, p, span, div, a, li, label, td, th { border-color: var(--border); }

/* ==========================================================================
   T4. 底部导航
   ========================================================================== */
.tab-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  transform: none !important;
  z-index: 800;
  height: calc(var(--tab-height) + var(--safe-bottom));
  padding: 0 0 var(--safe-bottom);
  background: var(--bg-raised);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: center;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
.tab-bar::before { display: none !important; }
.tab-bar-inner {
  width: 100%;
  max-width: var(--max-width);
  display: flex;
}
.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 10.5px;
  font-weight: 500;
  transition: color 0.22s ease;
  -webkit-tap-highlight-color: transparent;
}
.tab-item.active { color: var(--text); }
.tab-item.active .tab-label { font-weight: 700; }
.tab-svg {
  width: 24px; height: 24px;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.tab-item.active .tab-svg {
  color: var(--accent-deep);
  animation: a-tab-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
[data-theme="ink"] .tab-item.active .tab-svg { color: var(--accent); }
[data-theme="cloud"] .tab-item.active .tab-svg { color: #C9A700; }
.tab-item:active .tab-svg { transform: scale(0.82); }

/* ==========================================================================
   T5. 动画体系
   ========================================================================== */
@keyframes a-fade-up {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes a-fade {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes a-slide-up {
  from { transform: translateY(100%); } to { transform: translateY(0); }
}
@keyframes a-pop {
  0%   { opacity: 0; transform: scale(0.5); }
  62%  { opacity: 1; transform: scale(1.08); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes a-tab-pop {
  0% { transform: scale(0.7); }
  55% { transform: scale(1.18); }
  100% { transform: scale(1); }
}
@keyframes a-float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
@keyframes a-check-draw {
  from { stroke-dashoffset: 20; }
  to   { stroke-dashoffset: 0; }
}
@keyframes a-spin {
  to { transform: rotate(360deg); }
}
@keyframes a-pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.5); opacity: 0.55; }
}

/* —— 页面入场编排：主内容区直接子元素依次浮入 —— */
.app-container > * {
  animation: a-fade-up 0.5s cubic-bezier(0.22, 0.8, 0.32, 1) both;
}
.app-container > *:nth-child(1) { animation-delay: 0.03s; }
.app-container > *:nth-child(2) { animation-delay: 0.09s; }
.app-container > *:nth-child(3) { animation-delay: 0.15s; }
.app-container > *:nth-child(4) { animation-delay: 0.21s; }
.app-container > *:nth-child(5) { animation-delay: 0.27s; }
.app-container > *:nth-child(6) { animation-delay: 0.33s; }
.app-container > *:nth-child(n+7) { animation-delay: 0.39s; }

/* 通用动画工具类 */
.anim-pop { animation: a-pop 0.45s cubic-bezier(0.34, 1.4, 0.64, 1) both; }
.anim-float { animation: a-float 3.2s ease-in-out infinite; }
.spin { animation: a-spin 0.9s linear infinite; }

/* 卡片按压反馈 */
.pressable { transition: transform 0.18s cubic-bezier(0.34, 1.4, 0.64, 1), box-shadow 0.22s ease; }
.pressable:active { transform: scale(0.965); }

/* 尊重系统减弱动态设置 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   T5.5 全站回退按钮
   ========================================================================== */
.nav-back {
  position: fixed; top: calc(env(safe-area-inset-top, 0px) + 8px); left: 8px;
  z-index: 850; width: 36px; height: 36px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, transform 0.15s;
}
.nav-back:active { background: var(--fill); transform: scale(0.9); }
body.page-dashboard .nav-back, body.page-home .nav-back { display: none; }
body.hide-nav-back .nav-back { display: none !important; }

/* ==========================================================================
   T5.6 统一功能页页头（标题栏组件）
   所有功能页复用：返回键留白 + 标题 + 副标题 + 右侧操作区
   ========================================================================== */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px var(--px) 0 52px; /* 左侧留 navBack 空间：8(左距)+36(按钮)+8(间隙) */
}
.ph-left { flex: 1; min-width: 0; }
.ph-title {
  font-size: 24px; font-weight: 800; letter-spacing: -0.4px;
  line-height: 1.2; color: var(--text);
  display: flex; align-items: center; gap: 9px; margin: 0;
}
.ph-title .ic { width: 22px; height: 22px; background-color: var(--brand); flex-shrink: 0; }
.ph-sub { font-size: 13px; color: var(--text-secondary); margin: 5px 0 0; line-height: 1.45; }
.ph-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ==========================================================================
   T5.7 全局布局规范（信息层级与间距统一）
   ========================================================================== */
/* 区块标题：所有功能页的内容区块标题统一用此规范 */
.section-title {
  font-size: 15px; font-weight: 700; color: var(--text-secondary);
  letter-spacing: 0; line-height: 1.4; margin: 0 0 12px;
}
/* 内容区统一左右边距 */
.section-pad { padding-left: var(--px); padding-right: var(--px); }
/* 卡片圆角统一三档：小 10 / 中 14 / 大 18（对应 --r-sm/--r-md/--r-lg） */

/* ==========================================================================
   T6. AI 悬浮助手按钮
   ========================================================================== */
.ai-fab {
  position: fixed;
  right: 16px;
  bottom: calc(var(--tab-height) + var(--safe-bottom) + 20px);
  z-index: var(--z-modal);
  width: 48px; height: 48px;
  border-radius: var(--r-full);
  background: var(--brand);
  color: var(--on-brand);
  box-shadow: 0 6px 20px rgba(230, 202, 0, 0.4);
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
  transition: transform 0.25s cubic-bezier(0.34, 1.4, 0.64, 1), box-shadow 0.25s;
  animation: a-pop 0.45s cubic-bezier(0.34, 1.4, 0.64, 1) 1.2s both;
}
.ai-fab:active { transform: scale(0.85); box-shadow: 0 3px 10px rgba(230, 202, 0, 0.25); }

/* AI 聊天抽屉 */
.ai-chat-overlay {
  position: fixed; inset: 0; z-index: 980; background: rgba(0,0,0,0.4);
  display: none; align-items: flex-end; justify-content: center;
}
.ai-chat-overlay.open { display: flex; animation: a-fade 0.25s ease; }
.ai-chat-drawer {
  width: 100%; max-width: 480px; max-height: 70vh;
  background: var(--card); border-radius: 20px 20px 0 0;
  display: flex; flex-direction: column;
  animation: a-slide-up 0.35s cubic-bezier(0.22, 0.8, 0.32, 1);
}
.ai-chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.ai-chat-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.ai-chat-title svg { color: var(--brand); }
.ai-chat-close { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 4px; }
.ai-chat-body { padding: 16px 20px 30px; overflow-y: auto; }
.ai-msg { font-size: 14px; color: var(--text-secondary); margin-bottom: 16px; line-height: 1.6; }
.ai-msg.bot { background: var(--fill); border-radius: 14px; padding: 12px 16px; }
.ai-game-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ai-game-card {
  background: var(--fill); border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 16px 12px; text-align: center; cursor: pointer; font-family: var(--font);
  transition: background 0.15s, transform 0.15s;
}
.ai-game-card:active { transform: scale(0.96); background: var(--accent-soft); }
.agc-icon { font-size: 28px; display: block; margin-bottom: 8px; }
.agc-icon .ic { width: 24px; height: 24px; color: var(--brand); }
.agc-name { font-size: 14px; font-weight: 700; color: var(--text); display: block; }
.agc-desc { font-size: 11px; color: var(--text-muted); display: block; margin-top: 3px; }

/* ==========================================================================
   T7. 响应式：任意手机尺寸自适应
   ========================================================================== */
@media (max-width: 360px) {
  :root { --px: 14px; }
  .tab-svg { width: 22px; height: 22px; }
  .tab-item { font-size: 10px; }
}
@media (min-width: 481px) {
  .tab-bar { border-top: 1px solid var(--border); }
}
