/* ==================== 全局样式 - 深色玻璃拟态 · 翡翠绿青金 ==================== */
:root {
    /* 主色调：翡翠绿 + 青金 */
    --emerald: #10b981;
    --emerald-light: #34d399;
    --cyan: #06b6d4;
    --cyan-light: #22d3ee;
    --teal: #14b8a6;

    /* 文字色 */
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;

    /* 玻璃材质 */
    --glass-bg: rgba(255, 255, 255, 0.06);
    --glass-bg-strong: rgba(255, 255, 255, 0.09);
    --glass-border: rgba(255, 255, 255, 0.12);
    --glass-border-strong: rgba(255, 255, 255, 0.2);
    --glass-blur: blur(20px);

    /* 阴影 */
    --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-glow-emerald: 0 8px 32px rgba(16, 185, 129, 0.25);
    --shadow-glow-cyan: 0 8px 32px rgba(6, 182, 212, 0.25);

    /* 渐变 */
    --gradient-main: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
    --gradient-soft: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(6, 182, 212, 0.15) 100%);
}

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

/* 深色渐变背景 + 模糊光斑 */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, '微软雅黑';
    background: #0a0f1e;
    background-image:
        radial-gradient(circle at 15% 20%, rgba(16, 185, 129, 0.25) 0%, transparent 40%),
        radial-gradient(circle at 85% 30%, rgba(6, 182, 212, 0.22) 0%, transparent 45%),
        radial-gradient(circle at 50% 90%, rgba(20, 184, 166, 0.18) 0%, transparent 50%),
        linear-gradient(160deg, #0a0f1e 0%, #0f1729 50%, #0a1014 100%);
    background-attachment: fixed;
    min-height: 100vh;
    padding: 20px;
    color: var(--text-primary);
    position: relative;
    overflow-x: hidden;
}

/* 顶部主容器：玻璃卡片 */
.container {
    max-width: 1000px;
    margin: 0 auto;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 32px;
    box-shadow: var(--shadow-soft);
    position: relative;
    overflow: hidden;
}

/* 顶部高光线条 */
.container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(52, 211, 153, 0.6), transparent);
}

/* ==================== 标题 ==================== */
header {
    text-align: center;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--glass-border);
}

header h1 {
    font-size: 2.2em;
    background: linear-gradient(135deg, #34d399 0%, #22d3ee 50%, #34d399 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
    font-weight: 700;
    letter-spacing: -0.5px;
    animation: gradientShift 6s ease infinite;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% center; }
    50% { background-position: 200% center; }
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.95em;
    font-weight: 400;
}

/* ==================== 使用说明 ==================== */
.instructions {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    padding: 20px 24px;
    margin-bottom: 24px;
    border-radius: 16px;
    transition: all 0.3s ease;
}

.instructions:hover {
    border-color: var(--glass-border-strong);
    background: var(--glass-bg-strong);
}

.instructions h3 {
    background: var(--gradient-main);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 14px;
    font-size: 1.15em;
    font-weight: 600;
}

.instructions ul {
    list-style-position: inside;
    line-height: 1.8;
    color: var(--text-secondary);
    font-size: 0.92em;
}

.instructions ul li::marker {
    color: var(--emerald-light);
}

.api-notice {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.3);
    padding: 14px 16px;
    margin-top: 16px;
    border-radius: 12px;
    font-size: 0.88em;
    color: #fcd34d;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.api-notice a {
    color: var(--cyan-light);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.api-notice a:hover {
    color: var(--emerald-light);
    text-decoration: underline;
}

/* ==================== 搜索区域 ==================== */
.search-section {
    margin-bottom: 28px;
}

.search-box {
    display: flex;
    gap: 10px;
    max-width: 600px;
    margin: 0 auto;
}

#cityInput {
    flex: 1;
    padding: 12px 16px;
    font-size: 15px;
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    outline: none;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

#cityInput::placeholder {
    color: var(--text-muted);
}

#cityInput:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--emerald);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18), var(--shadow-glow-emerald);
}

#searchBtn {
    padding: 12px 22px;
    background: var(--gradient-main);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    box-shadow: var(--shadow-glow-emerald);
    position: relative;
    overflow: hidden;
}

#searchBtn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.6s ease;
}

#searchBtn:hover::before {
    left: 100%;
}

#searchBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 36px rgba(16, 185, 129, 0.4);
}

#searchBtn:active {
    transform: scale(0.97) translateY(0);
}

.btn-icon {
    font-size: 1.1em;
}

/* 热门城市 */
.hot-cities-inline {
    text-align: center;
    margin-top: 16px;
    padding: 8px;
    color: var(--text-muted);
    font-size: 13px;
}

