/* AI Content Processor - Interlinking Styles */

/* IMPORTANT: Only target specific interlinking elements to avoid conflicts */

/* Base styles for automatic links - ONLY these specific classes */
a.acp-auto-link {
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
    transition: all 0.2s ease;
}

/* Article links - internal content links */
a.acp-article-link {
    color: #0073aa;
    text-decoration: underline;
    text-decoration-style: solid;
    text-underline-offset: 2px;
    border-bottom: none;
    transition: all 0.2s ease;
}

a.acp-article-link:hover {
    color: #005a87;
    text-decoration-style: double;
    background-color: rgba(0, 115, 170, 0.05);
    padding: 0 2px;
    border-radius: 2px;
}

a.acp-article-link:visited {
    color: #6b46c1;
}

a.acp-article-link:active {
    color: #dc2626;
}

/* Entity links - links to entity pages */
a.acp-entity-link {
    color: #059669;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
    border-bottom: 1px dotted rgba(5, 150, 105, 0.4);
    transition: all 0.2s ease;
    position: relative;
}

a.acp-entity-link:hover {
    color: #047857;
    text-decoration-style: solid;
    background-color: rgba(5, 150, 105, 0.08);
    padding: 0 3px;
    border-radius: 3px;
    border-bottom: 1px solid rgba(5, 150, 105, 0.6);
}

a.acp-entity-link:visited {
    color: #7c3aed;
    border-bottom-color: rgba(124, 58, 237, 0.4);
}

a.acp-entity-link:active {
    color: #b91c1c;
}

/* Topic links - links to topic pages */
a.acp-topic-link {
    color: #7c3aed;
    text-decoration: underline;
    text-decoration-style: dashed;
    text-underline-offset: 2px;
    border-bottom: 1px dashed rgba(124, 58, 237, 0.4);
    transition: all 0.2s ease;
    position: relative;
}

a.acp-topic-link:hover {
    color: #6d28d9;
    text-decoration-style: solid;
    background-color: rgba(124, 58, 237, 0.08);
    padding: 0 3px;
    border-radius: 3px;
    border-bottom: 1px solid rgba(124, 58, 237, 0.6);
}

a.acp-topic-link:visited {
    color: #a855f7;
    border-bottom-color: rgba(168, 85, 247, 0.4);
}

a.acp-topic-link:active {
    color: #dc2626;
}

/* Entity link with category-specific styling */
a.acp-entity-link[data-entity-category="Person"] {
    color: #dc2626;
    border-bottom-color: rgba(220, 38, 38, 0.4);
}

a.acp-entity-link[data-entity-category="Organization"] {
    color: #7c2d12;
    border-bottom-color: rgba(124, 45, 18, 0.4);
}

a.acp-entity-link[data-entity-category="Technology"] {
    color: #7c3aed;
    border-bottom-color: rgba(124, 58, 237, 0.4);
}

a.acp-entity-link[data-entity-category="Location"] {
    color: #059669;
    border-bottom-color: rgba(5, 150, 105, 0.4);
}

a.acp-entity-link[data-entity-category="Product"] {
    color: #ea580c;
    border-bottom-color: rgba(234, 88, 12, 0.4);
}

/* Hover effects for category-specific entity links */
a.acp-entity-link[data-entity-category="Person"]:hover {
    background-color: rgba(220, 38, 38, 0.08);
    border-bottom-color: rgba(220, 38, 38, 0.6);
}

a.acp-entity-link[data-entity-category="Organization"]:hover {
    background-color: rgba(124, 45, 18, 0.08);
    border-bottom-color: rgba(124, 45, 18, 0.6);
}

a.acp-entity-link[data-entity-category="Technology"]:hover {
    background-color: rgba(124, 58, 237, 0.08);
    border-bottom-color: rgba(124, 58, 237, 0.6);
}

a.acp-entity-link[data-entity-category="Location"]:hover {
    background-color: rgba(5, 150, 105, 0.08);
    border-bottom-color: rgba(5, 150, 105, 0.6);
}

a.acp-entity-link[data-entity-category="Product"]:hover {
    background-color: rgba(234, 88, 12, 0.08);
    border-bottom-color: rgba(234, 88, 12, 0.6);
}

/* Entity link tooltip removed — using styled CSS tooltips instead */

