/* ==========================================================================
   Besee Client Gallery — Frontend Styles
   Inherits oaknut theme tokens where available.
   ========================================================================== */

:root {
    --bcgal-gap:     9px;
    --bcgal-radius:  0px;
    --bcgal-accent:  var(--wp--preset--color--foreground, #111);
    --bcgal-text:    var(--wp--preset--color--foreground, #111);
    --bcgal-muted:   color-mix(in srgb, var(--bcgal-text) 55%, transparent);
    --bcgal-bg:      var(--wp--preset--color--background, #f7f7f7);
    --bcgal-border:  color-mix(in srgb, var(--bcgal-text) 12%, transparent);
    --bcgal-card-bg: color-mix(in srgb, var(--bcgal-bg) 88%, var(--bcgal-text) 12%);
    --bcgal-font:    var(--wp--preset--font-family--body, inherit);
}

/* ==========================================================================
   1. Gate — password page
   ========================================================================== */

.bcgal-gate-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 48px 16px;
    font-family: var(--bcgal-font);
}

.bcgal-gate-box {
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.bcgal-gate-for {
    margin: 0 0 4px;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--bcgal-muted);
}

.bcgal-gate-title {
    margin: 0 0 28px;
    font-size: clamp(1.4rem, 4vw, 2rem);
    font-weight: 600;
    line-height: 1.25;
    color: var(--bcgal-text);
}

/* Notices */
.bcgal-notice {
    margin-bottom: 20px;
    padding: 12px 16px;
    border-radius: var(--bcgal-radius);
    font-size: 0.9rem;
    line-height: 1.5;
}

.bcgal-notice--error {
    background: #fef0f0;
    color: #c0392b;
    border: 1px solid #f5c6c6;
}

.bcgal-notice--expired {
    background: var(--bcgal-card-bg);
    color: var(--bcgal-muted);
    border: 1px solid var(--bcgal-border);
}

/* Gate form */
.bcgal-gate-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bcgal-gate-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--bcgal-muted);
    text-align: left;
}

.bcgal-gate-input {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 11px 14px;
    border: 1px solid var(--bcgal-border);
    background: var(--bcgal-bg);
    color: var(--bcgal-text);
    font-size: 1rem;
    font-family: var(--bcgal-font);
    outline: none;
    transition: border-color 0.15s;
}

.bcgal-gate-input:focus {
    border-color: var(--bcgal-accent);
}

.bcgal-gate-btn {
    position: relative;
    display: block;
    width: 100%;
    padding: 12px 20px;
    border: 1px solid var(--bcgal-border);
    background: transparent;
    color: var(--bcgal-text);
    font-size: 0.85rem;
    font-family: var(--bcgal-font);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.15s;
}

.bcgal-gate-btn:hover { background: var(--bcgal-card-bg); }

.bcgal-gate-btn-loading { display: none; }
.bcgal-gate-btn.is-loading .bcgal-gate-btn-label { visibility: hidden; }
.bcgal-gate-btn.is-loading .bcgal-gate-btn-loading {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
}

/* ==========================================================================
   2. Gallery view — header
   ========================================================================== */

.bcgal-gallery-wrap {
    max-width: min(1600px, 100%);
    margin: 0 auto;
    padding: 0 22px 64px;
    font-family: var(--bcgal-font);
}

.bcgal-gallery-header {
    padding: 36px 0 24px;
    border-bottom: 1px solid var(--bcgal-border);
    margin-bottom: 24px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.bcgal-gallery-header-meta {
    display: flex;
    gap: 12px;
    align-items: center;
    width: 100%;
    margin-bottom: 4px;
}

.bcgal-gallery-client {
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--bcgal-muted);
}

.bcgal-gallery-client + .bcgal-gallery-date::before {
    content: '·';
    margin-right: 12px;
    color: var(--bcgal-border);
}

.bcgal-gallery-date {
    font-size: 0.8rem;
    color: var(--bcgal-muted);
}

.bcgal-gallery-title {
    margin: 0;
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    font-weight: 400;
    letter-spacing: 0.04em;
    line-height: 1.2;
    color: var(--bcgal-text);
    flex: 1;
}

.bcgal-gallery-actions { flex-shrink: 0; }

