/**
 * 天气站全局样式 — 用于 index.php 整页
 * 设计：移动端优先；大屏参考腾讯天气 tianqi.qq.com 的宽屏布局（顶栏 + 主栏 + 侧栏生活指数）
 */

/* ========== 基础重置与页面背景 ========== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* ========== SEO/无障碍：仅视觉隐藏（用于页面 H1 等） ========== */
.tq-sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #1a2332;
    background: linear-gradient(165deg, #e8f4fc 0%, #f5f7fa 45%, #eef2f7 100%);
    min-height: 100dvh;
}

/* 外层全宽；内容区用 .tq-shell 限制最大宽度（手机仍近似全宽） */
.tq-app {
    margin: 0 auto;
    /* 让页脚贴底：底部留白交给 footer 自己处理 */
    padding: 0;
}

/* 与腾讯天气 PC 类似：内容区最大约 1200px 居中 */
.tq-shell {
    width: 100%;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 16px;
    padding-right: 16px;
}

/* ========== 顶部地区栏 — header.tq-top ========== */
.tq-top {
    padding: 16px 0 8px;
    position: sticky;
    top: 0;
    z-index: 30;
    /* 顶栏需要和页面底色拉开区分：更偏白的“玻璃”底 + 渐隐 */
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92) 62%, rgba(255, 255, 255, 0.72) 78%, rgba(245, 247, 250, 0) 100%);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: 0 6px 20px rgba(20, 50, 80, 0.08);
}

/* 顶栏一行：品牌 + 城市按钮（移动端纵向堆叠） */
.tq-top-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
}

.tq-brand {
    display: none;
}

.tq-brand-logo {
    display: block;
    font-size: 1.25rem;
    font-weight: 800;
    color: #0d3d5c;
    letter-spacing: 0.02em;
}

.tq-brand-sub {
    display: block;
    margin-top: 2px;
    font-size: 0.8rem;
    font-weight: 400;
    color: #6b7f8f;
}

.tq-loc-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    border: 1px solid rgba(255, 255, 255, 0.9);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 4px 20px rgba(30, 60, 90, 0.08);
    font-size: 1rem;
    font-weight: 600;
    color: #1a4a6e;
    cursor: pointer;
}

.tq-loc-name {
    flex: 1;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tq-loc-arrow {
    font-size: 0.7rem;
    opacity: 0.55;
}

/* 提示条 — 错误 / 缓存降级 */
.tq-banner {
    margin: 10px 0 0;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 0.875rem;
    text-align: center;
}

.tq-banner--warn {
    background: #fff3e0;
    color: #b45309;
}

.tq-banner--muted {
    background: rgba(255, 255, 255, 0.7);
    color: #5c6b7a;
}

/* ========== 当前天气大卡片 — section.tq-now ========== */
.tq-main {
    padding-top: 20px;
}

.tq-now {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 16px;
    box-shadow: 0 8px 32px rgba(25, 80, 120, 0.12);
}

.tq-now-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #7ec8e3 0%, #b8dfe9 50%, #d4e8f2 100%);
    opacity: 0.95;
}

.tq-now-inner {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 18px 24px;
}

.tq-now-icon {
    flex-shrink: 0;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.12));
}

.tq-now-meta {
    flex: 1;
    min-width: 0;
}

/* ========== 空气质量模块（放在当前天气右侧） ========== */
.tq-now-aqi {
    flex: 0 0 auto;
    width: min(320px, 42%);
    border-radius: 14px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid rgba(255, 255, 255, 0.78);
    box-shadow: 0 6px 22px rgba(20, 50, 80, 0.10);
}

