:root {
    color-scheme: dark;
    --bg: #090d0c;
    --panel: rgba(13, 20, 18, 0.78);
    --panel-strong: rgba(21, 34, 30, 0.9);
    --line: rgba(177, 255, 223, 0.2);
    --text: #f5fff9;
    --muted: #94b6a9;
    --accent: #40f5b0;
    --accent-hot: #ff6f61;
    --shadow: rgba(0, 0, 0, 0.38);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at 18% 20%, rgba(64, 245, 176, 0.2), transparent 28rem),
        radial-gradient(circle at 82% 18%, rgba(255, 111, 97, 0.16), transparent 24rem),
        linear-gradient(145deg, #07110e 0%, #0b1110 48%, #15110f 100%);
    color: var(--text);
    overflow-x: hidden;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
    background-size: 64px 64px;
    mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent);
}

.weather-stage {
    position: relative;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 44px 18px;
    isolation: isolate;
}

.atmosphere {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
}

.atmosphere span {
    position: absolute;
    width: 42rem;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(64, 245, 176, 0.36), transparent);
    opacity: 0.5;
    --tilt: -18deg;
    animation: drift 14s ease-in-out infinite alternate;
}

.atmosphere span:nth-child(1) {
    left: 6%;
    top: 10%;
}

.atmosphere span:nth-child(2) {
    right: 9%;
    top: 16%;
    width: 31rem;
    background: linear-gradient(90deg, transparent, rgba(255, 111, 97, 0.32), transparent);
    --tilt: 16deg;
    animation-delay: -3s;
}

.atmosphere span:nth-child(3) {
    left: 18%;
    bottom: 8%;
    width: 28rem;
    --tilt: 10deg;
    animation-delay: -6s;
}

.atmosphere span:nth-child(4) {
    right: 18%;
    bottom: 12%;
    width: 19rem;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.24), transparent);
    --tilt: -11deg;
    animation-delay: -9s;
}

.weather-console {
    width: min(100%, 760px);
    border: 1px solid var(--line);
    border-radius: 8px;
    background: linear-gradient(145deg, var(--panel), rgba(9, 13, 12, 0.66));
    box-shadow: 0 34px 100px var(--shadow);
    backdrop-filter: blur(26px);
    padding: clamp(22px, 5vw, 42px);
    position: relative;
    overflow: hidden;
    animation: consoleIn 720ms cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

.weather-console::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent, rgba(64, 245, 176, 0.13), transparent);
    transform: translateX(-100%);
    animation: scan 5s ease-in-out infinite;
    pointer-events: none;
}

.console-header,
.search,
.weather {
    position: relative;
    z-index: 1;
}

.eyebrow {
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
    margin-bottom: 12px;
}

h1 {
    font-size: 4.9rem;
    line-height: 0.92;
    letter-spacing: 0;
    max-width: 8ch;
}

.intro {
    color: var(--muted);
    line-height: 1.65;
    max-width: 34rem;
    margin-top: 18px;
}

.search {
    margin-top: 34px;
}

.search label {
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
    margin-bottom: 8px;
}

.search-bar {
    display: flex;
    gap: 10px;
}

.search input {
    min-width: 0;
    flex: 1;
    height: 58px;
    border: 1px solid var(--line);
    outline: 0;
    border-radius: 8px;
    background: rgba(245, 255, 249, 0.08);
    color: var(--text);
    padding: 0 18px;
    font: inherit;
    transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.search input:focus {
    border-color: rgba(64, 245, 176, 0.75);
    background: rgba(245, 255, 249, 0.12);
    box-shadow: 0 0 0 4px rgba(64, 245, 176, 0.12);
}

.search button {
    width: 58px;
    height: 58px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.search button:hover,
.search button:focus-visible {
    transform: translateY(-2px);
    background: #8cffd0;
    box-shadow: 0 16px 32px rgba(64, 245, 176, 0.25);
}

.search button:active {
    transform: translateY(0) scale(0.96);
}

.search button img {
    width: 18px;
    filter: invert(1);
}

.error {
    display: none;
    color: #ffaba3;
    margin-top: 12px;
    font-size: 0.92rem;
}

.weather {
    display: none;
    margin-top: 34px;
    animation: weatherReveal 560ms cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

.weather.is-visible {
    display: block;
}

.weather-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    border-top: 1px solid var(--line);
    padding-top: 30px;
}

.condition {
    color: var(--accent-hot);
    font-size: 0.84rem;
    font-weight: 800;
    text-transform: uppercase;
}

.city {
    margin-top: 8px;
    font-size: 4.4rem;
    line-height: 0.95;
    overflow-wrap: anywhere;
}

.weather-icon {
    width: clamp(104px, 28vw, 164px);
    filter: drop-shadow(0 24px 28px rgba(64, 245, 176, 0.16));
    animation: floatIcon 4s ease-in-out infinite;
}

.temperature-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    gap: 18px;
    margin-top: 18px;
}

.temp {
    font-size: 8.7rem;
    line-height: 0.85;
    font-weight: 800;
}

.feels {
    color: var(--muted);
    padding-bottom: 10px;
    white-space: nowrap;
}

.details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-top: 30px;
}

