<?php
class ProgressStore {

  public static function load($userId) {
    global $db;
    $stmt = $db->prepare("SELECT data FROM onboarding WHERE user_id=?");
    $stmt->execute([$userId]);
    return json_decode($stmt->fetchColumn(), true) ?? [];
  }

  public static function save($userId, $data) {
    global $db;
    $stmt = $db->prepare("
      INSERT INTO onboarding (user_id, data)
      VALUES (?, ?)
      ON DUPLICATE KEY UPDATE data=VALUES(data)
    ");
    $stmt->execute([$userId, json_encode($data)]);
  }
}
