---
import { Image } from 'astro:assets'
import type { GlobImage } from '../../types/generic'
import { plsLoadImage } from '../../utils/tools'

export interface Props {
  title: string
  link: string
  imageFile: string
}

const { imageFile, link, title } = Astro.props
const imagePath = `/src/assets/technologies/${imageFile}`
const images_logos = import.meta.glob<GlobImage>(
  '/src/assets/technologies/*.{png,webp}'
)
const loadedImage = plsLoadImage(images_logos, imagePath)
---

<a href={link} target="_blank" rel="noopener noreferrer" aria-label={title}>
  <article>
    <Image src={loadedImage} alt={title} loading={'eager'} width={100} height={100} quality={100}/>
    <div>
      <h2>{title}</h2>
    </div>
  </article>
  <span class="visually-hidden">{title}</span>
</a>

<style>
  a {
    text-decoration: none;
  }
  article {
    --size-value: 6.25rem;
    background-color: var(--c-darkergray);
    border-color: var(--c-darkgray);
    padding: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    transition: transform var(--speed) var(--ease);
    height: auto;
    width: auto;
    line-height: 100px;
    border-radius: 1.25rem;
    position: relative;
  }
  article:hover {
    transform: scale(var(--hover-scale));
  }
  article > img {
    border-radius: 1.25rem;
    width: var(--size-value);
    height: var(--size-value);
  }

  article:hover div {
    border-radius: 1.25rem;
    padding: 0 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background-color: var(--c-darkgray);
    height: calc(var(--size-value));
    width: calc(var(--size-value) - 1rem);
    opacity: 90%;
    z-index: 100;
    position: absolute;
    border-style: solid;
    border-width: 10px;
    border-color: var(--c-darkgray);
  }

  article:hover h2 {
    margin: 0;
    position: absolute;
    display: inline-flex;
    font-weight: bold;
    color: white;
    font-size: 18px;
    line-height: 150%;
  }

  article h2 {
    display: none;
  }

  article div {
    display: none;
  }
</style>