// KotschAds — eigene Werbe-Engine statt Monetag/AdSense (Umbau 2026-07-21).
// Anzeigen kommen als JSON von kotsch.tech und werden im Toolaro-Design gerendert.
// Verwaltung: kotsch.tech/admin/werbung. First-party, kein Tracking-Script, kein Consent nötig.

export const ADS_API = "https://www.kotsch.tech/api/ads/serve";

export type HouseAd = {
  id: number;
  title: string;
  body: string | null;
  image: string | null;
  video: string | null;
  cta: string;
  type: "app" | "webtool" | "shop" | "affiliate" | "custom";
  url: string; // Klick-URL (zählt + leitet weiter)
};

export async function fetchHouseAds(zone: string, limit: number): Promise<HouseAd[]> {
  try {
    const res = await fetch(`${ADS_API}?site=toolaro&zone=${encodeURIComponent(zone)}&limit=${limit}`, {
      cache: "no-store",
    });
    const json = (await res.json()) as { ok: boolean; ads: HouseAd[] };
    return json.ok ? json.ads : [];
  } catch {
    return [];
  }
}

// Anzahl gestapelter Karten je Seitenleiste (NUR Desktop ≥1280px — mobil sind die Leisten
// ausgeblendet). Rechts „voll" (dort ist kein Inhalt), links dezent. Frei änderbar.
export const RAIL_BANNERS: { left: number; right: number } = { left: 2, right: 4 };
