/*
 * Weather Box 2.x
 * All selectors are scoped to .wx-widget so the component can be dropped into
 * any theme without leaking styles into the rest of the page.
 */

.wx-widget {
    --wx-radius: 20px;
    --wx-bg: #f7fafc;
    --wx-bg-soft: rgba(255, 255, 255, 0.66);
    --wx-bg-strong: #ffffff;
    --wx-text: #13202c;
    --wx-muted: #5b6b7b;
    --wx-line: rgba(19, 32, 44, 0.12);
    --wx-accent: #2f7de1;
    --wx-accent-soft: rgba(47, 125, 225, 0.12);
    --wx-shadow: 0 18px 50px rgba(19, 32, 44, 0.12);
    --wx-anim-opacity: 0.55;
    position: relative;
    isolation: isolate;
    display: block;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    border: 1px solid var(--wx-line);
    border-radius: var(--wx-radius);
    background:
        radial-gradient(120% 100% at 100% 0%, rgba(255, 255, 255, 0.9) 0%, transparent 55%),
        linear-gradient(145deg, var(--wx-bg) 0%, var(--wx-bg-strong) 100%);
    box-shadow: var(--wx-shadow);
    color: var(--wx-text);
    font-family: inherit;
    font-size: 16px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

.wx-widget *,
.wx-widget *::before,
.wx-widget *::after {
    box-sizing: border-box;
}

.wx-widget[data-wx-theme="dark"] {
    --wx-bg: #101a24;
    --wx-bg-soft: rgba(255, 255, 255, 0.06);
    --wx-bg-strong: #17232f;
    --wx-text: #f0f6fb;
    --wx-muted: #a8b7c6;
    --wx-line: rgba(255, 255, 255, 0.12);
    --wx-accent: #6cb2ff;
    --wx-accent-soft: rgba(108, 178, 255, 0.16);
    --wx-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

@media (prefers-color-scheme: dark) {
    .wx-widget[data-wx-theme="auto"] {
        --wx-bg: #101a24;
        --wx-bg-soft: rgba(255, 255, 255, 0.06);
        --wx-bg-strong: #17232f;
        --wx-text: #f0f6fb;
        --wx-muted: #a8b7c6;
        --wx-line: rgba(255, 255, 255, 0.12);
        --wx-accent: #6cb2ff;
        --wx-accent-soft: rgba(108, 178, 255, 0.16);
        --wx-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
    }
}

.wx-widget[data-wx-intensity="light"] {
    --wx-anim-opacity: 0.35;
}

.wx-widget[data-wx-intensity="strong"] {
    --wx-anim-opacity: 0.78;
}

.wx-widget[data-wx-animations="0"] .wx-anim-layer {
    display: none;
}

.wx-content {
    position: relative;
    z-index: 2;
    padding: clamp(18px, 3.2vw, 30px);
}

.wx-anim-layer {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
    pointer-events: none;
    opacity: var(--wx-anim-opacity);
    transition: opacity 240ms ease;
}

.wx-canvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
}

.wx-lightning {
    position: absolute;
    inset: 0;
    background: #ffffff;
    opacity: 0;
    mix-blend-mode: screen;
}

.wx-lightning.is-flashing {
    animation: wx-flash 520ms ease-out;
}

@keyframes wx-flash {
    0% { opacity: 0; }
    8% { opacity: 0.72; }
    18% { opacity: 0.08; }
    28% { opacity: 0.62; }
    100% { opacity: 0; }
}

/* CSS-only ambience for fog, clouds and clear skies. JS adds particles on top. */
.wx-widget[data-wx-effect="fog"] .wx-anim-layer::before,
.wx-widget[data-wx-effect="fog"] .wx-anim-layer::after {
    content: "";
    position: absolute;
    left: -35%;
    width: 170%;
    height: 55%;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(255, 255, 255, 0.9) 0%, transparent 62%),
        radial-gradient(ellipse at 55% 45%, rgba(255, 255, 255, 0.72) 0%, transparent 60%),
        radial-gradient(ellipse at 85% 55%, rgba(255, 255, 255, 0.82) 0%, transparent 62%);
    filter: blur(14px);
    animation: wx-fog-drift 22s linear infinite alternate;
}

.wx-widget[data-wx-effect="fog"] .wx-anim-layer::before {
    top: 28%;
}

.wx-widget[data-wx-effect="fog"] .wx-anim-layer::after {
    top: 52%;
    opacity: 0.7;
    animation-duration: 29s;
    animation-direction: alternate-reverse;
}

