/* Mathematical Keyword Tooltips Styles */

/* Keyword Highlighting */
.math-keyword {
    background: linear-gradient(120deg, #a8e6cf 0%, #88d8c0 100%);
    color: #2c5530;
    padding: 2px 4px;
    border-radius: 3px;
    cursor: help;
    font-weight: 500;
    text-decoration: none;
    display: inline;
    position: relative;
    transition: all 0.3s ease;
    border-bottom: 1px dotted #2c5530;
}

.math-keyword:hover {
    background: linear-gradient(120deg, #88d8c0 0%, #64b5a6 100%);
    color: #1a3d1e;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(44, 85, 48, 0.2);
}

/* Tooltip Container */
.math-tooltip {
    position: fixed;
    z-index: 10000;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    max-width: 320px;
    min-width: 200px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border-top: 3px solid #3498db;
}

.math-tooltip:before {
    content: '';
    position: absolute;
    top: -6px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid #3498db;
}

.math-tooltip[style*="display: block"] {
    opacity: 1;
    transform: translateY(0);
}

/* Tooltip Header */
.tooltip-header {
    padding: 12px 16px 8px;
    border-bottom: 1px solid #f0f0f0;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 7px 7px 0 0;
}

.tooltip-header strong {
    color: #2c3e50;
    font-size: 16px;
    font-weight: 600;
    text-transform: capitalize;
    display: block;
    margin-bottom: 2px;
}

/* Tooltip Content */
.tooltip-content {
    padding: 12px 16px 16px;
    color: #4a5568;
    background: white;
    border-radius: 0 0 7px 7px;
}

.tooltip-content p {
    margin: 0;
    line-height: 1.6;
}

/* Enhanced Keyword Styles for Different Categories */
.math-keyword[data-keyword*="algebra"] {
    background: linear-gradient(120deg, #ffd89b 0%, #ffb65d 100%);
    color: #8b4513;
    border-bottom-color: #8b4513;
}

.math-keyword[data-keyword*="calculus"] {
    background: linear-gradient(120deg, #a8e6cf 0%, #7fcdcd 100%);
    color: #2c5530;
    border-bottom-color: #2c5530;
}

.math-keyword[data-keyword*="geometry"] {
    background: linear-gradient(120deg, #fbc2eb 0%, #a6c1ee 100%);
    color: #4a148c;
    border-bottom-color: #4a148c;
}

.math-keyword[data-keyword*="trigonometry"] {
    background: linear-gradient(120deg, #ffeaa7 0%, #fab1a0 100%);
    color: #b8860b;
    border-bottom-color: #b8860b;
}

.math-keyword[data-keyword*="statistics"] {
    background: linear-gradient(120deg, #d1c4e9 0%, #b39ddb 100%);
    color: #4a148c;
    border-bottom-color: #4a148c;
}

.math-keyword[data-keyword*="probability"] {
    background: linear-gradient(120deg, #ffcdd2 0%, #f8bbd9 100%);
    color: #c2185b;
    border-bottom-color: #c2185b;
}

/* Advanced Terms */
.math-keyword[data-keyword*="matrix"],
.math-keyword[data-keyword*="complex"],
.math-keyword[data-keyword*="logarithm"] {
    background: linear-gradient(120deg, #e1f5fe 0%, #b3e5fc 100%);
    color: #0277bd;
    border-bottom-color: #0277bd;
}

/* Hover Effects for Categories */
.math-keyword[data-keyword*="algebra"]:hover {
    background: linear-gradient(120deg, #ffb65d 0%, #ff8c42 100%);
    color: #5d2d0a;
}

.math-keyword[data-keyword*="calculus"]:hover {
    background: linear-gradient(120deg, #7fcdcd 0%, #5fb3b3 100%);
    color: #1a3d1e;
}

.math-keyword[data-keyword*="geometry"]:hover {
    background: linear-gradient(120deg, #a6c1ee 0%, #8e9aaf 100%);
    color: #2e0854;
}

.math-keyword[data-keyword*="trigonometry"]:hover {
    background: linear-gradient(120deg, #fab1a0 0%, #e17055 100%);
    color: #7d5a00;
}

.math-keyword[data-keyword*="statistics"]:hover {
    background: linear-gradient(120deg, #b39ddb 0%, #9575cd 100%);
    color: #2e0854;
}

/* Tooltip Animations */
@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes tooltipFadeOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-10px) scale(0.95);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .math-tooltip {
        max-width: 280px;
        font-size: 13px;
    }
    
    .tooltip-header {
        padding: 10px 12px 6px;
    }
    
    .tooltip-header strong {
        font-size: 14px;
    }
    
    .tooltip-content {
        padding: 10px 12px 12px;
    }
    
    .math-keyword {
        padding: 1px 3px;
        font-size: 0.95em;
    }
}

@media (max-width: 480px) {
    .math-tooltip {
        max-width: 250px;
        font-size: 12px;
        left: 10px !important;
        right: 10px !important;
        width: calc(100vw - 20px);
        max-width: none;
    }
    
    .tooltip-header {
        padding: 8px 10px 4px;
    }
    
    .tooltip-content {
        padding: 8px 10px 10px;
    }
    
    .math-keyword {
        padding: 1px 2px;
        border-radius: 2px;
    }
}

/* Print Styles */
@media print {
    .math-tooltip {
        display: none !important;
    }
    
    .math-keyword {
        background: none !important;
        color: inherit !important;
        border-bottom: none !important;
        font-weight: bold;
    }
    
    .math-keyword::after {
        content: " (see glossary)";
        font-size: 0.8em;
        color: #666;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .math-keyword {
        background: #ffff00 !important;
        color: #000000 !important;
        border: 1px solid #000000 !important;
    }
    
    .math-tooltip {
        background: #ffffff !important;
        border: 2px solid #000000 !important;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5) !important;
    }
    
    .tooltip-header {
        background: #f0f0f0 !important;
        border-bottom: 1px solid #000000 !important;
    }
    
    .tooltip-content {
        color: #000000 !important;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .math-keyword {
        transition: none;
    }
    
    .math-tooltip {
        transition: none;
        animation: none;
    }
    
    .math-keyword:hover {
        transform: none;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .math-tooltip {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .tooltip-header {
        background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
        border-bottom-color: #4a5568;
    }
    
    .tooltip-header strong {
        color: #e2e8f0;
    }
    
    .tooltip-content {
        background: #2d3748;
        color: #cbd5e0;
    }
    
    .math-keyword {
        background: linear-gradient(120deg, #2d5a3d 0%, #1a3d2e 100%);
        color: #9ae6b4;
        border-bottom-color: #9ae6b4;
    }
    
    .math-keyword:hover {
        background: linear-gradient(120deg, #1a3d2e 0%, #0f2419 100%);
        color: #c6f6d5;
    }
}

/* Focus Styles for Accessibility */
.math-keyword:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* Loading State */
.math-keyword.loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Tooltip Arrow Positioning */
.math-tooltip.tooltip-top:before {
    top: -6px;
    left: 20px;
    border-bottom: 6px solid #3498db;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
}

.math-tooltip.tooltip-bottom:before {
    bottom: -6px;
    left: 20px;
    border-top: 6px solid #3498db;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
}

.math-tooltip.tooltip-left:before {
    top: 15px;
    left: -6px;
    border-right: 6px solid #3498db;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
}

.math-tooltip.tooltip-right:before {
    top: 15px;
    right: -6px;
    border-left: 6px solid #3498db;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
}