/* ==========================================
   BMI CALCULATOR - EXTERNAL STYLES
   Non-critical styles loaded after page paint
   ========================================== */

/* ===== RESULTS SECTION ===== */
.results-section.show { 
    display: block; 
    animation: fadeIn 0.4s ease; 
}

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

.results-grid { 
    display: grid; 
    grid-template-columns: 260px 1fr; 
    gap: 15px; 
    align-items: stretch; 
    margin-top: 20px; 
}

/* BMI Display Box */
.bmi-box {
    border-radius: 12px;
    padding: 24px 20px;
    color: white;
    text-align: center;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
    transition: background 0.4s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.bmi-box::before { 
    content: ''; 
    position: absolute; 
    top: -50%; 
    right: -50%; 
    width: 200%; 
    height: 200%; 
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%); 
    pointer-events: none; 
}

.bmi-box.underweight { background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%); }
.bmi-box.normal { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }
.bmi-box.overweight { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); }
.bmi-box.obese { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); }

.bmi-label { font-size: 0.9rem; opacity: 0.9; margin-bottom: 4px; position: relative; z-index: 1; font-weight: 500; }
.bmi-value-wrapper { display: flex; align-items: baseline; justify-content: center; gap: 10px; margin: 8px 0; }
.bmi-value { font-size: 4.5rem; font-weight: 700; line-height: 1; position: relative; z-index: 1; letter-spacing: -2px; }
.bmi-unit { font-size: 1.1rem; opacity: 0.85; font-weight: 500; position: relative; z-index: 1; }
.bmi-category { font-size: 1.25rem; font-weight: 600; position: relative; z-index: 1; margin: 4px 0 20px; }
.bmi-detail { font-size: 0.95rem; opacity: 0.9; position: relative; z-index: 1; line-height: 1.4; margin-bottom: 16px; }
.bmi-divider { width: 40px; height: 2px; background: rgba(255,255,255,0.3); margin: 0 auto 16px; position: relative; z-index: 1; }

