/**
 * ==============================================================================
 * SADRA VISUALS — ARTBOOK PHOTOGRAPHY GALLERY DESIGN SYSTEM
 * LAYER 6.1: VIRTUALIZED FEED & PROGRESSIVE BLUR-UP LOADER
 * ==============================================================================
 * Stylesheet providing:
 * 1. Fluid Bento Masonry, Media Grid, and Story Cinema Stream layouts
 * 2. Progressive Blur-Up crossfade with Base64 LQIP and CLS = 0 preservation
 * 3. Transparent protection shield overlay integration
 * 4. Micro-animations, glowing hover states, and typography overlays
 * 5. Infinite virtualization sentinel, skeleton shimmer, and loading indicators
 * 6. Responsive mobile-first breakpoints (< 768px, < 480px, < 380px)
 */

/* ==============================================================================
   1. FEED CONTAINERS & PRESENTATION DENSITIES
   ============================================================================== */
.gallery-feed-wrapper {
    position: relative;
    width: 100%;
    margin: 0 auto;
}

/* Default Density 1: Bento Masonry — CSS Columns for true tight packing */
.gallery-feed,
.gallery-feed.density-bento {
    columns: 4;
    column-gap: var(--grid-gutter, clamp(14px, 1.6vw, 24px));
    display: block;
    width: 100%;
    box-sizing: border-box;
    transition: opacity 0.25s ease;
}

@media (max-width: 1200px) {
    .gallery-feed,
    .gallery-feed.density-bento {
        columns: 3;
        column-gap: var(--grid-gutter, clamp(12px, 1.4vw, 20px));
    }
}

.gallery-feed.density-bento .photo-card {
    break-inside: avoid;
    -webkit-column-break-inside: avoid;
    margin-bottom: var(--grid-gutter, clamp(16px, 2vw, 28px));
    width: 100%;
    display: block;
}

/* Balanced bento (main feed): dense grid on 1px rows; feed.js sets each item's
   row span from its measured height, so every card lands in the shortest column. */
#gallery-feed.density-bento {
    --bento-cols: var(--bento-cols-desktop, 4);
    display: grid;
    grid-template-columns: repeat(var(--bento-cols), minmax(0, 1fr));
    grid-auto-rows: 1px;
    grid-auto-flow: row dense;
    row-gap: 0;
    align-items: start;
}

#gallery-feed.density-bento > * {
    align-self: start;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
}

@media (max-width: 1200px) {
    #gallery-feed.density-bento { --bento-cols: 3; }
}

@media (max-width: 768px) {
    #gallery-feed.density-bento { --bento-cols: 2; }
}

/* Density 2: Uniform Media Square Grid */
.gallery-feed.density-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(clamp(220px, 18vw, 300px), 1fr));
    gap: var(--grid-gutter, clamp(12px, 1.5vw, 20px));
}

.gallery-feed.density-grid .photo-card-frame {
    aspect-ratio: 1 / 1 !important;
}

/* Density 3: Story Cinema Stream (Single Column Editorial) */
.gallery-feed.density-cinema,
.gallery-feed.density-story {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(48px, 6vh, 80px);
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding-left: clamp(16px, 3vw, 32px);
    padding-right: clamp(16px, 3vw, 32px);
    padding-bottom: clamp(80px, 10vh, 120px);
    box-sizing: border-box;
}

.gallery-feed.density-cinema .photo-card,
.gallery-feed.density-story .photo-card {
    width: 100%;
    max-width: 1100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    box-shadow: none;
    cursor: pointer;
}

/* Sizing bounds tailored for storytelling elegance */
.gallery-feed.density-cinema .photo-card.is-portrait,
.gallery-feed.density-story .photo-card.is-portrait {
    max-width: min(660px, 92vw);
}

.gallery-feed.density-cinema .photo-card.is-square,
.gallery-feed.density-story .photo-card.is-square {
    max-width: min(840px, 94vw);
}

