// Shared components

const { useState, useEffect, useRef, useMemo } = React;

// ---------- Icons (minimal hand-drawn — lucide-ish) ----------
const Icon = {
  Phone: (props) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...props}>
      <path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72c.13.96.36 1.9.7 2.81a2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45c.91.34 1.85.57 2.81.7A2 2 0 0 1 22 16.92z" />
    </svg>
  ),
  Mail: (props) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...props}>
      <rect x="2" y="4" width="20" height="16" rx="2" />
      <path d="m2 7 10 7 10-7" />
    </svg>
  ),
  Facebook: (props) => (
    <svg viewBox="0 0 24 24" fill="currentColor" {...props}>
      <path d="M13 22v-8h2.6l.4-3.2H13V8.7c0-.9.3-1.6 1.7-1.6H16V4.2c-.3 0-1.3-.1-2.4-.1-2.4 0-4 1.4-4 4.1v2.6H7V14h2.6v8H13z" />
    </svg>
  ),
  Instagram: (props) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...props}>
      <rect x="3" y="3" width="18" height="18" rx="5" />
      <circle cx="12" cy="12" r="4" />
      <circle cx="17.5" cy="6.5" r="0.9" fill="currentColor" />
    </svg>
  ),
  ArrowRight: (props) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...props}>
      <path d="M5 12h14M13 5l7 7-7 7" />
    </svg>
  ),
  Menu: (props) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.8" strokeLinecap="round" {...props}>
      <path d="M4 7h16M4 12h16M4 17h16" />
    </svg>
  ),
  Close: (props) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" {...props}>
      <path d="M6 6l12 12M18 6L6 18" />
    </svg>
  ),
  Heart: (props) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...props}>
      <path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z" />
    </svg>
  ),
  Camera: (props) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...props}>
      <path d="M14.5 4h-5L8 6H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-4l-1.5-2z" />
      <circle cx="12" cy="13" r="4" />
    </svg>
  ),
  Sparkles: (props) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...props}>
      <path d="M12 3v4M12 17v4M3 12h4M17 12h4M5.6 5.6l2.8 2.8M15.6 15.6l2.8 2.8M5.6 18.4l2.8-2.8M15.6 8.4l2.8-2.8" />
    </svg>
  ),
  Shield: (props) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...props}>
      <path d="M12 2 4 5v6c0 5 3.4 9.4 8 11 4.6-1.6 8-6 8-11V5l-8-3z" />
    </svg>
  ),
  Check: (props) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...props}>
      <path d="M20 6 9 17l-5-5" />
    </svg>
  ),
  Eye: (props) => (
    <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" {...props}>
      <path d="M1 12s4-7 11-7 11 7 11 7-4 7-11 7S1 12 1 12z" />
      <circle cx="12" cy="12" r="3" />
    </svg>
  ),
  Star: (props) => (
    <svg viewBox="0 0 24 24" fill="currentColor" {...props}>
      <path d="m12 2 2.93 6.5 7.07.7-5.3 4.84 1.55 7.06L12 17.6l-6.25 3.5L7.3 14.04 2 9.2l7.07-.7z" />
    </svg>
  ),
  Paw: (props) => (
    <svg viewBox="0 0 32 32" fill="currentColor" {...props}>
      <ellipse cx="16" cy="22" rx="5.5" ry="6.5" />
      <ellipse cx="6" cy="13" rx="3" ry="4" />
      <ellipse cx="16" cy="9" rx="3.2" ry="4" />
      <ellipse cx="26" cy="13" rx="3" ry="4" />
    </svg>
  ),
};

