/**
 * ==============================================================================
 * SADRA VISUALS — ARTBOOK PHOTOGRAPHY GALLERY DESIGN SYSTEM
 * LAYER 6.9: COMPLETE PORTFOLIO ARCHIVE EXPLORER
 * ==============================================================================
 * Stylesheet providing:
 * 1. Archive Hero Title & Curatorial Subhead
 * 2. Multi-tier Taxonomy Filter Bar (Genre chips, Series dropdown, Mood dropdown, Live Search)
 * 3. Archive Results Counter & Density View Controls
 * 4. Responsive Grid Integration with Zero-Jank CLS Protection
 * 5. Mobile-first Ergonomics (>=44px touch targets, >=16px font size, zero horizontal overflow)
 */

/* ==============================================================================
   1. ARCHIVE CONTAINER & HEADER
   ============================================================================== */
.archive-container {
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    padding: clamp(24px, 4vw, 48px) var(--page-gutter, clamp(16px, 3vw, 40px)) clamp(64px, 8vw, 120px);
    box-sizing: border-box;
}

.archive-header {
    text-align: center;
    max-width: 820px;
    margin: 0 auto clamp(24px, 4vh, 40px) auto;
}

.archive-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    border-radius: var(--radius-pill, 9999px);
    background: rgba(212, 175, 55, 0.08);
    border: 1px solid rgba(212, 175, 55, 0.25);
    color: var(--accent-gold, #d4af37);
    font-family: var(--font-mono, monospace);
    font-size: var(--text-xs, 0.75rem);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    margin-bottom: 14px;
}

.archive-title {
    font-family: var(--font-display, 'Space Grotesk', sans-serif);
    font-size: clamp(1.75rem, 3.5vw, 2.75rem);
    font-weight: 700;
    color: var(--text-primary, #ffffff);
    margin: 0 0 12px 0;
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.archive-subhead {
    font-family: var(--font-sans, 'Plus Jakarta Sans', sans-serif);
    font-size: clamp(0.9rem, 1.4vw, 1.05rem);
    color: var(--text-secondary, #94a3b8);
    line-height: 1.6;
    margin: 0 auto;
}

/* ==============================================================================
   2. TAXONOMY FILTER BAR
   ============================================================================== */
.archive-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(16px, 2.5vw, 24px);
    margin-bottom: clamp(24px, 4vh, 36px);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
    box-sizing: border-box;
}

/* Genre Filter Chips Rail & Exploration Tags */
.archive-chips-section {
    margin-bottom: 20px;
    width: 100%;
    box-sizing: border-box;
}

.archive-filter-label {
    display: block;
    font-family: var(--font-mono, monospace);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted, #64748b);
    margin-bottom: 10px;
}

.archive-chips-rail {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
    padding-bottom: 4px;
}

.archive-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 42px;
    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, inherit);
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
    flex: 0 0 auto;
    flex-shrink: 0;
    max-width: 100%;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    outline: none;
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
}

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

.archive-chip.active {
    background: rgba(212, 175, 55, 0.15);
    border-color: var(--accent-gold, #d4af37);
    color: var(--accent-gold, #d4af37);
    box-shadow: 0 0 16px rgba(212, 175, 55, 0.2);
    font-weight: 600;
}

/* Unified Photo Count Badge for Archive Filter Chips */
.archive-chip .dock-count-badge,
.archive-chip .dock-pill-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono, monospace);
    font-size: 0.68rem;
    font-weight: 500;
    line-height: 1;
    padding: 2px 7px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted, #94a3b8);
    border: 1px solid rgba(255, 255, 255, 0.06);
    margin-left: 6px;
    transition: all 0.15s ease;
    vertical-align: middle;
}

