const { useState, useRef, useEffect, useCallback } = React;
const { Button, PlayButton, Card, Kicker, Chip } = window.RitmikDesignSystem_5af782;

/* ---------- i18n ---------- */
const I18N = {
  en: {
    navAbout: "About",
    navContact: "Contact",
    navFeatures:"Features", navTry:"Try it", navWeb:"On the web", navCta:"App Store",
    navExamples:"Examples", navLibrary:"Library", navBlog:"Blog", navDownload:"Download Ritmik", navOpen:"Open Ritmik",
    navInstruments:"Instruments", menuBendir:"Frame drum, Düm-Tek strokes", menuErbane:"Frame drum with rings", menuHandpan:"Tone fields and ding",
    heroKicker:"Ritmik for iPhone", heroTitle:["Your rhythm,","in your pocket."],
    heroSub: "Write rhythm notation for bendir, erbane and handpan anywhere, and keep every composition saved right on your device. No account, no cloud, just your rhythms, always with you.",
    featKicker:"What it does", featTitle:"Everything Ritmik does, now with you offline.",
    saveT:"Save on your device", saveD:"The mobile difference: every composition is stored right on your iPhone. Open, edit and play your rhythms even with no connection, nothing leaves your device.",
    libT:"A rhythm library", libD:"Start from traditional Turkish usûls and Arabic rhythms, Maqsum, Aksak, Düyek, Çiftetelli and more.",
    playT:"Play it back", playD:"Hear any rhythm with bendir and erbane voices. Change the tempo, loop the tricky bars.",
    pdfT:"PDF in and out", pdfD:"Download a clean score as PDF to print or share, or upload a PDF and let Ritmik play the rhythm back to you.",
    notaT:"Real, playable notation", notaD: "Tap in the strokes and watch proper percussion notation appear, bar by bar — düm and tek for bendir and erbane, ding and tone fields for handpan.",
    savedOnDevice:"Saved on device", pdfOut:"PDF out", pdfIn:"PDF in",
    tryKicker:"Try it right here", tryTitle:["Tap a beat.","Hear it play."],
    trySub:"This is the heart of Ritmik: place strokes, press play, and loop. Give it a go, then imagine it in your pocket, with your whole library saved on your device.",
    tryLi:["Tap a note to cycle Düm → Tek → rest","Real bendir voices, straight from the app","Drag the tempo, toggle the loop"],
    liveDemo:"Live demo", ppHint:["Tap a note to change it, "," (top line), "," (bottom) or a rest. Then press play."], loop:"Loop",
    webKicker:"Also on the web", webTitle:"Prefer a bigger screen?",
    webSub:"Ritmik lives on the web too. Everything you write in the app you can also do free in your browser at ritmik.net, no install needed. The mobile app just adds one thing the web can't: your documents, saved on your device.",
    webBtn:"Open ritmik.net", finalKicker:"For iPhone", finalTitle:["Your rhythm, on paper.","And on the go."],
    footTag:"Percussion rhythm notation for bendir, erbane and hand percussion. Tap it, write it, loop it, print it.",
    dl1:"Download on the", dl2:"App Store",
  },
  tr: {
    navAbout: "Hakkında",
    navContact: "İletişim",
    navFeatures:"Özellikler", navTry:"Deneyin", navWeb:"Web'de", navCta:"App Store",
    navExamples:"Örnekler", navLibrary:"Kütüphane", navBlog:"Blog", navDownload:"Ritmik'i indir", navOpen:"Ritmik'i aç",
    navInstruments:"Çalgılar", menuBendir:"Çerçeve davul, Düm-Tek vuruşları", menuErbane:"Zilli çerçeve davul", menuHandpan:"Ton alanları ve ding",
    heroKicker:"iPhone için Ritmik", heroTitle:["Ritminiz,","cebinizde."],
    heroSub: "Bendir, erbane ve handpan için ritim notasyonunu her yerde yazın, her besteyi doğrudan cihazınızda saklayın. Hesap yok, bulut yok, sadece ritimleriniz, hep yanınızda.",
    featKicker:"Neler yapar", featTitle:"Ritmik'in yaptığı her şey, artık çevrimdışı da yanınızda.",
    saveT:"Cihazınıza kaydedin", saveD:"Mobil farkı: her beste doğrudan iPhone'unuzda saklanır. Bağlantı olmadan bile ritimlerinizi açın, düzenleyin ve çalın, hiçbir şey cihazınızdan çıkmaz.",
    libT:"Bir ritim kütüphanesi", libD:"Geleneksel Türk usûlleri ve Arap ritimleriyle başlayın, Maksum, Aksak, Düyek, Çiftetelli ve daha fazlası.",
    playT:"Geri çalın", playD:"Her ritmi bendir ve erbane sesleriyle dinleyin. Tempoyu değiştirin, zor ölçüleri döngüye alın.",
    pdfT:"PDF al ve ver", pdfD:"Temiz bir notayı PDF olarak indirip yazdırın ya da paylaşın, veya bir PDF yükleyin, Ritmik ritmi size çalsın.",
    notaT:"Gerçek, çalınabilir notasyon", notaD: "Vuruşları dokunarak girin, ölçü ölçü gerçek vurmalı notasyonun belirişini izleyin: bendir ve erbane için düm ve tek, handpan için ding ve ton alanları.",
    savedOnDevice:"Cihaza kaydedildi", pdfOut:"PDF ver", pdfIn:"PDF al",
    tryKicker:"Hemen burada deneyin", tryTitle:["Bir ritme dokunun.","Çalışını dinleyin."],
    trySub:"Ritmik'in kalbi bu: vuruşları yerleştirin, çal'a basın ve döngüye alın. Bir deneyin, sonra hayal edin: cebinizde, tüm kütüphaneniz cihazınızda kayıtlı.",
    tryLi:["Düm → Tek → es arasında geçmek için dokunun","Doğrudan uygulamadan gerçek bendir sesleri","Tempoyu sürükleyin, döngüyü açıp kapatın"],
    liveDemo:"Canlı demo", ppHint:["Değiştirmek için bir notaya dokunun, "," (üst çizgi), "," (alt) veya es. Sonra çal'a basın."], loop:"Döngü",
    webKicker:"Web'de de var", webTitle:"Daha büyük ekran mı istersiniz?",
    webSub:"Ritmik web'de de yaşıyor. Uygulamada yazdığınız her şeyi tarayıcınızda ücretsiz olarak ritmik.net'te de yapabilirsiniz, kurulum gerekmez. Mobil uygulama yalnızca web'in yapamadığı bir şeyi ekler: belgeleriniz, cihazınızda kayıtlı.",
    webBtn:"ritmik.net'i aç", finalKicker:"iPhone için", finalTitle:["Ritminiz, kâğıtta.","Ve her yerde."],
    footTag:"Bendir, erbane ve el perküsyonu için vurmalı ritim notasyonu. Dokunun, yazın, döngüye alın, yazdırın.",
    dl1:"Şuradan indirin:", dl2:"App Store",
  },
  de: {
    navAbout: "Über",
    navContact: "Kontakt",
    navFeatures: "Funktionen",
    navTry: "Ausprobieren",
    navWeb: "Im Web",
    navCta: "App Store",
    navExamples: "Beispiele",
    navLibrary: "Bibliothek",
    navBlog: "Blog",
    navDownload: "Ritmik laden",
    navOpen: "Ritmik öffnen",
    navInstruments: "Instrumente",
    menuBendir: "Rahmentrommel, Düm-Tek-Schläge",
    menuErbane: "Rahmentrommel mit Ringen",
    menuHandpan: "Tonfelder und Ding",
    heroKicker: "Ritmik fürs iPhone",
    heroTitle: ["Ihr Rhythmus,", "in Ihrer Tasche."],
    heroSub: "Schreiben Sie Rhythmusnotation für Bendir, Erbane und Handpan überall, und jede Komposition bleibt direkt auf Ihrem Gerät gespeichert. Kein Konto, keine Cloud, nur Ihre Rhythmen, immer dabei.",
    featKicker: "Was sie kann",
    featTitle: "Alles, was Ritmik kann — jetzt auch offline bei Ihnen.",
    saveT: "Auf dem Gerät gespeichert",
    saveD: "Der Unterschied unterwegs: Jede Komposition liegt direkt auf Ihrem iPhone. Öffnen, bearbeiten und abspielen auch ohne Verbindung — nichts verlässt Ihr Gerät.",
    libT: "Eine Rhythmus-Bibliothek",
    libD: "Beginnen Sie mit traditionellen türkischen Usûls und arabischen Rhythmen: Maqsum, Aksak, Düyek, Çiftetelli und mehr.",
    playT: "Hören Sie es ab",
    playD: "Hören Sie jeden Rhythmus mit Bendir- und Erbane-Klängen. Tempo ändern, schwere Takte in die Schleife nehmen.",
    pdfT: "PDF rein und raus",
    pdfD: "Laden Sie ein sauberes PDF zum Drucken oder Teilen — oder laden Sie ein PDF hoch und lassen Sie Ritmik den Rhythmus vorspielen.",
    notaT: "Echte, spielbare Notation",
    notaD: "Tippen Sie die Schläge ein und sehen Sie Takt für Takt richtige Perkussionsnotation entstehen — Düm und Tek für Bendir und Erbane, Ding und Tonfelder für Handpan.",
    savedOnDevice: "Auf dem Gerät gespeichert",
    pdfOut: "PDF raus",
    pdfIn: "PDF rein",
    tryKicker: "Gleich hier ausprobieren",
    tryTitle: ["Tippen Sie einen Schlag.", "Hören Sie ihn."],
    trySub: "Das ist der Kern von Ritmik: Schläge setzen, abspielen, in die Schleife nehmen. Probieren Sie es aus — und stellen Sie es sich in Ihrer Tasche vor, mit Ihrer ganzen Bibliothek auf dem Gerät.",
    tryLi: ["Auf eine Note tippen: Düm → Tek → Pause", "Echte Bendir-Klänge, direkt aus der App", "Tempo ziehen, Schleife an- und ausschalten"],
    liveDemo: "Live-Demo",
    ppHint: ["Zum Ändern auf eine Note tippen: ", " (obere Linie), ", " (untere) oder eine Pause. Dann abspielen."],
    loop: "Schleife",
    webKicker: "Auch im Web",
    webTitle: "Lieber ein größerer Bildschirm?",
    webSub: "Ritmik gibt es auch im Web. Alles, was Sie in der App schreiben, geht kostenlos auch im Browser auf ritmik.net, ohne Installation. Die App bringt nur eines dazu, was das Web nicht kann: Ihre Dokumente, gespeichert auf Ihrem Gerät.",
    webBtn: "ritmik.net öffnen",
    finalKicker: "Fürs iPhone",
    finalTitle: ["Ihr Rhythmus, auf Papier.", "Und unterwegs."],
    footTag: "Rhythmusnotation für Bendir, Erbane und Handperkussion. Antippen, schreiben, in die Schleife nehmen, drucken.",
    dl1: "Laden im",
    dl2: "App Store",
  },
  fr: {
    navAbout: "À propos",
    navContact: "Contact",
    navFeatures: "Fonctionnalités",
    navTry: "Essayer",
    navWeb: "Sur le web",
    navCta: "App Store",
    navExamples: "Exemples",
    navLibrary: "Bibliothèque",
    navBlog: "Blog",
    navDownload: "Télécharger Ritmik",
    navOpen: "Ouvrir Ritmik",
    navInstruments: "Instruments",
    menuBendir: "Tambour sur cadre, frappes Düm-Tek",
    menuErbane: "Tambour sur cadre à anneaux",
    menuHandpan: "Zones de son et ding",
    heroKicker: "Ritmik pour iPhone",
    heroTitle: ["Votre rythme,", "dans votre poche."],
    heroSub: "Écrivez la notation rythmique du bendir, de l'erbane et du handpan partout, et gardez chaque composition enregistrée sur votre appareil. Sans compte, sans cloud : juste vos rythmes, toujours avec vous.",
    featKicker: "Ce qu'elle fait",
    featTitle: "Tout ce que fait Ritmik, maintenant avec vous hors ligne.",
    saveT: "Enregistré sur votre appareil",
    saveD: "La différence en mobilité : chaque composition est stockée sur votre iPhone. Ouvrez, modifiez et jouez vos rythmes même sans connexion — rien ne quitte votre appareil.",
    libT: "Une bibliothèque de rythmes",
    libD: "Partez des usûls turcs traditionnels et des rythmes arabes : Maqsum, Aksak, Düyek, Çiftetelli et bien d'autres.",
    playT: "Écoutez-le",
    playD: "Écoutez n'importe quel rythme avec les voix du bendir et de l'erbane. Changez le tempo, bouclez les mesures difficiles.",
    pdfT: "PDF à l'entrée et à la sortie",
    pdfD: "Téléchargez une partition nette en PDF pour l'imprimer ou la partager — ou importez un PDF et laissez Ritmik vous jouer le rythme.",
    notaT: "Une vraie notation, jouable",
    notaD: "Saisissez les frappes et voyez apparaître une vraie notation de percussion, mesure après mesure : düm et tek pour le bendir et l'erbane, ding et zones de son pour le handpan.",
    savedOnDevice: "Enregistré sur l'appareil",
    pdfOut: "PDF export",
    pdfIn: "PDF import",
    tryKicker: "Essayez ici même",
    tryTitle: ["Posez un temps.", "Écoutez-le."],
    trySub: "C'est le cœur de Ritmik : poser des frappes, lancer la lecture, boucler. Essayez — puis imaginez-le dans votre poche, avec toute votre bibliothèque sur votre appareil.",
    tryLi: ["Touchez une note : Düm → Tek → silence", "De vraies voix de bendir, directement dans l'app", "Faites glisser le tempo, activez la boucle"],
    liveDemo: "Démo en direct",
    ppHint: ["Touchez une note pour la changer : ", " (ligne du haut), ", " (du bas) ou un silence. Puis lancez la lecture."],
    loop: "Boucle",
    webKicker: "Aussi sur le web",
    webTitle: "Vous préférez un grand écran ?",
    webSub: "Ritmik existe aussi sur le web. Tout ce que vous écrivez dans l'app, vous pouvez le faire gratuitement dans votre navigateur sur ritmik.net, sans rien installer. L'app ajoute seulement ce que le web ne peut pas : vos documents, enregistrés sur votre appareil.",
    webBtn: "Ouvrir ritmik.net",
    finalKicker: "Pour iPhone",
    finalTitle: ["Votre rythme, sur le papier.", "Et en déplacement."],
    footTag: "Notation rythmique pour bendir, erbane et percussions à main. Touchez, écrivez, bouclez, imprimez.",
    dl1: "Télécharger dans l'",
    dl2: "App Store",
  },
  es: {
    navAbout: "Acerca de",
    navContact: "Contacto",
    navFeatures: "Funciones",
    navTry: "Probar",
    navWeb: "En la web",
    navCta: "App Store",
    navExamples: "Ejemplos",
    navLibrary: "Biblioteca",
    navBlog: "Blog",
    navDownload: "Descargar Ritmik",
    navOpen: "Abrir Ritmik",
    navInstruments: "Instrumentos",
    menuBendir: "Tambor de marco, golpes Düm-Tek",
    menuErbane: "Tambor de marco con anillas",
    menuHandpan: "Zonas de sonido y ding",
    heroKicker: "Ritmik para iPhone",
    heroTitle: ["Tu ritmo,", "en tu bolsillo."],
    heroSub: "Escribe notación rítmica para bendir, erbane y handpan donde estés, y guarda cada composición en tu propio dispositivo. Sin cuenta, sin nube: solo tus ritmos, siempre contigo.",
    featKicker: "Qué hace",
    featTitle: "Todo lo que hace Ritmik, ahora contigo y sin conexión.",
    saveT: "Guardado en tu dispositivo",
    saveD: "La diferencia cuando estás fuera: cada composición se guarda en tu iPhone. Ábrela, edítala y escúchala aunque no tengas conexión: nada sale de tu dispositivo.",
    libT: "Una biblioteca de ritmos",
    libD: "Empieza con usûles turcos tradicionales y ritmos árabes: Maqsum, Aksak, Düyek, Çiftetelli y muchos más.",
    playT: "Escúchalo",
    playD: "Escucha cualquier ritmo con las voces del bendir y el erbane. Cambia el tempo y repite en bucle los compases difíciles.",
    pdfT: "PDF de entrada y de salida",
    pdfD: "Descarga una partitura limpia en PDF para imprimirla o compartirla, o sube un PDF y deja que Ritmik te toque el ritmo.",
    notaT: "Notación real, que se puede tocar",
    notaD: "Introduce los golpes y ve aparecer notación de percusión de verdad, compás a compás: düm y tek para bendir y erbane, ding y zonas de sonido para handpan.",
    savedOnDevice: "Guardado en el dispositivo",
    pdfOut: "PDF salida",
    pdfIn: "PDF entrada",
    tryKicker: "Pruébalo aquí mismo",
    tryTitle: ["Marca un golpe.", "Escúchalo."],
    trySub: "Esto es el corazón de Ritmik: marcar golpes, darle a reproducir, repetir en bucle. Pruébalo y luego imagínatelo en tu bolsillo, con toda tu biblioteca en el dispositivo.",
    tryLi: ["Toca una nota: Düm → Tek → silencio", "Voces reales de bendir, directas desde la app", "Arrastra el tempo, activa el bucle"],
    liveDemo: "Demo en vivo",
    ppHint: ["Toca una nota para cambiarla: ", " (línea de arriba), ", " (de abajo) o un silencio. Luego dale a reproducir."],
    loop: "Bucle",
    webKicker: "También en la web",
    webTitle: "¿Prefieres una pantalla grande?",
    webSub: "Ritmik también existe en la web. Todo lo que escribes en la app puedes hacerlo gratis en el navegador, en ritmik.net, sin instalar nada. La app solo añade lo que la web no puede: tus documentos, guardados en tu dispositivo.",
    webBtn: "Abrir ritmik.net",
    finalKicker: "Para iPhone",
    finalTitle: ["Tu ritmo, sobre el papel.", "Y contigo a donde vayas."],
    footTag: "Notación rítmica para bendir, erbane y percusión de mano. Toca, escribe, repite, imprime.",
    dl1: "Descargar en la",
    dl2: "App Store",
  },
};

