/* Image gallery - grid / columns / strip tiles, sample gradient tiles and an
   in-frame lightbox. Sample tiles use six fixed gradients with dark-mode
   variants; real photos are never tinted. The lightbox is position:fixed
   inside the frame; its top/height are set through the CSSOM to the part of
   the frame the visitor can see. */
:root {
    --ig-s1a: #c7d2fe; --ig-s1b: #818cf8; --ig-s2a: #fbcfe8; --ig-s2b: #f472b6; --ig-s3a: #bbf7d0; --ig-s3b: #34d399;
    --ig-s4a: #fde68a; --ig-s4b: #f59e0b; --ig-s5a: #bae6fd; --ig-s5b: #38bdf8; --ig-s6a: #e9d5ff; --ig-s6b: #a78bfa;
    --ig-motif: rgba(255, 255, 255, .55); --ig-scrim: rgba(10, 14, 30, .72); --ig-backdrop: rgba(9, 12, 26, .96);
}
html[data-theme="dark"] {
    --ig-s1a: #312e81; --ig-s1b: #4f46e5; --ig-s2a: #831843; --ig-s2b: #be185d; --ig-s3a: #14532d; --ig-s3b: #059669;
    --ig-s4a: #78350f; --ig-s4b: #b45309; --ig-s5a: #0c4a6e; --ig-s5b: #0284c7; --ig-s6a: #4c1d95; --ig-s6b: #7c3aed;
    --ig-motif: rgba(255, 255, 255, .22); --ig-backdrop: rgba(4, 6, 14, .97);
}
@media (prefers-color-scheme: dark) {
    html[data-theme="auto"] {
        --ig-s1a: #312e81; --ig-s1b: #4f46e5; --ig-s2a: #831843; --ig-s2b: #be185d; --ig-s3a: #14532d; --ig-s3b: #059669;
        --ig-s4a: #78350f; --ig-s4b: #b45309; --ig-s5a: #0c4a6e; --ig-s5b: #0284c7; --ig-s6a: #4c1d95; --ig-s6b: #7c3aed;
        --ig-motif: rgba(255, 255, 255, .22); --ig-backdrop: rgba(4, 6, 14, .97);
    }
}

.ig-wrap { display: grid; gap: 10px; }
.ig-list { list-style: none; margin: 0; padding: 0; }
.ig-li { margin: 0; min-width: 0; }
.ig-item { margin: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; position: relative; }

