@font-face {
    font-family: 'Berkeley Mono';
    src: url('/fonts/BerkeleyMono-Regular.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
}

* {
    margin: 0;
    padding: 0;
}

/* Loading screen */
#loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    font-family: 'Berkeley Mono', monospace;
    color: #ffffff;
    transition: opacity 3s ease-out;
}

#loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-bar {
    font-size: 0.875rem;
    letter-spacing: 0;
    line-height: 1.1;
    color: #444444;
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.8));
    opacity: 1;
    transition: opacity 1s ease-out;
}

#loading.clickable .loading-bar:hover {
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.loading-bar-top,
.loading-bar-mid,
.loading-bar-bottom {
    white-space: pre;
}

#loading-progress {
    color: #ffffff;
}

#loading-remaining {
    color: #222222;
}

.loading-percent {
    font-size: 0.875rem;
    margin-top: 0.5rem;
    color: #aaaaaa;
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.8));
    opacity: 1;
    transition: opacity 1s ease-out;
}

#loading.fade-content .loading-bar,
#loading.fade-content .loading-percent {
    opacity: 0;
}

html,
body {
    overflow: hidden;
    width: 100%;
    height: 100%;
    background-color: #000000;
}

#webgl {
    position: fixed;
    top: 0;
    left: 0;
    outline: none;
    pointer-events: none;
}

/* Panels container - just a holder, positioning done per-panel */
#panels-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#panels-container iframe {
    border: none;
    border-radius: 8px;
    box-shadow:
        0 12px 48px rgba(0, 0, 0, 0.7),
        0 4px 16px rgba(0, 0, 0, 0.4);
}

/* Index panel - initially shows just header (collapsed), expands on click */
#index-panel-iframe {
    position: fixed;
    top: 60px;
    left: 60px;
    opacity: 0;
    height: 60px; /* Collapsed - just shows header */
    overflow: hidden;
    pointer-events: auto;
    transition:
        height 0.8s ease-in-out,
        opacity 1s ease-in-out;
}

#index-panel-iframe.visible {
    opacity: 1;
}

#index-panel-iframe.expanded {
    /* Height is set dynamically via JavaScript based on content */
    max-height: calc(100vh - 120px); /* Don't exceed available vertical space */
}

/* Body panel - positioned to the right of index panel */
.body-panel-iframe {
    position: fixed;
    top: 60px; /* Same vertical position as index panel */
    left: 380px; /* 60px (index left) + 280px (index width) + 40px (gap) */
    width: 600px;
    height: calc(
        100vh - 120px
    ); /* Fill vertical space with equal 60px margins top/bottom */
    opacity: 0;
    pointer-events: none; /* Non-interactive by default */
    transition: opacity 0.8s ease-in-out;
}

.body-panel-iframe.visible {
    opacity: 1;
    pointer-events: auto;
    z-index: 2;
    visibility: visible;
}

.body-panel-iframe.hidden {
    opacity: 0;
    pointer-events: none;
    z-index: 1;
    visibility: hidden;
}

/* Overlay container for panels */
#overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

/* Plaque - bottom right corner */
#plaque {
    position: fixed;
    bottom: 60px;
    right: 60px;
    font-family: 'Berkeley Mono', monospace;
    color: #ffffff;
    text-align: right;
    z-index: 10;
    background: #000000;
    padding: 20px 24px;
    border-radius: 8px;
    box-shadow:
        0 12px 48px rgba(0, 0, 0, 0.7),
        0 4px 16px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transition: opacity 1s ease-in-out;
}

#plaque.visible {
    opacity: 1;
}

.plaque-title {
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.4;
}

.plaque-credit {
    font-size: 0.875rem;
    color: #aaaaaa;
    margin-top: 0.25rem;
}

.plaque-credit a {
    color: #aaaaaa;
    text-decoration: underline;
    transition: opacity 0.2s ease;
}

.plaque-credit a:hover {
    opacity: 0.7;
}

/* Photography Overlay */
#photography-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    overflow: hidden;
    transition: background 0.8s ease-in-out;
    transition-delay: 0.3s; /* Wait for content to fade out first */
}

#photography-overlay.visible {
    pointer-events: auto;
    background: rgba(0, 0, 0, 1);
    transition-delay: 0s; /* No delay when fading in */
}

/* Content fades in after background, fades out before background */
#photography-overlay .photo-layout,
#photography-overlay .photo-carousel,
#photography-overlay .photo-footer,
#photography-overlay .photo-close {
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
    transition-delay: 0s; /* No delay when fading out */
}

#photography-overlay.visible .photo-layout,
#photography-overlay.visible .photo-carousel,
#photography-overlay.visible .photo-footer,
#photography-overlay.visible .photo-close {
    opacity: 1;
    transition-delay: 0.7s; /* Wait for background to fade in */
}

