/* ===== CSS RESET & VARIABLES ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --font: 'Quicksand', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Dynamic palette — updated by JS based on weather, default to light sky */
    --bg-start: #e0f2fe;
    --bg-mid: #bae6fd;
    --bg-end: #7dd3fc;

    --glass-bg: rgba(255, 255, 255, 0.65);
    --glass-border: rgba(255, 255, 255, 0.9);
    --glass-hover: rgba(255, 255, 255, 0.85);

    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;

    --accent: #0284c7;
    --accent-glow: rgba(2, 132, 199, 0.15);

    --radius-sm: 12px;
    --radius-md: 18px;
    --radius-lg: 24px;
    --radius-xl: 32px;

    --shadow: 0 8px 32px rgba(0, 0, 0, 0.08); /* Much softer shadow */
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ===== APP CONTAINER & BACKGROUND ===== */
.app-container {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--bg-start), var(--bg-mid), var(--bg-end));
    transition: background 1.2s ease;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Floating particles */
.particles {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.particle {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    animation: floatUp linear infinite;
}

@keyframes floatUp {
    0% {
        transform: translateY(100vh) scale(0);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-10vh) scale(1);
        opacity: 0;
    }
}

/* ===== HEADER ===== */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid var(--glass-border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text-primary);
    flex-shrink: 0;
}

.logo-icon {
    width: 28px;
    height: 28px;
    color: var(--accent);
    animation: spin 12s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    padding: 6px 8px 6px 16px;
    gap: 8px;
    width: 100%;
    max-width: 420px;
    transition: var(--transition);
}

.search-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: rgba(255, 255, 255, 0.1);
}

.search-icon {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.95rem;
    min-width: 0;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

#search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition);
}

#search-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 16px var(--accent-glow);
}

#search-btn svg {
    width: 18px;
    height: 18px;
}

/* ===== API KEY MODAL ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: fadeIn 0.4s ease;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: linear-gradient(145deg, rgba(40, 38, 70, 0.95), rgba(20, 18, 45, 0.98));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    max-width: 440px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow);
    animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.modal h2 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 8px;
}

.modal p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 24px;
    line-height: 1.6;
}

.modal input {
    width: 100%;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.95rem;
    outline: none;
    margin-bottom: 16px;
    transition: var(--transition);
}

.modal input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.modal input::placeholder {
    color: var(--text-muted);
}

.modal button {
    width: 100%;
    padding: 14px;
    border-radius: var(--radius-sm);
    border: none;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    color: #fff;
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.modal button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--accent-glow);
}

.modal-hint {
    display: block;
    margin-top: 14px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ===== MAIN CONTENT ===== */
.main-content {
    flex: 1;
    position: relative;
    z-index: 1;
    padding: 32px;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
}

/* Welcome State */
.welcome-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 50vh;
    animation: fadeIn 0.8s ease;
}

.welcome-icon-wrapper {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 28px;
    animation: pulse 3s ease-in-out infinite;
}

.welcome-icon {
    width: 50px;
    height: 50px;
    color: var(--accent);
}

@keyframes pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 var(--accent-glow); }
    50% { transform: scale(1.05); box-shadow: 0 0 30px 8px var(--accent-glow); }
}

.welcome-state h1 {
    font-size: 2.2rem;
    font-weight: 800;
    letter-spacing: -1px;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #fff, rgba(255,255,255,0.6));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-state p {
    color: var(--text-secondary);
    font-size: 1.05rem;
    max-width: 420px;
    line-height: 1.7;
}

/* Loading */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    gap: 20px;
    animation: fadeIn 0.3s ease;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--glass-border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-state p {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Error */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    text-align: center;
    gap: 12px;
    animation: fadeIn 0.4s ease;
}

.error-icon {
    font-size: 3rem;
}

.error-state h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.error-state p {
    color: var(--text-secondary);
    max-width: 400px;
    line-height: 1.6;
}

/* Hidden */
.hidden {
    display: none !important;
}

/* ===== WEATHER CONTENT ===== */
.weather-content {
    animation: fadeIn 0.6s ease;
}

/* Hero Card */
.hero-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-xl);
    padding: 40px 48px;
    margin-bottom: 24px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
    overflow: hidden;
    position: relative;
}

.hero-card::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, var(--accent-glow), transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

.hero-left {
    position: relative;
    z-index: 1;
}

.location-info h1 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin-bottom: 2px;
}

.location-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.temp-display {
    display: flex;
    align-items: flex-start;
    margin: 16px 0 12px;
}

