@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap');

:root {
    --purple-100: hsl(254, 88%, 90%);
    --purple-500: hsl(256, 67%, 59%);

    --yellow-100: hsl(31, 66%, 93%);
    --yellow-500: hsl(39, 100%, 71%);

    --black: hsl(0, 0%, 7%);

    --primary-font: "DM Sans";

    --regular: 400;
    --medium: 500;
    --semi-bold: 600;
}

* {
    margin: 0;
    border: none;
    outline: none;
    box-sizing: border-box;
    font-family: var(--primary-font);
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 3rem 0;
    background-color: #f5f5f5;
}

main {
    display: grid;
    grid-auto-columns: 250px;
    grid-template-rows: 300px 68px 150px 250px;
    grid-template-areas: 
        'g a a d' 
        'g b c d' 
        'h b c d' 
        'h f e e';
    gap: 2rem;
}

.card {
    padding: 24px;
    border-radius: 12px;
    overflow: hidden;
}

.heading.medium {
    font-size: 30px;
    font-weight: var(--semi-bold);
    line-height: 0.9;
    letter-spacing: -1px;
    color: var(--black);
}

.first { /* First Card */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    grid-area: a;
    padding: 3.5rem 2rem;
    text-align: center;
    background-color: var(--purple-500);

    .heading {
        font-size: 3.5rem;
        font-weight: var(--medium);
        font-style: italic;
        line-height: 0.9;
        color: white;
    }

    span {
        color: var(--yellow-500);
    }

    .reviews {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        font-size: 18px;
        font-weight: var(--regular);
        color: var(--purple-100);
    }

    img {
        width: 160px;
        object-fit: contain;
    }
}

.second {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    grid-area: b;
    background-color: white;

    img {
        height: 65px;
        object-fit: contain;
    }
}

.third {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
    grid-area: c;
    padding: 24px 24px 0 24px;
    background-color: var(--yellow-500);

    img {
        width: 100%;
        object-fit: contain;
    }
}

.fourth {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    grid-area: d;
    padding: 3rem 24px;
    background-color: var(--purple-100);

    img {
        height: 320px;
        object-fit: contain;
    }

    .description {
        font-size: 1rem;
        font-weight: var(--medium);
        color: var(--black);
    }
}

.fifth {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    grid-area: e;
    background-color: var(--purple-500);

    img {
        height: 100%;
        object-fit: contain;
    }

    .heading {
        font-size: 38px;
        font-weight: var(--medium);
        line-height: 100%;
        color: white;
    }
}

.sixth {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    grid-area: f;
    background-color: white;

    .growth-rate {
        font-size: 3.5rem;
        font-weight: var(--semi-bold);
        color: var(--black);
    }

    .description {
        margin-top: 6px;
        font-size: 18px;
        font-weight: var(--medium);
        color: hsl(0, 0%, 20%);
    }

    img {
        margin-top: auto;
        height: 60px;
        object-fit: contain;
    }
}

.seventh {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    gap: 20px;
    grid-area: g;
    background-color: var(--yellow-100);

    .heading {
        font-size: 2rem;
    }

    span {
        color: var(--purple-500);
        font-style: italic;
    }

    img {
        width: 100%;
        object-fit: contain;
    }
}

.eighth {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    grid-area: h;
    background-color: var(--yellow-500);

    .heading {
        font-size: 36px;
    }

    img {
        width: min(325px, 100%);
        object-fit: contain;
    }
}

@media (max-width: 1125px) {
    main {
        grid-template-rows: 300px repeat(2, 250px) 300px;
        grid-template-areas: 
            'a a d'
            'b c d'
            'f e e'
            'h h g';
    }
}

@media (max-width: 850px) {
    main {
        grid-template-rows: 300px 250px 300px repeat(2, 250px) 300px;
        grid-template-areas: 
            'a a'
            'b c'
            'd d'
            'e e'
            'f g'
            'h h';
    }

    .fourth {
        align-items: center;
        text-align: center;
        padding: 28px 24px;

        img {
            height: 150px;
        }
    }

    .seventh img {
        width: 140px;
    }
}

@media (max-width: 550px) {
    main {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(8, min-content);
        grid-template-areas: none;
        width: min(375px, 90vw);
    }

    .card {
        grid-area: auto;
    }

    .heading.medium {
        font-size: 28px;
    }

    .first {
        padding: 40px 2rem;

        .heading {
            font-size: 3rem;
        }

        .reviews {
            font-size: 1rem;
        }
    }

    .second img {
        width: 100%;
        height: auto;
    }

    .third img {
        width: 240px;
    }

    .fourth {
        gap: 18px;

        img {
            width: 100%;
            height: auto;
        }
    }

    .fifth {
        flex-direction: column;
        justify-content: flex-start;
        gap: 2rem;
        padding: 24px 40px;
        text-align: center;

        img {
            width: 100%;
            height: auto;
        }

        .heading {
            font-size: 2rem;
        }
    }

    .sixth .growth-rate {
        font-size: 3rem;
    }

    .sixth .description {
        margin: 4px 0 24px 0;
    }

    .eighth img {
        width: 250px;
    }
}