/* =========================================================
   Instagram Feed - storefront. Mobile first: phones get --igf-cols-sm columns, tablets (641px+) --igf-cols-md and
   desktops (1025px+) --igf-cols; the view sets the three numbers and the gap from the settings.
   Colors are custom properties so a theme can restyle the block without touching this file, e.g.
   .igf { --igf-button-bg: #000; }
   ========================================================= */

.igf {
    --igf-cols: 4;
    --igf-cols-md: 3;
    --igf-cols-sm: 2;
    --igf-gap: 8px;
    --igf-text: #262626;
    --igf-muted: #737373;
    --igf-border: #dbdbdb;
    --igf-tile-bg: #efefef;
    --igf-button-bg: #0095f6;
    --igf-button-text: #fff;
    --igf-radius: 4px;

    box-sizing: border-box;
    width: 100%;
    margin: 40px auto;
    color: var(--igf-text);
    clear: both;
}

.igf *, .igf *::before, .igf *::after { box-sizing: border-box; }
.igf [hidden] { display: none !important; }

.igf-title {
    margin: 0 0 20px;
    font-size: 24px;
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
}

/* Profile bar */
.igf-profile {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 0 0 16px;
}

.igf-avatar {
    flex: none;
    display: block;
    width: 60px;
    height: 60px;
    padding: 2px;
    border-radius: 50%;
    background: linear-gradient(45deg, #f9ce34, #ee2a7b 55%, #6228d7);
}

.igf-avatar img,
.igf-avatar-letter {
    display: block;
    width: 100%;
    height: 100%;
    border: 2px solid #fff;
    border-radius: 50%;
    object-fit: cover;
    background: var(--igf-tile-bg);
}

.igf-avatar-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 600;
    color: var(--igf-muted);
}

.igf-profile-text {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.igf-name {
    overflow: hidden;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    color: inherit !important;
    text-decoration: none !important;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.igf-handle { font-size: 14px; color: var(--igf-muted); }

.igf-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    font-size: 13px;
    color: var(--igf-muted);
}

.igf-stats strong { color: var(--igf-text); font-weight: 600; }

.igf-follow,
.igf-more-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 20px;
    border: 0;
    border-radius: 8px;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    text-decoration: none !important;
    cursor: pointer;
    transition: opacity .15s ease, background-color .15s ease;
}

.igf-follow {
    flex: none;
    background: var(--igf-button-bg);
    color: var(--igf-button-text) !important;
}

.igf-follow:hover,
.igf-follow:focus { opacity: .88; }

/* Grid */
.igf-grid {
    display: grid;
    grid-template-columns: repeat(var(--igf-cols-sm), minmax(0, 1fr));
    gap: var(--igf-gap);
    margin: 0;
    padding: 0;
    list-style: none;
}

.igf-item { margin: 0; padding: 0; min-width: 0; }

/* Square tile: the padding keeps the ratio on browsers without aspect-ratio. */
.igf-link {
    position: relative;
    display: block;
    width: 100%;
    padding-top: 100%;
    overflow: hidden;
    border-radius: var(--igf-radius);
    background: var(--igf-tile-bg);
    color: #fff !important;
    text-decoration: none !important;
}

.igf-img {
    position: absolute;
    inset: 0;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    transition: transform .35s ease;
}

.igf-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    color: #fff;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .45));
    pointer-events: none;
}

.igf-overlay {
    position: absolute;
    inset: 0;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px;
    background: rgba(0, 0, 0, .55);
    opacity: 0;
    transition: opacity .2s ease;
    text-align: center;
}

.igf-caption {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    overflow: hidden;
    font-size: 13px;
    line-height: 1.4;
    word-break: break-word;
}

.igf-link:focus-visible { outline: 3px solid var(--igf-button-bg); outline-offset: 2px; }

@media (hover: hover) {
    .igf-link:hover .igf-img { transform: scale(1.05); }
    .igf-link:hover .igf-overlay,
    .igf-link:focus-visible .igf-overlay { opacity: 1; }
}

/* Load more */
.igf-more { margin: 20px 0 0; text-align: center; }

.igf-more-btn {
    background: transparent;
    border: 1px solid var(--igf-border);
    color: var(--igf-text);
    min-width: 180px;
}

.igf-more-btn:hover,
.igf-more-btn:focus { background: rgba(0, 0, 0, .04); }

