<?php
$content = file_get_contents('content.json');
$content = json_decode($content, true);
?>

<!DOCTYPE html>
<html lang="fr-FR">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Portfolio - Mathieu Francon</title>
    <meta name="description" content="Audiovisuel outdoor/sport extrême, Photo, Étudiant à IUT de Chambéry dans le multimédia">

    <!-- favicon -->
    <link rel="apple-touch-icon" sizes="180x180" href="favicon/apple-touch-icon.png">
    <link rel="icon" type="image/png" sizes="32x32" href="favicon/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="16x16" href="favicon/favicon-16x16.png">
    <link rel="manifest" href="favicon/site.webmanifest">

    <!-- css -->
    <link rel="stylesheet" href="css/reset.css">
    <link rel="stylesheet" href="css/layout.css">
    <link rel="stylesheet" href="css/folder.css">
    <link rel="stylesheet" href="css/font.css">
    <link rel="stylesheet" href="css/bg.css">
    <link rel="stylesheet" href="css/legend.css">
    <link rel="stylesheet" href="css/phone.css">
</head>

<body>
    <div class="bg">
        <div class="grain"></div>
        <div class="circle"></div>
    </div>
    <section>
        <h1><span>Portfolio</span><br>Mathieu Francon</h1>
        <main>
            <?php foreach ($content as $id => $item) : ?>
                <div class="folder" data-link="<?php echo $item['link'] ?>" id="<?php echo $id ?>" style="left: <?php echo $item['position']['x'] ?>%; top: <?php echo $item['position']['y'] ?>%;">
                    <div class="image">
                        <img src="img/icons/<?php echo $item['icon'] ?>.webp" class="icon">
                        <img src="img/folder.webp" alt="folder icon macOS">
                    </div>
                    <div class="name">
                        <div class="tags">
                            <?php foreach ($item['tags'] as $tag => $color) : ?>
                                <div class="tag" data-color="<?php echo $color ?>" data-index="<?php echo $tag ?>"></div>
                            <?php endforeach; ?>
                        </div>
                        <p class="name"><?php echo $item['name']; ?></p>
                    </div>
                </div>
            <?php endforeach; ?>
            <!-- <div class="folder file" data-link="CV.pdf" id="997" style="left: 71%; top: 85%;">
                <div class="image">
                    <img src="img/files/pdf-file.webp" alt="pdf file icon macOS">
                </div>
                <div class="name">
                    <p class="name">CV.pdf</p>
                </div>
            </div>
            <div class="folder file" data-link="coordonnees/" id="998" style="left: 83%; top: 85%;">
                <div class="image">
                    <img src="img/files/email-file.webp" alt="email file icon macOS">
                </div>
                <div class="name">
                    <p class="name">Coordonnées.txt</p>
                </div>
            </div> -->
        </main>
        <div class="legend">
            <?php
            $tags = file_get_contents('tags.json');
            $tags = json_decode($tags, true);
            foreach ($tags as $color => $tag) : ?>
                <div class="tags name">
                    <div class="tag" data-color="<?php echo $color ?>"></div>
                    <p class="name"><?php echo $tag ?></p>
                </div>
            <?php endforeach; ?>
        </div>
    </section>
    <script>
        if (window.matchMedia("(min-width: 780px)").matches) {
            document.write('<' + 'script src="js/drag.js"></' + 'script>');
        } else {
            // remove x and y position
            const folders = document.querySelectorAll('.folder');
            folders.forEach(folder => {
                folder.removeAttribute('style');
            });
        }
    </script>
    <script src="js/open.js"></script>
    <script src="js/screen-resize.js"></script>
</body>

</html>