/**
 * TBGFL Instagram - Frontend Styles
 * Responsive, hardware-accelerated Grid, Slider, and Masonry layouts.
 *
 * @package Custom_Instagram_Feed
 */

:root {
    --cif-brand-color: #B8860B;
    --cif-text-color: #112217;
    --cif-background-color: transparent;
    --cif-button-bg: #B8860B;
    --cif-button-color: #FFFFFF;
    --cif-card-radius: 16px;
    --cif-gap: 18px;
    --cif-cols-desktop: 4;
    --cif-cols-tablet: 3;
    --cif-cols-mobile: 2;
}

/* ==========================================================================
   1. Feed Outer Container & Reset
   ========================================================================== */
.cif-feed {
    position: relative;
    box-sizing: border-box;
    width: 100%;
    margin: 36px 0;
    padding: 0;
    background-color: var(--cif-background-color, transparent);
    color: var(--cif-text-color, #112217);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    -webkit-font-smoothing: antialiased;
}

.cif-feed *,
.cif-feed *::before,
.cif-feed *::after {
    box-sizing: border-box;
}

/* ==========================================================================
   2. Instagram Header & Branding
   ========================================================================== */
.cif-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 18px;
    margin-bottom: 26px;
    padding-bottom: 18px;
    border-bottom: 1px solid rgba(184, 138, 68, 0.18);
}

.cif-header-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.cif-avatar-ring {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    padding: 2.5px;
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    box-shadow: 0 4px 14px rgba(220, 39, 67, 0.25);
    flex-shrink: 0;
}

.cif-avatar-ring .cif-svg-ig {
    background: #FFFFFF;
    border-radius: 50%;
    padding: 6px;
    width: 100%;
    height: 100%;
    color: #bc1888;
}

.cif-header-text {
    display: flex;
    flex-direction: column;
}

