/**
 * UI تعاملات — سبک اینستاگرام
 * Rollback: docs/IG_INTERACTIONS_ROLLBACK.md
 */

:root {
    --ig-like-color: #ed4956;
}

[x-cloak] { display: none !important; }

.ig-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ——— پست ——— */

.ig-post {
    padding-bottom: 0.5rem;
}

.ig-post-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.5rem 0 1rem;
}

.ig-back-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    font-size: 1.25rem;
    color: var(--color-text);
    text-decoration: none;
    flex-shrink: 0;
}

.ig-post-meta { min-width: 0; flex: 1; }

.ig-post-title {
    font-size: 0.9375rem;
    font-weight: 700;
    line-height: 1.4;
    margin: 0;
}

.ig-post-date {
    font-size: 0.75rem;
    color: var(--color-muted);
}

.ig-post-media {
    position: relative;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 0.5rem;
    user-select: none;
    -webkit-user-select: none;
}

.ig-media-full-link {
    text-align: center;
    margin: 0 0 0.5rem;
    font-size: 0.8125rem;
}

.ig-media-full-link a {
    color: var(--color-muted);
    text-decoration: none;
}

.ig-media-full-link a:hover { color: var(--color-primary); }

.ig-post-media-link { display: block; line-height: 0; }

.ig-post-media-img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 70vh;
    object-fit: contain;
    margin: 0 auto;
    background: #111;
}

.ig-heart-burst {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    transform: scale(0);
}

.ig-heart-burst svg {
    width: 5rem;
    height: 5rem;
    color: var(--ig-like-color);
    fill: var(--ig-like-color);
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.35));
}

.ig-heart-burst-show {
    animation: ig-heart-pop 0.75s ease forwards;
}

@keyframes ig-heart-pop {
    0% { opacity: 0; transform: scale(0); }
    15% { opacity: 1; transform: scale(1.15); }
    30% { transform: scale(0.95); }
    45% { transform: scale(1.05); opacity: 1; }
    80% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(1); }
}

.ig-post-caption {
    padding: 0.25rem 0 0.75rem;
    font-size: 0.9375rem;
    line-height: 1.6;
}

.ig-caption-text { margin: 0; }

.ig-post-gallery {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.25rem;
    margin-bottom: 0.75rem;
    border-radius: var(--radius);
    overflow: hidden;
}

.ig-post-gallery-item {
    position: relative;
    display: block;
    overflow: hidden;
}

.ig-post-gallery-item img,
.ig-gallery-tap-img {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
}

.ig-gallery-tap-wrap {
    position: relative;
    display: block;
    line-height: 0;
}

.ig-gallery-tap-wrap .ig-heart-burst svg {
    width: 3rem;
    height: 3rem;
}

.ig-post-footer {
    padding: 0.25rem 0 0.5rem;
}

/* ——— اکشن‌ها ——— */

.ig-action-buttons {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.375rem 0;
}

.ig-like-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--color-text);
    line-height: 0;
    transition: transform 0.15s;
}

.ig-like-btn:active,
.ig-comment-btn:active { transform: scale(1.15); }

.ig-like-btn svg,
.ig-comment-btn svg { transition: color 0.15s, fill 0.15s; }

.ig-like-btn-active svg {
    color: var(--ig-like-color);
    fill: var(--ig-like-color);
}

.ig-comment-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--color-text);
    line-height: 0;
    transition: transform 0.15s;
}

.ig-like-btn.htmx-request,
.ig-bar-send.htmx-request {
    opacity: 0.55;
    pointer-events: none;
}

.ig-like-count,
.ig-comment-count {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0 0 0.625rem;
    line-height: 1.4;
}

/* ——— کامنت‌ها ——— */

.ig-comments { padding-bottom: 0.5rem; }

.ig-comment-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ig-comment {
    margin-bottom: 0.625rem;
    font-size: 0.875rem;
    line-height: 1.5;
}

.ig-comment-author {
    font-weight: 700;
    margin: 0 0 0.125rem;
    font-size: 0.8125rem;
}

.ig-comment-text {
    font-weight: 400;
    margin: 0 0 0.25rem;
    word-break: break-word;
}

.ig-comment-time {
    font-size: 0.6875rem;
    color: var(--color-muted);
}

.ig-comment-reply {
    margin: 0.5rem 0 0 1rem;
    padding-right: 0.75rem;
    border-right: 2px solid var(--color-primary);
}

