/* Cross-browser reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Container for posts */
.posts-container {
    max-width: 32rem;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin: 0 auto;
}

/* Card base styles */
.post-card {
    max-width: 32rem; /* 512px - max-w-lg */
    margin: 0 auto;
    width: 100%;
    background-color: #ffffff;
    border: 1px solid #e5e7eb; /* gray-200 */
    border-radius: 0.75rem; /* 12px - rounded-xl */
    padding: 1rem; /* 16px - p-4 */
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); /* shadow-sm */
    transition: box-shadow 200ms ease-in-out;
}

.post-card:hover {
    box-shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -1px rgba(0, 0, 0, 0.06); /* shadow-md */
}

/* Header styles */
.post-header {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: start;
    -ms-flex-align: start;
    align-items: flex-start;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
    margin-bottom: 0.75rem; /* 12px - mb-3 */
}

.user-info {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    gap: 0.75rem; /* 12px - space-x-3 */
    min-width: 0;
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
}

.avatar-link {
    -ms-flex-negative: 0;
    flex-shrink: 0;
}

.avatar {
    width: 3rem; /* 48px - w-12 */
    height: 3rem; /* 48px - h-12 */
    border-radius: 9999px;
    -o-object-fit: cover;
    object-fit: cover;
    border: 1px solid #e5e7eb;
    display: block;
}

.text-container {
    min-width: 0;
    -webkit-box-flex: 1;
    -ms-flex: 1;
    flex: 1;
    overflow: hidden;
}

.name-wrapper {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    gap: 0.25rem; /* 4px - space-x-1 */
}

.name-link {
    font-weight: 700;
    color: #111827;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.name-link:hover {
    text-decoration: underline;
}

.verified-badge {
    width: 1rem;
    height: 1rem;
    color: #3b82f6;
    -ms-flex-negative: 0;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
}

.handle-link {
    color: #6b7280;
    font-size: 0.875rem;
    text-decoration: none;
}

.handle-link:hover {
    text-decoration: underline;
}

.social-link {
    -ms-flex-negative: 0;
    flex-shrink: 0;

    -webkit-transition: color 200ms ease-in-out;
    -o-transition: color 200ms ease-in-out;
    transition: color 200ms ease-in-out;
}
.facebook {
    color: #60a5fa;
}

.facebook:hover {
    color: #2563eb;
}

.instagram {
    color: #000000;
}
.instagram:hover {
    color: #fd04b6;
}

.social-icon {
    width: 1.25rem;
    height: 1.25rem;
    display: block;
    fill: currentColor;
}

/* Content styles */
.post-content {
    margin-bottom: 0.75rem;
}

.post-text {
    color: #111827;
    font-size: 0.875rem;
    line-height: 1.625;
    white-space: pre-wrap;
    word-wrap: break-word;
    min-height: 0;
}

/* Image attachment styles */
.attachment-wrapper {
    margin-bottom: 0.75rem;
}

