component FeatureCard {
  props {
    icon: string = ""
    iconStyle: string = "soft"
    iconSize: string = "default"
    eyebrow: string = ""
    title: string = "Feature"
    description: string = ""

    image: string = ""
    imageAlt: string = ""
    imagePosition: string = "top"
    imageAspect: string = "wide"
    imageLoading: string = "lazy"

    href: string = ""
    target: string = ""
    rel: string = ""
    external: boolean = false
    actionLabel: string = "Learn more"
    actionIcon: string = ""
    showArrow: boolean = true
    stretchedLink: boolean = true

    badge: string = ""
    badgeColor: string = "primary"
    size: string = "default"
    color: string = "primary"
    variant: string = "default"
    hover: string = "lift"
    align: string = "left"
    disabled: boolean = false
    class: string = ""
  }

  view {
    <article
      {...attrs}
      data-ui-component="FeatureCard"
      data-size='{size}'
      data-color='{color}'
      data-variant='{variant}'
      data-hover='{hover}'
      data-align='{align}'
      data-icon-style='{iconStyle}'
      data-icon-size='{iconSize}'
      data-image-position='{imagePosition}'
      data-image-aspect='{imageAspect}'
      data-disabled='{disabled ? "true" : "false"}'
      data-stretched-link='{stretchedLink ? "true" : "false"}'
      class='wrn-feature-card {class}'
      role="listitem"
      aria-disabled='{disabled ? "true" : "false"}'
    >
      {#if image}
        <div class="wrn-feature-card__media">
          <img
            src='{image}'
            alt='{imageAlt}'
            loading='{imageLoading}'
            class="wrn-feature-card__image"
          />
          <div class="wrn-feature-card__media-overlay" aria-hidden="true"></div>
        </div>
      {/if}

      <slot name="media"></slot>

      <div class="wrn-feature-card__body">
        <div class="wrn-feature-card__top">
          <div class="wrn-feature-card__leading">
            <slot name="icon"></slot>

            {#if icon}
              <div class="wrn-feature-card__icon" aria-hidden="true">
                <span class='{icon}'></span>
              </div>
            {/if}
          </div>

          {#if badge}
            <span class="wrn-feature-card__badge" data-color='{badgeColor}'>
              {badge}
            </span>
          {/if}
        </div>

        <div class="wrn-feature-card__copy">
          {#if eyebrow}
            <p class="wrn-feature-card__eyebrow">{eyebrow}</p>
          {/if}

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

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

        <div class="wrn-feature-card__content">
          <slot></slot>
        </div>

        <div class="wrn-feature-card__footer">
          <div class="wrn-feature-card__footer-content">
            <slot name="footer"></slot>
          </div>

          {#if href && actionLabel && !disabled}
            <a
              href='{href}'
              target='{target}'
              rel='{external || target === "_blank" ? "noopener noreferrer" : rel}'
              class="wrn-feature-card__action"
              aria-label='{actionLabel + ": " + title}'
            >
              <span>{actionLabel}</span>

              {#if actionIcon}
                <span class='wrn-feature-card__action-icon {actionIcon}' aria-hidden="true"></span>
              {:else if external}
                <span class="wrn-feature-card__action-icon icon-[lucide--external-link]" aria-hidden="true"></span>
              {:else if showArrow}
                <span class="wrn-feature-card__action-icon icon-[lucide--arrow-right]" aria-hidden="true"></span>
              {/if}
            </a>
          {:else if actionLabel}
            <span class="wrn-feature-card__action wrn-feature-card__action--disabled">
              <span>{actionLabel}</span>
            </span>
          {/if}
        </div>
      </div>
    </article>
  }

  style {
    .wrn-feature-card {
      --feature-accent: var(--wrn-color-primary);
      --feature-accent-hover: var(--wrn-color-primary-hover);
      --feature-accent-soft: var(--wrn-color-primary-soft);
      --feature-accent-muted: var(--wrn-color-primary-muted);
      --feature-contrast: var(--wrn-color-primary-contrast);
      --feature-border: color-mix(in srgb, var(--feature-accent) 16%, var(--wrn-color-border));

      position: relative;
      isolation: isolate;
      display: flex;
      flex-direction: column;
      width: 100%;
      min-width: 0;
      height: 100%;
      overflow: hidden;
      color: var(--wrn-color-text);
      background:
        radial-gradient(
          circle at 100% 0%,
          color-mix(in srgb, var(--feature-accent) 7%, transparent),
          transparent 34%
        ),
        var(--wrn-color-surface-raised);
      border: 1px solid var(--feature-border);
      border-radius: 1.25rem;
      box-shadow:
        0 1px 0 color-mix(in srgb, white 4%, transparent) inset,
        0 10px 30px color-mix(in srgb, black 9%, transparent);
      transition:
        transform 180ms ease,
        border-color 180ms ease,
        box-shadow 180ms ease,
        background-color 180ms ease;
    }

    .wrn-feature-card[data-color="secondary"] {
      --feature-accent: var(--wrn-color-secondary);
      --feature-accent-hover: var(--wrn-color-secondary-hover);
      --feature-accent-soft: var(--wrn-color-secondary-soft);
      --feature-accent-muted: var(--wrn-color-secondary-muted);
      --feature-contrast: var(--wrn-color-secondary-contrast);
    }

    .wrn-feature-card[data-color="info"] {
      --feature-accent: var(--wrn-color-info);
      --feature-accent-soft: var(--wrn-color-info-soft);
      --feature-accent-muted: var(--wrn-color-info-muted);
      --feature-contrast: var(--wrn-color-info-contrast);
    }

    .wrn-feature-card[data-color="success"] {
      --feature-accent: var(--wrn-color-success);
      --feature-accent-soft: var(--wrn-color-success-soft);
      --feature-accent-muted: var(--wrn-color-success-muted);
      --feature-contrast: var(--wrn-color-success-contrast);
    }

    .wrn-feature-card[data-color="warning"] {
      --feature-accent: var(--wrn-color-warning);
      --feature-accent-soft: var(--wrn-color-warning-soft);
      --feature-accent-muted: var(--wrn-color-warning-muted);
      --feature-contrast: var(--wrn-color-warning-contrast);
    }

    .wrn-feature-card[data-color="danger"] {
      --feature-accent: var(--wrn-color-danger);
      --feature-accent-soft: var(--wrn-color-danger-soft);
      --feature-accent-muted: var(--wrn-color-danger-muted);
      --feature-contrast: var(--wrn-color-danger-contrast);
    }

    .wrn-feature-card::before {
      position: absolute;
      top: 0;
      right: 0;
      left: 0;
      z-index: -1;
      height: 3px;
      content: "";
      background: linear-gradient(90deg, var(--feature-accent), transparent 72%);
      opacity: 0.8;
    }

    .wrn-feature-card__media {
      position: relative;
      overflow: hidden;
      background: var(--wrn-color-surface-soft);
      border-bottom: 1px solid var(--feature-border);
    }

    .wrn-feature-card[data-image-aspect="square"] .wrn-feature-card__media {
      aspect-ratio: 1;
    }

    .wrn-feature-card[data-image-aspect="portrait"] .wrn-feature-card__media {
      aspect-ratio: 4 / 5;
    }

    .wrn-feature-card[data-image-aspect="standard"] .wrn-feature-card__media {
      aspect-ratio: 4 / 3;
    }

    .wrn-feature-card[data-image-aspect="wide"] .wrn-feature-card__media {
      aspect-ratio: 16 / 9;
    }

    .wrn-feature-card[data-image-aspect="cinema"] .wrn-feature-card__media {
      aspect-ratio: 21 / 9;
    }

    .wrn-feature-card__image {
      display: block;
      width: 100%;
      height: 100%;
      object-fit: cover;
      transition: transform 300ms ease;
    }

    .wrn-feature-card__media-overlay {
      position: absolute;
      inset: 0;
      pointer-events: none;
      background: linear-gradient(180deg, transparent 58%, color-mix(in srgb, black 18%, transparent));
    }

    .wrn-feature-card__body {
      display: flex;
      flex: 1;
      flex-direction: column;
      min-width: 0;
      padding: 1.5rem;
    }

    .wrn-feature-card[data-size="sm"] .wrn-feature-card__body {
      padding: 1.1rem;
    }

    .wrn-feature-card[data-size="lg"] .wrn-feature-card__body {
      padding: 1.85rem;
    }

    .wrn-feature-card__top {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 1rem;
      min-width: 0;
    }

    .wrn-feature-card__leading {
      display: flex;
      align-items: center;
      min-width: 0;
    }

    .wrn-feature-card__icon {
      display: inline-flex;
      flex: 0 0 auto;
      align-items: center;
      justify-content: center;
      width: 3rem;
      height: 3rem;
      color: var(--feature-accent);
      background: var(--feature-accent-soft);
      border: 1px solid color-mix(in srgb, var(--feature-accent) 18%, transparent);
      border-radius: 0.95rem;
      box-shadow: 0 1px 0 color-mix(in srgb, white 7%, transparent) inset;
    }

    .wrn-feature-card__icon > span {
      width: 1.35rem;
      height: 1.35rem;
    }

    .wrn-feature-card[data-icon-size="sm"] .wrn-feature-card__icon {
      width: 2.5rem;
      height: 2.5rem;
      border-radius: 0.8rem;
    }

    .wrn-feature-card[data-icon-size="sm"] .wrn-feature-card__icon > span {
      width: 1.1rem;
      height: 1.1rem;
    }

    .wrn-feature-card[data-icon-size="lg"] .wrn-feature-card__icon {
      width: 3.6rem;
      height: 3.6rem;
      border-radius: 1.05rem;
    }

    .wrn-feature-card[data-icon-size="lg"] .wrn-feature-card__icon > span {
      width: 1.65rem;
      height: 1.65rem;
    }

    .wrn-feature-card[data-icon-style="solid"] .wrn-feature-card__icon {
      color: var(--feature-contrast);
      background: var(--feature-accent);
      border-color: color-mix(in srgb, white 18%, transparent);
      box-shadow: 0 10px 24px color-mix(in srgb, var(--feature-accent) 24%, transparent);
    }

    .wrn-feature-card[data-icon-style="outline"] .wrn-feature-card__icon {
      color: var(--feature-accent);
      background: transparent;
      border-color: color-mix(in srgb, var(--feature-accent) 38%, var(--wrn-color-border));
      box-shadow: none;
    }

    .wrn-feature-card[data-icon-style="ghost"] .wrn-feature-card__icon {
      width: auto;
      height: auto;
      padding: 0.25rem;
      background: transparent;
      border-color: transparent;
      border-radius: 0;
      box-shadow: none;
    }

    .wrn-feature-card__badge {
      display: inline-flex;
      flex: 0 0 auto;
      align-items: center;
      min-height: 1.65rem;
      padding: 0.25rem 0.65rem;
      color: var(--feature-accent);
      font-size: 0.7rem;
      font-weight: 600;
      line-height: 1;
      white-space: nowrap;
      background: var(--feature-accent-soft);
      border: 1px solid color-mix(in srgb, var(--feature-accent) 18%, transparent);
      border-radius: 999px;
    }

    .wrn-feature-card__badge[data-color="secondary"] {
      color: var(--wrn-color-secondary);
      background: var(--wrn-color-secondary-soft);
      border-color: color-mix(in srgb, var(--wrn-color-secondary) 20%, transparent);
    }

    .wrn-feature-card__badge[data-color="info"] {
      color: var(--wrn-color-info);
      background: var(--wrn-color-info-soft);
      border-color: color-mix(in srgb, var(--wrn-color-info) 20%, transparent);
    }

    .wrn-feature-card__badge[data-color="success"] {
      color: var(--wrn-color-success);
      background: var(--wrn-color-success-soft);
      border-color: color-mix(in srgb, var(--wrn-color-success) 20%, transparent);
    }

    .wrn-feature-card__badge[data-color="warning"] {
      color: var(--wrn-color-warning-text);
      background: var(--wrn-color-warning-soft);
      border-color: color-mix(in srgb, var(--wrn-color-warning) 22%, transparent);
    }

    .wrn-feature-card__badge[data-color="danger"] {
      color: var(--wrn-color-danger);
      background: var(--wrn-color-danger-soft);
      border-color: color-mix(in srgb, var(--wrn-color-danger) 20%, transparent);
    }

    .wrn-feature-card__copy {
      min-width: 0;
      margin-top: 1.25rem;
    }

    .wrn-feature-card__eyebrow {
      margin: 0 0 0.5rem;
      color: var(--feature-accent);
      font-size: 0.72rem;
      font-weight: 600;
      line-height: 1.3;
      letter-spacing: 0.12em;
      text-transform: uppercase;
    }

    .wrn-feature-card__title {
      margin: 0;
      color: var(--wrn-color-text);
      font-size: 1.1rem;
      font-weight: 600;
      line-height: 1.35;
      letter-spacing: -0.015em;
      text-wrap: balance;
      transition: color 180ms ease;
    }

    .wrn-feature-card[data-size="sm"] .wrn-feature-card__title {
      font-size: 1rem;
    }

    .wrn-feature-card[data-size="lg"] .wrn-feature-card__title {
      font-size: 1.3rem;
    }

    .wrn-feature-card__description {
      margin: 0.75rem 0 0;
      color: var(--wrn-color-text-muted);
      font-size: 0.9rem;
      line-height: 1.65;
      text-wrap: pretty;
    }

    .wrn-feature-card[data-size="sm"] .wrn-feature-card__description {
      margin-top: 0.6rem;
      font-size: 0.82rem;
      line-height: 1.55;
    }

    .wrn-feature-card[data-size="lg"] .wrn-feature-card__description {
      font-size: 0.98rem;
    }

    /*
     * Slot content is app-authored, so a bare `p { color: ... }` in the app
     * stylesheet beats anything this container merely passes down by
     * inheritance. State it, at a specificity the app can still override.
     */
    .wrn-feature-card__content {
      color: var(--wrn-color-text);
      min-width: 0;
      margin-top: 1rem;
    }

    .wrn-feature-card__content:empty {
      display: none;
    }

    .wrn-feature-card__footer {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 1rem;
      min-width: 0;
      margin-top: auto;
      padding-top: 1.35rem;
    }

    .wrn-feature-card__footer-content {
      position: relative;
      z-index: 3;
      min-width: 0;
    }

    .wrn-feature-card__footer-content:empty {
      display: none;
    }

    .wrn-feature-card__action {
      position: relative;
      z-index: 2;
      display: inline-flex;
      flex: 0 0 auto;
      align-items: center;
      justify-content: center;
      gap: 0.45rem;
      min-height: 2.25rem;
      margin-left: auto;
      color: var(--feature-accent);
      font-size: 0.84rem;
      font-weight: 600;
      line-height: 1.2;
      text-decoration: none;
      transition:
        color 180ms ease,
        gap 180ms ease;
    }

    .wrn-feature-card__action::before {
      position: absolute;
      inset: -0.4rem -0.55rem;
      content: "";
      border-radius: 0.75rem;
    }

    .wrn-feature-card[data-stretched-link="true"] .wrn-feature-card__action::after {
      position: absolute;
      inset: auto;
      z-index: 1;
      content: "";
    }

    .wrn-feature-card[data-stretched-link="true"] .wrn-feature-card__action {
      position: static;
    }

    .wrn-feature-card[data-stretched-link="true"] .wrn-feature-card__action::after {
      position: absolute;
      inset: 0;
      border-radius: inherit;
    }

    .wrn-feature-card__action:hover {
      color: var(--feature-accent-hover, var(--feature-accent));
      gap: 0.65rem;
    }

    .wrn-feature-card__action:focus-visible {
      outline: 2px solid var(--wrn-color-focus);
      outline-offset: 4px;
      border-radius: 0.55rem;
    }

    .wrn-feature-card__action-icon {
      width: 1rem;
      height: 1rem;
      transition: transform 180ms ease;
    }

    .wrn-feature-card__action:hover .wrn-feature-card__action-icon {
      transform: translateX(0.15rem);
    }

    .wrn-feature-card__action--disabled {
      color: var(--wrn-color-text-muted);
      opacity: 0.7;
    }

    .wrn-feature-card[data-align="center"] .wrn-feature-card__body {
      align-items: center;
      text-align: center;
    }

    .wrn-feature-card[data-align="center"] .wrn-feature-card__top,
    .wrn-feature-card[data-align="center"] .wrn-feature-card__footer {
      width: 100%;
      justify-content: center;
    }

    .wrn-feature-card[data-align="center"] .wrn-feature-card__action {
      margin-inline: auto;
    }

    .wrn-feature-card[data-align="right"] .wrn-feature-card__body {
      align-items: flex-end;
      text-align: right;
    }

    .wrn-feature-card[data-align="right"] .wrn-feature-card__top,
    .wrn-feature-card[data-align="right"] .wrn-feature-card__footer {
      width: 100%;
      justify-content: flex-end;
    }

    .wrn-feature-card[data-variant="raised"] {
      box-shadow:
        0 1px 0 color-mix(in srgb, white 5%, transparent) inset,
        0 20px 50px color-mix(in srgb, black 17%, transparent);
    }

    .wrn-feature-card[data-variant="soft"] {
      background:
        linear-gradient(135deg, var(--feature-accent-soft), transparent 68%),
        var(--wrn-color-surface-raised);
      border-color: color-mix(in srgb, var(--feature-accent) 22%, var(--wrn-color-border));
      box-shadow: none;
    }

    .wrn-feature-card[data-variant="outline"] {
      background: transparent;
      box-shadow: none;
    }

    .wrn-feature-card[data-variant="ghost"] {
      background: transparent;
      border-color: transparent;
      box-shadow: none;
    }

    .wrn-feature-card[data-variant="minimal"] {
      background: transparent;
      border-color: transparent;
      border-radius: 0;
      box-shadow: none;
    }

    .wrn-feature-card[data-variant="solid"] {
      color: var(--feature-contrast);
      background:
        linear-gradient(135deg, color-mix(in srgb, white 9%, transparent), transparent 60%),
        var(--feature-accent);
      border-color: color-mix(in srgb, white 20%, transparent);
      box-shadow: 0 22px 54px color-mix(in srgb, var(--feature-accent) 28%, transparent);
    }

    .wrn-feature-card[data-variant="solid"] .wrn-feature-card__title,
    .wrn-feature-card[data-variant="solid"] .wrn-feature-card__description,
    .wrn-feature-card[data-variant="solid"] .wrn-feature-card__eyebrow,
    .wrn-feature-card[data-variant="solid"] .wrn-feature-card__action {
      color: var(--feature-contrast);
    }

    .wrn-feature-card[data-variant="solid"] .wrn-feature-card__description {
      opacity: 0.8;
    }

    .wrn-feature-card[data-variant="solid"] .wrn-feature-card__icon,
    .wrn-feature-card[data-variant="solid"] .wrn-feature-card__badge {
      color: var(--feature-contrast);
      background: color-mix(in srgb, white 12%, transparent);
      border-color: color-mix(in srgb, white 20%, transparent);
    }

    .wrn-feature-card[data-variant="gradient"] {
      background:
        radial-gradient(circle at 100% 0%, color-mix(in srgb, var(--feature-accent) 24%, transparent), transparent 44%),
        linear-gradient(145deg, var(--wrn-color-surface-raised), color-mix(in srgb, var(--feature-accent) 8%, var(--wrn-color-surface-raised)));
      border-color: color-mix(in srgb, var(--feature-accent) 26%, var(--wrn-color-border));
    }

    .wrn-feature-card[data-hover="lift"]:not([data-disabled="true"]):hover {
      transform: translateY(-0.3rem);
      border-color: color-mix(in srgb, var(--feature-accent) 48%, var(--wrn-color-border));
      box-shadow:
        0 1px 0 color-mix(in srgb, white 5%, transparent) inset,
        0 24px 58px color-mix(in srgb, black 20%, transparent);
    }

    .wrn-feature-card[data-hover="shadow"]:not([data-disabled="true"]):hover {
      box-shadow:
        0 1px 0 color-mix(in srgb, white 5%, transparent) inset,
        0 24px 58px color-mix(in srgb, black 20%, transparent);
    }

    .wrn-feature-card[data-hover="border"]:not([data-disabled="true"]):hover {
      border-color: color-mix(in srgb, var(--feature-accent) 58%, var(--wrn-color-border));
    }

    .wrn-feature-card[data-hover="glow"]:not([data-disabled="true"]):hover {
      border-color: color-mix(in srgb, var(--feature-accent) 54%, var(--wrn-color-border));
      box-shadow: 0 20px 60px color-mix(in srgb, var(--feature-accent) 22%, transparent);
    }

    .wrn-feature-card:not([data-disabled="true"]):hover .wrn-feature-card__image {
      transform: scale(1.035);
    }

    .wrn-feature-card:not([data-disabled="true"]):hover .wrn-feature-card__title {
      color: var(--feature-accent);
    }

    .wrn-feature-card[data-variant="solid"]:not([data-disabled="true"]):hover .wrn-feature-card__title {
      color: var(--feature-contrast);
    }

    .wrn-feature-card[data-disabled="true"] {
      pointer-events: none;
      opacity: 0.55;
      filter: saturate(0.65);
    }

    @media (min-width: 48rem) {
      .wrn-feature-card[data-image-position="left"],
      .wrn-feature-card[data-image-position="right"] {
        display: grid;
        grid-template-columns: minmax(0, 0.88fr) minmax(0, 1.12fr);
      }

      .wrn-feature-card[data-image-position="right"] {
        grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr);
      }

      .wrn-feature-card[data-image-position="right"] .wrn-feature-card__media {
        order: 2;
        border-right: 0;
        border-bottom: 0;
        border-left: 1px solid var(--feature-border);
      }

      .wrn-feature-card[data-image-position="left"] .wrn-feature-card__media {
        border-right: 1px solid var(--feature-border);
        border-bottom: 0;
      }

      .wrn-feature-card[data-image-position="left"] .wrn-feature-card__media,
      .wrn-feature-card[data-image-position="right"] .wrn-feature-card__media {
        height: 100%;
        min-height: 15rem;
        aspect-ratio: auto;
      }
    }

    @media (prefers-reduced-motion: reduce) {
      .wrn-feature-card,
      .wrn-feature-card__image,
      .wrn-feature-card__action,
      .wrn-feature-card__action-icon {
        transition: none;
      }
    }
  }
}
