import{j as e}from"./vendor-ui-CUslpDkL.js";import{u as i,w as l,b as n,B as c,A as m,s as d}from"./index-CJqEbhJN.js";import{L as o}from"./vendor-react-Dg0Tra3e.js";import{u as x}from"./vendor-query-CN1EccJz.js";import{f as u}from"./format-BrSaXzvW.js";import"./vendor-supabase-yzuDJZPy.js";import"./vendor-motion-CiNtJfg1.js";function y(){const{t:a}=i(),{data:t=[]}=x({queryKey:["latestBlogPosts"],queryFn:async()=>{const{data:s,error:r}=await d.from("blog_posts").select("id, title, slug, excerpt, created_at, read_time_minutes, category, cover_image_url").order("created_at",{ascending:!1}).limit(3);if(r)throw r;return s||[]},staleTime:5*60*1e3});return e.jsx("section",{className:"py-16 px-4",children:e.jsxs("div",{className:"mx-auto max-w-7xl",children:[e.jsxs("div",{className:"mb-8 flex items-center gap-3",children:[e.jsx(l,{className:"w-8 h-8 text-accent"}),e.jsx("h2",{className:"text-3xl font-bold",children:a("home.fromBlog")})]}),e.jsx("div",{className:"grid gap-6 md:grid-cols-3",children:t.length===0?e.jsxs("div",{className:"col-span-3 text-center py-12 glass-card",children:[e.jsx(l,{className:"w-12 h-12 mx-auto mb-4 text-muted-foreground"}),e.jsx("p",{className:"text-muted-foreground",children:a("home.noBlogPosts")})]}):t.map(s=>e.jsxs(o,{to:`/blog/${s.slug}`,className:"glass-card-hover group cursor-pointer focus:outline-none focus:ring-2 focus:ring-primary overflow-hidden rounded-xl flex flex-col",children:[s.cover_image_url&&e.jsxs("div",{className:"relative overflow-hidden h-44",children:[e.jsx("img",{src:s.cover_image_url,alt:s.title,className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-110",loading:"lazy"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-card via-transparent to-transparent"})]}),e.jsxs("div",{className:"p-6 flex flex-col flex-1",children:[e.jsx("span",{className:"inline-block px-3 py-1 text-xs font-semibold rounded-full bg-primary/30 text-primary-foreground mb-3 w-fit",children:s.category}),e.jsx("h3",{className:"text-xl font-semibold mb-2 group-hover:text-primary transition-colors",children:s.title}),e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2 mb-4 flex-1",children:s.excerpt}),e.jsxs("div",{className:"flex items-center gap-4 text-xs text-muted-foreground",children:[e.jsx("span",{children:u(new Date(s.created_at),"MMM d, yyyy")}),e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(n,{className:"w-3 h-3"}),s.read_time_minutes," min"]})]})]})]},s.id))}),t.length>0&&e.jsx("div",{className:"mt-8 text-center",children:e.jsx(o,{to:"/blog",children:e.jsxs(c,{variant:"outline",size:"lg",children:[a("home.viewAllPosts"),e.jsx(m,{className:"ml-2 w-4 h-4"})]})})})]})})}export{y as default};