"use client"; import { useState, useEffect, useRef } from "react"; import Link from "next/link"; import { motion, useInView } from "framer-motion"; import TuxedoVideoHero from "@/components/storefront/TuxedoVideoHero"; import CinematicShowcase from "@/components/storefront/CinematicShowcase"; import LayoutContainer from "@/components/layout/LayoutContainer"; import ProductCard from "@/components/storefront/ProductCard"; import PaginatedStops from "@/components/storefront/PaginatedStops"; import StorefrontHeader from "@/components/storefront/StorefrontHeader"; import StorefrontFooter from "@/components/storefront/StorefrontFooter"; import BrandStylesProvider from "@/components/storefront/BrandStylesProvider"; import { ScrollReveal, ParallaxLayer, FadeOnScroll } from "@/components/ui/ScrollAnimations"; import { api } from "@/lib/api"; import { getBrandSettingsPublic } from "@/actions/brand-settings"; import { gsap } from "gsap"; import { ScrollTrigger } from "gsap/ScrollTrigger"; // Register GSAP plugins if (typeof window !== "undefined") { gsap.registerPlugin(ScrollTrigger); } type Brand = { id: string; name: string; slug: string; }; type Stop = { id: string; city: string; state: string; date: string; time: string; location: string; slug: string; brand_id: string; }; type Product = { id: string; name: string; description: string | null; price: number; type: string; image_url: string | null; brand_id: string; is_taxable?: boolean; pickup_type?: "scheduled_stop" | "shed"; }; // ── Why Choose Tuxedo Corn — editorial masonry redesign ───────────── type FeatureColor = "emerald" | "amber"; interface Feature { color: FeatureColor; label: string; headline: string; story: string; accentColor: string; accentGlow: string; accentHover: string; size: "tall" | "normal"; icon: React.ReactNode; } const FEATURES: Feature[] = [ { color: "emerald", label: "Hand-Harvested", headline: "Picked by Hand, Every Ear", story: "Three generations of careful hands move through every row. No machine knows when an ear is perfectly ripe the way a farmer's daughter does.", accentColor: "bg-emerald-500", accentGlow: "hover:shadow-emerald-500/20", accentHover: "group-hover:bg-gradient-to-r group-hover:from-emerald-500 group-hover:to-emerald-600", size: "tall", icon: ( ), }, { color: "emerald", label: "Non-GMO", headline: "Seed to Field, Naturally", story: "Our Olathe Sweet seed has never been touched by a laboratory. The flavor was shaped by forty summers of patient selection — nothing added, nothing altered.", accentColor: "bg-emerald-500", accentGlow: "hover:shadow-emerald-500/20", accentHover: "group-hover:bg-gradient-to-r group-hover:from-emerald-500 group-hover:to-emerald-600", size: "normal", icon: ( ), }, { color: "emerald", label: "Colorado Grown", headline: "Born in the High Country", story: "Olathe Sweet was developed for Colorado's mountain climate — intense sun by day, crisp nights by morning. That contrast makes a sweetness no other soil can claim.", accentColor: "bg-emerald-500", accentGlow: "hover:shadow-emerald-500/20", accentHover: "group-hover:bg-gradient-to-r group-hover:from-emerald-500 group-hover:to-emerald-600", size: "normal", icon: ( ), }, { color: "emerald", label: "Regenerative", headline: "Our Roots Run Deep", story: "We give back more than we take. Our soil is healthier today than forty years ago — not because we had to, but because this land deserves that kind of care.", accentColor: "bg-emerald-500", accentGlow: "hover:shadow-emerald-500/20", accentHover: "group-hover:bg-gradient-to-r group-hover:from-emerald-500 group-hover:to-emerald-600", size: "tall", icon: ( ), }, { color: "amber", label: "Peak Freshness", headline: "Harvested the Morning You Order", story: "We pick before the heat steals a single calorie of sweetness. By the time your order arrives, the corn was still in the field that same morning.", accentColor: "bg-amber-500", accentGlow: "hover:shadow-amber-500/20", accentHover: "group-hover:bg-gradient-to-r group-hover:from-amber-500 group-hover:to-amber-600", size: "normal", icon: ( ), }, { color: "amber", label: "Grown in CO", headline: "Your Neighborhood Farm", story: "Forty years of Colorado stops. We know every town we serve — when they like to pick up, where they gather. Your order isn't a transaction; it's a relationship.", accentColor: "bg-amber-500", accentGlow: "hover:shadow-amber-500/20", accentHover: "group-hover:bg-gradient-to-r group-hover:from-amber-500 group-hover:to-amber-600", size: "tall", icon: ( ), }, { color: "amber", label: "No Middleman", headline: "From Our Rows to Your Table", story: "No distribution center. No supermarket back shelf. Just the field, the cooler, and your front door — the same day. That's the promise we keep.", accentColor: "bg-amber-500", accentGlow: "hover:shadow-amber-500/20", accentHover: "group-hover:bg-gradient-to-r group-hover:from-amber-500 group-hover:to-amber-600", size: "normal", icon: ( ), }, { color: "amber", label: "Easy Preorder", headline: "Reserve in 30 Seconds", story: "Choose your stop, tap your order, done. We'll have your corn in a labeled cooler with your name on it — no account, no app, no confusion.", accentColor: "bg-amber-500", accentGlow: "hover:shadow-amber-500/20", accentHover: "group-hover:bg-gradient-to-r group-hover:from-amber-500 group-hover:to-amber-600", size: "tall", icon: ( ), }, ]; // Single feature card with scroll-triggered entrance and hover effects function FeatureCard({ feature, index }: { feature: Feature; index: number }) { const ref = useRef(null); const isInView = useInView(ref, { once: true, margin: "-60px" }); return ( {/* Animated top accent line */}
{/* Icon with glow on hover */}
{feature.icon}
{/* Label */}

