/* Posts Modal - Styled to match site */

/* Modal Base */
.posts-gallery-modal .tingle-modal-box {
    width: 90%;
    max-width: 500px;
    height: 80vh;
    max-height: 700px;
    border-radius: 1.5rem; /* var(--radius) */
    overflow: hidden;
    background: linear-gradient(to right bottom, #121212, #191621, #23192f, #2f1a3c, #3e1947);
    box-shadow: 0 24px 60px rgba(0,0,0,0.8), 0 0 20px rgba(255, 0, 147, 0.2);
    border: 1px solid rgba(255, 0, 147, 0.3);
}

.posts-gallery-modal .tingle-modal-box__content {
    padding: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: transparent;
}

/* Modal Header */
.posts-modal-header {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    backdrop-filter: blur(10px);
    padding: 1.25rem;
    border-bottom: 1px solid rgba(255, 0, 147, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.posts-modal-title {
    font-size: 1.2rem;
    font-weight: 500;
    margin: 0;
    color: white;
    font-family: "Kanit", sans-serif;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.posts-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    color: white;
    transition: 0.3s ease-in-out;
    border-radius: 50%;
}

.posts-modal-close:hover {
    background: rgba(255, 0, 147, 0.2);
    color: #FF0093;
    box-shadow: 0 0 10px rgba(255, 0, 147, 0.4);
}

/* View Toggle */
.posts-modal-view-toggle {
    display: flex;
    gap: 0.75rem;
}

.posts-modal-view-toggle i{
    display: block;
}

.view-toggle-btn {
    padding: 0.65rem 1.25rem;
    border: 2px solid rgba(255, 0, 147, 0.3);
    background: transparent;
    cursor: pointer;
    border-radius: 1.5rem;
    color: white;
    font-family: "Kanit", sans-serif;
    font-weight: 400;
    font-size: 0.9rem;
    transition: 0.3s ease-in-out;
    backdrop-filter: blur(5px);
}

.view-toggle-btn:hover {
    border-color: #FF0093;
    box-shadow: 0 0 10px rgba(255, 0, 147, 0.3);
    transform: translateY(-1px);
}

.view-toggle-btn.active {
    background: linear-gradient(135deg, #FF0093, #ff38ab);
    color: white;
    border-color: transparent;
    box-shadow: 0 0 15px rgba(255, 0, 147, 0.4);
}

/* Modal Content */
.posts-modal-content {
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Feed View - Show One Post */
.posts-feed-view {
    display: none;
    width: 100%;
    height: 100%;
}

.posts-feed-view.active {
    display: block;
}

.posts-feed-container {
    width: 100%;
    height: 100%;
    overflow-y: auto;               /* enable two-finger scroll */
    overflow-x: hidden;
    scroll-snap-type: y mandatory;  /* snap to each post vertically */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.post-feed-item {
    width: 100%;
    height: 100%;
    min-height: 100%;
    position: relative;
    display: block;
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

.post-feed-media-container {
    width: 100%;
    height: 100%;
    position: relative;
}

.post-feed-media {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
    display: block;
}

/* Post Content Overlay - Bottom Left Stack */
.post-feed-content {
    position: absolute;
    bottom: 16px; /* lift slightly so it doesn't hug the edge */
    left: 16px;  /* add breathing room from the corner */
    z-index: 10;
    color: white;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.post-feed-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.post-feed-name {
    font-weight: 600;
    font-size: 1.1rem;
    margin: 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    font-family: "Kanit", sans-serif;
    color: white;
}

.post-feed-date {
    font-size: 0.85rem;
    opacity: 0.9;
    margin: 0;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
    font-family: "Kanit", sans-serif;
    font-weight: 300;
    color: #ccc;
}

.post-feed-caption {
    font-size: 0.95rem;
    line-height: 1.3;
    margin: 0;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.8);
    font-family: "Kanit", sans-serif;
    font-weight: 300;
    max-width: 280px;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* show 2 lines then ellipsis */
    -webkit-box-orient: vertical;
    overflow: hidden;
    cursor: pointer;
}

/* Carousel Support */
.post-feed-carousel {
    width: 100%;
    height: 100%;
}

.post-feed-carousel .splide__track {
    height: 100%;
}

.post-feed-carousel .splide__list {
    height: 100%;
}

.post-feed-carousel .splide__slide {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.post-feed-carousel .splide__slide img,
.post-feed-carousel .splide__slide video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}

/* Carousel Navigation - Site Theme */
.post-feed-carousel .splide__arrow {
    background: rgba(0, 0, 0, 0.7) !important;
    border: 2px solid rgba(255, 0, 147, 0.5);
    border-radius: 50%;
    width: 3rem;
    height: 3rem;
    transition: none !important;
    transform: none !important;
    animation: none !important;
    box-shadow: none !important;
    backdrop-filter: blur(5px);
}

.post-feed-carousel .splide__arrow:hover,
.post-feed-carousel .splide__arrow:focus,
.post-feed-carousel .splide__arrow:active {
    background: rgba(255, 0, 147, 0.8) !important;
    border-color: #FF0093;
    box-shadow: none !important;
    transform: none !important;
    animation: none !important;
}

.post-feed-carousel .splide__arrow svg {
    fill: white !important;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.post-feed-carousel .splide__pagination {
    bottom: 1rem;
    gap: 0.5rem;
}

.post-feed-carousel .splide__pagination__page {
    background: rgba(255, 255, 255, 0.6);
    width: 0.75rem;
    height: 0.75rem;
    border: 2px solid rgba(255, 0, 147, 0.3);
    border-radius: 50%;
    transition: var(--transition);
}

.post-feed-carousel .splide__pagination__page:hover {
    background: rgba(255, 255, 255, 0.9);
    transform: scale(1.2);
    border-color: #FF0093;
}

.post-feed-carousel .splide__pagination__page.is-active {
    background: #FF0093;
    border-color: #FF0093;
    box-shadow: 0 0 10px rgba(255, 0, 147, 0.6);
    transform: scale(1.3);
}

/* Hide arrows when disabled at ends */
.post-feed-carousel .splide__arrow[disabled] {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Grid View */
.posts-grid-view {
    display: none;
    width: 100%;
    height: 100%;
}

.posts-grid-view.active {
    display: block;
}

.posts-grid-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    padding: 16px;
    width: 100%;
    height: 100%;
    overflow-y: auto; /* enable two-finger scroll */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    align-content: start; /* prevent vertical overlap/packing */
    padding-bottom: 24px; /* ensure last row not clipped */
}

.post-grid-item {
    position: relative;
    display: block;
    width: 100%;
    /* Robust square sizing: padding-top fallback + aspect-ratio for modern browsers */
    aspect-ratio: 1 / 1;
    padding-top: 100%;
    height: 0;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    background: transparent;
}

.post-grid-media {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
}

.post-grid-media img,
.post-grid-media video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.video-indicator,
.multiple-media-indicator {
    position: absolute;
    right: 6px;
    top: 6px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border-radius: 12px;
    padding: 2px 6px;
    font-size: 0.75rem;
}

.post-grid-overlay {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 2px !important; /* tuck caption closer to bottom, force override */
    padding: 0;
    color: #fff;
    font-size: 0.8rem;
    background: transparent; /* remove black gradient bar */
    text-shadow: 0 1px 3px rgba(0,0,0,0.7);
    pointer-events: none;
    z-index: 2;
    display: none !important; /* hide captions in Grid View */
}

/* Remove default paragraph margins so text sits exactly at the bottom */
.post-grid-overlay p {
    margin: 0 !important;
    line-height: 1.2;
}

/* Navigation Fix */
.tingle-enabled .desktop-navi-wrapper,
.tingle-enabled .mob-navi-wrapper {
    position: fixed !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Loading and Empty States */
.posts-loading,
.posts-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #666;
    font-style: italic;
}

/* Full caption overlay */
/* Slide-up caption overlay (bottom sheet) */
.post-caption-overlay {
    position: absolute; /* relative to .posts-modal-content */
    inset: 0;
    background: rgba(0,0,0,0.35);
    display: none;
    align-items: flex-end; /* bottom sheet */
    justify-content: center;
    z-index: 1002; /* above media and header within the modal content */
}

.post-caption-overlay.active { display: flex; }

.post-caption-overlay-inner {
    width: 100%;
    max-height: 60vh;
    background: rgba(20, 20, 20, 0.95);
    color: #fff;
    border-radius: 16px 16px 0 0;
    padding: 1.25rem 1.25rem 1rem;
    overflow: auto;
    transform: translateY(100%);
    transition: transform .25s ease; 
}

.post-caption-overlay.active .post-caption-overlay-inner {
    transform: translateY(0);
}

.post-caption-close {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    font-size: 2rem;
    line-height: 1;
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
}

.post-caption-body {
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 1rem;
    line-height: 1.5;
}