<template>
  <div class="settings-landing">
    <p class="landing-intro">
      Pick a section from the left, or choose one below.
    </p>

    <section v-for="group in visibleGroups" :key="group.title" class="landing-section">
      <h2 class="section-heading">{{ group.title }}</h2>
      <div class="landing-grid">
        <router-link
          v-for="card in group.cards"
          :key="card.to"
          :to="card.to"
          class="landing-card"
        >
          <div class="card-head">
            <span class="card-icon"><component :is="card.icon" :size="18" /></span>
            <h3>{{ card.title }}</h3>
          </div>
          <p>{{ card.description }}</p>
        </router-link>
      </div>
    </section>
  </div>
</template>

<script setup>
import { computed } from 'vue'
import { useSettingsCatalog } from '../../composables/settingsCatalog'

// Core settings groups merged with plugin-contributed cards (ADR-010).
const { groups } = useSettingsCatalog()

// Drop empty groups (e.g. the Measuring Tools placeholder when its plugin is
// disabled) so a bare section heading never renders.
const visibleGroups = computed(() => groups.value.filter(g => g.cards.length))
</script>

<style scoped>
.landing-intro {
  margin: 0 0 1.5rem 0;
  color: var(--text-light);
}

.landing-section {
  margin-bottom: 1.75rem;
}
.section-heading {
  margin: 0 0 0.6rem 0;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-light);
}

.landing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.7rem;
}

.landing-card {
  display: block;
  padding: 0.8rem 0.9rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.landing-card:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.card-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.3rem;
}
.card-icon {
  display: inline-flex;
  color: var(--primary);
}
.landing-card h3 {
  margin: 0;
  font-size: 0.92rem;
  color: var(--text);
}
.landing-card p {
  margin: 0;
  color: var(--text-light);
  font-size: 0.82rem;
  line-height: 1.35;
}
</style>
