/* PEP 6A Unit 1 & 2 - Shared Styles */
:root {
  --primary: #4A90D9;
  --primary-light: #E8F2FC;
  --accent: #FF6B6B;
  --accent-light: #FFF0F0;
  --success: #4CAF50;
  --warning: #FF9800;
  --bg: #F5F7FA;
  --card-bg: #FFFFFF;
  --text: #333333;
  --text-light: #666666;
  --border: #E0E0E0;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --radius: 12px;
  --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font-main);
  font-size: 18px;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

/* ===== Layout ===== */
.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 1em;
}

.page-header {
  background: linear-gradient(135deg, var(--primary), #357ABD);
  color: white;
  padding: 1.5em 1em;
  border-radius: var(--radius);
  margin-bottom: 1.5em;
  text-align: center;
}

.page-header h1 {
  font-size: 1.6em;
  margin-bottom: 0.3em;
}

.page-header .subtitle {
  font-size: 1em;
  opacity: 0.9;
}

.back-link {
  display: inline-block;
  margin-bottom: 1em;
  color: var(--primary);
  text-decoration: none;
  font-size: 0.95em;
  padding: 0.3em 0.8em;
  border: 1px solid var(--primary);
  border-radius: 20px;
  transition: all 0.3s;
}

.back-link:hover {
  background: var(--primary);
  color: white;
}

/* ===== Section Cards ===== */
.section-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.2em;
  margin-bottom: 1.2em;
  box-shadow: var(--shadow);
}

.section-title {
  font-size: 1.3em;
  color: var(--primary);
  margin-bottom: 0.8em;
  padding-bottom: 0.4em;
  border-bottom: 2px solid var(--primary-light);
  display: flex;
  align-items: center;
  gap: 0.4em;
}

.section-title .emoji {
  font-size: 1.2em;
}

/* ===== Full Text Display ===== */
.full-text {
  background: var(--primary-light);
  border-radius: var(--radius);
  padding: 1.2em;
  margin-bottom: 1em;
  font-size: 1.05em;
  line-height: 2;
}

.full-text .line {
  margin-bottom: 0.5em;
  padding: 0.2em 0.4em;
  border-radius: 6px;
  transition: background 0.3s;
}

.full-text .line:hover {
  background: rgba(74,144,217,0.1);
}

.full-text .speaker {
  font-weight: 700;
  color: var(--primary);
  margin-right: 0.3em;
}

/* ===== Sentence Practice ===== */
.sentence-hint {
  background: #FFF8E1;
  border-left: 4px solid var(--warning);
  padding: 0.6em 1em;
  margin-bottom: 1em;
  border-radius: 0 8px 8px 0;
  font-size: 0.95em;
  color: #E65100;
}

.sentence-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.8em;
  overflow: hidden;
}

.sentence-en {
  padding: 0.8em 1em;
  font-size: 1.1em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5em;
}

.sentence-en .text {
  flex: 1;
}

.toggle-btn {
  background: var(--primary);
  color: white;
  border: none;
  width: 2em;
  height: 2em;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1em;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s;
  flex-shrink: 0;
}

.toggle-btn.active {
  transform: rotate(180deg);
}

.sentence-zh {
  display: none;
  padding: 0.6em 1em;
  background: #FAFAFA;
  color: var(--text-light);
  font-size: 0.95em;
  border-top: 1px solid var(--border);
}

.sentence-zh.show {
  display: block;
}

.audio-mini-btn {
  background: var(--primary-light);
  border: 1px solid var(--primary);
  color: var(--primary);
  padding: 0.3em 0.8em;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85em;
  white-space: nowrap;
  transition: all 0.3s;
}

.audio-mini-btn:hover {
  background: var(--primary);
  color: white;
}

/* ===== Key Words ===== */
.word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.8em;
}

.word-card {
  background: var(--primary-light);
  border-radius: var(--radius);
  padding: 0.8em;
  text-align: center;
  transition: transform 0.2s;
}

.word-card:hover {
  transform: translateY(-2px);
}

.word-card .word {
  font-size: 1.2em;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.2em;
}

.word-card .phonetic {
  font-size: 0.85em;
  color: var(--text-light);
  margin-bottom: 0.2em;
}

.word-card .meaning {
  font-size: 0.9em;
  color: var(--text);
}

.word-card .listen-btn {
  margin-top: 0.4em;
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.2em 0.8em;
  border-radius: 15px;
  cursor: pointer;
  font-size: 0.8em;
}

/* ===== Sentence with illustration ===== */
.sentence-with-img {
  display: flex;
  align-items: center;
  gap: 0.8em;
  padding: 0.8em;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 0.8em;
  background: white;
}

.sentence-with-img .illustration {
  font-size: 2.5em;
  flex-shrink: 0;
  width: 3em;
  height: 3em;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  border-radius: var(--radius);
}

