/* ================================================================================
   STYLESHEET: gallery.css
   CREATED:    2026-03-15
   MODIFIED:   2026-03-15
   PURPOSE:    Gallery topbar, navigation pill, breadcrumbs, search, grid, cards,
               badges, and empty state styles
   ================================================================================ */

/* ========== GALLERY TOPBAR ========== */
/* 2026-03-06 - Unified topbar: matching home topbar exactly */
.gallery-topbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 72px;
    padding: 14px var(--app-padding);
    background: rgba(250, 250, 252, 0.75);
    backdrop-filter: blur(40px) saturate(1.8);
    -webkit-backdrop-filter: blur(40px) saturate(1.8);
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    z-index: 100;
    overflow: visible;
}
/* 2026-03-05 - Add Object button in topbar */
.gallery-add-btn {
    margin-left: auto;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: #2563eb;
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.gallery-add-btn:active {
    opacity: 0.7;
}
/* 2026-03-06 - Unified: hide topbar add btn at all widths (use home/menu add instead) */
.gallery-topbar .gallery-add-btn {
    display: none !important;
}
/* 2026-03-05 - Card size slider in topbar right */
/* 2026-03-06 - Unified: slider hidden at all widths (size btns used instead) */
.card-size-slider-wrap {
    margin-left: 8px;
    display: none;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
/* 2026-03-06 - Home button on gallery topbar (narrow only) */
/* 2026-03-06 - Home button on gallery topbar (44px iOS standard) */
/* 2026-03-06 - Unified: show home btn at all widths */
.gallery-home-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 50%;
    border: none;
    background: #ececee;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    position: relative;
    z-index: 2;
}
.gallery-home-btn:active {
    opacity: 0.5;
}
/* 2026-03-06 - Search button hidden at all widths; search via 3-dot menu */
.gallery-search-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 50%;
    border: none;
    background: #ececee;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
}
.gallery-search-btn:active {
    opacity: 0.5;
}
/* 2026-03-06 - Gallery 3-dot menu inside pill (right end) */
/* 2026-03-07 - Gallery filter button: visible wide, hidden narrow (in 3-dot) */
.gallery-filter-wrap {
    display: flex;
    align-items: center;
    position: relative;
    flex-shrink: 0;
}
.gallery-filter-btn {
    display: flex;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #ececee;
    border: none;
    padding: 0;
    cursor: pointer;
    color: #999;
    align-items: center;
    justify-content: center;
}
.gallery-filter-btn.active {
    background: var(--accent-color);
    color: #fff;
}
.gallery-filter-popover {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 6px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.15);
    padding: 6px 0;
    z-index: 200;
    min-width: 200px;
}
.gallery-filter-popover.open {
    display: block;
}
/* Gallery 3-dot menu always shows filter section (for narrow fallback) */
/* 2026-03-15 - Pill search button (right end of nav pill, replaces 3-dot menu) */
.gallery-pill-search-wrap {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    margin-left: auto;
}
/* 2026-03-15 - Extra right padding so eyeglass doesn't crowd pill edge */
.gallery-pill-search-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: none;
    padding: 0;
    margin-right: 6px;
    cursor: pointer;
    color: var(--text-tertiary);
    transition: color 0.15s;
}
.gallery-pill-search-btn:hover {
    color: var(--text-primary);
}
/* 2026-03-15 - Topbar action icons (right side, replaces 3-dot dropdown) */
/* 2026-03-15 - Push to far right of topbar */
.gallery-topbar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    margin-left: auto;
}
.gallery-topbar-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
    color: var(--text-tertiary);
    transition: background 0.15s, color 0.15s;
}
.gallery-topbar-icon:hover {
    background: rgba(0,0,0,0.06);
    color: var(--text-primary);
}
.gallery-topbar-icon:active {
    background: rgba(0,0,0,0.1);
}
.card-size-slider-wrap svg {
    color: var(--text-tertiary);
    flex-shrink: 0;
}
.card-size-slider-track {
    position: relative;
    width: 160px;
    display: flex;
    align-items: center;
}
.card-size-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 3px;
    background: var(--text-tertiary);
    border-radius: 2px;
    outline: none;
    opacity: 0.6;
    position: relative;
    z-index: 3;
}
.card-size-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--text-secondary);
    cursor: pointer;
}
/* 2026-03-05 - Default-dot sits behind slider, visible when thumb moves away */
.card-size-default-dot {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--text-tertiary);
    background: var(--bg-primary, #fff);
    cursor: pointer;
    z-index: 2;
}