/* ==========================================================================
   3. Photo grid — flex column masonry, natural aspect ratio (oaknut style)
   ========================================================================== */

.bcgal-photo-grid {
    /* display:flex + gap set via inline style from bcgal_enqueue_frontend_assets() */
    display: flex;
    align-items: flex-start;
}

/* Each explicit column div */
.bcgal-col {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    /* gap set via inline style */
}

.bcgal-grid-item {
    display: block;
    padding: 9px;
    border: 1px solid var(--bcgal-border);
    background: var(--bcgal-card-bg);
    box-sizing: border-box;
    overflow: hidden;
    cursor: zoom-in;
    position: relative;
}

.bcgal-grid-img {
    display: block;
    width: 100%;
    height: auto;
    transition: transform 0.3s ease;
    pointer-events: none;
    /* Placeholder background while image loads (browser uses width/height attrs for aspect ratio) */
    background: color-mix(in srgb, var(--wp--preset--color--foreground, #111) 6%, transparent);
}

.bcgal-grid-item:hover .bcgal-grid-img {
    transform: scale(1.03);
}

.bcgal-grid-item:focus {
    outline: 2px solid var(--bcgal-accent);
    outline-offset: 2px;
}

.bcgal-empty {
    color: var(--bcgal-muted);
    text-align: center;
    padding: 48px 0;
}

/* ==========================================================================
   4. Shared button
   ========================================================================== */

.bcgal-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    font-size: 0.8rem;
    font-family: var(--bcgal-font);
    font-weight: 400;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid var(--bcgal-border);
    background: transparent;
    color: var(--bcgal-text);
    transition: background 0.15s, opacity 0.15s;
    line-height: 1.4;
    white-space: nowrap;
}

.bcgal-btn:hover {
    background: var(--bcgal-card-bg);
    opacity: 1;
    text-decoration: none;
    color: var(--bcgal-text);
}

.bcgal-btn--filled {
    background: var(--bcgal-accent);
    color: var(--bcgal-bg);
    border-color: var(--bcgal-accent);
}

.bcgal-btn--filled:hover {
    background: var(--bcgal-accent);
    color: var(--bcgal-bg);
    opacity: 0.82;
}

.bcgal-count-badge {
    background: var(--bcgal-border);
    color: var(--bcgal-muted);
    border-radius: 999px;
    padding: 1px 7px;
    font-size: 0.75rem;
}

/* ==========================================================================
   5. Lightbox
   ========================================================================== */

/* Backdrop — no opacity transition, instant show/hide */
.bcgal-lb-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bcgal-bg);
    z-index: 100000;
}

/* Show backdrop when lightbox is open OR when close-animation is running */
.bcgal-lightbox[aria-hidden="false"] + .bcgal-lb-backdrop,
.bcgal-lb-backdrop.is-closing {
    display: block;
}

/* Lightbox shell — above WP admin bar (z-index 99999) */
.bcgal-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100001;
    flex-direction: column;
    outline: none;
    background: var(--bcgal-bg);
}

.bcgal-lightbox[aria-hidden="false"] {
    display: flex;
}

/* Hide lightbox entirely during transition — only the ghost + backdrop are visible */
.bcgal-lightbox.is-transitioning {
    background: transparent;
}

.bcgal-lightbox.is-transitioning .bcgal-lb-toolbar,
.bcgal-lightbox.is-transitioning .bcgal-lb-stage,
.bcgal-lightbox.is-transitioning .bcgal-lb-footer {
    visibility: hidden;
    opacity: 0;
}

/* Shared element transition — ghost image */
.bcgal-ghost {
    position: fixed;
    z-index: 100002;
    pointer-events: none;
    will-change: transform, width, height, top, left, border-radius;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    object-fit: cover;
    background: color-mix(in srgb, var(--wp--preset--color--foreground, #111) 6%, transparent);
}

.bcgal-ghost.is-to-lightbox {
    object-fit: contain;
    border-radius: 0;
}

/* Top toolbar */
.bcgal-lb-toolbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 18px;
    border-bottom: 1px solid var(--bcgal-border);
    background: transparent;
    z-index: 2;
    gap: 12px;
}

.bcgal-lb-toolbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.bcgal-lb-toolbar-right {
    display: flex;
    align-items: center;
}

/* Counter */
.bcgal-lb-counter-toolbar {
    font-size: 0.8rem;
    font-family: var(--bcgal-font);
    letter-spacing: 0.06em;
    color: var(--bcgal-muted);
}

/* Nav buttons — sides of stage */
.bcgal-lb-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: 1px solid var(--bcgal-border);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bcgal-text);
    font-size: 1.4rem;
    cursor: pointer;
    z-index: 2;
    transition: background 0.15s;
    padding: 0;
}

