{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "book-flip",
  "title": "Book Flip",
  "author": "AlgorizeTech",
  "description": "An interactive 3D Book Flip / Leaf Carousel component simulating realistic book page turns, open spreads, spine folds, and bottom leaf navigation controls.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "utils"
  ],
  "files": [
    {
      "path": "src/components/custom/book-flip.tsx",
      "content": "\"use client\";\n\nimport {\n    useState,\n    useEffect,\n    useLayoutEffect,\n    useCallback,\n    useRef,\n    forwardRef,\n    useImperativeHandle,\n} from \"react\";\nimport type { CSSProperties } from \"react\";\nimport { cn } from \"@/lib/utils\";\nimport { ChevronLeft, ChevronRight, RotateCcw, Globe, QrCode, Sparkles } from \"lucide-react\";\n\nexport interface PageFlipLeaf {\n    id?: string | number;\n    frontImage: string;\n    backImage: string;\n    frontTitle?: string;\n    backTitle?: string;\n    frontSubtitle?: string;\n    backSubtitle?: string;\n    frontBadge?: string;\n    backBadge?: string;\n    frontColor?: string;\n    backColor?: string;\n}\n\nexport interface BookFlipProps {\n    /** Array of page leaves, each containing front and back images & metadata */\n    pages?: PageFlipLeaf[];\n    /** Default turned page count (0 = closed book on cover) */\n    defaultTurnedIndex?: number;\n    /** Controlled turned page count */\n    turnedIndex?: number;\n    /** Callback fired when page flip changes */\n    onPageChange?: (turnedCount: number, totalLeaves: number) => void;\n    /** Width of a single page in pixels (default: 260) */\n    pageWidth?: number;\n    /** Height of a single page in pixels (default: 380) */\n    pageHeight?: number;\n    /** 3D perspective depth in pixels (default: 1400) */\n    perspective?: number;\n    /** Maximum hover peek angle in degrees (default: 14) */\n    peekAngle?: number;\n    /** Total turn angle in degrees (default: 180) */\n    turnAngle?: number;\n    /** Transition flip animation duration in seconds (default: 0.7) */\n    duration?: number;\n    /** Easing curve for flip animation (default: \"cubic-bezier(0.4, 0, 0.2, 1)\") */\n    easing?: string;\n    /** Shadow intensity factor (0.0 to 1.0, default: 0.35) */\n    shadowIntensity?: number;\n    /** Dynamically shift spine horizontally when book is open to center the 2-page spread (default: true) */\n    spineShift?: boolean;\n    /** Border radius for pages (default: \"4px\") */\n    radius?: string | number;\n    /** Enable page numbering tags (default: true) */\n    showPageNumbers?: boolean;\n    /** Enable outer book spine binding shadow (default: true) */\n    showSpineBinding?: boolean;\n    /** Enable automatic page flipping (default: false) */\n    autoplay?: boolean;\n    /** Autoplay interval in milliseconds (default: 3500) */\n    autoplayInterval?: number;\n    /** Pause autoplay on hover (default: true) */\n    pauseOnHover?: boolean;\n    /** Enable interactive click on pages to flip (default: true) */\n    interactive?: boolean;\n    /** Enable navigation buttons (default: true) */\n    showControls?: boolean;\n    /** Optional container class name */\n    className?: string;\n    /** Optional container inline style */\n    style?: CSSProperties;\n}\n\nexport interface BookFlipHandle {\n    next: () => void;\n    prev: () => void;\n    reset: () => void;\n    goTo: (index: number) => void;\n    getTurnedCount: () => number;\n    getTotalLeaves: () => number;\n}\n\nconst DEFAULT_PAGES: PageFlipLeaf[] = [\n    {\n        id: 1,\n        frontImage: \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1200,c_limit/v1790146211/photo-1518709268805-4e9042af9f23-1790146212209.jpg\",\n        backImage: \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1200,c_limit/v1790145141/photo-1448375240586-882707db888b-1790145143491.jpg\",\n        frontTitle: \"TERRA INCOGNITA\",\n        frontSubtitle: \"A Visual Exploration of Earth's Most Remote Frontiers\",\n        frontBadge: \"LIMITED EDITION\",\n        frontColor: \"from-amber-400 to-yellow-600\",\n        backTitle: \"Whispering Evergreens\",\n        backSubtitle: \"Highland Ridges & Ancient Pines\",\n        backBadge: \"Plate 01\",\n        backColor: \"from-emerald-500 to-teal-600\",\n    },\n    {\n        id: 2,\n        frontImage: \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1200,c_limit/v1790145141/photo-1434394354979-a235cd36269d-1790145143490.jpg\",\n        backImage: \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1200,c_limit/v1790145141/photo-1469854523086-cc02fe5d8800-1790145143492.jpg\",\n        frontTitle: \"Cascading Emerald\",\n        frontSubtitle: \"Basalt Columns & Rainforest Mist\",\n        frontBadge: \"Plate 02\",\n        frontColor: \"from-teal-500 to-cyan-600\",\n        backTitle: \"Crimson Canyons\",\n        backSubtitle: \"Red Rock Gorges & Sunset Radiance\",\n        backBadge: \"Plate 03\",\n        backColor: \"from-rose-500 to-pink-600\",\n    },\n    {\n        id: 3,\n        frontImage: \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1200,c_limit/v1790146210/photo-1517411032315-54ef2cb783bb-1790146212209.jpg\",\n        backImage: \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1200,c_limit/v1790145141/photo-1464822759023-fed622ff2c3b-1790145143491.jpg\",\n        frontTitle: \"Celestial Auroras\",\n        frontSubtitle: \"Polar Nights & Luminous Fjord Skies\",\n        frontBadge: \"Plate 04\",\n        frontColor: \"from-indigo-500 to-purple-600\",\n        backTitle: \"Summit Horizons\",\n        backSubtitle: \"Glacial Peaks & Alpenglow Glow\",\n        backBadge: \"Plate 05\",\n        backColor: \"from-blue-500 to-indigo-600\",\n    },\n    {\n        id: 4,\n        frontImage: \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1200,c_limit/v1790146210/photo-1509316975850-ff9c5deb0cd9-1790146212209.jpg\",\n        backImage: \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1200,c_limit/v1790146210/photo-1507525428034-b723cf961d3e-1790146212208.jpg\",\n        frontTitle: \"Velvet Saharas\",\n        frontSubtitle: \"Wind Sculpted Dunes & Sunset Glow\",\n        frontBadge: \"Plate 06\",\n        frontColor: \"from-amber-600 to-yellow-500\",\n        backTitle: \"Azure Lagoons\",\n        backSubtitle: \"Coral Gardens & Crystal Waters\",\n        backBadge: \"Plate 07\",\n        backColor: \"from-cyan-500 to-blue-500\",\n    },\n    {\n        id: 5,\n        frontImage: \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1200,c_limit/v1790145142/photo-1500530855697-b586d89ba3ee-1790145143493.jpg\",\n        backImage: \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1200,c_limit/v1790146210/photo-1506744038136-46273834b3fb-1790146212208.jpg\",\n        frontTitle: \"Zen Bamboo Sanctuary\",\n        frontSubtitle: \"Whispering Canopy & Sunlit Paths\",\n        frontBadge: \"Plate 08\",\n        frontColor: \"from-emerald-600 to-lime-600\",\n        backTitle: \"Alpine Glaciers\",\n        backSubtitle: \"Glacial Reflections & Peak Shadows\",\n        backBadge: \"Plate 09\",\n        backColor: \"from-sky-500 to-blue-600\",\n    },\n    {\n        id: 6,\n        frontImage: \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1200,c_limit/v1790145142/photo-1476820865390-c52aeebb9891-1790145143492.jpg\",\n        backImage: \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1200,c_limit/v1790145141/photo-1454496522488-7a8e488e8606-1790145143491.jpg\",\n        frontTitle: \"Golden Autumn\",\n        frontSubtitle: \"Amber Woods & Crisp Air\",\n        frontBadge: \"Plate 10\",\n        frontColor: \"from-amber-500 to-orange-600\",\n        backTitle: \"Nordic Glaciers\",\n        backSubtitle: \"Fjord Passages & Ice Peaks\",\n        backBadge: \"Plate 11\",\n        backColor: \"from-cyan-600 to-teal-700\",\n    },\n    {\n        id: 7,\n        frontImage: \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1200,c_limit/v1790145140/photo-1426604966848-d7adac402bff-1790145143490.jpg\",\n        backImage: \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1200,c_limit/v1790146211/photo-1519681393784-d120267933ba-1790146212210.jpg\",\n        frontTitle: \"Wilderness Meadows\",\n        frontSubtitle: \"Alpine Wildflowers & Valley Breezes\",\n        frontBadge: \"Plate 12\",\n        frontColor: \"from-green-500 to-emerald-600\",\n        backTitle: \"Starlit Peaks\",\n        backSubtitle: \"Cosmic Heavens Above Mountain Ridges\",\n        backBadge: \"Plate 13\",\n        backColor: \"from-indigo-600 to-violet-700\",\n    },\n    {\n        id: 8,\n        frontImage: \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1200,c_limit/v1790145142/photo-1495616811223-4d98c6e9c869-1790145143493.jpg\",\n        backImage: \"https://res.cloudinary.com/dodndg7ai/image/upload/f_webp,q_auto,w_1200,c_limit/v1790145141/photo-1451187580459-43490279c0fa-1790145143491.jpg\",\n        frontTitle: \"Twilight Solitude\",\n        frontSubtitle: \"Ocean Horizon & Evening Glow\",\n        frontBadge: \"Plate 14\",\n        frontColor: \"from-rose-500 to-purple-600\",\n        backTitle: \"THE INFINITE COSMOS\",\n        backSubtitle: \"Published by Avara Fine Art Press\",\n        backBadge: \"HARDCOVER MONOGRAPH\",\n        backColor: \"from-purple-600 to-violet-800\",\n    },\n];\n\nexport const BookFlip = forwardRef<BookFlipHandle, BookFlipProps>(({\n    pages = DEFAULT_PAGES,\n    defaultTurnedIndex = 0,\n    turnedIndex: controlledTurnedIndex,\n    onPageChange,\n    pageWidth = 260,\n    pageHeight = 380,\n    perspective = 1400,\n    peekAngle = 14,\n    turnAngle = 180,\n    duration = 0.7,\n    easing = \"cubic-bezier(0.4, 0, 0.2, 1)\",\n    shadowIntensity = 0.35,\n    spineShift = true,\n    radius = \"4px\",\n    showPageNumbers = true,\n    showSpineBinding = true,\n    autoplay = false,\n    autoplayInterval = 3500,\n    pauseOnHover = true,\n    interactive = true,\n    showControls = true,\n    className,\n    style,\n}, ref) => {\n    const [internalTurned, setInternalTurned] = useState<number>(defaultTurnedIndex);\n    const [isHovered, setIsHovered] = useState<boolean>(false);\n    const [peekingIndex, setPeekingIndex] = useState<number | null>(null);\n    const [windowWidth, setWindowWidth] = useState<number>(typeof window !== \"undefined\" ? window.innerWidth : 1200);\n\n    useEffect(() => {\n        const handleResize = () => setWindowWidth(window.innerWidth);\n        window.addEventListener(\"resize\", handleResize);\n        handleResize();\n        return () => window.removeEventListener(\"resize\", handleResize);\n    }, []);\n\n    // Dynamically adjust page scale on small mobile screens (<640px)\n    const isSmallScreen = windowWidth < 640;\n    const effectivePageWidth = isSmallScreen ? Math.min(pageWidth, Math.floor((windowWidth - 48) / 2)) : pageWidth;\n    const effectivePageHeight = isSmallScreen ? Math.floor(effectivePageWidth * (pageHeight / pageWidth)) : pageHeight;\n\n    const totalLeaves = pages.length;\n    const currentTurned = controlledTurnedIndex !== undefined ? controlledTurnedIndex : internalTurned;\n\n    // Leaves that are mid-turn, kept above every other leaf until the\n    // rotation finishes. Without this, turning BACK flickered: the leaf\n    // lifting off the left stack lost its top z-index on the very first\n    // frame (the stack order re-ranks the leaf beneath it as \"last turned\"),\n    // so the page under it showed through until the rotation carried it\n    // far enough out of plane for 3D depth sorting to take over. Turning\n    // forward never showed it because the flipping leaf keeps the top slot\n    // in the static ordering. A layout effect runs before paint, so the\n    // z-index and the rotation change land in the same frame.\n    const [flipping, setFlipping] = useState<{ from: number; to: number; forward: boolean } | null>(null);\n    const previousTurnedRef = useRef<number>(currentTurned);\n    useLayoutEffect(() => {\n        const previous = previousTurnedRef.current;\n        if (previous === currentTurned) return;\n        previousTurnedRef.current = currentTurned;\n        setFlipping({\n            from: Math.min(previous, currentTurned),\n            to: Math.max(previous, currentTurned),\n            forward: currentTurned > previous,\n        });\n        const timer = setTimeout(() => setFlipping(null), duration * 1000 + 50);\n        return () => clearTimeout(timer);\n    }, [currentTurned, duration]);\n\n    const parsedRadius = typeof radius === \"number\" ? `${radius}px` : radius;\n\n    const setTurned = useCallback((newCount: number) => {\n        const clamped = Math.max(0, Math.min(newCount, totalLeaves));\n        if (controlledTurnedIndex === undefined) {\n            setInternalTurned(clamped);\n        }\n        if (onPageChange) {\n            onPageChange(clamped, totalLeaves);\n        }\n    }, [controlledTurnedIndex, totalLeaves, onPageChange]);\n\n    const flipNext = useCallback(() => {\n        if (currentTurned < totalLeaves) {\n            setTurned(currentTurned + 1);\n        }\n    }, [currentTurned, totalLeaves, setTurned]);\n\n    const flipPrev = useCallback(() => {\n        if (currentTurned > 0) {\n            setTurned(currentTurned - 1);\n        }\n    }, [currentTurned, setTurned]);\n\n    const resetBook = useCallback(() => {\n        setTurned(0);\n    }, [setTurned]);\n\n    useImperativeHandle(ref, () => ({\n        next: flipNext,\n        prev: flipPrev,\n        reset: resetBook,\n        goTo: (idx) => setTurned(idx),\n        getTurnedCount: () => currentTurned,\n        getTotalLeaves: () => totalLeaves,\n    }));\n\n    // Autoplay Timer\n    useEffect(() => {\n        if (!autoplay || (pauseOnHover && isHovered) || totalLeaves <= 1) return;\n        const timer = setInterval(() => {\n            setInternalTurned((prev) => (prev >= totalLeaves ? 0 : prev + 1));\n        }, autoplayInterval);\n        return () => clearInterval(timer);\n    }, [autoplay, autoplayInterval, pauseOnHover, isHovered, totalLeaves]);\n\n    // Preload Page Images to eliminate initial flip rendering jump/flash\n    useEffect(() => {\n        pages.forEach((page) => {\n            if (page.frontImage) {\n                const imgFront = new Image();\n                imgFront.src = page.frontImage;\n            }\n            if (page.backImage) {\n                const imgBack = new Image();\n                imgBack.src = page.backImage;\n            }\n        });\n    }, [pages]);\n\n    // Keyboard Navigation\n    useEffect(() => {\n        const handleKeyDown = (e: KeyboardEvent) => {\n            if (e.key === \"ArrowRight\") flipNext();\n            if (e.key === \"ArrowLeft\") flipPrev();\n        };\n        window.addEventListener(\"keydown\", handleKeyDown);\n        return () => window.removeEventListener(\"keydown\", handleKeyDown);\n    }, [flipNext, flipPrev]);\n\n    const handleLeafClick = (index: number) => {\n        if (!interactive) return;\n        if (index === currentTurned) {\n            flipNext();\n        } else if (index === currentTurned - 1) {\n            flipPrev();\n        }\n    };\n\n    // Container Translation for Spine Centering:\n    let containerTranslateX = 0;\n    if (spineShift) {\n        if (currentTurned > 0 && currentTurned < totalLeaves) {\n            containerTranslateX = effectivePageWidth / 2;\n        } else if (currentTurned === totalLeaves) {\n            containerTranslateX = effectivePageWidth;\n        }\n    }\n\n    return (\n        <div\n            className={cn(\"w-full flex flex-col items-center justify-center select-none py-6\", className)}\n            style={style}\n            onMouseEnter={() => setIsHovered(true)}\n            onMouseLeave={() => {\n                setIsHovered(false);\n                setPeekingIndex(null);\n            }}\n        >\n            {/* 3D Book Viewport Stage */}\n            <div\n                className=\"relative flex items-center justify-center transition-all duration-500\"\n                style={{\n                    perspective: `${perspective}px`,\n                    width: `${effectivePageWidth * 2 + (isSmallScreen ? 12 : 40)}px`,\n                    height: `${effectivePageHeight + 40}px`,\n                }}\n            >\n                {/* 3D Book Container */}\n                <div\n                    className=\"relative transition-transform\"\n                    style={{\n                        width: `${effectivePageWidth}px`,\n                        height: `${effectivePageHeight}px`,\n                        transformStyle: \"preserve-3d\",\n                        transition: `transform ${duration}s ${easing}`,\n                        transform: `translateX(${containerTranslateX}px)`,\n                    }}\n                >\n                    {/* Spine Binding Crease Line */}\n                    {showSpineBinding && (\n                        <div\n                            className=\"absolute top-0 bottom-0 left-[-3px] w-[6px] rounded-l-sm bg-gradient-to-r from-black/80 via-zinc-800 to-black/30 z-[999] pointer-events-none opacity-95\"\n                        />\n                    )}\n\n                    {/* Book Leaves Stacking Loop */}\n                    {pages.map((leaf, index) => {\n                        const isTurned = index < currentTurned;\n                        const isCanPeek = index === currentTurned;\n                        const isPeeking = peekingIndex === index;\n                        const isFrontCover = index === 0;\n                        const isBackCover = index === totalLeaves - 1;\n\n                        // Calculate robust stack zIndex\n                        // Unturned leaves stack downwards (top leaf highest)\n                        // Turned leaves stack upwards (last turned leaf highest)\n                        let zIndex = isTurned ? index + 1 : totalLeaves - index;\n\n                        // Give highest z-index priority to the active leaf currently flipping\n                        if (index === currentTurned - 1) {\n                            // Leaf that was just flipped to the left stays on top of left stack\n                            zIndex = totalLeaves + 20;\n                        } else if (index === currentTurned) {\n                            // Leaf about to flip from right stays on top of right stack\n                            zIndex = totalLeaves + 10;\n                        }\n\n                        // A leaf in motion outranks everything for the duration of the\n                        // turn. When several turn at once (goTo), order them the way the\n                        // stack they are landing on will order them, so nothing reshuffles\n                        // when the flight ends.\n                        if (flipping && index >= flipping.from && index < flipping.to) {\n                            zIndex = totalLeaves + 30 + (flipping.forward ? index - flipping.from : flipping.to - index);\n                        }\n\n                        let leafRotation = isTurned ? -turnAngle : 0;\n                        if (!isTurned && isPeeking) {\n                            leafRotation = -peekAngle;\n                        }\n\n                        // One shadow per stack, cast by the leaf at its bottom: the\n                        // last leaf under the unturned stack, the first under the\n                        // turned one. Every leaf casting its own stacked the same\n                        // shadow N times into a dark halo on all sides, and a turned\n                        // leaf's box-shadow isn't hidden by backface-visibility.\n                        const castsShadow =\n                            shadowIntensity > 0 &&\n                            ((index === totalLeaves - 1 && !isTurned) || (index === 0 && isTurned));\n\n                        const frontGrad = leaf.frontColor || \"from-emerald-500 to-teal-600\";\n                        const backGrad = leaf.backColor || \"from-indigo-500 to-purple-600\";\n\n                        return (\n                            <div\n                                key={leaf.id ?? index}\n                                onClick={() => handleLeafClick(index)}\n                                onMouseEnter={() => {\n                                    if (isCanPeek) setPeekingIndex(index);\n                                }}\n                                onMouseLeave={() => {\n                                    if (peekingIndex === index) setPeekingIndex(null);\n                                }}\n                                className={cn(\n                                    \"absolute inset-0 origin-left border-0 shadow-none transition-transform\",\n                                    interactive ? \"cursor-pointer\" : \"pointer-events-none\"\n                                )}\n                                style={{\n                                    transformStyle: \"preserve-3d\",\n                                    transition: `transform ${duration}s ${easing}`,\n                                    transform: `rotateY(${leafRotation}deg)`,\n                                    zIndex,\n                                    borderRadius: parsedRadius,\n                                    // Negative spread keeps it beneath the book rather\n                                    // than as an even halo round every edge.\n                                    boxShadow: castsShadow\n                                        ? `0 14px 28px -10px rgba(0, 0, 0, ${shadowIntensity})`\n                                        : \"none\",\n                                }}\n                            >\n                                {/* FRONT FACE */}\n                                <div\n                                    className=\"absolute inset-0 w-full h-full bg-zinc-900 dark:bg-zinc-950 overflow-hidden flex flex-col justify-between\"\n                                    style={{\n                                        backfaceVisibility: \"hidden\",\n                                        WebkitBackfaceVisibility: \"hidden\",\n                                        borderRadius: parsedRadius,\n                                    }}\n                                >\n                                    <img\n                                        src={leaf.frontImage}\n                                        alt={leaf.frontTitle ?? `Plate ${index * 2 + 1}`}\n                                        className=\"absolute inset-0 w-full h-full object-cover pointer-events-none select-none\"\n                                        loading=\"eager\"\n                                    />\n                                    <div className=\"absolute inset-0 bg-gradient-to-t from-black/95 via-black/40 to-transparent pointer-events-none\" />\n\n                                    {/* Integrated Spine Crease Overlay on Front Face */}\n                                    <div className=\"absolute top-0 bottom-0 left-0 w-[8px] bg-gradient-to-r from-black/90 via-zinc-900/60 to-transparent pointer-events-none z-30\" />\n\n                                     {/* Top Header */}\n                                    <div className=\"relative p-2 sm:p-3.5 z-10 flex items-center justify-between pointer-events-none\">\n                                        {!isFrontCover && leaf.frontBadge ? (\n                                            <span className={cn(\n                                                \"px-1.5 sm:px-2.5 py-0.5 sm:py-1 rounded-md text-[7px] sm:text-[9px] font-bold uppercase tracking-widest text-white bg-gradient-to-r ml-1 sm:ml-2\",\n                                                frontGrad\n                                            )}>\n                                                {leaf.frontBadge}\n                                            </span>\n                                        ) : <div />}\n                                        {/* Page Number */}\n                                        {showPageNumbers && !isFrontCover && (\n                                            <span className=\"px-1.5 sm:px-2.5 py-0.5 rounded-md text-[8px] sm:text-[10px] font-mono font-extrabold bg-black/60 backdrop-blur-md text-emerald-300\">\n                                                #{index * 2}\n                                            </span>\n                                        )}\n                                    </div>\n\n                                    {/* Bottom Content Metadata */}\n                                    {isFrontCover ? (\n                                        /* High-Fashion Minimalist Magazine Editorial Cover Design */\n                                        <div className=\"relative p-3 sm:p-6 z-10 w-full h-full flex flex-col justify-between pointer-events-none\">\n                                            {/* Top Brand Header */}\n                                            <div className=\"flex items-center justify-between z-20 pt-1 sm:pt-2\">\n                                                <div className=\"flex items-center gap-1 bg-black/70 backdrop-blur-md px-2 sm:px-3 py-0.5 sm:py-1 rounded-full border border-white/20\">\n                                                    <Globe className=\"w-2.5 h-2.5 sm:w-3.5 sm:h-3.5 text-emerald-400\" />\n                                                    <span className=\"text-[7px] sm:text-[9px] font-mono font-semibold tracking-widest text-white uppercase\">\n                                                        VOL. 08 — EDITION I\n                                                    </span>\n                                                </div>\n                                                <Sparkles className=\"w-3 h-3 sm:w-4 sm:h-4 text-emerald-400\" />\n                                            </div>\n\n                                            {/* Bottom Magazine Monograph Header */}\n                                            <div className=\"z-20 space-y-1 sm:space-y-2 pb-2 sm:pb-6\">\n                                                <div className=\"w-6 sm:w-10 h-0.5 sm:h-1 bg-gradient-to-r from-emerald-400 to-teal-500 rounded-full\" />\n                                                <h1 className=\"text-xl sm:text-4xl font-bold tracking-tighter text-white uppercase font-sans leading-tight sm:leading-none drop-shadow-2xl\">\n                                                    {leaf.frontTitle || \"TERRA INCOGNITA\"}\n                                                </h1>\n                                                <p className=\"text-[10px] sm:text-xs font-medium text-emerald-200/90 leading-tight sm:leading-relaxed max-w-[95%] sm:max-w-[90%] line-clamp-2 sm:line-clamp-none\">\n                                                    {leaf.frontSubtitle || \"A Visual Exploration of Earth's Most Remote Frontiers\"}\n                                                </p>\n                                                <div className=\"pt-0.5 sm:pt-2 text-[7px] sm:text-[9px] font-mono font-semibold tracking-widest text-zinc-300 uppercase\">\n                                                    AVARA MAGNATE PRESS\n                                                </div>\n                                            </div>\n                                        </div>\n                                    ) : (\n                                        /* Standard Plate Front Layout */\n                                        <div className=\"relative p-2 sm:p-4 z-10 space-y-0.5 sm:space-y-1 pointer-events-none\">\n                                            {leaf.frontTitle && (\n                                                <h4 className=\"text-xs sm:text-base font-bold tracking-tight text-white leading-tight\">\n                                                    {leaf.frontTitle}\n                                                </h4>\n                                            )}\n                                            {leaf.frontSubtitle && (\n                                                <p className=\"text-[9px] sm:text-xs font-semibold text-emerald-200/90 line-clamp-1\">\n                                                    {leaf.frontSubtitle}\n                                                </p>\n                                            )}\n                                        </div>\n                                    )}\n                                </div>\n\n                                {/* BACK FACE */}\n                                <div\n                                    className=\"absolute inset-0 w-full h-full bg-zinc-900 dark:bg-zinc-950 overflow-hidden flex flex-col justify-between\"\n                                    style={{\n                                        backfaceVisibility: \"hidden\",\n                                        WebkitBackfaceVisibility: \"hidden\",\n                                        transform: \"rotateY(180deg)\",\n                                        borderRadius: parsedRadius,\n                                    }}\n                                >\n                                    <img\n                                        src={leaf.backImage}\n                                        alt={leaf.backTitle ?? `Plate ${index * 2 + 2}`}\n                                        className=\"absolute inset-0 w-full h-full object-cover pointer-events-none select-none\"\n                                        loading=\"eager\"\n                                    />\n                                    <div className=\"absolute inset-0 bg-gradient-to-t from-black/95 via-black/40 to-transparent pointer-events-none\" />\n\n                                    {/* Integrated Spine Crease Overlay on Back Face */}\n                                    <div className=\"absolute top-0 bottom-0 right-0 w-[8px] bg-gradient-to-l from-black/90 via-zinc-900/60 to-transparent pointer-events-none z-30\" />\n\n                                    {/* Top Header */}\n                                    <div className=\"relative p-2 sm:p-3.5 z-10 flex items-center justify-between pointer-events-none\">\n                                        {!isBackCover && leaf.backBadge ? (\n                                            <span className={cn(\n                                                \"px-1.5 sm:px-2.5 py-0.5 sm:py-1 rounded-md text-[7px] sm:text-[9px] font-bold uppercase tracking-widest text-white bg-gradient-to-r\",\n                                                backGrad\n                                            )}>\n                                                {leaf.backBadge}\n                                            </span>\n                                        ) : <div />}\n                                        {/* Page Number */}\n                                        {showPageNumbers && !isBackCover && (\n                                            <span className=\"px-1.5 sm:px-2.5 py-0.5 rounded-md text-[8px] sm:text-[10px] font-mono font-extrabold bg-black/60 backdrop-blur-md text-cyan-300 mr-1 sm:mr-2\">\n                                                #{index * 2 + 1}\n                                            </span>\n                                        )}\n                                    </div>\n\n                                    {/* Bottom Content Metadata */}\n                                    {isBackCover ? (\n                                        /* Luxurious Royal Back Cover Design */\n                                        <div className=\"relative p-3 sm:p-6 z-10 w-full space-y-1.5 sm:space-y-3 pointer-events-none bg-gradient-to-t from-black/95 via-black/85 to-transparent text-center flex flex-col items-center justify-end pb-4 sm:pb-9\">\n                                            <div className=\"w-8 sm:w-12 h-0.5 bg-gradient-to-r from-purple-400 to-indigo-500 rounded-full mb-0.5\" />\n                                            <h3 className=\"text-xs sm:text-base font-bold tracking-[0.15em] sm:tracking-[0.2em] uppercase text-white font-serif\">\n                                                {leaf.backTitle || \"THE INFINITE COSMOS\"}\n                                            </h3>\n                                            <p className=\"text-[9px] sm:text-[11px] font-medium text-zinc-300/90 leading-tight sm:leading-relaxed max-w-[95%] sm:max-w-[92%] line-clamp-2 sm:line-clamp-none\">\n                                                {leaf.backSubtitle || \"Published by Avara Fine Art Press. All rights reserved.\"}\n                                            </p>\n                                            <div className=\"pt-1 sm:pt-2 w-full flex items-center justify-between border-t border-white/15 text-zinc-400 text-[7px] sm:text-[9px] font-mono\">\n                                                <span>ISBN 978-0-321-12345-6</span>\n                                                <QrCode className=\"w-3 h-3 sm:w-4 sm:h-4 text-white/80\" />\n                                            </div>\n                                        </div>\n                                    ) : (\n                                        /* Standard Plate Back Layout */\n                                        <div className=\"relative p-2 sm:p-4 z-10 space-y-0.5 sm:space-y-1 pointer-events-none\">\n                                            {leaf.backTitle && (\n                                                <h4 className=\"text-xs sm:text-base font-bold tracking-tight text-white leading-tight\">\n                                                    {leaf.backTitle}\n                                                </h4>\n                                            )}\n                                            {leaf.backSubtitle && (\n                                                <p className=\"text-[9px] sm:text-xs font-semibold text-cyan-200/90 line-clamp-1\">\n                                                    {leaf.backSubtitle}\n                                                </p>\n                                            )}\n                                        </div>\n                                    )}\n                                </div>\n                            </div>\n                        );\n                    })}\n                </div>\n            </div>\n\n            {/* Minimal Shadowless Icon-Only Controls Toolbar */}\n            {showControls && (\n                <div className=\"flex items-center justify-center gap-2 mt-5 p-1.5 rounded-full bg-muted/60 border border-border/70 backdrop-blur-md z-50 select-none shadow-none\">\n                    {/* Prev Button (Icon Only) */}\n                    <button\n                        onClick={flipPrev}\n                        disabled={currentTurned === 0}\n                        aria-label=\"Previous Page\"\n                        className=\"p-2.5 rounded-full flex items-center justify-center bg-background hover:bg-muted text-foreground border border-border/60 active:scale-90 disabled:opacity-30 disabled:pointer-events-none transition-all cursor-pointer shadow-none\"\n                    >\n                        <ChevronLeft className=\"w-4 h-4\" />\n                    </button>\n\n                    {/* Reset Button (Icon Only) */}\n                    <button\n                        onClick={resetBook}\n                        disabled={currentTurned === 0}\n                        aria-label=\"Reset Book\"\n                        className=\"p-2.5 rounded-full flex items-center justify-center bg-background hover:bg-muted text-muted-foreground hover:text-foreground border border-border/60 active:scale-90 disabled:opacity-30 disabled:pointer-events-none transition-all cursor-pointer group shadow-none\"\n                    >\n                        <RotateCcw className=\"w-4 h-4 group-hover:-rotate-90 transition-transform duration-300\" />\n                    </button>\n\n                    {/* Page Leaves Counter Badge */}\n                    <div className=\"px-3.5 py-1.5 rounded-full bg-background border border-border/60 text-xs font-mono font-semibold text-foreground flex items-center gap-1.5 shadow-none\">\n                        <span className=\"text-primary font-extrabold\">{currentTurned}</span>\n                        <span className=\"text-muted-foreground/60 font-normal\">/</span>\n                        <span>{totalLeaves}</span>\n                    </div>\n\n                    {/* Next Button (Icon Only) */}\n                    <button\n                        onClick={flipNext}\n                        disabled={currentTurned === totalLeaves}\n                        aria-label=\"Next Page\"\n                        className=\"p-2.5 rounded-full flex items-center justify-center bg-primary hover:bg-primary/90 text-primary-foreground border border-primary/20 active:scale-90 disabled:opacity-30 disabled:pointer-events-none transition-all cursor-pointer shadow-none\"\n                    >\n                        <ChevronRight className=\"w-4 h-4\" />\n                    </button>\n                </div>\n            )}\n        </div>\n    );\n});\n\nBookFlip.displayName = \"BookFlip\";\n\nexport default BookFlip;\nexport { BookFlip as ThreeDImagePageflip };\n",
      "type": "registry:component",
      "target": "components/custom/book-flip.tsx"
    }
  ],
  "docs": "Supports leaves array prop, controlled currentIndex, keyboard navigation, and custom aspect ratios.",
  "categories": [
    "data-display",
    "utilities"
  ],
  "type": "registry:component"
}
