/* ============================================================
   withU 天气详情弹层
   ------------------------------------------------------------
   - 点击首页天气卡打开的浮动天气卡
   - 浅色纸感卡片 + 天气渐变头部，参考博客/网站天气弹窗
   - 当前天气、24 小时温度曲线、未来 7 天、过去 7 天、详情
   - 动效克制，支持 prefers-reduced-motion
   ============================================================ */

.wu-weather-modal {
    --wu-wm-font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    --wu-wm-ink: #2b2327;
    --wu-wm-ink-2: #6d6167;
    --wu-wm-ink-3: #9b8e94;
    --wu-wm-line: rgba(43, 35, 39, 0.08);
    --wu-wm-rose: #f87171;
    --wu-wm-gold: #c9a26b;
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    font-family: var(--wu-wm-font);
    color: var(--wu-wm-ink);
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.26s ease, visibility 0.26s ease;
}

.wu-weather-modal.is-open {
    visibility: visible;
    opacity: 1;
}

.wu-weather-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(43, 35, 39, 0.3);
    backdrop-filter: blur(14px) saturate(120%);
    -webkit-backdrop-filter: blur(14px) saturate(120%);
}

.wu-weather-modal__sheet {
    position: relative;
    width: min(420px, calc(100vw - 32px));
    max-height: min(88vh, 780px);
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.92);
    border-radius: 30px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: linear-gradient(180deg, #fffdfb 0%, #fdf7f3 100%);
    box-shadow:
        0 40px 100px -36px rgba(43, 35, 39, 0.55),
        0 12px 30px -22px rgba(43, 35, 39, 0.25);
    scrollbar-width: thin;
    scrollbar-color: rgba(43, 35, 39, 0.16) transparent;
    transform: translateY(16px) scale(0.98);
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.wu-weather-modal__sheet::-webkit-scrollbar {
    width: 5px;
}

.wu-weather-modal__sheet::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(43, 35, 39, 0.16);
}

.wu-weather-modal.is-open .wu-weather-modal__sheet {
    transform: translateY(0) scale(1);
}

/* ------------------------------------------------------------
   天气渐变头部
   ------------------------------------------------------------ */
.wu-weather-modal__hero {
    position: relative;
    padding: 16px 16px 18px;
    border-radius: 23px;
    overflow: hidden;
    color: #fff;
    background: linear-gradient(135deg, #a9d6ee 0%, #7fb3dc 52%, #6998c5 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.42),
        0 18px 36px -26px rgba(64, 108, 148, 0.65);
}

.wu-weather-modal__sheet--orange .wu-weather-modal__hero {
    background: linear-gradient(135deg, #f6cb9e 0%, #eaa678 52%, #d4895c 100%);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.44),
        0 18px 36px -26px rgba(168, 105, 64, 0.6);
}

.wu-weather-modal__hero::before {
    content: "";
    position: absolute;
    top: -80px;
    right: -50px;
    width: 190px;
    height: 190px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.38), transparent 66%);
    pointer-events: none;
}

.wu-weather-modal__hero::after {
    content: "";
    position: absolute;
    left: -40px;
    bottom: -70px;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.2), transparent 66%);
    pointer-events: none;
}

.wu-weather-modal__hero > * {
    position: relative;
    z-index: 1;
}

.wu-weather-modal__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    min-width: 0;
}

.wu-weather-modal__top > div {
    flex: 1 1 auto;
    min-width: 0;
}

.wu-weather-modal__city {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    margin: 0;
    font-size: 15px;
    font-weight: 650;
    letter-spacing: 0.01em;
    line-height: 1.3;
    color: #fff;
}

.wu-weather-modal__city i {
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.92);
}

.wu-weather-modal__city span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wu-weather-modal__date {
    margin: 4px 0 0;
    font-size: 11.5px;
    line-height: 1.35;
    color: rgba(255, 255, 255, 0.74);
}

.wu-weather-modal__close {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid rgba(255, 255, 255, 0.34);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: background 0.2s ease, transform 0.2s ease;
}

.wu-weather-modal__close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.wu-weather-modal__close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.wu-weather-modal__now {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 2px 2px;
}

.wu-weather-modal__now-main {
    min-width: 0;
}

.wu-weather-modal__temp {
    display: flex;
    align-items: flex-start;
    font-size: clamp(60px, 15vw, 78px);
    font-weight: 200;
    line-height: 0.95;
    letter-spacing: -0.06em;
    font-variant-numeric: tabular-nums;
    color: #fff;
}

.wu-weather-modal__temp sup {
    margin-top: 0.14em;
    font-size: 0.42em;
    font-weight: 300;
    line-height: 1;
}

.wu-weather-modal__desc {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    color: #fff;
}

.wu-weather-modal__range {
    margin-top: 4px;
    font-size: 11.5px;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.78);
}

.wu-weather-modal__now-icon {
    flex-shrink: 0;
    padding-right: 4px;
    line-height: 1;
}