.metric {
    min-height: 92px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-strong);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.metric:hover {
    transform: translateY(-3px);
    border-color: rgba(64, 245, 176, 0.46);
    background: rgba(28, 45, 39, 0.92);
}

.metric img {
    width: 34px;
    flex: 0 0 auto;
}

.metric p,
.metric strong {
    display: block;
    font-size: 1.45rem;
    line-height: 1;
}

.metric span {
    display: block;
    color: var(--muted);
    font-size: 0.78rem;
    margin-top: 8px;
}

.metric-text {
    display: block;
}

.metric-sun {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.metric-sun > span {
    margin-top: 0;
}

.sun-times {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.sun-times p {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.82rem;
    color: var(--muted);
}

.sun-times strong {
    font-size: 1.2rem;
    color: var(--text);
}

.forecast {
    margin-top: 30px;
    border-top: 1px solid var(--line);
    padding-top: 26px;
}

.forecast-header {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 16px;
}

.forecast-kicker {
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.forecast h3 {
    font-size: 1.25rem;
    line-height: 1;
}

.forecast-list {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
}

.forecast-day {
    min-height: 158px;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(245, 255, 249, 0.07);
    display: grid;
    align-content: space-between;
    justify-items: start;
    gap: 8px;
    padding: 16px;
    transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.forecast-day > * {
    min-width: 0;
}

.forecast-day:hover {
    transform: translateY(-3px);
    border-color: rgba(255, 111, 97, 0.46);
    background: rgba(245, 255, 249, 0.1);
}

.forecast-date {
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.25;
}

.forecast-icon {
    width: 38px;
    filter: drop-shadow(0 12px 18px rgba(64, 245, 176, 0.16));
}

.forecast-range {
    font-size: clamp(1.15rem, 0.7vw + 0.75rem, 1.45rem);
    line-height: 1.05;
    white-space: nowrap;
}

.forecast-day span {
    min-height: 2.4em;
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.2;
    text-transform: capitalize;
}

.forecast-sun {
    color: var(--muted);
    font-size: 0.72rem;
    letter-spacing: 0.02em;
    line-height: 1.25;
}

.weather-console.is-loading .search button {
    animation: pulse 850ms ease-in-out infinite alternate;
}

.weather-console.is-loading .weather {
    opacity: 0.58;
}

@keyframes consoleIn {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

@keyframes floatIcon {
    0%,
    100% {
        transform: translateY(0) rotate(-2deg);
    }
    50% {
        transform: translateY(-12px) rotate(3deg);
    }
}

@keyframes drift {
    from {
        transform: translate3d(-18px, 12px, 0) rotate(var(--tilt)) scaleX(0.94);
    }
    to {
        transform: translate3d(24px, -22px, 0) rotate(var(--tilt)) scaleX(1.06);
    }
}

@keyframes scan {
    0%,
    58% {
        transform: translateX(-110%);
    }
    100% {
        transform: translateX(110%);
    }
}

@keyframes pulse {
    from {
        opacity: 0.72;
    }
    to {
        opacity: 1;
    }
}

@media (max-width: 620px) {
    .weather-stage {
        place-items: start center;
        padding-top: 22px;
    }

    .weather-console {
        padding: 22px;
    }

    h1 {
        font-size: 2.8rem;
    }

    .city {
        font-size: 2.6rem;
    }

    .temp {
        font-size: 4.6rem;
    }

    .temperature-row {
        grid-template-columns: 1fr;
    }

    .feels {
        padding-bottom: 0;
        white-space: normal;
    }

    .details {
        grid-template-columns: 1fr;
    }

    .forecast-header {
        align-items: start;
        flex-direction: column;
        gap: 8px;
    }

    .forecast-list {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 390px) {
    h1 {
        font-size: 2.35rem;
    }

    .city {
        font-size: 2.1rem;
    }

    .temp {
        font-size: 4rem;
    }

    .forecast-list {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