.gallery-feed.density-cinema .photo-card.is-landscape,
.gallery-feed.density-story .photo-card.is-landscape,
.gallery-feed.density-cinema .photo-card.is-panoramic,
.gallery-feed.density-story .photo-card.is-panoramic {
    max-width: min(1140px, 96vw);
}

/* Story view frame preserving true aspect ratio & zero layout shift */
.gallery-feed.density-cinema .photo-card-frame,
.gallery-feed.density-story .photo-card-frame {
    position: relative;
    width: 100%;
    aspect-ratio: var(--card-aspect, 3 / 2);
    max-height: calc(88vh);
    max-height: calc(88dvh);
    border-radius: var(--radius-md, 14px);
    overflow: hidden;
    background: #08090c;
    box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.7);
    border: 1px solid var(--border-subtle);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.35s cubic-bezier(0.16, 1, 0.3, 1),
                border-color 0.3s ease;
}

.gallery-feed.density-cinema .photo-card:hover .photo-card-frame,
.gallery-feed.density-story .photo-card:hover .photo-card-frame {
    transform: translateY(-4px) scale(1.005);
    box-shadow: 0 28px 64px -12px rgba(0, 0, 0, 0.85),
                0 0 30px rgba(212, 175, 55, 0.12);
    border-color: var(--border-active);
}

/* Progressive Blur-Up & Display Tier Image Fill */
.gallery-feed.density-cinema .photo-lqip,
.gallery-feed.density-story .photo-lqip {
    position: absolute !important;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
}

.gallery-feed.density-cinema .photo-img,
.gallery-feed.density-story .photo-img {
    position: absolute !important;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 2;
    image-rendering: auto;
    image-rendering: -webkit-optimize-contrast;
}

/* ==============================================================================
   2. PHOTO CARD ARCHITECTURE & ZERO-CLS GEOMETRY
   ============================================================================== */
.photo-card {
    position: relative;
    display: block;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transform: translateZ(0);
    backface-visibility: hidden;
    contain: layout;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                border-color 0.3s ease,
                box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.photo-card:hover,
.photo-card:focus-visible {
    transform: translateY(-4px);
    border-color: var(--border-active);
    box-shadow: var(--shadow-glow-gold, 0 12px 32px rgba(212, 175, 55, 0.12));
}

.photo-card:active {
    transform: translateY(-1px) scale(0.995);
}

/* Frame preserving aspect ratio geometry to prevent layout shift */
.photo-card-frame {
    position: relative;
    width: 100%;
    aspect-ratio: var(--card-aspect, 3 / 2);
    overflow: hidden;
    background: var(--bg-surface);
    contain: paint;
}

/* Bento: each frame uses its own card-aspect variable — set by JS per image */
.gallery-feed.density-bento .photo-card-frame {
    aspect-ratio: var(--card-aspect, 3 / 2);
}

/* ==============================================================================
   3. PROGRESSIVE BLUR-UP LOADER & CROSSFADE
   ============================================================================== */
/* Base64 Low Quality Image Placeholder (LQIP) */
.photo-lqip {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: blur(14px);
    transform: scale(1.06);
    opacity: 1;
    transition: opacity 0.4s ease-out, visibility 0.4s;
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    z-index: 1;
    will-change: opacity;
    backface-visibility: hidden;
}

/* High-Resolution Derivative Image */
.photo-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    z-index: 2;
    will-change: opacity;
    backface-visibility: hidden;
}

/* Once fully loaded by browser */
.photo-img.is-loaded {
    opacity: 1;
}

.photo-img.is-loaded + .photo-lqip,
.photo-card-frame.is-loaded .photo-lqip {
    opacity: 0;
    visibility: hidden;
}

/* ==============================================================================
   4. GLASSMORPHIC PHOTO CARD OVERLAY & INFO
   ============================================================================== */
