<script lang="js" setup>

import HeaderLinks from './HeaderLinks.vue';
import SiteOptions from './site_options/SiteOptions.vue';
import { ref, onMounted, onUnmounted } from 'vue';
 
const SCROLL_THRESHOLD = 120; // px scrolled before sticky header appears
 
const isVisible = ref(false);
 
function onScroll() {
    isVisible.value = window.scrollY > SCROLL_THRESHOLD;
}
 
onMounted(() => window.addEventListener('scroll', onScroll, { passive: true }));
onUnmounted(() => window.removeEventListener('scroll', onScroll));

</script>

<template>
<div class="tui-stickybar" :class="{ visible: isVisible }">
    <div class="sticky-inner">
        <div class="left">
            <span class="sticky-title" aria-hidden="true">◆ ARANROIG.COM</span>
            <HeaderLinks />
        </div>
        <SiteOptions />
    </div>
</div>
</template>

<style lang="scss" scoped>

.tui-stickybar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
 
    background: var(--color-sticky-header-bg);
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 0px 0px var(--color-container-shadow);
 
    // Hidden state — translated up and invisible
    transform: translateY(-100%);
    opacity: 0;
    pointer-events: none;
 
    transition:
        transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        opacity 0.3s ease;
 
    &.visible {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
        transition:
            transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
            opacity 0.3s ease;
    }
}

.sticky-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 6px 24px;

    @media screen and (max-width: 900px) {
        padding: 5px 16px;
    }

    @media screen and (max-width: 600px) {
        padding: 4px 12px;
        gap: 0.5rem;
    }
}

.left {
    display: flex;
    align-items: center;
    gap: 1rem;
    
    @media screen and (max-width: 600px) {
        gap: 0.5rem;
    }
}

.sticky-title {
    font-family: 'Hurmit', monospace;
    font-size: 0.8rem;
    color: var(--color-text);
    letter-spacing: 1px;
    white-space: nowrap;
    
    @media screen and (max-width: 900px) {
        font-size: 0.75rem;
    }

    @media screen and (max-width: 480px) {
        display: none;
    }
}

.site-options {
    display: flex;
    gap: 8px;
    align-items: center;
}
</style>