.bcgal-lb-nav:hover { background: var(--bcgal-card-bg); }

.bcgal-lb-nav:disabled {
    opacity: 0.15;
    cursor: default;
}

.bcgal-lb-prev { left: 12px; }
.bcgal-lb-next { right: 12px; }

/* Stage */
.bcgal-lb-stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    overflow: hidden;
    padding: 16px 68px;
    box-sizing: border-box;
    background: transparent;
}

.bcgal-lb-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    transition: opacity 0.18s;
    pointer-events: none;
}

.bcgal-lb-img.is-loading { opacity: 0; }
.bcgal-lb-img.is-hidden-for-transition { opacity: 0 !important; transition: none !important; }

/* Spinner */
.bcgal-lb-spinner {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.bcgal-lb-spinner::after {
    content: '';
    width: 28px;
    height: 28px;
    border: 2px solid var(--bcgal-border);
    border-top-color: var(--bcgal-muted);
    border-radius: 50%;
    animation: bcgal-spin 0.7s linear infinite;
}

.bcgal-lb-spinner.is-hidden { display: none; }

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

/* Footer — filename */
.bcgal-lb-footer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 18px 12px;
    background: transparent;
    border-top: 1px solid var(--bcgal-border);
}

.bcgal-lb-filename {
    color: var(--bcgal-muted);
    font-size: 0.75rem;
    font-family: var(--bcgal-font);
    letter-spacing: 0.04em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ==========================================================================
   6. Proofing — hearts, counter, submit
   ========================================================================== */

/* Heart button on grid cards */
.bcgal-heart {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.35);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.18s, background 0.15s, transform 0.15s;
}

.bcgal-heart svg {
    fill: rgba(255, 255, 255, 0.8);
    stroke: none;
    transition: fill 0.15s;
}

.bcgal-grid-item:hover .bcgal-heart,
.bcgal-heart.is-selected {
    opacity: 1;
}

.bcgal-heart.is-selected {
    background: rgba(220, 50, 50, 0.85);
}

.bcgal-heart.is-selected svg {
    fill: #fff;
}

.bcgal-heart:hover {
    transform: scale(1.1);
}

.bcgal-heart:disabled {
    cursor: default;
    opacity: 0.6;
}

.bcgal-heart:disabled:hover {
    transform: none;
}

/* Lightbox heart */
.bcgal-lb-heart svg {
    fill: var(--bcgal-muted);
    stroke: none;
    transition: fill 0.15s;
}

.bcgal-lb-heart.is-selected {
    color: #dc3232;
    border-color: #dc3232;
}

.bcgal-lb-heart.is-selected svg {
    fill: #dc3232;
}

/* Selection counter in header */
.bcgal-selection-counter {
    font-size: 0.8rem;
    font-family: var(--bcgal-font);
    letter-spacing: 0.06em;
    color: var(--bcgal-muted);
    white-space: nowrap;
}

/* Filter tabs (All / Selected / Unselected) */
.bcgal-filter-tabs {
    display: flex;
    gap: 6px;
    width: 100%;
    padding-top: 14px;
    border-top: 1px solid var(--bcgal-border);
    margin-top: 14px;
}

.bcgal-filter-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    font-size: 0.75rem;
    font-family: var(--bcgal-font);
    font-weight: 400;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--bcgal-muted);
    background: transparent;
    border: 1px solid var(--bcgal-border);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    white-space: nowrap;
}

.bcgal-filter-tab:hover {
    color: var(--bcgal-text);
    border-color: color-mix(in srgb, var(--bcgal-text) 35%, transparent);
}