/* 2026-03-14 - gallery-size-btns CSS removed (narrow mode removed) */

/* 2026-03-14 - Gallery nav pill (renamed from gallery-narrow-nav, shown at all widths) */
/* 2026-03-06 - Pill capped at 400px, absolute-centered on window midline */
.gallery-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
    max-width: calc(100% - 282px);
    background: #ececee;
    border-radius: 22px;
    height: 44px;
    overflow: visible;
}
.gallery-nav-back {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s ease;
}
.gallery-nav-back:hover {
    background: #f0f0f2;
}
/* 2026-03-15 - flex:1 + justify-content:center to center label in pill */
.gallery-nav-label {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 4px;
    font-size: 15px;
    font-weight: 500;
    font-family: var(--font-family);
    color: var(--text-primary);
    background: none;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    min-width: 0;
    transition: background 0.15s ease;
}
.gallery-nav-label span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.gallery-nav-label:hover {
    background: #f0f0f2;
}
.gallery-nav-chevron {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    opacity: 0.5;
    transition: transform 0.2s ease;
}
.gallery-nav-chevron.open {
    transform: rotate(180deg);
}
/* Hide chevron when no subcategories */
.gallery-nav-chevron.hidden {
    display: none;
}
/* 2026-03-08 - Gallery dropdown matches home category dropdown style */
.gallery-nav-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    border: 1px solid #d9d9dd;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12),
                0 2px 8px rgba(0, 0, 0, 0.06);
    z-index: 200;
    padding: 4px 0;
    min-width: 240px;
    max-width: 340px;
    max-height: 400px;
    overflow-y: auto;
}
.gallery-nav-dropdown.open {
    display: block;
}
/* Reuse bc-item / bc-depth-* styles inside gallery dropdown */
/* 2026-03-15 - Center-justify dropdown items */
.gallery-nav-dropdown .bc-item { cursor: pointer; transition: background 0.1s ease; justify-content: center; text-align: center; }
.gallery-nav-dropdown .bc-item:hover { background: #f5f5f7; }

/* Inline search: replaces breadcrumb content inside pill */
.gallery-nav-search {
    display: none;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
    padding: 0 16px;
    height: 100%;
}
.gallery-nav-search svg {
    flex-shrink: 0;
    color: var(--text-tertiary);
}
.gallery-nav-search-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: none;
    font-size: 14px;
    font-family: var(--font-family);
    color: var(--text-primary);
    outline: none;
}
.gallery-nav-search-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    border: none;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 50%;
    font-size: 10px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
}

/* ---------- Interactive Breadcrumb Navigation ---------- */
/* 2026-02-25 - Clickable breadcrumb segments with dropdown popovers */
/* 2026-03-06 - Unified: breadcrumb hidden at all widths (narrow nav used instead) */
.breadcrumb-nav {
    display: none;
    align-items: center;
    gap: 0;
    min-width: 0;
}

/* Each segment: clickable label that opens a popover */
.bc-segment {
    position: relative;
    display: flex;
    align-items: center;
    min-width: 0;
}
.bc-btn {
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 4px 6px;
    font-size: 13px;
    font-family: var(--font-family);
    color: var(--text-secondary);
    background: none;
    border: 1px solid transparent;
    border-radius: 5px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    transition: all 0.15s ease;
}
.bc-btn:hover {
    background: #f0f0f2;
    color: var(--text-primary);
}
.bc-segment.open .bc-btn {
    background: #e8e8ec;
    color: var(--text-primary);
}
/* Last segment (current selection) is bolder */
.bc-segment:last-child .bc-btn {
    color: var(--text-primary);
    font-weight: 500;
}
/* Down chevron inside the button */
.bc-chevron-down {
    flex-shrink: 0;
    width: 10px;
    height: 10px;
    stroke: currentColor;
    opacity: 0.5;
    pointer-events: none;
}

/* Separator chevron between segments */
.bc-sep {
    flex-shrink: 0;
    width: 12px;
    height: 12px;
    stroke: var(--text-tertiary);
    margin: 0 1px;
}