// ---------- Logo ----------
function Logo({ variant = "primary", color = "steel", size = 1 }) {
  // Primary logo now uses Aaron-provided official Kari Breen Pet Portraits artwork.
  // Alternate camera/paw marks remain as small supporting submarks only.
  const colors = {
    steel: { name: "#4C6883", art: "#4C6883", sub: "#779A93", paw: "#C8B6A8", neutral: "#97A1AA" },
    white: { name: "#ffffff", art: "#ffffff", sub: "rgba(255,255,255,0.86)", paw: "#DDD1C7", neutral: "rgba(255,255,255,.78)" },
    wafer: { name: "#4C6883", art: "#C8B6A8", sub: "#779A93", paw: "#C8B6A8", neutral: "#97A1AA" },
  };
  const c = colors[color] || colors.steel;
  const transform = { transform: `scale(${size})`, transformOrigin: "left center" };

  if (variant === "primary") {
    const onDark = color === "white";
    return (
      <div className="official-logo-wrap inline-flex items-center" style={transform}>
        <img
          src="assets/kari-breen-logo-transparent.png"
          alt="Kari Breen Pet Portraits"
          className={`${onDark ? "bg-white/95 rounded-[22px] p-2 shadow-[0_18px_50px_-34px_rgba(0,0,0,.8)]" : ""} official-logo-img block w-[158px] md:w-[172px] h-auto`}
        />
      </div>
    );
  }

  const CameraGlyph = ({ small = false }) => (
    <svg className="logo-line-art" width={small ? 30 : 42} height={small ? 28 : 36} viewBox="0 0 46 40" fill="none" aria-hidden="true">
      <rect className="draw" x="2" y="10" width="42" height="27" rx="5" stroke={c.art} strokeWidth="1.6" />
      <path className="draw delay" d="M13 10l4-5h12l4 5" stroke={c.art} strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" />
      <circle className="draw delay" cx="23" cy="24" r="9" stroke={c.art} strokeWidth="1.6" />
      <g fill={c.paw}>
        <ellipse cx="23" cy="27" rx="2.6" ry="3" />
        <ellipse cx="18.8" cy="22" rx="1.25" ry="1.65" />
        <ellipse cx="23" cy="20.2" rx="1.35" ry="1.75" />
        <ellipse cx="27.2" cy="22" rx="1.25" ry="1.65" />
      </g>
    </svg>
  );

  const PawGlyph = () => (
    <svg className="logo-line-art" width="52" height="52" viewBox="0 0 52 52" fill="none" aria-hidden="true">
      <g stroke={c.art} strokeWidth="1.7" fill="none" strokeLinecap="round">
        <ellipse className="draw" cx="26" cy="34" rx="9" ry="10.5" />
        <ellipse className="draw delay" cx="13" cy="22" rx="4.5" ry="6.2" />
        <ellipse className="draw delay" cx="26" cy="15" rx="4.9" ry="6.4" />
        <ellipse className="draw delay" cx="39" cy="22" rx="4.5" ry="6.2" />
      </g>
      <path d="M26 31c-1.7-2.1-5-1.5-5 1.3 0 2.8 5 5.6 5 5.6s5-2.8 5-5.6c0-2.8-3.3-3.4-5-1.3z" fill={c.paw} />
    </svg>
  );

  if (variant === "camera") {
    return (
      <div className="inline-flex flex-col items-start leading-none" style={transform}>
        <div className="flex items-end gap-2">
          <span className="brand-wordmark text-[30px]" style={{ color: c.name, lineHeight: 0.78 }}>Kari</span>
          <CameraGlyph small />
          <span className="brand-wordmark text-[30px]" style={{ color: c.name, lineHeight: 0.78 }}>Breen</span>
        </div>
        <div className="eyebrow mt-2 ml-1" style={{ color: c.sub, letterSpacing: "0.34em", fontSize: 9 }}>
          Pet Portraits
        </div>
      </div>
    );
  }

  if (variant === "paw") {
    return (
      <div className="inline-flex items-center gap-3" style={transform}>
        <PawGlyph />
        <div className="leading-tight">
          <div className="brand-wordmark text-[30px]" style={{ color: c.name, lineHeight: 0.82 }}>Kari Breen</div>
          <div className="eyebrow" style={{ color: c.sub, letterSpacing: "0.32em", fontSize: 9 }}>Pet Portraits</div>
        </div>
      </div>
    );
  }

  return <Logo variant="primary" color={color} size={size} />;
}

// ---------- Buttons ----------
function Button({ as = "button", variant = "primary", size = "md", children, className = "", ...rest }) {
  const Tag = as;
  const base =
    "inline-flex items-center justify-center gap-2 font-semibold tracking-[0.18em] uppercase text-xs transition-all duration-300 rounded-full active:scale-[0.98]";
  const sizes = {
    sm: "px-5 py-2.5",
    md: "px-7 py-3.5",
    lg: "px-9 py-4 text-[13px]",
  };
  const variants = {
    primary: "bg-charcoal text-white hover:bg-steel-blue shadow-[0_18px_38px_-22px_rgba(16,19,22,0.85)]",
    secondary: "bg-juniper text-white hover:bg-steel-blue shadow-[0_16px_34px_-24px_rgba(73,109,103,0.8)]",
    ghost: "bg-white/55 border border-steel-blue/25 text-steel-blue hover:bg-steel-blue hover:text-white hover:border-steel-blue backdrop-blur",
    "ghost-white": "border border-white/45 bg-white/10 text-white hover:bg-white hover:text-steel-blue backdrop-blur",
    tertiary: "bg-bark-beige-40 text-steel-blue hover:bg-white border border-white/60",
    link: "text-steel-blue underline-offset-4 hover:underline px-0",
  };
  return (
    <Tag className={`${base} ${sizes[size]} ${variants[variant]} ${className}`} {...rest}>
      {children}
    </Tag>
  );
}

