@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap");

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

.pop-up {
  position: absolute;
  top: 20%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #f8d7da;
  color: #721c24;
  padding: 16px;
  border-radius: 16px;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: all 0.4s ease;

  p {
    font-size: 16px;
    text-align: center;
  }
}

.pop-up.show {
  opacity: 1;
  pointer-events: auto;
}

.container {
  margin: 3rem auto;
  padding: 4px;
  border-radius: 16px;
  background: #333;
  color: #fff;
}

/* Grid Setup */
.container {
  max-width: 640px;
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: auto auto auto;

  & > #userInput {
    grid-column-start: 1;
    grid-row-start: 1;
    grid-row-end: 2;
  }

  & > #clock {
    grid-column-start: 1;
    grid-row-start: 2;
    grid-row-end: 4;
  }

  & > #mainDisplay,
  #details,
  #forecast {
    grid-column-start: 2;
    grid-column-end: 4;
  }
}

#userInput {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 16px;
  background: #005060;
  border-radius: 12px 4px 4px 4px;

  & > label {
    font-size: 14px;
  }

  & > .inputContainer {
    position: relative;
    display: flex;

    border: 2px solid #407090;
    border-radius: 4px;
    margin-top: 8px;

    & > #location {
      display: flex;
      align-items: center;

      & > input {
        flex: 1;
        padding: 4px 8px;
        background: transparent;
        outline: none;
        border: none;
        font: inherit;
        color: #fff;

        &::placeholder {
          color: #fff;
          opacity: 0.3;
        }
      }
    }

    & > button {
      display: flex;
      justify-content: center;
      align-items: center;

      border-radius: 0 4px 4px 0;
      padding: 8px 12px;
      cursor: pointer;
      background: aquamarine;
      outline: none;
      border: none;

      & > i {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        height: 100%;
        background: aquamarine;
        color: #407090;
        font-size: 32px;
      }
    }

    & #suggestions {
      position: absolute;
      top: 100%;
      left: 0;
      right: 0;
      z-index: 10;

      box-shadow: 0 4px 10px rgba(0, 0, 0, 0.6);
      border-radius: 4px;
      overflow: hidden;

      p {
        color: lightblue;
        padding: 4px;
        background-color: teal;
        border-top: 2px solid rgba(0, 255, 255, 0.4);
        cursor: pointer;

        &:hover {
          background-color: #009999;
        }
      }

      & p:last-child {
        border-bottom: 2px solid rgba(0, 255, 255, 0.4);
      }
    }
  }

  & p#resultsFor {
    margin-top: 8px;
    color: #4ba7cb;
    font-size: 12px;
  }
}

#clock {
  background: #407090;
  border-radius: 4px 4px 4px 12px;
  padding: 16px;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  & > .time {
    font-weight: 600;
    font-size: 56px;
    line-height: 1.2;

    & > #meridiem {
      font-size: 18px;
    }

    & > #separator {
      animation: blink 1.2s ease-in-out infinite;
    }
  }
}

#mainDisplay {
  padding: 12px 24px;
  background: #455575;
  border-radius: 4px 12px 4px 4px;
  width: 100%;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;

  & > #data {
    h3 {
      font-size: 3rem;
      text-align: center;
    }

    p {
      display: inline;
      font-weight: 600;
    }

    & > :last-child {
      margin-left: 12px;
    }
  }

  & > #img {
    width: 120px;
    height: 120px;

    & > img {
      width: 100%;
      object-fit: cover;
    }
  }
}

#details {
  background: #354545;
  padding: 16px;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 5px;

  & > p {
    width: 100%;
    display: flex;
    align-items: center;
    font-weight: 600;

    & > span {
      margin-left: auto;
    }

    & > i.fa-circle {
      width: 16px;
      margin-left: 5px;
      color: lightgreen;
    }

    & > i.fa-droplet {
      width: 16px;
      text-align: center;
      margin-left: 5px;
      color: aqua;
    }
  }
}

#forecast {
  padding: 16px;
  border-radius: 13px;
  display: flex;
  gap: 8px;
  justify-content: space-between;

  & > div {
    font-weight: 600;
    text-align: center;

    & > span.icon {
      width: 50px;
      & > img {
        width: 100%;
      }
    }

    & > p {
      display: grid;
      grid-template-rows: auto auto;

      & > .low {
        opacity: 0.6;
      }
    }
  }
}

@keyframes blink {
  0%,
  100% {
    opacity: 0;
  }

  50% {
    opacity: 1;
  }
}

@media (max-width: 650px) {
  :root {
    font-size: 12px;
  }

  body {
    padding: 16px;
  }
  .container {
    margin-top: 16px;
    display: flex;
    flex-direction: column;

    #userInput .inputContainer {
      display: flex;
      flex-direction: column;

      #city {
        padding: 16px 8px;
      }
    }

    #clock {
      .time {
        font-size: 3rem;
      }
    }
  }
}
