/* ==========================================================================
   CPU-349 考研英语 · 写作语块闪卡系统 (Writing Chunks Flashcard Edition)
   严格对标处方与全站闪卡规范：3D翻面、纯净无杂质、卡片大小自适应、问题居中、词库全息
   ========================================================================== */

/* 页面主体与闪卡尺寸适度收敛 */
body.chunks-flashcard-view {
  overflow: hidden;
}

body.chunks-flashcard-view .single-mode-container {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 10px clamp(10px, 2.5vw, 20px) 20px !important;
}

body.chunks-flashcard-view .flashcards-container {
  max-width: 760px !important;
  width: 100% !important;
  margin: 0 auto !important;
}

body.chunks-flashcard-view .card-scene-wrapper {
  max-width: 760px !important;
  width: 100% !important;
  padding-inline: 0 !important;
}

body.chunks-flashcard-view .card-scene {
  max-width: 760px !important;
  width: min(100%, 760px) !important;
  flex: 0 1 760px !important;
  min-height: 480px !important;
  max-height: clamp(480px, calc(100vh - 150px), 640px) !important;
  height: clamp(480px, calc(100vh - 150px), 640px) !important;
  margin: 0 auto !important;
}

/* 闪卡容器居中与自适应 */
body.chunks-flashcard-view .card-face.card-front {
  display: flex !important;
  flex-direction: column !important;
  justify-content: space-between !important;
  align-items: stretch !important;
  height: 100% !important;
  box-sizing: border-box !important;
}

/* 闪卡正面问题区：严格水平与垂直完全居中 */
body.chunks-flashcard-view .card-face.card-front .card-question-text {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  flex: 1 1 auto !important;
  margin: auto 0 !important;
  text-align: center !important;
  width: 100% !important;
  padding: 10px 8px !important;
  box-sizing: border-box !important;
  overflow-y: auto !important;
}

.writing-card-prompt-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  margin: auto 0;
  box-sizing: border-box;
}

.writing-chunk-zh-title {
  font-size: clamp(1.2rem, 2.2vw, 1.62rem);
  font-weight: 800;
  color: var(--text-main, #233322);
  line-height: 1.4;
  margin-bottom: 18px;
  letter-spacing: 0.2px;
  text-align: center;
}

body.dark-theme .writing-chunk-zh-title {
  color: #e5ede4;
}

.writing-chunk-avoid-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.92rem;
  color: #718096;
  text-align: center;
  background: rgba(0, 0, 0, 0.025);
  border-radius: 999px;
  padding: 6px 16px;
  border: 1px solid rgba(0, 0, 0, 0.04);
}

body.dark-theme .writing-chunk-avoid-row {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.08);
  color: #94a3b8;
}

.writing-chunk-avoid-row .avoid-label {
  font-weight: 700;
  color: #64748b;
  font-size: 0.85rem;
}

body.dark-theme .writing-chunk-avoid-row .avoid-label {
  color: #94a3b8;
}

.writing-chunk-avoid-words {
  text-decoration: line-through;
  font-style: italic;
  color: #94a3b8;
  font-weight: 600;
}

body.dark-theme .writing-chunk-avoid-words {
  color: #64748b;
}

/* 闪卡答案区（背面）全新优雅排版体系 (Modern Elegant Hierarchy) */
.writing-card-answer-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 2px 2px 8px 2px;
  box-sizing: border-box;
  text-align: left !important;
}

/* 1. 核心语块与同义进阶展架区 */
.answer-chunk-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 语块层级卡片基础 */
.chunk-tier-card {
  border-radius: 10px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-sizing: border-box;
  text-align: left;
  position: relative;
  cursor: pointer;
  user-select: none;
}

/* 首选主打大卡 (Hero Primary) */
.chunk-tier-card.tier-primary {
  background: #f0f7f0;
  border: 1.5px solid rgba(46, 125, 50, 0.22);
  padding: 12px 16px;
  box-shadow: 0 2px 6px rgba(46, 125, 50, 0.04);
}

.chunk-tier-card.tier-primary.is-active {
  border-color: #2E7D32;
  box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.2), 0 4px 12px rgba(46, 125, 50, 0.08);
}

body.dark-theme .chunk-tier-card.tier-primary {
  background: rgba(76, 175, 80, 0.1);
  border-color: rgba(76, 175, 80, 0.28);
  box-shadow: none;
}

