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

:root {
    --glass: rgba(255, 255, 255, 0.12);
    --glass-border: rgba(255, 255, 255, 0.2);
    --text: #ffffff;
    --muted: rgba(255, 255, 255, 0.55);
    --bg-transition: 1.4s cubic-bezier(0.4, 0, 0.2, 1);
}

html,
body {
    height: 100%;
    font-family: "DM Mono", monospace;
    color: var(--text);
    overflow: hidden;
    user-select: none;
}

/* ── Background ── */
.bg-layer {
    position: fixed;
    inset: 0;
    z-index: 0;
    transition: background var(--bg-transition);
    background: linear-gradient(160deg, #1a1a2e 0%, #16213e 60%, #0f3460 100%);
}

.bg-layer.clear-day {
    background: linear-gradient(
        185deg,
        #0a4fa0 0%,
        #1a80d4 25%,
        #4db6f0 55%,
        #f9d06a 78%,
        #f4a124 100%
    );
}
.bg-layer.clear-night {
    background: linear-gradient(
        185deg,
        #010510 0%,
        #050d1f 30%,
        #0a1535 60%,
        #0f1e46 100%
    );
}
.bg-layer.cloudy {
    background: linear-gradient(
        185deg,
        #3d4f62 0%,
        #546172 30%,
        #7a8fa2 65%,
        #9bafc0 100%
    );
}
.bg-layer.rainy {
    background: linear-gradient(
        185deg,
        #101d2c 0%,
        #1a2d3f 35%,
        #243a50 65%,
        #2e4760 100%
    );
}
.bg-layer.stormy {
    background: linear-gradient(
        185deg,
        #07070f 0%,
        #101020 30%,
        #191930 60%,
        #1c1c38 100%
    );
}
.bg-layer.snowy {
    background: linear-gradient(
        185deg,
        #a8c4de 0%,
        #c8dff0 35%,
        #e0eff8 65%,
        #f0f8ff 100%
    );
}
.bg-layer.misty {
    background: linear-gradient(
        185deg,
        #4a5a68 0%,
        #687888 35%,
        #8898a8 65%,
        #a8bac8 100%
    );
}

.particle-canvas {
    position: fixed;
    inset: 0;
    z-index: 1;
    pointer-events: none;
}

.bg-overlay {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    background: radial-gradient(
        ellipse at 50% 100%,
        rgba(0, 0, 0, 0.3) 0%,
        transparent 65%
    );
}

/* Sun glow */
.sun-orb {
    position: fixed;
    top: -60px;
    right: -60px;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    background: radial-gradient(
        circle,
        rgba(255, 230, 60, 0.5) 0%,
        rgba(255, 160, 0, 0.2) 45%,
        transparent 70%
    );
    z-index: 1;
    pointer-events: none;
    animation: sunPulse 5s ease-in-out infinite;
    filter: blur(4px);
}
@keyframes sunPulse {
    0%,
    100% {
        transform: scale(1);
        opacity: 0.85;
    }
    50% {
        transform: scale(1.1);
        opacity: 1;
    }
}

/* Sun rays */
.sun-rays {
    position: fixed;
    top: 30px;
    right: 30px;
    width: 200px;
    height: 200px;
    z-index: 1;
    pointer-events: none;
    animation: raysSpin 30s linear infinite;
}
@keyframes raysSpin {
    to {
        transform: rotate(360deg);
    }
}

/* Cloud divs */
.cloud-blur {
    position: fixed;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    filter: blur(35px);
    z-index: 1;
    pointer-events: none;
    animation: cloudDrift linear infinite;
}
@keyframes cloudDrift {
    from {
        transform: translateX(-120px);
    }
    to {
        transform: translateX(calc(100vw + 120px));
    }
}

/* Fog */
.fog-strip {
    position: fixed;
    left: 0;
    right: 0;
    height: 180px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.07) 30%,
        rgba(255, 255, 255, 0.1) 50%,
        rgba(255, 255, 255, 0.07) 70%,
        transparent 100%
    );
    filter: blur(18px);
    z-index: 1;
    pointer-events: none;
    animation: fogMove linear infinite;
}
@keyframes fogMove {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(100%);
    }
}

