import React from 'react';
import { styled, keyframes } from '@mui/system';

const drop = keyframes`
  0% {
    top: -50%;
  }
  100% {
    top: 110%;
  }
`;

const LinesWrapper = styled('div')`
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  margin: auto;
  width: 90vw;
`;

const Line = styled('div')`
  position: absolute;
  width: 1px;
  height: 100%;
  top: 0;
  left: 50%;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;

  &::after {
    content: '';
    display: block;
    position: absolute;
    height: 15vh;
    width: 100%;
    top: -50%;
    left: 0;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0%, #ffffff 75%, #ffffff 100%);
    animation: ${drop} 7s 0s infinite;
    animation-fill-mode: forwards;
    animation-timing-function: cubic-bezier(0.4, 0.26, 0, 0.97);
  }

  &:nth-of-type(1) {
    margin-left: -25%;
    &::after {
      animation-delay: 2s;
    }
  }

  &:nth-of-type(3) {
    margin-left: 25%;
    &::after {
      animation-delay: 2.5s;
    }
  }
`;

const LinesBackground = ({ children }) => {
  return (
    <div style={{ height: '100%', width: '100%', backgroundColor: '#171717', position: 'relative', overflow: 'hidden' }}>
      <LinesWrapper>
        <Line />
        <Line />
        <Line />
      </LinesWrapper>
      {children}
    </div>
  );
};

export default LinesBackground;
