<?php
// Function to fetch RSS feed and generate ticker HTML
def fetchRSS() {
    $rssUrl = "https://news.google.com/rss/search?q=health-technology&hl=en-US&gl=US&ceid=US:en";
    $rssFeed = simplexml_load_file($rssUrl);
    
    if (!$rssFeed) {
        return "<span>Latest news unavailable. Please refresh.</span>";
    }
    
    $headlines = [];
    foreach ($rssFeed->channel->item as $item) {
        $headlines[] = "<a href='" . htmlspecialchars($item->link) . "' style='color: black; text-decoration: none; font-weight: 100; font-size: 16px; margin-right: 20px;' target='_blank'>" . htmlspecialchars($item->title) . "</a>";
    }
    
    return "<span>" . implode(" • ", $headlines) . "</span>";
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>RSS Ticker</title>
    <style>
        #rssTickerContainer {
            white-space: nowrap;
            overflow: hidden;
            background: #fff478;
            color: black;
            padding: 10px;
            font-family: 'Open Sans', sans-serif;
            font-weight: 100;
            font-size: 16px;
        }
        #rssTicker {
            display: inline-block;
            animation: scroll 80s linear infinite;
        }
        @keyframes scroll {
            from { transform: translateX(0%); }
            to { transform: translateX(-100%); }
        }
        #rssTickerContainer:hover #rssTicker {
            animation-play-state: paused !important;
        }
    </style>
</head>
<body>
    <div id="rssTickerContainer">
        <div id="rssTicker">
            <?php echo fetchRSS(); ?>
        </div>
    </div>
</body>
</html>
