import type { CSSProperties } from "react";

/** Full DSHN lockup: infinity mark + DSHN wordmark (transparent PNG). */
const LOCKUP_SRC =
  "https://public.readdy.ai/ai/img_res/e1b1e71c-4243-4e9e-866a-3c738b0c183d.png";

/** Mark only: infinity symbol (transparent PNG). */
const MARK_SRC = "https://public.readdy.ai/ai/img_res/31b5650b-2393-474a-8c6f-9f5432b06421.png";

function cn(...cls: Array<string | false | null | undefined>): string {
  return cls.filter(Boolean).join(" ");
}

/**
 * The artwork is used as an alpha mask painted with `currentColor`,
 * so the logo automatically matches the text color around it
 * (dark on light surfaces, white on dark surfaces).
 */
function maskStyle(src: string): CSSProperties {
  return {
    backgroundColor: "currentColor",
    WebkitMaskImage: `url("${src}")`,
    maskImage: `url("${src}")`,
    WebkitMaskRepeat: "no-repeat",
    maskRepeat: "no-repeat",
    WebkitMaskPosition: "center",
    maskPosition: "center",
    WebkitMaskSize: "contain",
    maskSize: "contain",
  };
}

export function BrandLogo({
  className = "w-[52px] h-[34px]",
  title = "DSHN",
}: {
  className?: string;
  title?: string;
}) {
  return (
    <span
      role="img"
      aria-label={title}
      title={title}
      style={maskStyle(LOCKUP_SRC)}
      className={cn("inline-block align-middle shrink-0 select-none", className)}
    />
  );
}

export function BrandMark({
  className = "w-7 h-6",
  title = "DSHN",
}: {
  className?: string;
  title?: string;
}) {
  return (
    <span
      role="img"
      aria-label={title}
      title={title}
      style={maskStyle(MARK_SRC)}
      className={cn("inline-block align-middle shrink-0 select-none", className)}
    />
  );
}

export default BrandLogo;