.tdb-instagram {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 80px 0;
}

.tdb-instagram__head {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 24px;
    margin-bottom: 28px;
}

.tdb-instagram__eyebrow {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    opacity: 0.7;
}

.tdb-instagram__title {
    margin: 0;
    font-size: clamp(30px, 5vw, 56px);
    line-height: 1;
}

.tdb-instagram__profile-link,
.tdb-instagram__load-more,
.tdb-instagram-modal__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0 20px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    background: transparent;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    transition:
        background 0.25s ease,
        border-color 0.25s ease;
}

.tdb-instagram__profile-link:hover,
.tdb-instagram__load-more:hover,
.tdb-instagram-modal__link:hover {
    border-color: rgba(255, 255, 255, 0.55);
    background: rgba(255, 255, 255, 0.08);
}

.tdb-instagram__grid {
    display: grid;
    grid-template-columns:
        repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.tdb-instagram-card {
    min-width: 0;
    overflow: hidden;
    border-radius: 16px;
    background: #111;
}

.tdb-instagram-card__button {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #111;
    color: #fff;
    cursor: pointer;
}

.tdb-instagram-card__image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition:
        transform 0.4s ease,
        filter 0.4s ease;
}

.tdb-instagram-card:hover
.tdb-instagram-card__image {
    transform: scale(1.05);
}

.tdb-instagram-card__badge {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    transition:
        opacity 0.25s ease,
        transform 0.25s ease;
}

.tdb-instagram-card__badge svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tdb-instagram-card__badge svg path:first-child {
    fill: none;
}

.tdb-instagram-card:hover
.tdb-instagram-card__badge {
    opacity: 0;
    transform: scale(0.8);
}

.tdb-instagram-card__overlay {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 26px;
    padding: 24px;
    background: rgba(230, 0, 25, 0.94);
    color: #fff;
    text-align: center;
    opacity: 0;
    transition: opacity 0.28s ease;
}

.tdb-instagram-card:hover
.tdb-instagram-card__overlay,
.tdb-instagram-card__button:focus-visible
.tdb-instagram-card__overlay {
    opacity: 1;
}

.tdb-instagram-card__stats {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 54px;
}

.tdb-instagram-card__stat {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-size: 18px;
    line-height: 1;
}

.tdb-instagram-card__stat strong {
    font-size: 17px;
    font-weight: 700;
}

.tdb-instagram-card__stat svg {
    width: 32px;
    height: 32px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tdb-instagram-card__caption {
    display: -webkit-box;
    width: 100%;
    max-width: 92%;
    overflow: hidden;
    font-size: 15px;
    line-height: 1.5;
    word-break: break-word;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
}

.tdb-instagram__status,
.tdb-instagram__actions {
    margin-top: 28px;
    text-align: center;
}

.tdb-instagram__sentinel {
    display: block;
    width: 100%;
    height: 1px;
}

.tdb-instagram-modal[hidden] {
    display: none;
}

.tdb-instagram-modal {
    position: fixed;
    z-index: 9999;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.88);
}

.tdb-instagram-modal__dialog {
    position: relative;
    display: grid;
    grid-template-columns:
        minmax(0, 1.2fr)
        minmax(260px, 0.8fr);
    width: min(920px, 100%);
    max-height: 90vh;
    overflow: auto;
    border-radius: 18px;
    background: #111;
    color: #fff;
}

.tdb-instagram-modal__media {
    min-height: 420px;
    background: #050505;
}

.tdb-instagram-modal__image {
    display: block;
    width: 100%;
    height: 100%;
    max-height: 80vh;
    object-fit: contain;
}

.tdb-instagram-modal__content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 34px 26px 26px;
}

.tdb-instagram-modal__caption {
    margin: 0;
    white-space: pre-wrap;
    line-height: 1.6;
}

.tdb-instagram-modal__close {
    position: absolute;
    z-index: 3;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.78);
    color: #fff;
    font-size: 24px;
    cursor: pointer;
}

.tdb-modal-open {
    overflow: hidden;
}

@media (max-width: 900px) {
    .tdb-instagram__grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }

    .tdb-instagram-modal__dialog {
        grid-template-columns: 1fr;
    }

    .tdb-instagram-modal__media {
        min-height: auto;
    }
}

@media (max-width: 600px) {
    .tdb-instagram {
        padding: 56px 0;
    }

    .tdb-instagram__head {
        align-items: flex-start;
        flex-direction: column;
    }

    .tdb-instagram__grid {
        gap: 8px;
    }

    .tdb-instagram-card {
        border-radius: 10px;
    }

    .tdb-instagram-card__overlay {
        gap: 14px;
        padding: 12px;
    }

    .tdb-instagram-card__stats {
        gap: 24px;
    }

    .tdb-instagram-card__stat {
        gap: 6px;
        font-size: 14px;
    }

    .tdb-instagram-card__stat svg {
        width: 25px;
        height: 25px;
    }

    .tdb-instagram-card__stat strong {
        font-size: 14px;
    }

    .tdb-instagram-card__caption {
        display: none;
    }
}

@media (hover: none) {
    .tdb-instagram-card__overlay {
        top: auto;
        min-height: 54px;
        flex-direction: row;
        justify-content: center;
        padding: 10px;
        background:
            linear-gradient(
                transparent,
                rgba(0, 0, 0, 0.86)
            );
        opacity: 1;
    }

    .tdb-instagram-card__caption {
        display: none;
    }

    .tdb-instagram-card__stats {
        gap: 26px;
    }
}
