/**
 * Semantic UX Styles — Glossary Tooltips & Related Articles Cards
 * ================================================================
 * Part of the Phoca Premiere Template Semantic UX Enhancement
 */

/* =========================================================================
   DESIGN TOKENS
   ========================================================================= */

:root {
    /* Glossary */
    --ph-glossary-underline: #667eea;
    --ph-glossary-underline-hover: #764ba2;
    --ph-glossary-bg: rgba(255, 255, 255, 0.92);
    --ph-glossary-border: rgba(102, 126, 234, 0.25);
    --ph-glossary-shadow: 0 20px 60px rgba(0, 0, 0, 0.12), 0 4px 16px rgba(0, 0, 0, 0.08);
    --ph-glossary-text: #1e293b;
    --ph-glossary-term-color: #667eea;
    --ph-glossary-badge-bg: rgba(102, 126, 234, 0.1);
    --ph-glossary-badge-color: #667eea;
    --ph-glossary-body-color: #475569;

    /* Related Articles */
    --ph-related-bg: rgba(255, 255, 255, 0.6);
    --ph-related-card-bg: #ffffff;
    --ph-related-card-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    --ph-related-card-shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.12);
    --ph-related-title-color: #0f172a;
    --ph-related-text-color: #64748b;
    --ph-related-cta-color: #667eea;
    --ph-related-border: rgba(0, 0, 0, 0.06);
    --ph-related-header-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

[data-bs-theme="dark"] {
    --ph-glossary-bg: rgba(30, 41, 59, 0.95);
    --ph-glossary-border: rgba(102, 126, 234, 0.3);
    --ph-glossary-shadow: 0 20px 60px rgba(0, 0, 0, 0.35), 0 4px 16px rgba(0, 0, 0, 0.2);
    --ph-glossary-text: #e2e8f0;
    --ph-glossary-term-color: #818cf8;
    --ph-glossary-badge-bg: rgba(129, 140, 248, 0.15);
    --ph-glossary-badge-color: #a5b4fc;
    --ph-glossary-body-color: #94a3b8;

    --ph-related-bg: rgba(15, 23, 42, 0.6);
    --ph-related-card-bg: #1e293b;
    --ph-related-card-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
    --ph-related-card-shadow-hover: 0 12px 40px rgba(0, 0, 0, 0.3);
    --ph-related-title-color: #f1f5f9;
    --ph-related-text-color: #94a3b8;
    --ph-related-cta-color: #818cf8;
    --ph-related-border: rgba(255, 255, 255, 0.06);
}

/* =========================================================================
   GLOSSARY TERMS (inline in content)
   ========================================================================= */

.ph-glossary {
    position: relative;
    cursor: help;
    text-decoration: none;
    border-bottom: 2px dashed var(--ph-glossary-underline);
    padding-bottom: 1px;
    transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
    border-radius: 2px;
}

.ph-glossary:hover,
.ph-glossary:focus,
.ph-glossary.ph-glossary-active {
    border-bottom-color: var(--ph-glossary-underline-hover);
    background-color: var(--ph-glossary-badge-bg);
    outline: none;
}

.ph-glossary:focus-visible {
    outline: 2px solid var(--ph-glossary-underline);
    outline-offset: 2px;
    border-radius: 3px;
}

/* =========================================================================
   GLOSSARY TOOLTIP
   ========================================================================= */

.ph-glossary-tooltip {
    position: absolute;
    z-index: 99990;
    width: max-content;
    max-width: 380px;
    padding: 0;
    border-radius: 14px;
    background: var(--ph-glossary-bg);
    border: 1px solid var(--ph-glossary-border);
    box-shadow: var(--ph-glossary-shadow);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px) scale(0.96);
    transition: opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1),
        transform 0.25s cubic-bezier(0.4, 0, 0.2, 1),
        visibility 0.25s;
    font-family: inherit;
    line-height: 1.6;
}

.ph-glossary-tooltip.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.ph-glossary-tooltip.below {
    transform: translateY(-8px) scale(0.96);
}

.ph-glossary-tooltip.below.visible {
    transform: translateY(0) scale(1);
}

/* Arrow */
.ph-glossary-tooltip-arrow {
    position: absolute;
    width: 14px;
    height: 14px;
    background: var(--ph-glossary-bg);
    border: 1px solid var(--ph-glossary-border);
    transform: rotate(45deg);
    border-radius: 3px;
}

.ph-glossary-tooltip.above .ph-glossary-tooltip-arrow {
    bottom: -7px;
    border-top: none;
    border-left: none;
}

.ph-glossary-tooltip.below .ph-glossary-tooltip-arrow {
    top: -7px;
    border-bottom: none;
    border-right: none;
}

/* Header */
.ph-glossary-tooltip-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 16px 8px;
    border-bottom: 1px solid var(--ph-glossary-border);
}

