@import url("https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap");

/* Variables */
:root {
  /* Colors */
  --first-color: hsl(82, 60%, 28%);
  --title-color: hsl(0, 0%, 15%);
  --text-color: hsl(0, 0%, 35%);
  --body-color: hsl(0, 0%, 95%);
  --container-color: hsl(0, 0%, 100%);

  /* Font & Typography*/
  --body-font: "Poppins", sans-serif;
  --h2-font-size: 1.25rem;
  --small-font-size: 0.813rem;
}

/* Responsive typography */
@media screen and (min-width: 1120px) {
  :root {
    --h2-font-size: 1.5rem;
    --small-font-size: 0.875rem;
  }
}

/* Base */
* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--body-font);
  color: var(--text-color);
  background: linear-gradient(
      135deg,
      hsla(0, 0%, 95%, 0.8),
      hsla(0, 0%, 95%, 0.3)
    ),
    url(img/sunset-1373171_1280.jpg);
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  min-height: 100vh;
}

header {
  position: sticky;
  top: 0;
  z-index: 10;
}

.navbar {
  font-family: "Montserrat", sans-serif;
  height: 5.4rem;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 3.2rem;
  background-color: rgba(248, 242, 221, 0.2);
  backdrop-filter: blur(20px);
}

.nav_list {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.5s ease;
}

.nav_list.show {
  background-color: rgba(248, 242, 221, 0.3);
  max-height: 300px;
  opacity: 1;
  transform: translateY(140px);
  width: 100%;
  text-align: center;
  border-radius: 0 0 5px 5px;
}

.nav_link {
  display: block;
  text-decoration: none;
  border-radius: 0.8rem;
  background-color: transparent;
  padding: 0.4rem 0.8rem;
  margin: 0 0.8rem;
  font-size: 1rem;
  line-height: 2rem;
  font-weight: 600;
  color: hsl(220, 16%, 11%);
  transition: all 0.3s ease;
}

.nav_link:hover {
  background-color: hsla(220, 16%, 11%, 0.1);
}

/* Menu bar */
#menu_bar {
  cursor: pointer;
}

.bar {
  display: block;
  width: 25px;
  height: 4px;
  background-color: rgb(0, 0, 0);
  margin: 3px 0;
  border-radius: 25px;
  transition: all 0.3s ease;
}

/* Menu Bar transformation to X */
#menu_bar.open .bar:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

#menu_bar.open .bar:nth-child(2) {
  opacity: 0;
}

#menu_bar.open .bar:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* Card */
.container {
  display: grid;
  place-items: center;
  margin-inline: 1.5rem;
  padding-block: 5rem;
}

.card__container {
  display: grid;
  row-gap: 3.5rem;
}

.card__article {
  position: relative;
  overflow: hidden;
}

.card__img {
  display: block;
  max-width: 100%;
  height: auto;
  width: 328px;
  border-radius: 1.5rem;
}

.card__data {
  width: 280px;
  background-color: var(--container-color);
  padding: 1.5rem 2rem;
  box-shadow: 0 8px 24px hsla(0, 0%, 0%, 0.15);
  border-radius: 1rem;
  position: absolute;
  bottom: -9rem;
  left: 0;
  right: 0;
  margin-inline: auto;
  opacity: 0;
  transition: opacity 1s 1s;
}

.card__description {
  display: block;
  font-size: var(--small-font-size);
  margin-bottom: 0.25rem;
}

.card__title {
  font-size: var(--h2-font-size);
  font-weight: 500;
  color: var(--title-color);
  margin-bottom: 0.75rem;
}

.card__button {
  text-decoration: none;
  font-size: var(--small-font-size);
  font-weight: 500;
  color: var(--first-color);
}

.card__button:hover {
  text-decoration: underline;
}

/* Naming animations in hover  */
.card__article:hover .card__data {
  animation: show-data 1s forwards;
  opacity: 1;
  transition: opacity 3s;
}

.card__article:hover {
  animation: remove-overflow 2s forwards;
}

.card__article:not(:hover) {
  animation: show-overflow 2s forwards;
}

.card__article:not(:hover) .card__data {
  animation: remove-data 2s forwards;
}

/* Card animation */
@keyframes show-data {
  50% {
    transform: translateY(-10rem);
  }
  100% {
    transform: translateY(-7rem);
  }
}

@keyframes remove-overflow {
  to {
    overflow: initial;
  }
}

@keyframes remove-data {
  0% {
    transform: translateY(-10rem);
  }
  100% {
    transform: translateY(0.5rem);
  }
}

@keyframes show-overflow {
  0% {
    overflow: initial;
    pointer-events: none;
  }
  40% {
    overflow: hidden;
  }
}

/* Breakpoints */
/* For small devices */
@media screen and (max-width: 340px) {
  .container {
    margin-inline: 1rem;
  }

  .card__data {
    width: 250px;
    padding: 1rem;
  }
}

/* For medium devices */
@media screen and (min-width: 768px) {
  .nav_list {
    max-height: fit-content;
    opacity: 1;
    transform: translate(0);
    width: fit-content;
  }

  .nav_link {
    display: inline-block;
  }

  #menu_bar {
    display: none;
  }

  .card__container {
    grid-template-columns: repeat(2, 1fr);
    column-gap: 1rem;
  }
}

/* For large devices */
@media screen and (min-width: 1024px) {
  .container {
    min-height: 83vh;
  }

  .card__container {
    grid-template-columns: repeat(3, 1fr);
  }

  .card__img {
    width: 348px;
  }

  .card__data {
    width: 316px;
    padding-inline: 2.5rem;
  }
}