// ---------- Eyebrow + ScriptAccent ----------
function Eyebrow({ children, color = "#4C6883", className = "" }) {
  return (
    <div className={`eyebrow inline-flex items-center gap-2 ${className}`} style={{ color }}>
      <span style={{ width: 24, height: 1, background: color, opacity: 0.5 }} />
      {children}
    </div>
  );
}

function ScriptAccent({ children, angle = -4, color = "#779A93", className = "", style }) {
  return (
    <span
      className={`font-script inline-block ${className}`}
      style={{ color, transform: `rotate(${angle}deg)`, lineHeight: 0.9, ...style }}
    >
      {children}
    </span>
  );
}

// ---------- UtilityBar ----------
function UtilityBar() {
  return (
    <div className="hidden md:block bg-charcoal text-white/78 text-[12px]">
      <div className="max-w-[1280px] mx-auto px-6 py-2.5 flex items-center justify-between">
        <div className="flex items-center gap-2 tracking-wide">
          <Icon.Paw className="w-3 h-3 text-steel-blue" />
          <span>Fort Worth, TX · Pet Photography Studio</span>
        </div>
        <div className="flex items-center gap-5">
          <a href={window.PHONE_PRIMARY_TEL} className="text-white font-medium hover:text-bark-beige inline-flex items-center gap-1.5">
            <Icon.Phone className="w-3.5 h-3.5" />
            {window.PHONE_PRIMARY}
          </a>
          <a href={window.FB_URL} className="text-white/70 hover:text-bark-beige" aria-label="Facebook">
            <Icon.Facebook className="w-3.5 h-3.5" />
          </a>
          <a href={window.IG_URL} className="text-white/70 hover:text-bark-beige" aria-label="Instagram">
            <Icon.Instagram className="w-3.5 h-3.5" />
          </a>
        </div>
      </div>
    </div>
  );
}

