/**
 * tk-instagram-gallery — Frontend CSS
 * Layout: grid (free), masonry (pro), carousel (pro)
 * Lightbox con swipe (pro), filtri, badge tipo media
 */

/* ════════════════════════════════════════════════════════════
   LAYOUT: GRID (base — tutti i piani)
   ════════════════════════════════════════════════════════════ */
.tk-igg-gallery {
    margin: 1.5em 0;
}

.tk-igg-layout-grid {
    display: grid;
    grid-template-columns: repeat(var(--tk-igg-cols, 3), 1fr);
    gap: var(--tk-igg-gap, 6px);
}

/* ════════════════════════════════════════════════════════════
   LAYOUT: MASONRY (pro)
   ════════════════════════════════════════════════════════════ */
.tk-igg-layout-masonry {
    columns: var(--tk-igg-cols, 3);
    column-gap: var(--tk-igg-gap, 6px);
}

.tk-igg-layout-masonry .tk-igg-item {
    break-inside: avoid;
    margin-bottom: var(--tk-igg-gap, 6px);
}

.tk-igg-layout-masonry .tk-igg-thumb-wrap {
    aspect-ratio: auto;
}

.tk-igg-layout-masonry .tk-igg-thumb {
    height: auto;
}

/* ════════════════════════════════════════════════════════════
   LAYOUT: CAROUSEL (pro)
   ════════════════════════════════════════════════════════════ */
.tk-igg-layout-carousel {
    position: relative;
    overflow: hidden;
}

.tk-igg-carousel-track {
    display: flex;
    gap: var(--tk-igg-gap, 6px);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
}

.tk-igg-carousel-track::-webkit-scrollbar { display: none; }

.tk-igg-layout-carousel .tk-igg-item {
    flex: 0 0 calc(100% / var(--tk-igg-cols, 3) - var(--tk-igg-gap, 6px));
    scroll-snap-align: start;
}

