/* style.css - 海底学堂 Web 版全局样式 */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
  color: #fff;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body {
  background: linear-gradient(180deg, #006994 0%, #003d5c 50%, #001a2e 100%);
  background-attachment: fixed;
  min-height: 100vh;
}

#app {
  min-height: 100vh;
}

/* ===== 动画 keyframes ===== */
@keyframes bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-20px)} }
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-16px)} }
@keyframes sway { 0%,100%{transform:rotate(-5deg)} 50%{transform:rotate(5deg)} }
@keyframes grow { 0%{transform:scale(0.8)} 80%{transform:scale(1.1)} 100%{transform:scale(1)} }
@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.08)} }
@keyframes wiggle { 0%{transform:rotate(-8deg)} 50%{transform:rotate(8deg)} 100%{transform:rotate(-8deg)} }
@keyframes spin { from{transform:rotate(0)} to{transform:rotate(360deg)} }
@keyframes fadeIn { from{opacity:0;transform:translateY(20px)} to{opacity:1;transform:translateY(0)} }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-12px)} 75%{transform:translateX(12px)} }
@keyframes gemPop { 0%{transform:scale(0)} 50%{transform:scale(1.5)} 100%{transform:scale(1)} }

.anim-bounce { animation: bounce 0.8s ease infinite; }
.anim-float { animation: float 2s ease-in-out infinite; }
.anim-sway { animation: sway 1.5s ease-in-out infinite; }
.anim-grow { animation: grow 0.6s ease forwards; }
.anim-pulse { animation: pulse 1.2s ease infinite; }
.anim-wiggle { animation: wiggle 0.6s ease infinite; }
.anim-spin { animation: spin 4s linear infinite; }
.anim-fadein { animation: fadeIn 0.5s ease forwards; }

/* ===== 首页 ===== */
.page-home {
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 16px 80px;
}

.home-header {
  text-align: center;
  padding: 12px 0 16px;
}

.home-title {
  font-size: 32px;
  font-weight: 800;
  color: #FFE66D;
  text-shadow: 0 0 20px rgba(255, 230, 109, 0.3);
}

.home-subtitle {
  font-size: 14px;
  color: rgba(255,255,255,0.6);
  margin-top: 4px;
}

.age-tabs {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}

.age-tab {
  padding: 8px 24px;
  border-radius: 24px;
  background: rgba(255,255,255,0.1);
  font-size: 15px;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  transition: all 0.3s;
  user-select: none;
}

.age-tab:hover { background: rgba(255,255,255,0.15); }

.age-tab.active {
  background: #4ECDC4;
  color: #fff;
  font-weight: 700;
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

.course-card {
  background: rgba(255,255,255,0.12);
  border-radius: 18px;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  cursor: pointer;
  transition: all 0.2s;
  overflow: hidden;
}

.course-card:hover {
  background: rgba(255,255,255,0.18);
  transform: translateY(-2px);
}

.course-card:active { transform: scale(0.96); }

.course-emoji {
  font-size: 44px;
  margin-bottom: 10px;
  line-height: 1;
}

.course-title {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}

.course-meta {
  font-size: 12px;
  color: rgba(255,255,255,0.4);
}

.course-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(78,205,196,0.3);
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 11px;
  color: #4ECDC4;
}

.custom-card {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.06);
  border: 2px dashed rgba(255,255,255,0.2);
  border-radius: 18px;
  padding: 18px 16px;
  margin-bottom: 16px;
  cursor: pointer;
}

.custom-card:hover { background: rgba(255,255,255,0.1); }

.custom-icon { font-size: 28px; margin-right: 14px; }
.custom-title { font-size: 16px; color: rgba(255,255,255,0.8); font-weight: 700; }
.custom-desc { font-size: 12px; color: rgba(255,255,255,0.4); margin-top: 2px; }
.custom-tag {
  font-size: 11px; color: #FFB347;
  background: rgba(255,179,71,0.15);
  padding: 4px 10px; border-radius: 8px;
}

.custom-tag-ready {
  color: #4ECDC4;
  background: rgba(78,205,196,0.2);
}

.custom-card:active { transform: scale(0.97); }

.stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: rgba(255,255,255,0.08);
  border-radius: 16px;
  padding: 16px 0;
}

.stat-item { display: flex; flex-direction: column; align-items: center; }
.stat-num { font-size: 24px; font-weight: 800; color: #4ECDC4; }
.stat-label { font-size: 12px; color: rgba(255,255,255,0.4); margin-top: 2px; }
.stat-divider { width: 1px; height: 32px; background: rgba(255,255,255,0.1); }

/* ===== 课件页 ===== */
.page-course {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px 80px;
  position: relative;
  max-width: 640px;
  margin: 0 auto;
}

.phase-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  z-index: 10;
  max-width: 640px;
  margin: 0 auto;
}