.photo-card-overlay {
    position: absolute;
    inset: 0;
    z-index: 4;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 16px;
    background: linear-gradient(
        to top,
        rgba(8, 9, 12, 0.88) 0%,
        rgba(8, 9, 12, 0.5) 45%,
        transparent 100%
    );
    opacity: 0;
    transition: opacity 0.28s ease;
    pointer-events: none;
}

.photo-card:hover .photo-card-overlay,
.photo-card:focus-visible .photo-card-overlay {
    opacity: 1;
}

.photo-card.overlay-style-corner-badges .photo-card-overlay {
    background: none;
    padding: 12px;
}
.photo-card.overlay-style-corner-badges .photo-card-info {
    background: rgba(10, 11, 16, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 8px;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.photo-card.overlay-style-hover-only .photo-card-overlay {
    opacity: 0 !important;
}
.photo-card.overlay-style-hover-only:hover .photo-card-overlay,
.photo-card.overlay-style-hover-only:focus-visible .photo-card-overlay {
    opacity: 1 !important;
}

.photo-card-info {
    transform: translateY(6px);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

.photo-card:hover .photo-card-info,
.photo-card:focus-visible .photo-card-info {
    transform: translateY(0);
}

.photo-card-title {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    color: #ffffff;
    margin: 0 0 6px 0;
    line-height: 1.25;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.photo-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: var(--text-xs);
    color: rgba(255, 255, 255, 0.85);
}

.photo-card-tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.68rem;
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.photo-card-likes {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-mono);
    font-size: 0.76rem;
    color: var(--accent-gold);
    pointer-events: auto;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-pill);
    background: rgba(8, 9, 12, 0.4);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: transform 0.15s ease, background 0.15s ease;
}

.photo-card-likes:hover {
    transform: scale(1.08);
    background: rgba(212, 175, 55, 0.2);
}

.photo-card-likes.has-liked {
    color: #f43f5e;
}

/* ==============================================================================
   4.5. CHROMATIC PALETTE SWATCH DOTS (ROADMAP 1.6)
   ============================================================================== */
.photo-palette-dots {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px;
    border-radius: var(--radius-pill);
    background: rgba(8, 9, 12, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    margin: 4px 0 8px 0;
    width: fit-content;
    pointer-events: auto;
    transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.photo-palette-dots:hover {
    background: rgba(8, 9, 12, 0.7);
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.photo-palette-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--dot-color, #d4af37);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(255, 255, 255, 0.25);
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
    cursor: pointer;
    flex-shrink: 0;
}

.photo-palette-dot:hover {
    transform: scale(1.45);
    box-shadow: 0 0 10px var(--dot-color, #d4af37), 0 2px 6px rgba(0, 0, 0, 0.7);
    z-index: 2;
}

@media (hover: none) and (pointer: coarse) {
    .photo-palette-dots {
        padding: 5px 10px;
        gap: 8px;
    }
    .photo-palette-dot {
        width: 12px;
        height: 12px;
    }
}

/* Featured Star Badge (Hidden on public visitor cards to keep photographs pristine; curated in Admin view) */
.photo-featured-badge {
    display: none !important;
}

/* RAW Original Comparison Badge */
.photo-raw-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 3px 8px;
    border-radius: 9999px;
    background: rgba(8, 9, 12, 0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid rgba(56, 189, 248, 0.5);
    color: #38bdf8;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4), 0 0 10px rgba(56, 189, 248, 0.2);
}

/* ==============================================================================
   5. SKELETON SHIMMER & VIRTUALIZATION SENTINEL
   ============================================================================== */
.feed-sentinel {
    width: 100%;
    height: 1px;
    margin-top: 10px;
    pointer-events: none;
    opacity: 0;
}

.feed-loader {
    display: none;
    width: 100%;
    padding: 32px 0 48px 0;
    text-align: center;
    box-sizing: border-box;
}

.feed-loader.is-active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.feed-spinner {
    width: 32px;
    height: 32px;
    border: 2px solid var(--border-medium);
    border-top-color: var(--accent-gold);
    border-radius: 50%;
    animation: feed-spin 0.8s linear infinite;
}

.feed-loader-text {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text-secondary);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

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

/* Skeleton Loading Cards */
.skeleton-card {
    position: relative;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    overflow: hidden;
    aspect-ratio: 3 / 2;
    border: 1px solid var(--border-subtle);
}

.skeleton-shimmer {
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.05) 50%,
        transparent 100%
    );
    animation: skeleton-wave 1.6s infinite ease-in-out;
}

@keyframes skeleton-wave {
    100% { transform: translateX(100%); }
}

/* Feed End Notice */
.feed-end-notice {
    display: none;
    width: 100%;
    text-align: center;
    padding: 40px 16px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.feed-end-notice.is-visible {
    display: block;
}

/* Empty State Notice */
.feed-empty {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 20px;
    text-align: center;
    color: var(--text-secondary);
    width: 100%;
}

.feed-empty.is-visible {
    display: flex;
}

.feed-empty-icon {
    font-size: 2.2rem;
    margin-bottom: 12px;
    color: var(--accent-gold);
}

.feed-empty-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

.feed-empty-desc {
    font-size: var(--text-sm);
    color: var(--text-muted);
    max-width: 420px;
    margin: 0 auto 20px auto;
}

/* ==============================================================================
   6. RESPONSIVE MOBILE-FIRST BEHAVIORS
   ============================================================================== */
@media (max-width: 768px) {
    .gallery-feed,
    .gallery-feed.density-bento {
        columns: 2;
        column-gap: 10px;
    }

    .gallery-feed.density-bento .photo-card {
        margin-bottom: 10px;
    }

    .gallery-feed.density-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 8px;
    }

    .gallery-feed.density-cinema,
    .gallery-feed.density-story {
        gap: 28px;
        padding-left: 10px;
        padding-right: 10px;
        padding-bottom: 84px;
    }

    .gallery-feed.density-cinema .photo-card,
    .gallery-feed.density-story .photo-card {
        width: 100%;
        max-width: 100%;
    }

    .gallery-feed.density-cinema .photo-card-frame,
    .gallery-feed.density-story .photo-card-frame {
        width: 100%;
        max-height: calc(85dvh);
    }

    .gallery-feed.density-cinema .photo-img,
    .gallery-feed.density-story .photo-img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    /* ==========================================================================
       MOBILE GALLERY ADJUSTMENTS: ZERO CLUTTER, UNBLOCKED IMAGES
       ========================================================================== */
    /* 1. Color palette/chips: Completely hide colors section/palette across all layouts on mobile (Bento, Story, and Media Grid) */
    .photo-palette-dots,
    .gallery-feed .photo-palette-dots,
    .gallery-feed.density-bento .photo-palette-dots,
    #gallery-feed.density-bento .photo-palette-dots,
    .gallery-feed.density-grid .photo-palette-dots,
    .gallery-feed.density-cinema .photo-palette-dots,
    .gallery-feed.density-story .photo-palette-dots {
        display: none !important;
        pointer-events: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }

    /* Mobile-first: strictly remove proofing star buttons and actions on public feeds */
    #gallery-feed .card-proofing-btn,
    #gallery-feed .client-card-star-btn,
    #archive-feed .card-proofing-btn,
    #archive-feed .client-card-star-btn,
    #view-home .card-proofing-btn,
    #view-home .client-card-star-btn,
    #view-archive .card-proofing-btn,
    #view-archive .client-card-star-btn,
    #view-statement .card-proofing-btn,
    #view-statement .client-card-star-btn,
    .photo-card:not(.client-photo-card) .card-proofing-btn,
    .photo-card:not(.client-photo-card) .client-card-star-btn,
    body:not(.is-client-access) .photo-card-frame .card-proofing-btn,
    body:not(.is-client-access) .photo-card .card-proofing-btn,
    .photo-card:not(.client-photo-card) .photo-card-likes,
    .photo-card:not(.client-photo-card) .video-mute-btn,
    body:not(.is-client-access) .photo-card:not(.client-photo-card) button:not(.client-card-star-btn) {
        display: none !important;
        pointer-events: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }

    /* Restore direct star selection on thumbnails STRICTLY in client proofing on mobile */
    body.is-client-access #view-client .client-photo-card .card-proofing-btn,
    body.is-client-access #view-client .client-photo-card .client-card-star-btn,
    body.is-client-access #clientPortalGrid .client-card-star-btn,
    body.is-client-access #client-feed .client-card-star-btn {
        display: inline-flex !important;
        pointer-events: auto !important;
        opacity: 1 !important;
        visibility: visible !important;
        top: 8px !important;
        left: 8px !important;
        width: 44px !important;
        height: 44px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        z-index: 10 !important;
    }

    /* 2. Overlay and text clutter (Bento and Media Grid on mobile):
          Focus view on photos themselves. Remove heavy titles, metadata, and overlays that obstruct images.
          If title is shown, place it at the bottom with very low opacity—barely visible and readable without blocking the image.
          Move all remaining details and metadata to only show when photo is tapped and opened in full view. */
    .gallery-feed.density-bento .photo-card-overlay,
    #gallery-feed.density-bento .photo-card-overlay,
    .gallery-feed.density-grid .photo-card-overlay {
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        inset: auto 0 0 0 !important;
        max-height: 36px !important;
        height: auto !important;
        padding: 4px 8px !important;
        background: linear-gradient(
            to top,
            rgba(0, 0, 0, 0.28) 0%,
            rgba(0, 0, 0, 0) 100%
        ) !important;
        pointer-events: none !important;
        opacity: 1 !important;
        display: flex !important;
        justify-content: flex-end !important;
        align-items: flex-end !important;
        box-sizing: border-box !important;
    }

    .gallery-feed.density-bento .photo-card-info,
    #gallery-feed.density-bento .photo-card-info,
    .gallery-feed.density-grid .photo-card-info {
        width: 100% !important;
        transform: translateY(0) !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* Barely visible title at the bottom edge with very low opacity */
    .gallery-feed.density-bento .photo-card-title,
    #gallery-feed.density-bento .photo-card-title,
    .gallery-feed.density-grid .photo-card-title {
        display: block !important;
        font-family: var(--font-display, inherit) !important;
        font-size: 0.66rem !important;
        font-weight: 500 !important;
        color: #ffffff !important;
        opacity: 0.42 !important;
        margin: 0 !important;
        padding: 0 !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85) !important;
        letter-spacing: 0.02em !important;
        pointer-events: none !important;
    }

    /* Remove heavy metadata, tags, like counters, and badges on Bento & Media Grid mobile cards */
    .gallery-feed.density-bento .photo-card-meta,
    #gallery-feed.density-bento .photo-card-meta,
    .gallery-feed.density-grid .photo-card-meta,
    .gallery-feed.density-bento .photo-card-tag,
    #gallery-feed.density-bento .photo-card-tag,
    .gallery-feed.density-grid .photo-card-tag,
    .gallery-feed.density-bento .photo-card-likes,
    #gallery-feed.density-bento .photo-card-likes,
    .gallery-feed.density-grid .photo-card-likes,
    .gallery-feed.density-bento .photo-raw-badge,
    #gallery-feed.density-bento .photo-raw-badge,
    .gallery-feed.density-grid .photo-raw-badge,
    .gallery-feed.density-bento .card-foryou-badge,
    #gallery-feed.density-bento .card-foryou-badge,
    .gallery-feed.density-grid .card-foryou-badge,
    .gallery-feed.density-bento .photo-featured-badge,
    #gallery-feed.density-bento .photo-featured-badge,
    .gallery-feed.density-grid .photo-featured-badge {
        display: none !important;
        pointer-events: none !important;
    }
}

@media (max-width: 480px) {
    .gallery-feed,
    .gallery-feed.density-bento {
        columns: 2;
        column-gap: 8px;
    }

    .gallery-feed.density-bento .photo-card {
        margin-bottom: 8px;
    }

    .gallery-feed.density-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .gallery-feed.density-bento .photo-card-overlay,
    #gallery-feed.density-bento .photo-card-overlay,
    .gallery-feed.density-grid .photo-card-overlay {
        padding: 2px 6px !important;
        max-height: 28px !important;
    }

    .gallery-feed.density-bento .photo-card-title,
    #gallery-feed.density-bento .photo-card-title,
    .gallery-feed.density-grid .photo-card-title {
        font-size: 0.62rem !important;
        opacity: 0.38 !important;
    }
}

@media (max-width: 360px) {
    .gallery-feed,
    .gallery-feed.density-bento {
        columns: 2;
        column-gap: 6px;
    }

    .gallery-feed.density-bento .photo-card {
        margin-bottom: 6px;
    }
}

/* ==============================================================================
   7. IN-GRID PRIVATE / LOCKED SESSION SCREEN & PASSCODE CARD
   ============================================================================== */
.gallery-locked-screen {
    column-span: all;
    grid-column: 1 / -1;
    width: 100%;
    max-width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: clamp(32px, 6vw, 64px) 16px;
    box-sizing: border-box;
    animation: fadeInLockedScreen 0.35s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes fadeInLockedScreen {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.gallery-locked-card {
    background: rgba(14, 18, 28, 0.95);
    border: 1px solid rgba(212, 175, 55, 0.38);
    border-radius: var(--radius-lg, 18px);
    width: 100%;
    max-width: 480px;
    padding: clamp(24px, 5vw, 36px);
    box-shadow: 0 24px 60px -8px rgba(0, 0, 0, 0.8), 0 0 35px rgba(212, 175, 55, 0.12);
    text-align: center;
    box-sizing: border-box;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.gallery-locked-icon-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: rgba(212, 175, 55, 0.12);
    border: 1px solid rgba(212, 175, 55, 0.35);
    color: var(--accent-gold, #d4af37);
    margin-bottom: 18px;
    flex-shrink: 0;
}

.gallery-locked-title {
    font-family: var(--font-display, 'Space Grotesk', sans-serif);
    font-size: clamp(1.2rem, 2.5vw, 1.45rem);
    font-weight: 700;
    color: var(--text-primary, #f8fafc);
    margin: 0 0 10px;
    letter-spacing: -0.01em;
    line-height: 1.25;
}

.gallery-locked-desc {
    font-family: var(--font-sans, 'Plus Jakarta Sans', sans-serif);
    font-size: 0.88rem;
    color: var(--text-dim, #94a3b8);
    margin: 0 0 22px;
    line-height: 1.55;
    max-width: 380px;
    margin-left: auto;
    margin-right: auto;
}

.gallery-locked-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    box-sizing: border-box;
}

.gallery-locked-card.is-shaking {
    animation: gatekeeperShake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.gallery-locked-otp-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    margin: 8px 0 16px;
    box-sizing: border-box;
}

.gallery-locked-otp-cell {
    width: clamp(42px, 14vw, 56px);
    height: clamp(50px, 14vw, 58px);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.16));
    border-radius: var(--radius-md, 10px);
    font-family: var(--font-mono, 'JetBrains Mono', monospace);
    font-size: 1.35rem; /* >= 16px prevents iOS zoom */
    font-weight: 700;
    text-align: center;
    color: var(--text-primary, #f8fafc);
    outline: none;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
    caret-color: var(--accent-gold, #d4af37);
    -webkit-appearance: none;
}

.gallery-locked-otp-cell:focus {
    background: rgba(212, 175, 55, 0.08);
    border-color: var(--accent-gold, #d4af37);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.28), 0 0 16px rgba(212, 175, 55, 0.3);
    transform: translateY(-2px);
    color: #ffffff;
}

.gallery-locked-otp-cell.is-filled {
    background: rgba(212, 175, 55, 0.05);
    border-color: rgba(212, 175, 55, 0.5);
    color: var(--accent-gold, #d4af37);
}

.gallery-locked-otp-cell.is-error {
    background: rgba(239, 68, 68, 0.08);
    border-color: var(--status-danger, #ef4444);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25);
    color: #fca5a5;
    animation: otpCellErrorPulse 0.4s ease-in-out;
}

@keyframes otpCellErrorPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

[data-theme="light"] .gallery-locked-card {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(212, 175, 55, 0.45);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .gallery-locked-title {
    color: #0f172a;
}

[data-theme="light"] .gallery-locked-desc {
    color: #64748b;
}

[data-theme="light"] .gallery-locked-otp-cell {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.14);
    color: #0f172a;
}

[data-theme="light"] .gallery-locked-otp-cell:focus {
    background: #ffffff;
    border-color: var(--accent-gold, #d4af37);
}

[data-theme="light"] .gallery-locked-otp-cell.is-filled {
    background: rgba(212, 175, 55, 0.08);
    border-color: rgba(212, 175, 55, 0.6);
    color: #b38f2a;
}

.gallery-locked-submit-btn {
    height: 48px;
    min-height: 48px;
    width: 100%;
    background: linear-gradient(135deg, #d4af37 0%, #b38f2a 100%);
    color: #08090c;
    border: none;
    border-radius: var(--radius-md, 10px);
    font-family: var(--font-sans, 'Plus Jakarta Sans', sans-serif);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 14px rgba(212, 175, 55, 0.35);
    transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
    box-sizing: border-box;
}

.gallery-locked-submit-btn:hover {
    filter: brightness(1.08);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.45);
}

.gallery-locked-submit-btn:active {
    transform: scale(0.98);
}

.gallery-locked-alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm, 6px);
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    font-size: 0.84rem;
    line-height: 1.4;
    text-align: left;
    display: none;
    align-items: center;
    gap: 8px;
    box-sizing: border-box;
    word-break: break-word;
}

@media (max-width: 480px) {
    .gallery-locked-card {
        padding: 20px 16px;
        border-radius: var(--radius-md, 12px);
    }

    .gallery-locked-icon-badge {
        width: 46px;
        height: 46px;
        margin-bottom: 14px;
    }
}

/* ==============================================================================
   7. GALLERY FILTER & SEARCH INTERFACE (TAGS & CHROMIC MOODS)
   ============================================================================== */
.gallery-filter-container {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto clamp(20px, 3vh, 32px) auto;
    padding: 0 var(--page-gutter, clamp(16px, 3vw, 40px));
    box-sizing: border-box;
}

.gallery-filter-bar {
    background: var(--bg-card, rgba(14, 18, 27, 0.75));
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
    border-radius: var(--radius-lg, 16px);
    padding: clamp(14px, 2vw, 20px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
}

/* Live Search Wrap */
.gallery-filter-top {
    width: 100%;
}

.gallery-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

.gallery-search-icon {
    position: absolute;
    left: 16px;
    width: 18px;
    height: 18px;
    color: var(--text-muted, #94a3b8);
    pointer-events: none;
}

.gallery-search-input {
    width: 100%;
    height: 48px;
    min-height: 44px;
    padding: 0 46px 0 46px;
    border-radius: var(--radius-pill, 9999px);
    background: var(--bg-input, rgba(255, 255, 255, 0.05));
    border: 1px solid var(--border-medium, rgba(255, 255, 255, 0.14));
    color: var(--text-primary, #f8fafc);
    font-family: var(--font-sans, 'Plus Jakarta Sans', sans-serif);
    font-size: 16px; /* Prevents iOS Safari auto-zoom */
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.gallery-search-input::placeholder {
    color: var(--text-dim, #64748b);
}

.gallery-search-input:focus {
    border-color: var(--accent-gold, #d4af37);
    background: var(--bg-input-focus, rgba(255, 255, 255, 0.09));
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
}

.gallery-search-clear {
    position: absolute;
    right: 12px;
    width: 32px;
    height: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    color: var(--text-muted, #94a3b8);
    cursor: pointer;
    transition: all 0.2s ease;
}

.gallery-search-clear:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
}

/* Filter Sections & Rails */
.gallery-filter-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.gallery-filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.gallery-filter-title {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono, monospace);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted, #94a3b8);
}

.gallery-title-icon {
    color: var(--accent-gold, #d4af37);
    flex-shrink: 0;
}

/* Scrollable Chips Rails */
.gallery-chips-scroll {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.gallery-chips-scroll::-webkit-scrollbar {
    display: none;
}

/* Chips */
.gallery-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 16px;
    border-radius: var(--radius-pill, 9999px);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
    color: var(--text-secondary, #cbd5e1);
    font-family: var(--font-sans, 'Plus Jakarta Sans', sans-serif);
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
}

.gallery-chip:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.gallery-chip:active {
    transform: scale(0.97);
}

.gallery-chip.active {
    background: rgba(212, 175, 55, 0.14);
    border-color: var(--accent-gold, #d4af37);
    color: #ffffff;
    box-shadow: 0 0 14px rgba(212, 175, 55, 0.2);
}

/* Mood Swatches & Counts */
.mood-swatch {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--swatch-color, #94a3b8);
    box-shadow: 0 0 6px var(--swatch-color, #94a3b8);
    flex-shrink: 0;
}

.mood-swatch-all {
    background: conic-gradient(#d4af37, #0284c7, #94a3b8, #10b981, #ef4444, #d4af37);
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.3);
}

.chip-name {
    font-weight: 500;
}

.chip-count {
    font-family: var(--font-mono, monospace);
    font-size: 0.72rem;
    color: var(--text-muted, #94a3b8);
    opacity: 0.85;
}

.gallery-chip.active .chip-count {
    color: var(--accent-gold, #d4af37);
    opacity: 1;
}

/* Active Filters Status Strip */
.gallery-filter-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
    width: 100%;
    box-sizing: border-box;
}

.gallery-active-tags {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.gallery-active-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px 4px 12px;
    min-height: 34px;
    border-radius: var(--radius-pill, 9999px);
    background: rgba(212, 175, 55, 0.12);
    border: 1px solid rgba(212, 175, 55, 0.3);
    color: var(--accent-gold, #d4af37);
    font-size: 0.8rem;
    font-family: var(--font-mono, monospace);
    word-break: break-word;
    box-sizing: border-box;
}

.tag-remove-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    border-radius: 50%;
    opacity: 0.75;
    transition: opacity 0.15s ease, background 0.15s ease;
}

.tag-remove-btn:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
}

.gallery-reset-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-pill, 9999px);
    color: var(--text-secondary, #cbd5e1);
    font-family: var(--font-sans, 'Plus Jakarta Sans', sans-serif);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: auto;
    box-sizing: border-box;
}

.gallery-reset-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.35);
    color: #fca5a5;
}

@media (max-width: 768px) {
    .gallery-filter-bar {
        padding: 14px;
        gap: 12px;
    }

    .gallery-search-input {
        height: 46px;
    }
}

@media (max-width: 480px) {
    .gallery-filter-container {
        padding: 0 12px;
    }

    .gallery-filter-bar {
        padding: 12px;
        border-radius: var(--radius-md, 12px);
    }

    .gallery-filter-status {
        flex-direction: column;
        align-items: stretch;
    }

    .gallery-reset-btn {
        width: 100%;
        justify-content: center;
        margin-left: 0;
    }
}

@media (max-width: 380px) {
    .gallery-chip {
        padding: 0 12px;
        font-size: 0.8rem;
    }
}

