/* ==========================================================================
   BMI 计算器 —— 样式主文件（设计稿版）
   分层：全局重置 → 根容器 → 页面基类 → 封面页 → 主页(背景+滚动内容)
         → 输入区 → 结果区 → 历史记录 → 横屏提示 → 响应式
   兼容：QQ浏览器 / 微信浏览器 iOS & Android / PC 端
   ========================================================================== */

/* =========================================
   1. 全局重置
   ========================================= */
* { margin: 0; padding: 0; -webkit-box-sizing: border-box; box-sizing: border-box; }

html, body {
    width: 100%; height: 100%; overflow: hidden;
    font-family: 'Microsoft YaHei', 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px; color: #333;
    -webkit-text-size-adjust: none;
       -moz-text-size-adjust: none;
        -ms-text-size-adjust: none;
    -webkit-overflow-scrolling: touch;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;
}

/* =========================================
   2. 根容器
   ========================================= */
#app { width: 100%; max-width: 100%; height: 100%; position: relative; overflow: hidden; }
#app.desktop-mode { max-width: 420px; max-height: 820px; margin: 0 auto; background: #111; }

/* =========================================
   3. 页面切换基类
   ========================================= */
.page { display: none; position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; }
.page.active { display: block; }

button { border: none; background: transparent; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus { outline: none; }

/* =========================================
   4. 封面页（用户已调准，保留）
   ========================================= */
#coverPage { background: #222; z-index: 10; }
#coverPage.active { display: block; }

.cover-bg {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: url('../images/cover.jpg') no-repeat center center;
    background-size: cover;
}
.cover-title {
    position: absolute; top: 8%; left: 3%; width: 94%; z-index: 2;
    opacity: 0;
    -webkit-transform-origin: center; transform-origin: center;
    -webkit-animation: titleZoomIn 0.6s ease-in-out forwards;
            animation: titleZoomIn 0.6s ease-in-out forwards;
}
@-webkit-keyframes titleZoomIn { 0% { opacity: 0; -webkit-transform: scale(.3); } 100% { opacity: 1; } }
@keyframes titleZoomIn         { 0% { opacity: 0; transform: scale(.3); }         100% { opacity: 1; } }

.cover-start-btn {
    position: absolute; left: 50%; bottom: 12%;
    width: 44%; height: auto;
    z-index: 3; overflow: hidden;
    -webkit-transform: translateX(-50%); transform: translateX(-50%);
    -webkit-animation: timeBtnBreath 2.6s ease-in-out infinite;
            animation: timeBtnBreath 2.6s ease-in-out infinite;
}
.cover-start-btn img { width: 100%; }
.cover-start-btn::after {
    content: ""; pointer-events: none; will-change: background-position;
    background-image: -webkit-gradient(linear, 115deg, rgba(0,0,0,0) 42%, rgba(255,255,255,.55) 47%, rgba(255,255,255,.92) 50%, rgba(255,255,255,.55) 53%, rgba(0,0,0,0) 58%);
    background-image: linear-gradient(115deg, rgba(0,0,0,0) 42%, rgba(255,255,255,.55) 47%, rgba(255,255,255,.92) 50%, rgba(255,255,255,.55) 53%, rgba(0,0,0,0) 58%);
    background-repeat: no-repeat; background-size: 300% 100%;
    position: absolute; background-position: 100% 0;
    border-radius: 999px; inset: 0;
    -webkit-animation: timeBtnShimmer 2.6s ease-in-out infinite;
            animation: timeBtnShimmer 2.6s ease-in-out infinite;
}
.cover-start-btn:active { opacity: 0.85; }
@-webkit-keyframes timeBtnBreath { 0%,100% { -webkit-transform: translateX(-50%) scale(1); } 50% { -webkit-transform: translateX(-50%) scale(1.06); } }
@keyframes timeBtnBreath         { 0%,100% { transform: translateX(-50%) scale(1); }         50% { transform: translateX(-50%) scale(1.06); } }
@-webkit-keyframes timeBtnShimmer { 0%,100% { background-position: 100% 0; } 35% { background-position: 0 0; } }
@keyframes timeBtnShimmer         { 0%,100% { background-position: 100% 0; } 35% { background-position: 0 0; } }

/* =========================================
   5. BMI 计算器主页面（背景固定 + 内容滚动）
   ========================================= */
#toolPage.active {
    display: block;
    /* 隐藏滚动条 */
    -ms-overflow-style: none;
    scrollbar-width: none;
}
#toolPage::-webkit-scrollbar { width: 0; height: 0; display: none; }