const FLAG_UK = '<svg class="lang-flag" viewBox="0 0 24 24" aria-hidden="true"><g clip-path="url(#uk-clip)"><path d="M12 24C18.6274 24 24 18.6274 24 12C24 5.37258 18.6274 0 12 0C5.37258 0 0 5.37258 0 12C0 18.6274 5.37258 24 12 24Z" fill="#012169"></path><path d="M22.5997 6.36939L15 12.0375L22.5831 17.6616C22.0071 18.7361 21.2723 19.7127 20.41 20.5599L12 14.2875L3.60523 20.5748C2.74272 19.7303 2.0071 18.7567 1.42962 17.6853L8.96253 12.075L1.37244 6.42212C1.93751 5.34769 2.66075 4.36942 3.5112 3.51827L11.9625 9.78749L20.4419 3.47156C21.2987 4.31969 22.0284 5.29602 22.5997 6.36939Z" fill="white"></path><path d="M20.8802 3.92883C21.1558 4.23189 21.4161 4.54912 21.6599 4.87929L14.6625 10.1625L14.7375 8.51249L20.8802 3.92883ZM1.69653 5.84505C1.91731 5.47626 2.15733 5.1203 2.4152 4.77858L8.96246 9.59999H6.71246L1.69653 5.84505ZM21.5823 19.2246C21.8255 18.9025 22.0529 18.5678 22.2632 18.2216L15.9 13.5375H13.8375L21.5823 19.2246ZM3.17825 20.135L9.22496 15.6L8.99996 14.2875L2.40421 19.2068C2.64674 19.5292 2.90514 19.839 3.17825 20.135Z" fill="#C8102E"></path><path d="M23.6219 15C23.8687 14.0411 24 13.0359 24 12C24 10.9641 23.8687 9.95886 23.6219 9H15.0375V0.387769C14.0674 0.134706 13.0494 0 12 0C10.9776 0 9.98506 0.127861 9.0375 0.368465V9H0.378052C0.131259 9.95886 0 10.9641 0 12C0 13.0359 0.131259 14.0411 0.378052 15H9.0375V23.6315C9.98506 23.8721 10.9776 24 12 24C13.0494 24 14.0674 23.8653 15.0375 23.6122V15H23.6219Z" fill="white"></path><path d="M23.8602 13.8375C23.9522 13.2385 24 12.6248 24 12C24 11.4012 23.9561 10.8127 23.8715 10.2375H13.9307L13.9989 0.165729C13.3488 0.0567323 12.681 0 12 0C11.4573 0 10.9229 0.0360314 10.3993 0.105833L10.3307 10.2375H0.12852C0.0438522 10.8127 0 11.4012 0 12C0 12.6248 0.0477508 13.2385 0.139802 13.8375H10.3063L10.2384 23.8716C10.8133 23.9562 11.4015 24 12 24C12.6251 24 13.2391 23.9522 13.8384 23.8601L13.9063 13.8375H23.8602Z" fill="#C8102E"></path></g><defs><clipPath id="uk-clip"><rect width="24" height="24" rx="12" fill="white"></rect></clipPath></defs></svg>';
const FLAG_TR = '<svg class="lang-flag" viewBox="0 0 24 24" aria-hidden="true"><g clip-path="url(#tr-clip)"><path d="M12 24C18.6274 24 24 18.6274 24 12C24 5.37258 18.6274 0 12 0C5.37258 0 0 5.37258 0 12C0 18.6274 5.37258 24 12 24Z" fill="#E30A17"></path><path d="M14.556 9.8798C13.8859 9.14622 12.9134 8.68503 11.8311 8.68503C9.80989 8.68503 8.17114 10.29 8.17114 12.2775C8.17114 14.265 9.80989 15.8775 11.8311 15.8775C12.9172 15.8775 13.8917 15.4131 14.561 14.675C13.7512 15.9381 12.3194 16.7775 10.6875 16.7775C8.16005 16.7775 6.11255 14.7638 6.11255 12.2775C6.11255 9.79128 8.16005 7.78503 10.6875 7.78503C12.3161 7.78503 13.7453 8.62105 14.556 9.8798Z" fill="white"></path><path d="M16.1512 10.1812L16.1137 11.8425L14.5649 12.2625L16.0949 12.8062L16.0574 14.3325L17.0512 13.14L18.5587 13.665L17.6887 12.3862L18.7499 11.115L17.1187 11.565L16.1512 10.1775V10.1812Z" fill="white"></path></g><defs><clipPath id="tr-clip"><rect width="24" height="24" rx="12" fill="white"></rect></clipPath></defs></svg>';

