<?php
session_start();
require_once 'config/db.php';
require_once 'includes/header.php';

if (!isset($_GET['track_id'])) {
    header("Location: tracks.php");
    exit();
}

$track_id = (int)$_GET['track_id'];

$stmt = $pdo->prepare("SELECT * FROM tracks WHERE id = ?");
$stmt->execute([$track_id]);
$track = $stmt->fetch(PDO::FETCH_ASSOC);

if (!$track || $track['status'] !== 'active') {
    header("Location: tracks.php");
    exit();
}
?>

<div class="track-intro-wrapper">

    <h2><?php echo htmlspecialchars($track['track_name']); ?></h2>

    <p class="track-desc">
        <?php echo htmlspecialchars($track['description']); ?>
    </p>

    <div class="intro-box">
        <h3>📘 About This Learning Track</h3>
        <p>
            This track is designed to help you understand the basics of Python programming step by step.
            You do not need any prior coding knowledge to start.
        </p>
    </div>

    <div class="intro-box">
        <h3>🧠 What You Will Learn</h3>
        <ul>
            <li>How programming works</li>
            <li>How Python prints output</li>
            <li>Understanding variables and values</li>
            <li>Basic logical thinking using code</li>
            <li>Reading simple Python code</li>
        </ul>
    </div>

    <div class="intro-box">
        <h3>🧪 How the Practice Challenges Work</h3>
        <ul>
            <li>This track contains <strong>15 practice challenges</strong></li>
            <li>Each challenge focuses on one simple concept</li>
            <li>You will receive guidance if your first attempt is incorrect</li>
            <li>Mistakes are part of the learning process</li>
        </ul>
    </div>

    <div class="intro-box">
        <h3>🎖️ Learning Badge</h3>
        <p>
            After completing all practice challenges in this track,
            you will unlock the <strong>Python Basics – Learning Badge</strong>.
        </p>
        <p class="note">
            This badge represents your learning effort and consistency.
        </p>
    </div>

    <div class="start-track">
        <a href="practice_challenge.php?track_id=<?php echo $track_id; ?>" class="btn-primary">
            Start Python Basics Practice
        </a>
    </div>

    <a href="tracks.php" class="back-link">← Back to Tracks</a>

</div>

</body>
</html>