body.dark-theme .chunk-tier-card.tier-primary.is-active {
  border-color: #81C784;
  box-shadow: 0 0 0 2px rgba(129, 199, 132, 0.25);
}

/* 卡片顶栏：微徽章 + 中文释义 */
.tier-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.tier-badge {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.4px;
  padding: 2px 7px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.tier-badge.badge-primary {
  background: rgba(46, 125, 50, 0.15);
  color: #1b5e20;
}
body.dark-theme .tier-badge.badge-primary {
  background: rgba(76, 175, 80, 0.25);
  color: #a5d6a7;
}

.tier-badge.badge-alt {
  background: rgba(37, 99, 235, 0.14);
  color: #1d4ed8;
}
body.dark-theme .tier-badge.badge-alt {
  background: rgba(59, 130, 246, 0.22);
  color: #93c5fd;
}

.tier-badge.badge-upgrade {
  background: rgba(124, 58, 237, 0.14);
  color: #6d28d9;
}
body.dark-theme .tier-badge.badge-upgrade {
  background: rgba(168, 85, 247, 0.22);
  color: #d8b4fe;
}

.tier-zh {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-muted, #4b5563);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

body.dark-theme .tier-zh {
  color: #9ca3af;
}

/* 主打英文词组字号 */
.tier-primary .tier-en {
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "SF Pro Rounded", sans-serif;
  font-size: clamp(1.15rem, 2.2vw, 1.35rem);
  font-weight: 800;
  color: #1b5e20;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

body.dark-theme .tier-primary .tier-en {
  color: #81C784;
}

/* 平替与进阶双列展架 (Alt Shelf Grid) */
.chunk-alt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px;
  width: 100%;
}

.chunk-tier-card.tier-alt {
  background: rgba(37, 99, 235, 0.04);
  border: 1px solid rgba(37, 99, 235, 0.2);
  padding: 9px 13px;
}

.chunk-tier-card.tier-alt:hover {
  background: rgba(37, 99, 235, 0.07);
  border-color: rgba(37, 99, 235, 0.4);
}

.chunk-tier-card.tier-alt.is-active {
  border-color: #2563eb;
  background: rgba(37, 99, 235, 0.08);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.22);
}

body.dark-theme .chunk-tier-card.tier-alt {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(96, 165, 250, 0.25);
}

body.dark-theme .chunk-tier-card.tier-alt.is-active {
  border-color: #60a5fa;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.25);
}

.chunk-tier-card.tier-alt .tier-en {
  font-family: "Nunito", -apple-system, sans-serif;
  font-size: 1.02rem;
  font-weight: 700;
  color: #1e40af;
  line-height: 1.35;
}

body.dark-theme .chunk-tier-card.tier-alt .tier-en {
  color: #93c5fd;
}

.chunk-tier-card.tier-upgrade {
  background: rgba(124, 58, 237, 0.04);
  border: 1px dashed rgba(124, 58, 237, 0.25);
  padding: 9px 13px;
}

.chunk-tier-card.tier-upgrade:hover {
  background: rgba(124, 58, 237, 0.07);
  border-color: rgba(124, 58, 237, 0.45);
}

.chunk-tier-card.tier-upgrade.is-active {
  border-color: #7c3aed;
  border-style: solid;
  background: rgba(124, 58, 237, 0.08);
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.22);
}

body.dark-theme .chunk-tier-card.tier-upgrade {
  background: rgba(124, 58, 237, 0.08);
  border-color: rgba(167, 139, 250, 0.25);
}

body.dark-theme .chunk-tier-card.tier-upgrade.is-active {
  border-color: #c084fc;
  box-shadow: 0 0 0 2px rgba(167, 139, 250, 0.25);
}

.chunk-tier-card.tier-upgrade .tier-en {
  font-family: "Nunito", -apple-system, sans-serif;
  font-size: 1.02rem;
  font-weight: 700;
  color: #5b21b6;
  line-height: 1.35;
}

body.dark-theme .chunk-tier-card.tier-upgrade .tier-en {
  color: #d8b4fe;
}

