<template>
    <div class="header">
        <div class="logo center">
            <img src="@/assets/logo.png" alt="" />
            <span>飞鸟有味</span>
        </div>
        <div class="center-menu">
            <div class="tabs center">
                <div
                    :class="['tab-item center', { active: index === active }]"
                    @click="handleActive(item, index)"
                    v-for="(item, index) in tabs"
                    :key="index"
                >
                    {{ item.name }}
                </div>
            </div>
        </div>
        <div class="header-btn">我要认证</div>
    </div>
</template>

<script setup>
import { ref, defineEmits } from "vue";

const active = ref(0);
const tabs = [
    {
        name: "首页",
        component: "Home",
    },
    {
        name: "飞鸟三味",
        component: "ThreeFlavors",
    },
    {
        name: "3体6维认证",
        component: "Certification",
    },
    {
        name: "飞鸟溯源",
        component: "TraceSource",
    },
    {
        name: "生态守护者联盟",
        component: "DefendLeague",
    },
    {
        name: "有味指数地图",
        component: "ExponentialMap",
    },
];

const emit = defineEmits(["handleActive"]);

const handleActive = (value, index) => {
    active.value = index;
    emit("handleActive", value.component);
};

const input = ref("");
</script>

<style lang="scss" scoped>
.header {
    width: 100%;
    height: 70px;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.34);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 2;
    .center {
        display: flex;
        align-items: center;
    }
    .logo {
        font-size: 24px;
        font-weight: 400;
        letter-spacing: 2px;
        position: relative;
        z-index: 2;
        color: #FFDA75;
        // margin-right: 70px;
        img {
            width: 30px;
            height: 30px;
            margin: 0 20px 0 30px;
        }
        span {
            // font-family: "PangMenZhengDao";
        }
    }
    .center-menu {
        height: 100%;
        position: relative;
        flex: 1;
        // width: calc(100% - 500px);
    }
    .tabs {
        // width: 100%;
        height: 100%;
        position: absolute;
        left: 384px;
        // left: 20%;
        // transform: translateX(-50%);
        z-index: 2;
        margin-right: 30px;
        .tab-item {
            font-weight: 400;
            font-size: 18px;
            // width: 110px;
            height: 100%;
            justify-content: center;
            text-align: center;
            margin-right: 70px;
            cursor: pointer;
            position: relative;
            transform: perspective(1px) translateZ(0);
            overflow: hidden;
            // font-family: "PangMenZhengDao";
            &::before {
                  content: "";
                  position: absolute;
                  z-index: -1;
                  // left: 100%;
                  left: -100%;
                  // right: 51%;
                  bottom: 0;
                  width: 100%;
                  background: #ffda75;
                  border-radius: 20px;
                  height: 4px;
                  transition-property: left, right;
                  transition-duration: 0.3s;
                  transition-timing-function: ease-out;
                  opacity: 0;
              }
            &.active {
                font-weight: bold;
                color: #ffda75;
                &::before {
                    left: 0;
                    right: 0;
                    opacity: 1;
                }
            }
        }
    }
    .header-btn {
      margin-right: 71px;
      font-size: 18px;
      color: #FFDA75;
      padding: 10px 20px;
      border-radius: 5px;
      background: rgba(255, 218, 117, 0.08);
      border: 1px solid #FFDA75;
    }
}
</style>