const FLAG_DE = '<svg class="lang-flag" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="12" fill="#FFCE00"></circle><path d="M0,8h24V4a12,12 0 0 0-24,0z" fill="#000000"></path><path d="M0,16h24v-8H0z" fill="#DD0000"></path></svg>';
const FLAG_FR = '<svg class="lang-flag" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="12" fill="#fff"></circle><path d="M0,12a12,12 0 0 1 8-11.3v22.6A12,12 0 0 1 0,12z" fill="#002395"></path><path d="M24,12a12,12 0 0 0-8-11.3v22.6A12,12 0 0 0 24,12z" fill="#ED2939"></path></svg>';
const FLAG_ES = '<svg class="lang-flag" viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="12" fill="#F1BF00"/><path d="M0,7.5h24a12,12 0 0 0-24,0z" fill="#AA151B"/><path d="M0,16.5h24a12,12 0 0 1-24,0z" fill="#AA151B"/></svg>';
const FLAGS = { en: FLAG_UK, tr: FLAG_TR, de: FLAG_DE, fr: FLAG_FR, es: FLAG_ES };

/* Built from i18n/registry.js, and only for languages this page has copy for —
   it used to hardcode two buttons, so /mobile.html was English or Turkish only. */
/* The url prefix for a language, from i18n/registry.js: '' for English,
   '/tr', '/de', '/fr'. Keeps every in-page link inside the reader's language. */