/* Phones: the Follow button goes under the profile, full width; so does "Load more". */
@media (max-width: 480px) {
    .igf { margin: 28px auto; }
    .igf-title { font-size: 20px; margin-bottom: 14px; }
    .igf-profile { flex-wrap: wrap; }
    .igf-follow { width: 100%; }
    .igf-more-btn { width: 100%; }
    .igf-caption { -webkit-line-clamp: 3; font-size: 12px; }
}

@media (min-width: 641px) {
    .igf-grid { grid-template-columns: repeat(var(--igf-cols-md), minmax(0, 1fr)); }
}

@media (min-width: 1025px) {
    .igf-grid { grid-template-columns: repeat(var(--igf-cols), minmax(0, 1fr)); }
}

/* =========================================================
   Viewer: picture on the left and text on the right on wide screens, stacked and full screen on phones.
   ========================================================= */
html.igf-lb-open { overflow: hidden; }

.igf-lb {
    position: fixed;
    inset: 0;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 64px;
    background: rgba(0, 0, 0, .85);
    color: #262626;
}

.igf-lb[hidden],
.igf-lb [hidden] { display: none !important; }

.igf-lb-dialog {
    position: relative;
    display: flex;
    width: 100%;
    max-width: 1100px;
    max-height: calc(100vh - 48px);
    background: #fff;
    border-radius: 6px;
    overflow: hidden;
}

.igf-lb-media {
    position: relative;
    flex: 1 1 62%;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

.igf-lb-media img,
.igf-lb-media video {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 48px);
    width: auto;
    height: auto;
    object-fit: contain;
}

.igf-lb-side {
    flex: 0 0 38%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.igf-lb-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 48px 14px 16px;
    border-bottom: 1px solid #efefef;
    font-weight: 600;
    font-size: 14px;
}

.igf-lb-head img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.igf-lb-head a { color: inherit !important; text-decoration: none !important; }

.igf-lb-caption {
    flex: 1 1 auto;
    margin: 0;
    padding: 16px;
    overflow-y: auto;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.igf-lb-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-top: 1px solid #efefef;
    font-size: 12px;
    color: #737373;
}

.igf-lb-foot a {
    font-weight: 600;
    color: #0095f6 !important;
    text-decoration: none !important;
    white-space: nowrap;
}

.igf-lb button {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    background: transparent;
    font: inherit;
    cursor: pointer;
}

.igf-lb-close {
    top: 8px;
    right: 8px;
    z-index: 2;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: #262626;
    font-size: 26px !important;
    line-height: 1;
}

.igf-lb-prev,
.igf-lb-next {
    top: 50%;
    width: 44px;
    height: 44px;
    margin-top: -22px;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, .9) !important;
    color: #262626;
    font-size: 26px !important;
    line-height: 1;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}

.igf-lb-prev { left: 10px; }
.igf-lb-next { right: 10px; }

/* Slides of a carousel post: small arrows and dots over the picture. */
.igf-lb-slide-prev,
.igf-lb-slide-next {
    top: 50%;
    width: 30px;
    height: 30px;
    margin-top: -15px;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, .8) !important;
    color: #262626;
    font-size: 20px !important;
    line-height: 1;
}

.igf-lb-slide-prev { left: 10px; }
.igf-lb-slide-next { right: 10px; }

.igf-lb-dots {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 12px;
    display: flex;
    justify-content: center;
    gap: 5px;
    pointer-events: none;
}

.igf-lb-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .5);
}

.igf-lb-dots span.is-active { background: #fff; }

@media (min-width: 769px) {
    /* The post arrows sit outside the white box. */
    .igf-lb-prev { left: -54px; }
    .igf-lb-next { right: -54px; }
}

@media (max-width: 768px) {
    .igf-lb { padding: 0; align-items: stretch; }
    .igf-lb-dialog { flex-direction: column; max-height: none; height: 100%; border-radius: 0; }
    .igf-lb-media { flex: 1 1 auto; min-height: 0; }
    .igf-lb-media img,
    .igf-lb-media video { max-height: 100%; }
    .igf-lb-side { flex: 0 0 auto; max-width: none; max-height: 40%; }
    .igf-lb-close { background: rgba(255, 255, 255, .9) !important; }
    .igf-lb-prev,
    .igf-lb-next { top: 30%; }
}
