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

:root {
  /* Primary Colors */
  --color-red: hsl(14, 86%, 42%);
  --color-green: hsl(159, 69%, 38%);

  /* Rose Colors */
  --color-rose-50: hsl(20, 50%, 98%);
  --color-rose-100: hsl(20, 45%, 96%);
  --color-rose-200: hsl(14, 95%, 89%);
  --color-rose-300: hsl(14, 25%, 72%);
  --color-rose-400: hsl(12, 25%, 66%);
  --color-rose-500: hsl(12, 20%, 44%);
  --color-rose-600: hsl(14, 75%, 49%);
  --color-rose-700: hsl(14, 70%, 39%);
  --color-rose-800: hsl(14, 65%, 29%);
  --color-rose-900: hsl(14, 65%, 9%);
}
@font-face {
  font-family: "Red Hat Text";
  src: url("./assets/fonts/RedHatText-VariableFont_wght.ttf") format("truetype");
  font-weight: 400 700;
}

body {
  font-family: "Red Hat Text", sans-serif;
  background-color: var(--color-rose-50);
  min-height: 100vh;
  padding: 88px 24px;
}

img,
svg {
  display: block;
  max-width: 100%;
  height: auto;
}

dialog {
  border: none;
  border-radius: 8px;
  padding: 2rem;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  overflow-y: hidden;
  > img {
    margin-bottom: 1rem;
  }

  > p:first-of-type {
    font-weight: 700;
    font-size: 1.9rem;
    color: var(--color-rose-900);
    margin-bottom: 0.2rem;
  }

  > p:nth-of-type(2) {
    font-size: 0.875rem;
    color: var(--color-rose-500);
    margin-bottom: 1.5rem;
  }

  .order-summary {
    background-color: var(--color-rose-50);
    border-radius: 10px;
    padding: 1rem;
    overflow-y: auto;
    max-height: calc(100vh - 20rem);
    /* Scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: var(--color-rose-400) transparent;

    .order-summary-item {
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      column-gap: 1rem;
      align-items: center;
      padding-block: 1rem;
      border-bottom: 1px solid var(--color-rose-100);

      .order-summary-item__details {
        > img {
          height: 3rem;
          width: 3rem;
          border-radius: 5px;
        }
        display: flex;
        flex-direction: row;
        column-gap: 1rem;
        align-items: center;
        .order-summary-item__details__text {
          > p:first-of-type {
            font-weight: 500;
            color: var(--color-rose-900);
          }
          > p:nth-of-type(2) {
            display: flex;
            flex-direction: row;
            column-gap: 1.4rem;
            align-items: center;
            > span:first-of-type {
              color: var(--color-rose-600);
              font-weight: 500;
            }
            > span:nth-of-type(2) {
              color: var(--color-rose-400);
              font-weight: 400;
            }
          }
        }
      }

      > p:first-of-type {
        font-weight: 500;
        color: var(--color-rose-900);
      }
    }

    .order-summary-total {
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      padding-block: 1rem;
      align-items: center;

      > p:last-of-type {
        font-size: 25px;
        font-weight: 700;
        color: var(--color-rose-900);
      }
    }
  }

  .btn-new-order {
    border: none;
    padding: 12px;
    width: 100%;
    margin-top: 1.5rem;
    background-color: var(--color-rose-600);
    color: white;
    font-size: 1rem;
    border-radius: 40px;
    font-weight: 500;
    cursor: pointer;
    letter-spacing: 1px;
  }

  & ::backdrop {
    background-color: rgba(0, 0, 0, 0.5);
    transition: background-color 0.3s ease-in-out;
  }
}

#root {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  row-gap: 1rem;
}

.container {
  display: grid;
  grid-template-columns: minmax(0, 70%) minmax(0, 30%);
  column-gap: 2rem;
  max-width: 1216px;
}

h1 {
  font-weight: 700;
  color: var(--color-rose-900);
  margin-bottom: 2rem;
  font-size: 2rem;
}

.dessert-cards-container {
  display: grid;
  grid-template-columns: repeat(3, minmax(0px, 1fr));
  gap: 2rem 1.5rem;
}

.dessert-card__image-container {
  position: relative;
  width: fit-content;
  border-radius: 8px;
}

.dessert-card__image {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  object-fit: cover;
}

.btn-cart {
  border: 2px solid var(--color-rose-300);
  position: absolute;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: white;
  border-radius: 20px;
  padding: 3%;
  cursor: pointer;
  width: clamp(134px, 60%, 173px);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  column-gap: 0.5rem;
  font-weight: 600;
}

.btn-cart:hover {
  border: 2px solid var(--color-red);
}

.quantity-control {
  align-items: center;
  justify-content: space-between;
  width: clamp(134px, 60%, 173px);
  background-color: var(--color-red);
  border-radius: 2rem;
  color: white;
  padding: 3%;
  position: absolute;
  left: 50%;
  transform: translate(-50%, -50%);
  display: none;
}

.increment,
.decrement {
  border-radius: 50%;
  width: 1.25rem;
  height: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  background-color: var(--color-red);
  border: 2px solid white;
  &:hover {
    background-color: white;
    img {
      filter: invert(48%) sepia(85%) saturate(2229%) hue-rotate(338deg)
        brightness(97%) contrast(95%);
    }
  }
}

.dessert-card__category {
  font-family: "Red Hat Text", sans-serif;
  font-size: 15px;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  color: var(--color-rose-500);
}

.dessert-card__name {
  font-family: "Red Hat Text", sans-serif;
  font-weight: 700;
  color: var(--color-rose-900);
  font-size: clamp(12px, 0.8vw + 8px, 16px);
  margin-bottom: 0.5rem;
}

.dessert-card__price {
  font-family: "Red Hat Text", sans-serif;
  font-weight: 700;
  font-size: 17px;
  color: var(--color-red);
}

.right-container {
  padding: 1.5rem;
  background-color: white;
  border-radius: 1.125rem;
  display: flex;
  flex-direction: column;
  height: fit-content;
  max-height: calc(100vh - 12rem);
  overflow-y: auto;
  /* Scrollbar styling */
  scrollbar-width: thin;
  scrollbar-color: var(--color-rose-400) transparent;
  .cart-empty {
    display: flex;
    flex-direction: column;
    row-gap: 2rem;

    img {
      align-self: center;
    }
    .cart__empty-message {
      color: var(--color-rose-500);
      font-weight: 500;
      font-size: 0.875rem;
      text-align: center;
    }
  }
}

/* Cart Styles */
.cart-items-container {
  display: none;
  .cart-item {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid var(--color-rose-100);
    padding-block: 16px;

    .cart-item__details {
      display: flex;
      flex-direction: column;
      row-gap: 4px;
      font-size: 0.875rem;
      p:first-child {
        font-weight: 600;
        font-size: 0.875rem;
        color: var (--color-rose-900);
      }
      p:nth-child(2) {
        display: flex;
        flex-direction: row;
        column-gap: 16px;
        font-size: 0.875rem;
        span:first-child {
          color: var(--color-rose-600);
          font-weight: 600;
        }
        span:nth-child(2) {
          color: var(--color-rose-400);
          font-weight: 400;
        }
        span:last-child {
          color: var(--color-rose-500);
          font-weight: 600;
        }
      }
    }
  }
  .cart-total {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    padding-block: 2rem;
    align-items: center;
    p:first-child {
      font-weight: 500;
      font-size: 14px;
      color: var(--color-rose-500);
    }
    p:last-child {
      font-weight: 700;
      font-size: 24px;
      color: var(--color-rose-900);
    }
  }
  .carbon-neutral {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background-color: var(--color-rose-50);
    padding-block: 1rem;
    border-radius: 5px;
    p {
      font-size: 0.875rem;
      span {
        font-weight: 700;
        color: var(--color-rose-900);
      }
    }
  }
  .btn-confirm-order {
    border: none;
    padding: 19px;
    width: 100%;
    margin-top: 1.5rem;
    background-color: var(--color-rose-600);
    color: white;
    font-size: 1rem;
    border-radius: 40px;
    font-weight: 500;
    cursor: pointer;
    letter-spacing: 1px;
  }
}

.btn-remove {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 50%;
  border: 2px solid var(--color-rose-400);
  height: 20px;
  width: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

h2 {
  color: var(--color-red);
  font-size: clamp(16px, 1vw + 12px, 24px);
}

.attribution {
  font-size: 11px;
  text-align: center;
}
.attribution a {
  color: hsl(228, 45%, 44%);
}

@media screen and (width < 1014px) {
  .container {
    column-gap: 1rem;
  }

  .dessert-cards-container {
    gap: 1rem;
  }

  .right-container {
    padding: 1rem;
  }
}

@media screen and (width < 900px) {
  .container {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
  dialog {
    width: 50vw;
  }
}

@media screen and (width < 800px) {
  dialog {
    width: 70vw;
  }
}

@media screen and (width < 650px) {
  body {
    padding: 1.5rem;
  }
  .dessert-cards-container {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
}

@media screen and (width < 600px) {
  dialog {
    width: 80vw;
  }
}
/* This media query is for mobile devices */
@media screen and (width < 500px) {
  dialog {
    width: 90vw;
    padding: 0.5rem;
  }
}