function localeHome(code){
  const L = (typeof window !== 'undefined' && window.RITMIK_LANGS) || [];
  for (let i = 0; i < L.length; i++) if (L[i].code === code) return (L[i].prefix || '') + '/';
  return code === 'tr' ? '/tr/' : '/';
}

function LangSelector({lang, setLang}){
  const langs = (typeof window !== 'undefined' && window.RITMIK_LANGS ? window.RITMIK_LANGS : [{code:'en'},{code:'tr'}])
    .filter(l => I18N[l.code]);
  return(
    <div className="lang" role="group" aria-label="Language">
      {langs.map(l => (
        <button key={l.code} type="button" data-lang={l.code}
          className={lang===l.code?'active':''} onClick={()=>setLang(l.code)} aria-pressed={lang===l.code}>
          {FLAGS[l.code] ? <span className="lang-flag-wrap" dangerouslySetInnerHTML={{__html:FLAGS[l.code]}}></span> : null}
          {l.code.toUpperCase()}
        </button>
      ))}
    </div>
  );
}

/* ---------- ritmik.net-style page interactions ---------- */
const FX_COLORS = ['#c94210','#6f6cf0','#3570dd','#ffc63d','#0C6C5F'];
function fxQuarter(){return '<svg viewBox="0 0 40 66" fill="currentColor"><ellipse cx="13" cy="52" rx="12" ry="8.5" transform="rotate(-18 13 52)"></ellipse><rect x="22.5" y="8" width="5" height="46" rx="2"></rect></svg>';}
function fxEighth(){return '<svg viewBox="0 0 50 66" fill="currentColor"><ellipse cx="13" cy="52" rx="12" ry="8.5" transform="rotate(-18 13 52)"></ellipse><rect x="22.5" y="8" width="5" height="46" rx="2"></rect><path d="M27.5 8 q 20 5 15 32 q 1 -19 -15 -24 z"></path></svg>';}
const FX_SHAPES=[fxQuarter,fxEighth];

