:root { --c1: #FF6B6B; --c2: #FFD93D; --c3: #6BCB77; --c4: #4D96FF; --c5: #FF922B; --c6: #CC5DE8; --bg: #FFF9F0; --radius: 24px; --shadow: 0 8px 24px rgba(0,0,0,0.10); } * { box-sizing: border-box; margin: 0; padding: 0; } body { font-family: 'Nunito', sans-serif; background: var(--bg); color: #2D2D2D; min-height: 100dvh; overflow-x: hidden; } /* HEADER */ header { background: linear-gradient(135deg, var(--c1) 0%, var(--c5) 100%); padding: 24px 20px 64px; text-align: center; position: relative; overflow: hidden; } header::after { content: ''; position: absolute; bottom: -1px; left: 0; right: 0; height: 48px; background: var(--bg); border-radius: 50% 50% 0 0 / 100%; } header h1 { font-family: 'Fredoka One', cursive; font-size: clamp(2.2rem, 8vw, 3.2rem); color: white; text-shadow: 3px 3px 0 rgba(0,0,0,0.15); } header p { color: rgba(255,255,255,0.88); font-size: 1rem; margin-top: 4px; font-weight: 700; } /* CATEGORIES */ #categories { display: flex; gap: 12px; padding: 8px 16px 20px; overflow-x: auto; scrollbar-width: none; } #categories::-webkit-scrollbar { display: none; } .cat-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 16px; border: 3px solid #eee; border-radius: 20px; background: white; box-shadow: var(--shadow); cursor: pointer; min-width: 76px; flex-shrink: 0; font-family: 'Nunito', sans-serif; transition: transform 0.15s; -webkit-tap-highlight-color: transparent; } .cat-btn:active { transform: scale(0.93); } .cat-btn .icon { font-size: 2.2rem; line-height: 1; } .cat-btn .label { font-size: 0.72rem; font-weight: 800; white-space: nowrap; letter-spacing: 0.3px; } .cat-btn.active { border-color: var(--ac); background: var(--ac); color: white; transform: scale(1.07); box-shadow: 0 8px 20px rgba(0,0,0,0.18); } /* INFO BAR */ #result-info { padding: 0 16px 10px; font-weight: 700; color: #aaa; font-size: 0.85rem; min-height: 24px; } /* GRID */ #grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; padding: 0 16px 120px; } .img-card { background: white; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; cursor: pointer; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; position: relative; -webkit-tap-highlight-color: transparent; transition: transform 0.15s, box-shadow 0.15s; } .img-card:active { transform: scale(0.95); box-shadow: 0 4px 12px rgba(0,0,0,0.1); } .img-card img { width: 100%; height: 100%; object-fit: contain; padding: 10px; } .img-card .print-overlay { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(transparent, rgba(77,150,255,0.9)); padding: 20px 10px 10px; display: flex; align-items: flex-end; justify-content: center; opacity: 0; transition: opacity 0.2s; } .img-card:hover .print-overlay { opacity: 1; } .print-overlay span { font-size: 0.78rem; font-weight: 800; color: white; text-align: center; } /* SKELETON */ .skeleton { background: linear-gradient(90deg, #f0f0f0 25%, #e8e8e8 50%, #f0f0f0 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius); aspect-ratio: 1; } @keyframes shimmer { to { background-position: -200% 0; } } /* LOADING */ #loading { display: none; flex-direction: column; align-items: center; padding: 60px 20px; gap: 16px; } #loading.show { display: flex; } .spinner { width: 56px; height: 56px; border: 6px solid #eee; border-top-color: var(--c1); border-radius: 50%; animation: spin 0.75s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } } #loading p { font-weight: 700; color: #bbb; } /* EMPTY / HINT */ #empty { display: none; text-align: center; padding: 60px 20px; } #empty.show { display: block; } #empty .e { font-size: 4rem; } #empty p { margin-top: 12px; font-weight: 700; color: #bbb; } #hint { text-align: center; padding: 40px 20px; } #hint .big { font-size: 4rem; } #hint p { margin-top: 12px; font-size: 1.1rem; font-weight: 700; color: #ccc; } /* LIGHTBOX */ #lightbox { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.88); z-index: 1000; flex-direction: column; align-items: center; justify-content: center; padding: 20px; gap: 16px; } #lightbox.show { display: flex; } #lb-img { max-width: min(90vw, 600px); max-height: 62vh; border-radius: 20px; background: white; padding: 16px; object-fit: contain; } #lb-title { color: white; font-weight: 700; font-size: 1rem; text-align: center; max-width: 80vw; opacity: 0.85; } .lb-btns { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; } .lb-btn { padding: 14px 28px; border: none; border-radius: 16px; font-family: 'Fredoka One', cursive; font-size: 1.1rem; cursor: pointer; box-shadow: var(--shadow); transition: transform 0.12s; -webkit-tap-highlight-color: transparent; } .lb-btn:active { transform: scale(0.93); } .lb-btn.print { background: var(--c3); color: white; } .lb-btn.close { background: white; color: #444; } 🎨 Ausmalbilder WΓ€hle eine Kategorie! πŸ‘† Tippe auf eine Kategorie! Lade Bilder… πŸ˜• Keine Bilder gefunden οΏΌ πŸ–¨οΈ Drucken βœ• Schließen // ─── CONFIG ───────────────────────────────────────────────── // Passe an deine Domain an, z.B. 'https://ausmalbilder.meine-domain.de/api' const API_BASE = '/api'; const CATEGORIES = [ { id: 'tiere', label: 'Tiere', icon: '🐘', color: '#6BCB77' }, { id: 'pferde', label: 'Pferde', icon: '🐴', color: '#FF922B' }, { id: 'dinos', label: 'Dinos', icon: 'πŸ¦•', color: '#4D96FF' }, { id: 'fahrzeuge', label: 'Autos', icon: 'πŸš—', color: '#FF6B6B' }, { id: 'raketen', label: 'Weltraum', icon: 'πŸš€', color: '#CC5DE8' }, { id: 'prinzessin', label: 'MΓ€rchen', icon: 'πŸ‘Έ', color: '#FF6EB4' }, { id: 'drachen', label: 'Drachen', icon: 'πŸ‰', color: '#FF922B' }, { id: 'blumen', label: 'Blumen', icon: '🌸', color: '#6BCB77' }, { id: 'ozean', label: 'Ozean', icon: '🐬', color: '#4D96FF' }, { id: 'bauernhof', label: 'Bauernhof', icon: 'πŸ„', color: '#FFD93D' }, { id: 'insekten', label: 'Insekten', icon: 'πŸ¦‹', color: '#CC5DE8' }, { id: 'weihnacht', label: 'Weihnacht', icon: 'πŸŽ„', color: '#FF6B6B' }, ]; let currentLargeUrl = ''; let imageCache = {}; // ─── INIT ─────────────────────────────────────────────────── document.addEventListener('DOMContentLoaded', () => { renderCategories(); document.getElementById('btn-close').addEventListener('click', closeLightbox); document.getElementById('btn-print').addEventListener('click', printImage); document.getElementById('lightbox').addEventListener('click', e => { if (e.target === e.currentTarget) closeLightbox(); }); if ('serviceWorker' in navigator) { navigator.serviceWorker.register('sw.js').catch(() => {}); } }); // ─── CATEGORIES ───────────────────────────────────────────── function renderCategories() { document.getElementById('categories').innerHTML = CATEGORIES.map(cat => ` `).join(''); } async function selectCategory(id) { document.querySelectorAll('.cat-btn').forEach(b => b.classList.remove('active')); document.getElementById('cat-' + id).classList.add('active'); document.getElementById('hint').style.display = 'none'; if (imageCache[id]) { renderImages(imageCache[id]); document.getElementById('result-info').textContent = `${imageCache[id].length} Ausmalbilder`; return; } await loadImages(id); } // ─── LOAD ─────────────────────────────────────────────────── async function loadImages(categoryId) { const grid = document.getElementById('grid'); const loading = document.getElementById('loading'); const empty = document.getElementById('empty'); const info = document.getElementById('result-info'); empty.classList.remove('show'); info.textContent = ''; loading.classList.add('show'); grid.innerHTML = Array(12).fill('
').join(''); try { const res = await fetch(`${API_BASE}/images/${categoryId}`); if (!res.ok) throw new Error(`HTTP ${res.status}`); const data = await res.json(); loading.classList.remove('show'); grid.innerHTML = ''; if (!data.images || data.images.length === 0) { empty.classList.add('show'); return; } imageCache[categoryId] = data.images; renderImages(data.images); info.textContent = `${data.images.length} Ausmalbilder`; } catch (err) { loading.classList.remove('show'); grid.innerHTML = ''; empty.classList.add('show'); console.error('Ladefehler:', err); } } function renderImages(images) { const grid = document.getElementById('grid'); grid.innerHTML = ''; document.getElementById('empty').classList.remove('show'); images.forEach(img => { const card = document.createElement('div'); card.className = 'img-card'; card.innerHTML = ` ${img.title} `; card.addEventListener('click', () => openLightbox(img.large || img.thumb, img.title)); grid.appendChild(card); }); } // ─── LIGHTBOX ─────────────────────────────────────────────── function openLightbox(url, title) { currentLargeUrl = url; document.getElementById('lb-img').src = url; document.getElementById('lb-title').textContent = title || ''; document.getElementById('lightbox').classList.add('show'); document.body.style.overflow = 'hidden'; } function closeLightbox() { document.getElementById('lightbox').classList.remove('show'); document.body.style.overflow = ''; currentLargeUrl = ''; document.getElementById('lb-img').src = ''; } function printImage() { const win = window.open('', '_blank'); win.document.write(` `); win.document.close(); }