<script setup lang="ts">
	import { RouterLink } from 'vue-router'

	withDefaults(
		defineProps<{
			name: string
			title: string
			backgroundImage?: string
			backgroundAlt: string
			panelImage?: string
			panelAlt: string
			reversed?: boolean
			to: string
		}>(),
		{
			reversed: false
		}
	)
</script>

<template>
	<section
		class="product-feature"
		:class="{ 'product-feature-reversed': reversed }"
		v-custom-animation.scroll
	>
		<div class="product-feature-art">
			<img
				class="product-feature-bg"
				:src="backgroundImage"
				:alt="backgroundAlt"
				loading="lazy"
				translate-x-s="-100"
				translate-x="100"
			/>
			<img
				class="product-feature-panel"
				:src="panelImage"
				:alt="panelAlt"
				loading="lazy"
				translate-y-s="-100"
				translate-y="20"
			/>
		</div>

		<div class="product-feature-copy">
			<p class="product-feature-name">{{ name }}</p>
			<h2 class="product-feature-title">{{ title }}</h2>
			<RouterLink
				class="product-feature-link"
				:to="to"
				translate-y-s="100"
				translate-y="0"
			>
				{{$t('Home.viewMore')}}
			</RouterLink>
		</div>
	</section>
</template>

<style scoped lang="less">
	.product-feature {
		display: flex;
		align-items: center;
		gap: clamp(48px, 5.5vw, 76px);
		max-width: 1440px;
		min-width: 0;
		min-height: 690px;
		margin: 0 auto;
		& > div {
			width: 50%;
		}
	}

	.product-feature-reversed {
		grid-template-columns: minmax(420px, 0.95fr) minmax(0, 1.05fr);
	}

	.product-feature-reversed .product-feature-art {
		order: 2;
		justify-self: end;
	}

	.product-feature-reversed .product-feature-copy {
		order: 1;
		justify-self: start;
		max-width: 510px;
	}

	.product-feature-art {
		position: relative;
		width: min(100%, 560px);
		min-width: 0;
		min-height: 560px;
		justify-self: start;
	}

	.product-feature-bg {
		display: block;
		width: min(100%, 480px);
		max-width: 100%;
		height: auto;
		user-select: none;
	}

	.product-feature-panel {
		position: absolute;
		right: 0;
		bottom: 94px;
		width: min(72%, 380px);
		max-width: 100%;
		height: auto;
		user-select: none;
	}

	.product-feature-reversed .product-feature-bg {
		width: min(100%, 460px);
		margin-left: auto;
	}

	.product-feature-reversed .product-feature-panel {
		right: auto;
		left: -88px;
		bottom: 70px;
		width: min(78%, 430px);
	}

	.product-feature-copy {
		position: relative;
		z-index: 1;
		max-width: 590px;
		min-width: 0;
		justify-self: start;
		padding-bottom: 18px;
	}

	.product-feature-name {
		margin: 0 0 20px;
		color: #6e6e6e;
		font-family: Poppins, sans-serif;
		font-size: 18px;
		font-weight: 700;
		line-height: 1;
		letter-spacing: 2px;
	}

	.product-feature-title {
		margin: 0 0 28px;
		color: #252525;
		font-family: Poppins, sans-serif;
		font-size: clamp(30px, 2.8vw, 38px);
		font-weight: 700;
		line-height: 1.16;
		letter-spacing: 2px;
		text-transform: none;
		overflow-wrap: break-word;
	}

	.product-feature-link {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		min-width: 152px;
		min-height: 48px;
		padding: 0 28px;
		border-radius: 999px;
		color: #ffffff;
		background: #a72125;
		font-family: Poppins, sans-serif;
		font-size: 10px;
		font-weight: 700;
		line-height: 1;
		letter-spacing: 2px;
		text-decoration: none;
		text-transform: uppercase;
		transition:
			background-color 0.2s ease,
			transform 0.2s ease;
	}

	.product-feature-link:hover,
	.product-feature-link:focus-visible {
		background: #8e171b;
		transform: translateY(-1px);
	}

	.product-feature-link:focus-visible {
		outline: 2px solid #a72125;
		outline-offset: 4px;
	}

	@media (max-width: 980px) {
		.product-feature,
		.product-feature-reversed {
			flex-direction: column-reverse;
			gap: 24px;
			width: min(680px, calc(100% - 40px));
			min-height: 0;
			padding: 70px 0;
		}

		.product-feature-reversed .product-feature-art,
		.product-feature-reversed .product-feature-copy {
			order: initial;
			justify-self: start;
		}

		.product-feature-art {
			width: 100%;
			max-width: 100%;
			min-height: clamp(390px, 82vw, 560px);
			justify-self: stretch;
		}

		.product-feature-copy {
			width: 100%;
			max-width: 640px;
			justify-self: stretch;
			padding-bottom: 0;
		}

		.product-feature-reversed .product-feature-panel {
			left: 0;
		}
	}

	@media (max-width: 640px) {
		.product-feature,
		.product-feature-reversed {
			width: calc(100% - 32px);
			gap: 28px;
			padding: 0 0 64px;
		}

		.product-feature-art {
			min-height: clamp(280px, 82vw, 360px);
		}

		.product-feature-copy,
		.product-feature-reversed .product-feature-copy {
			width: 100% !important;
			max-width: 100% !important;
			justify-self: stretch !important;
		}

		.product-feature-bg {
			width: 72%;
			margin-left: 38px;
			border-radius: 10px;
		}

		.product-feature-panel,
		.product-feature-reversed .product-feature-panel {
			left: auto;
			right: 12px;
			bottom: 22px;
			width: 72%;
		}

		.product-feature-reversed .product-feature-bg {
			width: 70%;
			margin-right: 16px;
			margin-left: auto;
		}

		.product-feature-reversed .product-feature-panel {
			right: auto;
			left: 18px;
			bottom: 16px;
			width: 72%;
		}

		.product-feature-name {
			margin-bottom: 16px;
			font-size: 18px;
			letter-spacing: 1.5px;
		}

		.product-feature-title {
			width: 100%;
			max-width: 100%;
			margin-bottom: 26px;
			font-size: clamp(22px, 6.1vw, 26px);
			line-height: 1.35;
			letter-spacing: 1.2px;
			overflow-wrap: anywhere;
		}

		.product-feature-link {
			min-width: 100px;
			min-height: 40px;
			padding: 0 22px;
			font-size: 9px;
			letter-spacing: 1px;
		}
	}
</style>
