/* 单词闪卡样式 - 现代化设计 */

/* 粒子背景画布 */
#bg-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

:root {
  --bg: #0a0a0c;
  --surface: #0f1014;
  --card: #14161b;
  --text: #e7e7ea;
  --muted: #a1a1a7;
  --border: rgba(255,255,255,0.08);
  --shadow: 0 10px 30px rgba(0,0,0,0.4);
  --accent: #0a84ff;
  --accent-2: #7c4dff;
  --radius: 14px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f5f7;
    --surface: #f8f8fa;
    --card: #ffffff;
    --text: #1d1d1f;
    --muted: #6e6e73;
    --border: rgba(0,0,0,0.08);
    --shadow: 0 12px 30px rgba(0,0,0,0.08);
  }
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  margin: 0;
  background: var(--bg);
  overflow-x: hidden;
}

body {
  height: 100%;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Arial, "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, var(--bg), color-mix(in srgb, var(--bg) 98%, var(--accent) 2%)) fixed;
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  position: relative;
  z-index: 1;
}

/* Hero 区域 */
.hero {
  padding: 60px 0 20px;
  text-align: center;
}

.brand {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 12px;
  font-weight: 600;
}

.hero h1 {
  font-size: 36px;
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin: 0 0 12px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  color: var(--muted);
  margin: 0;
  font-size: 16px;
  font-weight: 500;
}

/* 单元和教材网格 */
.units, .books {
  padding: 20px 0 60px;
}

.units-grid, .books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

/* 教材卡片 */
.book-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 20px;
  transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: var(--shadow);
}

.book-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 40px rgba(0,0,0,0.12);
  border-color: var(--accent);
}

.book-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.book-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 16px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.book-icon img.loaded {
  opacity: 1;
}

.book-icon .image-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 24px;
  font-weight: 600;
}

.book-icon .image-placeholder::before {
  content: "📚";
}

.book-content {
  flex: 1;
  min-width: 0;
}

.book-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.book-arrow {
  font-size: 24px;
  color: var(--accent);
  flex-shrink: 0;
}

/* 面包屑导航 */
.breadcrumb {
  margin-top: 20px;
  padding: 12px 0;
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.breadcrumb a:hover {
  background: var(--card);
  transform: translateY(-1px);
}

/* 单元卡片 */

.unit-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-decoration: none;
  color: inherit;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: var(--shadow);
}

.unit-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 40px rgba(0,0,0,0.12);
  border-color: var(--accent);
}

.unit-icon {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  flex-shrink: 0;
}

.unit-content {
  flex: 1;
  min-width: 0;
}

.unit-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}