.cif-header-title {
    margin: 0 0 4px 0 !important;
    font-size: 22px !important;
    font-weight: 800 !important;
    line-height: 1.25 !important;
    color: var(--cif-text-color, #112217) !important;
    letter-spacing: -0.3px;
}

.cif-header-username {
    font-size: 14px;
    font-weight: 700;
    color: var(--cif-brand-color, #B8860B);
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.cif-header-username:hover {
    opacity: 0.8;
    text-decoration: underline;
}

.cif-header-subtitle {
    font-size: 13.5px;
    color: #64748B;
}

.cif-btn-follow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    background: var(--cif-button-bg, #B8860B);
    color: var(--cif-button-color, #FFFFFF) !important;
    border-radius: 50px;
    font-size: 13.5px;
    font-weight: 700;
    text-decoration: none !important;
    transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.25s ease;
    box-shadow: 0 4px 15px rgba(184, 138, 68, 0.35);
}

.cif-btn-follow:hover,
.cif-btn-follow:focus {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(184, 138, 68, 0.45);
    opacity: 0.95;
}

/* ==========================================================================
   3. Items Container & Responsive Layouts
   ========================================================================== */
.cif-track-wrapper {
    position: relative;
    width: 100%;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
}

/* --- Layout 1: Grid --- */
.cif-layout-grid .cif-items-track {
    display: grid;
    grid-template-columns: repeat(var(--cif-cols-desktop, 4), 1fr);
    gap: var(--cif-gap, 18px);
}

@media (max-width: 1024px) {
    .cif-layout-grid .cif-items-track {
        grid-template-columns: repeat(var(--cif-cols-tablet, 3), 1fr);
    }
}

@media (max-width: 640px) {
    .cif-layout-grid .cif-items-track {
        grid-template-columns: repeat(var(--cif-cols-mobile, 2), 1fr);
        gap: 12px;
    }
}

/* --- Layout 2: Slider / Carousel (Butter-Smooth Touch Swiping) --- */
.cif-layout-slider .cif-track-wrapper {
    cursor: grab;
    user-select: none;
    touch-action: pan-y;
    overflow: hidden;
    padding: 6px 0 16px 0;
}

.cif-layout-slider .cif-track-wrapper.is-dragging {
    cursor: grabbing;
}

.cif-layout-slider .cif-items-track {
    display: flex;
    gap: var(--cif-gap, 18px);
    transition: transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    perspective: 1000px;
    -webkit-perspective: 1000px;
}

.cif-layout-slider .cif-item {
    flex: 0 0 calc((100% - ((var(--cif-cols-desktop, 4) - 1) * var(--cif-gap, 18px))) / var(--cif-cols-desktop, 4));
    min-width: 0;
}

@media (max-width: 1024px) {
    .cif-layout-slider .cif-item {
        flex: 0 0 calc((100% - ((var(--cif-cols-tablet, 3) - 1) * var(--cif-gap, 18px))) / var(--cif-cols-tablet, 3));
    }
}

@media (max-width: 640px) {
    .cif-layout-slider .cif-items-track {
        gap: 12px;
    }

    .cif-layout-slider .cif-item {
        flex: 0 0 calc((100% - ((var(--cif-cols-mobile, 2) - 1) * 12px)) / var(--cif-cols-mobile, 2));
    }
}

@media (max-width: 480px) {
    .cif-layout-slider[data-cols-mobile="1"] .cif-item {
        flex: 0 0 100%;
    }
}

/* Slider Controls */
.cif-slider-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    margin-top: 24px;
}

.cif-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #FFFFFF;
    color: var(--cif-text-color, #112217);
    border: 1.5px solid rgba(184, 138, 68, 0.35);
    box-shadow: 0 4px 12px rgba(184, 138, 68, 0.12);
    cursor: pointer;
    transition: all 0.25s ease;
    padding: 0;
}

.cif-nav-btn:hover,
.cif-nav-btn:focus {
    background: var(--cif-brand-color, #B8860B);
    color: #FFFFFF;
    border-color: var(--cif-brand-color, #B8860B);
    box-shadow: 0 6px 18px rgba(184, 138, 68, 0.35);
    outline: none;
    transform: scale(1.05);
}

.cif-nav-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
}

.cif-slider-dots {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cif-slider-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(184, 138, 68, 0.30);
    border: none;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    padding: 0;
}

.cif-slider-dot.active {
    width: 28px;
    border-radius: 6px;
    background: var(--cif-brand-color, #B8860B);
    box-shadow: 0 2px 8px rgba(184, 138, 68, 0.3);
}

/* --- Layout 3: Masonry --- */
.cif-layout-masonry .cif-items-track {
    column-count: var(--cif-cols-desktop, 4);
    column-gap: var(--cif-gap, 18px);
}

.cif-layout-masonry .cif-item {
    break-inside: avoid;
    margin-bottom: var(--cif-gap, 18px);
    display: block;
}

@media (max-width: 1024px) {
    .cif-layout-masonry .cif-items-track {
        column-count: var(--cif-cols-tablet, 3);
    }
}

@media (max-width: 640px) {
    .cif-layout-masonry .cif-items-track {
        column-count: var(--cif-cols-mobile, 2);
    }
}

/* ==========================================================================
   4. Media Cards & Aspect Ratios
   ========================================================================== */
.cif-item {
    position: relative;
    border-radius: var(--cif-card-radius, 16px);
    overflow: hidden;
    background: #112217;
    border: 1px solid rgba(184, 138, 68, 0.16);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.05);
    transform: translate3d(0, 0, 0);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.cif-item:hover {
    transform: translateY(-5px);
    border-color: rgba(184, 138, 68, 0.35);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.12);
}

.cif-item-link {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    outline: none;
}

.cif-media-box {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: #0B1610;
}

/* Aspect Ratio Modifiers */
.cif-ratio-1-1 {
    aspect-ratio: 1 / 1;
}

.cif-ratio-4-5 {
    aspect-ratio: 4 / 5;
}

.cif-ratio-16-9 {
    aspect-ratio: 16 / 9;
}

.cif-ratio-original {
    aspect-ratio: auto;
}

.cif-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   5. Hover Effects & Engagement Overlays
   ========================================================================== */
.cif-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(17, 34, 23, 0.2) 0%, rgba(17, 34, 23, 0.85) 100%);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
    display: flex;
    align-items: stretch;
    justify-content: stretch;
    padding: 16px;
    color: #FFFFFF;
}

.cif-overlay-inner {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 100%;
    height: 100%;
}

.cif-overlay-top {
    display: flex;
    justify-content: flex-end;
}

.cif-icon-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(6px);
    border-radius: 50%;
    color: #FFFFFF;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.cif-overlay-mid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: auto 0;
}

.cif-stats {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 13px;
    font-weight: 700;
    color: #FFFFFF;
}

.cif-stat-likes,
.cif-stat-comments {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.cif-stat-likes svg {
    color: #F43F5E;
}

.cif-stat-comments svg {
    color: #38BDF8;
}

.cif-caption-text {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.45;
    color: #F8FAFC;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cif-overlay-bottom {
    display: flex;
    justify-content: flex-start;
}

.cif-post-date {
    font-size: 11.5px;
    font-weight: 600;
    color: #F3D079;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Hover Type 1: Zoom */
.cif-hover-zoom:hover .cif-img,
.cif-item:focus-within .cif-img {
    transform: scale(1.08);
}

.cif-item:hover .cif-overlay,
.cif-item:focus-within .cif-overlay {
    opacity: 1;
    visibility: visible;
}

/* Hover Type 2: Dark Overlay */
.cif-hover-overlay:hover .cif-overlay,
.cif-item:focus-within .cif-overlay {
    opacity: 1;
    visibility: visible;
}

/* Hover Type 3: None */
.cif-hover-none .cif-overlay {
    display: none;
}

/* ==========================================================================
   6. Mobile Layout Responsive Adjustments
   ========================================================================== */
@media (max-width: 640px) {
    .cif-feed {
        margin: 24px 0;
    }

    .cif-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 14px;
        margin-bottom: 20px;
    }

    .cif-header-action {
        width: 100%;
    }

    .cif-btn-follow {
        width: 100%;
        justify-content: center;
    }

    .cif-slider-controls {
        gap: 14px;
        margin-top: 18px;
    }

    .cif-nav-btn {
        width: 38px;
        height: 38px;
    }
}
