:root {
  --bg-color1: #212529;
  --bg-color2: #2a2b2d;
  --aqi-1: #d4e157;
  --aqi-2: #ffee58;
  --aqi-3: #ffca28;
  --aqi-4: #ff7043;
  --aqi-5: #ef5350;
}

* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}
body {
  background-color: var(--bg-color1);
  min-height: 100vh;
  color: white;
  font-family: sans-serif;
  padding: 0 15px;
}
hr {
  margin-bottom: 10px;
}
.header {
  position: sticky;
  top: 0;
  background-color: var(--bg-color1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding: 15px 0;
  & #cityInput {
    background-color: var(--bg-color2);
    border: none;
    padding: 12px;
    font-size: 16px;
    border-radius: 25px;
    color: white;

    &:focus {
      outline: none;
    }
  }
  & #searchBtn {
    border: none;
    padding: 12px;
    font-size: 16px;
    border-radius: 25px;
    background-color: white;
    cursor: pointer;
  }
  & #locationBtn {
    border: none;
    padding: 12px;
    font-size: 16px;
    border-radius: 25px;
    background-color: #ea6e4b;
    cursor: pointer;
  }
}
.card {
  background-color: var(--bg-color2);
  padding: 15px;
  border-radius: 15px;
  margin-bottom: 15px;
  & p {
    font-size: 14px;
    color: #999;
  }
  & h2 {
    font-size: 32px;
    font-weight: 500;
  }
}
.weather-data {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  & .weather-left {
    grid-column: span 1;
    & .current-weather {
      display: flex;
      justify-content: center;
      align-content: center;
      & h2 {
        margin: 7px 0;
      }
      & p {
        color: #fff;
      }
    }
    & .card-footer p {
      font-size: 14px;
      margin-bottom: 12px;
      display: flex;
      gap: 10px;
    }
    & .forecast-item {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      place-items: center;
      margin-bottom: 15px;
      & .icon-wrapper {
        display: flex;
        align-items: center;
      }
    }
  }
  & .weather-right {
    grid-column: span 3;
    & h2 {
      margin-bottom: 10px;
    }
    & .highlights {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      column-gap: 15px;

      & .card:nth-of-type(1),
      & .card:nth-of-type(2) {
        grid-column: span 2;
      }

      & .card-head {
        display: flex;
        justify-content: space-between;
        margin-bottom: 10px;
        & .air-index {
          color: black;
          padding: 5px 10px;
          border-radius: 15px;
          &.aqi-1 {
            background-color: var(--aqi-1);
          }
          &.aqi-2 {
            background-color: var(--aqi-2);
          }
          &.aqi-3 {
            background-color: var(--aqi-3);
          }
          &.aqi-4 {
            background-color: var(--aqi-4);
          }
          &.aqi-5 {
            background-color: var(--aqi-5);
          }
        }
      }
      & .air-indices {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        place-items: center;
        & p {
          text-align: center;
        }
      }
      .sunrise-sunset {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        & .item {
          display: flex;
          align-items: center;
          gap: 10px;
          & h2 {
            margin-top: 15px;
          }
        }
      }
      & .card-item {
        display: flex;
        justify-content: space-between;
      }
    }
    & .hourly-forecast {
      display: grid;
      grid-template-columns: repeat(8, 1fr);
      column-gap: 10px;
      & .card {
        text-align: center;
      }
    }
  }
}
@media (max-width: 1100px) {
  .weather-data {
    grid-template-columns: repeat(3, 1fr);
    & .weather-right {
      grid-column: span 2;
      & .highlights {
        grid-template-columns: repeat(3, 1fr);
        & .card:nth-of-type(1) {
          grid-column: span 3;
        }
      }
      & .hourly-forecast {
        grid-template-columns: repeat(6, 1fr);
      }
    }
  }
}
@media (max-width: 1040px) {
  .weather-data {
    grid-template-columns: repeat(2, 1fr);
    & .weather-right {
      grid-column: span 1;
      & .highlights {
        grid-template-columns: repeat(2, 1fr);
        & .card:nth-of-type(1) {
          grid-column: span 2;
        }
      }
      &.hourly-forecast {
        grid-template-columns: repeat(4, 1fr);
      }
    }
  }
}
@media (max-width: 992px) {
  .weather-data .weather-right .highlights {
    & .card {
      grid-column: span 2;
    }
    & .air-indices {
      grid-template-columns: repeat(3, 1fr);
    }
  }
}
@media (max-width: 850px) {
  .weather-data {
    grid-template-columns: 1fr;
    &.weather-right .highlights {
      & .card:nth-of-type(3),
      & .card:nth-of-type(4),
      & .card:nth-of-type(5),
      & .card:nth-of-type(6),
      & .card:nth-of-type(7) {
        grid-column: span 1;
      }
      & .air-indices {
        grid-template-columns: repeat(5, 1fr);
      }
    }
  }
}
@media (max-width: 660px) {
  .header {
    flex-direction: column;

    & h2 {
      margin-bottom: 8px;
    }
    & #cityInput,
    #searchBtn,
    #locationBtn {
      width: 100%;
      margin-bottom: 10px;
    }
  }
}
@media (max-width: 580px) {
  .weather-data .weather-right .highlights .air-indices {
    grid-template-columns: repeat(4, 1fr);
  }
}
@media (max-width: 520px) {
  .weather-data .weather-right .highlights {
    & .card:nth-of-type(3),
    & .card:nth-of-type(4),
    & .card:nth-of-type(5),
    & .card:nth-of-type(6),
    & .card:nth-of-type(7) {
      grid-column: span 2;
    }
    & .air-indices {
      grid-template-columns: repeat(3, 1fr);
    }
  }
}
@media (max-width: 480px) {
  .weather-data .weather-right .highlights .sunrise-sunset {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 450px) {
  .weather-data .weather-right .hourly-forecast {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 3980px) {
  .weather-data .weather-right .highlights .air-indices {
    grid-template-columns: repeat(2, 1fr);
  }
}
.loader {
  width: 15px;
  height: 15px;
  border: 3px solid #ef5350;
  border-bottom-color: transparent;
  border-radius: 50%;
  display: inline-block;
  box-sizing: border-box;
  animation: rotation 1s linear infinite;
  display: none;
}

@keyframes rotation {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
