/**
 * Web Source Reference Styles
 *
 * Styles for web source reference links and footer — links BanterBox content
 * back to the original report web pages.
 *
 * Color scheme: Orange/amber (#d97706 / #f59e0b) — distinct from:
 *   - Blue: inline page citations (p. X)
 *   - Green: cited source citations [Author]{source_XXX}
 *   - Purple: edition citations [YEAR Edition]{edition:slug:page}
 */

/* ===== INLINE WEB SOURCE REF ===== */
.web-source-ref {
    color: var(--bb-web-source-accent, #d97706);
    cursor: pointer;
    padding: 0.05em 0.15em;
    border-radius: 2px;
    transition: background-color 0.15s ease;
    font-size: 0.85em;
    text-decoration: none;
    -webkit-user-select: text;
    -moz-user-select: text;
    user-select: text;
}

.web-source-ref:hover {
    background-color: rgba(217, 119, 6, 0.12);
}

.web-source-ref:focus {
    outline: 2px solid var(--bb-web-source-accent, #d97706);
    outline-offset: 2px;
}


/* ===== TOOLTIP ===== */
.web-source-tooltip {
    position: fixed;
    max-width: 300px;
    min-width: 180px;
    padding: 0;
    background: var(--bb-surface, #ffffff);
    border: 1px solid var(--bb-border, #e5e7eb);
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    z-index: 1500;
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    pointer-events: none;
    overflow: hidden;
}

.web-source-tooltip.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.web-source-tooltip .tooltip-header {
    padding: 0.5rem 0.75rem;
    background: linear-gradient(135deg, #d97706, #b45309);
    color: white;
}

.web-source-tooltip .ws-section-name {
    font-size: 0.8125rem;
    font-weight: 600;
    display: block;
}

.web-source-tooltip .tooltip-content {
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
    color: var(--bb-text-secondary, #6b7280);
}

.web-source-tooltip .ws-page-title {
    display: block;
}

.web-source-tooltip .tooltip-hint {
    padding: 0.4rem 0.75rem;
    font-size: 0.6875rem;
    color: var(--bb-text-tertiary, #9ca3af);
    text-align: center;
    border-top: 1px solid var(--bb-border-light, #f3f4f6);
}

/* Tooltip arrow */
.web-source-tooltip::before {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--bb-surface, #fff);
    border: 1px solid var(--bb-border, #e5e7eb);
    border-right: none;
    border-bottom: none;
}

.web-source-tooltip.above::before {
    bottom: -7px;
    left: 50%;
    margin-left: -6px;
    transform: rotate(-135deg);
}

.web-source-tooltip.below::before {
    top: -7px;
    left: 50%;
    margin-left: -6px;
    transform: rotate(45deg);
    background: linear-gradient(135deg, #d97706, #b45309);
    border: none;
}


/* ===== FOOTER ===== */
.web-source-footer {
    margin-top: 1rem;
    padding: 0.5rem 0.75rem;
    background: transparent;
    border-radius: 6px;
    border-left: 2px solid var(--bb-web-source-accent, #d97706);
    order: 9998;  /* Before citation footer (9999) but after content */
}

.web-source-footer-header {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.35rem;
    font-weight: 500;
    font-size: 0.7rem;
    color: var(--bb-text-muted, #888);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.web-source-footer-icon {
    font-size: 0.8rem;
    opacity: 0.7;
}

.web-source-footer-title {
    flex-grow: 1;
}

.web-source-footer-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.web-source-footer-item {
    display: inline-flex;
    flex-direction: column;
    gap: 0.1rem;
    max-width: 280px;
}

.web-source-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.5rem;
    background: var(--bb-surface-alt, #f7f7f5);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s, border-color 0.15s;
    border: 1px solid var(--bb-border-light, #eee);
    text-decoration: none;
    color: var(--bb-web-source-accent, #d97706);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.3;
}

.web-source-link:hover {
    background: rgba(217, 119, 6, 0.08);
    border-color: var(--bb-web-source-accent, #d97706);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    color: var(--bb-web-source-accent-hover, #b45309);
    text-decoration: none;
}

.web-source-link:focus {
    outline: 2px solid var(--bb-web-source-accent, #d97706);
    outline-offset: 1px;
}

.web-source-arrow {
    font-size: 0.7rem;
    opacity: 0.6;
    transition: transform 0.15s;
}

.web-source-link:hover .web-source-arrow {
    transform: translateX(2px);
    opacity: 1;
}

.web-source-description {
    font-size: 0.65rem;
    color: var(--bb-text-muted, #999);
    padding-left: 0.5rem;
    display: none;
}

.web-source-footer-item:hover .web-source-description {
    display: block;
}


/* ===== DARK MODE ===== */
[data-theme="dark"] .web-source-ref {
    color: var(--bb-web-source-accent, #fbbf24);
}

[data-theme="dark"] .web-source-ref:hover {
    background-color: rgba(251, 191, 36, 0.15);
}

[data-theme="dark"] .web-source-tooltip {
    background: var(--bb-surface, #2d2a26);
    border-color: var(--bb-border, #4a4238);
}

[data-theme="dark"] .web-source-tooltip .tooltip-content {
    color: var(--bb-text-secondary, #a8a29e);
}

[data-theme="dark"] .web-source-tooltip .tooltip-hint {
    color: var(--bb-text-tertiary, #78716c);
    border-color: var(--bb-border-light, #3a3631);
}

[data-theme="dark"] .web-source-tooltip::before {
    background: var(--bb-surface, #2d2a26);
    border-color: var(--bb-border, #4a4238);
}

[data-theme="dark"] .web-source-tooltip.below::before {
    background: linear-gradient(135deg, #d97706, #b45309);
    border: none;
}

[data-theme="dark"] .web-source-footer {
    border-color: var(--bb-web-source-accent, #fbbf24);
}

[data-theme="dark"] .web-source-link {
    background: var(--bb-surface-alt, #2a2825);
    border-color: var(--bb-border, #444);
    color: var(--bb-web-source-accent, #fbbf24);
}

[data-theme="dark"] .web-source-link:hover {
    background: rgba(251, 191, 36, 0.1);
    border-color: var(--bb-web-source-accent, #fbbf24);
}

[data-theme="dark"] .web-source-description {
    color: var(--bb-text-muted, #78716c);
}


/* ===== SEPIA MODE ===== */
[data-theme="sepia"] .web-source-ref {
    color: #92400e;
}

[data-theme="sepia"] .web-source-ref:hover {
    background-color: rgba(146, 64, 14, 0.1);
}

[data-theme="sepia"] .web-source-tooltip {
    background: #faf8f3;
    border-color: #d4c9b0;
}

[data-theme="sepia"] .web-source-tooltip .tooltip-header {
    background: linear-gradient(135deg, #92400e, #78350f);
}

[data-theme="sepia"] .web-source-tooltip .tooltip-content {
    color: #78716c;
}

[data-theme="sepia"] .web-source-tooltip .tooltip-hint {
    color: #a8a29e;
    border-color: #e7e0d5;
}

[data-theme="sepia"] .web-source-tooltip::before {
    background: #faf8f3;
    border-color: #d4c9b0;
}

[data-theme="sepia"] .web-source-tooltip.below::before {
    background: linear-gradient(135deg, #92400e, #78350f);
    border: none;
}

[data-theme="sepia"] .web-source-footer {
    border-color: #92400e;
}

[data-theme="sepia"] .web-source-link {
    background: #f5f0e6;
    border-color: #d4c9b0;
    color: #92400e;
}

[data-theme="sepia"] .web-source-link:hover {
    background: #ebe5d8;
    border-color: #92400e;
}

[data-theme="sepia"] .web-source-description {
    color: #a8a29e;
}


/* ===== MOBILE ===== */
@media (max-width: 640px) {
    .web-source-tooltip {
        max-width: calc(100vw - 32px);
        left: 16px !important;
        right: 16px !important;
    }

    .web-source-tooltip::before {
        display: none;
    }

    .web-source-footer {
        margin-top: 0.75rem;
        padding: 0.4rem 0.5rem;
    }

    .web-source-link {
        font-size: 0.7rem;
        padding: 0.25rem 0.4rem;
    }
}
