@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,200..800;1,200..800&display=swap');

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 120%;
  letter-spacing: -.02em;
}

body {
  background-color: #0f172a;
  color: #fff;
  font-family: Plus Jakarta Sans, sans-serif;
  padding: 2rem 1rem 1rem 1rem;
  min-height: 100vh;
}

.bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-image: linear-gradient(to bottom, rgba(15, 23, 42, 0.4), rgba(15, 23, 42, 0.7)), url("imgs/rainforest.jpg");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 0;
    display: block;
    transition: opacity 0.5s ease-in-out;
}

/* --- Form & Header --- */
.main-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
    z-index: 10;
}

.headtext {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: .25rem;
    color: #fff;
}

.headtext h1 {
    font-size: 2.2rem;
    font-weight: 700;
}

.headtext p {
    color: rgba(255, 255, 255, 0.7);
    font-weight: 400;
}

form {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    margin-top: 1rem;
    width: 100%;
}

.input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    max-width: 400px;
}

.input-group label {
    font-size: 1rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.8);
}

.input-group input {
    width: 100%;
    padding: 1.2rem 1.5rem;
    /* Clean, sheer glassmorphism */
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    color: #fff;
    font-family: inherit;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    outline: none;
    text-align: center;
}

.input-group input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.input-group input:focus {
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.1);
}

/* Fix browser autocomplete overriding the transparent background */
.input-group input:-webkit-autofill,
.input-group input:-webkit-autofill:hover, 
.input-group input:-webkit-autofill:focus, 
.input-group input:-webkit-autofill:active {
    transition: background-color 5000s ease-in-out 0s;
    -webkit-text-fill-color: #fff !important;
}

#btn {
    padding: 1rem 3rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    color: white;
    font-family: inherit;
    font-weight: 600;
    font-size: 1.05rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

#btn:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.6);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

#btn:active {
    transform: translateY(0);
}

/* --- Error Message UI --- */
.error-glass {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    margin: 1.5rem auto 0;
    width: 100%;
    max-width: 450px;
    padding: 1rem 1.5rem;
    background: rgba(220, 38, 38, 0.15);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: 16px;
    color: #fca5a5;
    font-weight: 500;
    text-align: center;
    transform: translateY(0);
    opacity: 1;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.error-glass.hidden {
    display: none;
    opacity: 0;
    transform: translateY(-10px);
}

/* --- Loading Spinner UI --- */
.spinner-container {
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 15, 30, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 9999;
    margin: 0;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
}

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

.spinner-container.hidden {
    display: none;
}

.weather-dashboard {
    width: 100%;
    max-width: 900px;
    margin: 2rem auto 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    /* Soft entrance animation */
    animation: fadeIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.weather-header {
    text-align: center;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 2rem;
    border-radius: 32px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.weather-header h2 {
    font-size: 3rem;
    font-weight: 200;
    color: #fff;
    margin-bottom: 0.5rem;
    letter-spacing: -1.5px;
}

.weather-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 400;
    font-size: 1.25rem;
    text-transform: capitalize;
}

.weather-icon {
    color: rgba(255, 255, 255, 0.9);
}

.cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
}

.temp-card, .humidity-card, .pressure-card {
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 32px;
    padding: 2rem;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Glossy highlight sweep effect */
.temp-card::before, .humidity-card::before, .pressure-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.04) 50%, rgba(255, 255, 255, 0) 100%);
    transform: skewX(-25deg);
    transition: all 0.8s ease;
}

.temp-card:hover, .humidity-card:hover, .pressure-card:hover {
    transform: translateY(-6px);
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.3);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.temp-card:hover::before, .humidity-card:hover::before, .pressure-card:hover::before {
    left: 200%;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.icon-box {
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.6);
}

.card-header h3 {
    font-size: 1.05rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

.temp-card-body, .humidity-card-body, .pressure-card-body {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.temp-main-value, .humidity-main-value, .pressure-main-value {
    font-size: 3.8rem;
    font-weight: 200;
    color: #fff;
    line-height: 1;
    letter-spacing: -2px;
}

.temp-main-value span, .humidity-main-value span, .pressure-main-value span {
    font-size: 1.6rem;
    font-weight: 300;
    color: rgba(255, 255, 255, 0.5);
    margin-left: 0.3rem;
    letter-spacing: 0;
}

.temp-sub-value, .humidity-sub-value, .pressure-sub-value {
    font-size: 1.05rem;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 400;
    text-transform: capitalize;
}

/* --- Responsive Adjustments --- */
@media (max-width: 768px) {
    .weather-dashboard {
        margin: 1.5rem auto;
    }
    .weather-header {
        padding: 1.8rem 1.5rem;
        border-radius: 24px;
    }
    .weather-header h2 {
        font-size: 2.4rem;
    }
    .temp-card, .humidity-card, .pressure-card {
        padding: 1.5rem;
        border-radius: 24px;
        gap: 1rem;
    }
    .temp-main-value, .humidity-main-value, .pressure-main-value {
        font-size: 3rem;
    }
    .cards-container {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
        gap: 1rem;
    }
}

@media (max-width: 500px) {
    body {
        padding: 1rem;
    }
    .cards-container {
        grid-template-columns: 1fr; /* Force cards to stack exactly on top of each other */
    }
    .weather-header h2 {
        font-size: 2rem;
    }
    .temp-main-value, .humidity-main-value, .pressure-main-value {
        font-size: 2.8rem;
    }
    .input-group input {
        font-size: 1rem;
    }
    #btn {
        width: 100%; /* Full width button on mobile */
        padding: 1rem;
    }
}