<script>
  import { resolve } from '$app/paths';
  import { t } from '$lib/translations';

  import BoltIcon from '$lib/components/icons/BoltIcon.svelte';
  import PadlockIcon from '$lib/components/icons/PadlockIcon.svelte';
  import FourSquaresIcon from '$lib/components/icons/FourSquaresIcon.svelte';
  import FilesIcon from '$lib/components/icons/FilesIcon.svelte';
</script>

<section id="features">
  <header>
    <h1>{$t('features.title')}</h1>
    <p class="subtitle">{$t('features.subtitle')}</p>
  </header>

  <div class="cards-container">
    <div class="blob">
      <p class="adjective">{$t('features.cards.fast.adjective')}</p>
      <h2>{$t('features.cards.fast.title')}</h2>
      <BoltIcon color="#06345f" size={100} />
      <p class="description">{$t('features.cards.fast.description')}</p>
    </div>

    <div class="blob">
      <p class="adjective">{$t('features.cards.private.adjective')}</p>
      <h2>{$t('features.cards.private.title')}</h2>
      <PadlockIcon color="#06345f" size={100} />
      <p class="description">{$t('features.cards.private.description')}</p>
    </div>

    <div class="blob">
      <p class="adjective">{$t('features.cards.optimized.adjective')}</p>
      <h2>{$t('features.cards.optimized.title')}</h2>
      <FourSquaresIcon color="#06345f" size={100} />
      <p class="description">{$t('features.cards.optimized.description')}</p>
    </div>

    <div class="blob">
      <p class="adjective">{$t('features.cards.compatibility.adjective')}</p>
      <h2>{$t('features.cards.compatibility.title')}</h2>
      <FilesIcon color="#06345f" size={100} />
      <p class="description">
        {$t('features.cards.compatibility.description')}
      </p>
    </div>
  </div>
  <a class="organic-btn-secondary" href={resolve('/viewer')}
    >{$t('features.cta')}</a
  >
</section>

<style>
  #features {
    display: flex;
    align-items: center;
    flex-direction: column;
    padding: 100px 0;
    background-color: var(--color-primary);
    position: relative;
    overflow: hidden;
  }
  #features::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='600' height='600' viewBox='0 0 200 200' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M10 150 C 60 20, 140 180, 190 50' stroke='white' stroke-width='1.5' stroke-dasharray='4 6' opacity='0.2'/%3E%3Ccircle cx='10' cy='150' r='3' fill='white' opacity='0.25'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: 600px;
    background-position: right -100px top -80px;
    pointer-events: none;
  }
  #features::after {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='600' height='600' viewBox='0 0 200 200' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M20 40 C 80 180, 120 0, 180 140' stroke='white' stroke-width='1.2' stroke-dasharray='3 8' opacity='0.15'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: 500px;
    background-position: left -120px bottom -80px;

    pointer-events: none;
  }
  header {
    text-align: center;
    line-height: 1.5;
    width: 80%;
  }

  h1 {
    color: white;
    font-size: 2.7rem;
  }

  .subtitle {
    color: white;
    font-size: 1.2rem;
    text-align: center;
  }

  .cards-container {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(4, 1fr);
    margin: 0 auto;
    width: 100%;
    padding: 100px 40px;
  }

  .blob {
    width: 100%;
    max-width: 380px;
    height: 400px;
    aspect-ratio: 1;
    border-radius: 25% 50% 75% 100%;
    text-align: center;
    padding: 30px 60px;

    background: linear-gradient(
      30deg in oklch shorter hue,
      oklch(0.98 0.01 260) 10%,
      oklch(0.92 0.02 260)
    );

    box-shadow: 1rem 1rem 50px #0001;
  }

  .blob h2 {
    font-size: 1.5rem;
    margin-top: 10px;
  }

  .description {
    font-size: 1rem;
    margin-top: 20px;
  }

  .adjective {
    color: var(--color-primary);
    font-size: 0.8rem !important;
  }

  .organic-btn-secondary {
    font-size: 1.3rem;
    padding: 30px 90px;
  }

  @media (max-width: 1639px) {
    .blob {
      width: 100%;
      max-width: 340px;
      height: 380px;
    }
  }

  @media (max-width: 1480px) {
    .cards-container {
      grid-template-columns: repeat(3, 1fr);
    }

    .blob {
      width: 100%;
      max-width: 400px;
      height: 400px;
    }
  }
  @media (max-width: 1297px) {
    .cards-container {
      grid-template-columns: repeat(2, 1fr);
    }
  }

  @media (max-width: 1210px) {
    h1 {
      font-size: 2.3rem;
    }

    .subtitle {
      font-size: 1rem;
    }
  }

  @media (max-width: 1033px) {
    h1 {
      font-size: 2rem;
    }
  }

  @media (max-width: 880px) {
    #features {
      padding: 20px;
    }
    header {
      width: 100%;
    }

    h1 {
      font-size: 2rem;
    }

    .cards-container {
      padding: 0;
      grid-template-columns: 1fr;
    }

    .blob {
      width: 100%;
      max-width: 100%;
      padding-bottom: 50px;
      height: fit-content;
      aspect-ratio: 0;
    }
  }

  @media (max-width: 540px) {
    .organic-btn-secondary {
      width: 100%;
      text-align: center;
      font-size: 1rem;
      padding: 20px 50px;
      margin-top: 30px;
    }
  }
</style>
