<template><NuxtLayout name="default">
    <main id="main" class="container mx-auto max-w-screen-xl md:px-12 sm:px-0 px-0" aria-label="Home page">
        <h3 class="sm:text-5xl text-3xl text-center -mt-6 sm:-mt-16 font-display">
            I do things.
        </h3>
        <div class="grid sm:grid-cols-2 gap-6 mx-auto sm:py-8 py-6 col">
            <div class="aspect-w-16 aspect-h-9 shadow-lg">
                <a href="https://edugames.andreafranceschini.org/">
                    <video autoplay loop muted class="rounded" aria-hidden="true">
                        <source src="/images/gneg.mp4" type="video/mp4" />
                        Your browser does not support the video tag.
                    </video>
                    <span class="sr-only">Read more about the EduGames project</span>
                </a>
            </div>
            <div class="aspect-w-16 aspect-h-9 shadow-lg">
                <a href="https://edugames.andreafranceschini.org/cash-or-card"><figure aria-hidden="true">
                    <picture>
                        <source srcset="/images/cash_or_card-2x.webp" type="image/webp" />
                        <source srcset="/images/cash_or_card.jpg 1x, /images/cash_or_card-2x.jpg 2x" type="image/jpeg" />
                        <img class="rounded" srcset="/images/cash_or_card.jpg" alt="Cash or Card? title screen" />
                    </picture>
                </figure><span class="sr-only">Play the game "Cash or Card?"</span></a>
            </div>
            <!-- <div class="aspect-w-16 aspect-h-9 shadow-lg hidden sm:block">
                <iframe ref="video" lang="en" loading="lazy" data-src="https://www.youtube-nocookie.com/embed/AszBiqrvAaU" title="How to make your computer go BOOP" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
            </div> -->
        </div>
        <h3 class="sm:text-4xl text-3xl pb-8 text-center">
            <span class="scroll-down sm:hidden">
                <ScrollDownSVG />
            </span>
            What can I do for you?
            <span class="scroll-down sm:hidden">
                <ScrollDownSVG />
            </span>
        </h3>
        <nav id="home_bars" aria-label="Secondary menu" class="flex flex-row sm:max-w-screen-lg mx-auto">
            <ul class="contents">
                <li class="contents"><a href="/research" class="research flex-1"><span>Research</span></a></li>
                <li class="contents"><a href="/development" class="development flex-1"><span>Development</span></a></li>
                <li class="contents"><a href="/writing" class="writing flex-1"><span>Technical Writing</span></a></li>
                <li class="contents"><a href="/contact" class="other flex-1"><span>Something else</span></a></li>
            </ul>
        </nav>
    </main>
</NuxtLayout></template>

<style lang="pcss">
@reference '../assets/css/main.css';

@keyframes floating {
    0% { transform: translate(0,  -5px); }
    50%   { transform: translate(0, 0px); }   
    100%   { transform: translate(0, -5px); }   
}

.scroll-down {
    svg {
        width: 25px;
        height: 25px;
        display: inline;
        animation-name: floating;
        animation-duration: 2s;
        animation-iteration-count: infinite;
        animation-timing-function: ease-in-out;
        opacity: 50%;
    }
}

@media (prefers-reduced-motion: reduce) {
  .scroll-down svg { animation: none !important; }
  video[autoplay] { animation: none !important; }
}

html.no-webp {
    #home_bars a {
        &.research {
            background-image: url(../images/home-research-2x.png);
        }
        &.development {
            background-image: url(../images/home-development-2x.png);
        }
        &.writing {
            background-image: url(../images/home-writing-2x.png);
        }
        &.other {
            background-image: url(../images/home-contact-2x.png);
        }
    }
}

#home_bars a:focus-visible {
  outline: 3px solid #000;
  outline-offset: 4px;
}

#home_bars {
    a {
        width: 25%;
        height: 250px;
        padding: 0;
        margin: 0;
        position: relative;
        background: grey;
        text-shadow: 0px 0px 4px black;

        &.research {
            background-image: url(../images/home-research-2x.webp);
            background-position: 100% 100%;
            background-size: cover;
        }
        &.development {
            background-image: url(../images/home-development-2x.webp);
            background-position: 100% 100%;
            background-size: cover;
        }
        &.writing {
            background-image: url(../images/home-writing-2x.webp);
            background-position: 100% 100%;
            background-size: cover;
        }
        &.other {
            background-image: url(../images/home-contact-2x.webp);
            background-position: 100% 100%;
            background-size: cover;
        }

        span {
            position: absolute;
            color: #fff;
            font-family: Oswald,sans-serif;
            font-size: 30px;
            white-space: nowrap;
            transform-origin: bottom left;
            transform: rotate(-90deg);
            display: block;
            bottom: 0.5em;
            left: 1.6667em;
            overflow: visible;
        }
    }
}
</style>

<script lang="ts" setup>
definePageMeta({
    layout: false
});
const title = "Hello, I'm Andrea Franceschini, PhD";
const keywords = "music, learning, tabletop, research, the open university, university of cambridge, isaac physics, reactable";

useState('pageClasses', () => ['index', 'page']);
useState('headline', () => "Hello");
useState('tagline', () => "I'm Andrea");
useHead({
    title,
    meta: [
        { property: 'keywords', content: keywords },
        { property: 'DC.Title', content: title },
        { property: 'twitter:title', content: title },
        { property: 'og:title', content: title },
    ]
});

onMounted(() => {
  const m = window.matchMedia('(prefers-reduced-motion: reduce)');
  if (m.matches) {
    document.querySelectorAll<HTMLVideoElement>('video[autoplay]').forEach(v => {
      v.pause();
      v.removeAttribute('autoplay');
      v.removeAttribute('loop');
    });
  }
});

// const video = ref<HTMLIFrameElement>();

// onMounted(() => {
//     const src = video.value?.dataset['src'];
//     video.value?.setAttribute('src', src || '');
// });
</script>