import React from "react";
import Link from "next/link";
import styled from "styled-components";
import { Flex } from "reflexbox/styled-components";

import Text from "../components/Text";
import { Button } from "./Button";
import { fadeIn } from "../helpers/animations";
import { Col } from "./Layout";
import { SiteTheme } from "../consts/site-theme";

const Wrapper = styled(Flex).attrs({
  width: 1200,
  maxWidth: "98%",
  alignItems: "center",
  //margin: "150px 0 0",
  flexDirection: ["column", "column", "row"]
})`
  animation: ${fadeIn} 0.8s ease-out;
  box-sizing: border-box;
  margin: auto;
  padding: 0 10px;
  a {
    text-decoration: none;
  }
`;

const MainWrap = styled.div`
    width: 100%;
`;

const H1 = styled.h1`
    position: relative;
    text-align: center;
    margin: 100px 0;
    font-size: 3em;
    font-family: 'Montserrat';
    font-weight: 700;

    span {
        display: inline-block;
        position: relative;
        text-shadow: 0px 1px 0 hsl(206, 12%, 95%);

        &:after {
            content: "The Sanger Unified Link Shortener";
            position: absolute;
            top: 5px;
            left: 0;
            z-index: -1;
            text-shadow: none;
            background-image:
              linear-gradient(
                45deg,
                transparent 45%,
                #333 45%,
                #333 55%,
                transparent 0
                );
            background-size: .05em .05em;
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;

            animation: shad-anim 125s linear infinite;
        }
    }

    @media only screen and (max-width: 488px) {
        font-size: 2em;

        span {
            &:after {
                top: 3px;
            }
        }
    }

    @keyframes shad-anim {
      0% {background-position: 0 0}
      0% {background-position: 100% -100%}
    }
`;

const Title = styled.h2`
  font-size: 28px;
  font-weight: 300;
  padding-right: 32px;
  margin-bottom: 48px;

  @media only screen and (max-width: 768px) {
    font-size: 22px;
    text-align: center;
    padding-right: 0;
    margin-bottom: 32px;
    padding: 0 40px;
  }

  @media only screen and (max-width: 448px) {
    font-size: 18px;
    text-align: center;
    margin-bottom: 24px;
  }
`;

const Image = styled.img`
  flex: 0 0 60%;
  width: 60%;
  max-width: 100%;
  height: auto;

  @media only screen and (max-width: 768px) {
    flex-basis: 100%;
    width: 100%;
  }
`;

const SusdLogo = styled.img`
    display: block;
    margin: auto;
    margin-bottom: 15px;
    width: 120px;
    max-width: 100%;

    @media only screen and (max-width: 488px) {
      width: 70px;
      margin-bottom: 5px;
    }
`;

const NeedToLogin = () => (
  <MainWrap>
    <H1>
      <SusdLogo src={`${SiteTheme.SusdLogo}`}/>
      <span>The Sanger Unified Link Shortener</span>
    </H1>
    <Wrapper>
      <Col
        alignItems={["center", "center", "flex-start"]}
        mt={-32}
        mb={[32, 32, 0]}
      >
        <Title>
          Shorten links, set custom <b>address</b> and view <b>stats</b>.
        </Title>
        <Link href="/login">
          <a href="/login" title="login / signup">
              <Button>Login / Signup</Button>
          </a>
        </Link>
      </Col>
      <Image src="/images/callout.png" />
    </Wrapper>
  </MainWrap>
);

export default NeedToLogin;
