<?php
header('Content-Type: application/json');
if ($_SERVER['REQUEST_METHOD'] !== 'POST') { http_response_code(405); echo json_encode(['ok'=>false]); exit; }
$email = filter_var($_POST['email'] ?? '', FILTER_VALIDATE_EMAIL);
if (!$email) { http_response_code(400); echo json_encode(['ok'=>false,'error'=>'Invalid email']); exit; }
$line = date('c') . ',' . str_replace(',', '', $email) . PHP_EOL;
$file = __DIR__ . '/waitlist.csv';
file_put_contents($file, $line, FILE_APPEND | LOCK_EX);
echo json_encode(['ok'=>true]);
?>
