/**
 * My New Glossaire Plugin - Tooltip Styles
 * 
 * SEO-friendly tooltips for glossary terms
 * The tooltip text is always in the HTML (for crawlers)
 * but visually hidden until hover/focus
 *
 * @package MyNewGlossaire
 */

/* ==========================================================================
   Base Tooltip Styles
   ========================================================================== */

/**
 * Main tooltip container (can be <a> or <span>)
 */
.mngp-glossary-tooltip {
    position: relative;
    display: inline;
    cursor: help;
    border-bottom: 1px dotted currentColor;
    text-decoration: none;
    color: inherit;
}

/* When it's a link */
a.mngp-glossary-tooltip {
    color: #2563eb;
    border-bottom-color: #2563eb;
    cursor: pointer;
}

a.mngp-glossary-tooltip:hover {
    color: #1d4ed8;
    border-bottom-style: solid;
}

/**
 * Tooltip text container
 * Always in DOM for SEO, but visually hidden by default
 */
.mngp-tooltip-text {
    /* Positioning */
    position: absolute;
    z-index: 9999;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    
    /* Sizing */
    width: max-content;
    max-width: 300px;
    min-width: 200px;
    padding: 12px 16px;
    
    /* Appearance */
    background-color: #1f2937;
    color: #f9fafb;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    text-align: left;
    border-radius: 8px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2),
                0 8px 10px -6px rgba(0, 0, 0, 0.1);
    
    /* Hidden by default */
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.2s ease-in-out,
                visibility 0.2s ease-in-out;
    
    /* Prevent text selection issues */
    pointer-events: none;
}

/* Arrow/caret pointing down */
.mngp-tooltip-text::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: #1f2937;
}

/**
 * Show tooltip on hover and focus
 */
.mngp-glossary-tooltip:hover .mngp-tooltip-text,
.mngp-glossary-tooltip:focus .mngp-tooltip-text,
.mngp-glossary-tooltip:focus-within .mngp-tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media (max-width: 768px) {
    .mngp-tooltip-text {
        /* On mobile, position at bottom instead */
        bottom: auto;
        top: calc(100% + 8px);
        max-width: 250px;
        min-width: 180px;
        font-size: 13px;
        padding: 10px 12px;
    }
    
    /* Arrow pointing up on mobile */
    .mngp-tooltip-text::after {
        top: auto;
        bottom: 100%;
        border-top-color: transparent;
        border-bottom-color: #1f2937;
    }
}

/* Prevent tooltip from going off-screen on left edge */
.mngp-glossary-tooltip:first-child .mngp-tooltip-text,
.mngp-tooltip-left .mngp-tooltip-text {
    left: 0;
    transform: translateX(0);
}

.mngp-glossary-tooltip:first-child .mngp-tooltip-text::after,
.mngp-tooltip-left .mngp-tooltip-text::after {
    left: 20px;
}

/* Prevent tooltip from going off-screen on right edge */
.mngp-tooltip-right .mngp-tooltip-text {
    left: auto;
    right: 0;
    transform: translateX(0);
}

.mngp-tooltip-right .mngp-tooltip-text::after {
    left: auto;
    right: 20px;
}

/* ==========================================================================
   Pillar Page Styles
   ========================================================================== */

/**
 * Pillar page wrapper
 */
.mngp-pillar-page,
.mngp-global-glossary {
    margin: 2rem 0;
    padding: 0;
    background-color: transparent;
}

/**
 * Pillar page description
 */
.mngp-pillar-description {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background-color: #f8fafc;
    color: #334155;
    border-left: 4px solid #3b82f6;
    border-radius: 0 8px 8px 0;
}

.mngp-pillar-description p {
    color: #334155;
}

.mngp-pillar-description p:last-child {
    margin-bottom: 0;
}

/**
 * Alphabet navigation
 */
.mngp-alphabet-nav {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background-color: #f4f6f9 !important;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
}

.mngp-alphabet-nav ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
    justify-content: center;
}

.mngp-alphabet-nav li {
    margin: 0;
}

.mngp-alphabet-nav a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    font-weight: 700;
    font-size: 14px;
    color: #1f2937;
    background-color: #ffffff;
    border: 2px solid #1f2937;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.15s ease;
}

.mngp-alphabet-nav a:hover {
    background-color: #1f2937;
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.mngp-alphabet-nav .mngp-letter-disabled {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    font-weight: 400;
    font-size: 14px;
    color: #cbd5e1;
    background-color: transparent;
    cursor: not-allowed;
}

/**
 * Letter groups
 */
.mngp-letter-group {
    margin-bottom: 2.5rem;
    scroll-margin-top: 100px; /* For smooth scroll with fixed header */
}

.mngp-letter-heading {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    margin: 0 0 1rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e3a5f;
    background-color: #e0f2fe;
    border-radius: 12px;
}

/**
 * Terms list (definition list)
 */
.mngp-terms-list {
    margin: 0;
    padding: 0;
}

.mngp-term-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.5rem;
    margin-top: 0;
}