/* Lightning */
.lightning-flash {
    position: fixed;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    background: rgba(255, 255, 255, 0.85);
    opacity: 0;
}

/* ── Screens ── */
.screen {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hidden {
    display: none !important;
}

/* ── Search screen ── */
.search-inner {
    width: 100%;
    max-width: 520px;
    padding: 40px 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.label {
    font-size: 0.62rem;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--muted);
}

.search-title {
    font-family: "Playfair Display", serif;
    font-size: clamp(3.2rem, 10vw, 6.5rem);
    font-weight: 900;
    line-height: 0.93;
    letter-spacing: -0.02em;
    text-shadow: 0 2px 24px rgba(0, 0, 0, 0.25);
}
.search-title em {
    font-style: italic;
    font-weight: 400;
}

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

.input-wrap {
    flex: 1;
    background: var(--glass);
    border: 1.5px solid var(--glass-border);
    border-radius: 14px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    overflow: hidden;
    transition: border-color 0.2s ease;
    display: flex;
    align-items: center;
}

#locate-btn {
    background: transparent;
    border: none;
    padding: 0 14px 0 0;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.38);
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: color 0.2s ease;
}
#locate-btn:hover {
    color: rgba(255, 255, 255, 0.85);
}
#locate-btn.loading {
    animation: spin 0.9s linear infinite;
    color: rgba(255, 255, 255, 0.6);
}
.input-wrap:focus-within {
    border-color: rgba(255, 255, 255, 0.55);
}
.input-wrap.error {
    border-color: rgba(255, 90, 90, 0.8);
    animation: shake 0.35s ease;
}

#city-input {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: #fff;
    font-family: "DM Mono", monospace;
    font-size: 1rem;
    padding: 16px 18px;
}
#city-input::placeholder {
    color: rgba(255, 255, 255, 0.38);
}

#get-weather-btn {
    font-family: "DM Mono", monospace;
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    padding: 16px 28px;
    border-radius: 14px;
    border: none;
    background: rgba(255, 255, 255, 0.92);
    color: #111;
    cursor: pointer;
    white-space: nowrap;
    backdrop-filter: blur(12px);
    transition:
        transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity 0.2s;
}
#get-weather-btn:hover {
    transform: scale(1.05);
}
#get-weather-btn:active {
    transform: scale(0.97);
    opacity: 0.85;
}
#get-weather-btn:disabled {
    opacity: 0.38;
    cursor: not-allowed;
    transform: none;
}

.spinner-row {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.62rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
}
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.error-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 18px;
    background: rgba(255, 70, 70, 0.14);
    border: 1px solid rgba(255, 100, 100, 0.3);
    border-radius: 12px;
    font-size: 0.78rem;
    backdrop-filter: blur(8px);
    color: rgba(255, 185, 185, 0.95);
}

.recent-searches {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--glass);
    border: 1.5px solid var(--glass-border);
    border-radius: 14px;
    padding: 6px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 20;
}

.recent-search-item {
    background: transparent;
    border: none;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.7);
    font-family: "DM Mono", monospace;
    font-size: 0.85rem;
    text-align: left;
    transition: all 0.2s ease;
}

.recent-search-item:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

/* ── Weather screen ── */
#weather-screen {
    flex-direction: column;
    justify-content: space-between;
    align-items: stretch;
    padding: 0;
    animation: screenFadeIn 0.35s ease;
}

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

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 52px 28px 0;
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: "DM Mono", monospace;
    font-size: 0.68rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: #fff;
    padding: 10px 18px;
    border-radius: 100px;
    cursor: pointer;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    transition:
        background 0.2s ease,
        transform 0.2s ease;
}
.back-btn:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: scale(1.03);
}

.unit-toggle {
    display: flex;
    gap: 4px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 100px;
    padding: 4px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}
.unit-btn {
    font-family: "DM Mono", monospace;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    padding: 6px 14px;
    border-radius: 100px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.55);
    cursor: pointer;
    transition: all 0.2s ease;
}
.unit-btn.active {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
}

