@import url("https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,200..1000;1,200..1000&display=swap");

:root {
  /* Colors */
  --primary: #b5a1e5;
  --on-primary: #100e17;
  --background: #131214;
  --on-background: #eae6f2;
  --surface: #1d1c1f;
  --on-surface: #dddae5;
  --on-surface-variant: #7b7980;
  --on-surface-variant-2: #b9b6bf;
  --outline: #3e3d40;
  --bg-aqi-1: #89e589;
  --on-bg-aqi-1: #1f331f;
  --bg-aqi-2: #e5dd89;
  --on-bg-aqi-2: #33311f;
  --bg-aqi-3: #e5c089;
  --on-bg-aqi-3: #332b1f;
  --bg-aqi-4: #e58989;
  --on-bg-aqi-4: #331f1f;
  --bg-aqi-5: #e589b7;
  --on-bg-aqi-5: #331f29;
  --white: hsl(0, 0%, 100%);
  --white-alpha-4: hsla(0, 0%, 100%, 0.04);
  --white-alpha-8: hsla(0, 0%, 100%, 0.08);
  --black-alpha-10: hsla(0, 0%, 0%, 0.1);

  /* Gradient colors */
  --gradient-1: linear-gradient(
    180deg,
    hsla(270, 5%, 7%, 0) 0%,
    hsla(270, 5%, 7%, 0.8) 65%,
    hsl(270, 5%, 7%) 100%
  );
  --gradient-2: linear-gradient(
    180deg,
    hsla(260, 5%, 12%, 0) 0%,
    hsla(260, 5%, 12%, 0.8) 65%,
    hsl(260, 5%, 12%) 100%
  );

  /* Typography */
  --ff: "Nunito", sans-serif;

  --fw-regular: 400;
  --fw-semi-bold: 600;

  --heading: 5.6rem;
  --title-1: 2rem;
  --title-2: 1.8rem;
  --title-3: 1.6rem;
  --body-1: 2.2rem;
  --body-2: 2rem;
  --body-3: 1.6rem;
  --label-1: 1.4rem;
  --label-2: 1.2rem;

  /* Box shadows */
  --shadow-1: 0px 1px 3px hsla(0, 0%, 0%, 0.5);
  --shadow-2: 0px 3px 6px hsla(0, 0%, 0%, 0.4);

  /* Border radii */
  --br-28: 28px;
  --br-16: 16px;
  --br-pill: 500px;
  --br-circle: 50%;

  /* Transition */
  --transition: 100ms ease-in-out;
}

body {
  min-height: 200vh;
  background-color: var(--background);
  color: var(--on-background);
  font-size: var(--body-3); /* 16px */
  overflow: hidden;
}

/* Header styles */
.header .wrapper,
.header-actions {
  display: flex;
  align-items: center;
}

.header .wrapper {
  justify-content: space-between;
}

.header-actions {
  gap: 16px;
}

.header .btn-primary .span {
  display: none;
}

.logo img {
  width: 150px;
}

.header .btn-primary {
  padding-inline: 12px;
}

.search-view {
  position: fixed;
  top: 0;
  left: 0;

  width: 100%;
  height: 100vh;
  height: 100svh; /* For mobile browsers */
  background-color: var(--surface);
  color: var(--on-surface);

  opacity: 0;
  visibility: hidden;
  z-index: 4;

  clip-path: circle(4% at calc(100% - 102px) 5%);
  transition: clip-path 500ms ease-in-out;
}

.search-view.active {
  opacity: 1;
  visibility: visible;

  clip-path: circle(130% at 73% 5%);
}

.search-field-wrapper {
  border-bottom: 1px solid var(--outline);

  position: relative;
}

/* Loading symbol styles */
.search-field-wrapper::before {
  content: "";
  width: 24px;
  height: 24px;
  border: 3px solid var(--on-surface);
  border-top-color: transparent;
  border-radius: var(--br-circle);

  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: 16px;

  animation: loading 500ms linear infinite;

  display: none;
}

