/* CSS Variables for Theming */
:root {
    /* Day colors */
    --day-gradient-start: #87CEEB;
    --day-gradient-end: #4A90D9;

    /* Night colors */
    --night-gradient-start: #1a1a2e;
    --night-gradient-end: #16213e;

    /* Dawn/Dusk colors */
    --dawn-gradient-start: #FF6B6B;
    --dawn-gradient-mid: #FFE66D;
    --dawn-gradient-end: #4ECDC4;

    --dusk-gradient-start: #2C3E50;
    --dusk-gradient-mid: #E74C3C;
    --dusk-gradient-end: #F39C12;

    /* Glass effect */
    --glass-bg: rgba(255, 255, 255, 0.15);
    --glass-border: rgba(255, 255, 255, 0.25);
    --glass-shadow: rgba(0, 0, 0, 0.1);

    /* Text colors */
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.8);
    --text-muted: rgba(255, 255, 255, 0.6);

    /* Accent colors */
    --accent-sun: #FFD93D;
    --accent-moon: #E8E8E8;
    --accent-cloud: rgba(255, 255, 255, 0.9);
}

/* Reset and Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    color: var(--text-primary);
    line-height: 1.6;
}

/* Dynamic Background */
.background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background: linear-gradient(135deg, var(--day-gradient-start), var(--day-gradient-end));
    transition: background 1.5s ease;
}

body.night .background {
    background: linear-gradient(135deg, var(--night-gradient-start), var(--night-gradient-end));
}

body.dawn .background {
    background: linear-gradient(135deg, var(--dawn-gradient-start), var(--dawn-gradient-mid), var(--dawn-gradient-end));
}

body.dusk .background {
    background: linear-gradient(135deg, var(--dusk-gradient-start), var(--dusk-gradient-mid), var(--dusk-gradient-end));
}

/* Stars (visible at night) */
.stars {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(2px 2px at 20px 30px, white, transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 90px 40px, white, transparent),
        radial-gradient(2px 2px at 160px 120px, rgba(255,255,255,0.9), transparent),
        radial-gradient(1px 1px at 230px 80px, white, transparent),
        radial-gradient(2px 2px at 300px 150px, rgba(255,255,255,0.7), transparent),
        radial-gradient(1px 1px at 350px 200px, white, transparent),
        radial-gradient(2px 2px at 420px 50px, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 480px 180px, white, transparent),
        radial-gradient(2px 2px at 550px 90px, rgba(255,255,255,0.9), transparent);
    background-repeat: repeat;
    background-size: 600px 300px;
    opacity: 0;
    transition: opacity 1.5s ease;
}

body.night .stars {
    opacity: 1;
    animation: twinkle 4s ease-in-out infinite alternate;
}

@keyframes twinkle {
    0% { opacity: 0.7; }
    100% { opacity: 1; }
}

/* Floating Clouds */
.clouds {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
    opacity: 0.8;
}

body.night .clouds {
    opacity: 0.3;
}

.cloud {
    position: absolute;
    background: var(--accent-cloud);
    border-radius: 50%;
    filter: blur(2px);
}

.cloud::before,
.cloud::after {
    content: '';
    position: absolute;
    background: inherit;
    border-radius: inherit;
}

.cloud-1 {
    width: 100px;
    height: 40px;
    top: 10%;
    left: -150px;
    animation: float-cloud 35s linear infinite;
}

.cloud-1::before {
    width: 50px;
    height: 50px;
    top: -25px;
    left: 15px;
}

.cloud-1::after {
    width: 60px;
    height: 60px;
    top: -35px;
    left: 40px;
}

.cloud-2 {
    width: 120px;
    height: 50px;
    top: 25%;
    left: -180px;
    animation: float-cloud 45s linear infinite;
    animation-delay: -15s;
}

.cloud-2::before {
    width: 60px;
    height: 60px;
    top: -30px;
    left: 20px;
}

.cloud-2::after {
    width: 70px;
    height: 70px;
    top: -40px;
    left: 50px;
}

.cloud-3 {
    width: 80px;
    height: 35px;
    top: 50%;
    left: -130px;
    animation: float-cloud 40s linear infinite;
    animation-delay: -25s;
}

.cloud-3::before {
    width: 45px;
    height: 45px;
    top: -22px;
    left: 10px;
}

.cloud-3::after {
    width: 55px;
    height: 55px;
    top: -30px;
    left: 35px;
}

@keyframes float-cloud {
    from { transform: translateX(0); }
    to { transform: translateX(calc(100vw + 200px)); }
}

