/* --- INHERITED REFERENCE STYLES & VARIABLES --- */
@import url('https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,500;0,700;0,800;1,700;1,800&display=swap');

:root {
    --bg-page-1: #e6f0fa;
    --bg-page-2: #ffffff;
    --text-main: #4a5568;
    --text-heading: #2d3748;
}

/* Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

/* Body is now the main layout wrapper */
body {
    font-family: 'Nunito', sans-serif;
    color: var(--text-main);
    margin: 0;
    /* This padding creates the spacing at the top and bottom of the screen */
    padding: 1.5rem 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Fixed HTML Background Image with subtle blur and bleed correction */
.fc-bg-image {
    position: fixed;
    top: -5%;
    left: -5%;
    width: 110vw;
    height: 110vh;
    object-fit: cover;
    object-position: center;
    z-index: -1;
    pointer-events: none;
    filter: blur(8px);
}

/* --- HEADER STYLES --- */
.fc-header {
    display: flex;
    background: #0d7a31; /* Original dark green */
    border-bottom: 3px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25), inset 0 -1px 2px rgba(255, 255, 255, 0.2);
    z-index: 2;
}

/* 1/3 Width for Title */
.header-title {
    flex: 0 0 33.33%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: clamp(1.4rem, 2.5vw, 2rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: 1px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.4);
    text-align: center;
    padding: 1.2rem 0;
}

/* 2/3 Width for Location Pill wrapper */
.header-location-wrapper {
    flex: 0 0 66.67%;
    padding: 0.8rem 0 0.8rem 1rem; /* Spacing so it doesn't touch the text */
}

/* The indented groove pill with enhanced skeuomorphic rim borders */
.header-location {
    background: #4cc75b; /* Lighter vivid green */
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-end; /* Right aligns the text */
    padding-right: 4rem; /* Specific spacing from the right edge */
    padding-left: 2rem;
    border-radius: 50px 0 0 50px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-right: none;
    /* Inner shadow creates the cut-out/indention illusion */
    box-shadow: inset 3px 4px 8px rgba(0, 0, 0, 0.35), inset 0px -2px 4px rgba(255, 255, 255, 0.3);
    color: #ffffff;
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    font-weight: 800;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
}

/* --- FORECAST GRID STYLES --- */
.fc-grid {
    flex-grow: 1; /* Pushes the footer to the bottom */
    display: flex;
    padding: 3rem 5%;
    gap: 1.5rem;
    z-index: 1;
}

/* Modern hoverable glass cards sitting on the background */
.day-card {
    flex: 1;
    /* Preserves original Flexbox layout direction */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-evenly;
    padding: 1.5rem 0.5rem;
    text-align: center;
    /* Keeps the tall, iconic aspect ratio of the Wii Forecast Channel card */
    min-height: clamp(380px, 55vh, 520px);
    /* Gradient starts solid at 0px and runs solid down to the header bottom (4.5rem) before fading */
    background: linear-gradient(180deg, rgb(36, 94, 255) 0px, rgb(36, 94, 255) 4.5rem, rgba(255, 255, 255, 0.1) 100%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    /* Reduced backdrop blur to prevent compound stacking blur */
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);

    /* Use modern independent transform properties to resolve keyframe-exit transition conflicts */
    translate: 0 0;
    scale: 1;
    rotate: 0deg;

    /* Elastic, natural spring-back transition that handles exit interpolation perfectly */
    transition: 
        translate 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.15), 
        scale 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.15), 
        rotate 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.15), 
        box-shadow 0.7s cubic-bezier(0.25, 1, 0.5, 1), 
        background 0.5s ease;

    /* Skeuomorphic inner rim lighting highlights */
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.15), 
        inset 0 2px 3px rgba(255, 255, 255, 0.4),
        inset 0 -2px 4px rgba(0, 0, 0, 0.15);
    position: relative;
    /* Clips the overflowing header background block to match the card corners */
    overflow: hidden;
}

/* Soft, liquid spring wiggle animation targeting ONLY the rotate property */
@keyframes wiggleRotate {
    0% { 
        rotate: 0deg; 
    }
    20% { 
        rotate: -2deg; 
    }
    40% { 
        rotate: 1.5deg; 
    }
    60% { 
        rotate: -0.8deg; 
    }
    80% { 
        rotate: 0.3deg; 
    }
    100% { 
        rotate: 0deg; 
    }
}