/* Single image */
.single-image-container {
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

.single-image {
    width: 100%;
    height: 16rem;
    -o-object-fit: cover;
    object-fit: cover;
    display: block;
}
.single-image:hover,
.grid-image:hover {
    filter: brightness(0.96);
    cursor: pointer;
    border-color: #3b82f6;
}

/* Multiple images grid */
.attachment-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

.grid-image-container {
    border-radius: 0.5rem; /* 8px - rounded-lg */
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

.grid-image {
    width: 100%;
    height: 8rem; /* 128px - h-32 */
    -o-object-fit: cover;
    object-fit: cover;
    display: block;
}

/* Video container */
.video-container {
    border-radius: 0.75rem;
    overflow: hidden;
    border: 1px solid #e5e7eb;
}

.post-video {
    width: 100%;
    height: 16rem; /* 256px - h-64 */
    -o-object-fit: cover;
    object-fit: cover;
    display: block;
    background-color: #f3f4f6;
}

/* Stats section (likes & comments) */
.post-stats {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    gap: 1rem; /* 16px */
    margin-top: 0.75rem; /* 12px */
    padding-top: 0.75rem; /* 12px */
    border-top: 1px solid #e5e7eb; /* gray-200 */
}

.stat-item {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    gap: 0.375rem; /* 6px */
    color: #6b7280; /* gray-500 */
    font-size: 0.875rem; /* 14px */
}

.stat-icon {
    width: 1.25rem; /* 20px */
    height: 1.25rem; /* 20px */
    fill: currentColor;
}

.stat-number {
    font-weight: 500;
}

/* Like button (interactive) */
.like-button {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    gap: 0.375rem;
    background: none;
    border: none;
    /* color: #6b7280; */
    color: #6b7280;
    font-size: 0.875rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    -webkit-transition: all 200ms ease;
    -o-transition: all 200ms ease;
    transition: all 200ms ease;
}

.like-button:hover {
    color: #ef4444; /* red-500 */
    background-color: #fee2e2; /* red-50 */
}

.like-button.liked {
    color: #ef4444;
}

.like-button.liked .stat-icon {
    fill: #ef4444;
}

/* Comment button */
.comment-button {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    gap: 0.375rem;
    background: none;
    border: none;
    color: #6b7280;
    font-size: 0.875rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    -webkit-transition: all 200ms ease;
    -o-transition: all 200ms ease;
    transition: all 200ms ease;
    text-decoration: none;
}

.comment-button:hover {
    color: #3b82f6; /* blue-500 */
    background-color: #dbeafe; /* blue-50 */
}

/* Timestamp */
.timestamp {
    color: #6b7280;
    font-size: 0.75rem;
}

/* Footer with stats and actions */
.post-footer {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
    margin-top: 0.75rem;
}

.action-buttons {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    gap: 0.5rem;
}

/* IE Fallbacks */
.post-card,
.post-header,
.user-info,
.name-wrapper,
.post-stats,
.stat-item,
.post-footer,
.action-buttons {
    zoom: 1;
}

/* Responsive */
@media (min-width: 768px) {
    .attachment-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* When total items are odd, make the last item full width */
    .attachment-grid > *:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }

    .grid-image {
        height: 10rem;
    }
}

/* Load More Container */
.load-more-container {
    margin-top: 2rem; /* mt-8 */
    text-align: center; /* text-center */
}

/* Loading Indicator */
.loading-indicator {
    display: inline-flex; /* inline-flex */
    align-items: center; /* items-center */
    padding: 0.5rem 1rem; /* px-4 py-2 */
    color: #4b5563; /* text-gray-600 */
}

/* Spinner */
.spinner {
    animation: spin 1s linear infinite; /* animate-spin */
    height: 1.25rem; /* h-5 */
    width: 1.25rem; /* w-5 */
    margin-right: 0.75rem; /* mr-3 */
}

.spinner-circle-bg {
    opacity: 0.25; /* opacity-25 */
}

.spinner-path {
    opacity: 0.75; /* opacity-75 */
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Scroll Hint */
.scroll-hint {
    color: #9ca3af; /* text-gray-400 */
}

/* No More Posts Message */
.no-more-posts {
    margin-top: 2rem; /* mt-8 */
    text-align: center; /* text-center */
    color: #6b7280; /* text-gray-500 */
}

[x-cloak] {
    display: none !important;
}
.see-more {
    color: #3b82f6;
    cursor: pointer;
}

.post-text span {
    display: inline;
}

.post-text span[x-cloak] {
    display: none !important;
}

/* Comments Container
        ========================================================================== */
/* .comments-container {
    padding: 1rem;
} */

/* Comments Header
        ========================================================================== */
.comments-header {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: justify;
    -webkit-justify-content: space-between;
    -ms-flex-pack: justify;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

.comments-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.comments-count {
    background-color: #f3f4f6;
    color: #4b5563;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Comment Grid
        ========================================================================== */
.comment-grid {
    display: -ms-grid;
    display: grid;
    -ms-grid-columns: 1fr;
    grid-template-columns: 1fr;
    gap: 1rem;
}

/* Comment Card
        ========================================================================== */
.comment-card {
    background-color: #ffffff;
    border-radius: 0.75rem;
    padding: 1rem;
    -webkit-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #f0f0f0;
    -webkit-transition: all 0.2s ease;
    -o-transition: all 0.2s ease;
    transition: all 0.2s ease;
}

.comment-card:hover {
    -webkit-box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    border-color: #e5e7eb;
}

/* Comment Header (Avatar + Name + Time)
        ========================================================================== */
.comment-header {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    margin-bottom: 0.75rem;
}

.comment-avatar {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 9999px;
    background: -webkit-gradient(
        linear,
        left top,
        right top,
        from(#3b82f6),
        to(#8b5cf6)
    );
    background: -webkit-linear-gradient(left, #3b82f6, #8b5cf6);
    background: -o-linear-gradient(left, #3b82f6, #8b5cf6);
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -webkit-justify-content: center;
    -ms-flex-pack: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 1rem;
    -webkit-flex-shrink: 0;
    -ms-flex-negative: 0;
    flex-shrink: 0;
}

.comment-meta {
    margin-left: 0.75rem;
    -webkit-box-flex: 1;
    -webkit-flex: 1;
    -ms-flex: 1;
    flex: 1;
}

.comment-author {
    font-weight: 600;
    color: #111827;
    font-size: 0.9375rem;
    margin-bottom: 0.125rem;
}

.comment-time {
    font-size: 0.75rem;
    color: #6b7280;
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
}

.comment-time::before {
    content: "•";
    margin-right: 0.375rem;
    color: #9ca3af;
}

/* Comment Content
        ========================================================================== */
.comment-content {
    color: #1f2937;
    font-size: 0.9375rem;
    line-height: 1.5;
    margin-bottom: 0.75rem;
    word-wrap: break-word;
}

/* Comment Footer (Likes)
        ========================================================================== */
.comment-footer {
    display: -webkit-box;
    display: -webkit-flex;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    border-top: 1px solid #f3f4f6;
    padding-top: 0.75rem;
    margin-top: 0.25rem;
}

.comment-likes {
    display: -webkit-inline-box;
    display: -webkit-inline-flex;
    display: -ms-inline-flexbox;
    display: inline-flex;
    -webkit-box-align: center;
    -webkit-align-items: center;
    -ms-flex-align: center;
    align-items: center;
    color: #6b7280;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: default;
}

.comment-likes::before {
    content: "❤️";
    margin-right: 0.375rem;
    font-size: 1rem;
    opacity: 0.8;
}

.comment-likes.active::before {
    content: "❤️";
    opacity: 1;
}

.comment-likes-count {
    margin-left: 0.25rem;
    font-weight: 600;
    color: #4b5563;
}

/* Tablet Breakpoint - 768px
        ========================================================================== */
/* @media screen and (min-width: 768px) {
    .comment-grid {
        -ms-grid-columns: 1fr 1rem 1fr;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .comment-grid > *:last-child:nth-child(odd) {
        -ms-grid-column: 1;
        -ms-grid-column-span: 3;
        grid-column: 1 / -1;
    }

    .comment-grid > *:nth-child(3):last-child {
        -ms-grid-column: 1;
        -ms-grid-column-span: 3;
        grid-column: 1 / -1;
    }
} */

@media screen and (min-width: 768px) {
    .comment-grid {
        -ms-grid-columns: 1fr;
        grid-template-columns: 1fr;
        gap: 1rem;
    }
}

/* Desktop Breakpoint - 1024px
        ========================================================================== */
@media screen and (min-width: 1024px) {
    /* .comments-container {
        padding: 2rem;
    } */

    .comment-card {
        padding: 1.25rem;
    }

    .comment-avatar {
        width: 3rem;
        height: 3rem;
        font-size: 1.125rem;
    }

    .comment-author {
        font-size: 1rem;
    }

    .comment-content {
        font-size: 1rem;
    }
}

/* Print Styles
        ========================================================================== */
@media print {
    .comment-card {
        -webkit-box-shadow: none;
        box-shadow: none;
        border: 1px solid #ddd;
        break-inside: avoid;
    }
}

/* image count badge (totally optional, just for UX) */
.image-count-badge {
    display: inline-block;
    background: #e2e8f0;
    padding: 0.2rem 0.8rem;
    border-radius: 40px;
    font-size: 0.75rem;
    font-weight: 500;
    color: #1e293b;
    margin-left: 0.5rem;
}

/* ------------------ GALLERY OVERLAY ------------------ */
.gallery-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition:
        opacity 0.25s ease,
        visibility 0.25s;
    padding: 1rem;
}

.gallery-overlay.active {
    opacity: 1;
    visibility: visible;
}

.gallery-panel {
    max-width: 1200px;
    width: 100%;
    background: transparent;
    display: flex;
    flex-direction: column;
}

.gallery-image-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 200px;
    max-height: 85vh;
}

.gallery-image-wrapper img {
    max-width: 100%;
    max-height: 85vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    background: #0a0a0a;
}

/* ===== FIXED NAVIGATION BUTTONS ===== */
.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 56px;
    background: rgba(30, 41, 59, 0.9);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%; /* Perfect circle */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0.9;
    line-height: 1;
    padding: 0;
    margin: 0;
    font-size: 32px;
    font-weight: 300;
    z-index: 9999;
}

/* Remove any default button styles that might affect centering */
.gallery-nav::-moz-focus-inner {
    border: 0;
    padding: 0;
}

.gallery-nav:hover:not(.disabled) {
    /* background: #2c2f4d; */
    background: rgba(15, 23, 42, 0.7);
    border-color: rgba(255, 255, 255, 0.4);
    transform: translateY(-50%) scale(1.05);
    opacity: 1;
}

.gallery-nav.disabled {
    opacity: 0.2;
    cursor: default;
    pointer-events: none;
    background: #1e293b;
}

/* Position both buttons with enough space */
.nav-prev {
    left: 20px;
}

.nav-next {
    right: 20px;
}

/* ===== FIXED CLOSE BUTTON ===== */
.gallery-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1.5rem;
    padding: 0.5rem 1.5rem 0.5rem 1.5rem;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    border-radius: 100px; /* Large value ensures pill shape */
    color: #f1f5f9;
    font-size: 1rem;
    font-weight: 500;
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-height: 56px; /* Fixed height for consistency */
}

.gallery-counter {
    letter-spacing: 0.5px;
    padding-left: 4px;
}

/* Perfectly circular close button */
.close-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #f8fafc;
    width: 32px;
    height: 32px;
    font-size: 16px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 300;
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 0;
    margin: 0;
    line-height: 1;
}

/* Hover effect */
.close-btn:hover {
    background: #ef4444;
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

/* Remove any default focus outline and add custom one */
.close-btn:focus-visible {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* ===== FIXED RESPONSIVE BEHAVIOR ===== */
@media (max-width: 768px) {
    .gallery-nav {
        width: 48px;
        height: 48px;
        font-size: 28px;
    }

    /* Ensure both buttons are visible on mobile */
    .nav-prev {
        left: 12px;
    }

    .nav-next {
        right: 12px;
    }

    .close-btn {
        width: 40px;
        height: 40px;
        font-size: 24px;
    }

    .gallery-footer {
        padding: 0.4rem 1.2rem;
        min-height: 52px;
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .gallery-nav {
        width: 42px;
        height: 42px;
        font-size: 24px;
    }

    .nav-prev {
        left: 8px;
    }

    .nav-next {
        right: 8px;
    }

    .close-btn {
        width: 36px;
        height: 36px;
        font-size: 22px;
    }
}

/* Touch-friendly hover states for mobile */
@media (hover: none) and (pointer: coarse) {
    .gallery-nav:hover:not(.disabled) {
        transform: translateY(-50%);
        background: rgba(30, 41, 59, 0.9);
    }

    .close-btn:hover {
        background: rgba(255, 255, 255, 0.1);
        transform: none;
    }
}
