<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-9535429916301932" crossorigin="anonymous"></script>
  <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-T6FTQFPX');</script>
  <script async src='https://www.googletagmanager.com/gtag/js?id=G-4E84KVTKMW'></script>
  <script> window.dataLayer = window.dataLayer || [];  function gtag(){dataLayer.push(arguments);}  gtag('js', new Date()); gtag('config', 'G-4E84KVTKMW');</script>
  <title>SemSinal</title>
  <style>
    html, body {
      margin: 0;
      padding: 0;
      background: black;
      overflow: hidden;
      width: 100vw;
      height: 100vh;
    }
    .container {
      width: 100vw;
      height: 100vh;
      display: flex;
      gap: 4px;
    }
    .column {
      flex: 1;
      display: flex;
      flex-direction: column;
      gap: 4px;
    }
    .wrapper {
      position: relative;
      width: 100%;
      height: 100%;
      overflow: hidden;
      flex-shrink: 0;
    }
    .wrapper a {
      position: absolute;
      width: 100%;
      height: 100%;
      display: block;
      top: 0;
      left: 0;
    }
    .wrapper img {
      width: 100%;
      height: 100%;
      object-fit: cover;
      position: absolute;
      top: 0;
      left: 0;
      transition: opacity 2s ease-in-out;
    }
  </style>
</head>
<body>
  <div class="container" id="container"></div>

