/* Stratal public site: the picture viewer (js/lightbox.js) and the picture links that open it. Uses the design tokens of
   css/portal.css (loaded first on every page): graphite overlay, white text for the caption, electric blue for focus.
   Motion only for visitors who have not asked for less. */

/* The picture links on the page: the picture itself, with a small "enlarge" mark in its corner. */
.zoom { display: block; position: relative; border-radius: var(--r-3); color: inherit; cursor: zoom-in; }
.zoom:focus-visible { outline: 2px solid var(--blue-400); outline-offset: 3px; }
.zoom::after {
    content: ""; position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 50%;
    background: rgba(11, 13, 16, .78) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f3f6f9' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 3h6v6M9 21H3v-6M21 3l-7 7M3 21l7-7'/%3E%3C/svg%3E") center / 18px 18px no-repeat;
    border: 1px solid rgba(255, 255, 255, .16); opacity: 0; pointer-events: none;
}
.zoom:hover::after, .zoom:focus-visible::after { opacity: 1; }
@media (hover: none) { .zoom::after { opacity: .9; width: 32px; height: 32px; top: 10px; right: 10px; } }
.plugin-hero .zoom { border-radius: 0; }
.zoom-text { white-space: nowrap; }

/* The page behind an open viewer does not scroll. */
html.lb-lock, html.lb-lock body { overflow: hidden; }

/* The viewer: bar (count, close), the picture between previous and next, the caption underneath. */
.lb {
    position: fixed; inset: 0; z-index: 100; display: grid;
    grid-template-columns: 76px minmax(0, 1fr) 76px; grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "bar bar bar" "prev stage next" "cap cap cap";
    background: rgba(6, 8, 10, .975); color: var(--text); overscroll-behavior: contain;
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.lb[hidden] { display: none; }
.lb-bar { grid-area: bar; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 14px 4px 22px; min-height: 64px; }
.lb-count { margin: 0; color: var(--text-3); font-size: .95rem; font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.lb-stage { grid-area: stage; position: relative; display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0; padding: 4px 8px; }
.lb-img {
    display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain;
    border-radius: var(--r-2); background: var(--g-900); box-shadow: 0 30px 80px -30px #000, 0 0 0 1px rgba(255, 255, 255, .06);
}
.lb.is-loading .lb-img { visibility: hidden; }
.lb-state { position: absolute; max-width: 40ch; margin: 0; padding: 14px 18px; text-align: center; color: var(--text-2); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-2); }
.lb.is-loading .lb-stage::before {
    content: ""; position: absolute; width: 34px; height: 34px; border-radius: 50%;
    border: 3px solid var(--g-600); border-top-color: var(--blue-400);
}
.lb-caption {
    grid-area: cap; margin: 0 auto; padding: 14px 24px 22px; max-width: 80ch; text-align: center;
    color: var(--text-2); font-size: 1.02rem; line-height: 1.5;
}

/* Buttons: round, graphite, white glyphs; focus ring in the site's blue. */
.lb-btn {
    display: inline-grid; place-items: center; width: 48px; height: 48px; min-height: 48px; padding: 0; margin: 0;
    border-radius: 50%; border: 1px solid rgba(255, 255, 255, .14); background: rgba(27, 33, 41, .86); color: #fff; cursor: pointer;
    box-shadow: none;
}
.lb-btn:hover { background: var(--g-700); border-color: rgba(255, 255, 255, .28); }
.lb-btn:focus-visible { outline: 2px solid var(--blue-300); outline-offset: 3px; }
.lb-btn[hidden] { display: none; }
.lb-nav { align-self: center; justify-self: center; }
.lb-prev { grid-area: prev; }
.lb-next { grid-area: next; }

/* Phones: the picture full width, previous and next under it, either side of the caption's line. */
@media (max-width: 700px) {
    .lb {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr) auto auto;
        grid-template-areas: "bar bar" "stage stage" "prev next" "cap cap";
    }
    .lb-bar { padding: 8px 10px 2px 16px; min-height: 58px; }
    .lb-stage { padding: 2px 0; }
    .lb-img { border-radius: 0; }
    .lb-nav { margin-top: 10px; }
    .lb-prev { justify-self: start; margin-left: 16px; }
    .lb-next { justify-self: end; margin-right: 16px; }
    .lb-caption { padding: 10px 16px 18px; font-size: .96rem; }
}

/* Motion: a short fade in and a spinning load mark, never for visitors who asked for reduced motion. */
@media (prefers-reduced-motion: no-preference) {
    .zoom::after { transition: opacity var(--fast) var(--ease); }
    .lb { opacity: 0; transition: opacity 180ms var(--ease); }
    .lb.is-open { opacity: 1; }
    .lb-img { transition: opacity 160ms var(--ease); }
    .lb.is-loading .lb-stage::before { animation: lb-spin .8s linear infinite; }
    @keyframes lb-spin { to { transform: rotate(360deg); } }
}

@media print { .lb { display: none; } .zoom::after { display: none; } }