/* Close button */
.photo-close {
    position: absolute;
    top: 40px;
    right: 40px;
    background: none;
    border: none;
    color: #666666;
    font-size: 2rem;
    font-family: 'Berkeley Mono', monospace;
    cursor: pointer;
    padding: 10px;
    line-height: 1;
    transition: color 0.2s ease;
    z-index: 10;
}

.photo-close:hover {
    color: #ffffff;
}

.photo-close:focus {
    outline: none;
}

/* Split layout: left sidebar + right carousel */
.photo-layout {
    display: flex;
    align-items: center;
    width: 100%;
    height: 100%;
    gap: 40px;
    padding: 0 60px;
    box-sizing: border-box;
}

/* Left sidebar: toggle, nav, meta */
.photo-sidebar {
    width: 20%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    flex-shrink: 0;
    gap: 16px;
    font-family: 'Berkeley Mono', monospace;
}

/* Nav row: ^ 005 v inline */
.photo-nav-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Photo carousel — full height, clips via overlay */
.photo-carousel {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    isolation: isolate;
    width: 80%;
    height: 100%;
}

.photo-slot {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    transition: transform 0.7s cubic-bezier(0.4, 0, 0.05, 1);
}

/* Wrapper that sizes to image — anchor for absolutely-positioned metadata */
.photo-slot-anchor {
    position: relative;
}

/* Hide slots with no image */
.photo-slot .photo-image[src=''] {
    visibility: hidden;
}

/* Disable transition for instant repositioning */
.photo-slot.no-transition {
    transition: none !important;
}

/* Photo frame container */
.photo-frame {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    overflow: hidden;
}

.photo-image {
    width: auto;
    max-width: min(60vw, 1400px);
    max-height: 90vh;
    height: auto;
    user-select: none;
    -webkit-user-drag: none;
    transition:
        opacity 0.15s ease,
        filter 0.6s ease,
        transform 0.6s ease;
}

/* Blur-up LQIP: blurred low-quality placeholder fades to sharp */
.photo-image.lqip {
    filter: blur(25px);
    transform: scale(1.05);
}

/* Small format - printed photograph style */
.photo-frame.format-small {
    padding: min(1.25vw, 20px);
    background: #fdfbf7;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Small borderless format - small size, no border */
.photo-frame.format-small_borderless {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Scan/Edit toggle pill */
.photo-toggle {
    display: flex;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    transition:
        visibility 0s,
        opacity 0.2s ease;
}

.photo-toggle.hidden {
    visibility: hidden;
    opacity: 0;
    transition:
        visibility 0s 0.2s,
        opacity 0.2s ease;
}

.photo-toggle-btn {
    font-family: 'Berkeley Mono', monospace;
    font-size: 0.625rem;
    color: #666666;
    text-transform: lowercase;
    letter-spacing: 0.05em;
    background: none;
    border: none;
    padding: 6px 12px;
    cursor: pointer;
    transition:
        color 0.2s ease,
        background 0.2s ease;
}

.photo-toggle-btn:hover {
    color: #999999;
}

.photo-toggle-btn.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.15);
}

.photo-toggle-btn.disabled {
    color: #333333;
    cursor: default;
}

.photo-toggle-btn.disabled:hover {
    color: #333333;
}

/* Navigation arrows — inline in sidebar */
.photo-nav {
    background: none;
    border: none;
    color: #666666;
    font-size: 1.25rem;
    font-family: 'Berkeley Mono', monospace;
    cursor: pointer;
    padding: 4px 2px;
    line-height: 1;
    transition:
        opacity 0.3s ease,
        color 0.2s ease;
    flex-shrink: 0;
}

.photo-nav:hover {
    color: #ffffff;
}

.photo-nav:focus {
    outline: none;
}

.photo-nav-top {
    margin-top: 8px;
}

/* Metadata attached to each slot — moves with the photo */
.photo-slot-info {
    position: absolute;
    right: calc(100% + 24px);
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    font-family: 'Berkeley Mono', monospace;
    white-space: nowrap;
}

.photo-number {
    color: #ffffff;
    font-size: 1rem;
    font-family: 'Berkeley Mono', monospace;
}

.photo-meta {
    color: #888888;
    font-size: 0.875rem;
}

/* Gallery Overlay (password-protected client galleries) */
#gallery-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    overflow: hidden;
    transition: background 0.8s ease-in-out;
    transition-delay: 0.3s;
}

#gallery-overlay.visible {
    pointer-events: auto;
    background: rgba(0, 0, 0, 1);
    transition-delay: 0s;
}

#gallery-overlay .gallery-carousel-container,
#gallery-overlay .gallery-close {
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
    transition-delay: 0s;
}

