<script setup lang="ts">
// Section 05 — comparison table (Dezky vs US hyperscaler).
// Ported from landing-sections.jsx Compare.
import { useTheme, useCopy } from '~/composables/useLanding'
const t = useTheme()
const copy = useCopy()
</script>

<template>
  <section :style="{ background: t.bg, color: t.fg }">
    <LandingContainer pad="clamp(56px, 8vw, 140px) clamp(20px, 5vw, 64px)">
      <LandingSectionLabel :label="copy.compare.label" />
      <div class="compare-intro-grid" :style="{ display: 'grid', gap: '80px', alignItems: 'end', marginBottom: '56px' }">
        <h2 :style="{ fontFamily: '\'Inter Tight\', sans-serif', fontWeight: 600, fontSize: 'clamp(36px, 4.4vw, 64px)', letterSpacing: '-0.032em', lineHeight: 1.0, margin: 0, textWrap: 'balance', color: t.fg }">{{ copy.compare.heading }}</h2>
        <p :style="{ fontFamily: '\'Inter\', sans-serif', fontSize: '17px', lineHeight: 1.6, maxWidth: '460px', color: t.fgMuted, margin: 0, textWrap: 'pretty' }">{{ copy.compare.lede }}</p>
      </div>

      <div :style="{ border: `1px solid ${t.borderStrong}`, overflowX: 'auto' }">
        <div class="compare-table-grid compare-header" :style="{ display: 'grid', background: t.fg, color: t.bg }">
          <div :style="{ padding: '20px 28px', fontFamily: '\'JetBrains Mono\', monospace', fontSize: '11px', letterSpacing: '0.12em', textTransform: 'uppercase', opacity: 0.6 }">kategori</div>
          <div :style="{ padding: '20px 28px', display: 'flex', alignItems: 'center', gap: '10px', borderLeft: `1px solid ${t.fgDim}` }">
            <BrandNodeMark :size="18" :fg="t.signal" :accent="t.fg" />
            <span :style="{ fontFamily: '\'JetBrains Mono\', monospace', fontSize: '14px', fontWeight: 600 }">{{ copy.compare.cols[0] }}</span>
          </div>
          <div :style="{ padding: '20px 28px', fontFamily: '\'JetBrains Mono\', monospace', fontSize: '14px', fontWeight: 500, opacity: 0.7, borderLeft: `1px solid ${t.fgDim}` }">{{ copy.compare.cols[1] }}</div>
        </div>
        <div
          v-for="(row, i) in copy.compare.rows" :key="i"
          class="compare-table-grid"
          :style="{
            display: 'grid',
            borderTop: `1px solid ${t.border}`,
            background: i % 2 === 0 ? t.bg : t.bgAlt,
            fontFamily: '\'Inter\', sans-serif', fontSize: '15px',
          }"
        >
          <div class="cmp-cat" :style="{ padding: '22px 28px', color: t.fgMuted }">{{ row[0] }}</div>
          <div class="cmp-val" :style="{ padding: '22px 28px', color: t.fg, fontWeight: 600, borderLeft: `1px solid ${t.border}` }">
            <span class="cmp-key" :style="{ color: t.fgMuted }">{{ copy.compare.cols[0] }}</span>
            <span :style="{ display: 'flex', alignItems: 'center', gap: '10px' }">
              <span :style="{ width: '4px', height: '4px', background: t.signal, borderRadius: '999px', flexShrink: 0 }" />
              {{ row[1] }}
            </span>
          </div>
          <div class="cmp-val" :style="{ padding: '22px 28px', color: t.fgMuted, borderLeft: `1px solid ${t.border}` }">
            <span class="cmp-key" :style="{ color: t.fgMuted }">{{ copy.compare.cols[1] }}</span>
            {{ row[2] }}
          </div>
        </div>
      </div>
    </LandingContainer>
  </section>
</template>

<style scoped>
.compare-intro-grid {
  grid-template-columns: 1.1fr 1fr;
}

.compare-table-grid {
  grid-template-columns: 1.2fr 1fr 1fr;
}

/* The per-cell column label only appears once the table stacks on mobile. */
.cmp-key {
  display: none;
}

@media (max-width: 768px) {
  .compare-intro-grid {
    grid-template-columns: 1fr;
    gap: 24px !important;
  }

  .compare-table-grid {
    grid-template-columns: 1fr;
  }

  /* Header row is redundant once each value is labelled inline. */
  .compare-header {
    display: none;
  }

  /* Category becomes the card title; values drop the column divider + tighten. */
  .cmp-cat {
    font-weight: 600;
    padding-bottom: 2px !important;
  }
  .cmp-val {
    border-left: none !important;
    padding-top: 12px !important;
    padding-bottom: 14px !important;
  }
  .cmp-key {
    display: block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    font-weight: 500;
    margin-bottom: 5px;
  }
}
</style>