.tk-igg-carousel-prev,
.tk-igg-carousel-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.92);
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    font-size: 1.4rem;
    line-height: 1;
    color: #333;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s, background 0.2s;
}
.tk-igg-carousel-prev { left: 8px; }
.tk-igg-carousel-next { right: 8px; }
.tk-igg-carousel-prev:hover,
.tk-igg-carousel-next:hover { background: #fff; box-shadow: 0 2px 12px rgba(0,0,0,0.2); }

/* ════════════════════════════════════════════════════════════
   ITEM / THUMB (condivisi)
   ════════════════════════════════════════════════════════════ */
.tk-igg-item {
    display: block;
    text-decoration: none;
    cursor: pointer;
}

.tk-igg-item-lb { cursor: zoom-in; }

.tk-igg-thumb-wrap {
    position: relative;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    background: #ebebeb;
    border-radius: var(--tk-igg-radius, 4px);
}

.tk-igg-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.tk-igg-thumb-wrap:hover .tk-igg-thumb {
    transform: scale(1.06);
}

/* ── Badge tipo media ── */
.tk-igg-type-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    color: #fff;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}
.tk-igg-type-album { color: #fff; }

/* Play stili */
.tk-igg-play-filled   { background: rgba(0,0,0,0.55); box-shadow: 0 2px 6px rgba(0,0,0,0.2); }
.tk-igg-play-outline   { background: rgba(0,0,0,0.35); box-shadow: 0 2px 6px rgba(0,0,0,0.15); }
.tk-igg-play-circle    { background: rgba(0,0,0,0.45); box-shadow: 0 2px 6px rgba(0,0,0,0.2); width: 32px; height: 32px; }
.tk-igg-play-ig        { background: linear-gradient(135deg,#f09433,#e6683c,#dc2743,#cc2366,#bc1888); box-shadow: 0 2px 8px rgba(225,48,108,0.4); }
.tk-igg-play-glass     { background: rgba(255,255,255,0.18); border: 1.5px solid rgba(255,255,255,0.35); box-shadow: 0 2px 8px rgba(0,0,0,0.1); }

/* ── Overlay hover ── */
.tk-igg-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.52);
    display: flex;
    align-items: flex-end;
    padding: 10px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tk-igg-thumb-wrap:hover .tk-igg-overlay {
    opacity: 1;
}

.tk-igg-caption {
    color: #fff;
    font-size: 0.78rem;
    line-height: 1.35;
    margin: 0;
}

/* ── Video item (no-lightbox mode) ── */
.tk-igg-item--video {
    cursor: pointer;
}
.tk-igg-item--video:focus-visible,
.tk-igg-item-lb:focus-visible {
    outline: 2px solid #e1306c;
    outline-offset: 2px;
}

/* ════════════════════════════════════════════════════════════
   LIGHTBOX (pro) — galleria con swipe
   ════════════════════════════════════════════════════════════ */
#tk-igg-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.92);
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

#tk-igg-lightbox.tk-igg-lb-open {
    display: flex;
}

.tk-igg-lb-content {
    position: relative;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tk-igg-lb-content img,
.tk-igg-lb-content video {
    max-width: 100%;
    max-height: 82vh;
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
    display: block;
    object-fit: contain;
    user-select: none;
}

.tk-igg-lb-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    border: none;
    color: #fff;
    font-size: 1.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background 0.2s;
}
.tk-igg-lb-close:hover { background: rgba(255,255,255,0.25); }

.tk-igg-lb-prev,
.tk-igg-lb-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    border: none;
    color: #fff;
    font-size: 1.6rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background 0.2s;
}
.tk-igg-lb-prev { left: 16px; }
.tk-igg-lb-next { right: 16px; }
.tk-igg-lb-prev:hover,
.tk-igg-lb-next:hover { background: rgba(255,255,255,0.25); }

.tk-igg-lb-caption {
    color: rgba(255,255,255,0.85);
    font-size: 0.88rem;
    text-align: center;
    max-width: 600px;
    margin: 14px auto 0;
    line-height: 1.5;
}

.tk-igg-lb-counter {
    color: rgba(255,255,255,0.5);
    font-size: 0.75rem;
    text-align: center;
    margin-top: 6px;
}

/* ════════════════════════════════════════════════════════════
   VECCHIO MODALE VIDEO (fallback no-lightbox)
   ════════════════════════════════════════════════════════════ */
#tk-igg-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: rgba(0, 0, 0, 0.88);
    align-items: center;
    justify-content: center;
    padding: 16px;
}
#tk-igg-modal.tk-igg-modal--open { display: flex; }
#tk-igg-modal-inner {
    position: relative; width: 100%; max-width: 720px;
    background: #000; border-radius: 8px; overflow: hidden;
    box-shadow: 0 8px 40px rgba(0,0,0,0.7);
}
#tk-igg-modal-close {
    position: absolute; top: 10px; right: 12px; z-index: 10;
    background: rgba(0,0,0,0.6); border: none; color: #fff;
    font-size: 1.6rem; line-height: 1; width: 36px; height: 36px;
    border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s;
}
#tk-igg-modal-close:hover { background: rgba(255,255,255,0.2); }
#tk-igg-modal-video { width: 100%; display: block; max-height: 80vh; background: #000; }
#tk-igg-modal-caption { color: #ddd; font-size: 0.82rem; padding: 10px 14px; margin: 0; line-height: 1.4; }

/* ════════════════════════════════════════════════════════════
   FOOTER & POWERED BY
   ════════════════════════════════════════════════════════════ */
.tk-igg-footer {
    text-align: center;
    margin-top: 1.2em;
}

.tk-igg-follow-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border-radius: 50px;
    background: linear-gradient(135deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
    color: #fff !important;
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none !important;
    letter-spacing: 0.02em;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    box-shadow: 0 4px 14px rgba(225, 48, 108, 0.3);
    line-height: 1;
}
.tk-igg-follow-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(225, 48, 108, 0.4);
    color: #fff !important;
    text-decoration: none !important;
}
.tk-igg-follow-btn:active {
    transform: translateY(0);
}
.tk-igg-follow-btn svg {
    flex-shrink: 0;
}

.tk-igg-powered {
    text-align: center;
    margin-top: 0.4em;
    font-size: 0.7rem;
}
.tk-igg-powered a {
    color: #aaa;
    text-decoration: none;
}
.tk-igg-powered a:hover { color: #e1306c; }

/* ── Errore ── */
.tk-igg-error {
    color: #b00020;
    font-style: italic;
}

/* ════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════ */
@media (max-width: 600px) {
    .tk-igg-layout-grid,
    .tk-igg-layout-masonry {
        --tk-igg-cols: 2 !important;
    }
    .tk-igg-carousel-prev,
    .tk-igg-carousel-next {
        width: 32px; height: 32px; font-size: 1.1rem;
    }
    .tk-igg-lb-prev,
    .tk-igg-lb-next {
        width: 36px; height: 36px; font-size: 1.2rem;
    }
}
