/**
 * NextExtManager - news article pictures and lightbox (view=newsitem, SSR).
 *
 * Plain CSS rather than template utilities: tpl_nextsoftware's Tailwind is a
 * static build, so new utility classes would do nothing until it is rebuilt.
 * The text styles of the article body stay in the template (tailwind.config.css).
 */

/* The article sits on a card: fold fades end in the card colour, not the page. */
.nem-newsitem-body[data-image-fold] { --nem-fold-fade: var(--nxt-surface, #fff); }

/* Pictures: framed, centred when narrower than the column (phone screens). */
.nem-newsitem-body[data-image-fold] img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 1.75rem auto;
    border: 1px solid var(--nxt-border, #e5e7eb);
    border-radius: var(--nxt-radius-lg, 12px);
    background-color: var(--nxt-bg-alt, #f8fafc);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 12px 28px -18px rgba(15, 23, 42, .35);
    cursor: zoom-in;
}
.nem-newsitem-body[data-image-fold] img:focus-visible { outline: 3px solid var(--nxt-primary, #1d4ed8); outline-offset: 3px; }

/* <figure> has no reset in the template (preflight is off): UA margins indent it 40px. */
.nem-newsitem-body[data-image-fold] figure { margin: 2.25rem 0; padding: 0; }
.nem-newsitem-body[data-image-fold] figure img { margin: 0 auto; }

.nem-newsitem-body[data-image-fold] figcaption {
    max-width: 40rem;
    margin: .875rem auto 0;
    padding: 0 .5rem;
    text-align: center;
    font-size: .875rem;
    line-height: 1.55;
    color: var(--nxt-text-secondary, #64748b);
    text-wrap: pretty;
}

/* Fold wrapper (js/imagefold.js): centre the frame and its toggle under the picture. */
.nem-newsitem-body[data-image-fold] .nem-img-fold { display: flex; flex-direction: column; align-items: center; margin: 1.75rem 0; }
.nem-newsitem-body[data-image-fold] figure .nem-img-fold { margin: 0; }
.nem-newsitem-body[data-image-fold] .nem-img-fold__frame { max-width: 100%; border-radius: var(--nxt-radius-lg, 12px); }
.nem-newsitem-body[data-image-fold] .nem-img-fold.is-foldable:not(.is-open) .nem-img-fold__frame { box-shadow: 0 12px 28px -18px rgba(15, 23, 42, .35); }
.nem-newsitem-body[data-image-fold] .nem-img-fold img { margin: 0; }
.nem-newsitem-body[data-image-fold] .nem-img-fold.is-foldable .nem-img-fold__toggle { margin-top: .75rem; }

/* ---------------------------------------------------------------- Lightbox */

.nem-lb {
    position: fixed;
    inset: 0;
    z-index: 1700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3.5rem 4.5rem 1.5rem;
    background: rgba(9, 12, 20, .96);
    overscroll-behavior: contain;
}
.nem-lb__figure {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .875rem;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
}
.nem-lb__img {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 9rem);
    max-height: calc(100dvh - 9rem);
    width: auto;
    height: auto;
    border-radius: var(--nxt-radius-md, 8px);
    background-color: #fff;
    box-shadow: 0 24px 60px -12px rgba(0, 0, 0, .6);
    object-fit: contain;
}
.nem-lb__caption {
    display: flex;
    align-items: baseline;
    justify-content: center;
    flex-wrap: wrap;
    gap: .25rem .875rem;
    max-width: 44rem;
    text-align: center;
    font-size: .9375rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, .88);
}
.nem-lb__count {
    font-size: .8125rem;
    font-variant-numeric: tabular-nums;
    color: rgba(255, 255, 255, .55);
    white-space: nowrap;
}
.nem-lb__btn {
    position: absolute;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .18);
    border-radius: 999px;
    background: rgba(255, 255, 255, .08);
    color: #fff;
    cursor: pointer;
    transition: background-color .15s;
}
.nem-lb__btn:hover { background: rgba(255, 255, 255, .18); }
.nem-lb__btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.nem-lb__btn svg { width: 1.5rem; height: 1.5rem; fill: currentColor; }
.nem-lb__close { top: .875rem; right: .875rem; }
.nem-lb__prev { left: .875rem; top: 50%; transform: translateY(-50%); }
.nem-lb__next { right: .875rem; top: 50%; transform: translateY(-50%); }

/* Phones: the arrows move under the picture so they never cover it (swipe works too). */
@media (max-width: 599px) {
    .nem-lb { padding: 3.75rem .75rem 5rem; }
    .nem-lb__img { max-height: calc(100vh - 11rem); max-height: calc(100dvh - 11rem); }
    .nem-lb__prev, .nem-lb__next { top: auto; bottom: 1rem; transform: none; }
    .nem-lb__prev { left: calc(50% - 3.5rem); }
    .nem-lb__next { right: calc(50% - 3.5rem); }
}

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