.ig-comment-reply .ig-comment-line {
    margin: 0 0 0.125rem;
    font-size: 0.875rem;
    line-height: 1.5;
}

.ig-comment-reply-to {
    color: var(--color-muted);
    font-weight: 500;
    margin-left: 0.25rem;
    margin-right: 0.25rem;
}

.ig-owner-reply-form {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.625rem;
    align-items: center;
}

.ig-owner-reply-input {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    padding: 0.4375rem 0.75rem;
    font-size: 0.8125rem;
    font-family: inherit;
    background: var(--color-bg);
}

.ig-owner-reply-send {
    border: none;
    background: none;
    color: var(--color-primary);
    font-weight: 700;
    font-size: 0.8125rem;
    font-family: inherit;
    cursor: pointer;
    flex-shrink: 0;
}

.comment-reply-item {
    margin: 0.75rem 0 0 1rem;
    padding: 0.75rem;
    background: color-mix(in srgb, var(--color-primary) 6%, var(--color-surface));
    border-radius: var(--radius);
    border-right: 3px solid var(--color-primary);
}

.comment-reply-badge {
    font-size: 0.6875rem;
    color: var(--color-primary);
    font-weight: 600;
}

.comment-reply-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
    align-items: center;
}

.comment-reply-input {
    flex: 1;
    min-width: 12rem;
}

.ig-view-all,
.ig-no-comments {
    font-size: 0.8125rem;
    color: var(--color-muted);
    background: none;
    border: none;
    padding: 0.25rem 0 0.5rem;
    cursor: pointer;
    font-family: inherit;
}

.ig-view-all:hover { color: var(--color-text); }

.ig-no-comments { margin: 0; padding: 0.5rem 0; }

/* ——— فرم کامنت (inline) ——— */

.ig-comment-form {
    margin: 0.75rem 0 1rem;
    padding: 0.875rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 2px 12px rgba(61, 61, 61, 0.06);
}

.ig-comment-form-label {
    margin: 0 0 0.625rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-muted);
}

.ig-comment-field-row {
    display: grid;
    gap: 0.5rem;
    align-items: center;
    grid-template-columns: 1fr auto;
}

.ig-comment-field-row-compact {
    grid-template-columns: 1fr auto;
}

.ig-comment-field-row:has(.ig-bar-name) .ig-bar-name {
    grid-column: 1 / -1;
}

.ig-comment-field {
    border: 1px solid var(--color-border);
    border-radius: 1.25rem;
    padding: 0.5625rem 0.875rem;
    font-size: 0.875rem;
    font-family: inherit;
    background: var(--color-bg);
    line-height: 1.5;
    min-height: 2.625rem;
    box-sizing: border-box;
}

.ig-bar-name {
    width: 100%;
}

.ig-bar-input {
    resize: none;
    max-height: 7.5rem;
    overflow-y: auto;
    min-width: 0;
}

.ig-comment-field:focus {
    outline: none;
    border-color: var(--color-primary);
}

.ig-bar-send {
    border: none;
    color: var(--color-primary);
    font-weight: 700;
    font-size: 0.875rem;
    font-family: inherit;
    cursor: pointer;
    padding: 0.5625rem 0.875rem;
    min-height: 2.625rem;
    border-radius: 1.25rem;
    background: color-mix(in srgb, var(--color-primary) 15%, white);
    transition: opacity 0.15s, background 0.15s;
    white-space: nowrap;
    align-self: center;
}

.ig-bar-send:not(:disabled):hover {
    background: color-mix(in srgb, var(--color-primary) 28%, white);
}

.ig-bar-send:disabled {
    opacity: 0.35;
    cursor: default;
}

@media (min-width: 640px) {
    .ig-comment-field-row:has(.ig-bar-name) {
        grid-template-columns: 6.75rem 1fr auto;
    }

    .ig-comment-field-row:has(.ig-bar-name) .ig-bar-name {
        grid-column: auto;
    }
}

/* ——— گالری ——— */

.ig-gallery-card { position: relative; }

.ig-gallery-like-badge {
    position: absolute;
    bottom: 0.5rem;
    left: 0.5rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    z-index: 2;
}

.ig-gallery-like-badge svg {
    color: #fff;
    fill: #fff;
    width: 0.875rem;
    height: 0.875rem;
}

.ig-post-footer .ig-comments {
    padding-top: 0.25rem;
    margin-bottom: 0.25rem;
}