@keyframes loading {
  0% {
    transform: translateY(-50%) rotate(0);
  }

  100% {
    transform: translateY(-50%) rotate(1turn);
  }
}

/* The "searching" class will be added by JS */
.search-field-wrapper:has(.searching)::before {
  display: block;
}

.search-field {
  height: 80px;
  line-height: 80px;
  padding-inline: 56px 16px;
  outline: none;
}

.search-field::placeholder {
  color: var(--on-surface-variant-2);
}

.search-field::-webkit-search-cancel-button {
  display: none;
}

.search-field-wrapper .leading-go-back-icon {
  position: absolute;
  top: 50%;
  left: 28px;
  transform: translate(-50%, -50%);
}

.search-field-wrapper > .msr-icon {
  display: none;
}

.search-field-wrapper .icon-btn {
  background-color: transparent;
  box-shadow: none;
}

.search-results .search-list {
  padding-block: 8px 16px;
}

.search-results .search-item {
  height: 56px;

  display: flex;
  justify-content: start;
  align-items: center;
  gap: 16px;
  padding-inline: 16px 24px;

  position: relative;
}

.search-results .search-item :is(.msr-icon, .item-subtitle) {
  color: var(--on-surface-variant);
}

.search-results .search-item .item-link {
  position: absolute;
  inset: 0;

  box-shadow: none;
}

/* Main styles */
main {
  height: calc(100vh - 80px); /* = (100vh - header height) */
  height: calc(100svh - 80px); /* For mobile browsers */
  overflow: hidden;
}

/* Current weather card container article styles */
article.wrapper {
  height: 100%;
  overflow-y: auto;

  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;

  position: relative;
}

article.wrapper::-webkit-scrollbar-thumb {
  background-color: transparent;
}

article.wrapper:is(:hover, :focus-within)::-webkit-scrollbar-thumb {
  background-color: var(--white-alpha-8);
}

article.wrapper::-webkit-scrollbar-button {
  height: 10px;
}

article.wrapper::before {
  content: "";
  width: 100%;
  height: 40px;
  background-image: var(--gradient-1);

  position: fixed;
  bottom: 0;
  left: 0;
  z-index: 1;

  pointer-events: none;
}

/* Placeholder content styles */
.placeholder-content {
  text-align: center;
  padding: 40px 20px;
}

.placeholder-content .msr-icon {
  font-size: 4rem;
  color: var(--on-surface-variant);
  margin-bottom: 16px;
  display: block;
}

.placeholder-content .title-2 {
  color: var(--on-surface-variant);
  margin-bottom: 12px;
}

.placeholder-content .body-3 {
  color: var(--on-surface-variant-2);
  margin-bottom: 20px;
  line-height: 1.5;
}

.placeholder-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.placeholder-action-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--on-surface-variant-2);
}

.placeholder-action-item .msr-icon {
  font-size: 2rem;
  margin-bottom: 0;
}

/* Current weather card specific styles */
.current-weather-card .container {
  margin-block: 12px;

  display: flex;
  align-items: center;
  gap: 8px;
}

.current-weather-card .weather-icon {
  margin-inline: auto;
}

.current-weather-card > .body-3 {
  text-transform: capitalize;
}

.current-weather-card .meta-list {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--outline);
}

.current-weather-card .meta-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.current-weather-card .meta-item:not(:last-child) {
  margin-bottom: 12px;
}

.current-weather-card .meta-text {
  color: var(--on-surface-variant);
}

/* Forecast section styles */
.forecast-cards .title-2 {
  margin-bottom: 0;
}

.forecast-cards :is(.card-item, .icon-wrapper) {
  display: flex;
  align-items: center;
}

.forecast-cards .card-item:not(:last-child) {
  margin-bottom: 12px;
}

.forecast-cards .icon-wrapper {
  gap: 8px;
}

