/**
 * AEOS Glossary — Auto-link & Tooltip Styles
 * Loaded on all public pages where auto-linking is active.
 */

:root {
    --aeos-tooltip-bg:      #1f2937;
    --aeos-tooltip-text:    #f3f4f6;
    --aeos-tooltip-border:  #374151;
    --aeos-tooltip-width:   320px;
    --aeos-tooltip-radius:  10px;
    --aeos-tooltip-shadow:  0 8px 32px rgba(0,0,0,0.28), 0 2px 8px rgba(0,0,0,0.16);
    --aeos-link-underline:  #3b82f6;
}

/* ── Auto-link anchor ────────────────────────────────────────────────────────── */

.aeos-term-link {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: var(--aeos-link-underline);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
    text-decoration-style: dotted;
    cursor: help;
    transition: text-decoration-color 0.15s ease, background 0.15s ease;
    border-radius: 2px;
    position: relative;
}

.aeos-term-link:hover,
.aeos-term-link:focus {
    text-decoration-style: solid;
    background: rgba(59, 130, 246, 0.08);
    outline: none;
}

.aeos-term-link:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* ── Tooltip region container ────────────────────────────────────────────────── */

.aeos-tooltip-region {
    position: fixed;
    z-index: 9999;
    width: var(--aeos-tooltip-width);
    max-width: min(var(--aeos-tooltip-width), calc(100vw - 24px));
    pointer-events: none;
    opacity: 0;
    transform: translateY(6px) scale(0.98);
    transition: opacity 0.18s ease, transform 0.18s ease;
    will-change: transform, opacity;
}

.aeos-tooltip-region:not([hidden]) {
    pointer-events: auto;
}

.aeos-tooltip-region.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* ── Tooltip card ────────────────────────────────────────────────────────────── */

.aeos-tooltip-card {
    background: var(--aeos-tooltip-bg);
    color: var(--aeos-tooltip-text);
    border: 1px solid var(--aeos-tooltip-border);
    border-radius: var(--aeos-tooltip-radius);
    box-shadow: var(--aeos-tooltip-shadow);
    overflow: hidden;
}

.aeos-tooltip-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 8px;
    border-bottom: 1px solid var(--aeos-tooltip-border);
}

.aeos-tooltip-term {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
}

.aeos-tooltip-clusters {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.aeos-tooltip-cluster {
    font-size: 10px;
    padding: 1px 8px;
    background: rgba(255,255,255,0.08);
    color: #93c5fd;
    border: 1px solid rgba(147, 197, 253, 0.3);
    border-radius: 999px;
}

/* AEO snippet inside tooltip — same hard-coded class, dark-mode adjusted. */
.aeos-tooltip-card .aeo-snippet {
    background: rgba(59,130,246,0.1);
    border-left: 3px solid #3b82f6;
    border-radius: 0;
    padding: 10px 16px;
    margin: 0;
}

.aeos-tooltip-card .aeo-snippet::before {
    color: #93c5fd;
    font-size: 9px;
}

.aeos-tooltip-card .aeo-snippet p {
    font-size: 13px;
    line-height: 1.55;
    color: var(--aeos-tooltip-text);
}

.aeos-tooltip-related {
    padding: 8px 16px;
    border-top: 1px solid var(--aeos-tooltip-border);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.aeos-tooltip-related__label {
    font-size: 11px;
    color: #9ca3af;
    font-weight: 600;
}

.aeos-tooltip-related__link {
    font-size: 12px;
    color: #93c5fd;
    text-decoration: none;
}

.aeos-tooltip-related__link:hover {
    text-decoration: underline;
}

.aeos-tooltip-readmore {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: rgba(255,255,255,0.04);
    border-top: 1px solid var(--aeos-tooltip-border);
    font-size: 12px;
    font-weight: 600;
    color: #60a5fa;
    text-decoration: none;
    transition: background 0.12s ease;
}

.aeos-tooltip-readmore:hover {
    background: rgba(255,255,255,0.08);
    color: #93c5fd;
}

/* ── Loading state ───────────────────────────────────────────────────────────── */

.aeos-tooltip-loading {
    padding: 20px 16px;
    text-align: center;
    font-size: 13px;
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.aeos-tooltip-loading-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #6b7280;
    border-radius: 50%;
    animation: aeos-pulse 1.2s ease-in-out infinite;
}

.aeos-tooltip-loading-dot:nth-child(2) { animation-delay: 0.2s; }
.aeos-tooltip-loading-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes aeos-pulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40%            { opacity: 1;   transform: scale(1); }
}

/* ── Tooltip arrow ───────────────────────────────────────────────────────────── */

.aeos-tooltip-region::before {
    content: '';
    position: absolute;
    left: 20px;
    bottom: 100%;
    border: 7px solid transparent;
    border-bottom-color: var(--aeos-tooltip-border);
    pointer-events: none;
}

.aeos-tooltip-region::after {
    content: '';
    position: absolute;
    left: 21px;
    bottom: 100%;
    border: 6px solid transparent;
    border-bottom-color: var(--aeos-tooltip-bg);
    pointer-events: none;
}

.aeos-tooltip-region.is-above::before {
    bottom: auto;
    top: 100%;
    border-bottom-color: transparent;
    border-top-color: var(--aeos-tooltip-border);
}

.aeos-tooltip-region.is-above::after {
    bottom: auto;
    top: 100%;
    border-bottom-color: transparent;
    border-top-color: var(--aeos-tooltip-bg);
}

/* ── Reduced motion ──────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    .aeos-tooltip-region,
    .aeos-hub-card,
    .aeos-term-link {
        transition: none;
    }

    .aeos-tooltip-loading-dot {
        animation: none;
        opacity: 0.6;
    }
}
