<script>
  import { templates } from "$lib/templates/templates";
</script>

<svelte:head>
  <title>Carteles DMD</title>
  <meta
    name="description"
    content="Aplicación para la generación automática de carteles de actividades de DMD"
  />
</svelte:head>
<section>
  <p>Elige plantilla</p>
  <div class="main">
    {#each templates as template}
      <div class="element">
        <a href="/{template.name}" data-sveltekit-prefetch
          ><img
            src="/{template.image}"
            alt="Plantilla en blanco estilo {template.name}"
          />
          {#if template.description}
            <div class="caption">{@html template.description}</div>
          {:else}
            <div class="caption">{template.name}</div>
          {/if}
        </a>
      </div>
    {/each}
  </div>
</section>

<style>
  section {
    max-width: 800px;
    margin: 0 auto;
    display: grid;
    min-height: 90vh;
  }

  .main {
    display: grid;
    grid-template-columns: repeat(4, min-content);
    /* grid-auto-rows: 1fr; */
    grid-gap: 1rem;
    padding: 1rem 0;
  }
  p {
    font-size: 1.5rem;
    color: #333;
  }
  .element {
    line-height: 2rem;
    display: inline-block;
    padding: 0.25rem;
    background-color: rebeccapurple;
    box-shadow: 0 0 0.5rem 0 rgba(0, 0, 0, 0.7);
    margin: 0 0.5rem;
    border-radius: 0.5rem;
    align-self: center;
  }
  a {
    text-transform: capitalize;
    cursor: pointer;
    color: white;
    text-decoration: none;
    text-align: center;
    font-weight: 400;
    font-size: 1.4rem;
  }
  img {
    max-height: 200px;
    border-radius: 0.25rem 0.25rem 0 0;
  }
  .caption {
    text-align: left;
    padding: 0.25rem;
  }
  @media (max-width: 768px) {
    .main {
      grid-template-columns: repeat(2, min-content);
    }
  }
</style>