.weight-gap-indicator { margin-top: 8px; text-align: center; position: relative; z-index: 1; }
.weight-gap-heading { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: rgba(255, 255, 255, 0.75); margin-bottom: 6px; }
.weight-gap-description { font-size: 0.95rem; font-weight: 500; color: rgba(255, 255, 255, 0.95); line-height: 1.4; }
.weight-gap-description strong { font-weight: 700; color: #ffffff; }

/* Health Controls (White Cards) */
.bmi-controls {
    background: white;
    border-radius: 12px;
    padding: 10px;
    border: 2px solid #f1f5f9;
    height: 100%;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.bmi-title { font-size: 0.9rem; font-weight: 600; color: #64748b; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }

.ideal-weight { background: #f8fafc; border-radius: 10px; padding: 10px; border: 2px solid #e2e8f0; margin: 8px 0; }
.ideal-weight-title { font-size: 0.85rem; font-weight: 600; color: #1e293b; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.ideal-weight-range { font-size: 1.3rem; font-weight: 700; color: #5b21b6; text-align: center; margin: 6px 0; }
.ideal-weight-range .mass-unit { font-size: 0.95rem; font-weight: 500; color: #64748b; }
.ideal-weight-unit { font-size: 0.85rem; color: #64748b; text-align: center; }

/* Scale with Category Labels */
.bmi-scale { margin: 8px 0; padding: 8px; background: #f8fafc; border-radius: 10px; border: 2px solid #e2e8f0; }
.bmi-scale-title { font-size: 0.8rem; font-weight: 600; color: #475569; margin-bottom: 6px; }

.scale-categories { display: flex; width: 100%; margin-bottom: 4px; }
.scale-categories span { flex: 1; text-align: center; font-size: 0.65rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; }
.cat-underweight { color: #3b82f6; }
.cat-normal { color: #10b981; }
.cat-overweight { color: #f59e0b; }
.cat-obese { color: #ef4444; }

.scale-bar { height: 10px; border-radius: 5px; background: linear-gradient(90deg, #3b82f6 0%, #10b981 25%, #f59e0b 60%, #ef4444 100%); position: relative; margin: 6px 0; }
.scale-marker { position: absolute; top: -3px; width: 16px; height: 16px; background: white; border: 3px solid #1e293b; border-radius: 50%; transform: translateX(-50%); box-shadow: 0 2px 4px rgba(0,0,0,0.2); transition: left 0.5s ease; }
.scale-labels { display: flex; justify-content: space-between; font-size: 0.7rem; color: #64748b; margin-top: 4px; font-weight: 500; }

.health-risk { background: #fffbeb; border-radius: 10px; padding: 10px; border-left: 4px solid #f59e0b; margin-top: 8px; }
.health-risk-title { font-size: 0.85rem; font-weight: 600; color: #92400e; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; font-style: italic; }
.health-risk-text { font-size: 0.95rem; color: #78350f; line-height: 1.5; margin: 0; font-style: italic; }

/* Category Table */
.category-section { 
    grid-column: 1 / -1; 
    background: white; 
    border-radius: 12px; 
    padding: 12px; 
    border: 2px solid #f1f5f9; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.03); 
    margin-top: 15px; 
}

.category-header { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.category-icon { width: 32px; height: 32px; background: linear-gradient(135deg, #5b21b6 0%, #8b5cf6 100%); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: white; font-size: 1.2rem; flex-shrink: 0; }
.category-title { font-size: 1rem; font-weight: 600; color: #1e293b; margin-bottom: 4px; }
.category-desc { font-size: 0.85rem; color: #64748b; line-height: 1.4; }

.category-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; color: #334155; }
.category-table th { background: #f8fafc; padding: 10px; text-align: left; font-weight: 600; color: #64748b; border-bottom: 2px solid #e2e8f0; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
.category-table td { padding: 10px; border-bottom: 1px solid #f1f5f9; font-weight: 400 !important; }
.category-table tr:hover { background: #f8fafc; }
.category-table tr.current-category td { font-weight: 600 !important; background: #f3e8ff; }

.cat-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.cat-dot.underweight { background: #3b82f6; }
.cat-dot.normal { background: #10b981; }
.cat-dot.overweight { background: #f59e0b; }
.cat-dot.obese { background: #ef4444; }

.badge { padding: 4px 12px; border-radius: 12px; font-size: 0.8rem; font-weight: 600; display: inline-block; }
.badge-selected { background: #f3e8ff; color: #5b21b6; }
.badge-default { background: #f1f5f9; color: #94a3b8; }

/* Recalculate Button */
.recalculate-btn {
    grid-column: 1 / -1; 
    width: 100%; 
    padding: 16px; 
    background: #5b21b6; 
    color: white; 
    border: none; 
    border-radius: 10px; 
    font-size: 1.05rem; 
    font-weight: 600; 
    cursor: pointer; 
    transition: all 0.2s; 
    margin-top: 15px; 
    letter-spacing: 0.5px;
}
.recalculate-btn:hover { 
    background: #4c1d95; 
    transform: translateY(-2px); 
    box-shadow: 0 6px 20px rgba(91, 33, 182, 0.3); 
}

/* ===== RELATED CALCULATORS ===== */
.related-calculators { max-width: 800px; width: 100%; margin: 40px auto 32px; }
.related-calculators h3 { font-size: 1.0625rem; font-weight: 600; color: #1e293b; margin-bottom: 16px; text-align: left; }
.related-calculators-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.related-calc-card { display: flex; align-items: center; gap: 12px; padding: 14px 18px; background: white; border: 1px solid #f1f5f9; border-radius: 12px; text-decoration: none; color: #1e293b; transition: all 0.2s ease; box-shadow: 0 2px 4px rgba(0,0,0,0.02); }
.related-calc-card:hover { border-color: #3b82f6; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.06); }
.related-calc-icon { font-size: 1.25rem; background: #dbeafe; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; border-radius: 8px; flex-shrink: 0; }
.related-calc-title { font-weight: 600; font-size: 0.9375rem; color: #1e293b; line-height: 1.3; }

/* ===== ARTICLE CONTENT STYLES (Non-Critical) ===== */
.article-content { max-width: 800px; margin: 0 auto; padding: 40px 20px 80px; }
.article-content h2 { font-size: 1.75rem; font-weight: 700; margin-top: 60px; margin-bottom: 20px; color: #1e293b; scroll-margin-top: 100px; }
.article-content h3 { font-size: 1.25rem; font-weight: 600; margin-top: 32px; margin-bottom: 16px; color: #1e293b; }
.article-content p { margin-bottom: 20px; color: #475569; line-height: 1.8; font-size: 1.0625rem; }
.article-content ul, .article-content ol { margin-bottom: 20px; padding-left: 24px; }
.article-content li { margin-bottom: 12px; color: #475569; line-height: 1.8; font-size: 1.0625rem; }
.article-content strong { color: #5b21b6; font-weight: 600; }
.article-content a { color: #2563eb; text-decoration: underline; }
.article-content a:hover { color: #1d4ed8; }

/* Citation Links */
.citation { color: #5b21b6; font-weight: 600; text-decoration: none; font-size: 0.875rem; vertical-align: super; }
.citation:hover { text-decoration: underline; }

/* Formula Box */
.formula-box { background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%); border: 2px solid #c4b5fd; border-radius: 12px; padding: 32px; margin: 32px 0; text-align: center; }
.formula-box h3 { margin-top: 0; color: #4c1d95; font-size: 1.25rem; margin-bottom: 20px; }
.formula-display { font-family: 'Courier New', monospace; font-size: 1.25rem; font-weight: 700; color: #5b21b6; background: #ffffff; padding: 20px; border-radius: 8px; margin: 12px 0; border: 1px solid #e2e8f0; }
.formula-example { background: #ffffff; padding: 20px; border-radius: 8px; margin-top: 20px; text-align: left; border: 1px solid #e2e8f0; }
.formula-example h4 { margin-top: 0; font-size: 1rem; color: #1e293b; margin-bottom: 12px; }
.formula-step { font-family: 'Courier New', monospace; font-size: 0.9375rem; color: #64748b; margin: 8px 0; padding-left: 16px; border-left: 3px solid #c4b5fd; }

/* BMI Table */
.bmi-table { width: 100%; border-collapse: collapse; margin: 32px 0; font-size: 1rem; }
.bmi-table th, .bmi-table td { padding: 16px; border: 1px solid #e2e8f0; text-align: left; }
.bmi-table th { background: #f8fafc; font-weight: 600; color: #1e293b; }
.bmi-table tr:hover { background: #f8fafc; }

/* FAQ Items */
.faq-item { padding: 32px 0; border-bottom: 1px solid #e2e8f0; }
.faq-item:last-child { border-bottom: none; }
.faq-item h3 { margin-top: 0; }

/* Medical Disclaimer */
.medical-disclaimer { background: #fef3c7; border-left: 4px solid #f59e0b; padding: 20px; border-radius: 8px; margin: 48px 0; }
.medical-disclaimer p { margin: 0; color: #92400e; font-size: 1rem; line-height: 1.6; }
.medical-disclaimer strong { color: #78350f; }

/* References Section */
.references-section { margin-top: 60px; padding-top: 32px; border-top: 2px solid #e2e8f0; }
.references-section h3 { font-size: 1.25rem; font-weight: 600; color: #1e293b; margin-bottom: 20px; }
.references-list { list-style: none; padding: 0; margin: 0; counter-reset: ref-counter; }
.references-list li { margin-bottom: 16px; padding-left: 40px; position: relative; color: #475569; font-size: 0.9375rem; line-height: 1.6; counter-increment: ref-counter; }
.references-list li::before { content: '[' counter(ref-counter) ']'; position: absolute; left: 0; color: #5b21b6; font-weight: 600; }

.references-list a { 
    color: #1e3a8a; /* Very dark blue to ensure 3:1 contrast against gray text */
    font-weight: 600; /* Bold weight provides a non-color visual cue */
    text-decoration: none; 
}
.references-list a:hover { 
    color: #172554; /* Even darker on hover */
}

.references-list strong { color: #1e293b; font-weight: 600; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .results-grid { grid-template-columns: 1fr !important; gap: 12px; }
    .bmi-box { min-height: auto; position: static; margin-bottom: 0; width: 100%; padding: 20px 12px; }
    .bmi-controls { min-height: auto; width: 100%; padding: 10px; }
    .category-section { width: 100%; overflow-x: auto; padding: 12px; margin-top: 12px; }
}

@media (max-width: 640px) {
    /* Calculator Mobile Adjustments */
    .bmi-value { font-size: 5rem; }
    .bmi-unit { font-size: 1rem; }
    .bmi-category { font-size: 1.1rem; }
    .ideal-weight-range { font-size: 1.2rem; }
    .category-table { font-size: 0.8rem; }
    .category-table th, .category-table td { padding: 8px 6px; }
    .bmi-controls { padding: 10px; }
    .ideal-weight { margin: 8px 0; padding: 10px; }
    .bmi-scale { margin: 8px 0; padding: 10px; }
    .health-risk { margin-top: 8px; padding: 10px; }
    .health-risk-text { font-size: 0.8rem; }
    
    /* SEO Content Mobile Adjustments */
    .article-content { padding: 24px 16px 48px; }
    .article-content h2 { font-size: 1.4rem; margin-top: 40px; margin-bottom: 16px; }
    .article-content h3 { font-size: 1.1rem; margin-top: 24px; margin-bottom: 12px; }
    .article-content p { font-size: 0.95rem; margin-bottom: 16px; line-height: 1.7; }
    .article-content li { font-size: 0.95rem; margin-bottom: 10px; }
    .article-content ul, .article-content ol { padding-left: 20px; }
    
    /* Formula Box */
    .formula-box { padding: 20px 16px; margin: 24px 0; }
    .formula-box h3 { font-size: 1rem; }
    .formula-display { font-size: 1rem; padding: 14px; }
    .formula-example { padding: 16px; }
    .formula-example h4 { font-size: 0.875rem; }
    .formula-step { font-size: 0.85rem; padding-left: 12px; }
    
    /* BMI Table */
    .bmi-table { font-size: 0.85rem; }
    .bmi-table th, .bmi-table td { padding: 10px 8px; }
    
    /* FAQ */
    .faq-item { padding: 24px 0; }
    .faq-item h3 { font-size: 1rem; }
    .faq-item p { font-size: 0.9rem; }
    
    /* References */
    .references-section { margin-top: 40px; padding-top: 24px; }
    .references-section h3 { font-size: 1rem; }
    .references-list li { font-size: 0.85rem; padding-left: 32px; }
    
    /* Medical Disclaimer */
    .medical-disclaimer { padding: 16px; margin: 32px 0; }
    .medical-disclaimer p { font-size: 0.875rem; }
}