.wu-weather-modal__now-icon i {
    font-size: clamp(60px, 14vw, 80px);
    line-height: 1;
    color: #fff;
    opacity: 0.95;
    filter: drop-shadow(0 10px 20px rgba(32, 60, 86, 0.18));
    animation: wu-weather-icon-float 6s ease-in-out infinite;
}

/* ------------------------------------------------------------
   浅色内容区
   ------------------------------------------------------------ */
.wu-weather-modal__body {
    padding: 10px 4px 4px;
}

.wu-weather-modal__section {
    position: relative;
    margin-top: 10px;
    padding: 14px;
    border: 1px solid var(--wu-wm-line);
    border-radius: 20px;
    background: linear-gradient(180deg, #fffdfb 0%, #fffaf7 100%);
    box-shadow: 0 12px 28px -24px rgba(43, 35, 39, 0.35);
    color: var(--wu-wm-ink);
}

.wu-weather-modal__section[hidden] {
    display: none !important;
}

.wu-weather-modal__section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--wu-wm-ink-3);
}

.wu-weather-modal__section-head span:last-child {
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: none;
    color: #b0a3a9;
    white-space: nowrap;
}

.wu-weather-modal__section-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.wu-weather-modal__section-actions > span {
    font-weight: 500;
    letter-spacing: 0.04em;
    color: #b0a3a9;
    white-space: nowrap;
}

.wu-weather-modal__hourly-nav {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid rgba(43, 35, 39, 0.08);
    border-radius: 50%;
    background: #fff;
    color: #8a7d83;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.wu-weather-modal__hourly-nav:hover {
    background: #fdeeee;
    color: var(--wu-wm-rose);
}

.wu-weather-modal__hourly-nav:disabled {
    opacity: 0.35;
    cursor: default;
}

.wu-weather-modal__hourly-nav:focus-visible {
    outline: 2px solid var(--wu-wm-rose);
    outline-offset: 2px;
}

/* ------------------------------------------------------------
   24 小时：温度曲线 + 卡片
   ------------------------------------------------------------ */
.wu-weather-modal__hourly {
    display: block;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
    scrollbar-color: rgba(43, 35, 39, 0.18) transparent;
    -webkit-overflow-scrolling: touch;
    -webkit-mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 18px), transparent 100%);
    mask-image: linear-gradient(to right, #000 0, #000 calc(100% - 18px), transparent 100%);
}

.wu-weather-modal__hourly::-webkit-scrollbar {
    height: 4px;
}

.wu-weather-modal__hourly::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(43, 35, 39, 0.16);
}

.wu-weather-modal__hourly::-webkit-scrollbar-track {
    background: transparent;
}

.wu-weather-modal__hourly-track {
    width: max-content;
    min-width: 100%;
}

.wu-weather-modal__hourly-chart {
    display: block;
    margin: 2px 0 6px;
    animation: wu-weather-item-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.wu-weather-modal__hourly-cards {
    display: flex;
    gap: 8px;
    padding-bottom: 2px;
}

.wu-weather-modal__hour {
    flex: 0 0 58px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 8px 4px;
    border: 1px solid rgba(43, 35, 39, 0.07);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 4px 12px -10px rgba(43, 35, 39, 0.25);
    text-align: center;
    color: var(--wu-wm-ink);
    animation: wu-weather-item-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: calc(var(--i, 0) * 18ms);
}

.wu-weather-modal__hour.is-now {
    border-color: rgba(248, 113, 113, 0.22);
    background: linear-gradient(180deg, #fff6f6, #fff1f1);
    box-shadow: 0 8px 18px -14px rgba(248, 113, 113, 0.5);
}

.wu-weather-modal__hour-time {
    font-size: 11px;
    line-height: 1.2;
    color: var(--wu-wm-ink-3);
    white-space: nowrap;
}

.wu-weather-modal__hour i {
    font-size: 22px;
    line-height: 1;
    color: #7a9fbd;
}

.wu-weather-modal__hour.is-now i {
    color: var(--wu-wm-rose);
}

.wu-weather-modal__hour-temp {
    font-size: 14px;
    font-weight: 650;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    color: var(--wu-wm-ink);
}

.wu-weather-modal__hour-pop {
    min-height: 12px;
    font-size: 10px;
    line-height: 1.2;
    color: #8fb4cd;
    white-space: nowrap;
}

/* ------------------------------------------------------------
   未来 / 过去每日列表
   ------------------------------------------------------------ */
.wu-weather-modal__daily {
    display: flex;
    flex-direction: column;
}

.wu-weather-modal__day {
    display: grid;
    grid-template-columns: 48px 26px minmax(0, 1fr) auto;
    grid-template-rows: auto 4px;
    align-items: center;
    gap: 6px 10px;
    padding: 9px 2px;
    border-top: 1px solid rgba(43, 35, 39, 0.06);
    font-size: 13px;
    line-height: 1.3;
    animation: wu-weather-item-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
    animation-delay: calc(var(--i, 0) * 18ms);
}

.wu-weather-modal__day:first-child {
    border-top: 0;
}

.wu-weather-modal__day-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
    color: #5d5360;
}

.wu-weather-modal__day i {
    font-size: 20px;
    text-align: center;
    color: #7a9fbd;
}

.wu-weather-modal__day-desc {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--wu-wm-ink-3);
}