.ph-glossary-tooltip-term {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--ph-glossary-term-color);
    letter-spacing: -0.01em;
}

.ph-glossary-tooltip-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    background: var(--ph-glossary-badge-bg);
    color: var(--ph-glossary-badge-color);
    white-space: nowrap;
}

/* Body */
.ph-glossary-tooltip-body {
    padding: 10px 16px 14px;
    font-size: 0.85rem;
    color: var(--ph-glossary-body-color);
    line-height: 1.65;
}

/* =========================================================================
   RELATED ARTICLES SECTION
   ========================================================================= */

.ph-related-articles {
    margin: 3rem 0 2rem;
    padding: 2rem;
    border-radius: 20px;
    background: var(--ph-related-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--ph-related-border);
}

/* Header */
.ph-related-articles-header {
    margin-bottom: 1.5rem;
    text-align: center;
}

.ph-related-articles-title {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--ph-related-title-color);
    letter-spacing: -0.02em;
}

.ph-related-articles-title i {
    background: var(--ph-related-header-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 1.2rem;
}

.ph-related-articles-subtitle {
    margin-top: 0.35rem;
    font-size: 0.875rem;
    color: var(--ph-related-text-color);
    letter-spacing: 0.01em;
}

/* Card Grid */
.ph-related-articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.25rem;
}

@media (max-width: 576px) {
    .ph-related-articles-grid {
        grid-template-columns: 1fr;
    }

    .ph-related-articles {
        padding: 1.25rem;
        border-radius: 14px;
    }
}

/* Individual Card */
.ph-related-card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--ph-related-card-bg);
    border-radius: 14px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--ph-related-card-shadow);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid var(--ph-related-border);
}

.ph-related-card:hover,
.ph-related-card:focus-visible {
    transform: translateY(-4px);
    box-shadow: var(--ph-related-card-shadow-hover);
    text-decoration: none;
    color: inherit;
}

.ph-related-card:focus-visible {
    outline: 2px solid var(--ph-related-cta-color);
    outline-offset: 2px;
}

/* Card Accent Strip */
.ph-related-card-accent {
    height: 4px;
    width: 100%;
    flex-shrink: 0;
}

/* Card Content */
.ph-related-card-content {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

/* Card Icon */
.ph-related-card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    margin-bottom: 0.85rem;
    flex-shrink: 0;
}

.ph-related-card-icon i {
    color: #ffffff;
    font-size: 1rem;
}

/* Card Title */
.ph-related-card-title {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    font-weight: 650;
    color: var(--ph-related-title-color);
    line-height: 1.35;
    letter-spacing: -0.01em;
}

/* Card Excerpt */
.ph-related-card-excerpt {
    margin: 0 0 1rem;
    font-size: 0.825rem;
    color: var(--ph-related-text-color);
    line-height: 1.55;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Card CTA */
.ph-related-card-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ph-related-cta-color);
    margin-top: auto;
    transition: gap 0.2s ease;
}

.ph-related-card:hover .ph-related-card-cta {
    gap: 10px;
}

.ph-related-card-cta i {
    font-size: 0.7rem;
    transition: transform 0.2s ease;
}

.ph-related-card:hover .ph-related-card-cta i {
    transform: translateX(2px);
}

/* =========================================================================
   ANIMATIONS — Fade-in for related articles
   ========================================================================= */

.ph-related-articles {
    opacity: 0;
    transform: translateY(20px);
    animation: phRelatedFadeIn 0.6s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    animation-delay: 0.2s;
}

.ph-related-card {
    opacity: 0;
    transform: translateY(12px);
    animation: phRelatedFadeIn 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.ph-related-card:nth-child(1) {
    animation-delay: 0.3s;
}

.ph-related-card:nth-child(2) {
    animation-delay: 0.4s;
}

.ph-related-card:nth-child(3) {
    animation-delay: 0.5s;
}

.ph-related-card:nth-child(4) {
    animation-delay: 0.6s;
}

.ph-related-card:nth-child(5) {
    animation-delay: 0.7s;
}

.ph-related-card:nth-child(6) {
    animation-delay: 0.8s;
}

@keyframes phRelatedFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================================================================
   PRINT STYLES
   ========================================================================= */

@media print {
    .ph-glossary-tooltip {
        display: none !important;
    }

    .ph-glossary {
        border-bottom: none;
        text-decoration: underline;
    }

    .ph-related-articles {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ccc;
    }

    .ph-related-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* =========================================================================
   REDUCED MOTION
   ========================================================================= */

@media (prefers-reduced-motion: reduce) {
    .ph-glossary-tooltip {
        transition: opacity 0.1s;
        transform: none !important;
    }

    .ph-glossary-tooltip.visible {
        transform: none !important;
    }

    .ph-related-articles,
    .ph-related-card {
        animation: none;
        opacity: 1;
        transform: none;
    }

    .ph-related-card:hover {
        transform: none;
    }
}