/* ================================================
   INTELLIGENT TOOLTIP SYSTEM STYLES
   Modern, Accessible Tooltips for Scientific Terms
   ================================================ */

/* Tooltip Container (Global) */
.tooltip-container {
    position: absolute;
    z-index: 10000;
    max-width: 400px;
    width: max-content;
    background: var(--slate-dark);
    color: var(--text-inverse);
    border-radius: var(--radius-md);
    padding: 0;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(184, 115, 51, 0.3);
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    pointer-events: none;
    font-size: 0.95rem;
    line-height: 1.6;
}

.tooltip-container.visible {
    opacity: 1;
    transform: translateY(0);
}

.tooltip-container.pinned {
    pointer-events: auto;
}

/* Tooltip Header */
.tooltip-header {
    padding: 0.875rem 1rem;
    background: linear-gradient(135deg, var(--bronze) 0%, var(--deep-gold) 100%);
    color: var(--slate-dark);
    font-weight: var(--weight-black);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.tooltip-header strong {
    font-size: 1.05rem;
    letter-spacing: 0.02em;
}

.tooltip-pronunciation {
    font-size: 0.8rem;
    font-style: italic;
    font-weight: var(--weight-medium);
    opacity: 0.9;
}

/* Tooltip Body */
.tooltip-body {
    padding: 1rem;
    background: var(--slate-dark);
    color: rgba(255, 255, 255, 0.95);
    line-height: 1.7;
}

/* Tooltip Footer */
.tooltip-footer {
    padding: 0.625rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    font-size: 0.85rem;
    text-align: center;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    color: rgba(255, 255, 255, 0.8);
}

.tooltip-footer.warning {
    background: linear-gradient(135deg, rgba(212, 106, 67, 0.9), rgba(232, 162, 78, 0.9));
    color: var(--slate-dark);
    font-weight: var(--weight-bold);
}

/* Category-Specific Tooltip Colors */
.tooltip-container.medical .tooltip-header {
    background: linear-gradient(135deg, #4A6FA5 0%, #6B8E75 100%);
    color: white;
}

.tooltip-container.psychological .tooltip-header {
    background: linear-gradient(135deg, var(--forest-deep) 0%, var(--sage) 100%);
    color: white;
}

.tooltip-container.legal .tooltip-header {
    background: linear-gradient(135deg, var(--burnt-sienna) 0%, #E8A24E 100%);
    color: white;
}

.tooltip-container.nutrition .tooltip-header {
    background: linear-gradient(135deg, var(--sage) 0%, #8FBC8F 100%);
    color: white;
}

.tooltip-container.warning {
    border-color: var(--burnt-sienna);
    box-shadow: 0 8px 32px rgba(212, 106, 67, 0.4), 0 0 0 2px rgba(212, 106, 67, 0.5);
}

/* Tooltip Terms (In-Text Styling) */
.tooltip-term {
    position: relative;
    cursor: help;
    border-bottom: 1px dotted currentColor;
    transition: all 0.2s ease;
}

.tooltip-term:hover {
    color: var(--bronze);
    border-bottom-color: var(--bronze);
    border-bottom-width: 2px;
}

.tooltip-term.medical {
    color: inherit;
}

.tooltip-term.medical:hover {
    color: #4A6FA5;
    border-bottom-color: #4A6FA5;
}

.tooltip-term.psychological:hover {
    color: var(--forest-deep);
    border-bottom-color: var(--forest-deep);
}

.tooltip-term.legal:hover {
    color: var(--burnt-sienna);
    border-bottom-color: var(--burnt-sienna);
}

.tooltip-term.nutrition:hover {
    color: var(--sage);
    border-bottom-color: var(--sage);
}

.tooltip-term.tooltip-warning {
    border-bottom-style: dashed;
    border-bottom-color: var(--burnt-sienna);
}

/* Mobile-Specific Styles */
@media (max-width: 768px) {
    .tooltip-container {
        max-width: calc(100vw - 40px);
        font-size: 0.9rem;
    }

    .tooltip-header {
        padding: 0.75rem 0.875rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .tooltip-pronunciation {
        font-size: 0.75rem;
    }

    .tooltip-body {
        padding: 0.875rem;
        line-height: 1.6;
    }

    .tooltip-footer {
        padding: 0.5rem 0.875rem;
        font-size: 0.8rem;
    }

    /* Make tooltips easier to tap on mobile */
    .tooltip-term {
        padding: 2px 0;
        border-bottom-width: 2px;
    }
}

/* Accessibility - Keyboard Focus */
.tooltip-term:focus {
    outline: 2px solid var(--bronze);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Print Styles - Show definitions inline */
@media print {
    .tooltip-term {
        border-bottom: none;
        font-weight: bold;
    }

    .tooltip-term::after {
        content: " (" attr(title) ")";
        font-weight: normal;
        font-size: 0.9em;
        font-style: italic;
    }

    .tooltip-container {
        display: none !important;
    }
}

/* Animation for pinned tooltips */
@keyframes tooltipPulse {
    0%, 100% {
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(184, 115, 51, 0.3);
    }
    50% {
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 0 2px rgba(184, 115, 51, 0.6);
    }
}

.tooltip-container.pinned {
    animation: tooltipPulse 2s ease-in-out infinite;
}

/* Responsive Width Adjustments */
@media (max-width: 480px) {
    .tooltip-container {
        max-width: calc(100vw - 20px);
        left: 10px !important;
        right: 10px;
        width: auto !important;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .tooltip-container {
        border: 2px solid white;
    }

    .tooltip-term {
        border-bottom-width: 2px;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .tooltip-container {
        transition: none;
    }

    .tooltip-container.pinned {
        animation: none;
    }
}