.sentence-with-img .content {
  flex: 1;
}

.sentence-with-img .content .en {
  font-size: 1.05em;
  font-weight: 500;
  margin-bottom: 0.2em;
}

.sentence-with-img .content .zh {
  font-size: 0.9em;
  color: var(--text-light);
}

.sentence-with-img .content .keyword {
  color: var(--accent);
  font-weight: 700;
}

/* ===== Culture Corner ===== */
.culture-card {
  display: flex;
  gap: 1em;
  margin-bottom: 1.2em;
  padding: 1em;
  background: #FAFAFA;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.culture-card img {
  width: 120px;
  height: 90px;
  object-fit: cover;
  border-radius: 8px;
  flex-shrink: 0;
}

.culture-card .info {
  flex: 1;
}

.culture-card .info h3 {
  font-size: 1.1em;
  color: var(--primary);
  margin-bottom: 0.3em;
}

.culture-card .info p {
  font-size: 0.9em;
  color: var(--text-light);
  line-height: 1.5;
}

/* ===== Culture Audio Player ===== */
.culture-player {
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.5em 0.8em;
  background: var(--primary-light);
  border-radius: 25px;
  margin-top: 0.5em;
}

.culture-player .play-btn {
  width: 2.2em;
  height: 2.2em;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1em;
  flex-shrink: 0;
  transition: background 0.3s;
}

.culture-player .play-btn:hover {
  background: #357ABD;
}

.culture-player .progress-bar {
  flex: 1;
  height: 6px;
  background: #D0D0D0;
  border-radius: 3px;
  cursor: pointer;
  position: relative;
}

.culture-player .progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  width: 0%;
  transition: width 0.1s;
}

.culture-player .time {
  font-size: 0.75em;
  color: var(--text-light);
  min-width: 3em;
  text-align: right;
}

/* ===== Podcast Section ===== */
.podcast-section {
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: var(--radius);
  padding: 1.2em;
  margin-bottom: 1.2em;
  color: white;
}

.podcast-section .section-title {
  color: white;
  border-bottom-color: rgba(255,255,255,0.3);
}

.podcast-player {
  width: 100%;
  margin-top: 0.5em;
}

.podcast-player audio {
  width: 100%;
  height: 40px;
}

/* ===== Full Audio Player ===== */
.full-audio-bar {
  background: linear-gradient(135deg, #43e97b, #38f9d7);
  border-radius: var(--radius);
  padding: 1em;
  margin-bottom: 1em;
  display: flex;
  align-items: center;
  gap: 0.8em;
}

.full-audio-bar .label {
  font-weight: 700;
  white-space: nowrap;
  font-size: 0.95em;
}

.full-audio-bar audio {
  flex: 1;
  height: 36px;
}

/* ===== Exercises ===== */
.exercise-section {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.2em;
  margin-bottom: 1.2em;
  box-shadow: var(--shadow);
}

.exercise-question {
  margin-bottom: 1.2em;
  padding: 1em;
  background: #FAFAFA;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.exercise-question .q-text {
  font-weight: 600;
  margin-bottom: 0.6em;
  font-size: 1.05em;
}

.exercise-options label {
  display: block;
  padding: 0.5em 0.8em;
  margin: 0.3em 0;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
  border: 1px solid transparent;
}

.exercise-options label:hover {
  background: var(--primary-light);
}

.exercise-options input[type="radio"] {
  margin-right: 0.5em;
}

.check-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.6em 1.5em;
  border-radius: 25px;
  cursor: pointer;
  font-size: 1em;
  font-weight: 600;
  margin-top: 0.5em;
  transition: background 0.3s;
}

.check-btn:hover {
  background: #357ABD;
}

.answer-feedback {
  display: none;
  margin-top: 0.8em;
  padding: 0.8em;
  border-radius: 8px;
  font-size: 0.95em;
}

.answer-feedback.correct {
  display: block;
  background: #E8F5E9;
  color: #2E7D32;
  border: 1px solid #A5D6A7;
}

.answer-feedback.incorrect {
  display: block;
  background: var(--accent-light);
  color: #C62828;
  border: 1px solid #EF9A9A;
}

/* ===== Fill-in-blank ===== */
.fill-blank-passage {
  line-height: 2.2;
  font-size: 1.05em;
  padding: 1em;
  background: #FAFAFA;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.fill-blank-passage input[type="text"] {
  border: none;
  border-bottom: 2px solid var(--primary);
  background: var(--primary-light);
  padding: 0.1em 0.5em;
  font-size: 0.95em;
  width: 8em;
  text-align: center;
  border-radius: 4px 4px 0 0;
  outline: none;
}

.fill-blank-passage input[type="text"].correct {
  border-bottom-color: var(--success);
  background: #E8F5E9;
}

