<template>
  <div class="tier-picker">
    <div
      v-for="tier in tiers"
      :key="tier.amount"
      class="tier-option"
      :class="{ current: modelValue === tier.amount }"
      @click="$emit('update:modelValue', tier.amount)"
    >
      <span class="tier-amount">{{ tier.display }}</span>
      <span v-if="tier.subtitle" class="tier-subtitle">{{ tier.subtitle }}</span>
    </div>
  </div>
</template>

<script setup>
defineProps({
  modelValue: { type: Number, default: 0 },
  tiers: {
    type: Array,
    default: () => [
      { amount: 0, display: "$0", label: "Free" },
      { amount: 5, display: "$5", label: "/month" },
      { amount: 15, display: "$15", label: "/month" },
      { amount: 30, display: "$30", label: "/month" },
      { amount: 50, display: "$50", label: "/month" },
    ],
  },
});

defineEmits(["update:modelValue"]);
</script>

<style scoped>
.tier-picker {
  display: flex;
  gap: 0;
  margin-bottom: 12px;
}

.tier-option {
  flex: 1;
  padding: 18px 8px;
  text-align: center;
  border: 1px dashed var(--border);
  background: var(--bg);
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}

/* Overlap adjacent borders so dashed lines collapse into one */
.tier-option + .tier-option {
  margin-left: -1px;
}

.tier-option:hover {
  background: var(--surface-hover);
}

/* Active item paints its solid border on top of any neighbor */
.tier-option.current {
  border-color: var(--candle);
  border-style: solid;
  background: var(--surface);
  z-index: 1;
}

.tier-amount {
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  font-family: "Brygada 1918", serif;
  display: block;
  line-height: 1.1;
}

.tier-option.current .tier-amount {
  color: var(--candle);
}

.tier-subtitle {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-dim);
  font-family: "Commit Mono", monospace;
  letter-spacing: 0.02em;
}

@media (max-width: 768px) {
  .tier-picker {
    flex-wrap: wrap;
  }
  .tier-option {
    min-width: 60px;
  }
}
</style>
