/* Gallery page styles (extracted from pages/gallery.html). */
/* Image Reveal Animation Support (Moved from main.css) */
.ag-img-reveal {
    opacity: 0;
    transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.ag-img-reveal.loaded {
    opacity: 1;
}

/* Pinterest-like Masonry Grid */
/* Match the home page's Gallery section exactly. On desktop the global
   .container adds padding-right: 10rem, pushing content left of the logo; we
   cancel it and nudge the column right by 4rem — the same treatment the home
   sections (.gallery-intro { left: 4rem }) and the notifications page use. */
.gallery-container {
    position: relative;
    padding: 40px 16px;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    box-sizing: border-box;
    font-family: Inter, system-ui, -apple-system, sans-serif;
}

@media (min-width: 1024px) {
    .container:has(#gallery-page) {
        padding-right: 0 !important;
    }

    .gallery-container {
        left: 4rem;
    }
}

.section-header-line {
    margin-bottom: 2rem;
}

.masonry-grid {
    display: flex;
    gap: 16px;
    width: 100%;
    align-items: flex-start;
}

@media (max-width: 768px) {
    .masonry-grid {
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .masonry-grid {
        gap: 8px;
    }
}

.masonry-item {
    width: 100%;
}


/* Pin Card Styling */
.pin-card {
    position: relative;
    border-radius: 16px;
    overflow: hidden;
    cursor: zoom-in;
    transition: transform 0.2s ease-in-out;
    background: var(--surface-raised);
}

.pin-card:hover {
    transform: scale(1.02);
}

.pin-card img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 16px;
    transition: filter 0.3s ease;
}

.pin-card:hover img {
    filter: brightness(0.8);
}


/* ── GALLERY DETAIL VIEW (SPA) ── */
#gallery-detail-view {
    display: none;
    padding: 5px 16px;
    width: 100%;
    flex-direction: column;
    align-items: center;
    background: var(--surface-page);
    font-family: 'Segoe UI', Helvetica, Arial, sans-serif;
}
/* ══════════════════════════════════════════════════════════
   INSTAGRAM-STYLE SPLIT-PANEL POPUP MODAL
   ══════════════════════════════════════════════════════════ */

/* ── Backdrop overlay ── */
.ig-comment-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.ig-comment-overlay.open {
    display: flex;
    animation: igBackdropIn 0.25s ease;
}
@keyframes igBackdropIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Modal container: image left + panel right ── */
.ig-modal {
    display: flex;
    width: min(92vw, 1150px);
    height: min(92vh, 800px);
    background: var(--surface-raised, #1a1a1a);
    border-radius: 4px;
    overflow: hidden;
    animation: igSlideIn 0.28s cubic-bezier(0.34, 1.12, 0.64, 1);
    position: relative;
    box-shadow: 0 24px 60px rgba(0,0,0,0.7);
}
@keyframes igSlideIn {
    from { opacity: 0; transform: scale(0.94) translateY(8px); }
    to   { opacity: 1; transform: scale(1)   translateY(0);    }
}

/* ── Close × button (outside modal, top-right) ── */
.ig-modal-close {
    position: fixed;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    z-index: 10001;
    line-height: 1;
    opacity: 0.9;
    transition: opacity 0.2s;
    padding: 4px;
}
.ig-modal-close:hover { opacity: 1; }

/* ── Left panel: image ── */
.ig-modal-image {
    flex: 1;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    min-width: 0;
}
.ig-modal-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* ── Right panel: comments ── */
.ig-modal-panel {
    width: 400px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--surface-raised, #1a1a1a);
    border-left: 1px solid rgba(255,255,255,0.1);
    overflow: hidden;
}

/* ── Author header row ── */
.ig-modal-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 13px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}
.ig-modal-header-title {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
    text-align: center;
    word-break: break-word;
    line-height: 1.4;
    letter-spacing: 0.1px;
}

