/* ============================================
   MODERN REFERENCE SYSTEM - Minimal & Elegant
   ============================================ */

/* In-text citation styling */
.cite {
    position: relative;
    display: inline-block;
    vertical-align: super;
    font-size: 0.75em;
    line-height: 0;
    margin: 0 0.1em;
    cursor: pointer;
    text-decoration: none;
    color: #555;
    font-weight: 500;
    transition: all 0.2s ease;
}

.cite:hover {
    color: #1a1a1a;
}

/* Tooltip for reference preview */
.cite-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-8px);
    background: #2a2a2a;
    color: #e8e8e8;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: normal;
    max-width: 400px;
    min-width: 250px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    border: 1px solid #444;
    font-weight: normal;
    vertical-align: baseline;
}

.cite-tooltip::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #2a2a2a;
}

.cite:hover .cite-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(-12px);
}

/* Adjust tooltip position for citations near edges */
.cite-tooltip.tooltip-left {
    left: 0;
    transform: translateX(0) translateY(-8px);
}

.cite-tooltip.tooltip-left::before {
    left: 20px;
}

.cite:hover .cite-tooltip.tooltip-left {
    transform: translateX(0) translateY(-12px);
}

/* References Section */
.references-section {
    margin-top: 3rem;
    padding: 2rem 0;
    background: transparent;
    border-top: 1px solid #e0e0e0;
    position: relative;
}

.references-header {
    font-family: "Playfair Display", Georgia, serif;
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
    color: #1a1a1a;
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* Reference list items */
.references-list {
    font-size: 0.95rem;
    color: #444;
    padding-left: 0;
    margin: 0;
    list-style: none;
    counter-reset: ref-counter;
}

.references-list li {
    margin-bottom: 1.2rem;
    padding: 0.5rem 0 0.5rem 2.5rem;
    position: relative;
    line-height: 1.6;
    background: transparent;
    transition: all 0.2s ease;
    border-left: 2px solid transparent;
    scroll-margin-top: 100px;
}

.references-list li:hover {
    border-left-color: #ccc;
    padding-left: 2.6rem;
}

/* Reference number badge */
.references-list li::before {
    content: "[" counter(ref-counter) "]";
    counter-increment: ref-counter;
    position: absolute;
    left: 0;
    top: 0.5rem;
    color: #888;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.references-list li:hover::before {
    color: #333;
}

/* Back-to-text links */
.ref-backlink {
    display: inline-block;
    margin-left: 0.5rem;
    color: #666;
    text-decoration: none;
    font-size: 0.85em;
    opacity: 0.5;
    transition: all 0.2s ease;
    vertical-align: super;
    font-weight: 500;
}

.ref-backlink:hover {
    opacity: 1;
    transform: translateY(-1px);
    color: #333;
}

.ref-backlink::before {
    content: '↑';
    margin-right: 0.2em;
}

/* Highlight animation when scrolled to */
@keyframes highlight-ref {
    0% {
        background: transparent;
        border-left-color: transparent;
    }

    50% {
        background: #f5f5f5;
        border-left-color: #666;
    }

    100% {
        background: transparent;
        border-left-color: transparent;
    }
}

.references-list li:target {
    animation: highlight-ref 2s ease;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .cite-tooltip {
        max-width: 280px;
        min-width: 200px;
        font-size: 0.8rem;
        padding: 0.6rem 0.8rem;
    }

    .references-section {
        padding: 1.5rem 0;
    }

    .references-list li {
        padding: 0.5rem 0 0.5rem 2.5rem;
    }

    .references-list li::before {
        left: 0;
        top: 0.5rem;
    }
}

/* Smooth scrolling for the whole page */
html {
    scroll-behavior: smooth;
}