{feature.label}

{/* Headline */}

{feature.headline}

{/* Story */}

{feature.story}

{/* Corner decoration */}
); } function WhyTuxedoCorn() { const headerRef = useRef(null); const headerInView = useInView(headerRef, { once: true, margin: "-80px" }); return (
{/* Atmospheric glow */}
{/* Header */}
Why Olathe Sweet™ Why Choose
Tuxedo Corn
Colorado has trusted Olathe Sweet at their tables for over four decades. Here is why.
{/* Asymmetric masonry grid with staggered offsets */}
{/* Row 1: tall, normal, tall, normal — with vertical offset stagger */}
{/* Row 2: normal, tall, normal, tall — offset in opposite direction */}
{/* Footer */} Olathe Sweet™  ·  Olathe, Colorado
); } // ── Section header ────────────────────────────────────────────────── function SectionHeader({ eyebrow, headline, subtext, accent = "emerald", }: { eyebrow: string; headline: string; subtext: string; accent?: "emerald" | "stone"; }) { return (

{eyebrow}

{headline}

{subtext}

); } export default function TuxedoPage() { const [brand, setBrand] = useState(null); const [stops, setStops] = useState([]); const [products, setProducts] = useState([]); const [wholesaleEnabled, setWholesaleEnabled] = useState(false); const [logoUrl, setLogoUrl] = useState(null); const [logoUrlDark, setLogoUrlDark] = useState(null); const [olatheSweetLogoUrl, setOlatheSweetLogoUrl] = useState(null); const [olatheSweetLogoUrlDark, setOlatheSweetLogoUrlDark] = useState(null); const [showSchedulePdf, setShowSchedulePdf] = useState(true); const [showWholesaleLink, setShowWholesaleLink] = useState(true); const [heroTagline, setHeroTagline] = useState(null); const [heroImageUrl, setHeroImageUrl] = useState(null); const [isAdmin, setIsAdmin] = useState(false); const [customFooterText, setCustomFooterText] = useState(null); const [contactEmail, setContactEmail] = useState(null); const [contactPhone, setContactPhone] = useState(null); const [brandPrimaryColor, setBrandPrimaryColor] = useState(null); const [brandBgColor, setBrandBgColor] = useState(null); const [brandTextColor, setBrandTextColor] = useState(null); // Scope ref for GSAP context (fixes "invalid scope"/missing targets by providing explicit scope; selectors now limited to page) const pageScopeRef = useRef(null); useEffect(() => { async function load() { const slug = "tuxedo"; const [brandResult, settingsResult] = await Promise.all([ api.from("brands").select("*").eq("slug", slug).single(), getBrandSettingsPublic(slug), ]); const brandData = brandResult.data; setBrand(brandData); if (settingsResult.success && settingsResult.settings) { const s = settingsResult.settings; setLogoUrl(s.logo_url ?? null); setLogoUrlDark(s.logo_url_dark ?? null); setOlatheSweetLogoUrl(s.olathe_sweet_logo_url ?? null); setOlatheSweetLogoUrlDark(s.olathe_sweet_logo_url_dark ?? null); setHeroImageUrl(s.hero_image_url ?? null); setHeroTagline(s.hero_tagline ?? null); setCustomFooterText(s.custom_footer_text ?? null); setContactEmail(s.email ?? null); setContactPhone(s.phone ?? null); setShowSchedulePdf(s.show_schedule_pdf ?? true); setShowWholesaleLink(s.show_wholesale_link ?? true); setWholesaleEnabled(settingsResult.wholesaleEnabled ?? false); setBrandPrimaryColor(s.brand_primary_color ?? null); setBrandBgColor(s.brand_bg_color ?? null); setBrandTextColor(s.brand_text_color ?? null); } try { const { getCurrentAdminUser } = await import("@/actions/admin-user"); const adminUser = await getCurrentAdminUser(); setIsAdmin(!!adminUser); } catch { // not logged in as admin } if (brandData?.id) { const [{ data: stopsData }, { data: productsData }] = (await Promise.all([ api.from("stops").select("*").eq("brand_id", brandData.id).eq("active", true), api.from("products").select("*").eq("brand_id", brandData.id).eq("active", true), ])) as any; setStops(stopsData ?? []); setProducts(productsData ?? []); } } load(); }, []); function scrollToStops() { document.getElementById("stops")?.scrollIntoView({ behavior: "smooth" }); } function scrollToStory() { document.getElementById("story")?.scrollIntoView({ behavior: "smooth" }); } function scrollToProducts() { document.getElementById("products")?.scrollIntoView({ behavior: "smooth" }); } // ─── GSAP SCROLL ANIMATIONS ────────────────────────────────────────────── // Now explicitly scoped + resilient guards (no more "invalid scope" warnings) useEffect(() => { if (typeof window === "undefined") return; const ctx = gsap.context(() => { // Parallax floating elements gsap.utils.toArray(".parallax-float").forEach((el, i) => { gsap.to(el, { y: -60 - i * 15, scrollTrigger: { trigger: el, start: "top bottom", end: "bottom top", scrub: 1, }, }); }); // Staggered text reveal on scroll const revealTextElements = gsap.utils.toArray(".reveal-text"); revealTextElements.forEach((el) => { gsap.fromTo( el, { opacity: 0, y: 40, skewY: 2 }, { opacity: 1, y: 0, skewY: 0, duration: 1, ease: "power3.out", scrollTrigger: { trigger: el, start: "top 85%", toggleActions: "play none none reverse", }, } ); }); // Scale reveal for cards const revealScaleElements = gsap.utils.toArray(".reveal-scale"); revealScaleElements.forEach((el, i) => { gsap.fromTo( el, { opacity: 0, scale: 0.9, y: 40 }, { opacity: 1, scale: 1, y: 0, duration: 0.8, delay: i * 0.08, ease: "back.out(1.4)", scrollTrigger: { trigger: el, start: "top 85%", toggleActions: "play none none reverse", }, } ); }); // Counter animations (uses reliable proxy like before; now also has reduced-motion guard for resilience) const prefersReduced = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches; const counterElements = gsap.utils.toArray(".counter-animate"); counterElements.forEach((el) => { const target = parseInt(el.getAttribute("data-target") || "0", 10); if (prefersReduced) { el.textContent = target.toLocaleString(); return; } const obj = { val: 0 }; gsap.to(obj, { val: target, duration: 2, ease: "power2.out", onUpdate: () => { if (el.textContent !== null) { el.textContent = Math.floor(obj.val).toLocaleString(); } }, scrollTrigger: { trigger: el, start: "top 85%", toggleActions: "play none none none", }, }); }); // Horizontal reveal for section headers gsap.utils.toArray(".reveal-slide").forEach((el) => { gsap.fromTo( el, { opacity: 0, x: -40 }, { opacity: 1, x: 0, duration: 0.8, ease: "power3.out", scrollTrigger: { trigger: el, start: "top 85%", toggleActions: "play none none reverse", }, } ); }); }, pageScopeRef); return () => ctx.revert(); }, []); return (
{showWholesaleLink && wholesaleEnabled && (
Wholesale Portal →
)}
{/* Parallax background layers */}

Delivery Stops

Upcoming
Stops

Find a nearby stop and preorder your corn. Pickup is easy and guaranteed.

{showSchedulePdf && ( Download Schedule )}
{stops.length === 0 ? (

No stops on the calendar just yet

The harvest is right around the corner — new pickup stops go live weekly. You can still preorder below and pick a stop once they're announced.

View All Stops {showSchedulePdf && ( Download Schedule )}
) : ( )}
{/* Section divider */}
{/* Scroll-driven reveal for section header */}

Farm-Direct

This Week's
Harvest

Preorder for pickup at a stop, or have cooler boxes shipped directly to your door after the season.

{/* Cinematic showcase replaces static grid */} ({ id: p.id, name: p.name, description: p.description ?? "", price: `$${p.price}`, type: p.type, imageUrl: p.image_url, brand_id: p.brand_id, brand_slug: "tuxedo", is_taxable: p.is_taxable, pickup_type: p.pickup_type, }))} brandSlug="tuxedo" brandName={brand?.name ?? "Tuxedo Corn"} /> {/* Mobile-friendly fallback grid for smaller screens */}
{products.slice(0, 6).map((product) => ( ))}
{products.length > 3 && (

{products.length - 3} more products available in the full catalog.

)}
{/* Parallax decorative elements */}
{/* Large background text for parallax depth */}
SINCE

Our Story

Three Generations of
Sweet Corn Excellence

Tuxedo Corn is the exclusive grower and shipper of Olathe Sweet Sweet Corn — developed for Colorado's high-altitude mountain climate and grown by the same family for over 40 years.

{/* Stats with counter animation */}
{[ { stat: "40", suffix: "+", label: "Years Growing" }, { stat: "3", suffix: "", label: "Generations" }, { stat: "100", suffix: "%", label: "Hand-Picked" }, ].map((item, i) => (
0 {item.suffix}
{item.label}
))}
{ e.currentTarget.style.transform = "translateY(-3px)"; e.currentTarget.style.boxShadow = "0 12px 40px rgba(16, 185, 129, 0.4), inset 0 1px 0 rgba(255,255,255,0.2)"; }} onMouseLeave={(e) => { e.currentTarget.style.transform = "translateY(0)"; e.currentTarget.style.boxShadow = "0 8px 32px rgba(16, 185, 129, 0.3), inset 0 1px 0 rgba(255,255,255,0.2)"; }} > Read Our Story
); }