// ---------- Navbar ----------
function Navbar({ route, setRoute }) {
  const [scrolled, setScrolled] = useState(false);
  const [mobileOpen, setMobileOpen] = useState(false);

  useEffect(() => {
    const onScroll = () => setScrolled(window.scrollY > 8);
    window.addEventListener("scroll", onScroll);
    return () => window.removeEventListener("scroll", onScroll);
  }, []);

  useEffect(() => {
    if (!mobileOpen) {
      document.body.classList.remove("mobile-menu-open");
      return;
    }

    document.body.classList.add("mobile-menu-open");
    const onKey = (event) => {
      if (event.key === "Escape") setMobileOpen(false);
    };
    window.addEventListener("keydown", onKey);
    return () => {
      document.body.classList.remove("mobile-menu-open");
      window.removeEventListener("keydown", onKey);
    };
  }, [mobileOpen]);

  const go = (key) => {
    setRoute(key);
    setMobileOpen(false);
    window.scrollTo({ top: 0, behavior: "instant" });
  };

  return (
    <header
      className={`sticky top-0 z-40 transition-all duration-300 border-b ${
        scrolled ? "bg-white/82 backdrop-blur-xl border-white/70 shadow-[0_18px_60px_-45px_rgba(20,35,48,0.55)]" : "bg-white/62 backdrop-blur-xl border-white/50"
      }`}
    >
      <div className="max-w-[1280px] mx-auto px-4 sm:px-6 flex items-center justify-between h-[72px] md:h-[88px]">
        <button onClick={() => go("home")} className="cursor-pointer min-h-11 inline-flex items-center" aria-label="Kari Breen Pet Portraits home">
          <Logo variant="primary" color="steel" size={0.54} />
        </button>

        <nav className="hidden lg:flex items-center gap-1">
          {window.NAV.map((item) => (
            <button
              key={item.key}
              onClick={() => go(item.key)}
              className={`relative px-3.5 py-2 text-[13px] tracking-wide transition-colors ${
                route === item.key || (route.startsWith(item.key) && item.key !== "home")
                  ? "text-steel-blue"
                  : "text-charcoal/70 hover:text-steel-blue"
              }`}
            >
              {item.label}
              {(route === item.key || (route.startsWith(item.key) && item.key !== "home")) && (
                <span className="absolute left-3.5 right-3.5 bottom-1 h-px bg-juniper" />
              )}
            </button>
          ))}
        </nav>

        <div className="hidden lg:flex items-center gap-3">
          <Button onClick={() => go("contact")} size="sm">
            <Icon.Camera className="w-3.5 h-3.5" /> Book a Session
          </Button>
        </div>

        <button
          className="lg:hidden min-h-11 min-w-11 rounded-full border border-steel-blue/15 bg-white/70 text-steel-blue inline-flex items-center justify-center shadow-[0_12px_34px_-28px_rgba(20,35,48,.45)]"
          onClick={() => setMobileOpen(true)}
          aria-label="Open menu"
          aria-expanded={mobileOpen}
          aria-controls="mobile-menu-drawer"
        >
          <Icon.Menu className="w-6 h-6" />
        </button>
      </div>

      {/* Mobile drawer */}
      {mobileOpen && (
        <div className="fixed inset-0 z-50 lg:hidden" role="dialog" aria-modal="true" aria-label="Mobile navigation">
          <div className="absolute inset-0 bg-charcoal/48 backdrop-blur-[3px]" onClick={() => setMobileOpen(false)} />
          <div id="mobile-menu-drawer" className="absolute right-0 top-0 h-[100dvh] w-full sm:max-w-[390px] bg-[#F8F5F2] shadow-2xl flex flex-col border-l border-white/70">
            <div className="px-5 py-4 flex items-center justify-between bg-white/92 backdrop-blur border-b border-bark-beige-40">
              <Logo variant="primary" color="steel" size={0.48} />
              <button onClick={() => setMobileOpen(false)} className="min-h-11 min-w-11 rounded-full border border-steel-blue/15 bg-wafer-20 text-steel-blue inline-flex items-center justify-center" aria-label="Close menu">
                <Icon.Close className="w-5 h-5" />
              </button>
            </div>
            <div className="flex-1 overflow-auto px-5 py-5">
              <nav className="flex flex-col gap-1">
                {window.NAV.map((item) => (
                  <button
                    key={item.key}
                    onClick={() => go(item.key)}
                    className={`text-left min-h-[52px] px-4 py-3 rounded-2xl border font-serif text-xl flex items-center justify-between transition ${
                      route === item.key || (route.startsWith(item.key) && item.key !== "home")
                        ? "bg-white text-steel-blue border-steel-blue/18 shadow-[0_14px_34px_-30px_rgba(20,35,48,.55)]"
                        : "text-charcoal border-transparent hover:bg-white/70"
                    }`}
                  >
                    <span>{item.label}</span>
                    {(route === item.key || (route.startsWith(item.key) && item.key !== "home")) && <span className="h-2 w-2 rounded-full bg-juniper" />}
                  </button>
                ))}
              </nav>
              <div className="mt-6 space-y-3 rounded-[26px] bg-white/72 border border-white/70 p-4">
                <Button onClick={() => go("contact")} size="lg" className="w-full !px-5">
                  Book a Session
                </Button>
                <a href={window.PHONE_PRIMARY_TEL} className="min-h-11 flex items-center justify-center text-steel-blue py-2 text-sm font-semibold tracking-wide">
                  <Icon.Phone className="w-4 h-4 inline mr-1" /> {window.PHONE_PRIMARY}
                </a>
                <div className="flex items-center justify-center gap-3 pt-1">
                  <a href={window.FB_URL} aria-label="Facebook" className="h-10 w-10 rounded-full border border-steel-blue/15 text-steel-blue inline-flex items-center justify-center bg-wafer-20"><Icon.Facebook className="w-4 h-4" /></a>
                  <a href={window.IG_URL} aria-label="Instagram" className="h-10 w-10 rounded-full border border-steel-blue/15 text-steel-blue inline-flex items-center justify-center bg-wafer-20"><Icon.Instagram className="w-4 h-4" /></a>
                </div>
              </div>
            </div>
          </div>
        </div>
      )}
    </header>
  );
}

