/*
 * SMC Photo Viewer: the single photo viewer for the whole site (and the app, which mirrors the site).
 * Markup is built by assets/js/smc-photo-viewer.js. Icons are inline SVG, never Unicode glyphs.
 * File: /wp-content/themes/smc/assets/css/smc-photo-viewer.css
 */

html.smc-pv-lock,
body.smc-pv-lock {
    overflow: hidden;
}

.smc-pv {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    color: #f8fafc;
    font-family: 'NeueMontreal', system-ui, -apple-system, sans-serif;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s linear 0.22s;
    -webkit-tap-highlight-color: transparent;
}

.smc-pv.is-open {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), visibility 0s;
}

.smc-pv-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.92);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
}

/* Top bar */
.smc-pv-bar {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: calc(env(safe-area-inset-top, 0px) + 12px) max(16px, env(safe-area-inset-right, 0px) + 12px) 8px max(16px, env(safe-area-inset-left, 0px) + 12px);
}

.smc-pv-counter {
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.02em;
    color: rgba(248, 250, 252, 0.82);
    font-variant-numeric: tabular-nums;
    min-height: 20px;
}

.smc-pv-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.smc-pv-btn {
    appearance: none;
    -webkit-appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid rgba(248, 250, 252, 0.16);
    border-radius: 999px;
    background: rgba(15, 23, 42, 0.55);
    color: #f8fafc;
    cursor: pointer;
    transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease, opacity 0.18s ease;
}

.smc-pv-btn svg {
    width: 20px;
    height: 20px;
    display: block;
}

.smc-pv-btn:focus-visible {
    outline: 2px solid #2db6ff;
    outline-offset: 3px;
}

.smc-pv-btn[disabled] {
    opacity: 0.32;
    cursor: default;
}

@media (hover: hover) {
    .smc-pv-btn:not([disabled]):hover {
        background: rgba(45, 182, 255, 0.22);
        border-color: rgba(45, 182, 255, 0.55);
    }
}

/* Stage */
.smc-pv-stage {
    position: relative;
    z-index: 2;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    touch-action: none;
}

.smc-pv-figure {
    position: relative;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 0 max(72px, env(safe-area-inset-left, 0px) + 72px);
    box-sizing: border-box;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.smc-pv-img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 10px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    cursor: zoom-in;
    transform-origin: center center;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.22s ease;
    will-change: transform;
}

.smc-pv.is-zoomed .smc-pv-img {
    cursor: grab;
    border-radius: 0;
}

.smc-pv.is-dragging .smc-pv-img {
    cursor: grabbing;
    transition: none;
}

.smc-pv.is-loading .smc-pv-img {
    opacity: 0;
}

.smc-pv-spinner {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 34px;
    height: 34px;
    margin: -17px 0 0 -17px;
    border-radius: 50%;
    border: 3px solid rgba(248, 250, 252, 0.18);
    border-top-color: #2db6ff;
    animation: smc-pv-spin 0.8s linear infinite;
    display: none;
}

.smc-pv.is-loading .smc-pv-spinner {
    display: block;
}

.smc-pv-error {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: none;
    text-align: center;
    font-size: 15px;
    color: rgba(248, 250, 252, 0.85);
}

.smc-pv.is-error .smc-pv-error {
    display: block;
}

.smc-pv.is-error .smc-pv-img {
    display: none;
}

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

/* Prev / next */
.smc-pv-nav {
    position: absolute;
    top: 50%;
    z-index: 4;
    transform: translateY(-50%);
}

.smc-pv-prev { left: max(16px, env(safe-area-inset-left, 0px) + 12px); }
.smc-pv-next { right: max(16px, env(safe-area-inset-right, 0px) + 12px); }

.smc-pv.is-single .smc-pv-nav,
.smc-pv.is-single .smc-pv-thumbs,
.smc-pv.is-single .smc-pv-counter {
    display: none;
}

/* Caption + thumbnails */
.smc-pv-foot {
    position: relative;
    z-index: 3;
    padding: 10px max(16px, env(safe-area-inset-right, 0px) + 12px) calc(env(safe-area-inset-bottom, 0px) + 14px) max(16px, env(safe-area-inset-left, 0px) + 12px);
    display: grid;
    gap: 10px;
    justify-items: center;
}

.smc-pv-caption {
    max-width: 68ch;
    text-align: center;
    font-size: 14px;
    line-height: 1.5;
    color: rgba(248, 250, 252, 0.86);
    min-height: 0;
}

.smc-pv-caption:empty {
    display: none;
}

.smc-pv-thumbs {
    display: flex;
    gap: 8px;
    max-width: 100%;
    overflow-x: auto;
    padding: 4px 2px;
    scrollbar-width: none;
    scroll-behavior: smooth;
}

.smc-pv-thumbs::-webkit-scrollbar {
    display: none;
}

.smc-pv-thumb {
    appearance: none;
    -webkit-appearance: none;
    flex: 0 0 auto;
    width: 56px;
    height: 56px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.6);
    cursor: pointer;
    opacity: 0.55;
    transition: opacity 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.smc-pv-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.smc-pv-thumb.is-active {
    opacity: 1;
    border-color: #2db6ff;
}

.smc-pv-thumb:focus-visible {
    outline: 2px solid #2db6ff;
    outline-offset: 2px;
}

@media (hover: hover) {
    .smc-pv-thumb:hover {
        opacity: 0.9;
    }
}

@media (max-width: 640px) {
    .smc-pv-figure {
        padding: 0 12px;
    }

    .smc-pv-nav {
        display: none;
    }

    .smc-pv-thumb {
        width: 48px;
        height: 48px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .smc-pv,
    .smc-pv-figure,
    .smc-pv-img,
    .smc-pv-btn,
    .smc-pv-thumb {
        transition: none;
    }
}

/* Triggers: any element with data-smc-photo gets the zoom cursor; pages style the rest. */
[data-smc-photo] {
    cursor: zoom-in;
}