/* grid */
.ig-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
.ig-grid.ig-z-small { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
.ig-grid.ig-z-large { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }

/* columns: masonry-like, natural image height, reading order runs down each column */
.ig-columns { column-width: 140px; column-gap: 10px; }
.ig-columns.ig-z-small { column-width: 105px; }
.ig-columns.ig-z-large { column-width: 210px; }
.ig-columns .ig-li { break-inside: avoid; margin-bottom: 10px; }

/* strip: one row that scrolls sideways */
.ig-strip { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 2px 2px 8px; overscroll-behavior-x: contain; }
.ig-strip .ig-li { flex: 0 0 min(72%, 190px); scroll-snap-align: start; }
.ig-strip.ig-z-small .ig-li { flex-basis: min(60%, 140px); }
.ig-strip.ig-z-large .ig-li { flex-basis: min(86%, 280px); }
.ig-strip:focus-visible { outline: 2px solid var(--e-focus); outline-offset: 2px; border-radius: var(--e-radius-sm); }

.ig-open {
    display: block; width: 100%; padding: 0; margin: 0; border: 0; background: none; cursor: zoom-in; color: inherit;
    border-radius: var(--e-radius-sm); text-decoration: none;
}
a.ig-open { cursor: pointer; }
.ig-media {
    position: relative; display: block; overflow: hidden; border-radius: var(--e-radius-sm);
    background: var(--e-surface-2); border: 1px solid var(--e-line);
}
.ig-crop { aspect-ratio: 4 / 3; }
.ig-r-1x1 .ig-crop { aspect-ratio: 1 / 1; }
.ig-r-3x2 .ig-crop { aspect-ratio: 3 / 2; }
.ig-r-16x9 .ig-crop { aspect-ratio: 16 / 9; }
.ig-r-3x4 .ig-crop { aspect-ratio: 3 / 4; }
.ig-columns .ig-crop.ig-h1 { aspect-ratio: 4 / 5; }
.ig-columns .ig-crop.ig-h2 { aspect-ratio: 1 / 1; }
.ig-columns .ig-crop.ig-h3 { aspect-ratio: 4 / 3; }
.ig-img { display: block; width: 100%; height: auto; }
.ig-crop .ig-img, .ig-crop .ig-sample { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ig-open .ig-img { transition: transform .35s var(--e-ease); }
.ig-open:hover .ig-img { transform: scale(1.035); }
.ig-open:focus-visible { outline: 2px solid var(--e-focus); outline-offset: 2px; }

/* sample + unavailable tiles */
.ig-sample { display: block; position: relative; width: 100%; min-height: 80px; overflow: hidden; }
.ig-s1 { background: linear-gradient(140deg, var(--ig-s1a), var(--ig-s1b)); }
.ig-s2 { background: linear-gradient(140deg, var(--ig-s2a), var(--ig-s2b)); }
.ig-s3 { background: linear-gradient(140deg, var(--ig-s3a), var(--ig-s3b)); }
.ig-s4 { background: linear-gradient(140deg, var(--ig-s4a), var(--ig-s4b)); }
.ig-s5 { background: linear-gradient(140deg, var(--ig-s5a), var(--ig-s5b)); }
.ig-s6 { background: linear-gradient(140deg, var(--ig-s6a), var(--ig-s6b)); }
.ig-motif { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 72%; fill: var(--ig-motif); }
.ig-tag {
    position: absolute; top: 8px; left: 8px; padding: 1px 8px; border-radius: 999px; font-size: .7em; font-weight: 700;
    letter-spacing: .04em; text-transform: uppercase; background: rgba(255, 255, 255, .82); color: #1f2937;
}
.ig-unavail { display: grid; place-items: center; align-content: center; gap: 4px; background: var(--e-surface); color: var(--e-ink-3); text-align: center; padding: 8px; }
.ig-broken-ico { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ig-unavail-t { font-size: .74em; font-weight: 600; }

.ig-cap { font-size: .84em; line-height: 1.35; color: var(--e-ink-2); overflow-wrap: anywhere; }
.ig-cap-overlay .ig-cap {
    position: absolute; left: 1px; right: 1px; bottom: 1px; padding: 18px 9px 7px; color: #fff; pointer-events: none;
    background: linear-gradient(180deg, transparent, var(--ig-scrim)); border-radius: 0 0 var(--e-radius-sm) var(--e-radius-sm);
    font-size: .8em; font-weight: 600;
}
.ig-issues { margin: 0; padding-left: 28px; }

/* ---------------- lightbox ---------------- */
html.ig-locked, html.ig-locked body { overflow: hidden; }
.ig-lb { position: fixed; left: 0; right: 0; top: 0; height: 100%; z-index: 50; display: flex; background: var(--ig-backdrop); padding: 8px; }
.ig-lb[hidden] { display: none !important; }
.ig-lb-dialog { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 6px; color: #f3f4f6; }
.ig-lb-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ig-lb-count { font-size: .86em; font-weight: 650; font-variant-numeric: tabular-nums; padding-left: 4px; }
.ig-lb-stage { flex: 1; min-height: 0; display: flex; align-items: center; gap: 6px; }
.ig-lb-frame { flex: 1; min-width: 0; height: 100%; display: flex; align-items: center; justify-content: center; touch-action: pan-y; }
.ig-lb-frame .ig-img { width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.ig-lb-frame .ig-sample { width: 100%; max-width: 640px; height: 100%; max-height: 420px; border-radius: 10px; }
.ig-lb-btn {
    flex: none; display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; cursor: pointer;
    color: #fff; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .28); border-radius: 50%;
}
.ig-lb-btn:hover { background: rgba(255, 255, 255, .22); }
.ig-lb-btn:focus-visible, .ig-lb-link:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.ig-lb-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.ig-lb-foot { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; padding: 0 4px 2px; }
.ig-lb-cap { margin: 0; font-size: .88em; line-height: 1.4; overflow-wrap: anywhere; max-height: 4.2em; overflow: auto; }
.ig-lb-link { color: #fff; font-size: .84em; font-weight: 650; text-underline-offset: 2px; }

@media (max-width: 360px) {
    .ig-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
    .ig-lb-stage { gap: 2px; }
}
html[data-compact="1"] .ig-grid, html[data-compact="1"] .ig-strip { gap: 7px; }
