<script lang="ts">
  import Login from "@assets/icons/login-3.svg?dataurl"
  import AddCircle from "@assets/icons/add-circle.svg?dataurl"
  import Icon from "@lib/components/Icon.svelte"
  import Button from "@lib/components/Button.svelte"
  import Link from "@lib/components/Link.svelte"
  import Modal from "@lib/components/Modal.svelte"
  import ModalBody from "@lib/components/ModalBody.svelte"
  import CardButton from "@lib/components/CardButton.svelte"
  import LogIn from "@app/components/LogIn.svelte"
  import SignUp from "@app/components/SignUp.svelte"
  import {PLATFORM_TERMS, PLATFORM_PRIVACY, PLATFORM_NAME, PLATFORM_LOGO} from "@app/env"
  import {pushModal} from "@app/modal"

  const logIn = () => pushModal(LogIn)

  const signUp = () => pushModal(SignUp)
</script>

<Modal>
  <ModalBody>
    <div class="flex flex-col items-center gap-3 py-2">
      <img
        src={PLATFORM_LOGO}
        alt={PLATFORM_NAME}
        class="shadow-soft ring-primary/20 size-16 rounded-2xl object-cover ring-4 motion-safe:animate-float" />
      <h1 class="heading">Welcome to <span class="brand">{PLATFORM_NAME}</span>!</h1>
      <p class="max-w-sm text-center opacity-80">
        A cozy home for your community — chat, connect, and own your little corner of the internet.
      </p>
    </div>
    <Button onclick={logIn}>
      <CardButton class="btn-primary">
        {#snippet icon()}
          <div><Icon icon={Login} size={7} /></div>
        {/snippet}
        {#snippet title()}
          <div>Log in</div>
        {/snippet}
        {#snippet info()}
          <div>If you've been here before, you know the drill.</div>
        {/snippet}
      </CardButton>
    </Button>
    <Button onclick={signUp} class="btn-neutral">
      <CardButton>
        {#snippet icon()}
          <div><Icon icon={AddCircle} size={7} /></div>
        {/snippet}
        {#snippet title()}
          <div>Create an account</div>
        {/snippet}
        {#snippet info()}
          <div>Just a few questions and you'll be on your way.</div>
        {/snippet}
      </CardButton>
    </Button>
    <p class="text-center text-xs opacity-75">
      By using {PLATFORM_NAME}, you consent to our
      <Link external class="link" href={PLATFORM_TERMS}>Terms of Service</Link> and
      <Link external class="link" href={PLATFORM_PRIVACY}>Privacy Policy</Link>.
    </p>
  </ModalBody>
</Modal>