function usePageFx(){
  useEffect(()=>{
    const reduce = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;

    /* progressive reveal, layered triggers so it works across scroll contexts */
    const revealEls = Array.prototype.slice.call(document.querySelectorAll('.reveal'));
    const showEl=(el)=>{ el.classList.add('in'); const k=revealEls.indexOf(el); if(k>=0) revealEls.splice(k,1); };
    const reveal=()=>{ const vh=window.innerHeight||document.documentElement.clientHeight;
      for(let i=revealEls.length-1;i>=0;i--){ const el=revealEls[i]; const r=el.getBoundingClientRect();
        if(r.top < vh*0.92 && r.bottom > 0) showEl(el); } };
    const onScroll=()=>{ reveal(); };
    let io=null;
    if('IntersectionObserver' in window){
      io=new IntersectionObserver((es)=>{ es.forEach(e=>{ if(e.isIntersecting) showEl(e.target); }); },{threshold:0.12,rootMargin:'0px 0px -6% 0px'});
      revealEls.slice().forEach(el=>io.observe(el));
    }
    reveal(); requestAnimationFrame(reveal); setTimeout(reveal,60);
    window.addEventListener('scroll', onScroll, {passive:true});
    window.addEventListener('scroll', onScroll, {passive:true, capture:true});
    document.addEventListener('scroll', onScroll, {passive:true, capture:true});
    window.addEventListener('resize', onScroll, {passive:true});
    const failsafe=setTimeout(()=>{ revealEls.slice().forEach(showEl); }, 6000);

    /* hero click-to-spawn notes */
    const hero = document.querySelector('.hero');
    let onClick;
    if(hero){
      onClick=(e)=>{ if(e.target.closest('a,button')) return; const r=hero.getBoundingClientRect();
        const x=e.clientX-r.left, y=e.clientY-r.top, n=2+Math.floor(Math.random()*2);
        for(let i=0;i<n;i++) spawnInHero(hero,x,y,i,n,reduce); };
      hero.addEventListener('click', onClick);
    }

    /* note-spill out of CTA buttons on hover (ritmik.net) */
    const spillHandlers=[];
    if(!reduce){
      document.querySelectorAll('[data-spill]').forEach(btn=>{
        const h=()=>{ const r=btn.getBoundingClientRect(); for(let i=0;i<2;i++) spawnFixed(r); };
        btn.addEventListener('pointerenter', h); spillHandlers.push([btn,h]);
      });
    }

    return ()=>{ clearTimeout(failsafe); if(io) io.disconnect(); window.removeEventListener('scroll',onScroll); window.removeEventListener('scroll',onScroll,{capture:true}); document.removeEventListener('scroll',onScroll,{capture:true}); window.removeEventListener('resize',onScroll);
      if(hero){ if(onClick) hero.removeEventListener('click',onClick); }
      spillHandlers.forEach(([b,h])=>b.removeEventListener('pointerenter',h));
    };
  },[]);
}
function spawnInHero(hero,x,y,i,total,reduce){
  const el=document.createElement('span'); el.className='spark-note';
  el.style.cssText='position:absolute;left:0;top:0;width:'+(22+Math.random()*14)+'px;z-index:6;pointer-events:none;color:'+FX_COLORS[(Math.random()*FX_COLORS.length)|0]+';filter:drop-shadow(0 4px 6px rgba(20,17,11,.18));';
  el.innerHTML=(FX_SHAPES[(Math.random()*FX_SHAPES.length)|0])();
  el.querySelector('svg').style.cssText='width:100%;height:auto;display:block;'; hero.appendChild(el);
  const spread=(i-(total-1)/2)*30, driftX=spread+(Math.random()*2-1)*36, rise=150+Math.random()*90, rot=(Math.random()*2-1)*55, dur=reduce?480:880+Math.random()*360;
  const a=el.animate([{transform:'translate('+x+'px,'+y+'px) translate(-50%,-50%) scale(.3) rotate(0deg)',opacity:0,offset:0},{opacity:1,offset:.16},{transform:'translate('+(x+driftX)+'px,'+(y-rise)+'px) translate(-50%,-50%) scale(1) rotate('+rot+'deg)',opacity:0,offset:1}],{duration:dur,easing:'cubic-bezier(.2,.7,.3,1)'});
  a.onfinish=()=>el.remove(); a.oncancel=()=>el.remove();
}
function spawnFixed(rect){
  const el=document.createElement('span'); const size=15+Math.random()*13;
  el.style.cssText='position:fixed;left:0;top:0;width:'+size+'px;z-index:9999;pointer-events:none;color:'+FX_COLORS[(Math.random()*FX_COLORS.length)|0]+';filter:drop-shadow(0 4px 6px rgba(20,17,11,.18));';
  el.innerHTML=(FX_SHAPES[(Math.random()*FX_SHAPES.length)|0])();
  el.querySelector('svg').style.cssText='width:100%;height:auto;display:block;'; document.body.appendChild(el);
  const sx=rect.left+Math.random()*rect.width, sy=rect.top+rect.height*(.25+Math.random()*.5), driftX=(Math.random()*2-1)*46, rise=54+Math.random()*64, rot=(Math.random()*2-1)*60, dur=760+Math.random()*340;
  const a=el.animate([{transform:'translate('+sx+'px,'+sy+'px) translate(-50%,-50%) scale(.35) rotate(0deg)',opacity:0,offset:0},{opacity:1,offset:.18},{transform:'translate('+(sx+driftX)+'px,'+(sy-rise)+'px) translate(-50%,-50%) scale(1) rotate('+rot+'deg)',opacity:0,offset:1}],{duration:dur,easing:'cubic-bezier(.2,.7,.3,1)'});
  a.onfinish=()=>el.remove(); a.oncancel=()=>el.remove();
}