.phase-dots { display: flex; gap: 8px; }

.pdot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  transition: all 0.4s;
}

.pdot.active {
  background: #4ECDC4;
  width: 14px; height: 14px;
}

.phase-label { font-size: 13px; color: rgba(255,255,255,0.5); }

.back-btn {
  font-size: 20px;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  padding: 4px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.1);
  user-select: none;
}

.back-btn:hover { background: rgba(255,255,255,0.2); }

.gem-bar {
  position: fixed;
  bottom: 16px; left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: 6px;
  z-index: 5;
}

.gem {
  font-size: 18px;
  opacity: 0.25;
  transition: all 0.4s;
}

.gem.earned {
  opacity: 1;
  animation: gemPop 0.5s ease;
}

/* Phase 1: Learn */
.phase-learn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex: 1;
}

.learn-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.learn-letter {
  font-size: 100px;
  font-weight: 900;
  color: #FFE66D;
  text-shadow: 0 0 30px rgba(255,230,109,0.3);
  line-height: 1;
}

.learn-emoji {
  font-size: 72px;
  line-height: 1;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}

.learn-word {
  font-size: 22px;
  color: #fff;
  text-align: center;
}

.learn-pinyin {
  font-size: 16px;
  color: #4ECDC4;
  opacity: 0.7;
}

.learn-hint {
  font-size: 13px;
  color: rgba(255,255,255,0.3);
  margin-top: 32px;
}

.nav-btns { display: flex; gap: 24px; margin-top: 28px; }

.nav-btn {
  padding: 10px 28px;
  border-radius: 24px;
  background: rgba(255,255,255,0.12);
  font-size: 18px;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  user-select: none;
  transition: all 0.2s;
  border: none;
}

.nav-btn:hover { background: rgba(255,255,255,0.2); }
.nav-btn:active { transform: scale(0.95); }

.nav-next {
  background: #4ECDC4;
  color: #fff;
  font-weight: 700;
}

.nav-next:hover { background: #5dd8d0; }

/* Phase 2: Practice */
.phase-prac {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex: 1;
  gap: 28px;
}

.prac-prompt { font-size: 18px; color: rgba(255,255,255,0.6); }

.prac-letter {
  font-size: 80px;
  font-weight: 900;
  color: #FFE66D;
  text-shadow: 0 0 30px rgba(255,230,109,0.3);
  text-align: center;
}

.prac-options { display: flex; gap: 28px; }

.prac-option {
  width: 130px; height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.12);
  border-radius: 24px;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.prac-option:hover {
  transform: translateY(-2px);
  background: rgba(78,205,196,0.15);
  border-color: rgba(78,205,196,0.5);
}

.prac-option:active {
  transform: scale(0.9);
  background: rgba(78,205,196,0.2);
  border-color: #4ECDC4;
}

.prac-opt-emoji { font-size: 56px; }

.prac-feedback {
  font-size: 22px;
  color: #4ECDC4;
  min-height: 30px;
  opacity: 0;
  transition: opacity 0.3s;
}

.prac-feedback.show { opacity: 1; }
.prac-score { font-size: 15px; color: rgba(255,255,255,0.4); }

/* Phase 3: Challenge */
.phase-chal {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex: 1;
  gap: 28px;
}

.chal-prompt { font-size: 18px; color: rgba(255,255,255,0.6); }
.chal-emoji-display { font-size: 84px; line-height: 1; }

.chal-options { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }

.chal-option {
  min-width: 90px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.12);
  border-radius: 18px;
  border: 3px solid transparent;
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
  padding: 0 16px;
}

.chal-option:hover {
  transform: translateY(-2px);
  background: rgba(255,230,109,0.15);
  border-color: rgba(255,230,109,0.5);
}

.chal-option:active {
  transform: scale(0.9);
  background: rgba(255,230,109,0.2);
  border-color: #FFE66D;
}

.chal-feedback {
  font-size: 20px;
  color: #4ECDC4;
  min-height: 28px;
  opacity: 0;
  transition: opacity 0.3s;
}

.chal-feedback.show { opacity: 1; }
.chal-score { font-size: 15px; color: rgba(255,255,255,0.4); }

/* Achievement */
.phase-achieve {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  flex: 1;
  gap: 20px;
}

.ach-trophy { font-size: 96px; line-height: 1; }

.ach-title {
  font-size: 30px;
  font-weight: 800;
  color: #FFE66D;
  text-shadow: 0 0 20px rgba(255,230,109,0.3);
}

