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

definePageMeta({ layout: 'page' })

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

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' }">
      <!-- Draft / legal-review banner -->
      <div :style="{ padding: '18px 22px', borderRadius: '4px', border: `1px solid ${C.warn}55`, background: `${C.warn}14`, fontFamily: '\'Inter\', sans-serif', fontSize: '14px', lineHeight: 1.55, color: t.fg }">
        {{ c.draftNote }}
      </div>
      <div :style="{ fontFamily: '\'JetBrains Mono\', monospace', fontSize: '12px', color: t.fgDim, margin: '14px 0 40px' }">{{ c.updated }}</div>

      <!-- Uptime headline -->
      <div :style="{ display: 'flex', alignItems: 'baseline', gap: '16px', flexWrap: 'wrap', paddingBottom: '8px', marginBottom: '40px', borderBottom: `1px solid ${t.border}` }">
        <span :style="{ fontFamily: '\'Inter Tight\', sans-serif', fontWeight: 600, fontSize: 'clamp(48px, 9vw, 72px)', letterSpacing: '-0.03em', lineHeight: 1, color: t.fg }">{{ c.uptimeValue }}</span>
        <span :style="{ fontFamily: '\'Inter\', sans-serif', fontSize: '16px', color: t.fgMuted }">{{ c.uptimeNote }}</span>
      </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>

      <!-- Support response-time table -->
      <h2 :style="headingStyle">{{ c.supportHeading }}</h2>
      <div :style="{ border: `1px solid ${t.border}`, borderRadius: '4px', overflow: 'hidden', margin: '0 0 40px' }">
        <div :style="{ display: 'grid', gridTemplateColumns: '1fr auto', gap: '16px', 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.supportCols[0] }}</span>
          <span :style="{ textAlign: 'right' }">{{ c.supportCols[1] }}</span>
        </div>
        <div
          v-for="(row, i) in c.support" :key="i"
          :style="{ display: 'grid', gridTemplateColumns: '1fr auto', gap: '16px', padding: '15px 20px', borderTop: i === 0 ? 'none' : `1px solid ${t.border}`, fontFamily: '\'Inter\', sans-serif', fontSize: '14px', alignItems: 'baseline' }"
        >
          <span :style="{ color: t.fg }">{{ row[0] }}</span>
          <span :style="{ color: t.fg, fontWeight: 600, textAlign: 'right', whiteSpace: 'nowrap' }">{{ row[1] }}</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>