/* Popover panel (reused from before) */
.bc-popover {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 200px;
    max-width: 320px;
    max-height: 380px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--input-border);
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12),
                0 2px 8px rgba(0, 0, 0, 0.06);
    z-index: 200;
    padding: 4px 0;
}
.bc-segment.open .bc-popover {
    display: block;
}

/* Popover items */
/* 2026-03-09 - Increased side padding +15px */
.bc-item {
    display: flex;
    align-items: center;
    padding: 7px 29px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.1s ease;
}
.bc-item:hover {
    background: #f5f5f7;
}
.bc-item.active {
    color: var(--accent-color);
    font-weight: 500;
}
/* 2026-03-07 - Hierarchy depth styles for category dropdowns */
.bc-item.bc-depth-0 {
    font-weight: 600;
    font-size: 13px;
}
.bc-item.bc-depth-0.bc-group-sep {
    border-top: 1px solid var(--separator-color, #e5e5e5);
    margin-top: 4px;
    padding-top: 10px;
}
.bc-item.bc-depth-1 {
    font-weight: 400;
    font-size: 12.5px;
    color: var(--text-secondary, #666);
}
.bc-item.bc-depth-2 {
    font-weight: 400;
    font-size: 12px;
    color: #999;
}
/* Section divider inside popover (between "All" and items) */
.bc-item.bc-item-all {
    border-bottom: 1px solid var(--separator-color);
    margin-bottom: 2px;
}

/* Plain breadcrumb button (no dropdown) */
.bc-btn-plain {
    gap: 0;
}
.bc-btn-plain:hover {
    text-decoration: underline;
}
/* Current/static breadcrumb label (no interaction) */
.bc-btn-current {
    cursor: default;
    color: var(--text-primary);
    font-weight: 500;
}
.bc-btn-current:hover {
    background: none;
    text-decoration: none;
    color: var(--text-primary);
}
/* Home icon button */
.bc-home-btn {
    padding: 4px 5px;
}
/* 2026-02-26 - Fixed size home icon, 30% larger */
.bc-home-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
.bc-home-btn:hover {
    text-decoration: none;
}

/* Count badge */
.bc-count {
    margin-left: auto;
    padding-left: 10px;
    font-size: 11px;
    font-weight: 400;
    color: var(--text-tertiary);
}

/* ---------- Search Input (pushed to right) ---------- */
.search-wrapper {
    flex: 0 1 280px;
    position: relative;
}
.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    stroke: var(--text-tertiary);
    pointer-events: none;
}
.search-input {
    width: 100%;
    height: 34px;
    padding: 0 28px 0 32px;
    font-size: 13px;
    font-family: var(--font-family);
    color: var(--text-primary);
    /* 2026-02-26 - Soft, minimal style inspired by macOS search bars */
    background: #f0f0f2;
    border: 1px solid transparent;
    border-radius: 20px;
    outline: none;
}
.search-input:focus {
    background: #e8e8ec;
    border-color: transparent;
}
.search-input::placeholder {
    color: var(--text-tertiary);
}
/* 2026-02-25 - Clear button inside search field */
.search-clear {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    padding: 0;
    font-size: 10px;
    line-height: 18px;
    text-align: center;
    color: var(--text-tertiary);
    background: #e0e0e2;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.15s ease;
}
.search-clear:hover {
    background: #ccc;
    color: var(--text-primary);
}

/* ---------- Result Count ---------- */
/* 2026-02-27 - Sticky search bar below topbar: count + search centered */
/* 2026-03-06 - Unified: search bar hidden at all widths */
.gallery-search-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-color);
    display: none;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px clamp(16px, 10vw, 100px);
    border-bottom: 1px solid var(--topbar-border);
}
.result-count {
    font-size: 12px;
    color: var(--text-tertiary);
    white-space: nowrap;
}

/* 2026-03-05 - Category filter dropdown — subtle, borderless style */
.gallery-cat-filter {
    font-size: 13px;
    padding: 4px 6px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23999' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 4px center;
    padding-right: 20px;
}
.gallery-cat-filter:hover {
    background: rgba(0,0,0,0.04);
    color: var(--text-primary);
}
.gallery-cat-filter:focus {
    outline: none;
    background: rgba(0,0,0,0.04);
}
/* 2026-03-14 - Narrow gallery-cat-filter @media removed (desktop-only) */