.forecast-cards .label-1 {
  color: var(--on-surface-variant);
  font-weight: var(--fw-semi-bold);
}

.forecast-cards .card-item > .label-1 {
  width: 100%;
  text-align: right;
}

/* .forecast-cards .card-item {
  justify-content: space-between;
} */

/* Highlights section styles */
.highlights .msr-icon {
  font-size: 3.2rem;
}

.highlights .card-sm {
  background-color: var(--black-alpha-10);

  position: relative;
}

.highlight-list {
  display: grid;
  gap: 20px;
}

.highlight-list .title-3 {
  color: var(--on-surface-variant);
  margin-bottom: 20px;
}

.highlight-card :is(.container, .card-list, .card-item) {
  display: flex;
  align-items: center;
}

.highlight-card .container {
  justify-content: space-between;
  gap: 16px;
}

.highlight-card .card-list {
  row-gap: 8px;
  flex-grow: 1;
  flex-wrap: wrap;
}

.highlight-card .card-item {
  /* width: 50%; */

  flex-basis: 50%;
  justify-content: end;
  gap: 4px;
}

.highlight-card .label-1 {
  color: var(--on-surface-variant);
}

.highlight-card .badge {
  font-weight: var(--fw-semi-bold);
  border-radius: var(--br-pill);
  padding: 2px 12px;
  cursor: help;

  position: absolute;
  top: 16px;
  right: 16px;
}

.highlight-card.two .card-item {
  justify-content: start;
  gap: 8px 16px;
  flex-wrap: wrap;
}

.highlight-card.two .label-1 {
  margin-bottom: 4px;
}

/* Hourly forecast section styles */
.slider-container {
  margin-inline: -16px;
  overflow-x: auto;
}

.slider-container::-webkit-scrollbar {
  display: none;
}

.slider-list {
  display: flex;
  gap: 12px;
}

.slider-list:first-child {
  margin-bottom: 16px;
}

.slider-list::before,
.slider-list::after {
  content: "";
  min-width: 4px;
}

.slider-item {
  min-width: 110px;

  flex: 1 1 100%;
}

.slider-card {
  text-align: center;
}

.slider-card .weather-icon {
  margin-inline: auto;
  margin-block: 12px;
}