// ---------- Footer ----------
function Footer({ setRoute }) {
  const go = (k) => {
    setRoute(k);
    window.scrollTo({ top: 0, behavior: "instant" });
  };
  return (
    <footer className="relative bg-charcoal text-white overflow-hidden">
      <div className="absolute inset-0 opacity-70" style={{ background: "radial-gradient(circle at 12% 12%, rgba(119,154,147,.28), transparent 28rem), radial-gradient(circle at 88% 0%, rgba(76,104,131,.32), transparent 30rem)" }} />
      <div className="absolute inset-0 paw-pattern-light opacity-25" />
      <div className="relative max-w-[1280px] mx-auto px-4 sm:px-6 pt-14 sm:pt-16 md:pt-20 pb-8 sm:pb-10">
        <div className="grid gap-5 sm:gap-8 md:grid-cols-12 md:gap-10">
          <div className="md:col-span-4 rounded-[2rem] border border-white/10 bg-white/[0.04] px-5 py-6 sm:border-0 sm:bg-transparent sm:p-0 text-center sm:text-left">
            <div className="flex justify-center sm:justify-start">
              <Logo variant="primary" color="white" size={0.56} />
            </div>
            <p className="mt-4 sm:mt-5 text-white/75 max-w-sm mx-auto sm:mx-0 font-serif text-[14px] sm:text-[15px] leading-relaxed">
              Fort Worth, Texas. Twenty years of award-winning pet photography, paintings, and a signature greeting card line.
            </p>
            <div className="flex items-center justify-center sm:justify-start gap-3 mt-5 sm:mt-6">
              <a href={window.FB_URL} aria-label="Facebook" className="w-11 h-11 sm:w-9 sm:h-9 rounded-full border border-white/30 hover:bg-white hover:text-steel-blue inline-flex items-center justify-center transition">
                <Icon.Facebook className="w-4 h-4" />
              </a>
              <a href={window.IG_URL} aria-label="Instagram" className="w-11 h-11 sm:w-9 sm:h-9 rounded-full border border-white/30 hover:bg-white hover:text-steel-blue inline-flex items-center justify-center transition">
                <Icon.Instagram className="w-4 h-4" />
              </a>
            </div>
          </div>

          <div className="grid grid-cols-2 gap-3 sm:contents md:col-span-5">
            <div className="rounded-[1.5rem] border border-white/10 bg-white/[0.04] p-4 sm:p-0 sm:border-0 sm:bg-transparent md:col-span-3">
              <div className="eyebrow text-wafer mb-3 sm:mb-4">Sitemap</div>
              <ul className="space-y-1.5 sm:space-y-2.5 font-serif text-sm sm:text-base">
                {window.NAV.map((n) => (
                  <li key={n.key}>
                    <button onClick={() => go(n.key)} className="min-h-9 text-left hover:text-juniper-60 transition text-white/85">
                      {n.label}
                    </button>
                  </li>
                ))}
              </ul>
            </div>

            <div className="rounded-[1.5rem] border border-white/10 bg-white/[0.04] p-4 sm:p-0 sm:border-0 sm:bg-transparent md:col-span-2">
              <div className="eyebrow text-wafer mb-3 sm:mb-4">Contact</div>
              <ul className="space-y-2 sm:space-y-2.5 font-serif text-sm sm:text-base text-white/85">
                <li>
                  <a href={window.PHONE_PRIMARY_TEL} className="inline-flex min-h-9 items-center hover:text-juniper-60">{window.PHONE_PRIMARY}</a>
                </li>
                <li className="min-h-9 flex items-center">Fort Worth, TX</li>
                <li>
                  <button onClick={() => go("contact")} className="min-h-9 text-left hover:text-juniper-60">Send a message</button>
                </li>
              </ul>
            </div>
          </div>

          <div className="md:col-span-3 rounded-[1.75rem] border border-white/10 bg-white/[0.04] p-5 sm:p-0 sm:border-0 sm:bg-transparent">
            <div className="eyebrow text-wafer mb-3 sm:mb-4">Sister Studio</div>
            <div className="font-serif text-white/90 text-[15px] leading-relaxed">
              <strong className="font-display text-white text-lg block">Marty &amp; Pat's</strong>
              <span className="text-white/70 text-sm">Frame Shoppe &amp; Art Gallery</span>
              <p className="mt-2 text-sm text-white/70">Custom framing for your pet portraits & fine art.</p>
              <div className="mt-2 sm:mt-3 flex flex-col items-start gap-2">
                <a href={window.PHONE_MARTY_TEL} className="inline-flex min-h-10 items-center hover:text-juniper-60">{window.PHONE_MARTY}</a>
                <a href="#" className="min-h-10 rounded-full border border-juniper-60/35 px-4 inline-flex items-center gap-1.5 text-juniper-60 hover:bg-white hover:text-steel-blue text-sm transition">
                  Visit Marty &amp; Pat's <Icon.ArrowRight className="w-3.5 h-3.5" />
                </a>
              </div>
            </div>
          </div>
        </div>

        <div className="mt-9 sm:mt-14 pt-5 sm:pt-6 border-t border-white/15 flex flex-col md:flex-row items-center justify-between gap-3 sm:gap-4 text-[11px] sm:text-xs text-white/55 text-center md:text-left">
          <div>© 2026 Kari Breen Inc. All rights reserved.</div>
          <div className="flex flex-wrap justify-center items-center gap-x-5 gap-y-2">
            <a href="#" className="min-h-8 inline-flex items-center hover:text-white">Privacy Policy</a>
            <a href="#" className="min-h-8 inline-flex items-center hover:text-white">Terms of Service</a>
          </div>
        </div>
      </div>
    </footer>
  );
}