@keyframes wx-fog-drift {
    from { transform: translate3d(-6%, 0, 0); }
    to { transform: translate3d(6%, 0, 0); }
}

.wx-widget[data-wx-effect="clouds"] .wx-anim-layer::before,
.wx-widget[data-wx-effect="clouds"] .wx-anim-layer::after {
    content: "";
    position: absolute;
    width: 46%;
    height: 30%;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    filter: blur(18px);
    animation: wx-cloud-drift 34s linear infinite;
}

.wx-widget[data-wx-effect="clouds"] .wx-anim-layer::before {
    top: 16%;
    left: -20%;
}

.wx-widget[data-wx-effect="clouds"] .wx-anim-layer::after {
    top: 44%;
    left: -55%;
    width: 38%;
    height: 24%;
    opacity: 0.65;
    animation-duration: 46s;
    animation-delay: -12s;
}

@keyframes wx-cloud-drift {
    from { transform: translate3d(-10%, 0, 0); }
    to { transform: translate3d(310%, 0, 0); }
}

.wx-widget[data-wx-effect="clear"] .wx-anim-layer::before {
    content: "";
    position: absolute;
    top: -40%;
    right: -20%;
    width: 70%;
    height: 120%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 214, 102, 0.55) 0%, rgba(255, 214, 102, 0) 68%);
    animation: wx-glow 9s ease-in-out infinite alternate;
}

.wx-widget[data-wx-effect="clear"][data-wx-night="1"] .wx-anim-layer::before {
    background: radial-gradient(circle, rgba(188, 214, 255, 0.4) 0%, rgba(188, 214, 255, 0) 68%);
}

@keyframes wx-glow {
    from { transform: scale(0.94); opacity: 0.65; }
    to { transform: scale(1.06); opacity: 1; }
}

.wx-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px 20px;
    flex-wrap: wrap;
}

.wx-widget.wx-has-toggle .wx-head {
    padding-right: 112px;
}

.wx-place {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    min-width: 0;
}

.wx-city {
    margin: 0;
    font-size: clamp(20px, 2.4vw, 28px);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.02em;
    overflow-wrap: anywhere;
}

.wx-country {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border: 1px solid var(--wx-line);
    border-radius: 999px;
    color: var(--wx-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.wx-updated {
    color: var(--wx-muted);
    font-size: 12px;
    white-space: nowrap;
}

.wx-now {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(220px, 0.85fr);
    align-items: center;
    gap: clamp(18px, 3vw, 32px);
    margin-top: clamp(18px, 3vw, 28px);
}

.wx-summary {
    display: flex;
    align-items: center;
    gap: clamp(10px, 2vw, 20px);
    min-width: 0;
}

.wx-icon {
    flex: 0 0 auto;
    width: clamp(76px, 10vw, 112px);
    height: clamp(76px, 10vw, 112px);
    filter: drop-shadow(0 10px 18px rgba(19, 32, 44, 0.16));
}

.wx-widget[data-wx-theme="dark"] .wx-icon {
    filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.34)) brightness(1.06);
}

@media (prefers-color-scheme: dark) {
    .wx-widget[data-wx-theme="auto"] .wx-icon {
        filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.34)) brightness(1.06);
    }
}

.wx-temp-block {
    min-width: 0;
}

.wx-temp {
    display: flex;
    align-items: flex-start;
    color: var(--wx-text);
    font-size: clamp(46px, 8vw, 78px);
    font-weight: 750;
    line-height: 0.95;
    letter-spacing: -0.055em;
}

.wx-unit {
    margin-top: 0.18em;
    margin-left: 4px;
    color: var(--wx-muted);
    font-size: 0.36em;
    font-weight: 600;
    letter-spacing: 0;
}

.wx-desc {
    margin-top: 8px;
    font-size: clamp(15px, 1.7vw, 19px);
    font-weight: 600;
    overflow-wrap: anywhere;
}

.wx-feels {
    margin-top: 2px;
    color: var(--wx-muted);
    font-size: 13px;
}

.wx-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
    gap: 2px;
    margin: 0;
    padding: 6px;
    border: 1px solid var(--wx-line);
    border-radius: 14px;
    background: var(--wx-bg-soft);
}

.wx-metric {
    padding: 9px 10px;
    border-radius: 10px;
}