.bcgal-filter-tab.is-active {
    color: var(--bcgal-text);
    border-color: var(--bcgal-text);
    background: color-mix(in srgb, var(--bcgal-text) 6%, transparent);
}

.bcgal-tab-count {
    font-size: 0.7rem;
    opacity: 0.7;
}

.bcgal-filter-tab.is-active .bcgal-tab-count {
    opacity: 1;
}

/* Infinite scroll — load-more sentinel + spinner */
.bcgal-load-sentinel {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 32px 0 16px;
}
.bcgal-load-spinner {
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 2px solid color-mix(in srgb, var(--wp--preset--color--foreground, #111) 15%, transparent);
    border-top-color: color-mix(in srgb, var(--wp--preset--color--foreground, #111) 55%, transparent);
    border-radius: 50%;
    animation: bcgal-spin 0.7s linear infinite;
}

/* No-access proofing notice (visited without client token) */
.bcgal-proofing-notice {
    display: inline-flex;
    align-items: center;
    padding: 7px 16px;
    font-size: 0.78rem;
    font-family: var(--bcgal-font);
    letter-spacing: 0.04em;
    color: color-mix(in srgb, var(--wp--preset--color--foreground, #111) 50%, transparent);
    border: 1px solid color-mix(in srgb, var(--wp--preset--color--foreground, #111) 20%, transparent);
}

/* Submitted badge */
.bcgal-selection-submitted-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 7px 16px;
    font-size: 0.8rem;
    font-family: var(--bcgal-font);
    font-weight: 600;
    letter-spacing: 0.06em;
    color: #00a32a;
    border: 1px solid #00a32a;
    white-space: nowrap;
}

/* Submit confirmation dialog */
.bcgal-confirm-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200000;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.bcgal-confirm-overlay[aria-hidden="false"] {
    display: flex;
}

.bcgal-confirm-dialog {
    background: canvas;
    background-color: canvas;
    border: 1px solid var(--bcgal-border);
    padding: 32px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    font-family: var(--bcgal-font);
}

.bcgal-confirm-dialog h3 {
    margin: 0 0 12px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--bcgal-text);
}

.bcgal-confirm-msg {
    margin: 0 0 24px;
    font-size: 0.9rem;
    color: var(--bcgal-muted);
    line-height: 1.6;
}

.bcgal-confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* ==========================================================================
   7. Filename overlay (toggled via body.bcgal-show-filename)
   ========================================================================== */

.bcgal-show-filename .bcgal-grid-item::after {
    content: attr(data-filename);
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 24px 8px 8px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.55));
    color: #fff;
    font-size: 0.7rem;
    font-family: var(--bcgal-font);
    letter-spacing: 0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    transition: opacity 0.18s;
    pointer-events: none;
}

.bcgal-show-filename .bcgal-grid-item:hover::after {
    opacity: 1;
}

/* ==========================================================================
   8. Responsive
   ========================================================================== */

/* Columns are injected via inline style from PHP settings — no overrides here */

@media (max-width: 800px) {
    .bcgal-gallery-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .bcgal-gallery-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        align-items: center;
        width: 100%;
    }

    .bcgal-lb-toolbar {
        padding: 8px 12px;
        gap: 8px;
    }

    .bcgal-lb-toolbar-right {
        flex-wrap: wrap;
        gap: 4px;
    }

    .bcgal-lb-toolbar-right .bcgal-btn {
        font-size: 0.7rem;
        padding: 5px 10px;
    }

    .bcgal-lb-stage { padding: 12px 52px; }
    .bcgal-lb-prev { left: 6px; }
    .bcgal-lb-next { right: 6px; }
    .bcgal-lb-nav { width: 34px; height: 34px; }

    /* Heart buttons easier to tap on mobile */
    .bcgal-heart {
        width: 40px;
        height: 40px;
        opacity: 1;
    }

    .bcgal-confirm-dialog {
        padding: 24px 20px;
        margin: 16px;
    }
}

@media (max-width: 480px) {
    .bcgal-lb-stage { padding: 8px 44px; }

    .bcgal-lb-toolbar-left .bcgal-lb-close {
        font-size: 0.7rem;
        padding: 5px 8px;
    }
}
