@import url('https://fonts.googleapis.com/css2?family=Lato:wght@300;400;700;900&display=swap');

/* RESETS */
html {
    box-sizing: border-box;
}

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

body {
    font-family: 'Lato', sans-serif;
    color: var(--black);
}

img {
    max-width: 100%;
    height: auto;
    vertical-align: middle;
    font-style: italic;
}

button {
    font-family: inherit;
    color: var(--black);
}

:root {
    --bg-header: #ADDE87;
    --btn-color: #5CA720;
    --bg-hover: #512200;
    --btn-active: #7a3a0d;
    --gray: #A5A1A1;
    --black: #161616;
    --white: #F9F9F9;

    --default-space: 8px;
    --space-x2: 16px;
    --space-x3: 24px;
    --space-x4: 32px;
}

/* Utility Classes */
.flex {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.grid {
    display: grid;
}

/* HEADER */
header {
    min-height: 15svh;
    padding-inline: var(--space-x4);
}

header > img {
    width: clamp(7rem, 25vw + 0.5rem, 10rem);
}

nav {
    min-width: 30%;
    transition: min-width 600ms cubic-bezier(.6,-0.11,.74,.05); 
}

nav img {
    width: clamp(1rem, 3vw + 0.5rem, 1.8rem);
}

nav:has(.search-bar:focus-within) {
    min-width: 60%;
}

.search-bar {
    --_size: clamp(2rem, 8vw + 0.5rem, 3rem);

    width: var(--_size);
    height: var(--_size);
    padding: 3px;
    border: 2px solid var(--bg-header);
    border-radius: 50px;
    overflow: hidden;
    transition: width 600ms cubic-bezier(.6,-0.11,.74,.05);

    position: relative;
}

.search-bar:focus-within {
    width: 100%;

    .search-input {
        opacity: 1;
        width: calc(100% - var(--_size));
    }

    .search-submt {
        background-color: var(--bg-header);
    }
}

.search-input, .suggestions {
    font-size: clamp(1rem, 2vw + 0.5rem, 1.8rem);
    position: absolute;
}

.search-input {
    flex-grow: 1;
    padding: 0 0.5em;
    border: 0;
    line-height: calc(var(--_size) - 3px); /* truque pra centralizar uma única linha de texto. necessário pois no firefox buga o tamanho do input se for só position */
    opacity: 0;
    cursor: pointer;
    transition: opacity 300ms ease-in-out;

    top: 0;
    bottom: 0;
    left: 0;
}

.suggestions {
    max-width: 30%;
    border-radius: 10px;
    background: var(--bg-header);

    top: 10%;
    z-index: 2;
}

li {
    list-style-type: none;
    cursor: pointer;
    padding: 0 0.5em;
}

li:hover {
    background-color: var(--btn-color);
}

.hl {
    color: var(--white);
    background-color: var(--bg-hover);
}

.search-input:focus {
    outline: 0;
    cursor: initial;
}

.search-submt, .cart-icon {
    cursor: pointer;
    border: 0;
    background-color: transparent;
}

.search-submt {
    height: calc(var(--_size) - 10px);
    width: calc(var(--_size) - 10px);
    margin-left: auto;
    border-radius: 50%;
    transition: background 600ms ease-in-out 250ms;
}

.search-submt:active {
    box-shadow: 0 0 5px var(--bg-hover);
}

.cart-icon {
    position: relative;
}

.cart-icon span {
    width: clamp(1rem, 1.8vw + 0.5rem, 1.5rem);
    height: clamp(1rem, 1.8vw + 0.5rem, 1.5rem);
    justify-content: center;
    background-color: var(--btn-color);
    border-radius: 50%;

    position: absolute;
    top: 50%;
    left: 50%;
}


/* HERO SECTION */
.hero {
    min-height: 30svh;
    padding-block: var(--default-space);
    grid-template-rows: repeat(4, 1fr);
    background-color: var(--bg-header);

    position: relative;
}

.hero-img {
    width: clamp(250px, 70vw + 0.5rem, 500px);
    z-index: 1;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.scroller {
    max-width: 100%;
    user-select: none;
}

.scroller[data-animated=true] {
    overflow: hidden;
    -webkit-mask: linear-gradient(
        90deg, transparent, var(--white) 5%,
        var(--white) 95%, transparent);

        mask: linear-gradient(
        90deg, transparent, var(--white) 5%,
        var(--white) 95%, transparent);
    }
    
    .inner-scroller {
        gap: var(--space-x2);
    }
    
    .scroller[data-animated=true] .inner-scroller {
        width: max-content;
        animation: scroll 35s var(--_animation-direction, forwards) linear infinite;
    }
    
    .scroller[data-direction="left"] {
        --_animation-direction: forwards;
    }

    .scroller[data-direction="right"] {
        --_animation-direction: reverse;
    }
    
    .inner-scroller > p {
        font-size: clamp(2rem, 8vw + 0.5rem, 4rem);
        font-weight: 900;
        color: var(--bg-header);
        -webkit-text-stroke: 0.02em rgba(255, 255, 255, 0.2);
    }
    
    @keyframes scroll {
        to {
            transform: translateX(calc(-50% - var(--default-space))); /* metade do gap pra compensar o deslocamento q ele causa */
        }
    }

    /* MAIN */
    .promo {
        flex-wrap: wrap;
        padding-block: 36px;
        border-bottom: 1px solid var(--gray);
    }
    
    .promo h3 {
        font-size: clamp(1.3rem, 3vw + 0.5rem, 2rem);
    }
    
    .promo p {
    font-size: clamp(1rem, 2vw + 0.5rem, 1.5rem);
}

.promo :where(h3, p) {
    padding-inline: var(--space-x4);
}

.products {
    padding: 36px var(--space-x4) 0;
    grid-template-rows: min-content auto auto auto;
    grid-template-columns: repeat(auto-fill, minmax(30%, 150px));
    justify-content: space-between;
    column-gap:var(--default-space);
}

.card {
    line-height: 1.15rem;
    grid-row: span 4; /* necssário p/ q os elementos se relacionem corretamente com o grid-template-rows da .products */
    grid-template-rows: subgrid;
    row-gap: var(--default-space);
}

.wrapper {
    position: relative;
    overflow: hidden;
}

.card-img {
    width: 100%;
}

.wrapper > p {
    font-size: clamp(0.8rem, 0.8vw + 0.5rem, 1.8rem);
    color: var(--white);
    padding: var(--space-x2);
    justify-content: center;
    position: absolute;
    inset: 40% 0 0 0;
    opacity: 0;
    transform: translateY(100%);
    
    background-color: rgba(92, 167, 32, 0.7);
}

.card-img, .wrapper > p {
    transition: 500ms ease-in-out;
}

.wrapper:hover > p {
    opacity: 1;
    transform: translateY(0);
}

.wrapper:hover > .card-img {
    transform: scale(1.1);
    filter: blur(1px);
}

.card h4 {
    font-size: clamp(1rem, 1.3vw + 0.5rem, 1.3rem);
    margin-top: var(--default-space);
}

.price {
    font-size: clamp(0.6rem, 1vw + 0.5rem, 0.9rem);
    font-weight: 700;
}

.price span {
    font-size: clamp(0.9rem, 1.3vw + 0.5rem, 1.1rem);
    color: var(--btn-color);
    border-bottom: 1px solid var(--btn-color);
}

.buy {
    font-size: clamp(1.1rem, 1.4vw + 0.5rem, 1.5rem);
    font-weight: 900;
    color: var(--white);
    
    margin: var(--default-space) 0 var(--space-x4);
    padding: 0.3em 1em;
    border: none;
    border-radius: 10px;
    
    justify-self: flex-start;
    background-color: var(--btn-color);
    box-shadow: 0 0.4em 0.4em -0.1em #220e0039
}

.buy:hover {
    background-color: var(--bg-hover);
}

.buy:active {
    background-color: var(--btn-active);
}

.cart {
    text-align: center;
    height: 100vh;
    width: 60dvw;
    max-width: 350px;
    padding-top: var(--space-x3);
    background-color: var(--white);
    grid-template-rows: min-content 1fr min-content;

    position: fixed;
    inset: 0 0 0 auto;
    z-index: 3;
    transform: translateX(100%);
    transition: transform 800ms ease-in-out;
}

.show-cart {
    transform: translate(0);
}

.cart h2 {
    font-size: clamp(1.25rem, 2vw + 0.5rem, 1.8rem);
}

.cart-list {
    overflow: auto;
}

.cart-list::-webkit-scrollbar {
    width: 0;
}

.cart-item {
    padding-top: var(--space-x2);
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    align-items: center;
    gap: var(--default-space);
}

.cart-list .cart-item:nth-child(even) {
    background-color: rgb(236, 234, 234);
}

.cart-item img {
    display: none;
}

.quantity {
    grid-column: 1 / -1;
}

.quantity span:nth-child(odd) {
    cursor: pointer;
    width: clamp(1rem, 1.3vw + 0.5rem, 1.5rem);
    height: clamp(1rem, 1.3vw + 0.5rem, 1.5rem);
    display: inline-block;
    border-radius: 50%;
    background-color: var(--bg-header);
}

.quantity span:nth-child(odd):hover {
    background-color: var(--btn-color);
}

.quantity span:nth-child(odd):active {
    background-color: var(--bg-hover);
}

.cart-btns {
    grid-template-columns: 1fr 1fr;
}

.cart-btns > * {
    cursor: pointer;
    font-size: clamp(0.8rem, 2vw + 0.5rem, 1.8rem);
    color: var(--white);
    padding: 0.5em;
    border: none;

}

.close:hover {
    background-color: var(--btn-active);
}

.close, .close:active {
    background-color: var(--bg-hover);
}

.checkout:hover {
    background-color: var(--bg-header);
}

.checkout, .checkout:active  {
    background-color: var(--btn-color);
}

.note {
    max-width: 80%;
    position: fixed;
    left: 0;
    top: 10%;
    z-index: 3;
}

.note > * {
    font-size: clamp(1rem, 1vw + 0.5rem, 1.5rem);
    padding-block: var(--default-space);
    padding-inline: var(--space-x4) var(--default-space);
    background-color: var(--bg-header);
    border: 1px solid var(--bg-hover);
    border-left: none;
    border-radius: 0 10px 10px 0;
    transform: translateX(-100%);

    transition: transform 800ms ease-in-out;;
}

.show-note {
    transform: translateX(0);
}

.checkout-box {
    height: 100vh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #7a3a0d54;

    position: fixed;
    inset: 0;
    z-index: 4;
}

.checkout-box div {
    line-height: 1.8rem;
    width: 250px;
    height: 250px;
    padding: var(--space-x2);
    /* background-color: var(--bg-header); */
    background-color: transparent;
    border: 1px solid var(--bg-hover);
    -webkit-backdrop-filter: blur(32px);
    backdrop-filter: blur(32px);
}

.checkout-box button {
    width: 100%;
    height: 50px;
    cursor: pointer;
    font-size: var(--space-x3);
    color: var(--white);
    border: none;
    background-color: var(--bg-hover);
}

.checkout-box button:hover {
    background-color: var(--btn-active);
}

.checkout-box button:active {
    background-color: var(--bg-hover);
}

/* FOOTER */
footer {
    padding-top: var(--space-x2);
    margin-top: var(--space-x3);
    background-color: #F9F9F9;
    border-top: 1px solid var(--gray);
}

.infos {
    padding-inline: var(--space-x4);
}

.contacts {
    align-items: flex-start;
    flex-direction: column;
}

.contacts a {
    font-size: clamp(1rem, 1vw + 0.5rem, 1.5rem);
    color: var(--black);
    text-decoration: none;
    margin-bottom: var(--space-x2);
}

.contacts a:hover {
    color: var(--bg-header);
    font-weight: 700;
}

form {
    margin: var(--space-x4) 0;
    display: flex;
    flex-direction: column;
}

form > * {
    margin-bottom: var(--space-x2);
}

label {
    font-size: clamp(1rem, 1vw + 0.5rem, 1.5rem);
    font-weight: 700;
}

#email, .submit-mail {
    font-size: clamp(1rem, 1.3vw + 0.5rem, 1.8rem);
    line-height: 2.5em;
}

#email {
    padding-left: var(--default-space);
    border: 2px solid #D9D9D9;
}