/* Container */
.container {
    width: 100%;
    max-width: 600px;
    height: 100%;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: max-width 0.3s ease;
}

/* Glassmorphism Cards */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.25rem;
    box-shadow: 0 8px 32px var(--glass-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    flex-shrink: 0;
}

.glass-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

/* Search Section */
.search-section {
    text-align: center;
}

.search-wrapper {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

#city-input {
    flex: 1;
    padding: 0.875rem 1.25rem;
    border: 1px solid var(--glass-border);
    border-radius: 50px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
}

#city-input::placeholder {
    color: var(--text-muted);
}

#city-input:focus {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.icon-btn {
    width: 48px;
    height: 48px;
    border: 1px solid var(--glass-border);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.icon-btn:active {
    transform: scale(0.95);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

.location-name {
    font-size: 1.25rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 2rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--glass-border);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 1s linear infinite;
}

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

/* Error State */
.error-message {
    text-align: center;
    padding: 2rem;
    background: rgba(231, 76, 60, 0.2);
    border-radius: 15px;
    color: #ff6b6b;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.error-message svg {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
}

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

/* Weather Content */
.weather-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex: 1;
    min-height: 0;
    animation: fadeIn 0.5s ease;
}

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

/* Weather Card */
.weather-card {
    text-align: center;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.weather-primary {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.weather-main {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 0.5rem;
}

.temperature-display {
    display: flex;
    align-items: flex-start;
}

.temperature {
    font-size: 5rem;
    font-weight: 300;
    line-height: 1;
}

.temp-unit {
    font-size: 1.5rem;
    font-weight: 400;
    margin-top: 0.5rem;
}

.weather-icon {
    width: 80px;
    height: 80px;
}

.weather-icon svg {
    width: 100%;
    height: 100%;
}

.weather-description {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    text-transform: capitalize;
}

.weather-details {
    display: flex;
    justify-content: center;
    gap: 3rem;
    padding-top: 1rem;
    border-top: 1px solid var(--glass-border);
}

.detail-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.detail-item svg {
    width: 24px;
    height: 24px;
    color: var(--text-muted);
}

.detail-item span:not(.detail-label) {
    font-size: 1.25rem;
    font-weight: 500;
}

.detail-label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Hourly Forecast */
.hourly-card {
    flex-shrink: 0;
}

.hourly-card .card-title {
    justify-content: center;
}

.hourly-scroll {
    overflow-x: auto;
    margin: 0 -0.5rem;
    padding: 0 0.5rem;
    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-forecast {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding-bottom: 0.5rem;
}

.hourly-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.375rem;
    padding: 0.625rem 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    min-width: 65px;
    transition: background 0.2s ease, transform 0.2s ease;
}

.hourly-item:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.hourly-item.current {
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

.hourly-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.hourly-item.current .hourly-time {
    color: var(--text-primary);
}

.hourly-icon {
    width: 28px;
    height: 28px;
}

.hourly-icon svg {
    width: 100%;
    height: 100%;
}

.hourly-temp {
    font-size: 0.9rem;
    font-weight: 600;
}

/* Astro Row (Sun & Moon) */
.astro-row {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.astro-row .glass-card {
    flex: 1;
}

/* Sun Card */
.card-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.card-title svg {
    width: 20px;
    height: 20px;
}

.sun-timeline {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sun-time {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    min-width: 70px;
}

.sun-time svg {
    width: 28px;
    height: 28px;
    color: var(--accent-sun);
}

.time-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.time-value {
    font-size: 1rem;
    font-weight: 500;
}

.timeline-bar {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    position: relative;
    overflow: visible;
}

.timeline-progress {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-sun), #FF8C00);
    border-radius: 4px;
    width: 0%;
    transition: width 1s ease;
}

.sun-indicator {
    position: absolute;
    width: 20px;
    height: 20px;
    background: var(--accent-sun);
    border-radius: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    left: 0%;
    box-shadow: 0 0 15px var(--accent-sun);
    transition: left 1s ease;
}

/* Moon Card */
.moon-display {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.moon-graphic {
    flex-shrink: 0;
}

.moon-sphere {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, #E8E8E8 0%, #C0C0C0 50%, #A0A0A0 100%);
    position: relative;
    overflow: hidden;
    box-shadow:
        inset -10px -10px 20px rgba(0, 0, 0, 0.3),
        inset 5px 5px 15px rgba(255, 255, 255, 0.2),
        0 0 30px rgba(255, 255, 255, 0.2);
}

.moon-shadow {
    position: absolute;
    width: 100%;
    height: 100%;
    background: #1a1a2e;
    transition: transform 0.5s ease, border-radius 0.5s ease;
}

/* Moon phase shadows - controlled via JS */
.moon-shadow.new-moon {
    transform: translateX(0);
    border-radius: 50%;
}

.moon-shadow.waxing-crescent {
    transform: translateX(-30%);
    border-radius: 50% 0 0 50% / 50% 0 0 50%;
}

.moon-shadow.first-quarter {
    transform: translateX(-50%);
    border-radius: 0;
}

.moon-shadow.waxing-gibbous {
    transform: translateX(-70%);
    border-radius: 0 50% 50% 0 / 0 50% 50% 0;
}

.moon-shadow.full-moon {
    transform: translateX(-100%);
}

.moon-shadow.waning-gibbous {
    transform: translateX(70%);
    border-radius: 50% 0 0 50% / 50% 0 0 50%;
}

.moon-shadow.last-quarter {
    transform: translateX(50%);
    border-radius: 0;
}

.moon-shadow.waning-crescent {
    transform: translateX(30%);
    border-radius: 0 50% 50% 0 / 0 50% 50% 0;
}

.moon-info {
    text-align: left;
}

.moon-phase-name {
    font-size: 1.25rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.moon-illumination {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Weather Icons */
.weather-icon-sun {
    fill: var(--accent-sun);
    filter: drop-shadow(0 0 10px var(--accent-sun));
}

.weather-icon-cloud {
    fill: var(--accent-cloud);
}

.weather-icon-rain {
    fill: #74b9ff;
}

.weather-icon-snow {
    fill: #dfe6e9;
}

.weather-icon-storm {
    fill: #636e72;
}

/* Responsive Design */
@media (max-width: 480px) {
    .container {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .glass-card {
        padding: 1rem;
    }

    .temperature {
        font-size: 3.5rem;
    }

    .weather-icon {
        width: 50px;
        height: 50px;
    }

    .weather-details {
        gap: 2rem;
    }

    .sun-timeline {
        flex-wrap: wrap;
        justify-content: center;
    }

    .timeline-bar {
        order: 3;
        width: 100%;
        margin-top: 0.75rem;
    }

    .moon-display {
        flex-direction: row;
        gap: 1rem;
    }

    .moon-sphere {
        width: 70px;
        height: 70px;
    }

    .moon-info {
        text-align: left;
    }

    .card-title {
        margin-bottom: 0.75rem;
    }

    .hourly-item {
        min-width: 55px;
        padding: 0.5rem;
    }

    .hourly-icon {
        width: 24px;
        height: 24px;
    }

    .hourly-temp {
        font-size: 0.8rem;
    }
}

/* Fluid layout for low height - shift to horizontal */
@media (max-height: 700px) and (min-width: 600px) {
    .container {
        max-width: 900px;
        padding: 1rem;
        gap: 0.75rem;
    }

    .glass-card {
        padding: 1rem;
        border-radius: 15px;
    }

    /* Search becomes more compact */
    .search-section {
        padding: 0.75rem 1rem;
    }

    .search-wrapper {
        margin-bottom: 0.5rem;
    }

    .location-name {
        font-size: 1rem;
    }

    /* Weather card horizontal layout */
    .weather-card {
        flex-direction: row;
        align-items: center;
        justify-content: space-around;
        gap: 2rem;
        text-align: left;
    }

    .weather-primary {
        align-items: flex-start;
    }

    .weather-main {
        margin-bottom: 0.25rem;
        justify-content: flex-start;
    }

    .temperature {
        font-size: 4rem;
    }

    .weather-description {
        margin-bottom: 0;
    }

    .weather-details {
        border-top: none;
        border-left: 1px solid var(--glass-border);
        padding-top: 0;
        padding-left: 2rem;
        flex-direction: column;
        gap: 1rem;
    }

    .detail-item {
        flex-direction: row;
        gap: 0.75rem;
    }

    /* Sun and Moon side by side */
    .astro-row {
        flex-direction: row;
        gap: 0.75rem;
    }

    .astro-row .glass-card {
        flex: 1;
    }

    .card-title {
        margin-bottom: 0.75rem;
        font-size: 0.875rem;
    }

    .sun-time svg {
        width: 24px;
        height: 24px;
    }

    .moon-sphere {
        width: 70px;
        height: 70px;
    }

    .moon-display {
        gap: 1rem;
    }

    .moon-phase-name {
        font-size: 1rem;
    }

    /* Hourly compact */
    .hourly-card {
        padding: 0.75rem 1rem;
    }

    .hourly-card .card-title {
        margin-bottom: 0.5rem;
    }

    .hourly-item {
        min-width: 55px;
        padding: 0.5rem 0.625rem;
        gap: 0.25rem;
    }

    .hourly-icon {
        width: 24px;
        height: 24px;
    }

    .hourly-temp {
        font-size: 0.85rem;
    }

    .hourly-time {
        font-size: 0.7rem;
    }
}

/* Very low height - ultra compact */
@media (max-height: 550px) and (min-width: 700px) {
    .container {
        max-width: 1100px;
        padding: 0.5rem 1rem;
        gap: 0.5rem;
    }

    .glass-card {
        padding: 0.75rem 1rem;
        border-radius: 12px;
    }

    .search-section {
        padding: 0.5rem 1rem;
    }

    .weather-card {
        flex-direction: row;
        align-items: center;
        justify-content: space-around;
        gap: 1.5rem;
    }

    .weather-primary {
        align-items: flex-start;
    }

    .weather-main {
        margin-bottom: 0.25rem;
        justify-content: flex-start;
        gap: 1rem;
    }

    .temperature {
        font-size: 3rem;
    }

    .weather-icon {
        width: 50px;
        height: 50px;
    }

    .weather-description {
        margin-bottom: 0;
        font-size: 1rem;
    }

    .weather-details {
        border-top: none;
        border-left: 1px solid var(--glass-border);
        padding-top: 0;
        padding-left: 1.5rem;
        flex-direction: column;
        gap: 0.75rem;
    }

    .detail-item {
        flex-direction: row;
        gap: 0.5rem;
    }

    .astro-row {
        flex-direction: row;
        gap: 0.5rem;
    }

    .card-title {
        margin-bottom: 0.5rem;
    }

    .moon-sphere {
        width: 50px;
        height: 50px;
    }

    .sun-time {
        min-width: 55px;
    }

    .sun-time svg {
        width: 20px;
        height: 20px;
    }

    .time-value {
        font-size: 0.875rem;
    }

    /* Hourly ultra compact */
    .hourly-card {
        padding: 0.5rem 0.75rem;
    }

    .hourly-card .card-title {
        margin-bottom: 0.375rem;
    }

    .hourly-item {
        min-width: 48px;
        padding: 0.375rem 0.5rem;
        gap: 0.2rem;
    }

    .hourly-icon {
        width: 20px;
        height: 20px;
    }

    .hourly-temp {
        font-size: 0.75rem;
    }

    .hourly-time {
        font-size: 0.65rem;
    }
}

/* Low height on narrow screens - stack but compact */
@media (max-height: 700px) and (max-width: 599px) {
    .container {
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .glass-card {
        padding: 0.75rem;
        border-radius: 12px;
    }

    .temperature {
        font-size: 3rem;
    }

    .weather-icon {
        width: 50px;
        height: 50px;
    }

    .weather-main {
        gap: 1rem;
        margin-bottom: 0.25rem;
    }

    .weather-description {
        margin-bottom: 0.5rem;
        font-size: 0.9rem;
    }

    .weather-details {
        padding-top: 0.5rem;
        gap: 1.5rem;
    }

    .card-title {
        margin-bottom: 0.5rem;
        font-size: 0.8rem;
    }

    .moon-sphere {
        width: 50px;
        height: 50px;
    }

    .moon-display {
        gap: 1rem;
    }

    .moon-phase-name {
        font-size: 1rem;
    }

    .search-wrapper {
        margin-bottom: 0.25rem;
    }

    .location-name {
        font-size: 0.9rem;
    }

    .sun-time {
        min-width: 50px;
    }

    .sun-time svg {
        width: 20px;
        height: 20px;
    }

    .time-label {
        font-size: 0.65rem;
    }

    .time-value {
        font-size: 0.85rem;
    }

    /* Hourly compact for narrow */
    .hourly-card {
        padding: 0.5rem 0.75rem;
    }

    .hourly-card .card-title {
        margin-bottom: 0.375rem;
    }

    .hourly-item {
        min-width: 50px;
        padding: 0.375rem 0.5rem;
        gap: 0.25rem;
    }

    .hourly-icon {
        width: 22px;
        height: 22px;
    }

    .hourly-temp {
        font-size: 0.8rem;
    }

    .hourly-time {
        font-size: 0.65rem;
    }
}

/* Animation for weather icon */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.weather-icon svg {
    animation: pulse 3s ease-in-out infinite;
}

/* Button loading state */
.icon-btn.loading {
    pointer-events: none;
    opacity: 0.7;
}

.icon-btn.loading svg {
    animation: spin 1s linear infinite;
}