// ---------- Sister-site strip ----------
function SisterSiteStrip() {
  return (
    <section className="bg-bark-beige-40 border-y border-bark-beige-60">
      <div className="max-w-[1280px] mx-auto px-6 py-8 flex flex-col md:flex-row items-center justify-between gap-4">
        <div className="flex items-center gap-4">
          <div className="w-12 h-12 rounded-full bg-white grid place-items-center text-steel-blue">
            <Icon.Sparkles className="w-5 h-5" />
          </div>
          <div className="font-serif text-charcoal text-[15px] leading-snug">
            Need framing for your portraits? Kari also owns{" "}
            <strong className="font-display text-steel-blue">Marty &amp; Pat's Frame Shoppe &amp; Art Gallery</strong>.
          </div>
        </div>
        <div className="flex items-center gap-3">
          <a href={window.PHONE_MARTY_TEL} className="text-steel-blue font-medium tracking-wide hover:text-juniper inline-flex items-center gap-2 text-sm">
            <Icon.Phone className="w-4 h-4" />
            {window.PHONE_MARTY}
          </a>
          <Button as="a" href="#" variant="ghost" size="sm">
            Visit Marty &amp; Pat's <Icon.ArrowRight className="w-3.5 h-3.5" />
          </Button>
        </div>
      </div>
    </section>
  );
}

// ---------- Lightbox ----------
function Lightbox({ images, index, onClose, onPrev, onNext }) {
  useEffect(() => {
    if (index == null) {
      document.body.classList.remove("no-scroll");
      return;
    }

    document.body.classList.add("no-scroll");
    const onKey = (e) => {
      if (e.key === "Escape") onClose();
      if (e.key === "ArrowLeft") onPrev();
      if (e.key === "ArrowRight") onNext();
    };
    window.addEventListener("keydown", onKey);
    return () => {
      document.body.classList.remove("no-scroll");
      window.removeEventListener("keydown", onKey);
    };
  }, [index, onClose, onPrev, onNext]);

  if (index == null) return null;
  const img = images[index];

  return (
    <div className="fixed inset-0 z-[60] bg-charcoal/95 flex items-center justify-center" onClick={onClose}>
      <button onClick={onClose} className="absolute top-5 right-5 text-white/80 hover:text-white p-2" aria-label="Close">
        <Icon.Close className="w-7 h-7" />
      </button>
      <button
        onClick={(e) => {
          e.stopPropagation();
          onPrev();
        }}
        className="absolute left-4 md:left-10 top-1/2 -translate-y-1/2 w-12 h-12 rounded-full border border-white/30 text-white/80 hover:bg-white hover:text-charcoal grid place-items-center"
        aria-label="Previous"
      >
        <Icon.ArrowRight className="w-5 h-5 rotate-180" />
      </button>
      <button
        onClick={(e) => {
          e.stopPropagation();
          onNext();
        }}
        className="absolute right-4 md:right-10 top-1/2 -translate-y-1/2 w-12 h-12 rounded-full border border-white/30 text-white/80 hover:bg-white hover:text-charcoal grid place-items-center"
        aria-label="Next"
      >
        <Icon.ArrowRight className="w-5 h-5" />
      </button>
      <div className="max-w-[88vw] max-h-[85vh] flex flex-col items-center" onClick={(e) => e.stopPropagation()}>
        <img src={img.src} alt={img.caption} className="max-w-full max-h-[78vh] object-contain shadow-2xl" />
        <div className="mt-4 text-center text-white/80 font-serif">
          <div className="text-sm">{img.caption}</div>
          <div className="text-xs text-white/50 mt-1">
            {index + 1} / {images.length} ·{" "}
            <a href={window.IG_URL} className="underline-offset-4 hover:underline">
              Follow more on Instagram
            </a>
          </div>
        </div>
      </div>
    </div>
  );
}