/* 2. 考场实战例句区 (Natural Exam Sentence Section) */
.answer-sentence-section {
  background: rgba(0, 0, 0, 0.02);
  border-left: 3.5px solid #2E7D32;
  border-radius: 0 10px 10px 0;
  padding: 13px 16px;
  box-sizing: border-box;
  transition: border-color 0.25s ease;
}

body.dark-theme .answer-sentence-section {
  background: rgba(255, 255, 255, 0.03);
  border-left-color: #81C784;
}

.answer-sentence-section.tier-alt-active {
  border-left-color: #2563eb;
}
body.dark-theme .answer-sentence-section.tier-alt-active {
  border-left-color: #60a5fa;
}

.answer-sentence-section.tier-upgrade-active {
  border-left-color: #7c3aed;
}
body.dark-theme .answer-sentence-section.tier-upgrade-active {
  border-left-color: #c084fc;
}

.sentence-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.sentence-source-badge {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted, #718096);
  letter-spacing: 0.3px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sentence-tier-switcher-hint {
  font-size: 0.72rem;
  color: var(--text-muted, #94a3b8);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.switcher-hint-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #10b981;
}

/* 自然英文例句文字 */
.sentence-en-box {
  font-family: "Lora", Georgia, serif;
  font-size: clamp(1.02rem, 1.8vw, 1.15rem);
  line-height: 1.72;
  color: var(--text-main, #233322);
  margin-bottom: 8px;
  word-break: normal;
  overflow-wrap: break-word;
}

body.dark-theme .sentence-en-box {
  color: #e5ede4;
}

/* 优雅句中高亮语块 (融入自然阅读流，告别药丸贴膏药) */
.sentence-chunk-highlight {
  font-family: inherit;
  font-weight: 700;
  border-radius: 3px;
  padding: 1px 4px;
  margin: 0 1px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline;
}

.sentence-chunk-highlight.tier-primary {
  background: rgba(16, 185, 129, 0.16);
  color: #065f46;
  border-bottom: 2px solid #10b981;
}

body.dark-theme .sentence-chunk-highlight.tier-primary {
  background: rgba(52, 211, 153, 0.2);
  color: #6ee7b7;
  border-bottom-color: #34d399;
}

.sentence-chunk-highlight.tier-alt {
  background: rgba(59, 130, 246, 0.15);
  color: #1e40af;
  border-bottom: 2px solid #3b82f6;
}

body.dark-theme .sentence-chunk-highlight.tier-alt {
  background: rgba(96, 165, 250, 0.2);
  color: #93c5fd;
  border-bottom-color: #60a5fa;
}

.sentence-chunk-highlight.tier-upgrade {
  background: rgba(139, 92, 246, 0.15);
  color: #5b21b6;
  border-bottom: 2px solid #8b5cf6;
}

body.dark-theme .sentence-chunk-highlight.tier-upgrade {
  background: rgba(167, 139, 250, 0.2);
  color: #d8b4fe;
  border-bottom-color: #c084fc;
}

/* 中文例句译文 */
.sentence-zh-box {
  font-size: 0.92rem;
  line-height: 1.58;
  color: var(--text-muted, #4b5563);
  transition: opacity 0.2s ease;
}

body.dark-theme .sentence-zh-box {
  color: #9ca3af;
}

@media (max-width: 640px) {
  .chunk-alt-grid {
    grid-template-columns: 1fr;
  }
  .sentence-tier-switcher-hint {
    display: none;
  }
}

/* 卡片类型微标 (短语卡 vs 实战句卡) */
.card-type-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 2px 10px;
  border-radius: 999px;
  margin-left: 8px;
}

.card-type-phrase {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

body.dark-theme .card-type-phrase {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.card-type-sentence {
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

body.dark-theme .card-type-sentence {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
}

/* 闪卡翻转卡面平滑切换保障 */
.flashcard {
  perspective: 1000px;
  cursor: pointer;
}

.flashcard .card-face {
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.35s ease !important;
}

.flashcard:not(.is-flipped) .card-front {
  transform: rotateY(0deg) !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

.flashcard:not(.is-flipped) .card-back {
  transform: rotateY(180deg) !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.flashcard.is-flipped .card-front {
  transform: rotateY(-180deg) !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.flashcard.is-flipped .card-back {
  transform: rotateY(0deg) !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

#card-intent-badge {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  box-shadow: none !important;
}

#card-intent-badge .card-type-indicator {
  margin-left: 0 !important;
}