.archive-chip:hover .dock-count-badge,
.archive-chip:hover .dock-pill-count {
    color: var(--accent-gold, #d4af37);
    background: rgba(212, 175, 55, 0.12);
    border-color: rgba(212, 175, 55, 0.25);
}

.archive-chip.active .dock-count-badge,
.archive-chip.active .dock-pill-count {
    background: rgba(212, 175, 55, 0.25);
    color: var(--accent-gold, #d4af37);
    border-color: var(--accent-gold, #d4af37);
    font-weight: 700;
}

/* Secondary Filter Controls Row */
.archive-filter-row {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1.4fr;
    gap: 14px;
    align-items: end;
    margin-bottom: 18px;
}

.archive-filter-group {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Custom Select Dropdowns */
.archive-select-wrap {
    position: relative;
    width: 100%;
}

.archive-select {
    width: 100%;
    min-height: 44px;
    height: 44px;
    padding: 0 36px 0 14px;
    background: rgba(8, 9, 12, 0.6);
    background-image: none !important;
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
    border-radius: var(--radius-md, 10px);
    color: var(--text-primary, #ffffff);
    font-family: var(--font-sans, inherit);
    font-size: 16px; /* iOS Safari zoom prevention */
    cursor: pointer;
    outline: none !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    user-select: none;
    -webkit-user-select: none;
    color-scheme: dark;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.archive-select::-ms-expand {
    display: none !important;
}

.archive-select::-webkit-inner-spin-button,
.archive-select::-webkit-calendar-picker-indicator {
    display: none !important;
    -webkit-appearance: none !important;
}

.archive-select::selection,
.archive-select:focus::selection {
    background: transparent !important;
    color: inherit !important;
}

.archive-select::-moz-selection,
.archive-select:focus::-moz-selection {
    background: transparent !important;
    color: inherit !important;
}

.archive-select:hover {
    border-color: rgba(255, 255, 255, 0.25);
    background-color: rgba(12, 14, 20, 0.8);
    background-image: none !important;
}

.archive-select:focus,
.archive-select:focus-visible {
    outline: none !important;
    outline-offset: 0 !important;
    border-color: var(--accent-gold, #d4af37) !important;
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2) !important;
    background-color: rgba(14, 16, 24, 0.95);
    background-image: none !important;
}

.archive-select option {
    background: #0f131c;
    color: #ffffff;
    padding: 10px 14px;
}

.archive-select option:checked {
    background: #1a2030 !important;
    color: var(--accent-gold, #d4af37) !important;
    font-weight: 600;
}

.archive-select optgroup {
    font-style: normal;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted, #94a3b8);
    background-color: #0a0d14;
    padding: 10px 14px 4px;
}

.archive-select optgroup option {
    font-style: normal;
    font-weight: 400;
    font-size: 14px;
    text-transform: none;
    letter-spacing: normal;
    padding-left: 24px;
    background-color: #0f131c;
    color: #ffffff;
}

.select-chevron {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    pointer-events: none;
    color: var(--text-muted, #94a3b8);
    transition: color 0.2s ease;
}

.archive-select-wrap:hover .select-chevron,
.archive-select-wrap:focus-within .select-chevron {
    color: var(--accent-gold, #d4af37);
}

/* Light Theme Support for Archive Dropdowns */
[data-theme="light"] .archive-select,
html.light .archive-select {
    background-color: rgba(255, 255, 255, 0.92);
    color: #0f172a;
    border-color: rgba(15, 23, 42, 0.16);
    color-scheme: light;
}

[data-theme="light"] .archive-select:hover,
html.light .archive-select:hover {
    background-color: #ffffff;
    border-color: rgba(180, 120, 20, 0.45);
}

[data-theme="light"] .archive-select:focus,
[data-theme="light"] .archive-select:focus-visible,
html.light .archive-select:focus,
html.light .archive-select:focus-visible {
    outline: none !important;
    border-color: var(--accent-gold, #b47814) !important;
    box-shadow: 0 0 0 3px rgba(180, 120, 20, 0.18) !important;
    background-color: #ffffff;
}

[data-theme="light"] .archive-select option,
html.light .archive-select option {
    background-color: #ffffff;
    color: #0f172a;
}

[data-theme="light"] .archive-select option:checked,
html.light .archive-select option:checked {
    background-color: #fef3c7 !important;
    color: #92400e !important;
    font-weight: 600;
}

[data-theme="light"] .archive-select optgroup,
html.light .archive-select optgroup {
    background-color: #f1f5f9;
    color: #64748b;
}

[data-theme="light"] .archive-select optgroup option,
html.light .archive-select optgroup option {
    background-color: #ffffff;
    color: #0f172a;
}

[data-theme="light"] .archive-select-wrap .select-chevron,
html.light .archive-select-wrap .select-chevron {
    color: #64748b;
}

[data-theme="light"] .archive-select-wrap:hover .select-chevron,
[data-theme="light"] .archive-select-wrap:focus-within .select-chevron,
html.light .archive-select-wrap:hover .select-chevron,
html.light .archive-select-wrap:focus-within .select-chevron {
    color: #b47814;
}

/* Live Search Box */
.archive-search-wrap {
    position: relative;
    width: 100%;
}

.archive-search-input {
    width: 100%;
    min-height: 44px;
    height: 44px;
    padding: 0 14px 0 38px;
    background: rgba(8, 9, 12, 0.6);
    border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
    border-radius: var(--radius-md, 10px);
    color: var(--text-primary, #ffffff);
    font-family: var(--font-sans, inherit);
    font-size: 16px; /* iOS zoom prevention */
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.archive-search-input:focus {
    border-color: var(--accent-gold, #d4af37);
    box-shadow: 0 0 0 2px rgba(212, 175, 55, 0.2);
}

.archive-search-input::placeholder {
    color: var(--text-muted, #64748b);
    font-size: 0.88rem;
}

.search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    pointer-events: none;
    color: var(--text-muted, #94a3b8);
}

/* Stats & Density Strip */
.archive-stats-strip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    font-family: var(--font-mono, monospace);
    font-size: 0.78rem;
    color: var(--text-muted, #94a3b8);
}

.archive-stats-count {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    letter-spacing: 0.04em;
}

.archive-density-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(0, 0, 0, 0.3);
    padding: 3px;
    border-radius: var(--radius-md, 8px);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.archive-density-btn {
    min-width: 38px;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-muted, #94a3b8);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.archive-density-btn:hover {
    color: var(--text-primary, #ffffff);
}

.archive-density-btn.active {
    background: rgba(212, 175, 55, 0.2);
    color: var(--accent-gold, #d4af37);
}

/* ==============================================================================
   3. ARCHIVE EMPTY STATE & LOADER
   ============================================================================== */
.archive-empty {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(48px, 8vh, 96px) 20px;
    text-align: center;
    background: var(--bg-card, rgba(14, 18, 27, 0.5));
    border: 1px dashed var(--border-medium, rgba(255, 255, 255, 0.12));
    border-radius: var(--radius-lg, 16px);
    margin: 20px 0;
}

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

.archive-empty-icon {
    font-size: 2.5rem;
    margin-bottom: 14px;
    color: var(--accent-gold, #d4af37);
}

.archive-empty-title {
    font-family: var(--font-display, inherit);
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--text-primary, #ffffff);
    margin: 0 0 8px 0;
}

.archive-empty-desc {
    font-size: 0.92rem;
    color: var(--text-secondary, #94a3b8);
    max-width: 440px;
    line-height: 1.6;
    margin: 0 auto 20px auto;
}

.archive-reset-btn {
    min-height: 44px;
    padding: 0 24px;
    border-radius: var(--radius-pill, 9999px);
    background: rgba(212, 175, 55, 0.15);
    border: 1px solid var(--accent-gold, #d4af37);
    color: var(--accent-gold, #d4af37);
    font-family: var(--font-sans, inherit);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.archive-reset-btn:hover {
    background: var(--accent-gold, #d4af37);
    color: #08090c;
}

.archive-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 48px 0;
    width: 100%;
}

/* ==============================================================================
   4. ARCHIVE BENTO GRID & DENSITY MODES
   ============================================================================== */
.archive-grid,
#archive-feed {
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
    transition: opacity 0.25s ease;
}

/* Bento Layout Mode: Structured proportions & fluid dense packing */
.archive-grid.density-bento,
#archive-feed.density-bento {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(clamp(200px, 16vw, 260px), 1fr));
    grid-auto-rows: clamp(160px, 18vw, 220px);
    grid-auto-flow: dense;
    gap: var(--grid-gutter, clamp(10px, 1.4vw, 16px));
    columns: unset !important;
}

/* Cell Constraints: Standard, landscape & portrait bounds */
.archive-grid.density-bento .photo-card,
#archive-feed.density-bento .photo-card {
    grid-column: span 1;
    grid-row: span 1;
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: 100%;
    margin-bottom: 0 !important;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    border-radius: var(--radius-md, 8px);
    overflow: hidden;
}

/* Landscape and panoramic photos span 2 columns without excessive vertical height */
.archive-grid.density-bento .photo-card.is-landscape,
#archive-feed.density-bento .photo-card.is-landscape,
.archive-grid.density-bento .photo-card.is-panoramic,
#archive-feed.density-bento .photo-card.is-panoramic {
    grid-column: span 2;
    grid-row: span 1;
}

/* Portrait photos span 2 vertical rows to balance proportions harmoniously */
.archive-grid.density-bento .photo-card.is-portrait,
#archive-feed.density-bento .photo-card.is-portrait {
    grid-column: span 1;
    grid-row: span 2;
}

/* Frame constraints: Fills cell geometry cleanly without distortion */
.archive-grid.density-bento .photo-card-frame,
#archive-feed.density-bento .photo-card-frame {
    width: 100%;
    height: 100%;
    min-height: 100%;
    max-height: 100%;
    aspect-ratio: auto !important;
    position: relative;
    overflow: hidden;
    background: var(--bg-surface, #12141a);
}

/* Image sizing: Disciplined cover fitting, preventing oversized rendering */
.archive-grid.density-bento .photo-img,
#archive-feed.density-bento .photo-img {
    width: 100%;
    height: 100%;
    max-height: 100%;
    object-fit: cover !important;
    object-position: center !important;
    display: block;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.archive-grid.density-bento .photo-lqip,
#archive-feed.density-bento .photo-lqip {
    width: 100%;
    height: 100%;
    object-fit: cover !important;
}

/* Archive Uniform Grid Mode alignment */
.archive-grid.density-grid,
#archive-feed.density-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(clamp(170px, 15vw, 230px), 1fr));
    gap: var(--grid-gutter, clamp(10px, 1.4vw, 16px));
}

.archive-grid.density-grid .photo-card-frame,
#archive-feed.density-grid .photo-card-frame {
    aspect-ratio: 1 / 1 !important;
    height: auto;
}

/* ==============================================================================
   5. RESPONSIVE MOBILE BREAKPOINTS
   ============================================================================== */
@media (max-width: 900px) {
    .archive-filter-row {
        grid-template-columns: 1fr 1fr;
    }
    .archive-search-group {
        grid-column: span 2;
    }
    .archive-grid.density-bento,
    #archive-feed.density-bento {
        grid-template-columns: repeat(auto-fill, minmax(clamp(160px, 22vw, 220px), 1fr));
        grid-auto-rows: clamp(140px, 20vw, 180px);
        gap: 10px;
    }
}

@media (max-width: 600px) {
    .archive-filter-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .archive-search-group {
        grid-column: span 1;
    }
    .archive-stats-strip {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    .archive-grid.density-bento,
    #archive-feed.density-bento {
        grid-template-columns: repeat(2, 1fr) !important;
        grid-auto-rows: clamp(130px, 34vw, 160px);
        gap: 8px;
    }
    .archive-grid.density-bento .photo-card.is-landscape,
    #archive-feed.density-bento .photo-card.is-landscape,
    .archive-grid.density-bento .photo-card.is-panoramic,
    #archive-feed.density-bento .photo-card.is-panoramic {
        grid-column: span 2;
        grid-row: span 1;
    }
    .archive-grid.density-bento .photo-card.is-portrait,
    #archive-feed.density-bento .photo-card.is-portrait {
        grid-column: span 1;
        grid-row: span 2;
    }
}

@media (max-width: 380px) {
    .archive-grid.density-bento,
    #archive-feed.density-bento {
        grid-template-columns: repeat(2, 1fr) !important;
        grid-auto-rows: clamp(110px, 32vw, 140px);
        gap: 6px;
    }
}

