/**
 * Web Preview Component
 * Opt-in rich link card for external web resources referenced from events
 * (e.g. NIP-22 comment `I`/`i` tags with NIP-73 kind "web").
 *
 * Renders as a placeholder with a "Load preview" CTA; a Stimulus
 * controller swaps in the rich card after the user approves the fetch.
 */

.web-preview {
    display: block;
    padding: var(--spacing-3);
    margin: var(--spacing-2) 0;
    border: 1px solid var(--color-border, #ccc);
    background: var(--color-bg-light, #fafafa);
    color: inherit;
    text-decoration: none;
    transition: background-color 0.15s ease;
}

.web-preview--placeholder .web-preview__body {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-1);
}

.web-preview__link {
    display: flex;
    gap: var(--spacing-3);
    color: inherit;
    text-decoration: none;
}

.web-preview__link:hover,
.web-preview__link:focus-visible {
    text-decoration: none;
}

.web-preview--rich:hover,
.web-preview--rich:focus-within {
    background: var(--color-bg-hover, #f0f0f0);
}

.web-preview__image {
    flex: 0 0 128px;
    min-height: 96px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-color: var(--color-bg, #eee);
}

.web-preview__body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-1);
}

.web-preview__host {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--color-text-muted, #666);
}

.web-preview__title {
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.3;
    color: var(--color-text, inherit);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.web-preview__description {
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--color-text-muted, #555);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
}

.web-preview__url {
    font-size: 0.75rem;
    color: var(--color-text-muted, #888);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.web-preview__url a {
    color: inherit;
}

.web-preview__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--spacing-2);
    margin-top: var(--spacing-1);
}

.web-preview__notice {
    color: var(--color-text-muted, #888);
    font-size: 0.75rem;
}

.web-preview__status:empty {
    display: none;
}

.web-preview__status {
    font-size: 0.8rem;
    color: var(--color-text-muted, #666);
    margin-top: var(--spacing-1);
}

@media (max-width: 600px) {
    .web-preview__link {
        flex-direction: column;
    }
    .web-preview__image {
        flex: 0 0 160px;
        width: 100%;
    }
}