.tq-aqi-head {
    padding: 10px 12px;
    color: #fff;
    background: linear-gradient(135deg, #f2b34c 0%, #e98a2f 45%, #df6f23 100%);
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

.tq-aqi-title {
    font-size: 0.8rem;
    opacity: 0.95;
    letter-spacing: 0.02em;
}

.tq-aqi-val {
    font-size: 1.25rem;
    font-weight: 800;
}

.tq-aqi-name {
    font-size: 0.85rem;
    font-weight: 700;
    opacity: 0.95;
}

.tq-aqi-ico {
    margin-left: auto;
    width: 22px;
    height: 22px;
    object-fit: contain;
    opacity: 0.95;
}

/* 空气质量卡片内的日出日落（来自 air|rise 接口） */
.tq-aqi-sun {
    padding: 8px 12px;
    font-size: 0.78rem;
    color: #3d5a6e;
    background: rgba(255, 255, 255, 0.74);
    border-bottom: 1px solid rgba(230, 238, 245, 0.9);
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.tq-aqi-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    background: rgba(255, 255, 255, 0.75);
}

.tq-aqi-item {
    padding: 10px 6px;
    text-align: center;
    border-right: 1px solid rgba(230, 238, 245, 0.9);
    border-top: 1px solid rgba(230, 238, 245, 0.9);
}

.tq-aqi-item:nth-child(3n) {
    border-right: none;
}

.tq-aqi-num {
    font-weight: 800;
    color: #1a2332;
}

.tq-aqi-lab {
    margin-top: 2px;
    font-size: 0.75rem;
    color: #7a8a99;
}

@media (max-width: 680px) {
    .tq-now-inner {
        flex-wrap: wrap;
    }
    .tq-now-aqi {
        width: 100%;
    }
    .tq-nearby-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.tq-now-temp {
    margin: 0;
    display: flex;
    align-items: baseline;
    gap: 2px;
}

.tq-now-degree {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #0d3d5c;
}

.tq-now-unit {
    font-size: 1.25rem;
    font-weight: 600;
    color: #3a6e8c;
}

.tq-now-desc {
    margin: 4px 0 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #1a4a6e;
}

/**
 * 当前天气「预警徽章」
 * 用途：index.php 当前天气卡片里，天气文案（如：晴）右侧展示预警（如：大雾预警）
 */
.tq-now-desc-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex-wrap: wrap;
}

.tq-alarm-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1;
    color: rgba(255, 255, 255, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.45);
    box-shadow: 0 10px 22px rgba(15, 35, 55, 0.18);
    user-select: none;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.02em;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}

/* 中国气象预警常见颜色：红/橙/黄/蓝。level_code 一般为 01/02/03/04（未知则走默认橙色） */
.tq-alarm--lv01 {
    background: linear-gradient(135deg, #ff4b4b 0%, #e11d48 55%, #be123c 100%);
}
.tq-alarm--lv02 {
    background: linear-gradient(135deg, #ff8a3d 0%, #f97316 50%, #ea580c 100%);
}
.tq-alarm--lv03 {
    background: linear-gradient(135deg, #ffb02e 0%, #f59e0b 55%, #d97706 100%);
}
.tq-alarm--lv04 {
    background: linear-gradient(135deg, #5aa9ff 0%, #2d8ae6 55%, #1d4ed8 100%);
}
.tq-alarm--lv00 {
    background: linear-gradient(135deg, #ff8a3d 0%, #f97316 50%, #ea580c 100%);
}

.tq-now-sub {
    margin: 8px 0 0;
    font-size: 0.875rem;
    color: #3d5a6e;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.tq-sub-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.tq-sub-ico {
    width: 14px;
    height: 14px;
    object-fit: contain;
    opacity: 0.9;
}

.tq-sub-dot {
    opacity: 0.65;
}

.tq-now-update {
    margin: 6px 0 0;
    font-size: 0.75rem;
    color: #6b7f8f;
}

/* ========== 通用卡片 — .tq-card ========== */
.tq-card {
    background: rgba(255, 255, 255, 0.92);
    border-radius: 16px;
    padding: 16px 14px;
    margin-bottom: 14px;
    box-shadow: 0 2px 16px rgba(20, 50, 80, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.tq-card-title {
    margin: 0 0 12px;
    font-size: 0.95rem;
    font-weight: 700;
    color: #2c4a5e;
}

/* 日出日落 — .tq-sun */
.tq-sun-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.95rem;
    color: #3d5a6e;
}

/* ========== 24 小时横向滚动 — .tq-scroll--1h ========== */
.tq-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.tq-hour {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    min-width: 56px;
    padding: 8px 6px;
    border-radius: 12px;
    background: #f0f6fa;
}

.tq-hour-time {
    font-size: 0.75rem;
    color: #5c6b7a;
}

.tq-hour-icon {
    width: 36px;
    height: 36px;
}

.tq-hour-deg {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1a4a6e;
}

/* ========== 7 日预报横向表 — .tq-week-card（对齐腾讯天气 7 日格：日期/昼夜文图/高低温/曲线/风力） ========== */
.tq-week {
    --week-n: 7;
    --week-today: -1;
    min-width: 0;
    position: relative;
}

.tq-week-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -6px;
    padding: 0 6px 4px;
}

/* 腾讯天气效果：整列「今天」淡色背景（一整块贯穿所有行） */
.tq-week::before {
    content: "";
    position: absolute;
    /* 上下多覆盖一点，避免顶部/底部出现“断开”的留白 */
    top: 0px;
    bottom: 0px;
    left: calc((100% / var(--week-n)) * var(--week-today));
    width: calc(100% / var(--week-n));
    background: rgba(80, 170, 255, 0.08);
    border-radius: 12px;
    pointer-events: none;
    opacity: 0;
}

.tq-week::before {
    opacity: 0;
}
.tq-week:not([style*="--week-today: -1"])::before {
    opacity: 1;
}

.tq-week-row {
    display: grid;
    grid-template-columns: repeat(var(--week-n), minmax(52px, 1fr));
    /* 关键：gap 会导致折线点与列中心不对齐；改为 gap=0，用 cell 内边距制造间隔 */
    gap: 0;
    align-items: center;
    text-align: center;
    font-size: 0.8rem;
    color: #3d5a6e;
    position: relative;
    z-index: 1;
}

.tq-week-cell {
    min-width: 0;
    padding: 0 6px;
}

.tq-week-row--dates {
    padding-bottom: 6px;
    border-bottom: 1px solid #e8eef2;
    margin-bottom: 8px;
}

.tq-week-row--dates .tq-week-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tq-week-lab {
    font-weight: 700;
    font-size: 0.85rem;
    color: #1a4a6e;
}

.tq-week-sub {
    font-size: 0.72rem;
    color: #7a8a99;
}

.tq-week-row--dtxt,
.tq-week-row--ntxt {
    padding: 4px 0;
    border-bottom: 1px solid #f0f4f8;
}

.tq-week-row--dico,
.tq-week-row--nico {
    padding: 6px 0 8px;
}

.tq-week-ico {
    width: 40px;
    height: 40px;
    object-fit: contain;
    vertical-align: middle;
}

.tq-week-row--tmax {
    padding-bottom: 2px;
}

.tq-week-row--tmin {
    padding-top: 2px;
    padding-bottom: 6px;
    border-bottom: 1px solid #f0f4f8;
}

.tq-week-tnum {
    font-size: 0.82rem;
    font-weight: 600;
}

.tq-week-tnum--high {
    color: #e07020;
}

.tq-week-tnum--low {
    color: #2d8ae6;
}

.tq-week-chart-wrap {
    width: 100%;
    /* 曲线区域加高，接近腾讯天气视觉比例 */
    height: 108px;
    margin: 4px 0 2px;
    position: relative;
    z-index: 1;
}

.tq-week-svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* 折线圆点：用 HTML 绝对定位，保证永远是圆形（不受 SVG 拉伸影响） */
.tq-week-dot {
    position: absolute;
    width: 9px;
    height: 9px;
    border-radius: 999px;
    transform: translate(-50%, -50%);
    border: 2px solid #fff;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
    pointer-events: none;
}

.tq-week-dot--max {
    background: #ff8a3d;
}

.tq-week-dot--min {
    background: #4a9eff;
}

.tq-week-row--wind {
    padding-top: 8px;
    font-size: 0.72rem;
    color: #7a8a99;
    line-height: 1.35;
}

.tq-week-wind {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
}

.tq-week-aqi {
    display: block;
    font-size: 0.68rem;
    color: #9aa8b5;
}

@media (max-width: 900px) {
    .tq-week-scroll .tq-week {
        min-width: calc(var(--week-n) * 58px);
    }
}

/* ========== 生活指数网格 — .tq-life ========== */
.tq-life {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

/* 生活指数：双列卡片；图标在上、名称+等级居中（对齐腾讯天气生活指数样式） */
.tq-life-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 14px 10px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid rgba(230, 240, 248, 0.95);
    box-shadow: 0 2px 14px rgba(20, 50, 80, 0.07);
    text-align: center;
    min-height: 108px;
}

.tq-life-icon {
    width: 44px;
    height: 44px;
    object-fit: contain;
}

.tq-life-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: #2c4a5e;
    line-height: 1.3;
}

.tq-life-info {
    font-size: 0.78rem;
    color: #4a6678;
    line-height: 1.3;
}

/* ========== 周边城市（7日预报下方） ========== */
.tq-nearby-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.tq-nearby-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 10px;
    border-radius: 12px;
    text-decoration: none;
    color: #1a4a6e;
    background: rgba(240, 246, 250, 0.92);
    border: 1px solid rgba(225, 236, 244, 0.95);
    font-weight: 600;
    font-size: 0.9rem;
    min-height: 44px;
}

.tq-nearby-chip:hover {
    background: rgba(232, 244, 252, 1);
}

.tq-nearby-chip:active {
    transform: translateY(1px);
}

.tq-empty {
    text-align: center;
    padding: 48px 16px;
    color: #7a8a99;
}

/* ========== 地区选择抽屉 — #tqRegionPanel（手机底栏；大屏见文件末尾 media 为居中弹窗） ========== */
.tq-region-mask {
    position: fixed;
    inset: 0;
    background: rgba(15, 30, 45, 0.45);
    z-index: 100;
}

.tq-region-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 101;
    max-height: 85vh;
    overflow: auto;
    background: #fff;
    border-radius: 20px 20px 0 0;
    padding: 0 16px 24px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0));
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.12);
}

