/* Project gallery: frame + thumbnail strip + lightbox.
 * No JS: the markup stays a plain vertical list of links/images - every rule
 * below that hides slides, fixes the stage height, or shows the bar/thumbs
 * is gated behind .pgal.is-init, a class pgal.js adds on boot. Nothing here
 * is a hardcoded color/size that already has a token in main.css's :root.
 */

.pgal {
    margin: 0 0 var(--space-6);
    font-family: var(--font-body);
}

/* ---------- status bar ---------- */

.pgal__bar {
    display: none;
    align-items: center;
    gap: var(--space-3);
    padding: 0 0 var(--space-2);
}

.pgal.is-init .pgal__bar {
    display: flex;
}

.pgal__counter {
    font-family: var(--font-mono);
    font-size: 12px;
    font-feature-settings: 'tnum';
    color: var(--color-ink-soft);
    white-space: nowrap;
}

.pgal__file {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--color-neutral-700);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1 1 auto;
}

.pgal__actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex: 0 0 auto;
}

.pgal .btn {
    font-family: var(--font-body);
    font-size: 13px;
    line-height: 1.2;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-divider);
    background: var(--color-bg);
    color: var(--color-ink-soft);
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease, color .15s ease;
}

.pgal .btn:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.pgal .btn:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.pgal .btn-ghost {
    padding: 6px 10px;
    background: transparent;
}

.pgal .btn-secondary {
    color: var(--color-accent);
    border-color: var(--color-divider-strong);
}

.pgal .btn-secondary:hover {
    background: var(--color-surface-sunk);
}

/* ---------- stage (large frame) ---------- */

.pgal__stage {
    position: relative;
    border: 1px solid var(--color-divider);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
}

.pgal.is-init .pgal__stage {
    height: 420px;
    overflow: hidden;
}

.pgal__slide {
    display: block;
}

.pgal.is-init .pgal__slide {
    display: none;
}

.pgal.is-init .pgal__slide.is-active {
    display: block;
}

.pgal__slide img {
    width: 100%;
    height: auto;
    display: block;
}

.pgal.is-init .pgal__slide {
    cursor: zoom-in;
}

/* Bottom gradient hints that the frame is cropped, not the whole screenshot */
.pgal.is-init .pgal__stage::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 72px;
    background: linear-gradient(to bottom, transparent, var(--color-surface));
    pointer-events: none;
}

/* ---------- thumbnail strip ---------- */

.pgal__thumbs {
    display: none;
    list-style: none;
    margin: var(--space-3) 0 0;
    padding: 0 0 var(--space-1);
    gap: var(--space-2);
    overflow-x: auto;
    scrollbar-width: thin;
}

.pgal.is-init .pgal__thumbs {
    display: flex;
}

.pgal__thumbs li {
    flex: 0 0 auto;
}

.pgal__thumb {
    display: block;
    padding: 0;
    border: 1px solid var(--color-divider);
    border-radius: var(--radius-sm);
    background: none;
    cursor: pointer;
    line-height: 0;
}

.pgal__thumb:hover {
    border-color: var(--color-divider-strong);
}

.pgal__thumb.is-active {
    border-color: var(--color-accent);
}

.pgal__thumb:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.pgal__thumb img {
    width: 104px;
    height: 68px;
    object-fit: cover;
    object-position: top;
    display: block;
    border-radius: calc(var(--radius-sm) - 1px);
}

@media (max-width: 1020px) {
    .pgal.is-init .pgal__stage {
        height: 320px;
    }
}

@media (max-width: 768px) {
    .pgal.is-init .pgal__stage {
        height: 200px;
    }

    .pgal__thumb img {
        width: 76px;
        height: 50px;
    }

    .pgal__file {
        display: none;
    }
}

/* ---------- lightbox (single node, created by pgal.js on first open) ---------- */

.pgal-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: color-mix(in srgb, #201f1d 88%, transparent);
    flex-direction: column;
}

.pgal-lightbox.is-open {
    display: flex;
}

.pgal-lightbox__bar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    color: #fff;
}

.pgal-lightbox__counter {
    font-family: var(--font-mono);
    font-size: 12px;
    font-feature-settings: 'tnum';
    white-space: nowrap;
}

.pgal-lightbox__file {
    font-family: var(--font-mono);
    font-size: 11px;
    color: #c9cfce;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1 1 auto;
}

.pgal-lightbox__bar .btn {
    background: transparent;
    border-color: rgba(255, 255, 255, .28);
    color: #fff;
}

.pgal-lightbox__bar .btn:hover {
    border-color: #fff;
    color: #fff;
    background: rgba(255, 255, 255, .1);
}

.pgal-lightbox__body {
    position: relative;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    padding: 0 var(--space-6) var(--space-5);
}

.pgal-lightbox__body.is-full {
    overflow: auto;
    align-items: flex-start;
    justify-content: flex-start;
    cursor: grab;
}

.pgal-lightbox__body.is-full.is-dragging {
    cursor: grabbing;
}

.pgal-lightbox__img {
    display: block;
}

.pgal-lightbox__body:not(.is-full) .pgal-lightbox__img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.pgal-lightbox__body.is-full .pgal-lightbox__img {
    width: auto;
    height: auto;
    max-width: none;
    max-height: none;
}

.pgal-lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .28);
    background: rgba(32, 31, 29, .5);
    color: #fff;
    font-size: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.pgal-lightbox__nav:hover {
    border-color: #fff;
    background: rgba(32, 31, 29, .75);
}

.pgal-lightbox__nav:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

.pgal-lightbox__prev {
    left: var(--space-4);
}

.pgal-lightbox__next {
    right: var(--space-4);
}

@media (max-width: 768px) {
    .pgal-lightbox__nav {
        display: none;
    }

    .pgal-lightbox__body {
        padding: 0 var(--space-2) var(--space-3);
    }
}

@media (prefers-reduced-motion: no-preference) {
    .pgal-lightbox {
        transition: opacity .12s ease;
    }
}