.submit-mail {
    color: var(--white);
    background-color: var(--btn-color);
    border: none;   
    border-radius: 5px;
}

.submit-mail:hover {
    background-color: var(--bg-hover);
}

.submit-mail:active {
    background-color: var(--btn-active);
}

.social-pay {
    padding: var(--space-x3) var(--space-x4);
    border-top: 1px solid var(--gray);
}

.icon {
    width: clamp(1.2rem, 3vw + 0.5rem, 2rem);
}

.social a:first-child {
    margin-right: var(--space-x2);
}

.payment img:nth-child(2) {
    margin-inline: var(--space-x2);
}

/* RESPONSIVO */
@media only screen and (max-width: 372px) {
    .products {
        grid-template-columns: repeat(auto-fill, 100%);
        justify-content: center;
    }

    .card {
        line-height: 1.65rem;
        row-gap: 0;
    }
}

@media only screen and (min-width: 750px) {
    .card {
        line-height: 1.65rem;
        row-gap: 0;
    }

    .infos {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .cart-item {
        grid-template-columns: 1fr 2fr 1fr 2fr;
        grid-template-rows: unset;
    }

    .cart-item img {
        display: block;
    }

    .quantity {
        grid-column: 4 / -1;
    }

    form {
        display: grid;
        grid-template-rows: [news] min-content [email] 1fr [row-end];
        grid-template-columns: [col1] 1fr [col2] 1fr [col3] 1fr [col-end];
    }

    label {
        grid-row: news / email;
    }

    #email {
        border-right: none;
        grid-area: email / col1 / row-end / col3;
    }

    .submit-mail  {
        border-radius: 0 5px 5px 0;
        grid-area: email / col3 / row-end / col-end;
    }
}