.temp-value {
    font-size: 5rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -3px;
    background: linear-gradient(180deg, #ffffff, rgba(255,255,255,0.7));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.temp-unit {
    font-size: 1.8rem;
    font-weight: 300;
    margin-top: 8px;
    color: var(--text-secondary);
}

.condition-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.condition-row img {
    width: 36px;
    height: 36px;
}

.condition-row span {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.last-updated {
    margin-top: 12px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.hero-right {
    position: relative;
    z-index: 1;
}

.hero-weather-icon {
    width: 140px;
    height: 140px;
    object-fit: contain;
    filter: drop-shadow(0 8px 24px rgba(0,0,0,0.3));
    animation: bobble 4s ease-in-out infinite;
}

@keyframes bobble {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

/* ===== STATS GRID ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 20px 22px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: var(--transition);
}

.stat-card:hover {
    background: var(--glass-hover);
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
}

.stat-icon {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: var(--radius-sm);
    background: rgba(108, 99, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon svg {
    width: 22px;
    height: 22px;
    color: var(--accent);
}

.stat-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.stat-value {
    font-size: 1.15rem;
    font-weight: 700;
}

/* ===== SECTIONS ===== */
.section-block {
    margin-bottom: 32px;
}

.section-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 16px;
    letter-spacing: -0.3px;
}

/* Hourly Scroll */
.hourly-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    scroll-snap-type: x mandatory;
    -ms-overflow-style: none;
    scrollbar-width: thin;
    scrollbar-color: var(--glass-border) transparent;
}

.hourly-scroll::-webkit-scrollbar {
    height: 6px;
}

.hourly-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.hourly-scroll::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 3px;
}

.hourly-card {
    flex: 0 0 auto;
    width: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 18px 12px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    scroll-snap-align: start;
    transition: var(--transition);
    cursor: default;
}

.hourly-card.now {
    background: rgba(108, 99, 255, 0.2);
    border-color: var(--accent);
}

.hourly-card:hover {
    background: var(--glass-hover);
    transform: translateY(-3px);
}

.hourly-time {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.hourly-card img {
    width: 36px;
    height: 36px;
}

.hourly-temp {
    font-size: 1rem;
    font-weight: 700;
}

.hourly-rain {
    font-size: 0.7rem;
    color: #60a5fa;
    font-weight: 500;
}

/* Forecast Grid */
.forecast-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.forecast-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 24px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: var(--transition);
}

.forecast-card:hover {
    background: var(--glass-hover);
    transform: translateX(4px);
}

.forecast-day {
    width: 100px;
    font-size: 0.95rem;
    font-weight: 600;
    flex-shrink: 0;
}

.forecast-card img {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.forecast-condition {
    flex: 1;
    font-size: 0.88rem;
    color: var(--text-secondary);
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.forecast-rain {
    font-size: 0.82rem;
    color: #60a5fa;
    font-weight: 500;
    width: 50px;
    text-align: center;
    flex-shrink: 0;
}

.forecast-temps {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.forecast-high {
    font-size: 1rem;
    font-weight: 700;
}

.forecast-low {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Sun & Moon */
.sun-moon-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.sun-moon-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 24px 16px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    text-align: center;
    transition: var(--transition);
}

.sun-moon-card:hover {
    background: var(--glass-hover);
    transform: translateY(-3px);
}

.sun-moon-icon {
    font-size: 1.8rem;
}

.sun-moon-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.sun-moon-value {
    font-size: 1.05rem;
    font-weight: 700;
}

/* ===== FOOTER ===== */
.footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 24px;
    font-size: 0.82rem;
    color: var(--text-muted);
    border-top: 1px solid var(--glass-border);
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* stagger children */
.weather-content > *:nth-child(1) { animation: slideUp 0.5s ease both; animation-delay: 0s; }
.weather-content > *:nth-child(2) { animation: slideUp 0.5s ease both; animation-delay: 0.08s; }
.weather-content > *:nth-child(3) { animation: slideUp 0.5s ease both; animation-delay: 0.16s; }
.weather-content > *:nth-child(4) { animation: slideUp 0.5s ease both; animation-delay: 0.24s; }
.weather-content > *:nth-child(5) { animation: slideUp 0.5s ease both; animation-delay: 0.32s; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 12px;
        padding: 14px 18px;
    }

    .search-box {
        max-width: 100%;
    }

    .main-content {
        padding: 20px 16px;
    }

    .hero-card {
        flex-direction: column;
        text-align: center;
        padding: 32px 24px;
        gap: 16px;
    }

    .hero-card::before {
        top: -30%;
        right: -30%;
    }

    .hero-right {
        order: -1;
    }

    .hero-weather-icon {
        width: 100px;
        height: 100px;
    }

    .temp-display {
        justify-content: center;
    }

    .condition-row {
        justify-content: center;
    }

    .temp-value {
        font-size: 3.8rem;
    }

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

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

    .forecast-condition {
        display: none;
    }

    .welcome-state h1 {
        font-size: 1.6rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .forecast-card {
        padding: 14px 16px;
        gap: 10px;
    }

    .forecast-day {
        width: 70px;
        font-size: 0.85rem;
    }
}
