/* آکادمی ESP32 با میکروپایتون - استایل اصلی */
.epa-lesson-wrap, .epa-course-grid, .epa-toc, .epa-note, .epa-quiz, .epa-wokwi-embed, .epa-code-block {
	font-family: 'Vazirmatn', Tahoma, sans-serif;
	direction: rtl;
	text-align: right;
	box-sizing: border-box;
}
.epa-lesson-wrap *, .epa-course-grid *, .epa-quiz * { box-sizing: border-box; }

/* --- چیدمان کلی درس --- */
.epa-lesson-wrap {
	display: grid;
	grid-template-columns: 260px 1fr;
	gap: 30px;
	max-width: 1100px;
	margin: 0 auto;
}
@media (max-width: 782px) {
	.epa-lesson-wrap { grid-template-columns: 1fr; }
	.epa-lesson-sidebar { order: 2; }
}
.epa-lesson-body { min-width: 0; line-height: 2; font-size: 17px; }
.epa-lesson-body h2 { border-right: 5px solid #38bdf8; padding-right: 12px; margin-top: 40px; }
.epa-lesson-body h3 { color: #0369a1; margin-top: 30px; }
.epa-lesson-body img { max-width: 100%; height: auto; border-radius: 10px; margin: 14px 0; }

.epa-lesson-badges { display: flex; gap: 8px; margin-bottom: 20px; }
.epa-tag { display: inline-block; background: #f1f5f9; color: #334155; padding: 4px 12px; border-radius: 20px; font-size: 12.5px; }
.epa-tag-beginner { background: #dcfce7; color: #166534; }
.epa-tag-intermediate { background: #fef9c3; color: #854d0e; }
.epa-tag-advanced { background: #fee2e2; color: #991b1b; }

/* --- سایدبار / فهرست مطالب --- */
.epa-toc { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: 18px; position: sticky; top: 32px; max-height: calc(100vh - 64px); overflow-y: auto; }
.epa-toc h4, .epa-toc-title { margin-top: 0; color: #0f172a; font-size: 15px; }
.epa-toc ul { list-style: none; margin: 0; padding: 0; }
.epa-toc-item { padding: 8px 6px; border-radius: 8px; display: flex; align-items: center; gap: 8px; }
.epa-toc-item a { text-decoration: none; color: #334155; font-size: 13.5px; }
.epa-toc-item.is-active { background: #e0f2fe; }
.epa-toc-item.is-active a { color: #0369a1; font-weight: 700; }
.epa-toc-all { display: block; margin-top: 14px; font-size: 13px; color: #0284c7; text-decoration: none; }
.epa-lesson-check { color: #94a3b8; }
.epa-lesson-check.is-done { color: #16a34a; }

/* نوار پیشرفت «درس X از Y» */
.epa-toc-progress { margin-bottom: 12px; font-size: 12px; color: #475569; }
.epa-toc-progress-bar { background: #e2e8f0; border-radius: 20px; height: 6px; margin-top: 6px; overflow: hidden; }
.epa-toc-progress-bar span { display: block; height: 100%; background: linear-gradient(90deg, #38bdf8, #0ea5e9); border-radius: 20px; }

/* پرش سریع به فصل */
.epa-chapter-jump {
	width: 100%; padding: 9px 10px; border-radius: 8px; border: 1px solid #cbd5e1; background: #fff;
	font-family: inherit; font-size: 13px; color: #334155; margin-bottom: 14px;
}

/* منوی کامل دوره (همه فصل‌ها، باز/بسته‌شونده) */
.epa-toc-full { padding-top: 14px; }
.epa-toc-chapter { border-bottom: 1px solid #e2e8f0; padding: 6px 0; }
.epa-toc-chapter:last-of-type { border-bottom: none; }
.epa-toc-chapter summary {
	cursor: pointer; font-size: 13.5px; font-weight: 700; color: #0f172a;
	padding: 8px 6px; border-radius: 8px; list-style: none; display: flex; align-items: center; gap: 6px;
}
.epa-toc-chapter summary::-webkit-details-marker { display: none; }
.epa-toc-chapter summary::before { content: '›'; display: inline-block; transition: transform .15s ease; font-size: 16px; color: #38bdf8; }
.epa-toc-chapter[open] summary::before { transform: rotate(90deg); }
.epa-toc-chapter summary:hover { background: #f1f5f9; }
.epa-toc-chapter ul { margin: 4px 0 8px 0; padding-right: 14px; border-right: 2px solid #e2e8f0; }

/* خط اعتبار طراح */
.epa-credit { margin-top: 40px; padding-top: 14px; border-top: 1px dashed #cbd5e1; font-size: 12px; color: #94a3b8; text-align: center; }
.epa-credit a { color: #38bdf8; text-decoration: none; }
.epa-credit a:hover { text-decoration: underline; }

/* --- بنر بالای صفحهٔ اصلی دوره --- */
.epa-hero {
	background: linear-gradient(135deg, #0f172a 0%, #0c4a6e 55%, #075985 100%);
	color: #f8fafc; border-radius: 18px; padding: 46px 34px; text-align: center; margin-bottom: 30px;
	max-width: 1000px; margin-left: auto; margin-right: auto;
}
.epa-hero-badge {
	display: inline-block; background: rgba(56, 189, 248, .15); border: 1px solid rgba(56, 189, 248, .4);
	color: #7dd3fc; padding: 5px 16px; border-radius: 30px; font-size: 12.5px; margin-bottom: 16px;
}
.epa-hero h1 { font-size: 32px; margin: 0 0 12px; line-height: 1.5; }
.epa-hero p { color: #cbd5e1; font-size: 15.5px; max-width: 640px; margin: 0 auto; line-height: 2; }
.epa-hero-stats { display: flex; justify-content: center; gap: 34px; margin-top: 30px; flex-wrap: wrap; }
.epa-hero-stat { display: flex; flex-direction: column; align-items: center; }
.epa-hero-stat strong { font-size: 24px; color: #38bdf8; }
.epa-hero-stat span { font-size: 12.5px; color: #94a3b8; margin-top: 2px; }

/* --- ناوبری قبلی/بعدی --- */
.epa-lesson-nav { display: flex; justify-content: space-between; margin-top: 50px; gap: 12px; flex-wrap: wrap; }
.epa-lesson-nav a { background: #0f172a; color: #fff !important; padding: 12px 18px; border-radius: 10px; text-decoration: none; font-size: 14px; }
.epa-lesson-nav a:hover { background: #1e293b; }

/* --- دکمه تکمیل درس --- */
.epa-complete-wrap { margin: 30px 0; }
.epa-complete-btn { background: #16a34a; color: #fff; border: none; padding: 12px 24px; border-radius: 10px; cursor: pointer; font-size: 15px; font-family: inherit; }
.epa-complete-btn.is-done { background: #14532d; }
.epa-complete-msg { margin-right: 10px; color: #16a34a; font-size: 13px; }

/* --- جعبه‌های نکته --- */
.epa-note { border-radius: 10px; padding: 16px 18px; margin: 22px 0; border-right: 5px solid; }
.epa-note-tip { background: #f0fdf4; border-color: #22c55e; }
.epa-note-warning { background: #fff7ed; border-color: #f97316; }
.epa-note-info { background: #eff6ff; border-color: #3b82f6; }
.epa-note-project { background: #faf5ff; border-color: #a855f7; }
.epa-note-title { font-weight: 700; margin-bottom: 6px; }
.epa-note-body p:last-child { margin-bottom: 0; }

/* --- بلوک کد --- */
.epa-code-block { margin: 20px 0; border-radius: 10px; overflow: hidden; border: 1px solid #1e293b; direction: ltr; }
.epa-code-head { background: #1e293b; color: #94a3b8; padding: 8px 14px; display: flex; justify-content: space-between; align-items: center; font-size: 12px; direction: ltr; text-align: left; }
.epa-copy-btn { background: #334155; color: #e2e8f0; border: none; padding: 5px 12px; border-radius: 6px; cursor: pointer; font-size: 12px; font-family: inherit; }
.epa-copy-btn:hover { background: #475569; }
/* نکته مهم: direction به‌تنهایی متن انگلیسی/اعداد را داخل محتوای فارسی درست نمایش نمی‌دهد؛
   unicode-bidi: bidi-override این کار را با اجبار کامل چپ‌به‌راست تضمین می‌کند و از
   جابه‌جا/برعکس‌شدن حروف در کدها جلوگیری می‌کند. (این قوانین به همراه ویژگی dir و
   style درون‌خطی در PHP، سه لایه محافظت در برابر تداخل با CSS قالب هستند.) */
div.epa-code-block[dir="ltr"] pre[dir="ltr"],
div.epa-code-block[dir="ltr"] pre[dir="ltr"] code[dir="ltr"],
.epa-code-block pre,
.epa-code-block code {
	margin: 0;
	direction: ltr !important;
	unicode-bidi: bidi-override !important;
	text-align: left !important;
}
.epa-code-block pre * ,
.epa-code-block code * {
	direction: ltr !important;
	unicode-bidi: bidi-override !important;
}

/* --- شبیه‌ساز Wokwi --- */
.epa-wokwi-embed { border: 1px solid #1e293b; border-radius: 10px; overflow: hidden; margin: 24px 0; }
.epa-wokwi-head { background: #0f172a; color: #e2e8f0; padding: 10px 16px; display: flex; align-items: center; gap: 8px; font-size: 13px; }
.epa-wokwi-dot { width: 10px; height: 10px; background: #22c55e; border-radius: 50%; display: inline-block; }
.epa-wokwi-open { margin-right: auto; color: #38bdf8 !important; text-decoration: none; font-size: 12px; }
.epa-wokwi-caption { font-size: 12.5px; color: #64748b; background: #f8fafc; padding: 8px 16px; margin: 0; }

/* دکمهٔ بارگذاری تنبل شبیه‌ساز (برای سرعت بیشتر صفحه) */
.epa-wokwi-play {
	width: 100%; border: none; cursor: pointer; font-family: inherit;
	background: repeating-linear-gradient(135deg, #0f172a, #0f172a 12px, #111c34 12px, #111c34 24px);
	color: #e2e8f0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
}
.epa-wokwi-play-icon {
	width: 56px; height: 56px; border-radius: 50%; background: #38bdf8; color: #0f172a;
	display: flex; align-items: center; justify-content: center; font-size: 22px; margin-bottom: 6px;
}
.epa-wokwi-play-text { font-size: 14.5px; font-weight: 700; }
.epa-wokwi-play-sub { font-size: 11.5px; color: #94a3b8; }
.epa-wokwi-play:hover .epa-wokwi-play-icon { background: #7dd3fc; }

/* --- کوییز --- */
.epa-quiz { background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px; padding: 18px; margin: 26px 0; }
.epa-quiz-q { font-weight: 700; margin-bottom: 12px; }
.epa-quiz-options { display: flex; flex-direction: column; gap: 8px; }
.epa-quiz-opt { background: #fff; border: 1px solid #e2e8f0; padding: 10px 14px; border-radius: 8px; cursor: pointer; text-align: right; font-family: inherit; font-size: 14.5px; }
.epa-quiz-opt:hover { border-color: #f59e0b; }
.epa-quiz-opt.is-correct { background: #dcfce7; border-color: #22c55e; }
.epa-quiz-opt.is-wrong { background: #fee2e2; border-color: #ef4444; }
.epa-quiz-feedback { margin-top: 12px; font-weight: 700; }
.epa-quiz-explain { margin-top: 6px; font-size: 13.5px; color: #78716c; }

/* --- شبکه دوره (صفحه اصلی دوره) --- */
.epa-course-grid { max-width: 1000px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.epa-chapter-card { border: 1px solid #e2e8f0; border-radius: 16px; padding: 24px; background: #fff; transition: box-shadow .2s ease, transform .2s ease; }
.epa-chapter-card:hover { box-shadow: 0 10px 30px -12px rgba(15, 23, 42, .18); transform: translateY(-2px); }
.epa-chapter-head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 16px; }
.epa-chapter-num {
	background: linear-gradient(135deg, #0ea5e9, #0f172a);
	color: #fff; width: 40px; height: 40px; border-radius: 12px;
	display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; flex-shrink: 0;
}
.epa-chapter-head h3 { margin: 0 0 4px; font-size: 18px; }
.epa-chapter-head p { margin: 0; color: #64748b; font-size: 13.5px; }
.epa-lesson-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.epa-lesson-row { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 10px; transition: background .15s ease; }
.epa-lesson-row:hover { background: #f0f9ff; }
.epa-lesson-row a { text-decoration: none; color: #1e293b; font-size: 15px; flex-grow: 1; }
.epa-lesson-tags { display: flex; gap: 6px; }

/* =========================================================
 * ریسپانسیو کامل — موبایل، تبلت و صفحه‌های کوچک
 * ========================================================= */
@media (max-width: 960px) {
	.epa-hero { padding: 34px 22px; border-radius: 14px; }
	.epa-hero h1 { font-size: 24px; }
	.epa-hero-stats { gap: 20px; }
}

@media (max-width: 782px) {
	.epa-lesson-wrap { grid-template-columns: 1fr; gap: 18px; }
	.epa-lesson-sidebar { order: 2; }
	.epa-toc { position: static; max-height: none; }
	.epa-lesson-body { font-size: 16px; }
	.epa-chapter-head { flex-direction: row; }
	.epa-course-grid { padding: 0 4px; }
	.epa-lesson-nav { flex-direction: column; }
	.epa-lesson-nav a { width: 100%; text-align: center; }
	.epa-code-head span { font-size: 11px; }
	.epa-code-block pre { font-size: 13px; }
	.epa-wokwi-play { padding: 20px 12px; }
	.epa-wokwi-play-icon { width: 46px; height: 46px; font-size: 18px; }
}

@media (max-width: 480px) {
	.epa-hero h1 { font-size: 20px; line-height: 1.6; }
	.epa-hero p { font-size: 13.5px; }
	.epa-hero-stats { gap: 14px; }
	.epa-hero-stat strong { font-size: 19px; }
	.epa-chapter-num { width: 32px; height: 32px; font-size: 13px; }
	.epa-chapter-head h3 { font-size: 15.5px; }
	.epa-lesson-row a { font-size: 13.5px; }
	.epa-lesson-tags { flex-wrap: wrap; }
	.epa-quiz-opt { font-size: 13px; padding: 9px 12px; }
	.epa-guide-grid { grid-template-columns: 1fr !important; }
	.epa-wokwi-play-sub { display: none; }
}

/* استفاده از عرض کامل و جلوگیری از اسکرول افقی ناخواسته روی موبایل */
.epa-lesson-wrap, .epa-course-grid, .epa-hero { max-width: 100%; box-sizing: border-box; }
img { max-width: 100%; height: auto; }
