/*---------------------- Colors (change these to restyle the whole app) ------------------ */
:root {
  --bg: #eef1f5;        /* page background */
  --card: #ffffff;      /* the white card */
  --soft: #f3f5f8;      /* light gray boxes inside the card */
  --text: #1f2937;      /* main text */
  --muted: #6b7280;     /* secondary text */
  --accent: #3b82f6;    /* search button + icons */
  --accent-dark: #2563eb;
  --danger: #dc2626;
}

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

html {
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;
  padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  font-family: 'Poppins', sans-serif;
  background: var(--bg);
  color: var(--text);
}

/*---------------------- Card ------------------ */
.container {
  background-color: var(--card);
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  max-width: 440px;
  border-radius: 24px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 12px 32px rgba(16, 24, 40, 0.08);
  padding: 24px;
  user-select: none;
  animation: slideIn 0.5s ease both;
}

/*---------------------- Search bar ------------------ */
.search {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inputWrap {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 16px;
  background: var(--soft);
  border: 1px solid transparent;
  border-radius: 999px;
  transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.inputWrap:focus-within {
  background: var(--card);
  border-color: #d1d5db;
  box-shadow: 0 0 0 4px rgba(16, 24, 40, 0.05);
}

#locationIcon {
  color: var(--muted);
  font-size: 18px;
}

#cityInput {
  flex: 1;
  width: 100%;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 16px;
  color: var(--text);
}

#cityInput::placeholder {
  color: #9ca3af;
}

#clear,
#searchBtn {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 16px;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

#clear {
  background: var(--soft);
  color: var(--muted);
}
#clear:hover {
  background: #e5e7eb;
}

#searchBtn {
  background: var(--accent);
  color: #ffffff;
}
#searchBtn:hover {
  background: var(--accent-dark);
}

#clear:active,
#searchBtn:active {
  transform: scale(0.95);
}

/*---------------------- Small messages under the search bar ------------------ */
#errp,
#loading {
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  margin-top: 12px;
}
#errp {
  color: var(--danger);
  margin-top: 0;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, margin 0.3s ease, opacity 0.3s ease;
}
#errp.show {
  max-height: 24px;
  margin-top: 10px;
  margin-bottom: -14px;
  opacity: 1;
}
#loading {
  color: var(--muted);
}

/*---------------------- Results box (opens when you search) ------------------ */
.results {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.4s ease;
}
.container.expanded .results {
  grid-template-rows: 1fr;
}
.resultsInner {
  overflow: hidden;
  min-height: 0;
}
.resultsInner.fadeIn {
  animation: fadeIn 0.3s ease;
}

/*---------------------- Error ------------------ */
.errorMessage {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: 12px;
}
#errorIcon {
  width: 100px;
  height: 100px;
  max-width: 100%;
  object-fit: contain;
}
.errorMessage p {
  font-size: 15px;
  font-weight: 600;
  margin-top: 4px;
}

/*---------------------- Weather data ------------------ */
.allData {
  display: none;
  padding-top: 24px;
}

.weatherImgAndTemp {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

#countryName {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 15px;
  font-weight: 600;
  color: var(--muted);
  background: var(--soft);
  padding: 6px 16px;
  border-radius: 999px;
}

.weatherImgAndTemp img {
  width: 150px;
  height: 150px;
  object-fit: contain;
  margin: 16px 0 8px;
}

#temp {
  font-size: 56px;
  font-weight: 600;
  line-height: 1;
}

#tempDescription {
  font-size: 16px;
  color: var(--muted);
  text-transform: capitalize;
  margin-top: 8px;
}

.weatherInfo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 24px;
}

.iconAndtype {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 14px 16px;
  background: var(--soft);
  border-radius: 16px;
}

.iconAndtype i {
  font-size: 22px;
  color: var(--accent);
}

.percentage {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.2;
}
.labelone,
.labeltwo {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

/*---------------------- Footer ------------------ */
.weather-footer {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.creator-name {
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  transition: color 0.2s ease;
}
.creator-name:hover {
  color: var(--accent);
}

/*---------------------- Helpers & animations ------------------ */
.hide {
  display: none;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/*---------------------- Small phones ------------------ */
@media (max-width: 400px) {
  .container {
    padding: 18px;
    border-radius: 20px;
  }
  .search {
    gap: 6px;
  }
  .inputWrap {
    padding: 0 12px;
  }
  #clear,
  #searchBtn {
    width: 44px;
    height: 44px;
  }
  .weatherImgAndTemp img {
    width: 120px;
    height: 120px;
  }
  #temp {
    font-size: 48px;
  }
  .weatherInfo {
    gap: 8px;
  }
  .iconAndtype {
    padding: 12px;
    gap: 8px;
  }
}

/*---------------------- Very narrow phones ------------------ */
@media (max-width: 340px) {
  .weatherInfo {
    grid-template-columns: 1fr;
  }
  #temp {
    font-size: 42px;
  }
}

/*---------------------- Tablets ------------------ */
@media (min-width: 640px) {
  .container {
    max-width: 480px;
    padding: 28px;
  }
  #temp {
    font-size: 64px;
  }
  .weatherImgAndTemp img {
    width: 170px;
    height: 170px;
  }
}

/*---------------------- Laptops and large screens ------------------ */
@media (min-width: 1024px) {
  .container {
    max-width: 520px;
    padding: 32px;
  }
  .inputWrap,
  #clear,
  #searchBtn {
    height: 52px;
  }
  #clear,
  #searchBtn {
    width: 52px;
  }
  #temp {
    font-size: 72px;
  }
  .weatherImgAndTemp img {
    width: 190px;
    height: 190px;
  }
  .percentage {
    font-size: 20px;
  }
}

@media (min-width: 1600px) {
  .container {
    max-width: 600px;
  }
}

/*---------------------- Short screens (phones turned sideways) ------------------ */
@media (max-height: 520px) {
  body {
    justify-content: flex-start;
    padding-top: 16px;
    gap: 12px;
  }
  .allData {
    padding-top: 14px;
  }
  .weatherImgAndTemp img {
    width: 80px;
    height: 80px;
    margin: 8px 0 4px;
  }
  #temp {
    font-size: 40px;
  }
  .weatherInfo {
    margin-top: 14px;
  }
  #errorIcon {
    width: 70px;
    height: 70px;
  }
}

/*---------------------- Touch screens: no sticky hover ------------------ */
@media (hover: none) {
  #clear:hover {
    background: var(--soft);
  }
  #searchBtn:hover {
    background: var(--accent);
  }
}

/*---------------------- Respect "reduce motion" ------------------ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
