<script>
  /* eslint-disable svelte/no-at-html-tags -- static legal copy from locale JSON */
  import { page } from '$app/state';
  import { resolve } from '$app/paths';
  import { imageBaseUrl } from '$lib/config/imageCdn.js';
  import ArrowBackIcon from '$lib/components/icons/ArrowBackIcon.svelte';
  import Head from '$lib/components/Head.svelte';
  import { locale, t } from '$lib/translations';

  const ogImage = $derived(
    `${imageBaseUrl}/t/f_webp,w_1200,h_630,c_fill/leomurca/hero.webp`,
  );

  const privacyJsonLd = $derived(
    JSON.stringify({
      '@context': 'https://schema.org',
      '@type': 'WebPage',
      name: $t('privacy.meta.ogTitle'),
      description: $t('privacy.meta.description'),
      url: `${page.url.origin}${page.url.pathname}`,
      inLanguage: $locale === 'pt-BR' ? 'pt-BR' : 'en-US',
      isPartOf: {
        '@type': 'WebSite',
        name: 'Leonardo Murça',
        url: `${page.url.origin}/`,
      },
    }),
  );
</script>

<Head
  title={$t('privacy.meta.title')}
  description={$t('privacy.meta.description')}
  keywords={$t('privacy.meta.keywords')}
  ogTitle={$t('privacy.meta.ogTitle')}
  ogDescription={$t('privacy.meta.ogDescription')}
  ogImage={ogImage}
  twitterDescription={$t('privacy.meta.twitterDescription')}
  ogImageAlt={$t('privacy.meta.ogTitle')}
  jsonLd={privacyJsonLd}
/>

<a class="floating-button" href={resolve('/')}>
  <ArrowBackIcon size={25} />
  {$t('common.goBack')}
</a>

<article class="privacy" aria-labelledby="privacy-title">
  <p class="privacy__updated">{$t('privacy.lastUpdated')}</p>
  <h1 id="privacy-title">{$t('privacy.title')}</h1>

  <p>{$t('privacy.intro')}</p>

  <h2>{$t('privacy.controllerTitle')}</h2>
  <p>{$t('privacy.controller')}</p>

  <h2>{$t('privacy.analyticsTitle')}</h2>
  <p>{@html $t('privacy.analyticsHtml')}</p>

  <h2>{$t('privacy.cookiesTitle')}</h2>
  <p>{@html $t('privacy.cookiesHtml')}</p>

  <h2>{$t('privacy.storageTitle')}</h2>
  <p>{@html $t('privacy.storageHtml')}</p>

  <h2>{$t('privacy.rightsTitle')}</h2>
  <p>{$t('privacy.rights')}</p>

  <h2>{$t('privacy.changesTitle')}</h2>
  <p>{$t('privacy.changes')}</p>
</article>

<style>
  .floating-button {
    position: fixed;
    top: 30px;
    right: 30px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: 40px;
    background: var(--color-secondary);
    color: white;
    font-weight: 500;
    text-decoration: none;
    box-shadow: 0 4px 0 #cc3928;
    transition:
      transform 0.1s ease,
      box-shadow 0.1s ease;
  }

  .floating-button:hover {
    transform: translateY(1px);
    box-shadow: 0 3px 0 #cc3928;
  }

  .privacy {
    max-width: 720px;
    margin: 0 auto;
    padding: 120px 28px 100px;
    color: var(--color-font-dark);
    line-height: 1.6;
  }

  .privacy__updated {
    margin: 0 0 1rem;
    font-size: 0.9rem;
    color: var(--color-font-light);
  }

  .privacy h1 {
    margin: 0 0 1.25rem;
    font-size: clamp(2rem, 4vw, 2.5rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
  }

  .privacy h2 {
    margin: 2rem 0 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
  }

  .privacy p {
    margin: 0 0 1rem;
    font-size: 1.05rem;
  }

  .privacy :global(a) {
    color: var(--color-secondary);
    text-decoration: underline;
    text-underline-offset: 3px;
  }

  .privacy :global(a:hover) {
    color: var(--color-primary);
  }

  @media (max-width: 768px) {
    .floating-button {
      bottom: 20px;
      right: 16px;
      left: 16px;
      justify-content: center;
      width: auto;
    }

    .privacy {
      padding: 100px 20px 88px;
    }
  }
</style>
