* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--text-color, #1a1a1a);
    overflow-x: hidden;
    transition: background-color 0.5s ease;
}

/* Dynamic background conditions */
body[data-condition="clear-day"] {
    --bg-gradient: linear-gradient(135deg, #87CEEB 0%, #E0F6FF 50%, #FFE5B4 100%);
    --accent: #FF6B6B;
    --card-bg: rgba(255, 255, 255, 0.85);
    --text-color: #1a1a1a;
}

body[data-condition="clear-night"] {
    --bg-gradient: linear-gradient(135deg, #0a1428 0%, #1b2d4d 50%, #2a3f6b 100%);
    --accent: #FFD700;
    --card-bg: rgba(30, 50, 80, 0.8);
    --text-color: #f0f0f0;
}

body[data-condition="cloudy-day"] {
    --bg-gradient: linear-gradient(135deg, #9DA5C0 0%, #C5D3E0 50%, #D3E5F7 100%);
    --accent: #4A90E2;
    --card-bg: rgba(255, 255, 255, 0.8);
    --text-color: #2c3e50;
}

body[data-condition="cloudy-night"] {
    --bg-gradient: linear-gradient(135deg, #1a2847 0%, #2d3e50 50%, #3d4f63 100%);
    --accent: #A8D8EA;
    --card-bg: rgba(40, 60, 90, 0.8);
    --text-color: #e8e8e8;
}

body[data-condition="rain"] {
    --bg-gradient: linear-gradient(135deg, #4A5F7F 0%, #5A7C99 50%, #708FA3 100%);
    --accent: #5DADE2;
    --card-bg: rgba(80, 100, 130, 0.85);
    --text-color: #f5f5f5;
}

body[data-condition="thunderstorm"] {
    --bg-gradient: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    --accent: #FFD60A;
    --card-bg: rgba(20, 40, 70, 0.9);
    --text-color: #f0f0f0;
}

body[data-condition="snow"] {
    --bg-gradient: linear-gradient(135deg, #E8F4F8 0%, #F0F8FF 50%, #D0E8F2 100%);
    --accent: #4FC3F7;
    --card-bg: rgba(240, 250, 255, 0.9);
    --text-color: #2c3e50;
}

body[data-condition="fog"] {
    --bg-gradient: linear-gradient(135deg, #A9A9A9 0%, #C0C0C0 50%, #D3D3D3 100%);
    --accent: #666666;
    --card-bg: rgba(150, 150, 150, 0.8);
    --text-color: #1a1a1a;
}

body {
    background: var(--bg-gradient, linear-gradient(135deg, #87CEEB 0%, #E0F6FF 100%));
    background-attachment: fixed;
    position: relative;
}

/* Animated background layers */
.weather-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    background: inherit;
    pointer-events: none;
}

/* Rain animation */
body[data-condition="rain"]::before,
body[data-condition="thunderstorm"]::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background-image:
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 2px,
            rgba(255, 255, 255, 0.1) 2px,
            rgba(255, 255, 255, 0.1) 4px
        );
    animation: rain-fall 0.5s linear infinite;
    pointer-events: none;
}

@keyframes rain-fall {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100%); }
}

/* Snow animation */
body[data-condition="snow"]::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background-image:
        radial-gradient(2px 2px at 20px 30px, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0)),
        radial-gradient(2px 2px at 60px 70px, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0)),
        radial-gradient(1px 1px at 50px 50px, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0));
    background-repeat: repeat;
    background-size: 200px 200px;
    animation: snow-fall 10s linear infinite;
    pointer-events: none;
}

@keyframes snow-fall {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100%); }
}

/* Stars for night sky */
body[data-condition="clear-night"]::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background-image:
        radial-gradient(1px 1px at 20% 30%, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0)),
        radial-gradient(1px 1px at 60% 70%, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0)),
        radial-gradient(1px 1px at 50% 50%, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0)),
        radial-gradient(1px 1px at 80% 10%, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0)),
        radial-gradient(1px 1px at 90% 60%, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0));
    background-repeat: repeat;
    background-size: 200px 200px;
    animation: twinkle 3s ease-in-out infinite;
    pointer-events: none;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Main content container */
.container {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    min-height: 100vh;
}

/* Header with search */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    position: relative;
}

.location-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.location-form button {
    background: transparent;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    transition: transform 0.2s;
}

.location-form button:hover {
    transform: scale(1.1);
}

.location-form input {
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-color);
    font-size: 1rem;
    min-width: 200px;
    backdrop-filter: blur(12px);
}

.location-form input::placeholder {
    color: rgba(var(--text-color-rgb), 0.6);
}

/* Alerts banner */
.alerts-container {
    margin-bottom: 1.5rem;
}

.alert {
    background: rgba(255, 107, 107, 0.9);
    color: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    backdrop-filter: blur(12px);
    border-left: 4px solid #FF6B6B;
}

