:root {
    --main-bg-color: #1e272e;
    --main-font-color: #e0e6eb;
    --main-border-color: #555c61;
    --main-font-size: 2rem;
    --main-font-size-mobile: 1.6rem;
    --search-box-border-radius: 0.9rem; /* radius */
    --search-box-border-radius-mobile: 0.7rem; /* */
    font-size: 10px;
}

@layer initial-style, populated-style;

@layer initial-style {

    /* || General Styles */
    html {
        box-sizing: border-box;
    }

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

    body {
        background-color: var(--main-bg-color);
        min-height: 100svh;
        margin: 0;
        padding: 0;
    }

    .primary-header {
        width: 100%;
        max-width: 45.5rem;
        padding: var(--main-font-size);
    }

    .search-box {
        height: 6.2rem;
        width: 100%;
        max-width: 43.5rem;
        margin-top: 1rem;
    }

    .search-box input[type="text"] {
        min-width: 0;
        padding-left: var(--main-font-size);
        border-right: 1px solid var(--main-border-color);
        border-radius: var(--search-box-border-radius) 0 0 var(--search-box-border-radius);
    }

    .search-btn {
        width: 8rem;
        border-radius: 0 var(--search-box-border-radius) var(--search-box-border-radius) 0;
        border-left: none;
    }

    .search-box button, .search-box input[type="text"] {
        background-color: inherit;
        border: 1px solid var(--main-border-color);
        outline: 0 none;
    }

    .search-box button:focus, .search-box input[type="text"]:focus {
        border: 1px solid var(--main-font-color);
    }

    main {
        margin-top: 3rem;
    }

    h1, h2 {
        margin: 0;
    }

    ul {
        list-style: none;
        padding: 0;
        margin: 0;
    }

    .error {
        width: 100%;
        background-color: var(--main-bg-color);
        padding-left: 3rem;
    }

    a:hover {
        text-decoration: none;
    }

    .home-link:hover {
        cursor: pointer;
    }

    /* || Typography */
    body {
        font-family: "Inter", Arial, Helvetica, sans-serif;
        font-weight: 400;
        font-style: normal;
        font-size: 1.6rem;
        line-height: 1.5;
        color: var(--main-font-color);
    }

    h1, h2, .logo, a {
        font-family: "Roboto", Arial, Helvetica, sans-serif;
        font-weight: 400;
        font-style: normal;
        margin: 0;
    }

    .logo {
        font-size: 3.2rem;
    }

    h1.logo {
        text-align: center;
    }

    .search-box input[type="text"] {
        color: inherit;
        font-size: inherit;
    }

    h1 {
        line-height: 1.3;
    }

    ul, p {
        font-size: var(--main-font-size);
    }

    .profile-img {
        width: 39rem;
        border-radius: 50%;
    }

    a {
        color: var(--main-font-color);
    }

    /* || Layout */
    /* Body */
    body {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* .primary-header */
    .primary-header {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 1rem;
        position: relative;
    }

    /* Searchbox */
    .search-box {
        display: flex;
        position: relative;
    }

    .search-box input[type="text"] {
        flex: 1;
    }

    .error {
        display: block;
        position: absolute;
        bottom: -3rem;
        left: 0;
    }

    /* || Pre-loader styles */
    .cssload-container{
        position:absolute;
        top: 50%;
    }

    .cssload-whirlpool,
    .cssload-whirlpool::before,
    .cssload-whirlpool::after {
        position: absolute;
        top: 50%;
        left: 50%;
        border: 1px solid rgb(81,105,123);
        border-left-color: rgb(224,230,235);
        border-radius: 749px;
            -o-border-radius: 749px;
            -ms-border-radius: 749px;
            -webkit-border-radius: 749px;
            -moz-border-radius: 749px;
    }

    .cssload-whirlpool {
        margin: -19px 0 0 -19px;
        height: 37px;
        width: 37px;
        animation: cssload-rotate 1150ms linear infinite;
            -o-animation: cssload-rotate 1150ms linear infinite;
            -ms-animation: cssload-rotate 1150ms linear infinite;
            -webkit-animation: cssload-rotate 1150ms linear infinite;
            -moz-animation: cssload-rotate 1150ms linear infinite;
    }

    .cssload-whirlpool::before {
        content: "";
        margin: -17px 0 0 -17px;
        height: 33px;
        width: 33px;
        animation: cssload-rotate 1150ms linear infinite;
            -o-animation: cssload-rotate 1150ms linear infinite;
            -ms-animation: cssload-rotate 1150ms linear infinite;
            -webkit-animation: cssload-rotate 1150ms linear infinite;
            -moz-animation: cssload-rotate 1150ms linear infinite;
    }

    .cssload-whirlpool::after {
        content: "";
        margin: -22px 0 0 -22px;
        height: 42px;
        width: 42px;
        animation: cssload-rotate 2300ms linear infinite;
            -o-animation: cssload-rotate 2300ms linear infinite;
            -ms-animation: cssload-rotate 2300ms linear infinite;
            -webkit-animation: cssload-rotate 2300ms linear infinite;
            -moz-animation: cssload-rotate 2300ms linear infinite;
    }

    @keyframes cssload-rotate {
        100% {
            transform: rotate(360deg);
        }
    }

    @-o-keyframes cssload-rotate {
        100% {
            -o-transform: rotate(360deg);
        }
    }

    @-ms-keyframes cssload-rotate {
        100% {
            -ms-transform: rotate(360deg);
        }
    }

    @-webkit-keyframes cssload-rotate {
        100% {
            -webkit-transform: rotate(360deg);
        }
    }

    @-moz-keyframes cssload-rotate {
        100% {
            -moz-transform: rotate(360deg);
        }
    }
}

@layer populated-style {
    /* || General Styles */
    .populated .primary-header {
        padding: 2rem 6rem;
        max-width: 100%;
        margin: 0;
        background-color: inherit;
    }

    .populated main {
        width: 100%;
        max-width: 109rem;
        margin-top: 15rem;
        padding: 0 var(--main-font-size) 10rem var(--main-font-size);
    }

    .populated .search-box {
        margin: 0;
    }

    .populated h1 {
        border-bottom: 1px solid var(--main-border-color);
    }

    .additional-info li {
        margin: 0.7rem 0;
    }

    .bio, .profile-link {
        margin: 1rem 0;
    }

    .data-icon {
        width: var(--main-font-size);
        height: var(--main-font-size);
    }

    .star-icon {
        width: 1.5rem;
        height: 1.5rem;
        position: relative;
        top: -1px;
    }

    .repos h2 {
        margin-top: 5rem;
        margin-bottom: 1rem;
    }

    .repo {
        border: 1px solid var(--main-border-color);
        border-radius: 0.5rem;
        padding: 1.5rem;
    }

    .repo > * {
        margin: 0;
        margin-bottom: 0.3rem;
    }

    .repo .data-flex {
        margin: 0;
        margin-top: 0.5rem;
    }

    /* || Typography */
    .populated h1 {
        font-size: 4.4rem;
    }

    .repo p {
        font-size: 1.5rem;
    }

    .repo a {
        font-size: var(--main-font-size);
    }

    .prog-lang {
        color: #b2c1cd;
    }

    .populated .primary-header.with-error {
        padding-bottom: 3.5rem;
    }

    /* || Layout */
    .populated {
        display: flex;
        align-items: start;
        justify-content: center;
    }

    .populated .primary-header {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        position: fixed;
        top: 0;
        z-index: 1;
        gap: 5rem;
    }

    .populated .primary-header > * {
        flex: 1;
    }

    .populated .logo {
        order: 1;
    }

    .populated .search-box {
        order: 2;
        flex: 1 43.5rem;
    }

    .populated .primary-header .img-logo {
        order: 3;
        display: flex;
        justify-content: flex-end;
    }

    .populated .profile-header {
        display: flex;
        flex-flow: row wrap;
        justify-content: center;
        align-items: start;
        gap: 5rem;
    }

    .profile-info {
        flex: 1;
    }

    .profile-stats {
        display: flex;
        align-items: start;
        justify-content: start;
        gap: 6rem;
    }

    .data-flex {
        display: flex;
        align-items: center;
        gap: 0.8rem;
    }

    .repos ul {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(30rem, 1fr));
        grid-auto-rows: minmax(13rem, auto);
        gap: var(--main-font-size);
    }

    .repo-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 1rem;
    }

    /* || Responsive */
    @media screen and (max-width: 1055px) {
        /* || Layout */
        .populated .logo {
            display: none;
        }

        .populated .primary-header .img-logo {
            order: 1;
            justify-content: flex-start;
        }

        /* added an invisible content in the primary header so that the search bar will stay on the center */
        .populated .primary-header::after {
            content: '';
            flex: 1;
            order: 3;
        }
    }
    
    @media screen and (max-width: 817px) {
        /* || General Styles */
        .repos h2 {
            margin-top: 2rem;
        }

        .populated .search-box {
            max-width: revert;
        }

        /* || Layout */
        .populated .primary-header::after {
            display: none; /* remove the invisible content to avoid cramped layout on the logo and search bar */
        }

        .populated .primary-header > * {
            flex: revert;
        }
    }

    @media screen and (max-width: 768px) {
        /* || General Styles */
        .populated .primary-header {
            padding: 2rem 3rem;
        }
    }
    
    @media screen and (max-width: 480px) {
        /* || General Styles */
        .populated main {
            padding: 0 var(--main-font-size-mobile) 5rem var(--main-font-size-mobile);
            margin-top: 13rem;
        }

        .populated .primary-header {
            padding: 2rem var(--main-font-size-mobile);
        }

        .populated .img-logo img {
            width: 3.5rem;
        }

        .data-icon {
            width: var(--main-font-size-mobile);
            height: var(--main-font-size-mobile);
        }

        .profile-img {
            width: 25rem;
        }

        .populated .search-box {
            height: 5rem;
        }

        .populated .search-btn {
            width: 6rem;
            border-radius: 0 var(--search-box-border-radius-mobile) var(--search-box-border-radius-mobile) 0;
        }

        .populated .search-btn img {
            width: 1.6rem;
        }

        .populated .search-box input[type="text"] {
            width: 100%;
            padding-left: var(--main-font-size-mobile);
            border-radius: var(--search-box-border-radius-mobile) 0 0 var(--search-box-border-radius-mobile);
        }

        /*|| Typography */
        .populated h1 {
            font-size: 3.2rem;
        }

        .populated h2 {
            font-size: 2rem;
        }

        p, ul {
            font-size: var(--main-font-size-mobile);
        }

        .repo a {
            font-size: var(--main-font-size-mobile);
        }

        .repo p {
            font-size: 1.4rem;
        }

        /* || Layout */
        .profile-header {
            flex-direction: column;
        }

        .profile-stats {
            gap: 2rem;
        }

        .populated .primary-header {
            gap: 3rem;
        }

        .repos ul {
            grid-template-columns: 1fr;
            grid-auto-rows: minmax(12rem, auto);
        }

        .repo .data-flex {
            margin-top: 0.1rem;
        }
    }
}