/* ========== GALLERY GRID ========== */
/* 2026-03-06 - Changed from absolute to flow; #page-gallery is now the scroll parent */
.gallery-scroll {
    position: relative;
}
.gallery-grid {
    display: grid;
    /* 2026-03-05 - Columns set dynamically by setCardScale() for smooth zoom */
    grid-template-columns: repeat(auto-fill, minmax(var(--card-min-width), 1fr));
    gap: var(--card-gap);
    /* 2026-03-08 - Side padding uses app-wide variable for alignment */
    padding: 32px var(--app-padding) 80px;
    justify-content: center;
}

/* ---------- Gallery Card ---------- */
/* 2026-03-08 - Padding around image so edges don't touch card outline */
.gallery-card {
    background: #ffffff;
    border-radius: var(--card-radius);
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: box-shadow 0.2s ease;
    padding: 20px 8px 0 8px;
    /* 2026-03-06 - Suppress iOS native long-press callout */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}
.gallery-card:hover {
    box-shadow: var(--card-hover-shadow);
}
/* 2026-03-06 - Unselected cards: muted label. Selected: clean white */
/* 2026-03-15 - Unselected labels barely fainter than selected (was 0.25) */
.gallery-card .card-label {
    opacity: 0.7;
}
/* 2026-03-15 - Selected cards: deeper shadow instead of outline */
.gallery-card.card-selected {
    outline: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.gallery-card.card-selected .card-label {
    opacity: 1;
}
/* 2026-03-05 - Only the label area (title + category) opens detail */
.card-label {
    cursor: pointer;
}
/* 2026-03-05 - Aspect ratio wrapper for landscape images */
/* 2026-03-09 - Uses shared .img-contain for rounded uncropped images */
.card-image-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
}
.card-image {
    /* 2026-03-06 - Prevent iOS native image long-press action sheet */
    -webkit-touch-callout: none;
    pointer-events: none;
}
/* Restore card-image background for cards without .img-contain */
.card-image-wrapper:not(.img-contain) {
    background: #ffffff;
}
/* 2026-03-13 - Apple-style photo placeholder for cards without images */
.card-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: #f5f5f7;
    color: #c7c7cc;
}
.card-title {
    padding: 8px 10px;
    font-size: var(--card-title-size);
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.card-category {
    padding: 0 10px 8px;
    font-size: 11px;
    color: var(--text-tertiary);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 2026-02-25 - Pin and review badges on gallery cards */
.card-badge {
    position: absolute;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    pointer-events: auto;
    cursor: pointer;
    transition: opacity 0.15s ease, background 0.15s ease;
}
/* 2026-03-10 - Inactive badges hidden by default, revealed on Cmd+hover */
.card-badge.badge-inactive {
    opacity: 0;
    pointer-events: none;
}
body.cmd-held .gallery-card:hover .card-badge.badge-inactive {
    opacity: 1;
    pointer-events: auto;
}
/* 2026-03-10 - Hide gallery badges when user lacks permission */
body.hide-badge-checked .card-badge-checked,
body.hide-badge-pin .card-badge-pin,
body.hide-badge-review .card-badge-review {
    display: none !important;
}
/* 2026-03-10 - Info panel visibility now handled in JS (selectHomeCard) */
/* 2026-03-07 - Badge colors (positions set in JS, left-to-right: check, pin, review) */
/* 2026-03-10 - Checked badge positioned on right side */
.card-badge-checked {
    top: 6px;
    right: 6px;
    background: rgb(34, 153, 79);
    color: #fff;
}
.card-badge-checked.badge-inactive {
    background: rgba(180, 180, 180, 0.5);
}
/* 2026-03-10 - Active badges fully opaque */
.card-badge-pin {
    top: 6px;
    background: rgb(250, 36, 59);
    color: #fff;
}
.card-badge-pin.badge-inactive {
    background: rgba(180, 180, 180, 0.5);
}
.card-badge-review {
    top: 6px;
    background: rgb(123, 97, 194);
    color: #fff;
}
.card-badge-review.badge-inactive {
    background: rgba(180, 180, 180, 0.5);
}
/* 2026-02-26 - Uncategorized badge on gallery cards */
.card-badge-uncategorized {
    bottom: 6px;
    left: 6px;
    background: rgba(184, 134, 11, 0.85);
    color: #fff;
}
/* ========== EMPTY STATE ========== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-tertiary);
}
.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}
.empty-state-text {
    font-size: 15px;
}