/* ===== Styled Tooltips for All Link Types ===== */

a.acp-entity-link,
a.acp-article-link,
a.acp-topic-link,
a.acp-semantic-link {
    position: relative;
}

a.acp-entity-link::after,
a.acp-article-link::after,
a.acp-topic-link::after,
a.acp-semantic-link::after {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
    pointer-events: none;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
    letter-spacing: 0.2px;
}

a.acp-entity-link:hover::after,
a.acp-article-link:hover::after,
a.acp-topic-link:hover::after,
a.acp-semantic-link:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Arrow */
a.acp-entity-link::before,
a.acp-article-link::before,
a.acp-topic-link::before,
a.acp-semantic-link::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    pointer-events: none;
    z-index: 10001;
}

a.acp-entity-link:hover::before,
a.acp-article-link:hover::before,
a.acp-topic-link:hover::before,
a.acp-semantic-link:hover::before {
    opacity: 1;
    visibility: visible;
}

/* Entity: purple theme */
a.acp-entity-link::after {
    content: '🔍 ' attr(data-tooltip);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
}
a.acp-entity-link::before {
    border-top-color: #764ba2;
}

/* Article: blue theme */
a.acp-article-link::after {
    content: '📖 ' attr(data-tooltip);
    background: linear-gradient(135deg, #2271b1 0%, #135e96 100%);
    color: #fff;
}
a.acp-article-link::before {
    border-top-color: #135e96;
}

/* Topic: teal theme */
a.acp-topic-link::after {
    content: '💡 ' attr(data-tooltip);
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: #1d2327;
}
a.acp-topic-link::before {
    border-top-color: #11998e;
}

/* Semantic: coral/pink theme */
a.acp-semantic-link::after {
    content: '🔗 ' attr(data-tooltip);
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: #fff;
}
a.acp-semantic-link::before {
    border-top-color: #f093fb;
}

/* Hide CSS tooltips on mobile */
@media (max-width: 768px) {
    a.acp-entity-link::after,
    a.acp-entity-link::before,
    a.acp-article-link::after,
    a.acp-article-link::before,
    a.acp-topic-link::after,
    a.acp-topic-link::before,
    a.acp-semantic-link::after,
    a.acp-semantic-link::before {
        display: none;
    }
}

/* Responsive adjustments - only for interlinking elements */
@media (max-width: 768px) {

    a.acp-article-link,
    a.acp-entity-link {
        text-underline-offset: 1px;
    }

    a.acp-article-link:hover,
    a.acp-entity-link:hover {
        padding: 0 1px;
    }

    /* Hide tooltips on mobile to avoid clutter */
}

/* High contrast mode support - only for interlinking elements */
@media (prefers-contrast: high) {
    a.acp-article-link {
        color: #000080;
        text-decoration-style: solid;
        border-bottom: 2px solid #000080;
    }

    a.acp-entity-link {
        color: #006400;
        text-decoration-style: solid;
        border-bottom: 2px solid #006400;
    }

    a.acp-article-link:hover,
    a.acp-entity-link:hover {
        background-color: #ffff00;
        color: #000000;
    }
}

/* Reduced motion support - only for interlinking elements */
@media (prefers-reduced-motion: reduce) {

    a.acp-article-link,
    a.acp-entity-link {
        transition: none;
    }
}

/* Dark mode support - only for interlinking elements */
@media (prefers-color-scheme: dark) {
    a.acp-article-link {
        color: #60a5fa;
    }

    a.acp-article-link:hover {
        color: #93c5fd;
        background-color: rgba(96, 165, 250, 0.1);
    }

    a.acp-article-link:visited {
        color: #a78bfa;
    }

    a.acp-entity-link {
        color: #34d399;
    }

    a.acp-entity-link:hover {
        color: #6ee7b7;
        background-color: rgba(52, 211, 153, 0.1);
    }

    a.acp-entity-link:visited {
        color: #c084fc;
    }

    /* Dark mode category colors - specific selectors only */
    a.acp-entity-link[data-entity-category="Person"] {
        color: #fca5a5;
    }

    a.acp-entity-link[data-entity-category="Organization"] {
        color: #fdba74;
    }

    a.acp-entity-link[data-entity-category="Technology"] {
        color: #c4b5fd;
    }

    a.acp-entity-link[data-entity-category="Location"] {
        color: #6ee7b7;
    }


    a.acp-entity-link[data-entity-category="Product"] {
        color: #fed7aa;
    }

    /* Dark mode topic link colors */
    a.acp-topic-link {
        color: #c4b5fd;
    }

    a.acp-topic-link:hover {
        color: #ddd6fe;
        background-color: rgba(196, 181, 253, 0.1);
    }

    a.acp-topic-link:visited {
        color: #e9d5ff;
    }
}

/* Print styles - only for interlinking elements */
@media print {

    a.acp-article-link,
    a.acp-entity-link,
    a.acp-topic-link {
        color: #000000 !important;
        text-decoration: underline;
        background: none !important;
        border: none !important;
    }


}

/* Focus styles for accessibility - specific to interlinking elements */
a.acp-article-link:focus,
a.acp-entity-link:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
    background-color: rgba(0, 115, 170, 0.1);
    border-radius: 2px;
}