.fill-blank-passage input[type="text"].incorrect {
  border-bottom-color: var(--accent);
  background: var(--accent-light);
}

/* ===== True/False ===== */
.tf-options {
  display: flex;
  gap: 1em;
  margin-top: 0.4em;
}

.tf-options label {
  padding: 0.3em 1em;
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
}

/* ===== Grammar Page ===== */
.grammar-box {
  background: #FFF8E1;
  border-left: 4px solid var(--warning);
  padding: 1em;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 1em;
}

.grammar-box h3 {
  color: #E65100;
  margin-bottom: 0.4em;
}

.grammar-box .rule {
  font-size: 1.05em;
  margin-bottom: 0.5em;
}

.grammar-box .example {
  background: rgba(255,255,255,0.7);
  padding: 0.5em 0.8em;
  border-radius: 8px;
  margin: 0.3em 0;
  font-size: 0.95em;
}

.grammar-box .example .highlight {
  color: var(--accent);
  font-weight: 700;
}

/* ===== Reading Comprehension ===== */
.reading-passage {
  padding: 1.2em;
  background: #FAFAFA;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 1em;
  line-height: 2;
  font-size: 1.05em;
}

.reading-passage h4 {
  text-align: center;
  margin-bottom: 0.8em;
  color: var(--primary);
}

/* ===== Index Page ===== */
.index-header {
  background: linear-gradient(135deg, var(--primary), #764ba2);
  color: white;
  padding: 2em 1.5em;
  border-radius: var(--radius);
  text-align: center;
  margin-bottom: 1.5em;
}

.index-header h1 {
  font-size: 2em;
  margin-bottom: 0.3em;
}

.index-header p {
  font-size: 1.1em;
  opacity: 0.9;
}

.unit-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1em;
  margin-bottom: 1.5em;
}

.unit-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 1.2em;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}

.unit-card:hover {
  transform: translateY(-3px);
}

.unit-card h2 {
  font-size: 1.3em;
  color: var(--primary);
  margin-bottom: 0.5em;
}

.lesson-list {
  list-style: none;
}

.lesson-list li {
  margin-bottom: 0.4em;
}

.lesson-list a {
  display: block;
  padding: 0.5em 0.8em;
  color: var(--text);
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.2s;
  font-size: 0.95em;
}

.lesson-list a:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.lesson-list a::before {
  content: "📖 ";
}

.grammar-link {
  display: block;
  text-align: center;
  padding: 1em;
  background: linear-gradient(135deg, #FF9800, #F57C00);
  color: white;
  text-decoration: none;
  border-radius: var(--radius);
  font-size: 1.2em;
  font-weight: 700;
  margin-top: 1em;
  transition: transform 0.2s;
}

.grammar-link:hover {
  transform: translateY(-2px);
}

/* ===== Tab system for grammar ===== */
.tab-nav {
  display: flex;
  gap: 0.5em;
  margin-bottom: 1em;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 0.5em 1em;
  border: 2px solid var(--primary);
  background: white;
  color: var(--primary);
  border-radius: 25px;
  cursor: pointer;
  font-size: 0.9em;
  font-weight: 600;
  transition: all 0.3s;
}

.tab-btn.active {
  background: var(--primary);
  color: white;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ===== Cloze / Reading ===== */
.cloze-passage {
  padding: 1em;
  background: #FAFAFA;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  line-height: 2.2;
  margin-bottom: 1em;
}

.cloze-passage .blank-num {
  display: inline-block;
  font-weight: 700;
  color: var(--primary);
  margin: 0 0.1em;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  body { font-size: 20px; }
  .container { padding: 0.8em; }
  .page-header h1 { font-size: 1.4em; }
  .culture-card { flex-direction: column; }
  .culture-card img { width: 100%; height: 160px; }
  .word-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .sentence-with-img { flex-direction: column; text-align: center; }
}

@media (max-width: 480px) {
  body { font-size: 22px; }
  .page-header { padding: 1.2em 0.8em; }
  .section-card { padding: 1em; }
  .full-text { padding: 1em; }
  .word-grid { grid-template-columns: 1fr 1fr; }
  .index-header h1 { font-size: 1.5em; }
  .tab-nav { gap: 0.3em; }
  .tab-btn { padding: 0.4em 0.8em; font-size: 0.85em; }
}

/* Toggle full text visibility */
.full-text-toggle {
  display: inline-block;
  padding: 0.4em 1em;
  margin-bottom: 0.6em;
  background: var(--accent, #FF7043);
  color: #fff;
  border: none;
  border-radius: 20px;
  font-size: 0.85em;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}
.full-text-toggle:hover { opacity: 0.85; }
.full-text-toggle.hidden-state { background: #78909C; }
.full-text.text-hidden { display: none; }