/* ── Scrollable comment list ── */
.ig-modal-comment-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 0;
}
#ig-popup-comments-list {
    flex: 1;
    display: flex;
    flex-direction: column;
}
.ig-modal-comment-scroll::-webkit-scrollbar { width: 4px; }
.ig-modal-comment-scroll::-webkit-scrollbar-track { background: transparent; }
.ig-modal-comment-scroll::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.12);
    border-radius: 4px;
}
.ig-modal-comment-scroll:hover::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.25);
}


/* Individual comment rows */
.ig-modal-comment-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
}
.ig-modal-comment-row img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.ig-modal-comment-body {
    flex: 1;
    font-size: 13.5px;
    color: var(--text-primary);
    line-height: 1.45;
    word-break: break-word;
}
.ig-modal-comment-body strong {
    font-weight: 700;
    margin-right: 4px;
}
.ig-modal-comment-meta {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
}
.ig-modal-comment-meta span { cursor: pointer; }
.ig-modal-comment-meta span:hover { color: var(--text-primary); }
.ig-modal-comment-heart {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    transition: all 0.2s;
}
.ig-modal-comment-heart.liked { color: #ef4444; }
.ig-modal-comment-heart:hover { opacity: 0.75; }

/* Empty state */
.ig-modal-no-comments {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
    padding: 24px;
    gap: 4px;
}

/* ── Action bar (like / comment / share / bookmark) ── */
.ig-modal-actions {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 10px 12px 6px 12px;
    flex-shrink: 0;
}
.ig-modal-actions-row {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100% !important;
}
.ig-modal-actions-left {
    display: flex;
    gap: 14px;
    align-items: center;
}
.ig-modal-icon-btn {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    transition: all 0.2s;
}
.ig-modal-icon-btn:hover { opacity: 0.65; }
.ig-modal-icon-btn.liked { color: #ef4444; }
.ig-modal-icon-btn.liked:hover { transform: scale(1.12); opacity: 0.85; }
.ig-modal-actions-right {
    display: flex;
    align-items: center;
}
.ig-modal-action-group {
    display: flex;
    align-items: center;
    gap: 6px;
}
.ig-modal-count {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
}
.ig-modal-date-line {
    font-size: 12px;
    color: var(--text-secondary);
    letter-spacing: 0.2px;
    margin-top: 6px;
    margin-left: 4px;
    margin-bottom: 4px;
}

/* ── Input row ── */
.ig-modal-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px 12px;
    border-top: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}
.ig-modal-input-row img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.ig-modal-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    resize: none;
    max-height: 80px;
    line-height: 1.4;
    font-family: inherit;
}
.ig-modal-input::placeholder { color: var(--text-secondary); }
.ig-modal-post-btn {
    background: none;
    border: none;
    color: #3897f0;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    padding: 0 2px;
}
.ig-modal-post-btn:disabled { opacity: 0.35; cursor: default; }

/* Reply indicator inside modal */
.ig-modal-reply-indicator {
    display: none;
    padding: 4px 14px;
    font-size: 11px;
    background: rgba(128,128,128,0.07);
    color: var(--text-secondary);
    border-top: 1px solid rgba(128,128,128,0.1);
    flex-shrink: 0;
}

/* More menu */
.ig-comment-more-container { position: relative; }
.ig-comment-more-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: var(--surface-raised);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    min-width: 130px;
    z-index: 100;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    overflow: hidden;
}
.ig-comment-more-menu.open { display: block; }
.ig-comment-more-item {
    padding: 10px 14px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-primary);
}
.ig-comment-more-item:hover { background: rgba(255,255,255,0.07); }
.ig-comment-more-item.delete { color: #ef4444; }

/* ── Mobile: stack vertically ── */
@media (max-width: 470px) {
    .ig-modal {
        flex-direction: column;
        width: 100vw;
        max-width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
    }
    .ig-modal-image {
        height: 42vh;
        flex: none;
    }
    .ig-modal-panel {
        width: 100%;
        flex: 1;
        border-left: none;
        border-top: 1px solid rgba(255,255,255,0.1);
    }
    .ig-modal-close {
        top: 4px !important;
        right: 8px !important;
        font-size: 26px !important;
        padding: 8px !important;
        text-shadow: 0 1px 8px rgba(0, 0, 0, 0.8) !important;
        z-index: 10002 !important;
    }
}
