<!DOCTYPE html>
<html lang="vi">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mô phỏng Thí nghiệm: Biến đổi hoá học (Fe + S)</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Inter', sans-serif;
background-color: #f8fafc;
color: #1e293b;
}
/* Hiệu ứng lửa đèn cồn */
@keyframes flicker {
0%, 100% { transform: scale(1) rotate(-1deg); opacity: 0.95; }
25% { transform: scale(1.05, 0.95) rotate(1deg); opacity: 1; }
50% { transform: scale(0.96, 1.06) rotate(-1.5deg); opacity: 0.9; }
75% { transform: scale(1.03, 0.98) rotate(1.5deg); opacity: 1; }
}
.flame-anim {
transform-origin: 50% 100%;
animation: flicker 0.35s infinite ease-in-out;
}
/* Hiệu ứng phát sáng nóng đỏ */
@keyframes redGlow {
0%, 100% { filter: drop-shadow(0 0 8px rgba(239, 68, 68, 0.85)); }
50% { filter: drop-shadow(0 0 18px rgba(249, 115, 22, 1)); }
}
.glow-anim {
animation: redGlow 0.8s infinite ease-in-out;
}
/* Hiệu ứng khói nhẹ */
@keyframes riseSmoke {
0% { transform: translateY(0) scale(0.8); opacity: 0.6; }
100% { transform: translateY(-45px) scale(1.6); opacity: 0; }
}
.smoke-anim {
animation: riseSmoke 1.8s infinite ease-out;
}
/* Tùy chỉnh thanh cuộn */
::-webkit-scrollbar {
width: 8px;
}
::-webkit-scrollbar-track {
background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
background: #cbd5e1;
border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
background: #94a3b8;
}
</style>
</head>
<body class="min-h-screen flex flex-col">
<!-- Header -->
<header class="bg-gradient-to-r from-indigo-700 via-blue-700 to-cyan-700 text-white shadow-lg">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-5 flex flex-col md:flex-row items-center justify-between gap-4">
<div class="flex items-center gap-3">
<div class="bg-white/20 p-2.5 rounded-xl backdrop-blur-sm border border-white/30">
<svg class="w-8 h-8 text-amber-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19.428 15.428a2 2 0 00-1.022-.547l-2.387-.477a6 6 0 00-3.86.517l-.318.158a6 6 0 01-3.86.517L6.05 15.21a2 2 0 00-1.806.547M8 4h8l-1 1v5.172a2 2 0 00.586 1.414l5 5c1.26 1.26.367 3.414-1.415 3.414H4.828c-1.782 0-2.674-2.154-1.414-3.414l5-5A2 2 0 009 10.172V5L8 4z"></path>
</svg>
</div>
<div>
<span class="text-xs font-semibold uppercase tracking-wider bg-amber-400/20 text-amber-200 px-2.5 py-0.5 rounded-full border border-amber-300/30">Khoa học tự nhiên 8</span>
<h1 class="text-xl sm:text-2xl font-extrabold tracking-tight mt-1">Thí nghiệm về Biến đổi Hoá học: Sắt (Fe) phản ứng với Lưu huỳnh (S)</h1>
</div>
</div>
<button onclick="resetExperiment()" class="flex items-center gap-2 bg-white/15 hover:bg-white/25 active:scale-95 transition-all text-white font-medium px-4 py-2.5 rounded-xl border border-white/25 text-sm shadow-sm">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"></path>
</svg>
Làm lại thí nghiệm
</button>
</div>
</header>
<!-- Main Content -->
<main class="flex-grow max-w-7xl w-full mx-auto px-4 sm:px-6 lg:px-8 py-6 space-y-8">
<!-- Giới thiệu & Dụng cụ chuẩn bị -->
<section class="bg-white rounded-2xl shadow-sm border border-slate-200 p-5 sm:p-6">
<div class="flex flex-col lg:flex-row gap-6 justify-between">
<div class="space-y-2 lg:w-1/3">
<h2 class="text-base font-bold text-indigo-700 uppercase tracking-wide flex items-center gap-2">
<span class="w-2 h-2 rounded-full bg-indigo-600"></span>
Mục tiêu thí nghiệm
</h2>
<p class="text-sm text-slate-600 leading-relaxed">
Quan sát sự khác biệt giữa <strong>trộn lẫn hỗn hợp chất</strong> (biến đổi vật lí) và <strong>đun nóng tạo ra chất mới</strong> (biến đổi hoá học) thông qua phản ứng giữa bột sắt và bột lưu huỳnh.
</p>
</div>
<div class="lg:w-2/3 bg-slate-50 rounded-xl p-4 border border-slate-200/80">
<h3 class="text-sm font-bold text-slate-800 mb-3 flex items-center gap-2">
<svg class="w-4 h-4 text-blue-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2"></path>
</svg>
Chuẩn bị hoá chất & dụng cụ (Theo SGK):
</h3>
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-2.5 text-xs sm:text-sm">
<div class="flex items-center gap-2 bg-white p-2 rounded-lg border border-slate-200">
<span class="w-3 h-3 rounded-full bg-slate-700 shrink-0"></span>
<span><strong>Bột sắt (Fe):</strong> 7 phần khối lượng</span>
</div>
<div class="flex items-center gap-2 bg-white p-2 rounded-lg border border-slate-200">
<span class="w-3 h-3 rounded-full bg-yellow-400 shrink-0 border border-yellow-600"></span>
<span><strong>Bột lưu huỳnh (S):</strong> 4 phần khối lượng</span>
</div>
<div class="flex items-center gap-2 bg-white p-2 rounded-lg border border-slate-200">
<span class="text-blue-600 font-bold">🧪</span>
<span>2 ống nghiệm chịu nhiệt (1) và (2)</span>
</div>
<div class="flex items-center gap-2 bg-white p-2 rounded-lg border border-slate-200">
<span class="text-red-500 font-bold">🧲</span>
<span>Nam châm thanh / chữ U</span>
</div>
<div class="flex items-center gap-2 bg-white p-2 rounded-lg border border-slate-200">
<span class="text-orange-500 font-bold">🔥</span>
<span>Đèn cồn & Giá thí nghiệm</span>
</div>
<div class="flex items-center gap-2 bg-white p-2 rounded-lg border border-slate-200">
<span class="text-cyan-600 font-bold">🥄</span>
<span>Đũa thuỷ tinh, thìa thuỷ tinh</span>
</div>
</div>
</div>
</div>
</section>
<!-- Khu vực Mô phỏng Trực quan & Điều khiển -->
<section class="grid grid-cols-1 lg:grid-cols-12 gap-6 items-start">
<!-- Cột trái: Các nút bước thí nghiệm & Giải thích hiện tượng (5 cột) -->
<div class="lg:col-span-5 space-y-5">
<!-- Bảng chọn bước -->
<div class="bg-white rounded-2xl shadow-sm border border-slate-200 p-5">
<h2 class="text-base font-bold text-slate-800 mb-3 flex items-center justify-between">
<span>Các bước tiến hành thí nghiệm</span>
<span id="step-badge" class="text-xs font-semibold px-2.5 py-1 rounded-full bg-blue-100 text-blue-700">Bước 1 / 4</span>
</h2>
<div class="space-y-2.5" id="step-buttons">
<button onclick="setStep(1)" id="btn-step-1" class="step-btn w-full text-left p-3.5 rounded-xl border-2 transition-all flex items-start gap-3 bg-blue-50/70 border-blue-600 shadow-sm">
<span class="w-7 h-7 rounded-lg bg-blue-600 text-white font-bold text-sm flex items-center justify-center shrink-0 mt-0.5">1</span>
<div>
<div class="font-bold text-slate-900 text-sm">Trộn đều & Chia vào 2 ống nghiệm</div>
<div class="text-xs text-slate-600 mt-0.5">Trộn bột Fe và S tỉ lệ 7:4, cho vào ống (1) và (2) mỗi ống 3 thìa.</div>
</div>
</button>
<button onclick="setStep(2)" id="btn-step-2" class="step-btn w-full text-left p-3.5 rounded-xl border-2 transition-all flex items-start gap-3 bg-white border-slate-200 hover:border-blue-300">
<span class="w-7 h-7 rounded-lg bg-slate-200 text-slate-700 font-bold text-sm flex items-center justify-center shrink-0 mt-0.5">2</span>
<div>
<div class="font-bold text-slate-900 text-sm">Đưa nam châm lại gần ống nghiệm (1)</div>
<div class="text-xs text-slate-600 mt-0.5">Kiểm tra từ tính của hỗn hợp Fe và S trước khi đun nóng.</div>
</div>
</button>
<button onclick="setStep(3)" id="btn-step-3" class="step-btn w-full text-left p-3.5 rounded-xl border-2 transition-all flex items-start gap-3 bg-white border-slate-200 hover:border-blue-300">
<span class="w-7 h-7 rounded-lg bg-slate-200 text-slate-700 font-bold text-sm flex items-center justify-center shrink-0 mt-0.5">3</span>
<div>
<div class="font-bold text-slate-900 text-sm">Đun nóng mạnh đáy ống nghiệm (2)</div>
<div class="text-xs text-slate-600 mt-0.5">Đun bằng đèn cồn khoảng 30 giây rồi ngừng đun.</div>
</div>
</button>
<button onclick="setStep(4)" id="btn-step-4" class="step-btn w-full text-left p-3.5 rounded-xl border-2 transition-all flex items-start gap-3 bg-white border-slate-200 hover:border-blue-300">
<span class="w-7 h-7 rounded-lg bg-slate-200 text-slate-700 font-bold text-sm flex items-center justify-center shrink-0 mt-0.5">4</span>
<div>
<div class="font-bold text-slate-900 text-sm">Để nguội & Đưa nam châm gần ống (2)</div>
<div class="text-xs text-slate-600 mt-0.5">Kiểm tra từ tính của chất rắn thu được sau khi đun nóng.</div>
</div>
</button>
</div>
</div>
<!-- Bảng Hiện tượng quan sát & Giải thích -->
<div class="bg-gradient-to-br from-slate-800 to-slate-900 text-white rounded-2xl shadow-md p-5 border border-slate-700">
<div class="flex items-center gap-2 text-amber-400 font-bold text-sm uppercase tracking-wider mb-2">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"></path>
</svg>
Hiện tượng quan sát & Giải thích
</div>
<div id="observation-content" class="space-y-3 text-sm leading-relaxed text-slate-200">
<!-- Nội dung cập nhật động bằng JS -->
</div>
</div>
</div>
<!-- Cột phải: Phòng thí nghiệm mô phỏng SVG tương tác (7 cột) -->
<div class="lg:col-span-7 bg-white rounded-2xl shadow-sm border border-slate-200 p-4 sm:p-6 flex flex-col">
<div class="flex flex-wrap items-center justify-between gap-2 pb-3 mb-3 border-b border-slate-100">
<span class="text-sm font-bold text-slate-700 flex items-center gap-2">
<span class="w-2.5 h-2.5 rounded-full bg-emerald-500 animate-pulse"></span>
Khu vực mô phỏng trực quan
</span>
<!-- Chú thích màu sắc hạt -->
<div class="flex flex-wrap items-center gap-3 text-xs font-medium text-slate-600 bg-slate-50 px-3 py-1.5 rounded-lg border border-slate-200">
<span class="flex items-center gap-1.5">
<span class="w-2.5 h-2.5 rounded-full bg-slate-700 inline-block"></span> Bột sắt (Fe)
</span>
<span class="flex items-center gap-1.5">
<span class="w-2.5 h-2.5 rounded-full bg-yellow-400 border border-yellow-600 inline-block"></span> Bột lưu huỳnh (S)
</span>
<span class="flex items-center gap-1.5">
<span class="w-3 h-2.5 rounded-sm bg-zinc-800 inline-block"></span> Sắt(II) sulfide (FeS)
</span>
</div>
</div>
<!-- Khung SVG Lab -->
<div class="relative w-full bg-gradient-to-b from-sky-50/70 via-white to-slate-100 rounded-xl border border-slate-200 overflow-hidden select-none">
<svg id="lab-svg" viewBox="0 0 760 470" class="w-full h-auto block">
<defs>
<!-- Gradient thuỷ tinh ống nghiệm -->
<linearGradient id="glassGrad" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" stop-color="#ffffff" stop-opacity="0.65"/>
<stop offset="25%" stop-color="#e0f2fe" stop-opacity="0.2"/>
<stop offset="80%" stop-color="#bae6fd" stop-opacity="0.25"/>
<stop offset="100%" stop-color="#ffffff" stop-opacity="0.7"/>
</linearGradient>
<!-- Gradient kim loại giá đỡ -->
<linearGradient id="metalGrad" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" stop-color="#334155"/>
<stop offset="50%" stop-color="#64748b"/>
<stop offset="100%" stop-color="#1e293b"/>
</linearGradient>
<!-- Gradient ngọn lửa -->
<radialGradient id="flameOuter" cx="50%" cy="75%" r="55%">
<stop offset="0%" stop-color="#fef08a"/>
<stop offset="45%" stop-color="#f97316"/>
<stop offset="85%" stop-color="#dc2626" stop-opacity="0.8"/>
<stop offset="100%" stop-color="#dc2626" stop-opacity="0"/>
</radialGradient>
<radialGradient id="flameInner" cx="50%" cy="80%" r="50%">
<stop offset="0%" stop-color="#eff6ff"/>
<stop offset="60%" stop-color="#3b82f6"/>
<stop offset="100%" stop-color="#1d4ed8" stop-opacity="0"/>
</radialGradient>
<!-- Clip path cho bên trong 2 ống nghiệm -->
<clipPath id="tube1Clip">
<path d="M 192 120 L 248 120 L 248 312 A 28 28 0 0 1 192 312 Z" />
</clipPath>
<clipPath id="tube2Clip">
<path d="M 472 120 L 528 120 L 528 312 A 28 28 0 0 1 472 312 Z" />
</clipPath>
</defs>
<!-- Mặt bàn thí nghiệm -->
<rect x="0" y="425" width="760" height="45" fill="#cbd5e1" />
<line x1="0" y1="425" x2="760" y2="425" stroke="#94a3b8" stroke-width="2" />
<!-- ==================== HỆ THỐNG 1: ỐNG NGHIỆM (1) ==================== -->
<g id="stand-1">
<!-- Đế giá -->
<rect x="130" y="410" width="160" height="15" rx="3" fill="#1e293b" />
<!-- Trụ đứng -->
<rect x="155" y="70" width="10" height="340" rx="2" fill="url(#metalGrad)" />
<!-- Tay kẹp ngang -->
<rect x="150" y="155" width="75" height="8" rx="2" fill="url(#metalGrad)" />
<!-- Ốc vặn -->
<rect x="142" y="151" width="12" height="16" rx="2" fill="#0f172a" />
<!-- Vòng kẹp ống nghiệm -->
<rect x="188" y="150" width="64" height="18" rx="4" fill="#334155" />
</g>
<!-- Nhãn Ống nghiệm (1) -->
<g transform="translate(220, 88)">
<rect x="-56" y="-14" width="112" height="24" rx="12" fill="#e0e7ff" stroke="#6366f1" stroke-width="1.5"/>
<text x="0" y="2" text-anchor="middle" font-size="12" font-weight="700" fill="#3730a3">Ống nghiệm (1)</text>
</g>
<!-- Chất bên trong ống nghiệm (1) -->
<g id="tube1-contents" clip-path="url(#tube1Clip)"></g>
<!-- Vỏ thuỷ tinh ống nghiệm (1) -->
<g id="tube1-glass">
<path d="M 192 120 L 248 120 L 248 312 A 28 28 0 0 1 192 312 Z" fill="url(#glassGrad)" stroke="#64748b" stroke-width="2.5" />
<!-- Miệng ống -->
<ellipse cx="220" cy="120" rx="30" ry="5" fill="#f8fafc" stroke="#64748b" stroke-width="2" />
<!-- Kẹp đè lên trên kính -->
<rect x="188" y="152" width="64" height="14" rx="3" fill="#1e293b" opacity="0.9"/>
</g>
<!-- ==================== HỆ THỐNG 2: ỐNG NGHIỆM (2) ==================== -->
<g id="stand-2">
<!-- Đế giá -->
<rect x="430" y="410" width="210" height="15" rx="3" fill="#1e293b" />
<!-- Trụ đứng -->
<rect x="595" y="70" width="10" height="340" rx="2" fill="url(#metalGrad)" />
<!-- Tay kẹp ngang -->
<rect x="495" y="155" width="115" height="8" rx="2" fill="url(#metalGrad)" />
<!-- Ốc vặn -->
<rect x="605" y="151" width="12" height="16" rx="2" fill="#0f172a" />
<!-- Vòng kẹp ống nghiệm -->
<rect x="468" y="150" width="64" height="18" rx="4" fill="#334155" />
</g>
<!-- Nhãn Ống nghiệm (2) -->
<g transform="translate(500, 88)">
<rect x="-56" y="-14" width="112" height="24" rx="12" fill="#fef3c7" stroke="#d97706" stroke-width="1.5"/>
<text x="0" y="2" text-anchor="middle" font-size="12" font-weight="700" fill="#92400e">Ống nghiệm (2)</text>
</g>
<!-- Khói / Hơi lưu huỳnh nhẹ trong ống (2) khi đun -->
<g id="tube2-smoke" opacity="0" class="transition-opacity duration-500">
<circle cx="495" cy="240" r="8" fill="#fde047" class="smoke-anim" />
<circle cx="508" cy="220" r="10" fill="#fef08a" class="smoke-anim" style="animation-delay: 0.5s;" />
<circle cx="492" cy="195" r="7" fill="#cbd5e1" class="smoke-anim" style="animation-delay: 1s;" />
</g>
<!-- Chất bên trong ống nghiệm (2) -->
<g id="tube2-contents" clip-path="url(#tube2Clip)"></g>
<!-- Vỏ thuỷ tinh ống nghiệm (2) -->
<g id="tube2-glass">
<path d="M 472 120 L 528 120 L 528 312 A 28 28 0 0 1 472 312 Z" fill="url(#glassGrad)" stroke="#64748b" stroke-width="2.5" />
<ellipse cx="500" cy="120" rx="30" ry="5" fill="#f8fafc" stroke="#64748b" stroke-width="2" />
<rect x="468" y="152" width="64" height="14" rx="3" fill="#1e293b" opacity="0.9"/>
</g>
<!-- ==================== ĐÈN CỒN (Dưới ống nghiệm 2) ==================== -->
<g id="alcohol-lamp" transform="translate(500, 385)">
<!-- Ngọn lửa (ẩn mặc định, hiện ở Bước 3) -->
<g id="lamp-flame" opacity="0" class="transition-opacity duration-300">
<g class="flame-anim">
<!-- Quầng sáng ngoài -->
<path d="M 0 -55 C -22 -30 -24 -8 0 0 C 24 -8 22 -30 0 -55 Z" fill="url(#flameOuter)" />
<!-- Lõi xanh trong -->
<path d="M 0 -30 C -9 -16 -10 -4 0 0 C 10 -4 9 -16 0 -30 Z" fill="url(#flameInner)" />
</g>
</g>
<!-- Bấc đèn -->
<rect x="-3" y="-8" width="6" height="12" rx="1" fill="#475569" />
<!-- Cổ đèn kim loại -->
<rect x="-11" y="2" width="22" height="7" rx="2" fill="#94a3b8" stroke="#475569" stroke-width="1.5" />
<!-- Bầu thuỷ tinh chứa cồn -->
<path d="M -28 9 L 28 9 L 36 32 A 6 6 0 0 1 30 39 L -30 39 A 6 6 0 0 1 -36 32 Z" fill="#e0f2fe" stroke="#64748b" stroke-width="2" />
<!-- Mức cồn bên trong -->
<path d="M -31 20 L 31 20 L 34 32 A 5 5 0 0 1 29 37 L -29 37 A 5 5 0 0 1 -34 32 Z" fill="#38bdf8" opacity="0.45" />
<text x="0" y="31" text-anchor="middle" font-size="9" font-weight="700" fill="#0369a1">Đèn cồn</text>
</g>
<!-- ==================== NAM CHÂM TƯƠNG TÁC ==================== -->
<g id="magnet" transform="translate(-180, 290)" style="transition: transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);">
<!-- Đường sức từ (hiện khi nam châm lại gần) -->
<g id="magnetic-waves" opacity="0" class="transition-opacity duration-500">
<path d="M 102 -12 Q 116 0 102 12" fill="none" stroke="#ef4444" stroke-width="2" stroke-dasharray="3,2"/>
<path d="M 110 -18 Q 128 0 110 18" fill="none" stroke="#ef4444" stroke-width="1.5" stroke-dasharray="3,2"/>
</g>
<!-- Thân nam châm thanh: Cực S (Xanh) & Cực N (Đỏ) -->
<rect x="0" y="-16" width="50" height="32" rx="4" fill="#2563eb" stroke="#1e3a8a" stroke-width="1.5" />
<rect x="46" y="-16" width="50" height="32" rx="4" fill="#dc2626" stroke="#7f1d1d" stroke-width="1.5" />
<!-- Đường phân chia giữa -->
<line x1="48" y1="-16" x2="48" y2="16" stroke="#ffffff" stroke-width="1.5" />
<text x="24" y="5" text-anchor="middle" font-size="14" font-weight="800" fill="#ffffff">S</text>
<text x="72" y="5" text-anchor="middle" font-size="14" font-weight="800" fill="#ffffff">N</text>
<text x="48" y="30" text-anchor="middle" font-size="11" font-weight="700" fill="#334155">Nam châm</text>
</g>
<!-- Nhãn trạng thái nổi trên canvas -->
<g id="status-banner" transform="translate(380, 28)">
<rect x="-240" y="-16" width="480" height="30" rx="15" fill="#1e293b" />
<text id="status-banner-text" x="0" y="3" text-anchor="middle" font-size="12.5" font-weight="600" fill="#f8fafc">
Bước 1: Hỗn hợp bột Fe và S (tỉ lệ 7:4) được chia đều vào 2 ống nghiệm
</text>
</g>
</svg>
</div>
<!-- Thanh điều hướng nhanh dưới mô phỏng -->
<div class="mt-4 flex items-center justify-between gap-3">
<button onclick="prevStep()" id="btn-prev" class="px-4 py-2 rounded-xl border border-slate-300 text-slate-700 font-semibold text-sm hover:bg-slate-50 disabled:opacity-40 disabled:cursor-not-allowed transition-all">
← Bước trước
</button>
<div class="flex gap-1.5">
<span id="dot-1" class="w-2.5 h-2.5 rounded-full bg-blue-600 transition-all"></span>
<span id="dot-2" class="w-2.5 h-2.5 rounded-full bg-slate-300 transition-all"></span>
<span id="dot-3" class="w-2.5 h-2.5 rounded-full bg-slate-300 transition-all"></span>
<span id="dot-4" class="w-2.5 h-2.5 rounded-full bg-slate-300 transition-all"></span>
</div>
<button onclick="nextStep()" id="btn-next" class="px-4 py-2 rounded-xl bg-blue-600 text-white font-semibold text-sm hover:bg-blue-700 disabled:opacity-40 disabled:cursor-not-allowed transition-all shadow-sm">
Bước tiếp theo →
</button>
</div>
</div>
</section>
<!-- ==================== PHẦN 3: CÂU HỎI VẬN DỤNG ==================== -->
<section class="bg-white rounded-2xl shadow-sm border border-slate-200 p-5 sm:p-8">
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-4 pb-5 mb-6 border-b border-slate-200">
<div>
<span class="text-xs font-bold uppercase tracking-wider text-emerald-700 bg-emerald-100 px-3 py-1 rounded-full">Luyện tập & Vận dụng</span>
<h2 class="text-xl sm:text-2xl font-extrabold text-slate-900 mt-2">3 Câu hỏi Vận dụng Bám sát Thí nghiệm</h2>
<p class="text-sm text-slate-600 mt-1">Chọn đáp án đúng nhất cho từng câu hỏi và nhấn kiểm tra để xem lời giải chi tiết.</p>
</div>
<div class="flex items-center gap-3">
<div id="score-box" class="hidden px-4 py-2 rounded-xl bg-indigo-50 border border-indigo-200 text-indigo-800 font-bold text-sm">
Kết quả: <span id="score-value">0</span>/3 câu đúng
</div>
<button onclick="checkAllAnswers()" class="px-5 py-2.5 rounded-xl bg-emerald-600 hover:bg-emerald-700 text-white font-bold text-sm shadow-sm transition-all active:scale-95">
Kiểm tra đáp án
</button>
</div>
</div>
<div class="space-y-6" id="quiz-container">
<!-- Câu 1 -->
<div class="quiz-card p-5 rounded-2xl bg-slate-50 border border-slate-200 transition-all" data-question="1" data-correct="B">
<div class="flex items-start justify-between gap-3">
<h3 class="font-bold text-slate-900 text-base leading-snug">
<span class="text-blue-600 mr-1">Câu 1:</span>
Vì sao trong bước chuẩn bị lại trộn bột sắt (Fe) và bột lưu huỳnh (S) theo tỉ lệ khối lượng <span class="font-mono bg-white px-1.5 py-0.5 rounded border">7 : 4</span>? Nếu dùng dư bột sắt so với tỉ lệ này thì sau khi đun nóng và để nguội, đưa nam châm lại gần ống nghiệm (2) sẽ có hiện tượng gì?
</h3>
</div>
<div class="mt-4 grid grid-cols-1 md:grid-cols-2 gap-3">
<label class="option-label flex items-start gap-3 p-3.5 rounded-xl bg-white border border-slate-200 cursor-pointer hover:border-blue-400 transition-all">
<input type="radio" name="q1" value="A" class="mt-1 accent-blue-600">
<span class="text-sm text-slate-700"><strong>A.</strong> Để phản ứng xảy ra nhanh hơn; nếu dư sắt thì chất rắn sau đun nóng vẫn hoàn toàn không bị nam châm hút.</span>
</label>
<label class="option-label flex items-start gap-3 p-3.5 rounded-xl bg-white border border-slate-200 cursor-pointer hover:border-blue-400 transition-all">
<input type="radio" name="q1" value="B" class="mt-1 accent-blue-600">
<span class="text-sm text-slate-700"><strong>B.</strong> Để Fe và S phản ứng vừa đủ với nhau tạo thành FeS; nếu dùng dư sắt thì phần bột sắt còn dư sẽ bị nam châm hút.</span>
</label>
<label class="option-label flex items-start gap-3 p-3.5 rounded-xl bg-white border border-slate-200 cursor-pointer hover:border-blue-400 transition-all">
<input type="radio" name="q1" value="C" class="mt-1 accent-blue-600">
<span class="text-sm text-slate-700"><strong>C.</strong> Để tạo ra hỗn hợp có màu vàng đẹp mắt; nếu dư sắt thì ống nghiệm sẽ bị nứt vỡ khi đun nóng.</span>
</label>
<label class="option-label flex items-start gap-3 p-3.5 rounded-xl bg-white border border-slate-200 cursor-pointer hover:border-blue-400 transition-all">
<input type="radio" name="q1" value="D" class="mt-1 accent-blue-600">
<span class="text-sm text-slate-700"><strong>D.</strong> Vì khối lượng riêng của sắt gấp 7/4 lần lưu huỳnh; nếu dư sắt thì lưu huỳnh sẽ bị nam châm hút theo.</span>
</label>
</div>
<div class="mt-3 flex justify-end">
<button type="button" onclick="toggleExplanation(1)" class="text-xs font-semibold text-blue-600 hover:text-blue-800 flex items-center gap-1">
<span>Xem gợi ý & giải thích chi tiết</span>
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg>
</button>
</div>
<div id="exp-1" class="hidden mt-3 p-4 rounded-xl bg-blue-50/90 border border-blue-200 text-sm text-slate-700 leading-relaxed">
<p class="font-bold text-blue-900 mb-1">💡 Giải thích chi tiết (Đáp án đúng: B):</p>
<p>• Theo phương trình hoá học: <span class="font-mono font-semibold">Fe + S → FeS</span>, cứ 1 nguyên tử Fe (56 amu) phản ứng vừa đủ với 1 nguyên tử S (32 amu). Tỉ lệ khối lượng là <span class="font-mono">56 : 32 = 7 : 4</span>. Việc lấy đúng tỉ lệ 7 : 4 giúp hai chất phản ứng vừa hết với nhau, sản phẩm thu được chỉ có FeS tinh khiết (không có từ tính).</p>
<p class="mt-1">• Nếu lấy <strong>dư bột sắt (Fe)</strong>, sau khi phản ứng kết thúc vẫn còn lẫn bột Fe chưa phản ứng. Do đó, khi đưa nam châm lại gần ống nghiệm (2), <strong>phần bột sắt còn dư sẽ bị nam châm hút</strong> (còn hợp chất FeS thì không bị hút).</p>
</div>
</div>
<!-- Câu 2 -->
<div class="quiz-card p-5 rounded-2xl bg-slate-50 border border-slate-200 transition-all" data-question="2" data-correct="C">
<div class="flex items-start justify-between gap-3">
<h3 class="font-bold text-slate-900 text-base leading-snug">
<span class="text-blue-600 mr-1">Câu 2:</span>
Trong thực tế, một bạn học sinh làm thí nghiệm nhưng <strong>quên bước đun nóng</strong> mà chỉ khuấy đều hỗn hợp bột sắt (Fe) và bột lưu huỳnh (S) thật lâu rồi đưa nam châm lại gần. Hiện tượng xảy ra là gì và quá trình bạn đó vừa thực hiện thuộc loại biến đổi nào?
</h3>
</div>
<div class="mt-4 grid grid-cols-1 md:grid-cols-2 gap-3">
<label class="option-label flex items-start gap-3 p-3.5 rounded-xl bg-white border border-slate-200 cursor-pointer hover:border-blue-400 transition-all">
<input type="radio" name="q2" value="A" class="mt-1 accent-blue-600">
<span class="text-sm text-slate-700"><strong>A.</strong> Nam châm không hút được chất nào vì khuấy lâu đã tạo thành hợp chất FeS; đây là biến đổi hoá học.</span>
</label>
<label class="option-label flex items-start gap-3 p-3.5 rounded-xl bg-white border border-slate-200 cursor-pointer hover:border-blue-400 transition-all">
<input type="radio" name="q2" value="B" class="mt-1 accent-blue-600">
<span class="text-sm text-slate-700"><strong>B.</strong> Nam châm hút cả bột sắt lẫn bột lưu huỳnh; đây là biến đổi hoá học.</span>
</label>
<label class="option-label flex items-start gap-3 p-3.5 rounded-xl bg-white border border-slate-200 cursor-pointer hover:border-blue-400 transition-all">
<input type="radio" name="q2" value="C" class="mt-1 accent-blue-600">
<span class="text-sm text-slate-700"><strong>C.</strong> Nam châm hút các hạt bột sắt tách ra khỏi bột lưu huỳnh; đây là biến đổi vật lí vì không có chất mới tạo thành.</span>
</label>
<label class="option-label flex items-start gap-3 p-3.5 rounded-xl bg-white border border-slate-200 cursor-pointer hover:border-blue-400 transition-all">
<input type="radio" name="q2" value="D" class="mt-1 accent-blue-600">
<span class="text-sm text-slate-700"><strong>D.</strong> Hỗn hợp tự bốc cháy và toả nhiệt mạnh; đây là biến đổi vật lí.</span>
</label>
</div>
<div class="mt-3 flex justify-end">
<button type="button" onclick="toggleExplanation(2)" class="text-xs font-semibold text-blue-600 hover:text-blue-800 flex items-center gap-1">
<span>Xem gợi ý & giải thích chi tiết</span>
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg>
</button>
</div>
<div id="exp-2" class="hidden mt-3 p-4 rounded-xl bg-blue-50/90 border border-blue-200 text-sm text-slate-700 leading-relaxed">
<p class="font-bold text-blue-900 mb-1">💡 Giải thích chi tiết (Đáp án đúng: C):</p>
<p>• Phản ứng giữa sắt và lưu huỳnh cần có nhiệt độ cao (đun nóng) để khơi mào. Khi chỉ khuấy trộn ở nhiệt độ thường, các hạt bột Fe và S chỉ xen kẽ vào nhau chứ <strong>không xảy ra phản ứng hoá học</strong>.</p>
<p class="mt-1">• Mỗi chất vẫn giữ nguyên tính chất ban đầu (sắt vẫn có tính nhiễm từ nên bị nam châm hút tách ra, lưu huỳnh màu vàng ở lại). Vì <strong>không có chất mới sinh ra</strong> nên đây chỉ là <strong>biến đổi vật lí</strong>.</p>
</div>
</div>
<!-- Câu 3 -->
<div class="quiz-card p-5 rounded-2xl bg-slate-50 border border-slate-200 transition-all" data-question="3" data-correct="A">
<div class="flex items-start justify-between gap-3">
<h3 class="font-bold text-slate-900 text-base leading-snug">
<span class="text-blue-600 mr-1">Câu 3:</span>
Khi làm vỡ nhiệt kế thuỷ ngân (Hg), người ta thường rắc bột lưu huỳnh (S) lên các giọt thuỷ ngân rơi vãi để tạo thành hợp chất rắn thuỷ ngân(II) sulfide (HgS) không bay hơi, dễ thu gom và tránh ngộ độc. Dựa vào kiến thức từ thí nghiệm trên, việc rắc bột lưu huỳnh xử lí thuỷ ngân rơi vãi thuộc loại biến đổi nào? Vì sao?
</h3>
</div>
<div class="mt-4 grid grid-cols-1 md:grid-cols-2 gap-3">
<label class="option-label flex items-start gap-3 p-3.5 rounded-xl bg-white border border-slate-200 cursor-pointer hover:border-blue-400 transition-all">
<input type="radio" name="q3" value="A" class="mt-1 accent-blue-600">
<span class="text-sm text-slate-700"><strong>A.</strong> Biến đổi hoá học, vì thuỷ ngân (Hg) đã tác dụng với lưu huỳnh (S) tạo ra chất mới là thuỷ ngân(II) sulfide (HgS) có tính chất khác ban đầu.</span>
</label>
<label class="option-label flex items-start gap-3 p-3.5 rounded-xl bg-white border border-slate-200 cursor-pointer hover:border-blue-400 transition-all">
<input type="radio" name="q3" value="B" class="mt-1 accent-blue-600">
<span class="text-sm text-slate-700"><strong>B.</strong> Biến đổi vật lí, vì bột lưu huỳnh chỉ thấm hút các giọt thuỷ ngân lỏng giống như bông thấm nước.</span>
</label>
<label class="option-label flex items-start gap-3 p-3.5 rounded-xl bg-white border border-slate-200 cursor-pointer hover:border-blue-400 transition-all">
<input type="radio" name="q3" value="C" class="mt-1 accent-blue-600">
<span class="text-sm text-slate-700"><strong>C.</strong> Biến đổi vật lí, vì trạng thái của thuỷ ngân chuyển từ thể lỏng sang thể rắn (đông đặc).</span>
</label>
<label class="option-label flex items-start gap-3 p-3.5 rounded-xl bg-white border border-slate-200 cursor-pointer hover:border-blue-400 transition-all">
<input type="radio" name="q3" value="D" class="mt-1 accent-blue-600">
<span class="text-sm text-slate-700"><strong>D.</strong> Không có sự biến đổi nào xảy ra vì lưu huỳnh không phản ứng được với kim loại ở nhiệt độ thường.</span>
</label>
</div>
<div class="mt-3 flex justify-end">
<button type="button" onclick="toggleExplanation(3)" class="text-xs font-semibold text-blue-600 hover:text-blue-800 flex items-center gap-1">
<span>Xem gợi ý & giải thích chi tiết</span>
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path></svg>
</button>
</div>
<div id="exp-3" class="hidden mt-3 p-4 rounded-xl bg-blue-50/90 border border-blue-200 text-sm text-slate-700 leading-relaxed">
<p class="font-bold text-blue-900 mb-1">💡 Giải thích chi tiết (Đáp án đúng: A):</p>
<p>• Khác với sắt cần đun nóng, thuỷ ngân (Hg) phản ứng trực tiếp với lưu huỳnh (S) ngay ở nhiệt độ thường tạo thành chất mới là <strong>thuỷ ngân(II) sulfide (HgS)</strong> dạng rắn, màu đen, không bay hơi và ít độc hơn nhiều so với hơi thuỷ ngân.</p>
<p class="mt-1">• Vì có <strong>chất mới (HgS) được tạo thành</strong> với tính chất hoàn toàn khác với chất ban đầu (Hg lỏng, độc, dễ bay hơi và S bột màu vàng) nên quá trình này là <strong>biến đổi hoá học</strong>.</p>
</div>
</div>
</div>
</section>
</main>
<!-- Footer -->
<footer class="bg-slate-900 text-slate-400 py-5 text-center text-xs border-t border-slate-800">
<p>Mô phỏng tương tác Khoa học tự nhiên 8 — Bài: Biến đổi vật lí và biến đổi hoá học.</p>
</footer>
<!-- Message Toast Box (thay thế alert) -->
<div id="toast-box" class="fixed bottom-5 right-5 z-50 transform translate-y-20 opacity-0 transition-all duration-300 pointer-events-none">
<div id="toast-inner" class="bg-slate-900 text-white px-4 py-3 rounded-xl shadow-xl border border-slate-700 text-sm font-medium flex items-center gap-2.5">
<span id="toast-icon">ℹ️</span>
<span id="toast-msg">Thông báo</span>
</div>
</div>
<script>
// Trạng thái hiện tại của thí nghiệm (1 đến 4)
let currentStep = 1;
// Dữ liệu hạt bột trong ống nghiệm (1) và (2)
// Mỗi hạt gồm: loại ('Fe' hoặc 'S'), vị trí trộn đều (mixX, mixY), vị trí khi hút nam châm (magX, magY)
const particlesTube1 = [];
const particlesTube2 = [];
// Khởi tạo tọa độ hạt ngẫu nhiên có kiểm soát bên trong đáy ống nghiệm
function initParticles() {
particlesTube1.length = 0;
particlesTube2.length = 0;
// Tạo 66 hạt cho mỗi ống (tỉ lệ hạt mô phỏng ~ 7 Fe : 4 S -> 42 Fe, 24 S)
const total = 66;
for (let i = 0; i < total; i++) {
const isFe = i < 42;
// Vị trí trộn đều ở đáy ống (1): x từ 197..243, y từ 282..334
const row = Math.floor(i / 11);
const col = i % 11;
const jitterX = ((i * 17) % 5) - 2;
const jitterY = ((i * 13) % 5) - 2;
const t1MixX = 198 + col * 4.3 + jitterX;
const t1MixY = 282 + row * 8.5 + jitterY;
// Khi nam châm đưa lại gần bên trái ống (1) (x ~ 192):
// Hạt Fe bị hút dồn sát thành trái (x từ 195..206, y từ 262..328)
// Hạt S rơi/nằm lại ở đáy và lệch phải (x từ 208..244, y từ 302..335)
let t1MagX, t1MagY;
if (isFe) {
const feIdx = i;
t1MagX = 195 + (feIdx % 3) * 3.8 + (feIdx % 2);
t1MagY = 262 + Math.floor(feIdx / 3) * 4.8;
} else {
const sIdx = i - 42;
t1MagX = 209 + (sIdx % 6) * 5.8 + (sIdx % 2);
t1MagY = 306 + Math.floor(sIdx / 6) * 7.5;
}
particlesTube1.push({
type: isFe ? 'Fe' : 'S',
mixX: clampInTube(t1MixX, t1MixY, 220),
mixY: t1MixY,
magX: clampInTube(t1MagX, t1MagY, 220),
magY: t1MagY
});
// Vị trí trộn đều ở đáy ống (2): x từ 477..523, y từ 282..334
const t2MixX = 478 + col * 4.3 + jitterX;
const t2MixY = 282 + row * 8.5 + jitterY;
particlesTube2.push({
type: isFe ? 'Fe' : 'S',
mixX: clampInTube(t2MixX, t2MixY, 500),
mixY: t2MixY
});
}
// Xáo trộn thứ tự vẽ để hạt Fe và S xen kẽ tự nhiên
shuffleArray(particlesTube1);
shuffleArray(particlesTube2);
}
// Đảm bảo hạt không vượt ra ngoài phần đáy bo tròn của ống nghiệm (bán kính 28, tâm bo tròn y = 312)
function clampInTube(x, y, centerX) {
const minX = centerX - 24;
const maxX = centerX + 24;
let cx = Math.max(minX, Math.min(maxX, x));
if (y > 312) {
const dy = y - 312;
const maxDx = Math.sqrt(Math.max(0, 24 * 24 - dy * dy));
cx = Math.max(centerX - maxDx, Math.min(centerX + maxDx, cx));
}
return cx;
}
function shuffleArray(arr) {
for (let i = arr.length - 1; i > 0; i--) {
const j = (i * 29 + 7) % (i + 1);
[arr[i], arr[j]] = [arr[j], arr[i]];
}
}
// Vẽ các hạt vào SVG lần đầu
function renderInitialSVG() {
const g1 = document.getElementById('tube1-contents');
const g2 = document.getElementById('tube2-contents');
g1.innerHTML = '';
g2.innerHTML = '';
// Vẽ hạt ống nghiệm (1)
particlesTube1.forEach((p, idx) => {
const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
circle.setAttribute('id', `t1-p-${idx}`);
circle.setAttribute('cx', p.mixX);
circle.setAttribute('cy', p.mixY);
circle.setAttribute('r', p.type === 'Fe' ? '3.1' : '3.3');
circle.setAttribute('fill', p.type === 'Fe' ? '#334155' : '#facc15');
circle.setAttribute('stroke', p.type === 'Fe' ? '#0f172a' : '#ca8a04');
circle.setAttribute('stroke-width', '0.6');
circle.style.transition = 'all 0.85s cubic-bezier(0.34, 1.56, 0.64, 1)';
g1.appendChild(circle);
});
// Vẽ nhóm hạt rời ống nghiệm (2) (hiển thị ở Bước 1 & 2)
const g2Powder = document.createElementNS('http://www.w3.org/2000/svg', 'g');
g2Powder.setAttribute('id', 't2-powder-group');
g2Powder.style.transition = 'opacity 0.6s ease';
particlesTube2.forEach((p) => {
const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
circle.setAttribute('cx', p.mixX);
circle.setAttribute('cy', p.mixY);
circle.setAttribute('r', p.type === 'Fe' ? '3.1' : '3.3');
circle.setAttribute('fill', p.type === 'Fe' ? '#334155' : '#facc15');
circle.setAttribute('stroke', p.type === 'Fe' ? '#0f172a' : '#ca8a04');
circle.setAttribute('stroke-width', '0.6');
g2Powder.appendChild(circle);
});
g2.appendChild(g2Powder);
// Vẽ khối chất rắn FeS sau phản ứng trong ống (2) (ẩn ở Bước 1 & 2, hiện ở Bước 3 & 4)
const g2Solid = document.createElementNS('http://www.w3.org/2000/svg', 'g');
g2Solid.setAttribute('id', 't2-solid-group');
g2Solid.setAttribute('opacity', '0');
g2Solid.style.transition = 'opacity 0.8s ease';
// Khối rắn xốp màu đen xám Sắt(II) sulfide (FeS)
const solidBlock = document.createElementNS('http://www.w3.org/2000/svg', 'path');
solidBlock.setAttribute('id', 'fes-block');
solidBlock.setAttribute('d', 'M 472 286 Q 486 281 500 287 Q 514 282 528 286 L 528 312 A 28 28 0 0 1 472 312 Z');
solidBlock.setAttribute('fill', '#27272a');
solidBlock.setAttribute('stroke', '#18181b');
solidBlock.setAttribute('stroke-width', '1.5');
g2Solid.appendChild(solidBlock);
// Các vân xốp trên bề mặt khối FeS
const pores = [
{ cx: 486, cy: 300, r: 2.2 },
{ cx: 502, cy: 296, r: 2.5 },
{ cx: 515, cy: 304, r: 2 },
{ cx: 493, cy: 318, r: 2.8 },
{ cx: 509, cy: 322, r: 2.3 },
{ cx: 500, cy: 330, r: 2 }
];
pores.forEach(pt => {
const c = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
c.setAttribute('cx', pt.cx);
c.setAttribute('cy', pt.cy);
c.setAttribute('r', pt.r);
c.setAttribute('fill', '#3f3f46');
g2Solid.appendChild(c);
});
g2.appendChild(g2Solid);
}
// Nội dung giải thích chi tiết từng bước
const stepDetails = {
1: {
banner: "Bước 1: Trộn đều bột Fe và S (tỉ lệ 7:4), chia vào 2 ống nghiệm (1) và (2)",
html: `
<p><strong class="text-white">Thao tác:</strong> Trộn đều bột sắt (màu xám đen) và bột lưu huỳnh (màu vàng) theo tỉ lệ khối lượng <strong>7 : 4</strong>, sau đó chia đều vào 2 ống nghiệm (1) và (2), mỗi ống 3 thìa hỗn hợp.</p>
<p><strong class="text-emerald-300">Hiện tượng:</strong> Thu được hỗn hợp bột đồng nhất có màu vàng xám (các hạt sắt và lưu huỳnh nằm xen kẽ nhau).</p>
<p><strong class="text-amber-300">Nhận xét:</strong> Chưa có sự biến đổi chất nào xảy ra, hai chất chỉ trộn lẫn vật lí với nhau.</p>
`
},
2: {
banner: "Bước 2: Đưa nam châm lại gần ống nghiệm (1) → Bột sắt bị hút tách ra",
html: `
<p><strong class="text-white">Thao tác:</strong> Đưa thanh nam châm lại sát thành ống nghiệm (1).</p>
<p><strong class="text-emerald-300">Hiện tượng:</strong> Các hạt <strong>bột sắt (Fe)</strong> màu xám đen bị nam châm hút mạnh, di chuyển tập trung về phía thành ống nghiệm gần nam châm; trong khi <strong>bột lưu huỳnh (S)</strong> màu vàng không bị hút và ở lại đáy ống.</p>
<p><strong class="text-amber-300">Giải thích:</strong> Sau khi trộn, Fe và S vẫn giữ nguyên tính chất riêng ban đầu (Fe có từ tính). <strong>Không có chất mới tạo thành</strong> → Đây là <strong>biến đổi vật lí</strong>.</p>
`
},
3: {
banner: "Bước 3: Đun nóng mạnh đáy ống nghiệm (2) → Phản ứng toả nhiệt, tạo FeS",
html: `
<p><strong class="text-white">Thao tác:</strong> Đun nóng mạnh đáy ống nghiệm (2) trên ngọn lửa đèn cồn khoảng 30 giây rồi ngừng đun.</p>
<p><strong class="text-emerald-300">Hiện tượng:</strong> Hỗn hợp nóng chảy, <strong>cháy nóng đỏ rực lên</strong>, phản ứng toả nhiều nhiệt (vẫn tiếp tục nóng đỏ ngay cả khi ngừng đun) và chuyển dần thành một <strong>khối chất rắn xốp màu đen xám</strong>.</p>
<p><strong class="text-amber-300">Giải thích:</strong> Sắt đã phản ứng hoá học với lưu huỳnh tạo ra chất mới là <strong>Sắt(II) sulfide (FeS)</strong>: <br><span class="font-mono bg-slate-950 px-2 py-0.5 rounded text-cyan-300 inline-block mt-1">Sắt (Fe) + Lưu huỳnh (S) —t°→ Sắt(II) sulfide (FeS)</span></p>
`
},
4: {
banner: "Bước 4: Để nguội & đưa nam châm gần ống (2) → Chất rắn FeS không bị hút",
html: `
<p><strong class="text-white">Thao tác:</strong> Để ống nghiệm (2) nguội hẳn về nhiệt độ phòng, sau đó đưa nam châm lại sát thành ống nghiệm (2).</p>
<p><strong class="text-emerald-300">Hiện tượng:</strong> Khối chất rắn màu đen xám trong ống nghiệm (2) <strong>không bị nam châm hút</strong>.</p>
<p><strong class="text-amber-300">Kết luận:</strong> Chất thu được không còn tính chất từ của sắt và màu vàng của lưu huỳnh. Chứng tỏ <strong>đã có chất mới (FeS) được tạo thành</strong> → Quá trình đun nóng hỗn hợp Fe và S là <strong>biến đổi hoá học</strong>.</p>
`
}
};
// Cập nhật giao diện và hoạt ảnh theo bước
function setStep(step) {
currentStep = step;
// 1. Cập nhật trạng thái các nút Bước 1..4
for (let i = 1; i <= 4; i++) {
const btn = document.getElementById(`btn-step-${i}`);
const numBadge = btn.querySelector('span');
const dot = document.getElementById(`dot-${i}`);
if (i === step) {
btn.className = 'step-btn w-full text-left p-3.5 rounded-xl border-2 transition-all flex items-start gap-3 bg-blue-50/80 border-blue-600 shadow-sm';
numBadge.className = 'w-7 h-7 rounded-lg bg-blue-600 text-white font-bold text-sm flex items-center justify-center shrink-0 mt-0.5';
dot.className = 'w-5 h-2.5 rounded-full bg-blue-600 transition-all';
} else {
btn.className = 'step-btn w-full text-left p-3.5 rounded-xl border-2 transition-all flex items-start gap-3 bg-white border-slate-200 hover:border-blue-300';
numBadge.className = 'w-7 h-7 rounded-lg bg-slate-200 text-slate-700 font-bold text-sm flex items-center justify-center shrink-0 mt-0.5';
dot.className = 'w-2.5 h-2.5 rounded-full bg-slate-300 transition-all';
}
}
// 2. Cập nhật badge & nút điều hướng
document.getElementById('step-badge').textContent = `Bước ${step} / 4`;
document.getElementById('btn-prev').disabled = (step === 1);
document.getElementById('btn-next').disabled = (step === 4);
// 3. Cập nhật bảng giải thích & banner SVG
document.getElementById('observation-content').innerHTML = stepDetails[step].html;
document.getElementById('status-banner-text').textContent = stepDetails[step].banner;
// 4. Điều khiển hoạt ảnh SVG
const magnet = document.getElementById('magnet');
const magWaves = document.getElementById('magnetic-waves');
const lampFlame = document.getElementById('lamp-flame');
const tube2Smoke = document.getElementById('tube2-smoke');
const t2Powder = document.getElementById('t2-powder-group');
const t2Solid = document.getElementById('t2-solid-group');
const fesBlock = document.getElementById('fes-block');
if (step === 1) {
// Nam châm cất ngoài khung
magnet.setAttribute('transform', 'translate(-180, 290)');
magWaves.setAttribute('opacity', '0');
// Hạt trong ống (1) trộn đều
particlesTube1.forEach((p, idx) => {
const el = document.getElementById(`t1-p-${idx}`);
el.setAttribute('cx', p.mixX);
el.setAttribute('cy', p.mixY);
});
// Ống (2) là bột trộn đều, tắt lửa
lampFlame.setAttribute('opacity', '0');
tube2Smoke.setAttribute('opacity', '0');
t2Powder.setAttribute('opacity', '1');
t2Solid.setAttribute('opacity', '0');
fesBlock.classList.remove('glow-anim');
fesBlock.setAttribute('fill', '#27272a');
}
else if (step === 2) {
// Đưa nam châm lại sát bên trái ống nghiệm (1) (mép ống 1 ở x = 192 -> đầu cực N ở x = 186)
magnet.setAttribute('transform', 'translate(90, 290)');
magWaves.setAttribute('opacity', '1');
// Hạt Fe trong ống (1) bị hút dồn sát thành trái, hạt S ở lại
particlesTube1.forEach((p, idx) => {
const el = document.getElementById(`t1-p-${idx}`);
el.setAttribute('cx', p.magX);
el.setAttribute('cy', p.magY);
});
// Ống (2) vẫn là bột trộn đều, tắt lửa
lampFlame.setAttribute('opacity', '0');
tube2Smoke.setAttribute('opacity', '0');
t2Powder.setAttribute('opacity', '1');
t2Solid.setAttribute('opacity', '0');
fesBlock.classList.remove('glow-anim');
}
else if (step === 3) {
// Cất nam châm khỏi ống (1), trả hạt ống (1) về trạng thái trộn
magnet.setAttribute('transform', 'translate(-180, 290)');
magWaves.setAttribute('opacity', '0');
particlesTube1.forEach((p, idx) => {
const el = document.getElementById(`t1-p-${idx}`);
el.setAttribute('cx', p.mixX);
el.setAttribute('cy', p.mixY);
});
// Bật đèn cồn dưới ống (2), hỗn hợp nóng đỏ rực thành FeS
lampFlame.setAttribute('opacity', '1');
tube2Smoke.setAttribute('opacity', '1');
t2Powder.setAttribute('opacity', '0');
t2Solid.setAttribute('opacity', '1');
fesBlock.setAttribute('fill', '#b91c1c'); // Đỏ rực do phản ứng toả nhiệt
fesBlock.classList.add('glow-anim');
}
else if (step === 4) {
// Tắt đèn cồn, để nguội (khối FeS chuyển sang đen xám nguội)
lampFlame.setAttribute('opacity', '0');
tube2Smoke.setAttribute('opacity', '0');
t2Powder.setAttribute('opacity', '0');
t2Solid.setAttribute('opacity', '1');
fesBlock.classList.remove('glow-anim');
fesBlock.setAttribute('fill', '#27272a');
// Đưa nam châm lại sát bên trái ống nghiệm (2) (mép ống 2 ở x = 472 -> đầu cực N ở x = 466)
magnet.setAttribute('transform', 'translate(370, 295)');
magWaves.setAttribute('opacity', '1');
}
}
function nextStep() {
if (currentStep < 4) setStep(currentStep + 1);
}
function prevStep() {
if (currentStep > 1) setStep(currentStep - 1);
}
function resetExperiment() {
setStep(1);
showToast('🔄 Đã đặt lại thí nghiệm về bước ban đầu!');
}
// ==================== XỬ LÝ PHẦN CÂU HỎI VẬN DỤNG ====================
function toggleExplanation(qNum) {
const expBox = document.getElementById(`exp-${qNum}`);
expBox.classList.toggle('hidden');
}
function checkAllAnswers() {
const cards = document.querySelectorAll('.quiz-card');
let correctCount = 0;
let answeredCount = 0;
cards.forEach(card => {
const qNum = card.getAttribute('data-question');
const correctVal = card.getAttribute('data-correct');
const selectedInput = card.querySelector(`input[name="q${qNum}"]:checked`);
const labels = card.querySelectorAll('.option-label');
// Reset style các lựa chọn
labels.forEach(lbl => {
lbl.classList.remove('border-emerald-500', 'bg-emerald-50', 'border-red-500', 'bg-red-50');
lbl.classList.add('border-slate-200', 'bg-white');
});
if (selectedInput) {
answeredCount++;
const chosenVal = selectedInput.value;
const chosenLabel = selectedInput.closest('.option-label');
if (chosenVal === correctVal) {
correctCount++;
chosenLabel.classList.remove('border-slate-200', 'bg-white');
chosenLabel.classList.add('border-emerald-500', 'bg-emerald-50');
} else {
chosenLabel.classList.remove('border-slate-200', 'bg-white');
chosenLabel.classList.add('border-red-500', 'bg-red-50');
// Tô xanh đáp án đúng để học sinh dễ đối chiếu
const rightInput = card.querySelector(`input[name="q${qNum}"][value="${correctVal}"]`);
if (rightInput) {
const rightLabel = rightInput.closest('.option-label');
rightLabel.classList.remove('border-slate-200', 'bg-white');
rightLabel.classList.add('border-emerald-500', 'bg-emerald-50');
}
}
// Tự động mở giải thích khi đã chọn
document.getElementById(`exp-${qNum}`).classList.remove('hidden');
}
});
if (answeredCount < 3) {
showToast(`⚠️ Bạn mới chọn ${answeredCount}/3 câu. Hãy hoàn thành đủ 3 câu nhé!`);
return;
}
const scoreBox = document.getElementById('score-box');
const scoreVal = document.getElementById('score-value');
scoreBox.classList.remove('hidden');
scoreVal.textContent = correctCount;
if (correctCount === 3) {
showToast('🎉 Xuất sắc! Bạn đã trả lời đúng cả 3/3 câu hỏi vận dụng!');
} else {
showToast(`✅ Bạn trả lời đúng ${correctCount}/3 câu. Xem phần giải thích bên dưới mỗi câu nhé!`);
}
}
// Hiển thị thông báo nhỏ thay thế alert()
let toastTimeout;
function showToast(message) {
const box = document.getElementById('toast-box');
const msg = document.getElementById('toast-msg');
msg.textContent = message;
box.classList.remove('translate-y-20', 'opacity-0');
clearTimeout(toastTimeout);
toastTimeout = setTimeout(() => {
box.classList.add('translate-y-20', 'opacity-0');
}, 3500);
}
// Khởi chạy khi tải trang
window.addEventListener('DOMContentLoaded', () => {
initParticles();
renderInitialSVG();
setStep(1);
});
</script>
</body>
</html>