.mngp-term-title a,
.mngp-term-title a.mngp-term-link {
    color: #1e3a5f;
    text-decoration: underline;
    text-decoration-color: #f59e0b;
    text-underline-offset: 3px;
    text-decoration-thickness: 2px;
    transition: all 0.15s ease;
}

.mngp-term-title a:hover,
.mngp-term-title a.mngp-term-link:hover {
    color: #0f172a;
    text-decoration-color: #d97706;
}

.mngp-term-definition {
    margin: 0 0 2rem 0;
    padding: 0 0 1.5rem 0;
    color: #475569;
    line-height: 1.7;
    border-bottom: 1px solid #e2e8f0;
}

.mngp-letter-group:last-child .mngp-term-definition:last-child {
    border-bottom: none;
}

.mngp-read-more {
    display: inline-block;
    margin-top: 0.5rem;
    font-size: 0.9em;
    font-weight: 500;
    color: #1e3a5f;
    text-decoration: none;
    white-space: nowrap;
    padding: 0.25rem 0.5rem;
    background-color: #fef3c7;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.mngp-read-more:hover {
    background-color: #fde68a;
    color: #0f172a;
}

/**
 * Multi-column layout
 */
.mngp-columns-2 {
    column-count: 2;
    column-gap: 3rem;
}

.mngp-columns-3 {
    column-count: 3;
    column-gap: 2rem;
}

.mngp-columns-2 .mngp-letter-group,
.mngp-columns-3 .mngp-letter-group {
    break-inside: avoid;
}

@media (max-width: 768px) {
    .mngp-columns-2,
    .mngp-columns-3 {
        column-count: 1;
    }
}

/**
 * Pillar footer
 */
.mngp-pillar-footer {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #e5e7eb;
}

.mngp-terms-count {
    color: #6b7280;
    font-size: 0.9rem;
}

/**
 * Category cards (for index)
 */
.mngp-category-index {
    display: grid;
    gap: 1.5rem;
}

.mngp-category-index.mngp-columns-2 {
    grid-template-columns: repeat(2, 1fr);
    column-count: unset;
}

.mngp-category-index.mngp-columns-3 {
    grid-template-columns: repeat(3, 1fr);
    column-count: unset;
}

@media (max-width: 768px) {
    .mngp-category-index.mngp-columns-2,
    .mngp-category-index.mngp-columns-3 {
        grid-template-columns: 1fr;
    }
}

.mngp-category-card {
    padding: 1.5rem;
    background-color: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.mngp-category-card:hover {
    border-color: #2563eb;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}

.mngp-category-title {
    margin: 0 0 0.5rem;
    font-size: 1.25rem;
}

.mngp-category-title a {
    color: #1f2937;
    text-decoration: none;
}

.mngp-category-title a:hover {
    color: #2563eb;
}

.mngp-category-count {
    font-weight: 400;
    font-size: 0.9em;
    color: #6b7280;
}

.mngp-category-description {
    margin: 0 0 1rem;
    color: #4b5563;
    font-size: 0.95rem;
    line-height: 1.5;
}

.mngp-category-link {
    display: inline-block;
    font-size: 0.9rem;
    color: #2563eb;
    text-decoration: none;
}

.mngp-category-link:hover {
    text-decoration: underline;
}

/**
 * Term categories badge
 */
.mngp-term-categories {
    font-weight: 400;
    font-size: 0.85em;
    color: #6b7280;
    margin-left: 0.5rem;
}

/**
 * Single term display
 */
.mngp-single-term {
    margin: 1.5rem 0;
    padding: 1.5rem;
    background-color: #f8fafc;
    border-radius: 8px;
}

.mngp-single-term .mngp-term-title {
    margin-top: 0;
}

.mngp-single-term .mngp-term-content {
    margin: 0;
}

/**
 * Error message
 */
.mngp-error {
    padding: 1rem;
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    color: #dc2626;
    font-size: 0.9rem;
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

/**
 * Focus styles
 */
.mngp-glossary-tooltip:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
    border-radius: 2px;
}

/**
 * Reduced motion support
 */
@media (prefers-reduced-motion: reduce) {
    .mngp-tooltip-text,
    .mngp-alphabet-nav a,
    .mngp-category-card {
        transition: none;
    }
}

/**
 * High contrast mode support
 */
@media (prefers-contrast: high) {
    .mngp-glossary-tooltip {
        border-bottom-width: 2px;
    }
    
    .mngp-tooltip-text {
        border: 2px solid #fff;
    }
}

/* ==========================================================================
   Print styles
   ========================================================================== */

@media print {
    .mngp-glossary-tooltip {
        border-bottom: none;
    }
    
    .mngp-tooltip-text {
        display: none !important;
    }
    
    a.mngp-glossary-tooltip::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }
    
    .mngp-alphabet-nav {
        display: none;
    }
}

