import Link from "next/link";

import { SulsysLogo, SulsysLockup } from "./brand/SulsysMark";
import styles from "./LockUp.module.css";

import { getT } from "@/lib/content";
import type { Locale } from "@/lib/locales";
import { href } from "@/lib/routes";

/**
 * The site mark. SULSYS, and only SULSYS.
 *
 * The first build set NEXYS SYSTEM as the global identity with "by SULSYS"
 * underneath it, which inverted the real relationship: Sulsys is the company,
 * Nexys is the software it sells. A visitor who lands on any page must be able
 * to answer "whose site is this?" from the top-left corner alone, and the
 * answer is the company.
 *
 * V2 answered it typographically, because no vector of the real mark existed
 * and drawing one from memory would have been inventing the company's
 * identity. The approved reference now exists, so the corner carries the
 * actual Sulsys logo: the swept blades and the SulSys.Net wordmark, traced
 * from the artwork rather than redrawn. This is the single change that does
 * most to make the site read as *this* company's rather than as a well-made
 * site about a company.
 *
 * The mark is `aria-hidden` and the company's name sits beside it as real text
 * for assistive technology, so the link announces "Sulsys" rather than a file
 * name — and so the hierarchy stays testable from the DOM.
 */
export function LockUp({
  locale,
  size = "default",
  asLink = true,
}: {
  locale: Locale;
  size?: "default" | "large";
  asLink?: boolean;
}) {
  const t = getT(locale);

  const inner = (
    <>
      {size === "large" ? (
        /*
         * The footer signature: the full heritage lockup, tagline included.
         * This is the one place on the site that shows the complete historical
         * identity, which is why the tagline does not need to appear in the
         * header of every page to be present.
         */
        <SulsysLockup />
      ) : (
        <SulsysLogo tier="compact" />
      )}
      <span className="visually-hidden">{t("site.companyName")}</span>
    </>
  );

  const className = [styles.lockup, size === "large" ? styles.large : null]
    .filter(Boolean)
    .join(" ");

  if (!asLink) {
    return <span className={className}>{inner}</span>;
  }

  return (
    <Link href={href({ key: "home" }, locale)} className={className}>
      {inner}
    </Link>
  );
}

/*
 * There is deliberately no Nexys mark in this file.
 *
 * V2 exported a `NexysRing` — a plain circle, described as a flat redraw of
 * the product's ring. The source it redrew (ASSET-MANIFEST A-05) turns out to
 * be the 2016 software-box badge: a lime 3-D torus stamped with a version
 * number over a spreadsheet, which the manifest itself marks DO NOT USE. A
 * circle was not that mark; it was a new one.
 *
 * Inventing the company's mark was ruled out here from the start, and the same
 * rule has to apply to the product's. Nexys is set in type until Sulsys
 * supplies a real vector for it, at which point it belongs in this file beside
 * the Sulsys marks — and never in the site header, which is the company's
 * corner.
 */
