import TextLink from "./TextLink.wrn"

component FeatureIconCard {
  props {
    icon: string = "icon-[lucide--sparkles]"
    iconSize: string = "md"
    iconVariant: string = "soft"
    title: string = "Feature"
    description: string = ""
    href: string = ""
    actionLabel: string = "Explore"
    badge: string = ""
    size: string = "default"
    color: string = "primary"
    variant: string = "default"
    align: string = "left"
    hover: string = "lift"
    class: string = ""
  }

  view {
    <article
      data-ui-component="FeatureIconCard"
      data-size='{size}' data-variant='{variant}' data-hover='{hover}' data-align='{align}'
      class='wrn-feature-icon-card {class}'
    >
      <div
        class="wrn-feature-icon-card__icon"
        data-size='{iconSize}' data-variant='{iconVariant}' data-color='{color}'
      >
        <span class='{icon + " wrn-feature-icon-card__icon-glyph"}' aria-hidden="true"></span>

        {#if badge}
          <span class="wrn-feature-icon-card__badge">
            {badge}
          </span>
        {/if}
      </div>

      <h3 class="wrn-feature-icon-card__title">{title}</h3>

      {#if description}
        <p class="wrn-feature-icon-card__description">{description}</p>
      {/if}

      <slot></slot>

      {#if href}
        <TextLink
          label='{actionLabel}'
          href='{href}'
          color='{color}'
          size="sm"
          class="wrn-feature-icon-card__action"
        />
      {/if}

      <slot name="footer"></slot>
    </article>
  }

  style {
    .wrn-feature-icon-card { position: relative; display: flex; height: 100%; flex-direction: column; padding: 1.5rem; border: 1px solid var(--wrn-color-border); border-radius: calc(var(--wrn-radius) * 2); background: var(--wrn-color-surface-raised); box-shadow: var(--wrn-shadow-1); transition: transform var(--wrn-motion-base), border-color var(--wrn-motion-base), box-shadow var(--wrn-motion-base); }
    .wrn-feature-icon-card[data-size="sm"] { padding: 1.25rem; } .wrn-feature-icon-card[data-size="lg"] { padding: 2rem; }
    .wrn-feature-icon-card[data-variant="soft"] { background: var(--wrn-color-surface-soft); }
    .wrn-feature-icon-card[data-variant="ghost"] { border-color: transparent; background: transparent; box-shadow: none; }
    .wrn-feature-icon-card[data-hover="lift"]:hover { transform: translateY(-0.25rem); }
    .wrn-feature-icon-card:is([data-hover="lift"], [data-hover="shadow"]):hover { box-shadow: var(--wrn-shadow-3); }
    .wrn-feature-icon-card:is([data-hover="lift"], [data-hover="border"]):hover { border-color: var(--wrn-color-primary); }
    .wrn-feature-icon-card[data-align="center"] { align-items: center; text-align: center; }
    .wrn-feature-icon-card__icon { position: relative; display: flex; width: 3.5rem; height: 3.5rem; align-items: center; justify-content: center; border: 1px solid var(--wrn-color-primary-muted); border-radius: calc(var(--wrn-radius) * 1.5); color: var(--wrn-color-primary); background: var(--wrn-color-primary-soft); }
    .wrn-feature-icon-card__icon[data-size="sm"] { width: 3rem; height: 3rem; } .wrn-feature-icon-card__icon[data-size="lg"] { width: 4rem; height: 4rem; }
    .wrn-feature-icon-card__icon[data-variant="solid"] { color: var(--wrn-color-on-primary); background: var(--wrn-color-primary); }
    .wrn-feature-icon-card__icon[data-color="success"]:not([data-variant="solid"]) { color: var(--wrn-color-success); background: var(--wrn-color-success-soft); }
    .wrn-feature-icon-card__icon[data-color="warning"]:not([data-variant="solid"]) { color: var(--wrn-color-warning-text); background: var(--wrn-color-warning-soft); }
    .wrn-feature-icon-card__icon[data-color="danger"]:not([data-variant="solid"]) { color: var(--wrn-color-danger); background: var(--wrn-color-danger-soft); }
    .wrn-feature-icon-card__icon-glyph { width: 1.75rem; height: 1.75rem; }
    .wrn-feature-icon-card__badge { position: absolute; top: -0.5rem; right: -0.5rem; padding: 0.25rem 0.5rem; border: 1px solid var(--wrn-color-border); border-radius: 999px; color: var(--wrn-color-primary); background: var(--wrn-color-surface-raised); box-shadow: var(--wrn-shadow-1); font-size: 0.625rem; font-weight: 700; letter-spacing: 0.025em; text-transform: uppercase; }
    .wrn-feature-icon-card__title { margin-top: 1.5rem; color: var(--wrn-color-text); font-size: 1.25rem; font-weight: 700; letter-spacing: -0.025em; }
    .wrn-feature-icon-card__description { flex: 1; margin-top: 0.75rem; color: var(--wrn-color-text-muted); font-size: 0.875rem; line-height: 1.5rem; }
    .wrn-feature-icon-card__action { margin-top: 1.5rem; }
  }
}
