<script setup lang="ts">
import { useTheme, useCopy } from '~/composables/useLanding'

definePageMeta({ layout: 'page' })

const t = useTheme()
const copy = useCopy()
const c = computed(() => copy.value.pages.cookies)

const headingStyle = computed(() => ({
  fontFamily: '\'Inter Tight\', sans-serif', fontWeight: 600, fontSize: '22px',
  letterSpacing: '-0.015em', color: t.value.fg, margin: '0 0 14px',
}))
</script>

<template>
  <LandingPageHeader :label="c.label" :title="c.title" :intro="c.intro" />

  <LandingContainer pad="clamp(32px, 5vw, 48px) clamp(20px, 5vw, 64px) clamp(80px, 12vw, 160px)">
    <div :style="{ maxWidth: '760px' }">
      <div :style="{ fontFamily: '\'JetBrains Mono\', monospace', fontSize: '12px', color: t.fgDim, margin: '0 0 48px' }">{{ c.updated }}</div>

      <!-- Clauses -->
      <section v-for="(s, i) in c.sections" :key="i" :style="{ marginBottom: '36px' }">
        <h2 :style="headingStyle">{{ s.h }}</h2>
        <p
          v-for="(para, j) in s.p" :key="j"
          :style="{ fontFamily: '\'Inter\', sans-serif', fontSize: '15px', lineHeight: 1.65, color: t.fgMuted, margin: '0 0 12px', textWrap: 'pretty' }"
        >{{ para }}</p>
      </section>

      <!-- Cookie table -->
      <h2 :style="headingStyle">{{ c.tableHeading }}</h2>
      <div :style="{ border: `1px solid ${t.border}`, borderRadius: '4px', overflow: 'hidden', margin: '0 0 40px' }">
        <div class="cookie-row cookie-header" :style="{ padding: '13px 20px', background: t.surface, borderBottom: `1px solid ${t.border}`, fontFamily: '\'JetBrains Mono\', monospace', fontSize: '11px', letterSpacing: '0.06em', textTransform: 'uppercase', color: t.fgMuted }">
          <span>{{ c.tableCols[0] }}</span>
          <span>{{ c.tableCols[1] }}</span>
          <span>{{ c.tableCols[2] }}</span>
        </div>
        <div
          v-for="(row, i) in c.table" :key="i"
          class="cookie-row"
          :style="{ padding: '16px 20px', borderTop: i === 0 ? 'none' : `1px solid ${t.border}`, fontFamily: '\'Inter\', sans-serif', fontSize: '14px', alignItems: 'baseline' }"
        >
          <span :style="{ color: t.fg, fontWeight: 600, fontFamily: '\'JetBrains Mono\', monospace', fontSize: '13px' }">{{ row[0] }}</span>
          <span :style="{ color: t.fgMuted }">{{ row[1] }}</span>
          <span :style="{ color: t.fgMuted, fontFamily: '\'JetBrains Mono\', monospace', fontSize: '12px' }">{{ row[2] }}</span>
        </div>
      </div>

      <!-- Contact -->
      <h2 :style="headingStyle">{{ c.contactHeading }}</h2>
      <p :style="{ fontFamily: '\'Inter\', sans-serif', fontSize: '15px', lineHeight: 1.6, color: t.fgMuted, margin: 0 }">{{ c.contactBody }}</p>
    </div>
  </LandingContainer>
</template>

<style scoped>
.cookie-row {
  display: grid;
  grid-template-columns: 0.9fr 1.6fr 0.7fr;
  gap: 16px;
}
@media (max-width: 768px) {
  .cookie-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .cookie-header {
    display: none;
  }
}
</style>
