/* BMI計算機樣式 - 主色碼 #e8f6e9 */

/* BMI計算機外框容器 */
.bmi-calculator-wrapper {
    background: linear-gradient(to top, #e8f6e9, rgba(232, 246, 233, 0));
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    margin-bottom: 2rem;
    border: 1px solid rgba(232, 246, 233, 0.5);
}

/* 內文嵌入環境 */
.story__text .bmi-embed {
    margin: 2rem 0;
    clear: both;
}

.story__text .bmi-embed .bmi-calculator-header h4 {
    font-size: 22px;
    padding-left: 0;
}

/* 內文嵌入：初始僅顯示表單，計算後才展開說明區 */
.bmi-embed .bmi-calculator-form {
    margin-bottom: 0;
}

.bmi-embed .bmi-explanation {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    margin-top: 0;
    padding: 0;
    border-color: transparent;
    box-shadow: none;
    transform: translateY(-10px);
    transition: opacity 0.5s ease, max-height 0.5s ease, margin-top 0.5s ease, padding 0.5s ease, transform 0.5s ease;
}

.bmi-embed .bmi-explanation.explanation--show {
    opacity: 1;
    max-height: 5000px;
    margin-top: 2rem;
    padding: 2rem;
    border: 2px solid rgba(76, 175, 80, 0.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transform: translateY(0);
}

.bmi-embed .bmi-explanation.explanation--disappear {
    opacity: 0;
    max-height: 0;
    margin-top: 0;
    padding: 0;
    border-color: transparent;
    box-shadow: none;
    transform: translateY(-10px);
}

/* BMI計算機標題區域 */
.bmi-calculator-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.bmi-calculator-header h4 {
    font-size: 26px;
    font-weight: 400;
    line-height: 2;
    padding-left: 21px;
    color: #218431;
    margin: 0;
}

/* 清除按鈕 */
.bmi-calculator-wrapper .reset-btn {
    padding: 0.625rem;
    background: transparent;
    color: #666;
    border: none;
    border-radius: 8px;
    font-size: 1.125rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.bmi-calculator-wrapper .reset-btn:hover {
    background: #f5f5f5;
    color: #4caf50;
}

.bmi-calculator-wrapper .reset-btn:active {
    transform: scale(0.95);
}

.bmi-calculator-wrapper .reset-btn i {
    font-size: 1.25rem;
}

/* 輸入區域 */
.bmi-calculator-form {
    margin-bottom: 2rem;
}

.bmi-calculator-form__row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
    justify-content: center;
}

.bmi-calculator__height,
.bmi-calculator__weight {
    padding: 0.875rem 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: #ffffff;
    color: #333;
    outline: none;
    flex: 1;
    min-width: 150px;
    max-width: 200px;
}

.bmi-calculator__height:focus,
.bmi-calculator__weight:focus {
    border-color: #4caf50;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
    background: #fafafa;
}

.bmi-calculator__height:hover,
.bmi-calculator__weight:hover {
    border-color: #bdbdbd;
}

.bmi-calculator-form__row label {
    color: #666;
    font-size: 0.875rem;
    font-weight: 500;
    flex: 0 0 auto;
    align-self: center;
}

/* 計算按鈕 */
.bmi-calculator__submit {
    padding: 0.875rem;
    background: linear-gradient(135deg, #4caf50 0%, #66bb6a 100%);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
    min-width: 140px;
    flex: 0 0 auto;
}

.bmi-calculator__submit:hover {
    background: linear-gradient(135deg, #43a047 0%, #5cb660 100%);
    box-shadow: 0 6px 16px rgba(76, 175, 80, 0.4);
    transform: translateY(-2px);
}

.bmi-calculator__submit:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

/* 結果區域 */
.bmi-calculator__result {
    background: linear-gradient(135deg, #e8f6e9 0%, #f1f8f4 100%);
    border-radius: 16px;
    padding: 0;
    margin-top: 0;
    border: 2px solid transparent;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transform: translateY(-20px);
    transition: all 0.5s ease;
}

.bmi-calculator__result.result--show {
    opacity: 1;
    max-height: 1000px;
    padding: 2.5rem 2rem;
    margin-top: 2rem;
    border-color: rgba(76, 175, 80, 0.2);
    transform: translateY(0);
}

.bmi-calculator__result.result--disappear {
    opacity: 0;
    max-height: 0;
    padding: 0;
    margin-top: 0;
    border-color: transparent;
    transform: translateY(-20px);
}

.bmi-calculator__result-answer {
    text-align: center;
    padding: 1.5rem 0;
    margin: 0 auto;
}

.bmi-calculator__result-answer p:first-of-type {
    margin-bottom: 1rem;
}

.bmi-calculator__result-answer p:nth-of-type(2) {
    margin: 1rem 0;
}

.bmi-calculator__value {
    font-size: 3.5rem;
    font-weight: 700;
    color: #2e7d32;
    display: inline-block;
    background: linear-gradient(135deg, #4caf50, #66bb6a);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.bmi-calculator__category {
    font-size: 1.25rem;
    color: #555;
    font-weight: 600;
    margin-top: 0.5rem;
}

/* BMI 說明區塊 */
.bmi-explanation {
    margin-top: 2.5rem;
    padding: 2rem;
    background: #ffffff;
    border-radius: 16px;
    border: 2px solid rgba(76, 175, 80, 0.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.bmi-explanation h5 {
    font-size: 1.25rem;
    color: #2e7d32;
    margin: 1.5rem 0 0.75rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(76, 175, 80, 0.2);
}

.bmi-explanation h5:first-child {
    margin-top: 0;
}

.bmi-explanation p {
    font-size: 1rem;
    line-height: 1.8;
    color: #555;
    margin-bottom: 1rem;
}

.bmi-explanation ul {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0 1.5rem 0;
}

.bmi-explanation ul li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
    font-size: 1rem;
    line-height: 1.8;
    color: #555;
}

.bmi-explanation ul li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: #4caf50;
    font-weight: bold;
    font-size: 1.25rem;
}

.bmi-explanation ul li strong {
    color: #2e7d32;
}

.bmi-explanation .bmi-waist-table {
    width: 100%;
    max-width: 480px;
    border-collapse: collapse;
    margin: 1rem 0 1.5rem 0;
    font-size: 1rem;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(76, 175, 80, 0.2);
}

.bmi-explanation .bmi-waist-table thead {
    background: linear-gradient(135deg, #2e7d32 0%, #388e3c 100%);
    color: #fff;
}

.bmi-explanation .bmi-waist-table th {
    padding: 0.875rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 1rem;
}

.bmi-explanation .bmi-waist-table tbody tr {
    background: #fff;
    border-bottom: 1px solid rgba(232, 246, 233, 0.8);
}

.bmi-explanation .bmi-waist-table tbody tr:last-child {
    border-bottom: none;
}

.bmi-explanation .bmi-waist-table tbody tr:nth-child(even) {
    background: #f8fdf8;
}

.bmi-explanation .bmi-waist-table td {
    padding: 0.875rem 1rem;
    color: #555;
    line-height: 1.6;
}

.bmi-explanation .bmi-source {
    margin-top: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: #777;
}

.bmi-explanation .bmi-source a {
    color: #2e7d32;
    text-decoration: none;
}

.bmi-explanation .bmi-source a:hover {
    text-decoration: underline;
}

/* 結果詳細資訊列表（擴充用） */
.bmi-calculator__result > ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.bmi-calculator__result > ul > li {
    background: #ffffff;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    border: 1px solid rgba(232, 246, 233, 0.8);
}

.bmi-calculator__result > ul > li:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #4caf50;
}

/* 響應式設計 */
@media (max-width: 768px) {
    .bmi-calculator-wrapper {
        padding: 1.5rem;
    }

    .bmi-calculator-form__row {
        flex-direction: column;
    }

    .bmi-calculator__height,
    .bmi-calculator__weight {
        max-width: 100%;
        min-width: 100%;
        width: 100%;
        box-sizing: border-box;
    }

    .bmi-calculator__submit {
        width: 100%;
    }

    .bmi-calculator__value {
        font-size: 2.5rem;
    }

    .bmi-calculator__result > ul {
        grid-template-columns: 1fr;
    }

    .bmi-explanation {
        margin-top: 1.5rem;
        padding: 1.5rem;
    }

    .bmi-explanation h5 {
        font-size: 1.125rem;
    }

    .bmi-explanation p {
        font-size: 0.9375rem;
    }

    .bmi-explanation .bmi-waist-table {
        max-width: 100%;
        font-size: 0.9375rem;
    }

    .bmi-explanation .bmi-waist-table th,
    .bmi-explanation .bmi-waist-table td {
        padding: 0.75rem;
    }

    .bmi-calculator-header {
        margin-bottom: 1.5rem;
    }

    .bmi-calculator-header h4 {
        font-size: 22px;
        padding-left: 0;
    }

    .bmi-calculator-wrapper .reset-btn {
        width: 36px;
        height: 36px;
        padding: 0.5rem;
    }
}

/* 輸入驗證錯誤樣式 */
.bmi-calculator__height[style*="border-color: rgb(244, 67, 54)"],
.bmi-calculator__weight[style*="border-color: rgb(244, 67, 54)"] {
    border-color: #f44336 !important;
    background: #ffebee;
    animation: bmi-shake 0.3s;
}

@keyframes bmi-shake {
    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}
