<script lang="ts">
  import Icon from '$lib/components/Icon.svelte';
  import { reveal } from '$lib/actions/reveal';
  import type { AboutPageContent, SiteSharedContent } from '$lib/types';

  export let content: SiteSharedContent;
  export let pageContent: AboutPageContent;
</script>

<main class="about-page">
  <section class="about-hero">
    <div class="about-inner">
      <h1>{pageContent.title}</h1>
    </div>
  </section>

  {#each pageContent.sections as section}
    <section
      use:reveal
      class:about-section-gradient={section.accent === 'gradient'}
      class="about-section reveal-block"
    >
      <div class:about-section-reverse={section.reverse} class="about-inner about-section-grid">
        <div class="about-copy">
          <h2>{section.title}</h2>
          {#each section.body as paragraph}
            <p>{paragraph}</p>
          {/each}
        </div>

        <div class="about-media">
          <img src={section.imageUrl} alt={section.imageAlt} loading="lazy" />
        </div>
      </div>
    </section>
  {/each}

  <section use:reveal={{ delay: 40 }} class="about-services reveal-block">
    <div class="about-inner">
      <div class="about-section-heading">
        <h2>{pageContent.servicesTitle}</h2>
      </div>

      <div class="about-service-grid">
        {#each content.services as service}
          <a class="about-service-card" href={service.href}>
            <div class="about-service-icon" aria-hidden="true">
              <Icon name={service.icon} />
            </div>
            <span>{service.title}</span>
          </a>
        {/each}
      </div>
    </div>
  </section>

  <section use:reveal={{ delay: 70 }} class="about-contact reveal-block">
    <div class="about-inner">
      <div class="about-contact-card">
        <h2>{pageContent.contact.title}</h2>
        <div class="about-contact-grid">
          <a class="about-contact-link" href={`mailto:${pageContent.contact.email}`}>
            {pageContent.contact.email}
          </a>
          <a class="btn btn-yellow" href={pageContent.contact.cta.href}>
            {pageContent.contact.cta.label}
          </a>
          <a class="about-contact-link" href={`tel:${pageContent.contact.phone.replace(/[^0-9+]/g, '')}`}>
            {pageContent.contact.phone}
          </a>
        </div>
      </div>
    </div>
  </section>
</main>

<style>
  .about-page {
    background: var(--off-white);
  }

  .about-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 0 50px;
  }

  .about-hero {
    padding: 72px 0 40px;
  }

  .about-hero h1,
  .about-section-heading h2,
  .about-copy h2,
  .about-contact-card h2 {
    margin: 0;
    font-family: var(--font-head);
    font-size: clamp(34px, 4vw, 56px);
    line-height: 1.05;
    letter-spacing: -0.04em;
    color: #000;
  }

  .about-hero h1,
  .about-section-heading {
    text-align: center;
  }

  .about-section {
    padding: 0 0 88px;
  }

  .about-section-gradient {
    margin: 0 24px 88px;
    padding: 40px 0;
    border-radius: 36px;
    background: linear-gradient(180deg, #f5efe6 0%, #f9f6ef 100%);
  }

  .about-section-grid {
    display: grid;
    grid-template-columns: minmax(0, 0.7fr) minmax(0, 1.3fr);
    gap: 44px;
    align-items: center;
  }

  .about-section-reverse {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.7fr);
  }

  .about-section-reverse .about-copy {
    order: 2;
  }

  .about-section-reverse .about-media {
    order: 1;
  }

  .about-copy h2 {
    font-size: clamp(28px, 3vw, 40px);
  }

  .about-copy p {
    margin: 18px 0 0;
    color: #34363a;
    font-size: 17px;
    line-height: 1.75;
  }

  .about-media img {
    display: block;
    width: 100%;
    max-width: 460px;
    margin-left: auto;
    margin-right: auto;
    border-radius: 28px;
    object-fit: cover;
    box-shadow: 0 16px 40px rgba(17, 20, 24, 0.08);
  }

  :global(.reveal-ready.reveal-block) {
    opacity: 0;
    transform: translate3d(0, var(--reveal-distance, 24px), 0);
    transition:
      opacity 0.55s ease,
      transform 0.7s cubic-bezier(0.2, 0.8, 0.2, 1);
    transition-delay: var(--reveal-delay, 0ms);
  }

  :global(.reveal-visible.reveal-block) {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }

  .about-services {
    padding: 0 0 88px;
  }

  .about-section-heading {
    margin-bottom: 34px;
  }

  .about-section-heading h2 {
    font-size: clamp(28px, 3vw, 40px);
  }

  .about-service-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 22px;
  }

  .about-service-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    min-height: 200px;
    padding: 28px 24px;
    border-radius: 28px;
    background: #fff;
    box-shadow: 0 14px 34px rgba(17, 20, 24, 0.05);
    color: #000;
    text-align: center;
    text-decoration: none;
    transition:
      transform 0.18s cubic-bezier(0.22, 1, 0.36, 1),
      box-shadow 0.22s ease;
  }

  @media (hover: hover) {
    .about-service-card:hover {
      transform: translateY(-6px) scale(1.012);
      box-shadow: 0 20px 40px rgba(17, 20, 24, 0.09);
    }
  }

  .about-service-card:active {
    transform: translateY(-1px) scale(0.992);
  }

  .about-service-icon {
    font-size: 42px;
    color: #000;
  }

  .about-service-card span {
    font-family: var(--font-head);
    font-size: 24px;
    line-height: 1.2;
  }

  .about-contact {
    padding: 0 0 88px;
  }

  .about-contact-card {
    border-radius: 36px;
    background: #fff;
    padding: 42px 48px;
    box-shadow: 0 14px 34px rgba(17, 20, 24, 0.05);
    text-align: center;
  }

  .about-contact-card h2 {
    font-size: clamp(28px, 3vw, 42px);
  }

  .about-contact-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    align-items: center;
    margin-top: 28px;
  }

  .about-contact-link {
    color: #34363a;
    font-size: 20px;
    font-weight: 600;
    text-decoration: none;
  }

  @media (max-width: 1024px) {
    .about-section-grid,
    .about-section-reverse {
      grid-template-columns: 1fr;
    }

    .about-section-reverse .about-copy,
    .about-section-reverse .about-media {
      order: initial;
    }

    .about-service-grid,
    .about-contact-grid {
      grid-template-columns: 1fr;
    }
  }

  @media (max-width: 768px) {
    .about-inner {
      padding: 0 24px;
    }

    .about-hero {
      padding: 56px 0 24px;
    }

    .about-section,
    .about-services,
    .about-contact {
      padding-bottom: 64px;
    }

    .about-section-gradient {
      margin: 0 12px 64px;
      padding: 28px 0;
      border-radius: 28px;
    }

    .about-section-grid {
      gap: 24px;
    }

    .about-copy h2,
    .about-section-heading h2,
    .about-contact-card h2 {
      font-size: 30px;
    }

    .about-copy p {
      font-size: 16px;
      line-height: 1.7;
    }

    .about-service-card {
      min-height: 168px;
    }

    .about-contact-card {
      padding: 30px 24px;
    }

    .about-contact-grid {
      margin-top: 22px;
    }

    .about-contact-link {
      font-size: 18px;
    }
  }
</style>