/* 已完成单元的样式 */
.unit-card.completed {
  background: linear-gradient(135deg, #10b981, #059669);
  border-color: #059669;
  color: white;
}

.unit-card.completed:hover {
  background: linear-gradient(135deg, #059669, #047857);
  border-color: #047857;
}

.unit-card.completed .unit-icon {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

.unit-card.completed .unit-icon::before {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  background: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.unit-card.completed .unit-icon::after {
  content: '✓';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
  color: #059669;
  z-index: 1;
}

.unit-card.completed .unit-title {
  color: white;
}

.unit-card.completed .unit-arrow {
  color: rgba(255, 255, 255, 0.9);
}

/* 学习中单元的样式 */
.unit-card.in-progress {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border-color: #2563eb;
  color: white;
}

.unit-card.in-progress:hover {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border-color: #1d4ed8;
}

.unit-card.in-progress .unit-icon {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

.unit-card.in-progress .unit-icon::before {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  background: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.unit-card.in-progress .unit-icon::after {
  content: '⋯';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 900;
  color: #2563eb;
  z-index: 1;
  line-height: 1;
}

.unit-card.in-progress .unit-title {
  color: white;
}

.unit-card.in-progress .unit-arrow {
  color: rgba(255, 255, 255, 0.9);
}

.unit-arrow {
  font-size: 24px;
  color: var(--accent);
  flex-shrink: 0;
}

/* 工具栏 */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(10px);
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn-back, .btn-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: inherit;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-back:hover, .btn-control:hover {
  background: var(--card);
  transform: translateY(-1px);
}

.btn-control.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.progress {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

/* 卡片容器 */
.card-container {
  padding: 20px 0 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

/* 3D 翻转卡片 */
.flashcard {
  width: 100%;
  max-width: 500px;
  height: 400px;
  perspective: 1000px;
  cursor: pointer;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s ease-in-out;
  transform-style: preserve-3d;
}

.flashcard.flipped .card-inner {
  transform: rotateY(180deg);
}

.card-front, .card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.card-front {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  z-index: 2;
}

.card-back {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  transform: rotateY(180deg);
  z-index: 1;
}

.card-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  text-align: center;
  color: white;
}

.word {
  font-size: 52px;
  font-weight: 700;
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}

.phonetic {
  font-size: 28px;
  margin-bottom: 20px;
  color: rgba(255,255,255,0.9);
  font-family: "Lucida Sans Unicode", "Arial Unicode MS", Arial;
}

.part-of-speech {
  display: inline-block;
  padding: 8px 20px;
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(10px);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  margin-top: 8px;
  min-height: 20px;
}

.part-of-speech:empty {
  display: none;
}

.audio-btn {
  margin-top: 24px;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  position: relative;
}

.audio-btn:hover {
  background: rgba(255,255,255,0.25);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.audio-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.audio-btn.playing {
  background: var(--accent);
  border-color: var(--accent);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 4px 12px rgba(0,0,0,0.2), 0 0 0 0 var(--accent); }
  50% { box-shadow: 0 6px 20px rgba(0,0,0,0.3), 0 0 0 8px rgba(10, 132, 255, 0.3); }
  100% { box-shadow: 0 4px 12px rgba(0,0,0,0.2), 0 0 0 0 rgba(10, 132, 255, 0); }
}

.meaning {
  font-size: 26px;
  font-weight: 600;
  margin-bottom: 20px;
}

.examples {
  width: 100%;
  max-width: 400px;
}

.example {
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  text-align: left;
}

.example-en {
  font-size: 18px;
  font-style: italic;
  margin-bottom: 10px;
  line-height: 1.5;
}

.example-cn {
  font-size: 14px;
  opacity: 0.9;
  line-height: 1.5;
}

.tap-hint {
  position: absolute;
  bottom: 16px;
  right: 16px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  border-radius: 8px;
  color: rgba(255,255,255,0.8);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid rgba(255,255,255,0.1);
  transition: opacity 0.2s ease;
}

/* 导航按钮 */
.navigation {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  max-width: 600px;
  margin: 0 auto;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: inherit;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow);
  white-space: nowrap;
}

.nav-btn:hover:not(:disabled) {
  background: var(--card);
  transform: translateY(-2px);
  box-shadow: 0 16px 40px rgba(0,0,0,0.12);
}

.nav-btn:active:not(:disabled) {
  transform: translateY(0);
}

.nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* 首个和末个按钮的特殊样式 */
.nav-btn-first, .nav-btn-last {
  padding: 12px 20px;
}

/* 按钮文字 */
.btn-text {
  display: inline;
}

/* 页脚 */
footer {
  padding: 24px 0;
  color: #888;
  text-align: center;
  margin-top: 40px;
  border-top: none;
}

footer p {
  margin: 4px 0;
  font-size: 13px;
  font-weight: 400;
}

footer a {
  color: #888;
  text-decoration: none;
  transition: color 0.2s ease;
}

footer a:hover {
  color: #aaa;
}

.gh-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  text-decoration: none;
  transition: all 0.2s ease;
  padding: 8px 12px;
  border-radius: 8px;
}

.gh-link:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 50%, transparent);
}

.gh-link svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.error {
  padding: 20px;
  text-align: center;
  color: #ff6b6b;
  background: rgba(255, 107, 107, 0.1);
  border-radius: var(--radius);
}

/* 加载和错误状态样式 */
.loading, .error {
  text-align: center;
  padding: 40px 20px;
  color: #666;
  font-size: 16px;
}

.error {
  color: #e74c3c;
}

.loading::after {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  margin-left: 10px;
  border: 2px solid #ddd;
  border-top: 2px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ===== 学习素材包弹窗样式 ===== */
.material-modal {
  position: fixed;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: top 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55), opacity 0.3s ease, visibility 0s 0.5s;
  max-width: 500px;
  width: 90%;
}

.material-modal.show {
  top: 20px;
  opacity: 1;
  visibility: visible;
  transition: top 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55), opacity 0.3s ease, visibility 0s 0s;
}

.material-modal-content {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  animation: modalPulse 2s ease-in-out infinite;
}

@keyframes modalPulse {
  0%, 100% {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  }
  50% {
    box-shadow: 0 20px 80px rgba(10, 132, 255, 0.5);
  }
}

.material-modal-body {
  padding: 32px 24px 24px;
  text-align: center;
  color: white;
}

.material-icon {
  font-size: 64px;
  margin-bottom: 16px;
  animation: iconBounce 1s ease-in-out infinite;
}

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

.material-text {
  font-size: 18px;
  font-weight: 500;
  line-height: 1.6;
  margin: 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.material-modal-footer {
  padding: 16px 24px 24px;
  display: flex;
  gap: 12px;
  justify-content: center;
}

.material-btn {
  flex: 1;
  max-width: 150px;
  padding: 12px 24px;
  border-radius: 12px;
  border: none;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: inherit;
}

.material-btn-cancel {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.material-btn-cancel:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.material-btn-ok {
  background: white;
  color: var(--accent);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.material-btn-ok:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.material-btn:active {
  transform: translateY(0);
}

@media (max-width: 768px) {
  .hero {
    padding: 20px 0 10px;
  }

  .hero h1 {
    font-size: 24px;
    margin-bottom: 12px;
  }

  .units-grid {
    grid-template-columns: 1fr;
  }

  .flashcard {
    height: 380px;
  }

  .word {
    font-size: 34px;
  }

  .phonetic {
    font-size: 20px;
  }

  .meaning {
    font-size: 20px;
  }

  .toolbar {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    margin-top: 0;
  }

  .controls {
    display: flex;
    gap: 8px;
    align-items: center;
  }

  .progress {
    text-align: right;
  }

  /* 移动端导航按钮优化 */
  .navigation {
    gap: 10px;
    width: 100%;
    justify-content: space-between;
  }

  .nav-btn {
    font-size: 14px;
    padding: 12px;
    flex: 1;
    min-width: 0;
    justify-content: center;
  }

  /* 移动端隐藏按钮文字，只显示图标 */
  .nav-btn .btn-text {
    display: none;
  }

  /* 调整SVG图标大小 */
  .nav-btn svg {
    width: 24px;
    height: 24px;
    margin: 0;
  }

  /* 首个和末个按钮在移动端的样式 */
  .nav-btn-first, .nav-btn-last {
    padding: 12px;
    flex: 1;
  }

  /* 移动端弹窗适配 */
  .material-modal {
    width: calc(100% - 32px);
  }
  
  .material-modal.show {
    top: 16px;
  }
  
  .material-modal-body {
    padding: 24px 20px 20px;
  }
  
  .material-icon {
    font-size: 48px;
    margin-bottom: 12px;
  }
  
  .material-text {
    font-size: 16px;
  }
  
  .material-modal-footer {
    padding: 12px 20px 20px;
  }
  
  .material-btn {
    padding: 10px 20px;
    font-size: 14px;
  }
}

@media (prefers-color-scheme: light) {
  .material-modal-content {
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  }
  
  @keyframes modalPulse {
    0%, 100% {
      box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    }
    50% {
      box-shadow: 0 20px 80px rgba(10, 132, 255, 0.3);
    }
  }
}