<script>
  const images = ["agrobio.semsinal.com_14062025213941_1-300x180.jpg","agrobio.semsinal.com_2_20250614_102249.jpg","criptomoedas.semsinal.com_2.jpg","600+Sojourn+6.jpg","thinking-woman-glasses-looking-light-260nw-333005096.jpg","criptomoedas.semsinal.com_14062025213930_1-300x180.jpg","criptomoedas.semsinal.com_2-1.jpg","criptomoedas.semsinal.com_1-150x150.jpg","agrobio.semsinal.com_1-300x180_20250614_102249.jpg","criptomoedas.semsinal.com_2-300x180.jpg","criptomoedas.semsinal.com_1.jpg","criptomoedas.semsinal.com_1-150x150_20250614_102248.jpg","criptomoedas.semsinal.com_1-300x180.jpg","criptomoedas.semsinal.com_1_20250613_234636.jpg","agrobio.semsinal.com_2.jpg","criptomoedas.semsinal.com_1-1-300x180_20250614_102248.jpg","agrobio.semsinal.com_14062025213941_2-150x150.jpg","agrobio.semsinal.com_14062025213941_1-150x150.jpg","criptomoedas.semsinal.com_2-150x150_20250614_102248.jpg","criptomoedas.semsinal.com_2-1-300x180.jpg","criptomoedas.semsinal.com_2-1-300x180_20250614_102249.jpg","criptomoedas.semsinal.com_mulhers.jpeg","agrobio.semsinal.com_1_20250614_102249.jpg","criptomoedas.semsinal.com_2-300x180_20250613_234636.jpg","criptomoedas.semsinal.com_1-1-150x150_20250614_102249.jpg","agrobio.semsinal.com_2-300x180_20250614_102249.jpg","criptomoedas.semsinal.com_1-1_20250614_102249.jpg","criptomoedas.semsinal.com_14062025213930_1-150x150.jpg","criptomoedas.semsinal.com_2-1-150x150.jpg","agrobio.semsinal.com_1.jpg","criptomoedas.semsinal.com_ee.jpeg","criptomoedas.semsinal.com_1_20250614_102248.jpg","criptomoedas.semsinal.com_1-1.jpg","agrobio.semsinal.com_14062025213941_2.jpg","criptomoedas.semsinal.com_2-1-150x150_20250614_102249.jpg","criptomoedas.semsinal.com_3.jpg","agrobio.semsinal.com_2-150x150.jpg","criptomoedas.semsinal.com_14062025213930_1.jpg","agrobio.semsinal.com_1-300x180.jpg","criptomoedas.semsinal.com_1-300x180_20250613_234636.jpg","agrobio.semsinal.com_14062025213941_1.jpg","criptomoedas.semsinal.com_1-150x150_20250613_234636.jpg","criptomoedas.semsinal.com_14062025213930_2.jpg","criptomoedas.semsinal.com_2-300x180_20250614_102248.jpg","agrobio.semsinal.com_1-150x150_20250614_102249.jpg","criptomoedas.semsinal.com_14062025213930_2-150x150.jpg","criptomoedas.semsinal.com_2-150x150.jpg","criptomoedas.semsinal.com_1-1-150x150.jpg","criptomoedas.semsinal.com_2-150x150_20250613_234636.jpg","thinking-woman-question-mark-on-260nw-310072547.jpg","setores-de-cripto.jpg","agrobio.semsinal.com_1-150x150.jpg","agrobio.semsinal.com_14062025213941_2-300x180.jpg","criptomoedas.semsinal.com_2_20250613_234636.jpg","criptomoedas.semsinal.com_2_20250614_102248.jpg","criptomoedas.semsinal.com_1-300x180_20250614_102248.jpg","criptomoedas.semsinal.com_1-1-300x180.jpg","criptomoedas.semsinal.com_14062025213930_2-300x180.jpg","agrobio.semsinal.com_2-150x150_20250614_102249.jpg","agrobio.semsinal.com_2-300x180.jpg","criptomoedas.semsinal.com_dde.webp","criptomoedas.semsinal.com_2-1_20250614_102249.jpg"];
  const container = document.getElementById('container');
  const columnsCount = 5;
  const rectsPerColumn = 3;
  const fadeRate = 2;
  const fadeDuration = 2000;

  const heightRatios = [
    [0.35, 0.35, 0.3],
    [0.4, 0.3, 0.3],
    [0.3, 0.4, 0.3],
    [0.3, 0.35, 0.35],
    [0.33, 0.33, 0.34]
  ];

  let currentImages = [];

  function getDomainFromFilename(filename) {
    const base = filename.replace(/\.(jpe?g|png|gif|webp)$/i, '');
    return base.split('_')[0];  // take only the part before the underscore
  }


  function getRandomImage(exclude) {
    if (images.length <= exclude.length) return null;
    let img;
    do {
      img = images[Math.floor(Math.random() * images.length)];
    } while (exclude.includes(img));
    return img;
  }

  function createImageLinkElement(file) {
    const domain = getDomainFromFilename(file);
    const link = document.createElement('a');
    link.href = `https://${domain}`;
    link.target = "_blank";

    const img = document.createElement('img');
    img.src = `images/${file}`;
    img.style.opacity = 1;

    link.appendChild(img);
    return { link, img };
  }

  function setup() {
    const used = [];
    for (let c = 0; c < columnsCount; c++) {
      const col = document.createElement('div');
      col.classList.add('column');
      container.appendChild(col);

      for (let r = 0; r < rectsPerColumn; r++) {
        const file = getRandomImage(used);
        if (!file) break;
        used.push(file);

        const wrapper = document.createElement('div');
        wrapper.classList.add('wrapper');
        wrapper.style.flex = heightRatios[c][r];

        const { link, img } = createImageLinkElement(file);
        wrapper.appendChild(link);
        col.appendChild(wrapper);

        currentImages.push({ file, wrapper });
      }
    }
  }

  function replaceOneImage() {
    if (currentImages.length === 0) return;

    const index = Math.floor(Math.random() * currentImages.length);
    const old = currentImages[index];
    const newFile = getRandomImage(currentImages.map(i => i.file));
    if (!newFile) return;

    const domain = getDomainFromFilename(newFile);
    const newLink = document.createElement('a');
    newLink.href = `https://${domain}`;
    newLink.target = "_blank";

    const newImg = document.createElement('img');
    newImg.src = `images/${newFile}`;
    newImg.style.opacity = 0;
    newImg.style.transition = `opacity ${fadeDuration}ms ease-in-out`;

    newLink.appendChild(newImg);
    old.wrapper.appendChild(newLink);

    const oldLink = old.wrapper.querySelector('a');
    const oldImg = oldLink?.querySelector('img');

    // Trigger fade transition
    setTimeout(() => {
      if (oldImg) {
        oldImg.style.transition = `opacity ${fadeDuration}ms ease-in-out`;
        oldImg.style.opacity = 0;
      }
      newImg.style.opacity = 1;
    }, 50);

    // Remove old image after fade
    setTimeout(() => {
      if (oldLink && old.wrapper.contains(oldLink)) {
        old.wrapper.removeChild(oldLink);
      }
      currentImages[index].file = newFile;
    }, fadeDuration + 100);
  }

  setup();
  setInterval(replaceOneImage, 1000 / fadeRate);
</script>
</body>
</html>