.day-card:hover {
    translate: 0 -10px;
    scale: 1.04;
    box-shadow: 
        0 18px 36px rgba(0,0,0,0.22), 
        inset 0 2px 4px rgba(255,255,255,0.45),
        inset 0 -2px 4px rgba(0,0,0,0.1);
    /* Slightly lighter and less transparent gradient on hover, starting solid at the header bottom */
    background: linear-gradient(180deg, rgb(70, 120, 255) 0px, rgb(70, 120, 255) 4.5rem, rgba(255, 255, 255, 0.25) 100%);
    /* Animation runs ONLY on the independent rotate property, preventing translate/scale snapping on exit */
    animation: wiggleRotate 0.85s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

/* Day Name Style sitting above the card's navy background element */
.day-name {
    color: #ffffff;
    font-size: clamp(1.8rem, 2.5vw, 2.4rem); /* Chunky, readable fluid typography */
    font-weight: 800;
    width: 80%;
    padding-top: 6px;
    padding-bottom: 12px;
    margin-bottom: 10px;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
    position: relative;
    z-index: 1; /* Layers text above card background block */
    letter-spacing: 1px;
}

/* Background Navy Header block expansion. Aligned exactly inside the card boundaries */
.day-name::before {
    content: '';
    position: absolute;
    /* Stretches upward to cover the card top, and horizontally to match the card borders */
    top: -15rem;
    left: calc(-12.5% - 0.5rem - 1px);
    right: calc(-12.5% - 0.5rem - 1px);
    bottom: -5px; /* Extends slightly below the text to complete the visual block */
    background: #2a3eb1; /* Solid Navy */
    z-index: -1;
    /* Bottom corners are beautifully rounded and render inside the card container */
    border-radius: 0 0 16px 16px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-top: none;
    border-bottom: 2px solid rgba(0, 0, 0, 0.25);
    /* Downward-pointing drop shadow and premium rim lighting highlights */
    box-shadow: 
        0 6px 12px rgba(0, 0, 0, 0.35),
        inset 0 1.5px 2px rgba(255, 255, 255, 0.45),
        inset 0 -1.5px 3px rgba(0, 0, 0, 0.25);
    pointer-events: none;
}

/* Allows the middle icon container to expand and occupy vertical space */
.icon-container {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    margin: 0.5rem 0;
    flex-grow: 1;
}

/* Prominent weather icon sizing scaling to match the Wii Forecast Channel density */
.icon-container svg,
.icon-container img {
    width: clamp(110px, 14vw, 160px);
    height: clamp(110px, 14vw, 160px);
    filter: drop-shadow(0 6px 10px rgba(0,0,0,0.3));
    object-fit: contain;
}

/* Chunky high-contrast colors and outlines reminiscent of Wii UI design */
.temp-high, .temp-low {
    font-size: clamp(3.2rem, 4.5vw, 4.2rem);
    font-weight: 800;
    line-height: 1.05;
    text-shadow: 2px 2px 0px rgba(0,0,0,0.6), 0px 2px 4px rgba(0,0,0,0.4);
}

.temp-high {
    color: #ffcc00; /* Warm Yellow */
    margin-bottom: 5px;
}

.temp-low {
    color: #aaeaff; /* Cool Cyan */
}

.loading-state {
    color: #ffffff;
    font-size: 1.5rem;
    font-weight: 700;
    width: 100%;
    text-align: center;
    margin: 50px 0;
}

/* --- FOOTER STATUS BAR --- */
.fc-footer {
    width: 100%;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 3rem;
    /* User's custom background */
    background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(135, 206, 235, 0.75) 25%, rgba(220, 30, 30, 0.9) 100%);
    color: #ffffff;
    font-weight: 700;
    font-size: 1.1rem;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
    /* Reduced backdrop blur to prevent stack compounding */
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.2);
}

/* Dynamic Gradient Top Border Highlight */
.fc-footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    /* Brighter, more opaque version of the footer gradient to act as a highlight */
    background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(135, 206, 235, 1) 25%, rgba(255, 100, 100, 1) 100%);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.footer-left {
    opacity: 0.9;
}

.footer-right {
    font-weight: 800;
}

/* Responsive Scaling */
@media (max-width: 800px) {
    .fc-grid { flex-direction: column; padding: 1.5rem; }
    .day-card { min-height: unset; padding: 2rem 0.5rem; }
    .day-name { font-size: 1.5rem; }
    .icon-container svg, .icon-container img { width: 90px; height: 90px; }
    .fc-footer { flex-direction: column; gap: 0.8rem; text-align: center; padding: 1rem; }
    .header-location { padding-right: 2rem; }
}