/**
 * Whitetip Instagram Feed
 *
 * Scoped entirely under .wtig-feed so it cannot leak into a client theme.
 * Columns and gap arrive as custom properties set inline by the template.
 */

.wtig-feed {
    --wtig-columns: 3;
    --wtig-gap: 8px;
    --wtig-radius: 2px;

    /* Distance from the header to the grid. Deliberately not --wtig-gap:
       they are different distances and want different values. */
    --wtig-header-gap: 20px;

    /* Follow button. Block themes publish their palette as custom properties
       and get adopted automatically; everywhere else the fallback applies and
       one rule in the theme overrides it per site. */
    --wtig-follow-bg: var(--wp--preset--color--primary, #1f2937);
    --wtig-follow-fg: var(--wp--preset--color--base, #fff);
    --wtig-follow-radius: 6px;

    /* The theme owns the body font, and some hand this region a monospace
       stack. Stating it here keeps the feed legible whatever the theme does.
       Inter is used when the theme already loads it; otherwise the system
       stack renders something very close — no extra request, and nothing for
       GDPR to worry about. */
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------- header ---------- */

.wtig-feed .wtig-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: var(--wtig-header-gap);
}

.wtig-feed .wtig-avatar {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    object-fit: cover;
    flex: none;
}

.wtig-feed .wtig-identity {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.3;
}

.wtig-feed .wtig-handle {
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 20px;
    font-weight: 400;
    text-decoration: none;
    color: inherit;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wtig-feed .wtig-handle:hover,
.wtig-feed .wtig-handle:focus-visible {
    text-decoration: underline;
}

.wtig-feed .wtig-stats {
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 1.2em;
    opacity: .6;
}

.wtig-feed .wtig-follow {
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin-left: auto;
    flex: none;
    padding: 9px 18px;
    border-radius: var(--wtig-follow-radius);
    background-color: #00b8ff;
    color: var(--wtig-follow-fg);
    font-size: 1.5em;
    font-weight: 400;
    letter-spacing: .01em;
    text-decoration: none;
    line-height: 1;
    transition: opacity .15s ease;
}

/* Colour restated on hover: themes routinely recolour links on hover, and
   without this the label would drift to the theme's link colour on top of
   the button's own background. */
.wtig-feed .wtig-follow:hover,
.wtig-feed .wtig-follow:focus-visible {
    color: var(--wtig-follow-fg);
    opacity: .85;
}

/* ---------- grid ---------- */

.wtig-feed .wtig-grid {
    display: grid;
    grid-template-columns: repeat(var(--wtig-columns), minmax(0, 1fr));
    gap: var(--wtig-gap);
    margin: 0;
    padding: 0;
    list-style: none;
}

.wtig-feed .wtig-item {
    margin: 0;
    padding: 0;
    list-style: none;
    min-width: 0;
}

.wtig-feed .wtig-link {
    display: block;
    position: relative;
    overflow: hidden;
    border-radius: var(--wtig-radius);
    background: rgba(127, 127, 127, .12);
    aspect-ratio: 1 / 1;
    text-decoration: none;
}

.wtig-feed .wtig-link img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .35s ease, opacity .2s ease;
}

@media (hover: hover) {
    .wtig-feed .wtig-link:hover img {
        transform: scale(1.04);
        opacity: .88;
    }
}

.wtig-feed .wtig-link:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* ---------- badges ---------- */

.wtig-feed .wtig-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    display: flex;
    color: #fff;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .55));
    pointer-events: none;
}

/* ---------- caption ---------- */

.wtig-feed .wtig-caption {
    margin: 6px 0 0;
    font-size: .85em;
    line-height: 1.4;
    opacity: .8;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
}

/* ---------- responsive ---------- */

@media (max-width: 780px) {
    .wtig-feed .wtig-grid {
        grid-template-columns: repeat(min(var(--wtig-columns), 3), minmax(0, 1fr));
    }
}

@media (max-width: 480px) {
    .wtig-feed .wtig-grid {
        grid-template-columns: repeat(min(var(--wtig-columns), 2), minmax(0, 1fr));
    }
}

@media (prefers-reduced-motion: reduce) {
    .wtig-feed .wtig-link img {
        transition: none;
    }
}

/* ---------- lightbox ---------- */

/* Not scoped under .wtig-feed: the overlay is appended to body, outside the
   feed, so it can sit above any theme layout without a z-index fight. */

.wtig-lb-open {
    overflow: hidden;
}

.wtig-lb {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* The display above overrides the browser's own [hidden] { display: none },
   because author styles beat the UA stylesheet. Without this rule the hidden
   attribute is set correctly and changes nothing on screen. */
.wtig-lb[hidden] {
    display: none;
}

.wtig-lb__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .88);
}

.wtig-lb__stage {
    position: relative;
    max-width: min(92vw, 900px);
    max-height: 88vh;
    display: flex;
}

.wtig-lb__figure {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
}

.wtig-lb__image {
    display: block;
    max-width: 100%;
    max-height: 78vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 2px;
    background: rgba(255, 255, 255, .06);
}

.wtig-lb__caption {
    color: #fff;
    font-size: .9rem;
    line-height: 1.5;
    text-align: center;
    max-width: 65ch;
    margin: 0 auto;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
}

.wtig-lb__btn {
    position: absolute;
    appearance: none;
    border: 0;
    margin: 0;
    cursor: pointer;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    font-size: 26px;
    line-height: 1;
    padding: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color .15s ease;
}

.wtig-lb__btn:hover,
.wtig-lb__btn:focus-visible {
    background: rgba(255, 255, 255, .26);
}

.wtig-lb__btn:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.wtig-lb__close {
    top: 16px;
    right: 16px;
}

.wtig-lb__prev {
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
}

.wtig-lb__next {
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
}

.wtig-lb__counter {
    position: absolute;
    bottom: 16px;
    left: 0;
    right: 0;
    margin: 0;
    text-align: center;
    color: rgba(255, 255, 255, .6);
    font-size: .8rem;
    font-variant-numeric: tabular-nums;
}

/* Touch targets get out of the way of the image on narrow screens. */
@media (max-width: 600px) {
    .wtig-lb__prev {
        left: 12px;
        top: auto;
        bottom: 56px;
        transform: none;
    }

    .wtig-lb__next {
        right: 12px;
        top: auto;
        bottom: 56px;
        transform: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .wtig-lb__btn {
        transition: none;
    }
}