/**
 * WPE Block Footnote - Frontend Styles
 * Popover footnote styling for visitors
 * Supports rich content (bold, italic, links, images)
 */

/* ==========================================================================
   BASE FOOTNOTE STYLING
   ========================================================================== */

.wpe-footnote {
    position: relative;
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dotted currentColor;
    cursor: help;
    transition: all 0.2s ease;
}

.wpe-footnote:hover {
    border-bottom-style: solid;
    color: #4f46e5;
}

/* Comment icon removed as per request - only border dot indicator remains */

/* ==========================================================================
   FOOTNOTE POPOVER (JavaScript-rendered)
   ========================================================================== */

.wpe-footnote-popover-box {
    position: absolute;
    z-index: 100000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.wpe-footnote-popover-box.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

/* Popover content container */
.wpe-footnote-popover-content {
    background: var(--wpe-fn-bg, #1f2937);
    color: var(--wpe-fn-text, #f9fafb);
    padding: var(--wpe-fn-padding, 14px);
    border-radius: var(--wpe-fn-radius, 12px);
    font-size: var(--wpe-fn-size, 14px);
    line-height: 1.6;
    max-width: var(--wpe-fn-width, 380px);
    width: max-content;
    min-width: 150px;
    box-shadow: var(--wpe-fn-shadow, 0 10px 15px -3px rgba(0, 0, 0, 0.1));
}

/* Arrow */
.wpe-footnote-popover-arrow {
    position: absolute;
    width: 0;
    height: 0;
    border: 8px solid transparent;
}

/* Arrow for top position (popover above) */
.wpe-footnote-popover-box.position-top .wpe-footnote-popover-arrow {
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-top-color: var(--wpe-fn-bg, #1f2937);
    border-bottom: none;
}

/* Arrow for bottom position (popover below) */
.wpe-footnote-popover-box.position-bottom .wpe-footnote-popover-arrow {
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-bottom-color: var(--wpe-fn-bg, #1f2937);
    border-top: none;
}

/* ==========================================================================
   RICH CONTENT STYLING INSIDE POPOVER
   ========================================================================== */

.wpe-footnote-popover-content strong,
.wpe-footnote-popover-content b {
    font-weight: 600;
    color: inherit;
}

.wpe-footnote-popover-content em,
.wpe-footnote-popover-content i {
    font-style: italic;
}

.wpe-footnote-popover-content a {
    color: var(--wpe-fn-link, #93c5fd);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: all 0.2s;
}

.wpe-footnote-popover-content a:hover {
    filter: brightness(1.1);
    opacity: 0.9;
}

.wpe-footnote-popover-content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 10px 0;
    display: block;
}

.wpe-footnote-popover-content p {
    margin: 0 0 8px 0;
}

.wpe-footnote-popover-content p:last-child {
    margin-bottom: 0;
}

/* ==========================================================================
   ACCESSIBILITY
   ========================================================================== */

.wpe-footnote:focus {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
    border-radius: 2px;
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
    .wpe-footnote {
        border-bottom: none;
    }

    .wpe-footnote::after {
        display: none !important;
    }

    .wpe-footnote-popover-box {
        display: none !important;
    }

    /* Show footnote as inline text when printing */
    .wpe-footnote[data-footnote]::before {
        content: ' [Footnote: ' attr(data-footnote) ']';
        font-style: italic;
        font-size: 0.9em;
    }
}

/* ==========================================================================
   REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .wpe-footnote-popover-box {
        transition: opacity 0.15s ease;
    }
}

/* ==========================================================================
   MOBILE/TOUCH
   ========================================================================== */

@media (max-width: 768px) {
    .wpe-footnote-popover-content {
        max-width: calc(100vw - 40px);
        font-size: 13px;
    }
}