.ach-gems { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.ach-gem { font-size: 40px; }

.ach-score { font-size: 48px; font-weight: 800; color: #4ECDC4; }
.ach-msg { font-size: 18px; color: rgba(255,255,255,0.8); }

.ach-buttons { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; }

.ach-btn {
  padding: 14px 48px;
  border-radius: 28px;
  font-size: 17px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
  border: none;
}

.ach-btn:hover { transform: translateY(-1px); }
.ach-btn:active { transform: scale(0.95); }

.ach-btn-primary { background: #4ECDC4; color: #fff; font-weight: 700; }
.ach-btn-primary:hover { background: #5dd8d0; }

.ach-btn-secondary {
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.6);
}

.ach-btn-secondary:hover { background: rgba(255,255,255,0.2); }

/* ===== AI 生成课件页 ===== */
.page-custom {
  max-width: 640px;
  margin: 0 auto;
  padding: 60px 16px 80px;
  min-height: 100vh;
}

.custom-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.custom-intro {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 4px 4px 8px;
}

.custom-intro-icon { font-size: 28px; line-height: 1.2; flex-shrink: 0; }
.custom-intro-text {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
  line-height: 1.6;
}

.custom-section {
  background: rgba(255,255,255,0.08);
  border-radius: 18px;
  padding: 20px 16px;
}

.custom-section-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 14px;
}

.api-key-row {
  display: flex;
  gap: 10px;
}

.api-key-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.25);
  color: #fff;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
}

.api-key-input::placeholder { color: rgba(255,255,255,0.25); }
.api-key-input:focus { border-color: #4ECDC4; }

.api-key-save {
  padding: 10px 20px;
  border-radius: 12px;
  background: #4ECDC4;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.api-key-save:hover { background: #5dd8d0; }
.api-key-save:active { transform: scale(0.95); }

.api-key-status {
  font-size: 13px;
  margin-top: 10px;
  color: rgba(255,255,255,0.6);
}

.api-key-hint {
  font-size: 12px;
  color: rgba(255,255,255,0.3);
  margin-top: 6px;
  line-height: 1.5;
}

.api-link {
  color: #4ECDC4;
  text-decoration: none;
}

.api-link:hover { text-decoration: underline; }

.topic-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(0,0,0,0.25);
  color: #fff;
  font-size: 15px;
  outline: none;
  margin-bottom: 14px;
  transition: border-color 0.2s;
}

.topic-input::placeholder { color: rgba(255,255,255,0.25); }
.topic-input:focus { border-color: #4ECDC4; }

.age-select-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.age-select-label {
  font-size: 14px;
  color: rgba(255,255,255,0.5);
}

.age-select {
  padding: 6px 16px;
  border-radius: 20px;
  background: rgba(255,255,255,0.1);
  font-size: 14px;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  user-select: none;
  transition: all 0.2s;
}

.age-select:hover { background: rgba(255,255,255,0.15); }

.age-select.active {
  background: #4ECDC4;
  color: #fff;
  font-weight: 700;
}

.generate-btn {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, #4ECDC4, #44b8b0);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.generate-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(78,205,196,0.3);
}

.generate-btn:active { transform: scale(0.98); }

.generate-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.gen-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 36px 0;
}

.gen-loading-spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255,255,255,0.1);
  border-top-color: #4ECDC4;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.gen-loading-text {
  margin-top: 16px;
  font-size: 15px;
  color: rgba(255,255,255,0.6);
}

.gen-error {
  background: rgba(255,100,100,0.12);
  border: 1px solid rgba(255,100,100,0.25);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 14px;
  color: #ff8888;
  line-height: 1.5;
}

.saved-course-item {
  display: flex;
  align-items: center;
  background: rgba(255,255,255,0.06);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: background 0.2s;
}

.saved-course-item:hover { background: rgba(255,255,255,0.12); }
.saved-course-item:last-child { margin-bottom: 0; }

.saved-course-emoji {
  font-size: 32px;
  margin-right: 12px;
  line-height: 1;
}

.saved-course-info { flex: 1; }

.saved-course-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.saved-course-meta {
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  margin-top: 2px;
}

.saved-course-delete {
  font-size: 20px;
  color: rgba(255,255,255,0.25);
  cursor: pointer;
  padding: 4px 10px;
  user-select: none;
  transition: color 0.2s;
}

.saved-course-delete:hover { color: #ff8888; }

/* ===== 响应式 ===== */
@media (min-width: 768px) {
  .course-grid { grid-template-columns: repeat(3, 1fr); }
  .learn-letter { font-size: 140px; }
  .learn-emoji { font-size: 96px; }
  .learn-word { font-size: 26px; }
  .prac-letter { font-size: 100px; }
  .prac-option { width: 160px; height: 160px; }
  .prac-opt-emoji { font-size: 72px; }
  .chal-emoji-display { font-size: 100px; }
  .chal-option { min-width: 110px; height: 96px; font-size: 32px; }
}