/* Footer styles */
.footer,
.footer .body-3:last-child {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.footer {
  color: var(--on-surface-variant);
  text-align: center;
  margin-top: 28px;

  gap: 12px 24px;

  display: none;
}

.footer .copyright-year {
  display: inline;
}

.fade-in .footer {
  display: flex;
}

.footer .body-3:last-child {
  gap: 6px;
}

/* Loading screen styles */
.loading-screen {
  width: 100%;
  height: 100%;
  background-color: var(--background);

  /* display: grid; */
  display: none;
  place-items: center;

  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

.loading-screen::before {
  content: "";
  width: 48px;
  height: 48px;
  border: 4px solid var(--on-background);
  border-top-color: transparent;
  border-radius: var(--br-circle);

  animation: loading 500ms linear infinite;
}

/* Error: 404 section styles */
.erroneous-content {
  width: 100%;
  height: 100vh;
  height: 100svh;
  background-color: var(--background);

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

  position: fixed;
  top: 0;
  left: 0;
  z-index: 8;
}

.erroneous-content .btn-primary {
  margin-top: 20px;
}

/* Responsiveness for screen sizes >= 768px */
@media (width >= 768px) {
  .header-actions {
    gap: 24px;
  }

  .header .btn-primary {
    padding-inline: 16px 24px;
  }

  .header .btn-primary .span {
    display: block;
  }

  .search-view {
    clip-path: circle(3% at calc(100% - 273px) 6%);
  }

  main {
    height: calc(100vh - 96px);
    height: calc(100svh - 96px);
  }

  article.wrapper {
    padding-top: 0;

    grid-template-columns: 280px minmax(0, 1fr);
    align-items: start;
    gap: 24px;
  }

  .left-content {
    position: sticky;
    top: 0;
  }

  .forecast-cards .card-item:not(:last-child) {
    margin-bottom: 16px;
  }

  .highlights .msr-icon {
    font-size: 3.6rem;
  }

  .highlight-list {
    grid-template-columns: repeat(2, 1fr);
  }

  .highlight-card:nth-child(-n + 2) {
    height: 160px;

    grid-column: span 2;
  }

  .highlight-card:nth-child(n + 3) {
    height: 120px;
  }

  .highlight-card .badge {
    top: 20px;
    right: 20px;
  }

  .highlight-card.one .card-item {
    /* width: 25%; */

    flex-basis: 25%;
    flex-direction: column-reverse;
    gap: 8px;
  }

  .slider-container {
    border-top-left-radius: var(--br-16);
    border-bottom-left-radius: var(--br-16);
    margin-inline: 0 -24px;
  }

  .slider-list::before {
    display: none;
  }

  .slider-list::after {
    min-width: 12px;
  }

  .hourly-forecast .card-sm {
    padding: 16px;
  }

  .placeholder-actions {
    flex-direction: row;
    gap: 24px;
  }
}

/* Responsiveness for screen sizes >= 1200px */
@media (width >= 1200px) {
  :root {
    /* Font size */
    --heading: 8rem;
    --title-2: 2rem;
  }

  .header {
    height: 120px;

    position: relative;
    z-index: 4;
  }

  .header .wrapper {
    height: 100%;
    padding-block: 0;
  }

  .header .icon-btn {
    display: none;
  }

  .logo img {
    width: 200px;
  }

  .search-view,
  .search-view.active {
    all: unset;

    display: block;
    width: 500px;

    position: relative;

    animation: none;
  }

  .search-field-wrapper {
    border-bottom: none;
  }

  .search-field-wrapper > .msr-icon {
    display: block;
  }

  .search-field,
  .search-view .search-list {
    background-color: var(--surface);
  }

  .search-field {
    height: 56px;
    border-radius: var(--br-28);
  }

  .search-results,
  .search-view:not(:focus-within) .search-results {
    display: none;
  }

  .search-view:focus-within .search-results.active {
    display: block;
  }

  .search-view:has(.search-results.active):focus-within .search-field {
    border-bottom-right-radius: 0;
    border-bottom-left-radius: 0;
  }

  .search-view .search-list {
    width: 100%;
    max-height: 360px;
    border-top: 1px solid var(--outline);
    border-radius: 0 0 var(--br-28) var(--br-28);
    overflow-y: auto;

    position: absolute;
    top: 100%;
    left: 0;
  }

  .search-view .search-list:empty {
    min-height: 120px;
  }

  .search-view .search-list::-webkit-scrollbar-button {
    height: 20px;
  }

  .search-view:is(:hover, :has(.search-list):hover) {
    filter: drop-shadow(var(--shadow-1));
  }

  .search-view:is(:focus-within, :has(.search-list):focus-within) {
    filter: drop-shadow(var(--shadow-2));
  }

  main {
    height: calc(100vh - 120px);
    height: calc(100svh - 120px);
  }

  article.wrapper {
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 40px;
  }

  .current-weather-card .weather-icon {
    width: 80px;
  }

  .forecast-cards .title-2 {
    --title-2: 2.2rem;
  }

  .highlight-card:nth-child(-n + 2) {
    min-height: 200px;
  }

  .highlight-card:nth-child(n + 3) {
    min-height: 150px;
  }

  .highlight-card .msr-icon {
    font-size: 4.8rem;
  }

  .highlight-card.two .card-item {
    column-gap: 24px;
  }

  .highlight-card .title-1 {
    font-size: 2.8rem !important; /* reduced from 3.6rem */
  }

  .slider-list {
    gap: 16px;
  }
}

/* Responsiveness for screen sizes >= 1400px */
@media (width >= 1400px) {
  .highlight-list {
    grid-template-columns: repeat(4, 1fr);
  }
}
