<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="sticky-header" :class="{ visible: isVisible }">
        <div class="container">
            <div class="sticky-header-inner">
                <div class="left">
                    <h1>ARANROIG.COM</h1>
                    <HeaderLinks />
                </div>
                <SiteOptions />
            </div>
        </div>
    </div>
</template>

<style lang="scss" scoped>

.sticky-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
 
    background: var(--color-sticky-header-bg, #fff);
    border-bottom: 1px solid var(--color-sticky-header-border, rgba(0, 0, 0, 0.08));
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    backdrop-filter: blur(10px);
 
    // 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;
    }
}
 
.sticky-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 10px 0;
 
    h1 {
        margin: 0;
        font-size: inherit; // inherit from your existing h1 styles
        white-space: nowrap;
        font-weight: normal;
    }
}

.left {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-left: 30px;
}
</style>