/* ==========================================================================
   تابلوساز درخشان — Lightbox / image viewer
   Self-contained: works on pages with or without site.css.
   RTL-first. Accent falls back to brand gold when site tokens are absent.
   ========================================================================== */

:root {
    --lb-accent: var(--gold, #b8893b);
    --lb-control: rgba(255, 255, 255, 0.92);
    --lb-control-bg: rgba(26, 22, 17, 0.55);
    --lb-control-bg-hover: rgba(184, 137, 59, 0.92);
}

/* trigger affordance on source images */
[data-lightbox],
[data-lightbox-trigger] {
    cursor: zoom-in;
}

body.lb-lock {
    overflow: hidden;
}

.lb-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(12px, 4vw, 48px);
    background: rgba(15, 12, 8, 0.92);
    backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.lb-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

.lb-figure {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
}

.lb-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: min(94vw, 1400px);
    max-height: 82vh;
    overflow: hidden;
    border-radius: 10px;
    touch-action: none;
}

.lb-img {
    display: block;
    max-width: min(94vw, 1400px);
    max-height: 82vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
    transform: translate(0, 0) scale(1);
    transform-origin: center center;
    transition: transform 0.18s ease;
    cursor: zoom-in;
    user-select: none;
    -webkit-user-drag: none;
}

.lb-stage.is-zoomed .lb-img {
    cursor: grab;
    transition: none;
}

.lb-stage.is-panning .lb-img {
    cursor: grabbing;
    transition: none;
}

.lb-img.is-loading {
    opacity: 0;
}

/* loading spinner */
.lb-spinner {
    position: absolute;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.25);
    border-top-color: var(--lb-accent);
    animation: lb-spin 0.8s linear infinite;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.lb-stage.is-loading .lb-spinner {
    opacity: 1;
}

@keyframes lb-spin {
    to { transform: rotate(360deg); }
}

/* caption + counter */
.lb-caption {
    max-width: min(94vw, 900px);
    color: rgba(255, 255, 255, 0.92);
    font-family: var(--sans, "IranYekanX", Tahoma, Arial, sans-serif);
    font-size: 15px;
    line-height: 1.7;
    text-align: center;
    min-height: 1.7em;
}

.lb-caption:empty {
    display: none;
}

.lb-counter {
    position: absolute;
    inset-block-start: clamp(12px, 3vw, 26px);
    inset-inline-start: clamp(12px, 3vw, 26px);
    padding: 6px 14px;
    border-radius: 999px;
    background: var(--lb-control-bg);
    color: var(--lb-control);
    font-family: var(--sans, "IranYekanX", Tahoma, Arial, sans-serif);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.04em;
    backdrop-filter: blur(8px);
}

/* control buttons */
.lb-btn {
    position: absolute;
    z-index: 2;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 50%;
    background: var(--lb-control-bg);
    color: var(--lb-control);
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: background 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.lb-btn:hover {
    background: var(--lb-control-bg-hover);
    color: #fff;
}

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

.lb-btn svg {
    width: 26px;
    height: 26px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.lb-close {
    inset-block-start: clamp(12px, 3vw, 26px);
    inset-inline-end: clamp(12px, 3vw, 26px);
    width: 46px;
    height: 46px;
}

.lb-nav {
    inset-block-start: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
}

.lb-nav:hover {
    transform: translateY(-50%) scale(1.08);
}

/* physical placement: first (newest) image is on the right in RTL,
   so "previous" sits on the right, "next" on the left. */
.lb-prev { right: clamp(8px, 2.5vw, 28px); }
.lb-next { left: clamp(8px, 2.5vw, 28px); }

.lb-nav[hidden] {
    display: none;
}

@media (max-width: 600px) {
    .lb-nav { width: 44px; height: 44px; }
    .lb-btn svg { width: 22px; height: 22px; }
    .lb-stage,
    .lb-img { max-height: 72vh; }
    .lb-caption { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
    .lb-overlay,
    .lb-img,
    .lb-btn { transition: none; }
    .lb-spinner { animation-duration: 1.6s; }
}
