/**
 * Professional Citation System Styles
 * Following high-end journalism best practices (BBC, Reuters, Financial Times)
 * Citations are present but subtle - nearly invisible until hovered/focused
 * Maintains full functionality while prioritizing clean visual presentation
 */

/* Citation Links - Subtle and Professional */
.citation-link {
    font-size: 0.5em;
    line-height: 1;
    margin-left: 1px;
    position: relative;
    vertical-align: super;
}

.citation-number {
    color: #999;
    text-decoration: none;
    font-weight: 400;
    transition: all 0.2s ease;
    border-radius: 2px;
    padding: 0px 1px;
    opacity: 0.7;
}

.citation-number:hover,
.citation-number:focus {
    background-color: #666;
    color: white;
    text-decoration: none;
    outline: none;
    opacity: 1;
    transform: scale(1.1);
}

.citation-number:focus {
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.3);
}

/* Tooltip Styles */
.citation-tooltip {
    position: absolute;
    background-color: #1f2937;
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.85em;
    line-height: 1.4;
    max-width: 300px;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s ease;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

.citation-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border: 5px solid transparent;
    border-top-color: #1f2937;
}

/* Footnotes Section */
.footnotes-section {
    margin-top: 3rem;
    padding: 2rem 0;
    border-top: 2px solid #e5e7eb;
    background-color: #f9fafb;
}

.footnotes-section h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: #1f2937;
}

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

.footnote-item {
    margin-bottom: 1.2rem;
    padding: 0.8rem;
    background-color: white;
    border-radius: 6px;
    border-left: 3px solid #2563eb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: relative;
    line-height: 1.5;
}

.footnote-backref {
    color: #2563eb;
    text-decoration: none;
    font-weight: bold;
    font-size: 0.9em;
    margin-right: 0.5rem;
    display: inline-block;
    width: 20px;
    text-align: center;
}

.footnote-backref:hover {
    color: #1d4ed8;
}

.citation-content {
    display: inline;
    color: #374151;
}

.citation-content strong {
    color: #1f2937;
}

.source-link {
    color: #2563eb;
    text-decoration: none;
    word-break: break-all;
}

.source-link:hover {
    text-decoration: underline;
}

.citation-methodology,
.citation-notes {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background-color: #f3f4f6;
    border-radius: 4px;
    color: #6b7280;
}

.citation-methodology strong,
.citation-notes strong {
    color: #374151;
}

.methodology-note {
    margin-top: 1.5rem;
    padding: 1rem;
    background-color: #e0f2fe;
    border-radius: 6px;
    text-align: center;
}

.methodology-note a {
    color: #0369a1;
    text-decoration: none;
    font-weight: 500;
}

.methodology-note a:hover {
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
    .citation-tooltip {
        max-width: 250px;
        font-size: 0.8em;
    }
    
    /* Keep citations extra subtle on mobile */
    .citation-link {
        font-size: 0.45em;
        opacity: 0.6;
    }
    
    .fact-item .citation-link,
    .stat-card .citation-link {
        font-size: 0.35em;
        opacity: 0.4;
    }
    
    /* Mobile hover alternative - tap to reveal */
    .fact-item:active .citation-link,
    .stat-card:active .citation-link {
        opacity: 0.8;
    }
    
    .footnotes-section {
        padding: 1.5rem 0;
    }
    
    .footnote-item {
        padding: 0.6rem;
        margin-bottom: 1rem;
    }
    
    .footnotes-section h3 {
        font-size: 1.3rem;
    }
    
    .source-link {
        word-break: break-all;
        font-size: 0.9em;
    }
}

/* Print Styles */
@media print {
    .citation-tooltip {
        display: none;
    }
    
    .citation-number {
        color: #000;
        background: none !important;
    }
    
    .footnotes-section {
        background-color: white;
        border-top: 1px solid #000;
        page-break-inside: avoid;
    }
    
    .footnote-item {
        background-color: white;
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }
    
    .source-link:after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .citation-number {
        border: 1px solid currentColor;
    }
    
    .citation-tooltip {
        background-color: #000;
        border: 1px solid #fff;
    }
    
    .footnote-item {
        border: 2px solid #000;
        border-left: 4px solid #0000ff;
    }
}

/* Inline text citations - newspaper style */
p [data-cite] .citation-link,
span[data-cite] .citation-link {
    font-size: 0.45em;
    margin-left: 0px;
    opacity: 0.6;
    vertical-align: super;
    position: relative;
    top: -1px;
}

/* Hover enhancement for better UX */
[data-cite]:hover .citation-link {
    opacity: 0.9;
}

/* Focus states for accessibility - keep subtle but accessible */
.citation-link:focus-within .citation-number {
    opacity: 1;
    outline: 1px solid #666;
    outline-offset: 1px;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .citation-number,
    .citation-tooltip {
        transition: none;
    }
    
    .citation-number:hover {
        transform: none;
    }
}

/* Focus Indicators for Accessibility */
.citation-link:focus-within .citation-number,
.footnote-backref:focus,
.source-link:focus,
.methodology-note a:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* Special styling for inline statistics with citations */
.stat-number[data-cite],
.fact-number[data-cite] {
    position: relative;
}

.stat-number .citation-link,
.fact-number .citation-link {
    position: absolute;
    top: -2px;
    right: -8px;
    font-size: 0.4em;
    opacity: 0.5;
}

/* Story-specific citation styles - Subtle inline */
.story-stats-inline .citation-link {
    font-size: 0.45em;
    margin-left: 1px;
    opacity: 0.6;
    vertical-align: super;
}

/* Homepage stats grid citations - Ultra subtle */
.stat-card .citation-link {
    position: absolute;
    top: 3px;
    right: 6px;
    font-size: 0.4em;
    opacity: 0.5;
}

.stat-card:hover .citation-link {
    opacity: 0.8;
}

.stat-card {
    position: relative;
}

/* Quick facts citations - Ultra subtle */
.fact-item .citation-link {
    position: absolute;
    top: 5px;
    right: 8px;
    font-size: 0.4em;
    opacity: 0.5;
}

.fact-item:hover .citation-link {
    opacity: 0.8;
}