<script>
/*
*as soon as you scroll content becomes blurry
*slow
*hover over links : chimmering sound
*/


    ];
    
    function playHoverSound(idx) {
        const hoverSound = new Audio(sounds[idx]);
    }
    
    /* get all the links i the document, iterate ovet them and add a random sound */
    const links = document.querySelectorAll('a');    
    links.forEach((link, i) => {
        console.log(link, i);
         link.addEventListener('mouseover', () => playHoverSound(r));    
    });    
    
    /* get all the elements on the page. Add a flower to one in ten of the elements */
    const elems = document.querySelectorAll('*');    
    elems.forEach((el, i) => {
        console.log(el, i);
         el.classList.add("has-flower");
         el.classList.add("has-flower-" + Math.floor(Math.random()*sounds.length));
         }
    });    
const checkScrollSpeed = (() => {
  let lastPos = window.scrollY;
  const deltas = [];
  const maxDeltas = 5; // Number of measurements to average

  return () => {
    const newPos = window.scrollY;
    const delta = newPos - lastPos;
    lastPos = newPos;

    // Add the new delta to the list
    deltas.push(Math.abs(delta));

    // Ensure we only keep the last 'maxDeltas' measurements
    if (deltas.length > maxDeltas) {
      deltas.shift();
    }

    // Calculate the average of the deltas
    const sum = deltas.reduce((acc, val) => acc + val, 0);
    const average = sum / deltas.length;

    return average;
  };
})();

let lastBlur = 0;

// Listen to the "scroll" event, get the average pixels scrolled and use the value for the blur. So faster scrolling is more blur
window.addEventListener('scroll', () => {

  let speed = checkScrollSpeed();
  
  if (speed > lastBlur) lastBlur = speed;
  console.log(speed, lastBlur);
 
  document.body.style.filter = "blur(" + (lastBlur) + "px)";
});

s = setInterval(()=>{    
    let n = parseFloat(document.body.style.filter.match("[0-9]+\.[0-9]?")); 
    document.body.style.filter = "blur(" + (n * .95) + "px)"; 
    lastBlur *= .9;
//        console.log(n, lastBlur); 
    }, 200)

</script>

<style>


body {
       }
       
img, video {
    box-shadow: 10px 10px 5px 30px lightblue;
    filter: sepia(60%);
    border-radius: 250px;
    }
p {
      box-shadow: 10px 10px 5px 30px pink;
       border-radius: 250px;
       background : pink;
    }  
 h1 {
       box-shadow: 10px 10px 5px 30px #9bf99c;
       border-radius: 250px;
       background : #9bf99c;
     }     
    

   
body > *:not(.has-flower) {
/*    filter: blur(15px); */
 }
 
 
img, video {
    animation: spin 50s linear infinite;
}
@keyframes spin {  
}

.has-flower .has-flower:after {
}


.has-flower:after {
    filter: none !important;
  background: transparent url("https://shelf.hackersanddesigners.nl/apps/files_sharing/publicpreview/CBENCGS8nbp38TA?file=/fabulations/files/yTkrKEeGc.png&fileId=16939&x=3600&y=2338&a=true&etag=fa7ee2b871bce9927b5e7833138851c6") no-repeat;
  width: 20px;
  height: 20px;
  position: absolute;
  content: "";
  display: inline-block;
  float: left;
  background-size: cover;
}


.has-flower-1:after {
  background: transparent url("https://shelf.hackersanddesigners.nl/apps/files_sharing/publicpreview/CBENCGS8nbp38TA?file=/fabulations/files/flower-purple-on-white.png&fileId=16940&x=3600&y=2338&a=true&etag=93e6c6e46c141a95ac4623a1e7574db5") no-repeat;
  
  width: 20px;
  height: 20px;
  position: absolute;
  content: "";
  display: inline-block;
  float: left;
  background-size: cover;
}

.has-flower-2:after {
  background: transparent url("https://shelf.hackersanddesigners.nl/apps/files_sharing/publicpreview/CBENCGS8nbp38TA?file=/fabulations/files/kT85oeyxc.png&fileId=16954&x=3600&y=2338&a=true&etag=97f33f479ba5a6cae9ea85ac5b2b6464") no-repeat;
  width: 35px;
  height: 35px;
  position: absolute;
  content: "";
  display: inline-block;
  float: left;
  background-size: cover;
}


.has-flower-3:after {
  background: transparent url("https://shelf.hackersanddesigners.nl/apps/files_sharing/publicpreview/CBENCGS8nbp38TA?file=/fabulations/files/XyikankcE.png&fileId=16938&x=3600&y=2337&a=true&etag=4a6c5a2e313d86a71ee4047289c27e17") no-repeat;
  width: 40px;
  height: 40px;
  position: absolute;
  content: "";
  display: inline-block;
  float: left;
  background-size: cover;
}

/*
body *:after {
    filter: none !important;
  background: transparent url("https://shelf.hackersanddesigners.nl/apps/files_sharing/publicpreview/CBENCGS8nbp38TA?file=/fabulations/files/yTkrKEeGc.png&fileId=16939&x=3600&y=2338&a=true&etag=fa7ee2b871bce9927b5e7833138851c6") no-repeat;
  width: 20px;
  height: 20px;
  position: absolute;
  content: "";
  display: inline-block;
  float: left;
  background-size: cover;
}

body *:nth-child(2n):after {
  background: transparent url("https://shelf.hackersanddesigners.nl/apps/files_sharing/publicpreview/CBENCGS8nbp38TA?file=/fabulations/files/flower-purple-on-white.png&fileId=16940&x=3600&y=2338&a=true&etag=93e6c6e46c141a95ac4623a1e7574db5") no-repeat;
  width: 22px;
  height: 22px;
  position: absolute;
  content: "";
  display: inline-block;
  float: left;
  background-size: cover;
}

body *:nth-child(3n):after {
  background: transparent url("https://shelf.hackersanddesigners.nl/apps/files_sharing/publicpreview/CBENCGS8nbp38TA?file=/fabulations/files/kT85oeyxc.png&fileId=16954&x=3600&y=2338&a=true&etag=97f33f479ba5a6cae9ea85ac5b2b6464") no-repeat;
  width: 35px;
  height: 35px;
  position: absolute;
  content: "";
  display: inline-block;
  float: left;
  background-size: cover;
}



body *:nth-child(4n):after {
  background: transparent url("https://shelf.hackersanddesigners.nl/apps/files_sharing/publicpreview/CBENCGS8nbp38TA?file=/fabulations/files/XyikankcE.png&fileId=16938&x=3600&y=2337&a=true&etag=4a6c5a2e313d86a71ee4047289c27e17") no-repeat;
  width: 40px;
  height: 40px;
  position: absolute;
  content: "";
  display: inline-block;
  float: left;
  background-size: cover;
}
*/

</style>