/* 固定背景层：bg.png 始终铺满，不随内容滚动 */
.tool-bg {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: url('../images/bg.png') no-repeat center top;
    background-size: cover;
    pointer-events: none;
    z-index: 0;
}

/* 可滚动内容层：在背景之上 */
.tool-content {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 0 30px;
    padding-top: calc(40px + env(safe-area-inset-top));
    padding-bottom: calc(40px + env(safe-area-inset-bottom));
}
.tool-content::-webkit-scrollbar { width: 0; height: 0; display: none; }
.tool-content { -ms-overflow-style: none; scrollbar-width: none; }

/* 底部占位，确保最后一个板块不被底部裁掉 */
.content-bottom-pad { height: 20px; }

/* =========================================
   6. 输入区域
   ========================================= */
/* 每组输入 */
.input-group {
    margin-bottom: 40px;
}

/* 标题图（height.png / weight.png）——居中 */
.input-title-img {
    display: block;
    width: auto;
    max-width: 114px;
    height: auto;
    margin: 0 auto 30px;
}

/* 数字控制行 */
.input-control {
    position: relative;    /* ← 给 unit-label 绝对定位用 */
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center; -webkit-align-items: center; -ms-flex-align: center; align-items: center;
    -webkit-box-pack: center; -webkit-justify-content: center; -ms-flex-pack: center; justify-content: center;
    gap: 22px;
}

/* + / - 图标按钮（plus.png / minus.png 108x108）*/
.num-btn {
    -webkit-box-flex: 0; -webkit-flex: 0 0 auto; -ms-flex: 0 0 auto; flex: 0 0 auto;
    width: 46px; height: 46px;
    border-radius: 50%;
    background: rgba(255,255,255,0.6);
    -webkit-box-shadow: 0 2px 10px rgba(0,0,0,0.08);
            box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    overflow: hidden;
}
.num-btn img {
    width: 100%; height: 100%;
    -webkit-filter: drop-shadow(0 1px 2px rgba(0,0,0,0.15));
            filter: drop-shadow(0 1px 2px rgba(0,0,0,0.15));
}
.num-btn:active {
    -webkit-transform: scale(0.88);
            transform: scale(0.88);
}

/* 数字输入框*/
.num-input {
    -webkit-box-flex: 0; -webkit-flex: 0 0 auto; -ms-flex: 0 0 auto; flex: 0 0 auto;
    width: 154px;
    height: 40px;
    text-align: center;
    font-size: 26px;
    font-weight: bold;
    color: #025ece;
    line-height: 40px;
    border: none;
    outline: none;
        background: url(../images/input_bg.png) no-repeat center center;
    background-size: 100% 100%;
}
.num-input::-webkit-outer-spin-button,
.num-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.num-input:focus { outline: none; }

/* 单位标签 cm / kg — 绝对定位到最右侧，脱离 flex 平分空间 */
.unit-label {
    position: absolute;
    right: 0;
    top: 100%;
    -webkit-transform: translateY(-50%);
            transform: translateY(-50%);
    font-size: 18px;
    color: #025ece;
    -webkit-box-flex: 0; -webkit-flex: 0 0 auto; -ms-flex: 0 0 auto; flex: 0 0 auto;
}