.tq-region-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0 8px;
    position: sticky;
    top: 0;
    background: #fff;
}

.tq-region-title {
    margin: 0;
    font-size: 1.1rem;
}

.tq-region-close {
    border: none;
    background: #f0f4f8;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    color: #5c6b7a;
}

.tq-region-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.tq-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.875rem;
    color: #5c6b7a;
}

.tq-field select {
    width: 100%;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid #dce6ee;
    font-size: 1rem;
    background: #fafcfd;
    color: #1a2332;
}

.tq-submit {
    margin-top: 8px;
    padding: 14px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #3a9bc9 0%, #2d7cac 100%);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

.tq-submit:active {
    opacity: 0.92;
}

[hidden] {
    display: none !important;
}

/* ========== 平板：略放宽字号与顶栏 ========== */
@media (min-width: 600px) {
    .tq-now-inner {
        padding: 28px 28px 32px;
        gap: 20px;
    }

    .tq-now-icon {
        width: 140px;
        height: auto;
    }

    .tq-now-degree {
        font-size: 3.5rem;
    }

    .tq-hour {
        min-width: 60px;
        padding: 10px 8px;
    }
}

/* ========== 桌面：双栏（主内容 + 生活指数侧栏）、顶栏横排 ========== */
@media (min-width: 900px) {
    body {
        background: #e9f2f8;
        background-image:
            radial-gradient(ellipse 80% 60% at 50% -10%, rgba(126, 200, 227, 0.35), transparent 55%),
            linear-gradient(180deg, #e3eef6 0%, #eef3f8 40%, #e8edf2 100%);
    }

    .tq-top {
        border-bottom: 1px solid rgba(255, 255, 255, 0.65);
        box-shadow: 0 4px 24px rgba(20, 50, 80, 0.06);
    }

    .tq-top-row {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 16px;
    }

    .tq-brand {
        display: block;
        flex: 1;
        min-width: 200px;
    }

    .tq-loc-btn {
        width: auto;
        max-width: min(420px, 42vw);
        margin-left: auto;
        padding: 12px 22px;
    }

    .tq-now {
        border-radius: 24px;
    }

    .tq-now-inner {
        padding: 36px 40px 40px;
        min-height: 200px;
        align-items: center;
        justify-content: flex-start;
    }

    .tq-now-icon {
        width: 160px;
        max-width: 40%;
    }

    .tq-now-degree {
        font-size: 4rem;
    }

    /* 主内容 + 侧栏：有生活指数时双栏（侧栏放多枚生活指数卡片） */
    .tq-desktop-grid--aside {
        display: grid;
        grid-template-columns: 1fr min(400px, 36vw);
        gap: 24px;
        align-items: start;
    }

    .tq-desktop-aside {
        position: sticky;
        top: 88px;
        /* 侧栏略加宽，容纳双列小卡片 */
        max-width: 420px;
    }

    .tq-desktop-main {
        min-width: 0;
    }

    /* 让左下「周边城市」能撑出与右侧生活指数接近的高度（形成整齐的两列块） */
    .tq-nearby-card {
        min-height: 520px;
    }

    .tq-life-card {
        min-height: 520px;
    }

    .tq-scroll--1h {
        gap: 12px;
        padding: 4px 8px 12px;
    }

    .tq-card {
        padding: 20px 18px;
    }

    /* 地区选择：大屏居中弹窗，非底部抽屉 */
    .tq-region-panel {
        left: 50%;
        right: auto;
        bottom: auto;
        top: 50%;
        transform: translate(-50%, -50%);
        width: min(480px, 92vw);
        max-height: min(560px, 85vh);
        border-radius: 20px;
        box-shadow: 0 24px 80px rgba(0, 0, 0, 0.18);
        padding: 0 24px 28px;
    }

    .tq-region-head {
        padding-top: 20px;
    }
}

/* ========== 超宽屏：略增内边距 ========== */
@media (min-width: 1400px) {
    .tq-shell {
        padding-left: 24px;
        padding-right: 24px;
    }
}

/* ========== 页脚 — footer.tq-footer（底部声明/站点信息） ========== */
.tq-footer {
    margin-top: 0;
    padding: 16px 0;
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0));
    /* 深色页脚：和顶部一样是渐变质感，但色相更沉稳、对比更清晰 */
    background: linear-gradient(135deg, rgba(13, 61, 92, 0.96) 0%, rgba(26, 74, 110, 0.96) 55%, rgba(18, 52, 78, 0.98) 100%);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.tq-footer-inner {
    text-align: center;
}

.tq-footer-line {
    margin: 0;
    /* 主文案：更清晰的层级与可读性 */
    font-size: clamp(0.86rem, 2.2vw, 0.98rem);
    font-weight: 500;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.88);
    letter-spacing: 0.008em;
}

.tq-footer-site {
    margin: 8px 0 0;
    /* 站点签名：更轻、更“logo感” */
    font-size: clamp(0.72rem, 2.0vw, 0.82rem);
    font-weight: 500;
    line-height: 1.2;
    color: rgba(255, 255, 255, 0.72);
    letter-spacing: 0.14em;
    text-transform: uppercase;
}