// ---------- Image card with hover caption ----------
function PortfolioCard({ image, onClick }) {
  return (
    <button
      onClick={onClick}
      className="group relative block w-full overflow-hidden bg-white/70 frame-border cursor-pointer"
    >
      <img
        src={image.src}
        alt={image.caption}
        loading="lazy"
        className="w-full h-auto object-cover transition duration-700 group-hover:scale-[1.03]"
      />
      <div className="absolute inset-0 bg-charcoal/0 group-hover:bg-charcoal/24 transition" />
      <div className="absolute inset-x-0 bottom-0 p-4 translate-y-2 opacity-0 group-hover:opacity-100 group-hover:translate-y-0 transition duration-300">
        <div className="bg-white/90 backdrop-blur-xl px-4 py-2 rounded-full inline-flex items-center gap-2 text-[11px] tracking-wider uppercase text-steel-blue shadow-lg">
          <Icon.Eye className="w-3.5 h-3.5" />
          {image.caption}
        </div>
      </div>
    </button>
  );
}

// ---------- Soul callout (brand guide page 20) ----------
function SoulCallout() {
  return (
    <section className="relative bg-slate-gray text-white overflow-hidden">
      <div className="absolute inset-0 opacity-20 paw-pattern-light" />
      <div className="relative max-w-[960px] mx-auto px-6 py-20 md:py-24 text-center">
        <Eyebrow color="rgba(255,255,255,0.72)" className="mb-6 justify-center">
          Award-winning pet photographer
        </Eyebrow>
        <h2 className="font-serif text-3xl md:text-5xl leading-tight text-white tracking-tight">
          Portraits with personality, warmth, and heart.
        </h2>
        <p className="mt-6 mx-auto max-w-2xl font-serif text-lg leading-relaxed text-white/78">
          A quiet, thoughtful way to preserve the spirit of the pets who are part of your family.
        </p>
      </div>
    </section>
  );
}

// ---------- Section header w/ optional eyebrow & script ----------
function SectionHeader({ eyebrow, title, script, scriptAfter, sub, align = "center", invert = false }) {
  const alignCls = align === "left" ? "text-left items-start" : "text-center items-center";
  return (
    <div className={`flex flex-col gap-4 ${alignCls}`}>
      {eyebrow && <Eyebrow color={invert ? "rgba(255,255,255,0.7)" : "#4C6883"}>{eyebrow}</Eyebrow>}
      <h2 className={`font-serif text-4xl md:text-5xl leading-tight tracking-tight ${invert ? "text-white" : "text-steel-blue"}`}>
        {title}
        {script && (
          <>
            {" "}
            <ScriptAccent angle={-4} color={invert ? "#DDD1C7" : "#779A93"} className="text-5xl md:text-6xl align-baseline">
              {script}
            </ScriptAccent>
            {scriptAfter}
          </>
        )}
      </h2>
      {sub && <p className={`font-serif text-lg md:text-xl max-w-2xl ${invert ? "text-white/80" : "text-charcoal/75"}`}>{sub}</p>}
    </div>
  );
}


// ---------- HyperFrames motion graphics system ----------
function HyperFramesBackground() {
  const PawParticle = ({ cls }) => (
    <svg className={`hf-paw-particle ${cls}`} viewBox="0 0 32 32" fill="currentColor">
      <ellipse cx="16" cy="22" rx="5.5" ry="6.5" />
      <ellipse cx="6" cy="13" rx="3" ry="4" />
      <ellipse cx="16" cy="9" rx="3.2" ry="4" />
      <ellipse cx="26" cy="13" rx="3" ry="4" />
    </svg>
  );
  return (
    <div className="hyperframes-bg" aria-hidden="true">
      <div className="hf-orb one" />
      <div className="hf-orb two" />
      <div className="hf-orb three" />
      <div className="hf-frame a" />
      <div className="hf-frame b" />
      <div className="hf-frame c" />
      <div className="hf-frame d" />
      <div className="hf-frame e" />
      <PawParticle cls="one" />
      <PawParticle cls="two" />
      <PawParticle cls="three" />
    </div>
  );
}

function HyperFrameStage({ image, caption = "Award-winning Fort Worth pet portraiture" }) {
  return (
    <div className="hyper-stage reveal" aria-label="Featured pet portrait">
      <div className="stage-frame one" />
      <div className="stage-frame two" />
      <img src={image} alt={caption} className="stage-img" />
      <div className="absolute left-8 top-8 hidden sm:block opacity-90">
        <Logo variant="primary" color="steel" size={0.34} />
      </div>
      <div className="absolute right-8 bottom-28 hidden md:block w-32 h-32 rounded-full overflow-hidden border-[6px] border-white shadow-[0_20px_60px_-36px_rgba(0,0,0,.55)]">
        <img src={window.PORTFOLIO[8]?.src || image} alt="Pet portrait detail" className="w-full h-full object-cover" />
      </div>
      <div className="hyper-badge">
        <div className="flex items-center justify-between gap-4">
          <div>
            <div className="text-[10px] uppercase tracking-[0.22em] text-steel-blue/70">Fort Worth pet portraits</div>
            <div className="mt-1 font-serif text-xl md:text-2xl leading-snug text-charcoal">A calm, artful session for the pets you love.</div>
          </div>
          <div className="h-11 w-11 rounded-full bg-wafer grid place-items-center text-steel-blue shrink-0">
            <Icon.Paw className="w-5 h-5" />
          </div>
        </div>
      </div>
    </div>
  );
}

