:root {
    /* Max widths and font sizes for responsive scaling */
    --card-max-width: 420px;
    --form-max-width: 420px;
    --input-font-size: clamp(1.2rem, 2vw, 2rem);
    --button-font-size: clamp(1.2rem, 2vw, 2rem);
    --title-font-size: clamp(2rem, 4vw, 3.5rem);
    --subtitle-font-size: clamp(1rem, 2.2vw, 1.5rem);
    --card-padding: clamp(20px, 4vw, 50px);
}

/* === Reset & Base === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Base styles and layout for body */
body {
    font-family: Arial, sans-serif;
    background-color: hsl(0, 0%, 95%);
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    transition: background 0.5s ease, color 0.5s ease;
}

/* === Theme Classes === */
/* Light mode background animation and text color */
body.light-mode {
    background: linear-gradient(-45deg, #83a4d4, #b6fbff, #d4fc79, #96e6a1);
    background-size: 400% 400%;
    animation: gradientMove 15s ease infinite;
    color: #222;
}

/* Dark mode background animation and text color */
body.dark-mode {
    background: linear-gradient(-45deg, #0f2027, #203a43, #2c5364, #1a1a1a);
    background-size: 400% 400%;
    animation: gradientMove 15s ease infinite;
    color: #f0f0f0;
}

/* Gradient animation keyframes */
@keyframes gradientMove {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Light and dark mode backgrounds for form and card */
body.light-mode .card,
body.light-mode .weatherForm {
    background: rgba(255, 255, 255, 0.3);
}

body.dark-mode .card,
body.dark-mode .weatherForm {
    background: rgba(255, 255, 255, 0.05);
}

/* Dark mode input styling */
body.dark-mode .cityInput {
    background: #2c3e50;
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.15);
}

/* Dark mode button styles */
body.dark-mode .weatherForm button {
    background-color: #1e90ff;
}

body.dark-mode .weatherForm button:hover {
    background-color: #1c86ee;
}

/* === Theme Toggle Switch === */
/* Position and size of toggle */
.themeToggle {
    position: fixed;
    top: 15px;
    right: 20px;
    z-index: 1100;
    width: 60px;
    height: 30px;
}

/* Hide the native checkbox input */
.themeToggle input {
    display: none;
}

/* Toggle background styling */
.themeToggle .switch {
    width: 100%;
    height: 100%;
    background: #ccc;
    border-radius: 50px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s ease;
}

/* Toggle background when checked */
.themeToggle input:checked + .switch {
    background: #4a90e2;
}

/* Thumb (circle) inside toggle */
.themeToggle .thumb {
    width: 26px;
    height: 26px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: transform 0.3s ease;
}

/* Thumb moves when toggle is checked */
.themeToggle input:checked + .switch .thumb {
    transform: translateX(30px);
}

/* Sun and moon icons inside toggle */
.themeToggle .sun,
.themeToggle .moon {
    position: absolute;
    font-size: 16px;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}

/* Sun icon visible by default */
.sun {
    opacity: 1;
    transform: scale(1);
}

/* Moon icon hidden by default */
.moon {
    opacity: 0;
    transform: scale(0.7);
}

/* Toggle icons visibility swap on checked */
.themeToggle input:checked + .switch .sun {
    opacity: 0;
    transform: scale(0.7);
}

.themeToggle input:checked + .switch .moon {
    opacity: 1;
    transform: scale(1);
}

/* === Title === */
/* Fixed header styling */
.appHeader {
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    text-align: center;
    padding: 10px 0;
    backdrop-filter: blur(12px);
    background: rgba(255, 255, 255, 0.3);
    z-index: 1000;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: inset 0 -1px 2px rgba(255, 255, 255, 0.3),
        0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Title and subtitle font sizes */
.appTitle {
    font-size: var(--title-font-size);
    font-weight: bold;
    color: inherit;
}

.appSubtitle {
    font-size: var(--subtitle-font-size);
    color: inherit;
    opacity: 0.7;
}

/* === Weather Form === */
.weatherForm {
    margin: 20px;
    margin-top: 120px; /* space for fixed header */
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: var(--form-max-width);
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(12px);
    padding: 16px;
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: all 0.3s ease;
}

/* Input styling */
.cityInput {
    padding: 10px 14px;
    font-size: var(--input-font-size);
    font-weight: bold;
    border: 2px solid hsla(0, 0%, 20%, 0.3);
    border-radius: 10px;
    background: white;
    color: #222;
    width: 100%;
}

/* Submit button styling */
button[type="submit"] {
    padding: 10px 20px;
    font-weight: bold;
    font-size: var(--button-font-size);
    background-color: hsl(122, 39%, 50%);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

/* Submit button hover effect */
button[type="submit"]:hover {
    background-color: hsl(122, 39%, 40%);
    transform: scale(1.05);
}

/* === Weather Card === */
/* Card container styling and animation */
.card {
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(12px);
    padding: var(--card-padding);
    margin-top: 120px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 15px;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
    box-sizing: border-box;
    width: 100%;
    max-width: var(--card-max-width);
    min-width: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: background 0.3s ease, color 0.3s ease, transform 0.4s ease;
    animation: fadeInScale 0.5s ease forwards;
}

/* Fade and scale animation keyframes */
@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Headings and paragraph spacing */
h1 {
    margin-top: 0;
    margin-bottom: 25px;
}

p {
    font-size: 1.5rem;
    margin: 5px 0;
}

/* Specific weather info text styles */
.cityDisplay,
.tempDisplay {
    font-size: 3.5rem;
    font-weight: bold;
    color: hsla(0, 0%, 0%, 0.8);
    margin-bottom: 25px;
}

.humidityDisplay {
    font-weight: bold;
    margin-bottom: 25px;
}

.descDisplay {
    font-style: italic;
    font-weight: bold;
    font-size: 2rem;
}

/* Weather icon style */
.weatherEmoji {
    width: 100px;
    height: 100px;
    object-fit: contain;
    margin: 10px 0;
}

/* Error message styling */
.errorDisplay {
    font-size: 2.5rem;
    font-weight: bold;
    color: hsla(0, 0%, 0%, 0.75);
}

/* === Forecast Container === */
.forecastContainer {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 12px;
    margin-top: 20px;
    width: 100%;
}

/* Individual forecast item styling */
.forecastItem {
    flex: 1 1 75px;
    max-width: 80px;
    min-width: 60px;
    text-align: center;
    background: rgba(255, 255, 255, 0.2);
    padding: 6px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease;
}

/* Forecast item hover scaling */
.forecastItem:hover {
    transform: scale(1.05);
}

/* Forecast icons */
.forecastItem img {
    width: 40px;
    height: 40px;
    margin: 4px 0;
}

/* Forecast text */
.forecastItem p {
    font-size: 0.9rem;
    margin: 2px 0;
    line-height: 1.2;
}

/* Day separator styling in forecast */
.daySeparator {
  width: 100%;
  font-weight: bold;
  font-size: 1.2rem;
  margin: 12px 0 6px 0;
  color: #b3b3b3;
  border-bottom: 1px solid rgba(0,0,0,0.1);
  padding-bottom: 4px;
}

/* === Responsive Styling === */
@media (max-width: 500px) {
  .forecastContainer {
    justify-content: center;
    gap: 12px;
  }

  .forecastItem {
    flex: 1 1 40%;
    max-width: 45%;
  }
}

@media (min-width: 600px) {
    .weatherForm {
        flex-direction: row;
        justify-content: center;
        align-items: center;
    }

    .cityInput {
        flex: 1;
        margin-right: 10px;
    }

    .weatherForm button {
        width: auto;
    }
}

@media (max-width: 400px) {
    .appTitle {
        font-size: 2rem;
    }

    .appSubtitle {
        font-size: 0.95rem;
    }

    .cityInput,
    .weatherForm button {
        font-size: 1.2rem;
        padding: 8px;
    }

    .card {
        padding: 20px;
    }

    .themeToggle {
        top: 10px;
        right: 10px;
        transform: scale(0.9);
    }
}

@media (max-width: 480px) {
    .weatherForm {
        flex-direction: column;
    }

    .themeToggle {
        top: 10px;
        right: 10px;
        transform: scale(0.9);
    }
}

@media (min-width: 481px) and (max-width: 767px) {
    .weatherForm {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .weatherForm {
        max-width: 600px;
    }

    .card {
        max-width: 600px;
    }
}

@media (min-width: 1024px) {
    .weatherForm {
        max-width: 800px;
        margin-top: 150px ;
    }

    .card {
        max-width: 800px;
    }
}

/* === Animations === */
/* Fade in and slide up for smoother UI */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Footer styling */
.footer {
    margin-top: auto;
    padding: 10px;
    font-size: 0.9rem;
    color: inherit;
    opacity: 0.6;
    text-align: center;
}
/* Light Theme */
.light-mode .footer a,
.light-mode .footer a:visited,
.light-mode .footer a:active {
  color: #1e40af;
  text-decoration: none;
  transition: color 0.3s ease, text-decoration 0.3s ease;
}
.light-mode .footer a:hover,
.light-mode .footer a:focus {
  color: #1d4ed8;
  text-decoration: underline;
}
/* Dark Theme */
.dark-mode .footer a,
.dark-mode .footer a:visited,
.dark-mode .footer a:active {
  color: #60a5fa;
  text-decoration: none;
  transition: color 0.3s ease, text-decoration 0.3s ease;
}
.dark-mode .footer a:hover,
.dark-mode .footer a:focus {
  color: #93c5fd;
  text-decoration: underline;
}

/* Loader spinner styles */
.loader {
    border: 6px solid rgba(0, 0, 0, 0.1);
    border-top: 6px solid hsl(122, 39%, 50%);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

/* Spin animation for loader */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Time and Date display container */
.timeDateDisplay {
    margin-top: 20px;
    text-align: center;
    background: rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(12px);
    padding: 10px 20px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    font-weight: bold;
    font-size: 1.2rem;
    color: inherit;
    transition: all 0.3s ease;
}

/* Dark mode style for time and date */
body.dark-mode .timeDateDisplay {
    background: rgba(255, 255, 255, 0.05);
    color: #f0f0f0;
}
