<script lang="ts">
  import type { GuestbookDisplayElement } from './components/guestbook-display';
  
  function handleSignCreated(event: CustomEvent) {
    console.log('New signature created:', event.detail);
    // refresh the display
    const display = document.querySelector('guestbook-display') as GuestbookDisplayElement;
    if (display) {
      display.refresh();
    }
  }
</script>

<main>
  <header>
    <h1>Guestbook</h1>
    <p class="subtitle">Leave your thoughts and memories. Thanks for visiting!</p>
  </header>
  
  <div class="components">
    <guestbook-sign 
      did="did:plc:ttdrpj45ibqunmfhdsb4zdwq"
      onsign-created={handleSignCreated}>
    </guestbook-sign>
    
    <guestbook-display 
      did="did:plc:ttdrpj45ibqunmfhdsb4zdwq"
      limit="50">
    </guestbook-display>
  </div>
</main>

<style>
  main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 48px 24px;
  }
  
  header {
    margin-bottom: 48px;
  }
  
  h1 {
    font-size: 48px;
    font-weight: 700;
    margin: 0 0 12px 0;
    color: #000;
  }
  
  .subtitle {
    font-size: 18px;
    color: #6b7280;
    margin: 0;
  }
  
  .components {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 48px;
    align-items: start;
  }
  
  @media (max-width: 768px) {
    .components {
      grid-template-columns: 1fr;
    }
  }
</style>