// Shared components (TypeScript).


interface ArrowProps {
  rotate?: number;
  size?: number;
}

const Arrow: React.FC<ArrowProps> = ({ rotate = 0, size = 14 }) => (
  <svg width={size} height={size} viewBox="0 0 16 16" fill="none" aria-hidden="true" focusable="false" className="arr" style={{ transform: `rotate(${rotate}deg)` }}>
    <path d="M3 8h10M9 4l4 4-4 4" stroke="currentColor" strokeWidth="1.4" strokeLinecap="round" strokeLinejoin="round" />
  </svg>
);

interface LogoSlotProps {
  id?: string;
  w?: number;
  h?: number;
  dark?: boolean;
}

const LogoSlot: React.FC<LogoSlotProps> = ({ id = "rio3-logo", w = 110, h = 40, dark = false }) => (
  <span className="logo-slot logo-slot-bare" style={{ width: w, height: h }}>
    <Brand size={Math.round(h * 0.78)} dark={dark} />
  </span>
);

interface BrandProps {
  size?: number;
  dark?: boolean;
}

const Brand: React.FC<BrandProps> = ({ size = 28, dark = false }) => (
  <span className="brand wordmark" style={{ fontSize: size }}>
    <span className="wm-ri" style={dark ? { color: "#ffffff" } : undefined}>Ri</span>
    <span className="wm-o">O</span>
    <span className="wm-sub">3</span>
  </span>
);

// O3 Molecule SVG — schematic, not anatomical
interface OzoneMoleculeProps {
  animate?: boolean;
}

const OzoneMolecule: React.FC<OzoneMoleculeProps> = ({ animate = true }) => (
  <svg viewBox="0 0 400 400" className="ozone-svg" role="img" aria-label="Ozone molecule (O₃) — three oxygen atoms">
    <defs>
      {/* Glassy oxygen sphere — bright specular top-left, teal body, navy edge */}
      <radialGradient id="oz-atom" cx="36%" cy="32%" r="72%">
        <stop offset="0%" stopColor="#eafaff" />
        <stop offset="22%" stopColor="#7fd4ea" />
        <stop offset="60%" stopColor="#2aa3c8" />
        <stop offset="100%" stopColor="#124a63" />
      </radialGradient>
      {/* Central atom — a touch deeper for depth separation */}
      <radialGradient id="oz-atom-core" cx="36%" cy="32%" r="72%">
        <stop offset="0%" stopColor="#e7f6ff" />
        <stop offset="24%" stopColor="#5cc0dd" />
        <stop offset="62%" stopColor="#1d7fa0" />
        <stop offset="100%" stopColor="#0e2a3a" />
      </radialGradient>
      {/* Soft ambient halo behind the molecule */}
      <radialGradient id="oz-halo" cx="50%" cy="50%" r="50%">
        <stop offset="0%" stopColor="#2aa3c8" stopOpacity="0.28" />
        <stop offset="55%" stopColor="#2aa3c8" stopOpacity="0.08" />
        <stop offset="100%" stopColor="#2aa3c8" stopOpacity="0" />
      </radialGradient>
      {/* Bonds */}
      <linearGradient id="oz-bond" x1="0" y1="0" x2="1" y2="1">
        <stop offset="0%" stopColor="#1d7fa0" />
        <stop offset="100%" stopColor="#7fd4ea" />
      </linearGradient>
      {/* Depth shadow cast beneath the atoms */}
      <filter id="oz-shadow" x="-40%" y="-40%" width="180%" height="180%">
        <feDropShadow dx="0" dy="10" stdDeviation="12" floodColor="#0e2a3a" floodOpacity="0.28" />
      </filter>
    </defs>

    {/* ambient glow */}
    <circle cx="200" cy="212" r="150" fill="url(#oz-halo)" />

    <g transform="translate(200 212)">
      {animate && (
        <animateTransform attributeName="transform" additive="sum" type="translate" values="0 0; 0 -9; 0 0" dur="7s" repeatCount="indefinite" calcMode="spline" keySplines="0.4 0 0.6 1; 0.4 0 0.6 1" />
      )}

      {/* bonds (behind atoms) */}
      <g strokeLinecap="round" fill="none">
        <path d="M-92 44 L0 -62" stroke="url(#oz-bond)" strokeWidth="9" opacity="0.55" />
        <path d="M92 44 L0 -62" stroke="url(#oz-bond)" strokeWidth="9" opacity="0.55" />
      </g>

      {/* atoms with depth shadow */}
      <g filter="url(#oz-shadow)">
        <circle cx="-92" cy="44" r="50" fill="url(#oz-atom)" />
        <circle cx="92" cy="44" r="50" fill="url(#oz-atom)" />
        <circle cx="0" cy="-62" r="56" fill="url(#oz-atom-core)" />
      </g>

      {/* specular highlights */}
      <g fill="#ffffff" opacity="0.7">
        <ellipse cx="-107" cy="26" rx="15" ry="10" transform="rotate(-28 -107 26)" opacity="0.55" />
        <ellipse cx="77" cy="26" rx="15" ry="10" transform="rotate(-28 77 26)" opacity="0.55" />
        <ellipse cx="-18" cy="-82" rx="18" ry="12" transform="rotate(-28 -18 -82)" opacity="0.6" />
      </g>

      {/* thin rim light for a crisp glass edge */}
      <g fill="none" stroke="#eafaff" strokeOpacity="0.35" strokeWidth="1.5">
        <circle cx="-92" cy="44" r="49" />
        <circle cx="92" cy="44" r="49" />
        <circle cx="0" cy="-62" r="55" />
      </g>
    </g>

    <text x="200" y="366" textAnchor="middle" fill="#0e2a3a" fillOpacity="0.75" fontFamily="var(--mono)" fontSize="11" letterSpacing="3">OZONE · O₃</text>
  </svg>
);

const MapPlaceholder: FC = () => (
  <iframe
    src="https://www.google.com/maps?q=440+S+Federal+Hwy,+Deerfield+Beach,+FL+33441&output=embed"
    style={{ width: "100%", height: "100%", border: 0, display: "block" }}
    loading="lazy"
    referrerPolicy="no-referrer-when-downgrade"
    title="Rio3 location"
  />
);

const AppleMapsLink: FC = () => (
  <a
    href="https://maps.apple.com/?address=440+S+Federal+Hwy,+Suite+205,+Deerfield+Beach,+FL+33441"
    target="_blank"
    rel="noopener noreferrer"
    className="apple-maps-link"
  >
    <svg viewBox="0 0 24 24" fill="currentColor" width="14" height="14" aria-hidden="true">
      <path d="M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.54 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.029 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701z" />
    </svg>
    Get directions
  </a>
);

// Striped placeholder block (used inside image slots as visual indicator)
interface StripePhProps {
  label: string;
  height?: string | number;
  style?: React.CSSProperties;
}

const StripePh: React.FC<StripePhProps> = ({ label, height = "100%", style = {} }) => (
  <div className="stripe-ph" style={{ height, width: "100%", ...style }}>
    {label}
  </div>
);

Object.assign(window, { Arrow, LogoSlot, Brand, OzoneMolecule, MapPlaceholder, AppleMapsLink, StripePh });