#gallery-overlay.visible .gallery-carousel-container,
#gallery-overlay.visible .gallery-close {
    opacity: 1;
    transition-delay: 0.7s;
}

.gallery-carousel-container {
    width: 100%;
    height: 100%;
}

.gallery-carousel-container .photo-layout {
    display: flex;
    align-items: center;
    width: 100%;
    height: 100%;
    gap: 40px;
    padding: 0 60px;
    box-sizing: border-box;
}

/* Password form */
.gallery-password-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
    transition-delay: 0s;
}

#gallery-overlay.visible .gallery-password-container {
    opacity: 1;
    transition-delay: 0.7s;
}

.gallery-password-form {
    display: flex;
    align-items: center;
    gap: 0;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
}

.gallery-password-input {
    font-family: 'Berkeley Mono', monospace;
    font-size: 0.875rem;
    color: #ffffff;
    background: transparent;
    border: none;
    padding: 12px 16px;
    width: 240px;
    outline: none;
    letter-spacing: 0.1em;
}

.gallery-password-input::placeholder {
    color: #444444;
    letter-spacing: 0.05em;
}

.gallery-password-submit {
    font-family: 'Berkeley Mono', monospace;
    font-size: 1rem;
    color: #666666;
    background: none;
    border: none;
    padding: 12px 16px;
    cursor: pointer;
    transition: color 0.2s ease;
}

.gallery-password-submit:hover {
    color: #ffffff;
}

.gallery-password-submit:disabled {
    color: #333333;
    cursor: default;
}

.gallery-password-error {
    font-family: 'Berkeley Mono', monospace;
    font-size: 0.75rem;
    color: #ff4444;
    min-height: 1.2em;
}

/* Gallery slots reuse photo-slot styles but within gallery overlay */
#gallery-overlay .photo-slot {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    transition: transform 0.7s cubic-bezier(0.4, 0, 0.05, 1);
}

body.gallery-active {
    overflow: hidden;
}

@media (max-width: 767px) {
    html,
    body {
        overflow: auto;
        overflow-x: hidden;
    }
    #webgl,
    #plaque,
    #loading {
        display: none;
    }

    #panels-container {
        position: relative;
        width: 100%;
        height: auto;
        pointer-events: auto;
    }

    #panels-container iframe {
        border-radius: 0;
        box-shadow: none;
    }

    #index-panel-iframe {
        position: relative !important;
        top: auto;
        left: auto;
        width: 100% !important;
        opacity: 1;
        pointer-events: auto;
        max-height: none;
    }

    .body-panel-iframe {
        position: fixed !important;
        top: 0;
        left: 0;
        width: 100% !important;
        height: 100% !important;
        z-index: 2000;
        background: #000;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.8s ease-in-out;
    }

    .body-panel-iframe.visible {
        opacity: 1;
        pointer-events: auto;
    }
    .body-panel-iframe.hidden {
        display: none;
    }

    .article-close {
        position: fixed;
        top: 12px;
        right: 12px;
        background: none;
        border: none;
        color: #666666;
        font-size: 2rem;
        font-family: 'Berkeley Mono', monospace;
        cursor: pointer;
        padding: 10px;
        line-height: 1;
        z-index: 2001;
        display: none;
    }

    body.article-active .article-close {
        display: block;
    }
    body.article-active {
        overflow: hidden;
    }

    /* Photography overlay — mobile: fullscreen, swipe-only */
    .photo-slot {
        top: 50%;
        left: 50%;
        right: auto;
        display: block;
    }
    .photo-carousel {
        width: 100%;
        height: 85vh;
        overflow: hidden;
    }
    .photo-image {
        max-width: 86vw;
        max-height: 75vh;
    }
    .photo-frame.format-small {
        padding: max(12px, min(1.25vw, 20px));
    }

    .photo-footer {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 6px;
        margin-top: 12px;
    }
    /* On mobile, hide in-slot metadata — show it in the footer instead
       to avoid overlap with landscape-rotated photos */
    .photo-slot-info {
        display: none;
    }

    /* Rotate landscape photos to portrait on mobile */
    .photo-frame.landscape {
        transform: rotate(90deg);
    }
    .photo-frame.landscape .photo-image {
        width: 75vh;
        max-width: none;
        max-height: 86vw;
    }
    .photo-close {
        top: 12px;
        right: 12px;
    }

    body.photography-active {
        overflow: hidden;
    }

    /* Gallery overlay mobile */
    #gallery-overlay .photo-slot {
        top: 50%;
        left: 50%;
        right: auto;
        display: block;
    }

    #gallery-overlay .photo-carousel {
        width: 100%;
        height: 85vh;
        overflow: hidden;
    }

    .gallery-password-input {
        width: 200px;
    }

    body.gallery-active {
        overflow: hidden;
    }
}