/* 滑块：已拖部分蓝色 / 未拖部分黄色 / 实心蓝色拇指 */
.range-slider {
    display: block;
    width: 100%;
    height: 10px;
    margin-top: 30px;
    -webkit-appearance: none; -moz-appearance: none; appearance: none;
    border-radius: 6px;
    outline: none;
    /* 核心：用 CSS 变量 --progress 控制蓝黄分界 */
    background: -webkit-gradient(linear, left top, right top,
        #4facfe 0%, #4facfe var(--progress, 0%),
        #fee219 var(--progress, 0%), #fee219 100%);
    background: linear-gradient(to right,
        #4facfe 0%, #4facfe var(--progress, 0%),
        #fee219 var(--progress, 0%), #fee219 100%);
}
.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: #4facfe;                /* 实心蓝 */
    border: 2px solid #fff;             /* 白边 */
    -webkit-box-shadow: 0 2px 10px rgba(79,172,254,0.5);
            box-shadow: 0 2px 10px rgba(79,172,254,0.5);
    cursor: pointer;
    margin-top: -2px;                   /* 让 thumb 居中到轨道 */
}
.range-slider::-moz-range-thumb {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: #4facfe;                /* 实心蓝 */
    border: 2px solid #fff;
    box-shadow: 0 2px 10px rgba(79,172,254,0.5);
    cursor: pointer;
}
/* Firefox 需要隐藏默认轨道（因为它会用自身轨道覆盖我们的渐变背景）*/
.range-slider::-moz-range-track {
    height: 12px;
    background: transparent;
    border-radius: 6px;
    border: none;
}

/* 计算按钮：calculate.png 图片 */
.calc-btn {
    display: block;
    width: 44%;
    margin: 50px auto 0;
    -webkit-animation: btnBreath 2.2s ease-in-out infinite;
            animation: btnBreath 2.2s ease-in-out infinite;
}
.calc-btn img {
    width: 100%;
    height: auto;
    display: block;
}
.calc-btn:active {
    -webkit-transform: scale(0.96);
            transform: scale(0.96);
    -webkit-animation: none; animation: none;
}
@-webkit-keyframes btnBreath { 0%,100% { -webkit-transform: scale(1); } 50% { -webkit-transform: scale(1.04); } }
@keyframes btnBreath         { 0%,100% { transform: scale(1); }         50% { transform: scale(1.04); } }

/* =========================================
   7. 结果展示区域
   ========================================= */
.result-area {
    margin-top: 50px;
    -webkit-animation: resultPopIn 0.4s ease-out both;
            animation: resultPopIn 0.4s ease-out both;
}
@-webkit-keyframes resultPopIn { 0% { opacity: 0; -webkit-transform: translateY(16px) scale(0.97); } 100% { opacity: 1; -webkit-transform: none; } }
@keyframes resultPopIn         { 0% { opacity: 0; transform: translateY(16px) scale(0.97); }           100% { opacity: 1; transform: none; } }

/* 你的BMI指数 横幅（yours.png） */
.result-banner {
    position: relative;
    width: 100%;
    text-align: center;
    margin-bottom: 30px;
}
.result-banner-img {
    width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}
.result-bmi-value {
    width: 64%;
    font-size: 64px;
    font-weight: bold;
    color: #1a5ab8;
    padding: 0px 0px 10px;
    margin: -10px auto 0;
    font-size: 60px;
    font-weight: bold;
    color: #1a5ab8;
    padding: 0 0 10px;
    /* 白色描边：text-shadow 多方向叠加模拟描边效果 */
    text-shadow:
        -1px -1px 0 #fff, 1px -1px 0 #fff,
        -1px  1px 0 #fff, 1px  1px 0 #fff,
         0   -1px 0 #fff, 0    1px 0 #fff,
        -1px  0   0 #fff, 1px  0   0 #fff,
        0 2px 4px rgba(0,0,0,0.2); /* 底部柔和阴影 */
    line-height: 1;
    background: url('../images/num_bg.png') no-repeat center bottom;
    background-size: 100%;
}

/* 状态图片（normal.png / overweight.png / underweight.png / fat.png 383x110）*/
.result-status-wrap {
    text-align: center;
    margin-bottom: 24px;
}
.bmi-status-img {
    width: auto;
    width: 160px;
    height: auto;
    display: inline-block;
}

/* 刻度条：indicator-bar.png + arrow.png 指针 */
.bmi-scale-wrap {
    margin-bottom: 20px;
}
.bmi-scale {
    position: relative;
    width: 100%;
}
.scale-bar-img {
    width: 100%;
    height: auto;
    display: block;
}
/* arrow.png 51x43 */
.scale-pointer {
    position: absolute;
    top: -10px;
    left: 0;
    width: 20px;
    height: auto;
    margin-left: -10px;
    -webkit-transition: left 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
            transition: left 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    -webkit-filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
            filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}
/* 刻度两端 0 和 MAX（中间 18.5/24/28 由图片自带）*/
.scale-labels {
    display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex;
    -webkit-box-pack: justify; -webkit-justify-content: space-between; -ms-flex-pack: justify; justify-content: space-between;
    margin-top: 4px;
    padding: 0 4px;
    font-size: 11px;
    color: #888;
    font-weight: 500;
}

/* 标准体重 + 体重差值（各用独立背景图）*/
.result-detail {
    display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex;
    gap: 14px;
    margin-bottom: 18px;
}
.detail-item {
    -webkit-box-flex: 1; -webkit-flex: 1; -ms-flex: 1; flex: 1;
    text-align: center;
}
/* 数字卡片 */
.detail-num-bg {
    position: relative;
    aspect-ratio: 452 / 268;
    background-size: 100% 100%;
    font-size: 26px;
    font-weight: 800;
    color: #025ece;
    text-align: center;
    display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex;
    -webkit-box-align: center; -webkit-align-items: center; -ms-flex-align: center; align-items: center;
    -webkit-box-pack: center; -webkit-justify-content: center; -ms-flex-pack: center; justify-content: center;
    padding-top: 30px; 
}
.detail-num-bg em { font-style: normal; font-size: 13px; font-weight: 600; margin-left: 2px; }

/* 标准体重卡片底：normal_weight_bg.png */
.detail-num-bg.detail-standard {
    background: url('../images/normal_weight_bg.png') no-repeat center center;
    background-size: cover;
}
/* 体重差值卡片底：weight_difference_bg.png */
.detail-num-bg.detail-diff {
    background: url('../images/weight_difference_bg.png') no-repeat center center;
    background-size: cover;
}
.detail-num-bg.diff-positive { color: #e74c3c; }
.detail-num-bg.diff-negative { color: #3498db; }
.detail-num-bg.diff-zero     { color: #27ae60; }

/* 建议文字 */
.result-suggestion {
    margin-top: 10px;
    padding: 6px 10px;
    font-size: 14px;
    color: #04409e;
    line-height: 1.6;
    border-radius: 10px;
    border: 1px solid #d2d2d2;
    background: #f4f4f4;
}

/* 免责声明 */
.result-disclaimer {
    margin-top: 14px;
    font-size: 12px;
    color: #000000;
    text-align: center;
    line-height: 1.6;
}

/* =========================================
   8. 历史记录区域
   ========================================= */
.history-area {
    margin-top: 40px;
}

/* 历史区标题栏：左标题 + 右清空按钮 */
.history-header {
    position: relative;
    display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex;
    -webkit-box-align: center; -webkit-align-items: center; -ms-flex-align: center; align-items: center;
    -webkit-box-pack: center; -webkit-justify-content: center; -ms-flex-pack: center; justify-content: center;
    margin-bottom: 24px;
}
/* history.png 标题图（保持居中，按钮绝对钉右边）*/
.history-title-img {
    display: block;
    width: auto;
    max-width: 200px;
    height: auto;
    margin: 0 auto;
}
/* 清空按钮 clear.png：钉在标题右侧 */
.history-clear-btn {
    position: absolute;
    right: 0;
    top: 58%;
    -webkit-transform: translateY(-50%);
            transform: translateY(-50%);
    height: 22px;
    width: auto;
    cursor: pointer;
    opacity: 0.8;
    -webkit-transition: opacity 0.2s;
            transition: opacity 0.2s;
}
.history-clear-btn:active { opacity: 1; }

.history-list {
    list-style: none; padding: 0; margin: 0;
}

/* 单条记录：用 list_bg.png 976x140 做底 */
.history-item {
    position: relative;
    padding: 0;
    margin-bottom: 12px;
    min-height: 54px;
    background: url('../images/list_bg.png') no-repeat center center;
    background-size: 100% 100%;
    display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex;
    -webkit-box-align: center; -webkit-align-items: center; -ms-flex-align: center; align-items: center;
    padding: 8px 48px 8px 14px;
    /* 三个子元素等间距 */
    -webkit-box-pack: justify; -webkit-justify-content: space-between; -ms-flex-pack: justify; justify-content: space-between;
    gap: 10px;
}

/* 左侧 BMI 数值 */
.history-item-bmi {
    -webkit-box-flex: 0.5; -webkit-flex: 0.5; -ms-flex: 0.5; flex: 0.5;
    font-size: 20px;
    font-weight: bold;
    color: #0052d3;
    text-align: left;
    min-width: 0;
}

/* 中间状态胶囊：保持小巧，不撑满 */
.history-item-status {
    -webkit-box-flex: 0; -webkit-flex: 0 0 auto; -ms-flex: 0 0 auto; flex: 0 0 auto;
    font-size: 14px;
    font-weight: bold;
    padding: 3px 10px;
    border-radius: 12px;
    border: 1px solid;
    color: #04409e;
    line-height: 1;
    text-align: center;
}
/* 体重过轻 */
.history-item-status.thin   { background: #95ffd1; border-color: #47e6a2; }
/* 正常体重 */
.history-item-status.normal { background: #fde896; border-color: #fddb57; }
/* 体重过重 */
.history-item-status.over   { background: #ffabb7; border-color: #ef7689; }
/* 肥胖 */
.history-item-status.obese  { background: #ffc6a2; border-color: #fe8b45; }

/* meta 内上下两行：上身高体重（重点），下日期（弱化）*/
.history-item-meta {
    -webkit-box-flex: 0.7; -webkit-flex: 0.7; -ms-flex: 0.7; flex: 0.7;
    min-width: 0;
    font-size: 12px;
    color: #888;
    display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex;
    -webkit-box-orient: vertical; -webkit-box-direction: normal; -ms-flex-direction: column; flex-direction: column;
    -webkit-box-align: flex-end; -webkit-align-items: flex-end; -ms-flex-align: end; align-items: flex-end;
    line-height: 1.5;
}
/* 身高体重：字体大，深蓝色 */
.history-item-meta .meta-hw {
    font-size: 14px;
    font-weight: 700;
    color: #0052d3;
}
/* 日期：保持默认弱化样式 */
.history-item-meta .meta-date {
    font-size: 11px;
    color: #737373;
}

/* 右侧删除按钮：close.png 22x22 */
.history-item-del {
    position: absolute;
    right: 14px;
    top: 50%;
    -webkit-transform: translateY(-50%); transform: translateY(-50%);
    width: 15px; height: 15px;
    padding: 0;
    background: transparent;
    overflow: hidden;
}
.history-item-del img { width: 100%; height: 100%;-webkit-transition: opacity 0.15s; transition: opacity 0.15s; }
.history-item-del:active img { opacity: 1; }

/* 新记录入场动画 */
@-webkit-keyframes historySlideIn { 0% { opacity: 0; -webkit-transform: translateY(-8px); } 100% { opacity: 1; } }
@keyframes historySlideIn         { 0% { opacity: 0; transform: translateY(-8px); }         100% { opacity: 1; } }
.history-item.new {
    -webkit-animation: historySlideIn 0.35s ease-out both;
            animation: historySlideIn 0.35s ease-out both;
}


/* =========================================
   9. 横屏提示
   ========================================= */
.rotate-tip-layer {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: #fff;
    z-index: 9999;
    display: none;
    -webkit-box-align: center; -webkit-align-items: center; -ms-flex-align: center; align-items: center;
    -webkit-box-pack: center; -webkit-justify-content: center; -ms-flex-pack: center; justify-content: center;
}
.rotate-tip-layer.show {
    display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex;
}
.rotate-tip-img {
    width: 36%; max-width: 280px; height: auto;
    -o-object-fit: contain; object-fit: contain;
    display: block;
}

/* =========================================
   10. 响应式
   ========================================= */
@media screen and (min-width: 320px) { html { font-size: 12px; } }
@media screen and (min-width: 360px) { html { font-size: 13px; } }
@media screen and (min-width: 375px) { html { font-size: 14px; } }
@media screen and (min-width: 414px) { html { font-size: 15px; } }
@media screen and (min-width: 480px) { html { font-size: 16px; } }
@media screen and (min-width: 640px) { html { font-size: 18px; } }

@media (max-width: 360px) {
    .num-btn { width: 40px; height: 40px; }
    .num-input { height: 44px; font-size: 24px; }
    .result-bmi-value { font-size: 28px; }
}
@media (max-height: 640px) {
    .tool-content { padding-top: calc(24px + env(safe-area-inset-top)); }
    .input-group { margin-bottom: 28px; }
}
