/* ==========================================================================
   Link hover preview (external post links)
   Subtle Google/Streak-style card with an arrow pointer that aims at the
   hovered link. Positioned by JS (position: fixed, viewport-clamped).
   ========================================================================== */

.ht-link-preview {
    position: fixed;
    z-index: 100000;
    left: 0;
    top: 0;
    width: 340px;
    max-width: calc(100vw - 24px);
    box-sizing: border-box;
    display: flex;
    gap: 12px;
    padding: 12px;
    border-radius: 10px;
    background: #ffffff;
    color: #1a1a1a;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
    font-size: 13px;
    line-height: 1.4;
    text-align: left;
    direction: ltr;
    pointer-events: none;     /* never intercept the mouse */
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.16s ease, transform 0.16s ease;
    overflow: visible;
}

.ht-link-preview.ht-lp-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Thumbnail (og:image). Hidden by JS when there is no image or it fails. */
.ht-link-preview .ht-lp-thumb {
    flex: 0 0 88px;
    width: 88px;
    height: 88px;
    border-radius: 6px;
    object-fit: cover;
    background: #f0f0f0;
    display: block;
}

.ht-link-preview .ht-lp-body {
    min-width: 0;              /* allow text truncation inside flex */
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ht-link-preview .ht-lp-title {
    font-weight: 600;
    font-size: 14px;
    color: #111;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ht-link-preview .ht-lp-desc {
    color: #555;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ht-link-preview .ht-lp-site {
    margin-top: 2px;
    font-size: 12px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Arrow pointer (triangle) --- */
.ht-link-preview .ht-lp-arrow {
    position: absolute;
    width: 12px;
    height: 12px;
    background: inherit;
    border: inherit;
    transform: rotate(45deg);
    box-shadow: none;
}

/* Card below the link -> arrow on top edge, pointing up. */
.ht-link-preview.ht-lp-below .ht-lp-arrow {
    top: -7px;
    border-right: 0;
    border-bottom: 0;
}

/* Card above the link -> arrow on bottom edge, pointing down. */
.ht-link-preview.ht-lp-above .ht-lp-arrow {
    bottom: -7px;
    border-left: 0;
    border-top: 0;
}

/* ==========================================================================
   Dark mode — matches the forum's html.dark + prefers-color-scheme scheme.
   ========================================================================== */
@media (prefers-color-scheme: dark) {
    html.dark .ht-link-preview {
        background: var(--main-dark-color, #383838);
        color: #e8e8e8;
        border-color: rgba(255, 255, 255, 0.12);
        box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
    }

    html.dark .ht-link-preview .ht-lp-thumb {
        background: var(--real-dark, rgb(20, 20, 20));
    }

    html.dark .ht-link-preview .ht-lp-title {
        color: #f5f5f5;
    }

    html.dark .ht-link-preview .ht-lp-desc {
        color: #bdbdbd;
    }

    html.dark .ht-link-preview .ht-lp-site {
        color: var(--main-bright, #5accee);
    }
}

/* html.light forces light even when the OS prefers dark. Default rules above
   already cover the light appearance, so nothing extra is needed here. */

@media (prefers-reduced-motion: reduce) {
    .ht-link-preview {
        transition: opacity 0.01s linear;
        transform: none;
    }
    .ht-link-preview.ht-lp-visible {
        transform: none;
    }
}