.alert-title {
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.alert-period {
    font-size: 0.9rem;
    opacity: 0.9;
}

.alert-description {
    font-size: 0.95rem;
    margin-top: 0.75rem;
    line-height: 1.5;
}

/* Alert badge on hero card */
.current-alerts {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-self: flex-start;
    min-width: 150px;
}

.alert-badge {
    background: rgba(255, 107, 107, 0.9);
    color: white;
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    line-height: 1.3;
    border-left: 3px solid #FF6B6B;
}

/* Current conditions hero */
.current-hero {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 1.5rem;
    align-items: center;
}

.current-icon {
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.current-icon img {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.current-info h1 {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    margin: 0 0 0.25rem 0;
    color: var(--text-color);
}

.current-description {
    font-size: clamp(0.85rem, 2.5vw, 1.1rem);
    color: rgba(var(--text-color-rgb), 0.8);
    margin-bottom: 0.5rem;
}

.current-temp {
    font-size: clamp(2.5rem, 8vw, 3.5rem);
    font-weight: bold;
    color: var(--accent);
    line-height: 1;
}

/* Current detail strip */
.current-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.detail-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.detail-label {
    font-size: 0.85rem;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--accent);
}

.detail-subvalue {
    font-size: 0.9rem;
    opacity: 0.8;
}

/* UV Index color coding */
.uvi-low { color: #4CAF50; }
.uvi-moderate { color: #FFC107; }
.uvi-high { color: #FF9800; }
.uvi-very-high { color: #F44336; }
.uvi-extreme { color: #9C27B0; }

/* AQI card */
.aqi-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.aqi-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.aqi-label {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.aqi-bar {
    height: 8px;
    background: linear-gradient(90deg, #4CAF50 0%, #FFC107 25%, #FF9800 50%, #F44336 75%, #8B0000 100%);
    border-radius: 4px;
    margin-bottom: 1rem;
}

.pollutants {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 1rem;
    font-size: 0.9rem;
}

.pollutant {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.pollutant-label {
    opacity: 0.7;
    font-size: 0.8rem;
}

.pollutant-value {
    font-weight: 600;
    color: var(--accent);
}

/* Hourly chart */
.hourly-section {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

#hourlyChart {
    max-height: 300px;
}

/* Daily forecast cards */
.forecast-section {
    margin-bottom: 2rem;
}

.forecast-container {
    display: flex;
    overflow-x: auto;
    gap: 1rem;
    scroll-snap-type: x mandatory;
    padding-bottom: 1rem;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.forecast-container::-webkit-scrollbar {
    height: 6px;
}

.forecast-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.forecast-container::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
}

.forecast-card {
    flex: 1 1 auto;
    min-width: 90px;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border-radius: 8px;
    padding: 0.75rem 0.5rem;
    text-align: center;
    scroll-snap-align: start;
    transition: transform 0.2s, box-shadow 0.2s;
}

.forecast-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.forecast-day {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.forecast-icon {
    width: 48px;
    height: 48px;
    margin: 0.4rem auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.forecast-icon img {
    width: 100%;
    height: 100%;
}

.forecast-temps {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
}

.forecast-high {
    color: var(--accent);
}

.forecast-low {
    opacity: 0.7;
}

.forecast-pop {
    font-size: 0.7rem;
    opacity: 0.8;
    margin-bottom: 0.3rem;
}

.forecast-precip {
    font-size: 0.65rem;
    opacity: 0.7;
    line-height: 1.2;
}

/* Moon phase section */
.moon-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.moon-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    text-align: center;
}

.moon-icon {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    margin-bottom: 0.25rem;
}

.moon-label {
    font-size: 0.8rem;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.moon-time {
    font-size: 1rem;
    font-weight: 600;
}

/* Footer */
footer {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 3rem;
    text-align: center;
    font-size: 0.85rem;
    opacity: 0.8;
}

footer a {
    color: var(--accent);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Responsive: Mobile */
@media (max-width: 640px) {
    .container {
        padding: 1rem 0.75rem;
    }

    header {
        flex-direction: column;
        gap: 1rem;
        margin-bottom: 1rem;
    }

    .location-form {
        width: 100%;
        justify-content: stretch;
    }

    .location-form input {
        min-width: 100%;
        flex: 1;
    }

    .current-hero {
        grid-template-columns: auto 1fr;
        text-align: left;
        gap: 1rem;
    }

    .current-icon {
        width: 90px;
        height: 90px;
    }

    .current-alerts {
        display: none;
    }

    .moon-section {
        grid-template-columns: 1fr;
    }

    .forecast-card {
        flex: 0 0 100px;
    }

}

/* Responsive: Tablet */
@media (min-width: 641px) and (max-width: 1024px) {
    .current-details {
        grid-template-columns: repeat(3, 1fr);
    }

    .forecast-card {
        flex: 0 0 130px;
    }
}

/* Responsive: Desktop */
@media (min-width: 1025px) {
    .current-hero {
        grid-template-columns: 150px 1fr;
        gap: 3rem;
    }

    .current-icon {
        width: 150px;
        height: 150px;
    }

    .current-details {
        grid-template-columns: repeat(3, 1fr);
    }

    .forecast-container {
        display: flex;
        overflow-x: visible;
        gap: 0.75rem;
        padding-bottom: 0.5rem;
    }

    .forecast-card {
        flex: 1 1 auto;
        min-width: 90px;
    }

    .moon-section {
        grid-template-columns: 100px 1fr;
        gap: 2rem;
    }
}

/* Loading state */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.skeleton {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.1) 25%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.1) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