/* Animation for newly added links (optional) - scoped */
@keyframes acp-link-highlight {
    0% {
        background-color: rgba(255, 255, 0, 0.3);
    }

    100% {
        background-color: transparent;
    }
}

a.acp-new-link {
    animation: acp-link-highlight 2s ease-out;
}

/* Debug mode styles (when debug is enabled) - scoped */
.acp-debug a.acp-article-link::after {
    content: " [A:" attr(data-article-id) "]";
    color: #666;
    font-size: 10px;
    font-weight: normal;
}

.acp-debug a.acp-entity-link::after {
    content: " [E:" attr(data-entity-id) "]";
    color: #666;
    font-size: 10px;
    font-weight: normal;
}

/* Loading state for dynamic links - scoped */
a.acp-link-loading {
    opacity: 0.6;
    pointer-events: none;
}

a.acp-link-loading::after {
    content: "⏳";
    margin-left: 2px;
    font-size: 10px;
}

/* Error state for broken links - scoped */
a.acp-link-broken {
    color: #dc2626;
    text-decoration: line-through;
    opacity: 0.7;
}

a.acp-link-broken::after {
    content: " ⚠️";
    font-size: 10px;
}

/* Success state for validated links - scoped */
a.acp-link-validated {
    position: relative;
}

a.acp-link-validated::after {
    content: "✓";
    position: absolute;
    top: -2px;
    right: -8px;
    font-size: 8px;
    color: #059669;
    opacity: 0.7;
}

/* ===== Topic Archive Pagination ===== */

.pagination-wrapper {
    margin: 30px 0 20px;
    padding: 20px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.pagination-wrapper .pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 6px;
}

.pagination-wrapper .pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    color: #ccc;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
}

.pagination-wrapper .pagination .page-numbers:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.35);
    color: #fff;
}

.pagination-wrapper .pagination .page-numbers.current {
    background: #FB4540;
    border-color: #FB4540;
    color: #fff;
    font-weight: 700;
}

.pagination-wrapper .pagination .page-numbers.dots {
    border: none;
    background: none;
    min-width: auto;
    padding: 0 4px;
    color: #888;
}

.pagination-wrapper .pagination .page-numbers.prev,
.pagination-wrapper .pagination .page-numbers.next {
    padding: 0 16px;
    font-weight: 600;
}

/* Light theme override */
@media (prefers-color-scheme: light) {
    .pagination-wrapper {
        border-top-color: #dcdcde;
    }

    .pagination-wrapper .pagination .page-numbers {
        border-color: #dcdcde;
        background: #f6f7f7;
        color: #50575e;
    }

    .pagination-wrapper .pagination .page-numbers:hover {
        background: #e0e0e0;
        border-color: #999;
        color: #1d2327;
    }

    .pagination-wrapper .pagination .page-numbers.current {
        background: #FB4540;
        border-color: #FB4540;
        color: #fff;
    }
}

@media (max-width: 600px) {
    .pagination-wrapper .pagination .page-numbers {
        min-width: 36px;
        height: 36px;
        padding: 0 8px;
        font-size: 13px;
    }

    .pagination-wrapper .pagination .page-numbers.prev,
    .pagination-wrapper .pagination .page-numbers.next {
        padding: 0 10px;
    }
}