.hot-label {
    background: var(--gradient-main);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 600;
    margin-right: 8px;
}

.hot-cities-inline a {
    color: var(--text-secondary);
    text-decoration: none;
    margin: 0 4px;
    transition: all 0.25s ease;
    padding: 5px 10px;
    border-radius: 8px;
    font-weight: 500;
    border: 1px solid transparent;
    display: inline-block;
}

.hot-cities-inline a:hover {
    color: var(--emerald-light);
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.3);
    transform: translateY(-1px);
}

/* ==================== 加载和错误提示 ==================== */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--emerald-light);
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(16, 185, 129, 0.15);
    border-top: 3px solid var(--emerald);
    border-right: 3px solid var(--cyan);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
    margin: 0 auto 16px;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    padding: 14px 18px;
    border-radius: 12px;
    margin-bottom: 16px;
    text-align: center;
    font-size: 0.92em;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* ==================== 当前天气 ==================== */
.current-weather {
    margin-bottom: 24px;
    background:
        linear-gradient(135deg, rgba(16, 185, 129, 0.25) 0%, rgba(6, 182, 212, 0.25) 100%),
        rgba(255, 255, 255, 0.04);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border-strong);
    color: white;
    padding: 28px;
    border-radius: 20px;
    box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    position: relative;
    overflow: hidden;
}

/* 卡片右上角光晕装饰 */
.current-weather::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 60%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.08) 0%, transparent 60%);
    pointer-events: none;
}

.weather-header {
    text-align: center;
    margin-bottom: 24px;
    position: relative;
    z-index: 1;
}

.weather-header h2 {
    font-size: 1.7em;
    margin-bottom: 6px;
    font-weight: 700;
    text-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.weather-header p {
    opacity: 0.85;
    font-size: 0.88em;
}

.weather-main {
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: relative;
    z-index: 1;
}

.temperature-section {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 28px;
}

#weatherIcon {
    width: 110px;
    height: 110px;
    filter: drop-shadow(0 4px 20px rgba(0, 0, 0, 0.4));
    animation: floatIcon 4s ease-in-out infinite;
}

@keyframes floatIcon {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.temp-info {
    text-align: center;
}

.temp-current {
    font-size: 3.6em;
    font-weight: 200;
    line-height: 1;
    text-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

.temp-desc {
    font-size: 1.3em;
    margin-top: 10px;
    opacity: 0.95;
    font-weight: 500;
}

.weather-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.detail-item {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 14px;
    border-radius: 14px;
    text-align: center;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: all 0.3s ease;
}

.detail-item:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-3px);
}

.detail-label {
    display: block;
    font-size: 0.85em;
    opacity: 0.85;
    margin-bottom: 6px;
}

.detail-value {
    display: block;
    font-size: 1.2em;
    font-weight: 600;
}

/* ==================== 近几日天气预报 ==================== */
.forecast-section {
    margin-bottom: 24px;
}

.forecast-section h3 {
    background: var(--gradient-main);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 18px;
    text-align: center;
    font-size: 1.4em;
    font-weight: 700;
}

.forecast-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 14px;
}

.forecast-day {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 18px 12px;
    text-align: center;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.forecast-day::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--gradient-main);
    transform: scaleX(0);
    transition: transform 0.35s ease;
}

.forecast-day:hover {
    transform: translateY(-6px);
    background: var(--glass-bg-strong);
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: var(--shadow-glow-emerald);
}

.forecast-day:hover::before {
    transform: scaleX(1);
}

.forecast-date {
    font-weight: 600;
    color: var(--emerald-light);
    margin-bottom: 4px;
    font-size: 0.92em;
}

.forecast-weekday {
    color: var(--text-muted);
    font-size: 0.82em;
    margin-bottom: 8px;
}

.forecast-icon {
    width: 52px;
    height: 52px;
    margin: 8px auto;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
    transition: transform 0.3s ease;
}

.forecast-day:hover .forecast-icon {
    transform: scale(1.12);
}

.forecast-temp {
    font-size: 1.2em;
    font-weight: 600;
    color: var(--text-primary);
    margin: 8px 0;
}

.forecast-desc {
    color: var(--text-secondary);
    font-size: 0.85em;
    margin-bottom: 8px;
}

.forecast-details {
    display: flex;
    justify-content: space-around;
    font-size: 0.8em;
    color: var(--text-muted);
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--glass-border);
}

/* ==================== 实时气象云图 ==================== */
.map-section {
    margin-bottom: 24px;
}

/* 标题行：标题 + 切换按钮 */
.map-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
    padding: 0 4px;
}

