/* ==========================================
   CSS VARIABLES
   ========================================== */
:root {
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --border-light: #f1f5f9;
    --border-medium: #e2e8f0;
    --primary: #5b21b6;
    --primary-dark: #4c1d95;
    --primary-light: #c4b5fd;
    --gradient-subtle: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* ==========================================
   NON-CRITICAL CSS: 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); } }

.summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.summary-card {
    border-radius: 12px;
    padding: 24px 20px;
    color: white;
    text-align: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.summary-card::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; 
}

.primary-card { background: linear-gradient(135deg, #10b981 0%, #059669 100%); }
.activity-card { background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); }

.summary-label { font-size: 0.85rem; opacity: 0.9; margin-bottom: 8px; position: relative; z-index: 1; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.summary-value { font-size: 3rem; font-weight: 700; line-height: 1; position: relative; z-index: 1; letter-spacing: -2px; margin-bottom: 8px; }
.summary-unit { font-size: 0.9rem; opacity: 0.85; font-weight: 500; position: relative; z-index: 1; }
.summary-detail { font-size: 0.8rem; opacity: 0.8; margin-top: 12px; position: relative; z-index: 1; font-style: italic; }

.activity-list { text-align: left; position: relative; z-index: 1; margin-top: 12px; }
.activity-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.2); font-size: 0.85rem; }
.activity-item:last-child { border-bottom: none; }
.activity-name { opacity: 0.9; }
.activity-calories { font-weight: 700; font-size: 0.95rem; }

/* Formula Comparison Table */
.comparison-section {
    background: white;
    border-radius: 12px;
    padding: 20px;
    border: 2px solid #f1f5f9;
    box-shadow: 0 4px 15px rgba(0,0,0,0.03);
    margin-bottom: 20px;
}

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

.formula-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; color: #334155; }
.formula-table th { background: #f8fafc; padding: 12px; text-align: left; font-weight: 600; color: #64748b; border-bottom: 2px solid #e2e8f0; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.formula-table td { padding: 12px; border-bottom: 1px solid #f1f5f9; }
.formula-table tr:hover { background: #f8fafc; }
.formula-table .formula-name { font-weight: 600; color: #1e293b; }
.formula-table .formula-value { font-weight: 700; color: #5b21b6; font-size: 1.05rem; }
.formula-table .formula-best { color: #64748b; font-size: 0.85rem; }

/* Next Step Cross-Promotion */
.next-step-section {
    background: linear-gradient(135deg, #f5f3ff 0%, #ede9fe 100%);
    border: 2px solid #c4b5fd;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 20px;
}

.next-step-icon { font-size: 2rem; flex-shrink: 0; }
.next-step-title { font-size: 1.1rem; font-weight: 700; color: #4c1d95; margin-bottom: 8px; }
.next-step-text { font-size: 0.9rem; color: #5b21b6; line-height: 1.6; margin-bottom: 12px; }
.next-step-btn { 
    display: inline-block; 
    padding: 10px 20px; 
    background: #5b21b6; 
    color: white; 
    text-decoration: none; 
    border-radius: 8px; 
    font-weight: 600; 
    font-size: 0.9rem; 
    transition: all 0.2s; 
}
.next-step-btn:hover { background: #4c1d95; transform: translateY(-2px); }

/* Recalculate Button */
.recalculate-btn {
    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; 
    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 */
.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; }
.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 Styles */
.formula-box { 
    background: var(--gradient-subtle); 
    border: 2px solid var(--primary-light); 
    border-radius: var(--radius-lg); 
    padding: var(--space-6); 
    margin: var(--space-6) 0; 
    text-align: center; 
}
.formula-box h3 { margin-top: 0; color: var(--primary-dark); font-size: 1.125rem; margin-bottom: var(--space-4); }
.formula-display { 
    font-family: 'Courier New', monospace; 
    font-size: 1.25rem; 
    font-weight: 700; 
    color: var(--primary); 
    background: var(--bg-primary); 
    padding: var(--space-4); 
    border-radius: var(--radius-md); 
    margin: var(--space-3) 0; 
    border: 1px solid var(--border-light); 
}
.formula-example { 
    background: var(--bg-primary); 
    padding: var(--space-4); 
    border-radius: var(--radius-md); 
    margin-top: var(--space-4); 
    text-align: left; 
    border: 1px solid var(--border-light); 
}
.formula-example h4 { margin-top: 0; font-size: 0.9375rem; color: var(--text-primary); margin-bottom: var(--space-3); }
.formula-step { 
    font-family: 'Courier New', monospace; 
    font-size: 0.9375rem; 
    color: var(--text-secondary); 
    margin: var(--space-2) 0; 
    padding-left: var(--space-4); 
    border-left: 3px solid var(--primary-light); 
}

/* FAQ Items */
.faq-item { padding: 16px 0; border-bottom: 1px solid #e2e8f0; }
.faq-item:last-child { border-bottom: none; }
.faq-item h3 { margin-top: 0; font-size: 1.1rem; }
.faq-item p { margin-bottom: 0; }

/* Medical Disclaimer */
.medical-disclaimer {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-left: 4px solid #f59e0b;
    border-radius: 8px;
    padding: 20px;
    margin: 48px 0;
    display: flex;
    gap: 16px;
    align-items: flex-start;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}
.disclaimer-icon { font-size: 1.5rem; flex-shrink: 0; line-height: 1; }
.disclaimer-content { flex: 1; }
.disclaimer-content strong { color: #92400e; font-size: 1rem; display: block; margin-bottom: 8px; }
.disclaimer-content p { margin: 0; color: #78350f; font-size: 0.95rem; line-height: 1.6; }

/* References Section */
.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 strong { color: #1e293b; font-weight: 600; }

/* WCAG Accessibility Standard for Reference Links */
.references-list a { 
    color: #1e3a8a; 
    font-weight: 600; 
    text-decoration: none; 
}
.references-list a:hover { 
    color: #172554; 
}

/* Responsive */
@media (max-width: 768px) {
    .summary-grid { grid-template-columns: 1fr; gap: 15px; }
}

@media (max-width: 640px) {
    .summary-value { font-size: 2.5rem; }
    
    .article-content { padding: 24px 2px 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 { 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; }
    
    .faq-item { padding: 12px 0; }
    .faq-item h3 { font-size: 1rem; }
    .faq-item p { font-size: 0.9rem; }
    
    .medical-disclaimer { padding: 16px; margin: 32px 0; flex-direction: column; gap: 8px; }
    .disclaimer-content p { font-size: 0.875rem; }
    
    .next-step-section { flex-direction: column; text-align: center; align-items: center; }
}