/* ---------- brand doodles ---------- */
function NoteQuarter(p){return(<svg viewBox="0 0 40 66" fill="currentColor" aria-hidden="true" {...p}><ellipse cx="13" cy="52" rx="12" ry="8.5" transform="rotate(-18 13 52)"></ellipse><rect x="22.5" y="8" width="5" height="46" rx="2"></rect></svg>);}
function NoteEighth(p){return(<svg viewBox="0 0 50 66" fill="currentColor" aria-hidden="true" {...p}><ellipse cx="13" cy="52" rx="12" ry="8.5" transform="rotate(-18 13 52)"></ellipse><rect x="22.5" y="8" width="5" height="46" rx="2"></rect><path d="M27.5 9 C40 13, 44 24, 40 34 C42 24, 38 16, 27.5 17 Z"></path></svg>);}
function AppleGlyph({size=26}){return(<svg viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" style={{width:size,height:size,flex:"none"}}><path d="M17.05 20.28c-.98.95-2.05.8-3.08.35-1.09-.46-2.09-.48-3.24 0-1.44.62-2.2.44-3.06-.35C2.79 15.25 3.51 7.59 9.05 7.31c1.35.07 2.29.74 3.08.8 1.18-.24 2.31-.93 3.57-.84 1.51.12 2.65.72 3.4 1.8-3.12 1.87-2.38 5.98.48 7.13-.57 1.5-1.31 2.99-2.53 4.08zM12.03 7.25c-.15-2.23 1.66-4.07 3.74-4.25.29 2.58-2.34 4.5-3.74 4.25z"></path></svg>);}
function Gear(){return(<svg viewBox="0 0 256 256" fill="none" stroke="currentColor" strokeWidth="16" aria-hidden="true" style={{width:19,height:19}}><circle cx="128" cy="128" r="40"></circle><path d="M130.05 206.11h-4L94 224a94.42 94.42 0 0 1-24.75-14.3l1.35-36.06-2.83-2.83-36.06 1.35A94.42 94.42 0 0 1 17.41 147L35.29 115v-4L17.41 79A94.42 94.42 0 0 1 31.71 54.25l36.06 1.35 2.83-2.83-1.35-36.06A94.42 94.42 0 0 1 94 2.36L126 20.25h4L162 2.36A94.42 94.42 0 0 1 186.75 16.66l-1.35 36.06 2.83 2.83 36.06-1.35A94.42 94.42 0 0 1 238.59 79L220.71 111v4L238.59 147a94.42 94.42 0 0 1-14.3 24.75l-36.06-1.35-2.83 2.83 1.35 36.06A94.42 94.42 0 0 1 162 224Z" transform="translate(0,4)"></path></svg>);}

function AppStoreButton({t, placement}){
  const track = ()=>{
    if(window.va) window.va('event',{name:'appstore_click', data:{source: placement||'ios-page', page:'ios-page-'+(document.documentElement.lang==='tr'?'tr':'en'), lang: document.documentElement.lang==='tr'?'tr':'en'}});
  };
  return(
    <a className="asbtn" href="https://apps.apple.com/us/app/ritmik/id6791616074" target="_blank" rel="noopener" aria-label="Download on the App Store" data-spill onClick={track}>
      <AppleGlyph/>
      <span className="asbtn-txt"><small>{t.dl1}</small><b>{t.dl2}</b></span>
    </a>
  );
}

/* ---------- hero: 3-phone 3D coverflow ---------- */
const MAQ = [{s:'D',q:.5},{s:'T',q:.5},{s:'R',q:.5},{s:'T',q:.5},{s:'D',q:.5},{s:'R',q:.5},{s:'T',q:.5},{s:'R',q:.5}];
const MAQ2 = [{s:'D',q:.5},{s:'R',q:.5},{s:'T',q:.5},{s:'T',q:.5},{s:'D',q:.5},{s:'T',q:.5},{s:'R',q:.5},{s:'T',q:.5}];

// The home screenshot lists two düm-tek documents. The middle card is covered
// with a real handpan file — drawn live with the app's own renderer — so the
// recent list shows the instrument too. Box is in % of the screenshot, measured
// off assets/app-home.png, so it tracks the phone at any size.
const HP_DOC = [
  { sig:['4','4'], events:[
    {s:'D',s2:'5',q:.5},{s:'3',q:.5},{s:'5',q:.5},{s:'3',q:.5},
    {s:'D',q:.5},{s:'7',q:.5},{s:'5',q:.5},{s:'T',q:.5}] },
  { sig:['4','4'], events:[
    {s:'D',q:.5},{s:'1',q:.5},{s:'6',s2:'2',q:.5},{s:'S',q:.5},
    {s:'D',q:.5},{s:'4',q:.5},{s:'3',q:.5},{s:'K',q:.5}] },
];
function HandpanFile(){
  const System = window.SystemSVG;
  return(
    <div className="hpdoc" aria-hidden="true">
      <div className="hpdoc-head"><b>Handpan Ding Study</b><span>☆</span></div>
      {HP_DOC.map((r,i)=>(
        <div className="hpdoc-stave" key={i}>
          {System ? React.createElement(System, {
            measures:[{mi:0, sig:r.sig, showSig:true, events:r.events}],
            showClef:true, isLast:true, inst:'handpan', highlight:null
          }) : null}
        </div>
      ))}
      <div className="hpdoc-tags"><i className="on">4/4</i><i>Handpan</i><i>Ding</i><u>2d</u></div>
    </div>
  );
}

const HERO_SHOTS = [
  {src:"/assets/app-home.png", label:"Ritmik home screen with recent rhythm files", file:true},
  {src:"/assets/app-doc.png", label:"A rhythm document open in Ritmik"},
  {src:"/assets/app-editor.png", label:"Editing a measure with the note builder"},
];
function HeroStage(){
  const [active,setActive] = useState(1);
  const paused = useRef(false);
  useEffect(()=>{
    const id=setInterval(()=>{ if(!paused.current) setActive(a=>(a+1)%3); }, 3400);
    return ()=>clearInterval(id);
  },[]);
  return(
    <div className="hero-stage" onMouseEnter={()=>paused.current=true} onMouseLeave={()=>paused.current=false}>
      {HERO_SHOTS.map((s,i)=>{
        let rel=i-active; if(rel>1)rel-=3; if(rel<-1)rel+=3;
        return(
          <div key={i} className={"hp"+(rel===0?" front":"")} data-rel={rel} onClick={()=>setActive(i)} aria-hidden={rel!==0}>
            <div className="hp-frame">
              <img className="hp-shot" src={s.src} alt={s.label}/>
              {s.file ? <HandpanFile/> : null}
            </div>
          </div>
        );
      })}
    </div>
  );
}

/* ---------- interactive prototype ---------- */
const PATTERN0 = [{s:'D',q:.5},{s:'T',q:.5},{s:'R',q:.5},{s:'T',q:.5},{s:'D',q:.5},{s:'R',q:.5},{s:'T',q:.5},{s:'R',q:.5}];
function TapPrototype({t}){
  const [events,setEvents] = useState(PATTERN0);
  const [playing,setPlaying] = useState(false);
  const [cur,setCur] = useState(-1);
  const [loop,setLoop] = useState(true);
  const [bpm,setBpm] = useState(96);
  const bpmRef = useRef(bpm); bpmRef.current = bpm;
  const loopRef = useRef(loop); loopRef.current = loop;
  const evRef = useRef(events); evRef.current = events;
  const stepsRef = useRef(PATTERN0.map((e,i)=>({...e,_i:i})));
  const MeasureSVG = window.MeasureSVG;

  const cycle = (s)=> s==='R'?'D': s==='D'?'T':'R';
  const tapNote = (i)=>{
    setEvents(prev=>{
      const ns = cycle(prev[i].s);
      const next=prev.map((e,j)=> j===i?{...e,s:ns}:e);
      if(stepsRef.current[i]) stepsRef.current[i].s = ns;
      if(ns!=='R' && window.RithmicAudio) window.RithmicAudio.tapPreview(ns);
      return next;
    });
  };
  const stop = useCallback(()=>{ if(window.RithmicAudio) window.RithmicAudio.stop(); setPlaying(false); setCur(-1); },[]);
  const start = ()=>{
    if(!window.RithmicAudio) return;
    stepsRef.current = evRef.current.map((e,i)=>({...e, _i:i}));
    window.RithmicAudio.play(stepsRef.current, bpmRef.current, {
      loop: loopRef.current,
      onStep: (st)=> setCur(st._i),
      onEnd: ()=>{ setPlaying(false); setCur(-1); },
    });
    setPlaying(true);
  };
  const toggle = ()=> playing? stop() : start();
  useEffect(()=>()=>{ if(window.RithmicAudio) window.RithmicAudio.stop(); },[]);

  // Stop playback when the demo scrolls (mostly) out of view — a looping beat
  // the visitor can no longer see is just noise.
  const rootRef = useRef(null);
  useEffect(()=>{
    if(!playing || !rootRef.current || typeof IntersectionObserver==='undefined') return;
    const io = new IntersectionObserver(
      (entries)=>{ if(entries[0].intersectionRatio < 0.1) stop(); },
      {threshold:[0.1]}
    );
    io.observe(rootRef.current);
    return ()=> io.disconnect();
  },[playing,stop]);

  return(
    <div className="proto-phone" ref={rootRef}>
      <div className="pp-screen">
        <div className="pp-head">
          <span className="pp-kick">{t.liveDemo}</span>
          <span className="pp-sig">4/4 · Maqsum</span>
        </div>
        <p className="pp-hint">{t.ppHint[0]}<b>Düm</b>{t.ppHint[1]}<b>Tek</b>{t.ppHint[2]}</p>
        <div className="pp-stave">
          {MeasureSVG ? <MeasureSVG events={events} sig={{num:4,den:4}} showClef={true} showSig={true} showCounts={true} hlIndex={cur} onGlyphClick={tapNote} inst="bendir"/> : null}
        </div>
        <div className="pp-transport">
          <button type="button" className={"pp-loop"+(loop?" on":"")} onClick={()=>setLoop(l=>!l)} aria-pressed={loop}>
            <svg viewBox="0 0 256 256" fill="none" stroke="currentColor" strokeWidth="20" strokeLinecap="round" aria-hidden="true"><polyline points="188 32 228 72 188 112"></polyline><path d="M28 128a72 72 0 0 1 72-72h128"></path><polyline points="68 224 28 184 68 144"></polyline><path d="M228 128a72 72 0 0 1-72 72H28"></path></svg>
            {t.loop}
          </button>
          <div className="pp-tempo">
            <input type="range" min="60" max="160" value={bpm} onChange={e=>setBpm(+e.target.value)} aria-label="Tempo"/>
            <span className="pp-bpm">{bpm}<small>bpm</small></span>
          </div>
          <button type="button" className={"pp-play"+(playing?" on":"")} onClick={toggle} aria-label={playing?"Stop":"Play"}>
            {playing?<svg viewBox="0 0 256 256" fill="currentColor"><rect x="72" y="72" width="112" height="112" rx="10"></rect></svg>
                    :<svg viewBox="0 0 256 256" fill="currentColor"><polygon points="80 60 200 128 80 196 80 60"></polygon></svg>}
          </button>
        </div>
      </div>
    </div>
  );
}

/* ---------- feature card visuals ---------- */
function SaveVisual({t}){
  return(<div className="fv-save">
    <div className="fv-file"><span className="fv-check"><svg viewBox="0 0 256 256" fill="none" stroke="currentColor" strokeWidth="24" strokeLinecap="round" strokeLinejoin="round"><polyline points="216 72 104 184 48 128"></polyline></svg></span>{t.savedOnDevice}</div>
    <div className="fv-file ghost">Aksak · 9/8</div>
    <div className="fv-file ghost">Düyek study</div>
  </div>);
}
function LibVisual(){
  return(<div className="fv-lib">
    {[["Maqsum","4/4"],["Aksak","9/8"],["Çiftetelli","8/8"],["Maqam Saidi","4/4"],["Düyek","8/8"],["Baladi","4/4"]].map(([n,s],i)=>(
      <span key={i} className="fv-pill">{n}<b>{s}</b></span>
    ))}
  </div>);
}
function PlaybackVisual(){
  return(<div className="fv-play">
    <span className="fv-round"><svg viewBox="0 0 256 256" fill="currentColor"><polygon points="80 60 200 128 80 196 80 60"></polygon></svg></span>
    <div className="fv-wave">{[10,22,40,28,52,34,60,42,30,50,24,44,18,36,12].map((h,i)=>(<i key={i} style={{height:h}}></i>))}</div>
    <span className="fv-bpm">96</span>
  </div>);
}
function PdfVisual({t}){
  return(<div className="fv-pdf">
    <span className="fv-tag"><svg viewBox="0 0 256 256" fill="none" stroke="currentColor" strokeWidth="18" strokeLinecap="round" strokeLinejoin="round"><path d="M74 104l54 54 54-54"></path><line x1="128" y1="40" x2="128" y2="158"></line><path d="M216 152v56a8 8 0 0 1-8 8H48a8 8 0 0 1-8-8v-56"></path></svg>{t.pdfOut}</span>
    <span className="fv-tag"><svg viewBox="0 0 256 256" fill="none" stroke="currentColor" strokeWidth="18" strokeLinecap="round" strokeLinejoin="round"><path d="M74 94l54-54 54 54"></path><line x1="128" y1="40" x2="128" y2="158"></line><path d="M216 152v56a8 8 0 0 1-8 8H48a8 8 0 0 1-8-8v-56"></path></svg>{t.pdfIn}</span>
  </div>);
}

/* ---------- page ---------- */
function App(){
  usePageFx();
  // Language is shared with the rest of the site via localStorage['ritmik_lang'].
  const [lang,setLangState] = useState(()=>{
    // The path states the language outright — /de/mobile.html is German — and
    // that beats a stored preference, which otherwise repainted this page in
    // whatever language the reader last chose elsewhere.
    const L = (typeof window !== 'undefined' && window.RITMIK_LANGS) || [];
    for (let i = 0; i < L.length; i++) {
      const q = L[i].prefix;
      if (q && (location.pathname === q || location.pathname.indexOf(q + '/') === 0) && I18N[L[i].code]) return L[i].code;
    }
    try{ const s = localStorage.getItem('ritmik_lang'); if(I18N[s]) return s; }catch(e){}
    return 'en';
  });
  const setLang = useCallback((l)=>{
    try{ localStorage.setItem('ritmik_lang', l); }catch(e){}
    // Each language has its own url; switching navigates there so the page and
    // its canonical agree.
    const L = (typeof window !== 'undefined' && window.RITMIK_LANGS) || [];
    let prefix = null;
    for (let i = 0; i < L.length; i++) if (L[i].code === l) prefix = L[i].prefix;
    if (prefix != null && /^https?:$/.test(location.protocol)) {
      location.href = prefix + '/mobile.html';
      return;
    }
    setLangState(l);
  },[]);
  useEffect(()=>{ document.documentElement.lang = lang; },[lang]);
  const t = I18N[lang] || I18N.en;   // an unknown code must not blank the page
  return(<React.Fragment>
    {/* NAV */}
    <header className="nav">
      <div className="nav-in">
        {/* Same main navigation as the home page; the download button scrolls to
            this page's App Store section. Links are language-aware, root-absolute. */}
        <a className="brand" href={localeHome(lang)} aria-label="Ritmik"><img src="/assets/ritmik-logo.svg" alt="Ritmik" className="nav-logo"/></a>
        <nav className="nav-links">
          <div className="nav-item">
            <button className="nav-trigger" type="button" aria-haspopup="true">{t.navInstruments}<svg viewBox="0 0 256 256" fill="none" stroke="currentColor" strokeWidth="26" strokeLinecap="round" strokeLinejoin="round" aria-hidden="true"><polyline points="48 96 128 176 208 96"></polyline></svg></button>
            <div className="nav-menu" role="menu" aria-label={t.navInstruments}>
              {[['bendir','Bendir','#dcebfd',t.menuBendir],['erbane','Erbane','#ffe2cd',t.menuErbane],['handpan','Handpan','#e8e6fd',t.menuHandpan]].map(function(c){
                return (<a key={c[0]} className="nav-card" role="menuitem" style={{background:c[2]}} href={localeHome(lang)+c[0]+'.html'}>
                  <img src={'/assets/illo-'+c[0]+'.svg'} alt=""/><b>{c[1]}</b><span>{c[3]}</span>
                </a>);
              })}
            </div>
          </div>
          <a href={lang==='tr' ? '/tr/rhythms.html' : '/rhythms.html'}>{t.navLibrary}</a>
          <a href="/blog.html">{t.navBlog}</a>
        </nav>
        <LangSelector lang={lang} setLang={setLang}/>
        <a className="nav-download" href="#appstore"><AppleGlyph size={17}/><span>{t.navDownload}</span></a>
        <a className="nav-cta" href={lang==='tr' ? '/tr/Rithmic.html' : '/Rithmic.html'}>{t.navOpen}</a>
      </div>
    </header>

    {/* HERO */}
    <section className="hero snap" id="top">
      <div className="hero-bg rk-staff-bg rk-staff-bg--masked"></div>
      <span className="doodle d1"><NoteQuarter style={{width:"100%"}}/></span>
      <span className="doodle d2"><NoteEighth style={{width:"100%"}}/></span>
      <span className="doodle d3"><NoteQuarter style={{width:"100%"}}/></span>
      <div className="hero-in">
        <div className="hero-copy reveal">
          <Kicker>{t.heroKicker}</Kicker>
          <h1 className="display">{t.heroTitle[0]}<br/>{t.heroTitle[1]}</h1>
          <p className="hero-sub">{t.heroSub}</p>
          <div className="hero-cta">
            <AppStoreButton t={t} placement="hero"/>
          </div>
        </div>
        <div className="hero-art reveal"><HeroStage/></div>
      </div>
    </section>

    {/* FEATURES */}
    <section className="section snap" id="features">
      <div className="sec-head reveal">
        <Kicker>{t.featKicker}</Kicker>
        <h2 className="display sec-title">{t.featTitle}</h2>
      </div>
      <div className="bento-top">
        <div className="bcell b-save reveal">
          <Card color="coral" title={t.saveT} description={t.saveD}>
            <SaveVisual t={t}/>
          </Card>
        </div>
        <div className="bcell b-lib reveal" style={{transitionDelay:".08s"}}>
          <Card color="indigo" title={t.libT} description={t.libD}>
            <LibVisual/>
          </Card>
        </div>
        <div className="bcell b-play reveal" style={{transitionDelay:".16s"}}>
          <Card color="blue" title={t.playT} description={t.playD}>
            <PlaybackVisual/>
          </Card>
        </div>
      </div>
      <div className="bento-bottom">
        <div className="bcell b-pdf reveal">
          <Card color="yellow" title={t.pdfT} description={t.pdfD}>
            <PdfVisual t={t}/>
          </Card>
        </div>
        <div className="bcell b-notation reveal" style={{transitionDelay:".08s"}}>
          <Card color="green" title={t.notaT} description={t.notaD}>
            <img className="b-note-img" src="/assets/notation-row2.png" alt="notation"/>
          </Card>
        </div>
      </div>
    </section>

    {/* PROTOTYPE */}
    <section className="section try snap" id="try">
      <div className="try-in">
        <div className="try-copy reveal">
          <Kicker color="var(--on-blue,#f1f6ff)">{t.tryKicker}</Kicker>
          <h2 className="display sec-title">{t.tryTitle[0]}<br/>{t.tryTitle[1]}</h2>
          <p className="try-sub">{t.trySub}</p>
          <ul className="try-list">
            {t.tryLi.map((li,i)=>(<li key={i}>{li}</li>))}
          </ul>
        </div>
        <div className="try-art reveal" style={{transitionDelay:".1s"}}><TapPrototype t={t}/></div>
      </div>
    </section>

    {/* WEB */}
    <section className="section web-wrap snap" id="web">
      <div className="band reveal">
        <div className="web-in">
          <div className="web-copy">
            <Kicker style={{color:"var(--band-ink)",opacity:.82}}>{t.webKicker}</Kicker>
            <h2 className="display web-title">{t.webTitle}</h2>
            <p className="web-sub">{t.webSub}</p>
            <a className="btn-web" href="https://ritmik.net" target="_blank" rel="noopener">{t.webBtn}
              <svg viewBox="0 0 256 256" fill="none" stroke="currentColor" strokeWidth="20" strokeLinecap="round" strokeLinejoin="round" style={{width:18,height:18}}><line x1="40" y1="128" x2="208" y2="128"></line><polyline points="144 64 208 128 144 192"></polyline></svg>
            </a>
          </div>
          <div className="web-window">
            <div className="ww-bar"><i></i><i></i><i></i><span className="ww-url">ritmik.net</span></div>
            <img className="web-shot" src="/assets/ritmik-web.png" alt="Ritmik running in a web browser at ritmik.net"/>
          </div>
        </div>
      </div>
    </section>

    {/* FINAL */}
    <section className="final snap" id="appstore">
      <div className="hero-bg rk-staff-bg rk-staff-bg--masked"></div>
      <span className="doodle f1"><NoteQuarter style={{width:"100%"}}/></span>
      <span className="doodle f2"><NoteEighth style={{width:"100%"}}/></span>
      <div className="reveal final-inner">
        <Kicker>{t.finalKicker}</Kicker>
        <h2 className="display final-title">{t.finalTitle[0]}<br/>{t.finalTitle[1]}</h2>
        <div className="final-cta"><AppStoreButton t={t} placement="final-cta"/></div>
      </div>
    </section>

    {/* FOOTER */}
    <footer className="footer">
      <div className="footer-bg rk-staff-bg rk-staff-bg--light"></div>
      <img className="foot-logo" src="/assets/ritmik-logo-on-dark.svg" alt="Ritmik"/>
      <div className="foot-line"></div>
      <div className="foot-row">
        <p className="foot-tag">{t.footTag}</p>
        <div className="foot-links">
          <a href="#appstore">{t.navCta}</a>
          <a href="https://ritmik.net" target="_blank" rel="noopener">ritmik.net</a>
          <a href="#features">{t.navFeatures}</a>
          <a href={localeHome(lang) + 'about.html'}>{t.navAbout}</a>
          <a href={localeHome(lang) + 'contact.html'}>{t.navContact}</a>
        </div>
      </div>
      <p className="foot-copy">© 2026 Ritmik</p>
    </footer>
  </React.Fragment>);
}

ReactDOM.createRoot(document.getElementById("root")).render(<App/>);