.wx-metric dt {
    margin: 0 0 1px;
    color: var(--wx-muted);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.wx-metric dd {
    margin: 0;
    font-size: 14px;
    font-weight: 650;
    line-height: 1.25;
}

.wx-forecast {
    margin-top: clamp(18px, 3vw, 26px);
    padding-top: clamp(14px, 2.4vw, 20px);
    border-top: 1px solid var(--wx-line);
}

.wx-forecast-title {
    margin: 0 0 10px;
    color: var(--wx-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.wx-forecast-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.wx-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    min-width: 0;
    padding: 10px 8px;
    border: 1px solid var(--wx-line);
    border-radius: 12px;
    background: var(--wx-bg-soft);
    text-align: center;
}

.wx-day.is-today {
    border-color: var(--wx-accent);
    background: var(--wx-accent-soft);
}

.wx-day-name {
    font-size: 13px;
    font-weight: 750;
}

.wx-day-date {
    color: var(--wx-muted);
    font-size: 11px;
}

.wx-day-icon {
    width: 44px;
    height: 44px;
    margin: 1px 0;
}

.wx-day-desc {
    display: -webkit-box;
    overflow: hidden;
    min-height: 2.5em;
    color: var(--wx-muted);
    font-size: 11px;
    line-height: 1.25;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.wx-day-temp {
    display: inline-flex;
    align-items: baseline;
    gap: 5px;
    margin-top: 2px;
    font-size: 14px;
}

.wx-day-temp strong {
    font-weight: 750;
}

.wx-day-temp span {
    color: var(--wx-muted);
    font-size: 12px;
}

.wx-day-pop {
    color: var(--wx-muted);
    font-size: 10px;
    white-space: nowrap;
}

.wx-toggle {
    position: absolute;
    top: clamp(14px, 2.2vw, 22px);
    right: clamp(14px, 2.2vw, 22px);
    z-index: 4;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 10px 6px 8px;
    border: 1px solid var(--wx-line);
    border-radius: 999px;
    background: var(--wx-bg-soft);
    color: var(--wx-muted);
    font: inherit;
    font-size: 11px;
    font-weight: 650;
    line-height: 1;
    cursor: pointer;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.wx-toggle:hover {
    color: var(--wx-text);
    border-color: var(--wx-accent);
}

.wx-toggle:focus-visible {
    outline: 2px solid var(--wx-accent);
    outline-offset: 2px;
}

.wx-switch {
    position: relative;
    display: inline-block;
    width: 28px;
    height: 16px;
    border-radius: 999px;
    background: var(--wx-accent);
    transition: background 160ms ease;
}

.wx-switch-dot {
    position: absolute;
    top: 2px;
    left: 14px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
    transition: transform 160ms ease;
}

.wx-toggle[aria-pressed="false"] .wx-switch {
    background: var(--wx-muted);
}

.wx-toggle[aria-pressed="false"] .wx-switch-dot {
    transform: translateX(-12px);
}

.wx-widget:not(.wx-js) .wx-toggle {
    display: none;
}

.wx-empty {
    padding: clamp(22px, 4vw, 34px);
    border: 1px dashed var(--wx-line);
    border-radius: 14px;
    background: var(--wx-bg-soft);
    text-align: center;
}

.wx-empty-title {
    margin: 0;
    font-size: 15px;
    font-weight: 650;
}

.wx-empty-hint {
    margin: 8px 0 0;
    color: var(--wx-muted);
    font-size: 12px;
}

@media (max-width: 760px) {
    .wx-now {
        grid-template-columns: minmax(0, 1fr);
        gap: 18px;
    }

    .wx-widget.wx-has-toggle .wx-head {
        padding-right: 0;
        padding-top: 34px;
    }

    .wx-toggle {
        top: 12px;
        right: 12px;
    }
}

@media (max-width: 520px) {
    .wx-content {
        padding: 16px;
    }

    .wx-city {
        font-size: 19px;
    }

    .wx-temp {
        font-size: 54px;
    }

    .wx-summary {
        gap: 8px;
    }

    .wx-forecast-list {
        display: flex;
        gap: 8px;
        overflow-x: auto;
        padding-bottom: 6px;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
    }

    .wx-day {
        flex: 0 0 116px;
        scroll-snap-align: start;
    }

    .wx-metrics {
        grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    .wx-widget[data-wx-animations="0"] *,
    .wx-widget[data-wx-animations="0"] *::before,
    .wx-widget[data-wx-animations="0"] *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
        transition-duration: 0.001ms !important;
    }
}

@media print {
    .wx-anim-layer,
    .wx-toggle {
        display: none !important;
    }

    .wx-widget {
        box-shadow: none;
        border-color: #cccccc;
    }
}
