/* ══════════════════════════════════════════════════
   Calculator — iOS 计算器风格
   ══════════════════════════════════════════════════ */

#scene-calculator {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    background: #000;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'PingFang SC', sans-serif;
    user-select: none;
    -webkit-user-select: none;
    overflow: hidden;
    padding-top: var(--safe-top, 0);
    padding-bottom: var(--safe-bottom, 0);
}

/* ── 导航栏 ── */

.calc-nav {
    display: flex;
    align-items: center;
    height: 52px;
    padding: 0 8px;
    flex-shrink: 0;
    z-index: 2;
    position: relative;
}

.calc-nav-back {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.calc-nav-back:hover {
    background: rgba(255, 255, 255, 0.18);
}

.calc-nav-back:active {
    transform: scale(0.88);
}

.calc-nav-back svg {
    width: 20px;
    height: 20px;
}

.calc-nav-title {
    flex: 1;
    text-align: center;
    font-size: 17px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: 0.02em;
    margin-right: 36px;
}

/* ── 结果显示区域 ── */

.calc-display {
    flex: 1;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    padding: 0 20px 8px;
    min-height: 100px;
    z-index: 2;
    position: relative;
}

.calc-display-value {
    font-size: clamp(48px, 14vw, 96px);
    font-weight: 300;
    color: #fff;
    text-align: right;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
    transition: font-size 0.1s ease;
}

/* ── 按钮网格 ── */

.calc-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 10px 14px 14px;
    flex-shrink: 0;
    z-index: 2;
    position: relative;
}

/* ── 按钮基础 ── */

.calc-btn {
    aspect-ratio: 1 / 1;
    border: none;
    border-radius: 50%;
    font-size: clamp(22px, 6.5vw, 40px);
    font-weight: 400;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s, transform 0.1s;
    position: relative;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

.calc-btn:active,
.calc-btn.pressed {
    transform: scale(0.88);
}

/* ── 数字按钮（暗色） ── */

.calc-btn-num {
    background: #333;
    color: #fff;
}

.calc-btn-num:hover {
    background: #3a3a3a;
}

.calc-btn-num:active,
.calc-btn-num.pressed {
    background: #737373;
}

/* ── 功能按钮（浅灰） ── */

.calc-btn-func {
    background: #a5a5a5;
    color: #000;
}

.calc-btn-func:hover {
    background: #b3b3b3;
}

.calc-btn-func:active,
.calc-btn-func.pressed {
    background: #d9d9d9;
}

/* ── 运算符按钮（橙色） ── */

.calc-btn-op {
    background: #ff9f0a;
    color: #fff;
}

.calc-btn-op:hover {
    background: #ffab2e;
}

.calc-btn-op:active,
.calc-btn-op.pressed {
    background: #fcc980;
}

/* ── 等号按钮（同运算符色） ── */

.calc-btn-eq {
    background: #ff9f0a;
    color: #fff;
}

.calc-btn-eq:hover {
    background: #ffab2e;
}

.calc-btn-eq:active,
.calc-btn-eq.pressed {
    background: #fcc980;
}

/* ── 0 按钮（双倍宽） ── */

.calc-btn-wide {
    grid-column: span 2;
    border-radius: 9999px;
    aspect-ratio: auto;
    justify-content: flex-start;
    padding-left: 28px;
}

/* ── 按钮高亮状态（运算符选中时） ── */

.calc-btn-op.active-op {
    background: #fff;
    color: #ff9f0a;
}

/* ── 响应式 ── */

@media (min-width: 500px) {
    #scene-calculator {
        max-width: 400px;
        margin: 0 auto;
        border-radius: 44px;
    }
}

@media (max-width: 380px) {
    .calc-buttons {
        gap: 7px;
        padding: 7px 10px 10px;
    }

    .calc-display {
        padding: 0 14px 4px;
        min-height: 80px;
    }

    .calc-btn-wide {
        padding-left: 20px;
    }
}

/* ── 动画/过渡 ── */

@keyframes calcFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

#scene-calculator.active .calc-nav {
    animation: calcFadeIn 0.25s ease-out both;
}

#scene-calculator.active .calc-display {
    animation: calcFadeIn 0.3s ease-out 0.05s both;
}

#scene-calculator.active .calc-buttons {
    animation: calcFadeIn 0.35s ease-out 0.1s both;
}
