(function() {
  'use strict';
  
  var SORO_BLOG_TITLE = 'agapefamilyfarms.com';
  var SORO_ARTICLES = [{"id":"6af5e502-9cb0-49f1-add7-0d0a52aaa068","title":"Rustic Wedding Planning Guide for Florida Couples","slug":"rustic-wedding-planning-guide-florida-couples","excerpt":"This rustic wedding planning guide helps Central Florida couples choose a farm venue, shape their style, plan for weather, and host with ease and heart.","content":null,"date":"October 10, 2026","isoDate":"2026-10-10T03:14:47.207+00:00","image":"https://afocirmbqdxnkyescnev.supabase.co/storage/v1/object/public/featured-images/dee036a5-8e3c-4db4-a4fb-6a40ac86c1f6/workflows/d9c263ef-6508-4bd9-8702-dd13d45b16ac.webp"},{"id":"444a62cb-3b17-4a47-b08d-2ce39f208458","title":"How to Create Kid Friendly Celebrations That Shine","slug":"create-kid-friendly-celebrations","excerpt":"Create kid friendly celebrations with room to play, simple planning, farm fun, and thoughtful touches that let every guest enjoy the day together today.","content":null,"date":"October 8, 2026","isoDate":"2026-10-08T03:21:22.736+00:00","image":"https://afocirmbqdxnkyescnev.supabase.co/storage/v1/object/public/featured-images/dee036a5-8e3c-4db4-a4fb-6a40ac86c1f6/workflows/d2fde4ee-c55a-449d-b02f-fe3fd81cba29.webp"},{"id":"3fad4227-daea-42af-98e7-2b18dea82d27","title":"Farm Venue Versus Banquet Hall: Which Fits?","slug":"farm-venue-versus-banquet-hall","excerpt":"Choosing a farm venue versus banquet hall? Compare atmosphere, guest comfort, planning support, food, and fun for your Central Florida celebration day.","content":null,"date":"October 6, 2026","isoDate":"2026-10-06T03:13:43.571+00:00","image":"https://afocirmbqdxnkyescnev.supabase.co/storage/v1/object/public/featured-images/dee036a5-8e3c-4db4-a4fb-6a40ac86c1f6/workflows/25b524cc-e33c-4582-85b9-e36e4c9d7152.webp"},{"id":"f1ebc4cd-137a-4bb7-868d-5cf5d0fb88c7","title":"Wedding Venues That Feel Like Your Love Story","slug":"wedding-venues-love-story","excerpt":"Wedding venues should make your day feel personal, beautiful, and easy to enjoy. Learn what to look for before you book your ideal Central Florida setting.","content":null,"date":"October 4, 2026","isoDate":"2026-10-04T03:14:00.498+00:00","image":"https://afocirmbqdxnkyescnev.supabase.co/storage/v1/object/public/featured-images/dee036a5-8e3c-4db4-a4fb-6a40ac86c1f6/workflows/3a6ee280-8f94-40cb-8322-fdba2b742215.webp"},{"id":"1b1b0bf6-3c9e-4755-bafd-b00119f6de3b","title":"Event Coordination Questions to Ask Before You Book","slug":"event-coordination-questions","excerpt":"Get clear event coordination questions answered before your celebration, from food and weather plans to setup, guest flow, and joyful farm activities.","content":null,"date":"October 2, 2026","isoDate":"2026-10-02T03:21:31.553+00:00","image":"https://afocirmbqdxnkyescnev.supabase.co/storage/v1/object/public/featured-images/dee036a5-8e3c-4db4-a4fb-6a40ac86c1f6/workflows/7d22acb6-5a6f-455d-8d4a-db2899b02de9.webp"},{"id":"5129e4dc-fbd1-40de-9eca-72fbb8f6875a","title":"How to Choose Wedding Reception Catering for Guests","slug":"choose-wedding-reception-catering","excerpt":"Learn how to choose wedding reception catering that suits your guests, budget, and setting, with a menu that feels warm, beautiful, and simple to enjoy.","content":null,"date":"September 30, 2026","isoDate":"2026-09-30T03:14:49.455+00:00","image":"https://afocirmbqdxnkyescnev.supabase.co/storage/v1/object/public/featured-images/dee036a5-8e3c-4db4-a4fb-6a40ac86c1f6/workflows/f358d407-a4de-4b12-8fbe-0e7bdb075e1d.webp"},{"id":"9a7a3c7f-9225-453c-99bb-6f599f90102b","title":"Best Baby Shower Venue Features to Look For","slug":"best-baby-shower-venue-features","excerpt":"Discover the best baby shower venue features for a beautiful, relaxed Central Florida celebration, from flexible spaces to thoughtful support and comfort.","content":null,"date":"September 28, 2026","isoDate":"2026-09-28T03:13:25.267+00:00","image":"https://afocirmbqdxnkyescnev.supabase.co/storage/v1/object/public/featured-images/dee036a5-8e3c-4db4-a4fb-6a40ac86c1f6/workflows/80d56150-4ff9-47b2-b4ec-8b4e4cea3fd8.webp"},{"id":"13830d6d-9208-433d-8035-6708a194b4f1","title":"Farm Venues That Turn Gatherings Into Memories","slug":"farm-venues-gatherings-memories","excerpt":"See why farm venues create warm, easy celebrations with beautiful scenery, family fun, and thoughtful planning for every meaningful milestone together.","content":null,"date":"September 26, 2026","isoDate":"2026-09-26T03:20:28.194+00:00","image":"https://afocirmbqdxnkyescnev.supabase.co/storage/v1/object/public/featured-images/dee036a5-8e3c-4db4-a4fb-6a40ac86c1f6/workflows/1fa31e73-7fe9-4a9a-9312-950a656bfb25.webp"},{"id":"eddf0b7c-5524-49b2-a939-e78f867d8fa5","title":"Farm Birthday Planning for Joyful, Easy Parties","slug":"farm-birthday-planning","excerpt":"Make farm birthday planning feel easy with a private Central Florida celebration full of animal visits, play, good food, and meaningful time together.","content":null,"date":"September 24, 2026","isoDate":"2026-09-24T03:21:09.148+00:00","image":"https://afocirmbqdxnkyescnev.supabase.co/storage/v1/object/public/featured-images/dee036a5-8e3c-4db4-a4fb-6a40ac86c1f6/workflows/18c52e1b-52f8-439b-be8c-2b3143132e34.webp"},{"id":"e9404b26-7ee7-4d0e-978e-73e08dc0f868","title":"How to Plan a Stress-Free Quinceañera Celebration","slug":"plan-stress-free-quinceanera","excerpt":"Learn how to plan stress free quinceañera celebration with a clear budget, meaningful traditions, guest-friendly timing, and a venue team you can trust.","content":null,"date":"September 22, 2026","isoDate":"2026-09-22T03:14:19.092+00:00","image":"https://afocirmbqdxnkyescnev.supabase.co/storage/v1/object/public/featured-images/dee036a5-8e3c-4db4-a4fb-6a40ac86c1f6/workflows/a409e77c-55ad-4210-a2f2-4eb12b34aaaf.webp"},{"id":"c4f85795-ab34-4428-90d4-360af2347f13","title":"Full Service Versus Rental Venue for Your Party","slug":"full-service-versus-rental-venue","excerpt":"Choosing a full service versus rental venue? See changes for your budget, planning time, food, guest experience, and celebration day in Central Florida.","content":null,"date":"September 20, 2026","isoDate":"2026-09-20T03:20:44.478+00:00","image":"https://afocirmbqdxnkyescnev.supabase.co/storage/v1/object/public/featured-images/dee036a5-8e3c-4db4-a4fb-6a40ac86c1f6/workflows/1cb48f03-dcc6-429f-98ce-b186aadcc6e5.webp"},{"id":"a9f8abbf-877a-496a-922b-12feb336c145","title":"Birthday Party Activities Kids Will Remember","slug":"birthday-party-activities-kids-will-remember","excerpt":"Make birthday party activities feel effortless with farm fun, animals, play, food, and space for Central Florida families to celebrate joyfully.","content":null,"date":"September 18, 2026","isoDate":"2026-09-18T03:24:18.839+00:00","image":"https://afocirmbqdxnkyescnev.supabase.co/storage/v1/object/public/featured-images/dee036a5-8e3c-4db4-a4fb-6a40ac86c1f6/workflows/c4ad31a0-f159-4807-8e2f-5ae81e44a6da.webp"},{"id":"b91e5653-3763-4f45-a4ed-19df08e3058b","title":"Private Party Venue Sebring for Meaningful Events","slug":"private-party-venue-sebring","excerpt":"Searching for a private party venue Sebring families love? See how a farm celebration brings food, fun, warm scenery, and stress-free hosting together.","content":null,"date":"September 16, 2026","isoDate":"2026-09-16T03:31:26.228+00:00","image":"https://afocirmbqdxnkyescnev.supabase.co/storage/v1/object/public/featured-images/dee036a5-8e3c-4db4-a4fb-6a40ac86c1f6/workflows/0857b5f5-5623-4723-89b4-36a4cf68012e.webp"},{"id":"bb0a96d8-09a2-467d-972c-4ab0360b2f10","title":"How to Choose an Employee Appreciation Event Venue","slug":"employee-appreciation-event-venue","excerpt":"Choose an employee appreciation event venue that gives your Central Florida team room to relax, connect, and feel truly valued beyond the office together.","content":null,"date":"September 14, 2026","isoDate":"2026-09-14T03:43:02.361+00:00","image":"https://afocirmbqdxnkyescnev.supabase.co/storage/v1/object/public/featured-images/dee036a5-8e3c-4db4-a4fb-6a40ac86c1f6/workflows/9b0a2837-c5c1-4842-8002-92a13bfd287c.webp"},{"id":"a5c9e6dc-b1d3-4236-81b4-c9356f586cb7","title":"Event Setup and Cleanup Without Missing the Joy","slug":"event-setup-and-cleanup","excerpt":"Make room for the moments that matter. Our event setup and cleanup support helps Central Florida hosts celebrate with less work and more joy together.","content":null,"date":"September 13, 2026","isoDate":"2026-09-13T03:41:56.923+00:00","image":"https://afocirmbqdxnkyescnev.supabase.co/storage/v1/object/public/featured-images/dee036a5-8e3c-4db4-a4fb-6a40ac86c1f6/workflows/6aaa358a-98f7-4bd9-b724-dff3bb4e8881.webp"},{"id":"b86f51c8-dbcf-4ffb-9f7e-10faf161a64c","title":"Farm to Table Catering for Events That Feel Personal","slug":"farm-to-table-catering-for-events","excerpt":"Farm to table catering for events brings Central Florida celebrations closer to the land with seasonal flavor, thoughtful planning, and warm hospitality.","content":null,"date":"September 12, 2026","isoDate":"2026-09-12T02:52:21.14+00:00","image":"https://afocirmbqdxnkyescnev.supabase.co/storage/v1/object/public/featured-images/dee036a5-8e3c-4db4-a4fb-6a40ac86c1f6/workflows/a4c72a28-40b8-4d98-8ce5-94dd5d98225a.webp"},{"id":"e69d4f1c-4e8b-4e57-a1a7-f090c924299e","title":"Choosing a Corporate Retreat Venue Central Florida","slug":"corporate-retreat-venue-central-florida","excerpt":"Find a corporate retreat venue in Central Florida where teams trade routine for fresh air, focused conversation, farm views, and easy planning together.","content":null,"date":"September 11, 2026","isoDate":"2026-09-11T02:12:13.791+00:00","image":"https://afocirmbqdxnkyescnev.supabase.co/storage/v1/object/public/featured-images/dee036a5-8e3c-4db4-a4fb-6a40ac86c1f6/workflows/8dc96b89-553e-4dd3-9141-bf141eb5ce2d.webp"},{"id":"0110d275-68dc-4d3e-837e-8485ee951fa1","title":"Choosing a Retirement Party Venue in Florida","slug":"retirement-party-venue-florida","excerpt":"Find a retirement party venue in Florida that feels personal, beautiful, and easy to plan, with room for stories, family, food, and joyful memories.","content":null,"date":"September 10, 2026","isoDate":"2026-09-10T02:12:54.43+00:00","image":"https://afocirmbqdxnkyescnev.supabase.co/storage/v1/object/public/featured-images/dee036a5-8e3c-4db4-a4fb-6a40ac86c1f6/workflows/1a1c4e40-df2b-4c07-8f1d-2ef387856c83.webp"},{"id":"e4877897-4b7e-4f31-9f65-f0ed0bc202ae","title":"How to Choose an Outdoor Anniversary Party Venue","slug":"outdoor-anniversary-party-venue","excerpt":"Choose an outdoor anniversary party venue in Central Florida with beautiful views, planning support, great food, and space for every generation to gather.","content":null,"date":"September 9, 2026","isoDate":"2026-09-09T02:16:34.346+00:00","image":"https://afocirmbqdxnkyescnev.supabase.co/storage/v1/object/public/featured-images/dee036a5-8e3c-4db4-a4fb-6a40ac86c1f6/workflows/0b90c6dd-2cff-4da2-8c6f-25959191366d.webp"},{"id":"7006f725-f5e9-4d41-83e7-78e3fd3e7654","title":"Graduation Party Venue Sebring Families Remember","slug":"graduation-party-venue-sebring","excerpt":"Choose a graduation party venue Sebring families can enjoy together, with beautiful farm views, thoughtful planning, food, fun, and room to celebrate.","content":null,"date":"September 8, 2026","isoDate":"2026-09-08T07:04:04.588+00:00","image":"https://afocirmbqdxnkyescnev.supabase.co/storage/v1/object/public/featured-images/dee036a5-8e3c-4db4-a4fb-6a40ac86c1f6/workflows/2a68bd3c-27da-4fd2-8eff-b7ad805c4f89.webp"},{"id":"21e733d9-a2ae-4681-b154-f69cb1427035","title":"How to Choose a Family Reunion Venue in Central Florida","slug":"family-reunion-venue-central-florida","excerpt":"Choose a family reunion venue in Central Florida with beautiful gathering spaces, farm fun for every age, and caring help from setup through cleanup too.","content":null,"date":"September 7, 2026","isoDate":"2026-09-07T09:06:55.851+00:00","image":"https://afocirmbqdxnkyescnev.supabase.co/storage/v1/object/public/featured-images/dee036a5-8e3c-4db4-a4fb-6a40ac86c1f6/workflows/2bfcd67f-6f75-4694-a1f2-5f58fc265b8d.webp"},{"id":"54d61606-ea06-4f27-a455-353584b93f21","title":"How to Choose a Garden Venue for a Bridal Shower","slug":"garden-venue-for-bridal-shower","excerpt":"Choose a garden venue for bridal shower celebrations with beautiful scenery, thoughtful planning, and room for guests to relax together with ease and joy.","content":null,"date":"September 6, 2026","isoDate":"2026-09-06T09:12:53.178+00:00","image":"https://afocirmbqdxnkyescnev.supabase.co/storage/v1/object/public/featured-images/dee036a5-8e3c-4db4-a4fb-6a40ac86c1f6/workflows/993b64ed-2a2d-4f0c-8280-3334732d403b.webp"},{"id":"66f6171d-9acd-46ea-8f60-2789b1faeb5e","title":"Choosing a Baby Shower Venue With Catering","slug":"baby-shower-venue-with-catering","excerpt":"Choose a baby shower venue with catering for a beautiful, relaxed Central Florida celebration with farm-fresh food, thoughtful details, and less to manage.","content":null,"date":"September 5, 2026","isoDate":"2026-09-05T09:18:53.726+00:00","image":"https://afocirmbqdxnkyescnev.supabase.co/storage/v1/object/public/featured-images/dee036a5-8e3c-4db4-a4fb-6a40ac86c1f6/workflows/96a94b0f-1205-4691-af8b-f1aed774471e.webp"},{"id":"87d5401f-2065-4690-a785-e593789759e6","title":"Why a Party Venue With Playground Feels Easier","slug":"party-venue-with-playground","excerpt":"Choose a party venue with playground fun, farm animals, welcoming spaces, and thoughtful coordination so every guest can celebrate with ease and joy.","content":null,"date":"September 4, 2026","isoDate":"2026-09-04T09:21:52.947+00:00","image":"https://afocirmbqdxnkyescnev.supabase.co/storage/v1/object/public/featured-images/dee036a5-8e3c-4db4-a4fb-6a40ac86c1f6/workflows/8c8c2b88-52a5-4a8e-8de0-34870daac318.webp"},{"id":"a98ff977-f35e-41e3-8d5f-8946d44675d0","title":"Why a Petting Zoo for Private Events Feels Special","slug":"petting-zoo-for-private-events","excerpt":"Bring generations together with a petting zoo for private events in Central Florida, plus thoughtful planning tips for a joyful, stress-free celebration.","content":null,"date":"September 3, 2026","isoDate":"2026-09-03T05:18:47.626+00:00","image":"https://afocirmbqdxnkyescnev.supabase.co/storage/v1/object/public/featured-images/dee036a5-8e3c-4db4-a4fb-6a40ac86c1f6/a98ff977-f35e-41e3-8d5f-8946d44675d0.webp"},{"id":"4331610c-9892-4ed7-aae0-7bc87aef79fe","title":"Choosing a Farm Birthday Party Venue in Florida","slug":"choosing-a-farm-birthday-party-venue-florida","excerpt":"Choose a farm birthday party venue with room to play, beautiful farm views, and thoughtful support so parents can enjoy the celebration with ease, too.","content":null,"date":"September 2, 2026","isoDate":"2026-09-02T16:46:46.569+00:00","image":"https://afocirmbqdxnkyescnev.supabase.co/storage/v1/object/public/featured-images/bd84edc4-643f-45f7-b913-bf3b4cb616b3/4331610c-9892-4ed7-aae0-7bc87aef79fe.webp"},{"id":"1f22a24b-1684-4356-883c-43505c2f11ab","title":"Foam Party Upgrade for Events Guests Love","slug":"foam-party-upgrade-for-events","excerpt":"A foam party upgrade for events brings cool, carefree fun to Central Florida celebrations, with thoughtful planning, guest comfort, and photo-ready joy.","content":null,"date":"September 2, 2026","isoDate":"2026-09-02T16:06:54.524+00:00","image":"https://afocirmbqdxnkyescnev.supabase.co/storage/v1/object/public/featured-images/dee036a5-8e3c-4db4-a4fb-6a40ac86c1f6/workflows/8e98b1e5-b76a-4d2d-badc-5a1ed5142eba.webp"}];
  var SORO_TOKEN = 'e855b09c-be2f-407b-9997-fe2f77e1eedc';
  var SORO_API_BASE = 'https://app.trysoro.com';
  var SORO_T = {"allArticles":"All Articles","backToAll":"Back to all articles","loading":"Loading article...","error":"Failed to load article. Please try again.","empty":"Published articles may take up to 60 minutes to appear here.","blogArticles":"Blog articles"};
  
  // Content cache (loaded on demand)
  var contentCache = {};
  
  // Pre-populate cache with any server-included content (for SEO deep links)
  SORO_ARTICLES.forEach(function(article) {
    if (article.content) {
      contentCache[article.id] = article.content;
    }
  });
  
  // Find the container
  var container = document.getElementById('soro-blog');
  if (!container) {
    console.error('Soro Blog: No element with id="soro-blog" found');
    return;
  }
  
  // Save the original page title so we can restore it
  var originalTitle = document.title;
  var originalDescription = '';
  var descMeta = document.querySelector('meta[name="description"]');
  if (descMeta) originalDescription = descMeta.getAttribute('content') || '';
  
  // Detect if running inside a srcdoc iframe (website builders like GoDaddy, Wix, etc.)
  var isSrcdocIframe = false;
  var parentBaseUrl = null;
  try {
    isSrcdocIframe = window.location.href === 'about:srcdoc' || 
                     window.location.pathname === '/srcdoc' ||
                     (window.self !== window.top && window.location.origin === 'null');
  } catch(e) {
    isSrcdocIframe = true; // cross-origin means we're in an iframe
  }
  
  // Try to get the parent page URL for building article links
  if (isSrcdocIframe) {
    try {
      var pUrl = new URL(window.parent.location.href);
      pUrl.searchParams.delete('post');
      parentBaseUrl = pUrl.origin + pUrl.pathname + pUrl.search;
    } catch(e) {
      parentBaseUrl = null;
    }
  }
  
  // Detect deep-linked article from URL query param: ?post=slug
  function getRequestedSlug() {
    try {
      if (isSrcdocIframe) {
        // In srcdoc iframe, check parent URL if accessible
        try {
          var params = new URLSearchParams(window.parent.location.search);
          return params.get('post') || null;
        } catch(e) {
          return null;
        }
      }
      var params = new URLSearchParams(window.location.search);
      return params.get('post') || null;
    } catch(e) {
      return null;
    }
  }
  
  // Build article URL with query param (preserves existing params)
  function getArticleUrl(slug) {
    try {
      if (isSrcdocIframe && parentBaseUrl) {
        // Build full parent page URL with ?post= param so new tab works
        var sep = parentBaseUrl.indexOf('?') !== -1 ? '&' : '?';
        return parentBaseUrl + sep + 'post=' + encodeURIComponent(slug);
      }
      if (isSrcdocIframe) {
        return '#post=' + encodeURIComponent(slug);
      }
      var url = new URL(window.location.href);
      url.searchParams.set('post', slug);
      return url.pathname + url.search;
    } catch(e) {
      return '#post=' + encodeURIComponent(slug);
    }
  }
  
  // Get the base list URL (current page without post param)
  function getListUrl() {
    try {
      if (isSrcdocIframe && parentBaseUrl) {
        return parentBaseUrl;
      }
      if (isSrcdocIframe) {
        return '#';
      }
      var url = new URL(window.location.href);
      url.searchParams.delete('post');
      var search = url.search;
      return url.pathname + (search ? search : '');
    } catch(e) {
      return window.location.pathname;
    }
  }
  
  // Safe pushState wrapper (fails silently in srcdoc iframes)
  function safePushState(state, title, url) {
    if (isSrcdocIframe) return;
    try {
      history.pushState(state, title, url);
    } catch(e) {
      // pushState not available (srcdoc iframe, cross-origin, etc.)
    }
  }
  
  // Update page meta tags for SEO (title, description, canonical, JSON-LD)
  // Skip in srcdoc iframes since we can't meaningfully update the parent page
  function updatePageMeta(article) {
    if (isSrcdocIframe) return;
    if (article) {
      // Article view: set article-specific meta
      document.title = article.title + ' | ' + SORO_BLOG_TITLE;
      
      var desc = document.querySelector('meta[name="description"]');
      if (!desc) {
        desc = document.createElement('meta');
        desc.setAttribute('name', 'description');
        document.head.appendChild(desc);
      }
      desc.setAttribute('content', article.excerpt);
      
      // Set canonical URL to the article deep link
      var canonical = document.querySelector('link[rel="canonical"][data-soro]');
      if (!canonical) {
        canonical = document.createElement('link');
        canonical.setAttribute('rel', 'canonical');
        canonical.setAttribute('data-soro', 'true');
        document.head.appendChild(canonical);
      }
      canonical.setAttribute('href', window.location.href);
      
      // JSON-LD: single BlogPosting
      injectJsonLd({
        '@context': 'https://schema.org',
        '@type': 'BlogPosting',
        'headline': article.title,
        'description': article.excerpt,
        'datePublished': article.isoDate,
        'image': article.image || undefined,
        'url': window.location.href
      });
    } else {
      // List view: restore original meta
      document.title = originalTitle;
      
      var desc = document.querySelector('meta[name="description"]');
      if (desc && originalDescription) {
        desc.setAttribute('content', originalDescription);
      }
      
      // Remove soro canonical
      var canonical = document.querySelector('link[rel="canonical"][data-soro]');
      if (canonical) canonical.remove();
      
      // JSON-LD: Blog with all articles
      var blogPosting = SORO_ARTICLES.map(function(a) {
        var item = {
          '@type': 'BlogPosting',
          'headline': a.title,
          'description': a.excerpt,
          'datePublished': a.isoDate,
          'url': window.location.origin + getArticleUrl(a.slug)
        };
        if (a.image) item.image = a.image;
        return item;
      });
      
      injectJsonLd({
        '@context': 'https://schema.org',
        '@type': 'Blog',
        'name': SORO_BLOG_TITLE,
        'blogPost': blogPosting
      });
    }
  }
  
  // Inject styles
  var styleId = 'soro-blog-styles-light';
  if (!document.getElementById(styleId)) {
    var style = document.createElement('style');
    style.id = styleId;
    style.textContent = `
      .soro-blog {
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
        max-width: 800px;
        margin: 0 auto;
        color: #1a1a1a;
        background: transparent;
      }
      .soro-blog * {
        box-sizing: border-box;
      }
      .soro-blog a {
        text-decoration: none;
        color: inherit;
      }
      .soro-blog-header {
        display: none;
        align-items: center;
        margin-bottom: 16px;
      }
      .soro-blog-back {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        background: transparent;
        border: 1px solid #e5e5e5;
        color: #666;
        cursor: pointer;
        font-size: 14px;
        padding: 8px 16px;
        border-radius: 6px;
        transition: background 0.2s, border-color 0.2s;
        text-decoration: none;
      }
      .soro-blog-back:hover {
        background: #f5f5f5;
        border-color: #d0d0d0;
      }
      .soro-blog-list {
        display: flex;
        flex-direction: column;
        gap: 24px;
      }
      .soro-blog-card {
        display: flex;
        gap: 20px;
        padding: 20px;
        background: transparent;
        border: 1px solid #e5e5e5;
        border-radius: 12px;
        cursor: pointer;
        transition: box-shadow 0.2s, border-color 0.2s;
        text-decoration: none;
        color: inherit;
      }
      .soro-blog-card:hover {
        box-shadow: 0 4px 12px rgba(0,0,0,0.08);
        border-color: #d0d0d0;
      }
      .soro-blog-card-image {
        width: 140px;
        height: 100px;
        object-fit: cover;
        border-radius: 8px;
        flex-shrink: 0;
      }
      .soro-blog-card-content {
        flex: 1;
        min-width: 0;
      }
      .soro-blog-card-title {
        font-size: 18px;
        font-weight: 600;
        margin: 0 0 8px 0;
        line-height: 1.3;
        color: #1a1a1a;
      }
      h2.soro-blog-card-title {
        font-size: 18px;
      }
      .soro-blog-card-excerpt {
        font-size: 14px;
        color: #666;
        margin: 0 0 12px 0;
        line-height: 1.5;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
      }
      .soro-blog-card-date {
        font-size: 12px;
        color: #999;
      }
      .soro-blog-article {
        display: none;
      }
      .soro-blog-article.visible {
        display: block;
      }
      .soro-blog-article-title {
        font-size: 32px;
        font-weight: 700;
        margin: 0 0 12px 0;
        line-height: 1.2;
        color: #1a1a1a;
      }
      .soro-blog-article-date {
        font-size: 14px;
        color: #666;
        margin-bottom: 24px;
      }
      .soro-blog-article-image {
        width: 100%;
        max-height: 400px;
        object-fit: cover;
        border-radius: 12px;
        margin-bottom: 24px;
      }
      .soro-blog-article-content {
        font-size: 16px;
        line-height: 1.7;
        color: #1a1a1a;
      }
      .soro-blog-article-content h1,
      .soro-blog-article-content h2,
      .soro-blog-article-content h3 {
        margin-top: 32px;
        margin-bottom: 16px;
        line-height: 1.3;
        color: #1a1a1a;
      }
      .soro-blog-article-content h2 {
        font-size: 24px;
      }
      .soro-blog-article-content h3 {
        font-size: 20px;
      }
      .soro-blog-article-content p {
        margin: 0 0 16px 0;
      }
      .soro-blog-article-content ul,
      .soro-blog-article-content ol {
        margin: 0 0 16px 0;
        padding-left: 24px;
        padding-right: 0;
      }
      .soro-blog-article-content li {
        margin-bottom: 8px;
      }
      .soro-blog-article-content a {
        color: #0066cc;
      }
      .soro-blog-article-content img {
        max-width: 100%;
        height: auto;
        border-radius: 8px;
      }
      .soro-blog-empty {
        text-align: center;
        padding: 48px 24px;
        color: #666;
      }
      .soro-blog-loading {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 48px 24px;
        color: #666;
      }
      .soro-blog-spinner {
        width: 24px;
        height: 24px;
        border: 2px solid #e5e5e5;
        border-top-color: #1a1a1a;
        border-radius: 50%;
        animation: soro-spin 0.8s linear infinite;
        margin-right: 12px;
      }
      @keyframes soro-spin {
        to { transform: rotate(360deg); }
      }
      .soro-blog-error {
        text-align: center;
        padding: 48px 24px;
        color: #dc2626;
      }
      @media (max-width: 600px) {
        .soro-blog-card {
          flex-direction: column;
          gap: 12px;
        }
        .soro-blog-card-image {
          width: 100%;
          height: 180px;
        }
        .soro-blog-article-title {
          font-size: 24px;
        }
      }
    `;
    document.head.appendChild(style);
  }
  
  // Inject or update JSON-LD structured data
  function injectJsonLd(data) {
    var jsonLdId = 'soro-blog-jsonld';
    var existing = document.getElementById(jsonLdId);
    if (existing) existing.remove();
    
    var script = document.createElement('script');
    script.id = jsonLdId;
    script.type = 'application/ld+json';
    script.textContent = JSON.stringify(data);
    document.head.appendChild(script);
  }
  
  // State
  var currentView = 'list';
  var currentArticle = null;
  var isLoading = false;
  
  // Fetch article content on demand
  function fetchArticleContent(articleId, callback) {
    // Check cache first (includes server-pre-rendered content for deep links)
    if (contentCache[articleId]) {
      callback(null, contentCache[articleId]);
      return;
    }
    
    var url = SORO_API_BASE + '/api/embed/' + SORO_TOKEN + '/article/' + articleId;
    
    fetch(url)
      .then(function(response) {
        if (!response.ok) throw new Error('Failed to load article');
        return response.json();
      })
      .then(function(data) {
        contentCache[articleId] = data.content;
        callback(null, data.content);
      })
      .catch(function(error) {
        callback(error, null);
      });
  }
  
  // Render article list — cards are real <a> links for SEO crawlability
  function renderList() {
    if (SORO_ARTICLES.length === 0) {
      return '<div class="soro-blog-empty"><p>' + SORO_T.empty + '</p></div>';
    }
    
    var html = '<section class="soro-blog-list" role="feed" aria-label="' + SORO_T.blogArticles + '">';
    SORO_ARTICLES.forEach(function(article) {
      var articleUrl = getArticleUrl(article.slug);
      var targetAttr = isSrcdocIframe ? ' target="_blank" rel="noopener"' : '';
      html += '<a href="' + articleUrl + '"' + targetAttr + ' class="soro-blog-card" data-slug="' + escapeHtml(article.slug) + '" itemscope itemtype="https://schema.org/BlogPosting">';
      if (article.image) {
        html += '<img class="soro-blog-card-image" src="' + article.image + '" alt="' + escapeHtml(article.title) + '" loading="lazy" itemprop="image">';
      }
      html += '<div class="soro-blog-card-content">';
      html += '<h2 class="soro-blog-card-title" itemprop="headline">' + escapeHtml(article.title) + '</h2>';
      html += '<p class="soro-blog-card-excerpt" itemprop="description">' + escapeHtml(article.excerpt) + '</p>';
      html += '<time class="soro-blog-card-date" datetime="' + article.isoDate + '" itemprop="datePublished">' + article.date + '</time>';
      html += '</div></a>';
    });
    html += '</section>';
    return html;
  }
  
  function renderArticle(article, content) {
    var html = '<article class="soro-blog-article visible" itemscope itemtype="https://schema.org/BlogPosting">';
    html += '<header>';
    html += '<h1 class="soro-blog-article-title" itemprop="headline">' + escapeHtml(article.title) + '</h1>';
    html += '<time class="soro-blog-article-date" datetime="' + article.isoDate + '" itemprop="datePublished">' + article.date + '</time>';
    html += '</header>';
    if (article.image) {
      html += '<img class="soro-blog-article-image" src="' + article.image + '" alt="' + escapeHtml(article.title) + '" itemprop="image">';
    }
    html += '<div class="soro-blog-article-content" itemprop="articleBody">' + content + '</div>';
    html += '</article>';
    return html;
  }
  
  function renderLoading() {
    return '<div class="soro-blog-loading"><div class="soro-blog-spinner"></div>' + SORO_T.loading + '</div>';
  }
  
  function renderError() {
    return '<div class="soro-blog-error"><p>' + SORO_T.error + '</p></div>';
  }
  
  function escapeHtml(str) {
    var div = document.createElement('div');
    div.textContent = str;
    return div.innerHTML;
  }
  
  // Make all links inside article content open in a new tab
  // This is critical for embeds running on external sites or inside iframes
  function processContentLinks(parentEl) {
    var links = parentEl.querySelectorAll('.soro-blog-article-content a');
    for (var i = 0; i < links.length; i++) {
      links[i].setAttribute('target', '_blank');
      links[i].setAttribute('rel', 'noopener noreferrer');
    }
  }
  
  // Navigate to article view (updates URL without full reload)
  function showArticle(slug) {
    var article = null;
    for (var i = 0; i < SORO_ARTICLES.length; i++) {
      if (SORO_ARTICLES[i].slug === slug) {
        article = SORO_ARTICLES[i];
        break;
      }
    }
    if (!article) {
      // Unknown slug (deleted or unpublished article) — show the list instead of a blank widget
      showList();
      return;
    }

    currentArticle = article;
    currentView = 'article';
    
    // Update URL (pushState so back button works)
    var articleUrl = getArticleUrl(slug);
    if (!isSrcdocIframe && window.location.pathname + window.location.search !== articleUrl) {
      safePushState({ post: slug }, '', articleUrl);
    }
    
    // Update page meta for SEO
    updatePageMeta(article);
    
    var header = container.querySelector('.soro-blog-header');
    var content = container.querySelector('.soro-blog-content');
    header.style.display = 'flex';
    
    // Check if content is already available (pre-rendered or cached)
    if (contentCache[article.id]) {
      content.innerHTML = renderArticle(article, contentCache[article.id]);
      processContentLinks(content);
    } else {
      // Show loading, then fetch
      isLoading = true;
      content.innerHTML = renderLoading();
      
      fetchArticleContent(article.id, function(error, articleContent) {
        isLoading = false;
        if (error) {
          content.innerHTML = renderError();
        } else {
          content.innerHTML = renderArticle(article, articleContent);
          processContentLinks(content);
        }
      });
    }
    
    container.scrollIntoView({ behavior: 'smooth', block: 'start' });
  }
  
  // Navigate to list view
  function showList() {
    currentView = 'list';
    currentArticle = null;
    isLoading = false;
    
    // Update URL
    var listUrl = getListUrl();
    if (!isSrcdocIframe && window.location.pathname + window.location.search !== listUrl) {
      safePushState({ post: null }, '', listUrl);
    }
    
    // Restore page meta
    updatePageMeta(null);
    
    var header = container.querySelector('.soro-blog-header');
    var content = container.querySelector('.soro-blog-content');
    header.style.display = 'none';
    content.innerHTML = renderList();
    
    // Intercept card link clicks
    var cards = content.querySelectorAll('.soro-blog-card');
    cards.forEach(function(card) {
      card.addEventListener('click', function(e) {
        e.preventDefault();
        var slug = card.getAttribute('data-slug');
        if (isSrcdocIframe) {
          // In srcdoc iframe, open article in a new tab with real URL
          var url = getArticleUrl(slug);
          window.open(url, '_blank');
        } else {
          showArticle(slug);
        }
      });
    });
  }
  
  // Handle browser back/forward buttons (not applicable in srcdoc iframes)
  if (!isSrcdocIframe) {
    window.addEventListener('popstate', function(e) {
      var slug = getRequestedSlug();
      if (slug) {
        showArticle(slug);
      } else {
        showList();
      }
    });
  }
  
  // Initial render
  var backArrow = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M19 12H5M12 19l-7-7 7-7"/></svg>';
  container.innerHTML = '<div class="soro-blog">' +
    '<div class="soro-blog-header" style="display: none;">' +
      '<a href="' + getListUrl() + '" class="soro-blog-back" aria-label="' + SORO_T.backToAll + '">' +
        backArrow +
        SORO_T.allArticles +
      '</a>' +
    '</div>' +
    '<div class="soro-blog-content"></div>' +
  '</div>';
  
  // Add back button handler (intercept for SPA navigation)
  container.querySelector('.soro-blog-back').addEventListener('click', function(e) {
    e.preventDefault();
    showList();
  });
  
  // Check if URL has a deep-linked article on initial load
  var initialSlug = getRequestedSlug();
  if (initialSlug) {
    showArticle(initialSlug);
  } else {
    showList();
  }
})();