.map-header h3 {
    background: var(--gradient-main);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
    font-size: 1.4em;
    font-weight: 700;
}

/* 切换按钮组 */
.map-switch {
    display: inline-flex;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 4px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.map-switch-btn {
    padding: 7px 16px;
    font-size: 0.88em;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.28s ease;
    white-space: nowrap;
}

.map-switch-btn:hover {
    color: var(--text-secondary);
}

.map-switch-btn.active {
    color: #ffffff;
    background: var(--gradient-main);
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

/* 单图容器 */
.map-wrapper {
    position: relative;
    width: 100%;
    max-width: 650px;
    margin: 0 auto;
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid var(--glass-border-strong);
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow-soft);
    aspect-ratio: 650 / 580;
    transition: all 0.35s ease;
    display: none;
}

.map-wrapper.active {
    display: block;
}

.map-wrapper:hover {
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: var(--shadow-glow-emerald);
}

/* iframe 自适应容器宽度 */
.map-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

/* 多图容器：2x2 网格 */
.map-multi {
    display: none;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    max-width: 880px;
    margin: 0 auto;
}

.map-multi.active {
    display: grid;
}

.map-cell {
    position: relative;
    width: 100%;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--glass-border-strong);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-soft);
    transition: box-shadow 0.3s ease, border-color 0.3s ease;
    /* 高度由 JS 根据 scale 动态设置，避免地图裁切 */
}

.map-cell:hover {
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: var(--shadow-glow-emerald);
}

.map-cell-label {
    position: absolute;
    top: 10px;
    left: 12px;
    z-index: 2;
    padding: 4px 10px;
    font-size: 0.8em;
    font-weight: 600;
    color: #ffffff;
    background: rgba(10, 15, 30, 0.55);
    border: 1px solid var(--glass-border-strong);
    border-radius: 8px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    pointer-events: none;
}

/* iframe 保持原始 650×450 渲染，用 transform 等比缩小，杜绝裁切 */
.map-cell iframe {
    display: block;
    width: 650px;
    height: 450px;
    border: 0;
    transform-origin: top left;
}

/* ==================== 页脚 ==================== */
footer {
    text-align: center;
    padding-top: 20px;
    margin-top: 28px;
    border-top: 1px solid var(--glass-border);
    color: var(--text-muted);
    font-size: 0.88em;
}

.footer-links {
    margin-bottom: 8px;
}

.footer-links a {
    color: var(--cyan-light);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.25s ease;
    padding: 4px 6px;
    border-radius: 6px;
}

.footer-links a:hover {
    color: var(--emerald-light);
    background: rgba(16, 185, 129, 0.1);
    text-decoration: none;
}

.footer-sep {
    color: var(--text-muted);
    margin: 0 8px;
    opacity: 0.5;
}

footer a {
    color: var(--cyan-light);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

footer a:hover {
    color: var(--emerald-light);
    text-decoration: underline;
}

footer p {
    margin: 4px 0;
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    .container {
        padding: 20px;
        border-radius: 18px;
    }

    header h1 {
        font-size: 1.7em;
    }

    .search-box {
        flex-direction: column;
    }

    .hot-cities-inline {
        font-size: 12px;
    }

    .hot-cities-inline a {
        margin: 0 3px;
        padding: 4px 7px;
    }

    .temperature-section {
        flex-direction: column;
        gap: 14px;
    }

    #weatherIcon {
        width: 84px;
        height: 84px;
    }

    .temp-current {
        font-size: 2.9em;
    }

    .weather-details {
        grid-template-columns: repeat(2, 1fr);
    }

    .forecast-container {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 10px;
    }

    .current-weather {
        padding: 20px;
    }

    /* 移动端：标题行居中堆叠，多图改单列 */
    .map-header {
        flex-direction: column;
        text-align: center;
    }

    .map-multi.active {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 14px;
        border-radius: 14px;
    }

    header h1 {
        font-size: 1.5em;
    }

    .subtitle {
        font-size: 0.85em;
    }

    .hot-cities-inline {
        font-size: 11px;
    }

    .hot-cities-inline a {
        display: inline-block;
        margin: 2px 3px;
    }

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

    .current-weather {
        padding: 18px;
    }

    .temp-current {
        font-size: 2.6em;
    }

    .instructions {
        padding: 16px;
    }
}

/* ==================== 滚动条美化 ==================== */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #0a0f1e;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, var(--emerald), var(--cyan));
    border-radius: 5px;
    border: 2px solid #0a0f1e;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--emerald-light), var(--cyan-light));
}

/* 选中文字颜色 */
::selection {
    background: rgba(16, 185, 129, 0.4);
    color: #ffffff;
}
