html{
    box-sizing: border-box;
    font-family: Inter, sans-serif;
    font-weight: 400;
    font-size: 14px;
}

*, *::before, *::after{
    box-sizing: inherit;
    padding: 0;
    margin: 0;
}

:root{
    /* Primary colours */
    --lime-green: hsl(163, 72%, 41%);
    --bright-red: hsl(356, 69%, 56%);
    --facebook: hsl(208, 92%, 53%);
    --twitter: hsl(203, 89%, 53%);
    --instagram: linear-gradient(to right, hsl(37, 97%, 70%), hsl(329, 70%, 58%));
    --youtube:  hsl(348, 97%, 39%);

    /* Toggle */
    --toggle-bg-left: hsl(230, 22%, 74%);
    --toggle-bg-right: hsl(230, 22%, 74%);
    --toggle: white;

    --bg-color: hsl(0, 0%, 100%);
    --top-bg-color: hsl(225, 100%, 98%);
    --card-bg-color:  hsl(227, 47%, 96%);
    --text-color: hsl(228, 12%, 44%); 
    --headings-color: hsl(230, 17%, 14%);
}

[data-theme='dark']{
    --toggle-bg-left: linear-gradient(to right,  hsl(210, 78%, 56%), hsl(180, 51%, 47%));
    --toggle-bg-right: linear-gradient(to right,  hsl(180, 51%, 47%), hsl(146, 68%, 55%));
    --toggle: hsl(230, 17%, 14%);
    --bg-color:  hsl(230, 17%, 14%);
    --top-bg-color:hsl(232, 19%, 15%);
    --card-bg-color:   hsl(228, 28%, 20%);
    --text-color: hsl(228, 34%, 66%); 
    --headings-color: hsl(0, 0%, 100%);
}

body{
    background-color: var(--bg-color);
}

.top-BG{
    background-color: var(--top-bg-color);
    width: 100%;
    height: 240px;
    position: absolute;
    top: 0;
    z-index: -1;
    border-radius: 0 0 20px 20px;
}

.wrapper{
    margin: 0 auto;
    max-width: 1200px;
}

.container{
    max-width: 1200px;
    margin: 2.5rem 5rem;
}

.card-heading-section{
    font-weight: 700;
    display: flex;
    align-items: center;
}

.app-info > h1{
    font-size: 1.9em;
    color: var(--headings-color);
}

.app-info > span{
    color: var(--text-color);
}

.toggle-container{
    display: flex;
    align-items: center;
    width: max-content;
    margin-left: auto;
}

.toggle-label{
    color: var(--text-color);
}

.toggle-area{
    margin-left: calc(1rem);
    width: 4rem;
    height: 2rem;
    position: relative;
    display: flex;
    align-items: center;
    cursor: pointer;
}

.toggle-left{
    position: absolute;
    z-index: -1;
    width: 2rem;
    height: 2rem;
    background: var(--toggle-bg-left);
    border-radius: 50% 0 0 50%;
}

.toggle-right{
    z-index: -1;
    position: absolute;
    width: 2rem;
    height: 2rem;
    background: var(--toggle-bg-right);
    border-radius: 0 50% 50% 0;
    transform: translateX(2rem);
}

.toggle{
    border-radius: 50%;
    width: 1.5rem;
    height: 1.5rem;
    background-color: var(--toggle);
    transform: translateX(2.2rem);
    transition: transform 100ms linear;
}

.social-media{
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    margin: 0 5rem;
    gap: 20px;
}

.large-card{
    border-radius: 5px;
    display: flex;
    flex-flow: column nowrap;
    align-items: center;
    justify-content: center;
    width: 250px;
    height: 250px;
    flex: 0 0 auto;
    background-color: var(--card-bg-color);
}

.social-info{
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
    font-weight: 700;
}

.user-handle{
    color: var(--text-color);
}

.follower-count{
    grid-column: 2/6;
    grid-row-start: 4;
    font-weight: 700;
    font-size:4.3em;
    color: var(--headings-color);
}

.follower-text{
    text-transform: uppercase;
    letter-spacing: 5px;
    color: var(--text-color);
}

.large-card > :last-child{
    margin-top: 20px;
}

.daily-change{
    font-weight: 700;
    display: flex;
    gap: 3px;
    align-items: center;
}

.facebook{
    border-top: 4px solid var(--facebook);
}

.twitter{
    border-top: 4px solid var(--twitter);
}

.instagram{
    border-top: 4px solid transparent;
    background-clip: padding-box;
    position: relative;
}

/* We need a pseudo element to achieve gradient border since 
   a border colour cannot be set to a gradient */
.instagram::before{
    content: '';
    background-image: var(--instagram);
    position: absolute;
    border-radius: 5px;
    width: 250px;
    height: 250px;
    top: -4px;
    z-index: -1;
}

.youtube{
    border-top: 4px solid var(--youtube);
}

.green-text{
    color: var(--lime-green);

}

.red-text{
    color: var(--bright-red);
}

.overview-text{
    margin: 4rem 5rem 2rem;
    display: block;
    font-size: 1.8em;
    font-weight: 700;
    color: var(--text-color);
}

.overview-section{
    display: grid;
    grid-template-columns: repeat(auto-fit, 250px);
    justify-content: space-between;
    gap: 20px;
}

.overview-card{
    width: 250px;
    height: 125px;
    background-color: var(--card-bg-color);
    border-radius: 5px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 20px;
}

.overview-card-heading{
    font-weight: 700;
    color: var(--text-color);
}

.overview-card-icon{
    justify-self: end;
}

.overview-card-count{
    font-weight: 700;
    font-size: 2rem;
    align-self: end;
    color: var(--headings-color);
}

.overview-card-current{
    justify-self: end;
    align-self: end;
}

.toggle-dark{
    transform: translateX(0.2rem);
}

.attribution{ 
    font-size: small; 
    display: flex;
    width: 100%;
    justify-content: center;
    margin: 8px 0;
    color: var(--text-color);
}

.attribution > *{
    margin: 0 4px 0;
    color: var(--headings-color);
}

@media only screen and (max-width: 640px){

    .container{
        margin: 2.5rem 2rem;
    }

    .card-heading-section{
        flex-wrap: wrap;
    } 

    .toggle-container{
        justify-content: space-between;
        width: 100%;
        border-top: 1px solid;
        padding-top: 1rem;
        margin-top: 1rem;
        margin-left: 0;
        transform: translateX(0);
    }

    .toggle-area{
        transform: translateX(-1rem);
    }

    .large-card{
        width: 100%;
    }

    .instagram::before{
        width: 100%;
    }

    .overview-text{
        margin: 4rem 2rem 2rem;
    }

    .overview-section{
        grid-template-columns: 1fr;
    }

    .overview-card{
        width: 100%;
    }
}