// Brand mark — image-based logo using the M2 Tech icon asset.
// The icon is placed inside a small rounded "tile" so the mark stays legible
// on both the light nav/paper surfaces and the dark footer/drawer.
//
// Artwork is generated from assets/logos/M2_Tech_Logo_Pack_GREEN-05.jpg as a
// trimmed, transparent PNG. The mark is roughly 2:1, so the tile is widened.
const LOGO_SRC = "assets/logo-mark.png";

const M2Logo = ({ size = 40, variant = "dark", showWordmark = false }) => {
  const fg = variant === "dark" ? "var(--ink)" : "var(--logo-bg)";

  return (
    <span style={{ display: "inline-flex", alignItems: "center", gap: 10, lineHeight: 1, whiteSpace: "nowrap" }}>
      <span
        className="logo-tile"
        style={{
          width: Math.round(size * 1.5),
          height: size,
          display: "inline-flex",
          alignItems: "center",
          justifyContent: "center",
          flexShrink: 0,
          background: "var(--logo-bg)",
          border: "1px solid var(--line)",
          borderRadius: "calc(var(--radius) * 0.6)",
          overflow: "hidden",
        }}
        aria-label="M2 Tech"
      >
        <img
          src={LOGO_SRC}
          alt="M2 Tech"
          width={Math.round(size * 1.2)}
          height={Math.round(size * 0.6)}
          style={{ width: "80%", height: "60%", objectFit: "contain", display: "block" }}
        />
      </span>

      {showWordmark && (
        <span
          style={{
            fontFamily: "'Inria Sans', serif",
            fontWeight: 700,
            fontSize: size * 0.42,
            letterSpacing: "0.02em",
            color: fg,
            whiteSpace: "nowrap",
          }}
        >
          M2&nbsp;TECH
        </span>
      )}
    </span>
  );
};

// Service discipline icons (web / app / game), sized by height.
// The web mark is a mask filled with currentColor so it follows the text
// colour — dark on light surfaces, light in dark mode and on hover.
const ServiceIcon = ({ kind, height = 56, className, style }) => {
  if (kind === "web")
  return <span className={className} role="img" aria-hidden="true" style={{
    display: "block", height, width: Math.round(height * 2.05), background: "currentColor",
    WebkitMask: "url(assets/icon-web.png) center / contain no-repeat",
    mask: "url(assets/icon-web.png) center / contain no-repeat", ...style
  }} />;
  const src = kind === "app" ? "assets/icon-app.png" : "assets/icon-game.png";
  return <img className={className} src={src} alt="" height={height} style={{ display: "block", height, width: "auto", ...style }} />;
};

window.M2Logo = M2Logo;
window.ServiceIcon = ServiceIcon;