.wu-weather-modal__day-temp {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    color: var(--wu-wm-ink);
}

.wu-weather-modal__day-temp b {
    font-weight: 650;
}

.wu-weather-modal__day-temp em {
    font-style: normal;
    color: var(--wu-wm-ink-3);
}

.wu-weather-modal__day-bar {
    grid-column: 3 / -1;
    height: 4px;
    border-radius: 999px;
    background: rgba(43, 35, 39, 0.07);
    overflow: hidden;
}

.wu-weather-modal__day-bar i {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #8fc7ee, #f3b17d);
}

/* ------------------------------------------------------------
   天气详情
   ------------------------------------------------------------ */
.wu-weather-modal__details {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.wu-weather-modal__detail {
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid rgba(43, 35, 39, 0.06);
    border-radius: 14px;
    background: #fff;
}

.wu-weather-modal__detail-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10px;
    line-height: 1.3;
    letter-spacing: 0.04em;
    color: var(--wu-wm-ink-3);
    white-space: nowrap;
}

.wu-weather-modal__detail-label i {
    color: var(--wu-wm-gold);
}

.wu-weather-modal__detail-value {
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 15px;
    font-weight: 650;
    line-height: 1.25;
    font-variant-numeric: tabular-nums;
    color: var(--wu-wm-ink);
}

/* ------------------------------------------------------------
   加载 / 空状态 / 页脚 / 完成按钮
   ------------------------------------------------------------ */
.wu-weather-modal__loading,
.wu-weather-modal__empty {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 2px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--wu-wm-ink-3);
}

.wu-weather-spinner {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(43, 35, 39, 0.15);
    border-top-color: var(--wu-wm-rose);
    border-radius: 50%;
    animation: wu-weather-spin 0.8s linear infinite;
}

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

.wu-weather-modal__foot {
    margin: 14px 0 0;
    text-align: center;
    font-size: 10px;
    line-height: 1.4;
    letter-spacing: 0.06em;
    color: #b0a3a9;
}

.wu-weather-modal__done {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 12px 16px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(135deg, #fca5a5 0%, #f87171 52%, #e05757 100%);
    color: #fff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    box-shadow: 0 14px 28px -16px rgba(248, 113, 113, 0.7);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.wu-weather-modal__done:hover {
    transform: translateY(-1px);
    filter: brightness(1.03);
    box-shadow: 0 18px 32px -16px rgba(248, 113, 113, 0.8);
}

.wu-weather-modal__done:focus-visible {
    outline: 2px solid var(--wu-wm-rose);
    outline-offset: 3px;
}

/* ------------------------------------------------------------
   打开时锁定页面滚动
   ------------------------------------------------------------ */
html.wu-weather-modal-open,
html.wu-weather-modal-open body {
    overflow: hidden !important;
}

html.wu-weather-modal-open #confetti-canvas {
    opacity: 0 !important;
    visibility: hidden !important;
}

html.wu-weather-modal-open .withu-scroll-progress {
    opacity: 0 !important;
}

/* ------------------------------------------------------------
   动效
   ------------------------------------------------------------ */
@keyframes wu-weather-item-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes wu-weather-icon-float {
    0%, 100% { transform: translateY(0) rotate(0); }
    50% { transform: translateY(-4px) rotate(-1deg); }
}

/* ------------------------------------------------------------
   响应式
   ------------------------------------------------------------ */
@media (max-width: 640px) {
    .wu-weather-modal {
        padding: 10px;
    }

    .wu-weather-modal__sheet {
        width: calc(100vw - 20px);
        max-height: calc(100dvh - 20px);
        padding: 8px;
        border-radius: 26px;
    }

    .wu-weather-modal__hero {
        padding: 14px;
        border-radius: 20px;
    }

    .wu-weather-modal__temp {
        font-size: clamp(58px, 20vw, 76px);
    }

    .wu-weather-modal__now-icon i {
        font-size: clamp(56px, 18vw, 74px);
    }

    .wu-weather-modal__body {
        padding: 8px 2px 2px;
    }

    .wu-weather-modal__section {
        padding: 12px;
        border-radius: 18px;
    }
}

@media (max-width: 360px) {
    .wu-weather-modal__day {
        grid-template-columns: 42px 22px minmax(0, 1fr) auto;
        gap: 6px 8px;
    }

    .wu-weather-modal__details {
        grid-template-columns: 1fr;
    }
}

@media (prefers-reduced-motion: reduce) {
    .wu-weather-modal,
    .wu-weather-modal__sheet {
        transition: none;
    }

    .wu-weather-modal__hour,
    .wu-weather-modal__day,
    .wu-weather-modal__hourly-chart,
    .wu-weather-modal__now-icon i {
        animation: none;
    }

    .wu-weather-spinner {
        animation: none;
    }
}