function BrandMotionShowcase() {
  const swatches = [
    ["Steel Blue", "#4C6883"],
    ["Slate Gray", "#97A1AA"],
    ["Juniper", "#779A93"],
    ["Bark Beige", "#C8B6A8"],
    ["Wafer", "#DDD1C7"],
  ];
  return (
    <section className="brand-motion-grid relative overflow-hidden border-y border-white/70">
      <div className="absolute inset-0 pointer-events-none">
        <div className="hf-frame a opacity-35" />
        <div className="hf-frame c opacity-35" />
      </div>
      <div className="relative max-w-[1280px] mx-auto px-6 py-20 md:py-24 grid lg:grid-cols-12 gap-10 items-center">
        <div className="lg:col-span-5">
          <Eyebrow>Brand system applied</Eyebrow>
          <h2 className="mt-5 font-display text-4xl md:text-5xl text-steel-blue leading-tight">
            Style guide, now in motion.
          </h2>
          <p className="mt-5 font-serif text-lg leading-relaxed text-charcoal/75">
            The site now uses Kari Breen's guide colors, signature wordmark style, camera/paw submarks,
            script accents, and earthy blue-green-beige palette as a living HyperFrames system.
          </p>
          <div className="mt-7 flex flex-wrap gap-3">
            {swatches.map(([name, hex]) => (
              <div key={hex} className="rounded-full bg-white/70 border border-white/80 pr-4 pl-2 py-2 inline-flex items-center gap-2 shadow-sm">
                <span className="w-7 h-7 rounded-full border border-white/80" style={{ background: hex }} />
                <span className="text-[10px] uppercase tracking-[0.18em] text-charcoal/65">{name}</span>
              </div>
            ))}
          </div>
        </div>
        <div className="lg:col-span-7 grid sm:grid-cols-3 gap-4">
          <div className="brand-submark-card frame-border p-6 min-h-[230px] flex flex-col justify-between">
            <div className="relative z-10"><Logo variant="primary" color="steel" size={0.92} /></div>
            <div className="relative z-10 mt-8 text-[10px] uppercase tracking-[0.24em] text-charcoal/55">Official primary logo</div>
          </div>
          <div className="brand-submark-card frame-border p-6 min-h-[230px] bg-steel-blue !text-white flex flex-col justify-between" style={{ background: "#4C6883" }}>
            <div className="relative z-10"><Logo variant="paw" color="white" size={0.92} /></div>
            <div className="relative z-10 mt-8 text-[10px] uppercase tracking-[0.24em] text-white/70">Paw-heart submark</div>
          </div>
          <div className="brand-submark-card frame-border p-6 min-h-[230px] flex flex-col justify-between" style={{ background: "linear-gradient(135deg,#DDD1C7,#C8B6A8)" }}>
            <div className="relative z-10"><Logo variant="camera" color="white" size={1.02} /></div>
            <div className="relative z-10 mt-8 text-[10px] uppercase tracking-[0.24em] text-white/78">Camera wordmark alternate</div>
          </div>
        </div>
      </div>
    </section>
  );
}


function ProfessionalStats() {
  const stats = [
    ["20+", "years of portrait work"],
    ["Fort Worth", "local studio"],
    ["Pets first", "patient sessions"],
  ];
  return (
    <div className="mt-9 grid sm:grid-cols-3 gap-3 max-w-2xl">
      {stats.map(([num, label]) => (
        <div key={label} className="pro-card px-4 py-4 text-center">
          <div className="font-serif text-xl md:text-2xl text-steel-blue leading-none">{num}</div>
          <div className="mt-2 text-[10px] uppercase tracking-[0.16em] text-charcoal/55">{label}</div>
        </div>
      ))}
    </div>
  );
}

Object.assign(window, {
  Icon,
  Logo,
  Button,
  Eyebrow,
  ScriptAccent,
  UtilityBar,
  Navbar,
  Footer,
  SisterSiteStrip,
  Lightbox,
  PortfolioCard,
  SoulCallout,
  SectionHeader,
  HyperFramesBackground,
  HyperFrameStage,
  BrandMotionShowcase,
  ProfessionalStats,
});