/* Weather body — centered */
.weather-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 20px 28px;
    text-align: center;
    overflow: hidden;
}

/* Big SVG weather icon */
.wx-icon-wrap {
    width: 140px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 8px 32px rgba(0, 0, 0, 0.25));
}

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

/* Location */
.wx-location h2 {
    font-family: "Playfair Display", serif;
    font-size: clamp(1.8rem, 5vw, 3rem);
    font-weight: 700;
    letter-spacing: -0.01em;
    text-shadow: 0 2px 16px rgba(0, 0, 0, 0.2);
}
#weather-country {
    font-size: 0.68rem;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
    margin-top: 4px;
}

/* Temperature */
.wx-temp-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.wx-temp {
    font-family: "Playfair Display", serif;
    font-size: clamp(4rem, 14vw, 8rem);
    font-weight: 900;
    line-height: 1;
    letter-spacing: -0.04em;
    text-shadow: 0 4px 32px rgba(0, 0, 0, 0.2);
}

.wx-desc {
    font-size: clamp(0.85rem, 2.5vw, 1.1rem);
    letter-spacing: 0.1em;
    text-transform: capitalize;
    color: var(--muted);
    margin-top: 12px;
    margin-bottom: 4px;
}

.wx-range {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
    color: var(--muted);
}
.range-sep {
    opacity: 0.4;
}

/* Details pill */
.details-pill {
    width: calc(100% - 48px);
    max-width: 520px;
    margin: 0 auto 36px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 28px;
    padding: 18px 12px;
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    display: flex;
    align-items: center;
    justify-content: space-around;
}

.detail-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    flex: 1;
}

.detail-svg {
    width: 22px;
    height: 22px;
    color: rgba(255, 255, 255, 0.7);
    stroke-linecap: round;
    stroke-linejoin: round;
}

.detail-val {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "Playfair Display", serif;
    font-size: 1.05rem;
    font-weight: 700;
}
.detail-lbl {
    font-size: 0.52rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
}
.detail-sep {
    width: 1px;
    height: 40px;
    background: var(--glass-border);
    flex-shrink: 0;
}

/* Snowy/misty text needs to be dark */
body.theme-light .wx-temp,
body.theme-light .wx-desc,
body.theme-light .wx-range,
body.theme-light .wx-location h2,
body.theme-light #weather-country,
body.theme-light .detail-val,
body.theme-light .detail-lbl,
body.theme-light .back-btn,
body.theme-light .unit-btn,
body.theme-light .search-title,
body.theme-light #city-input {
    color: #1a2535;
}
body.theme-light .back-btn,
body.theme-light .unit-toggle {
    background: rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.15);
}
body.theme-light .recent-search-item {
    color: rgba(26, 37, 53, 0.7);
    background: transparent;
}
body.theme-light .recent-search-item:hover {
    color: #1a2535;
    background: rgba(0, 0, 0, 0.05);
}
body.theme-light #city-input::placeholder {
    color: rgba(26, 37, 53, 0.4);
}
body.theme-light .detail-svg {
    color: rgba(26, 37, 53, 0.65);
}

@keyframes shake {
    0%,
    100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-6px);
    }
    75% {
        transform: translateX(6px);
    }
}

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

.search-inner > * {
    animation: fadeUp 0.5s ease both;
}
.search-inner > *:nth-child(1) {
    animation-delay: 0s;
}
.search-inner > *:nth-child(2) {
    animation-delay: 0.07s;
}
.search-inner > *:nth-child(3) {
    animation-delay: 0.13s;
}

@media (max-width: 500px) {
    .top-bar {
        padding: 40px 20px 0;
    }
    .weather-body {
        padding: 16px 20px;
        gap: 10px;
    }
    .details-pill {
        width: calc(100% - 40px);
        margin-bottom: 28px;
        padding: 14px 8px;
    }
    .detail-val {
        font-size: 0.9rem;
    }
    .wx-icon-wrap {
        width: 110px;
        height: 110px;
    }
}
