/* features/static/features/css/front/gallery.css - the card's Gallery tab (features/front/gallery.html) */

/* Gallery Controls */
.section-title {
    flex-wrap: wrap;
}

.gallery-controls {
    display: flex;
    align-items: center;
    /* end of the title row in LTR and RTL (ms-auto was a physical margin-left) */
    margin-inline-start: auto;
}

/* view toggle = shared .fx-segmented control (features-common.css) */

/* ------------------------------------------------------------------
 * Albums: a strip of album cards above the photos (All / albums / Other)
 * ---------------------------------------------------------------- */
.gallery-albums {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 4px 2px 8px;
    margin: 4px 0 6px;
    scroll-snap-type: x proximity;
}

.gallery-albums::-webkit-scrollbar {
    display: none;
}

.album-card {
    flex: 0 0 auto;
    width: 96px;
    padding: 0;
    border: 0;
    background: none;
    text-align: center;
    cursor: pointer;
    color: inherit;
    scroll-snap-align: start;
    transition: transform 0.2s ease;
}

.album-card:hover {
    transform: translateY(-2px);
}

/* no ring after a tap/click (the theme outlined focused buttons); keyboard focus still shows one */
.album-card:focus,
.album-card:active {
    outline: none;
    box-shadow: none;
}

.album-card:focus-visible .album-cover {
    outline: 2px solid var(--primary-color, #0d6efd);
    outline-offset: 2px;
}

.album-cover {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 96px;
    height: 72px;
    margin-bottom: 6px;
    border-radius: 10px;
    overflow: hidden;
    background: #eef0f3;
    color: #8a9099;
    font-size: 1.25rem;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.2s ease;
}

/* the cover photo sits over the fallback icon (a broken cover removes itself) */
.album-cover img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.album-cover-all {
    background: color-mix(in srgb, var(--primary-color, #0d6efd) 12%, #fff);
    color: var(--primary-color, #0d6efd);
}

.album-card:hover .album-cover img {
    transform: scale(1.05);
}

.album-name {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--dark-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* active album: coloured name with a short bar under it (no frame around the cover) */
.album-card.active .album-name {
    color: var(--primary-color, #0d6efd);
    font-weight: 600;
}

.album-card .album-count {
    position: relative;
    padding-bottom: 5px;
}

.album-card.active .album-count::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 18px;
    height: 3px;
    border-radius: 3px;
    background: var(--primary-color, #0d6efd);
    transform: translateX(-50%);
}

.album-count {
    display: block;
    font-size: 0.65rem;
    color: #8a9099;
}

.gallery-album-heading {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin: 2px 0 4px;
    font-size: 0.9rem;
}

.gallery-album-heading[hidden] {
    display: none;
}

.gallery-album-title {
    font-weight: 600;
    color: var(--dark-color);
}

.gallery-album-total {
    font-size: 0.75rem;
}

/* Gallery Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin: 10px 0;
    transition: all 0.3s ease;
}

/* List Layout */
.gallery-grid.list-layout {
    grid-template-columns: 1fr;
    gap: 6px;
}

.gallery-grid.list-layout .gallery-item {
    aspect-ratio: auto;
}

.gallery-grid.list-layout .gallery-item-inner {
    aspect-ratio: 16/9;
    max-height: 200px;
}

.gallery-grid.list-layout .gallery-overlay {
    opacity: 1;
    transform: translateY(0);
    background: linear-gradient(to top, rgba(0, 0, 0, 0.75) 0%, rgba(0, 0, 0, 0) 100%);
}

.gallery-grid.list-layout .gallery-content {
    transform: translateY(0);
}

/* Gallery Item Wrapper */
.gallery-item-wrapper {
    position: relative;
}

.gallery-item-wrapper[hidden] {
    display: none !important;
}

/* no focus frame on the photo after a tap/click; keyboard focus keeps one */
.gallery-item:focus {
    outline: none;
}

.gallery-item:focus-visible {
    outline: 2px solid var(--primary-color, #0d6efd);
    outline-offset: 2px;
}

/* ------------------------------------------------------------------
 * Like heart: bottom corner of the tile, and in the viewer's caption bar
 * ---------------------------------------------------------------- */
.gallery-like {
    position: absolute;
    bottom: 6px;
    inset-inline-end: 6px;
    z-index: 6;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border: 0;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 0.72rem;
    line-height: 1.4;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: transform 0.15s ease, background 0.15s ease;
}

.gallery-like:hover {
    background: rgba(0, 0, 0, 0.72);
}

.gallery-like:active {
    transform: scale(0.92);
}

.gallery-like:focus {
    outline: none;
}

.gallery-like:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 1px;
}

.gallery-like.liked i {
    color: #ff4d6d;
}

.gallery-like:disabled {
    cursor: default;
    opacity: 1;
}

.gallery-grid.list-layout .gallery-like {
    bottom: 10px;
    inset-inline-end: 10px;
}

/* the hover caption leaves room for the heart */
.gallery-overlay {
    padding-inline-end: 64px !important;
}

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

.gallery-like.gallery-like-viewer {
    position: static;
    padding: 5px 12px;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.12);
}

.gallery-like.gallery-like-viewer:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Gallery Item */
.gallery-item {
    position: relative;
    display: block;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    aspect-ratio: 1;
    text-decoration: none;
    transition: all 0.3s ease;
}

.gallery-item:hover {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.gallery-item.featured {
    box-shadow: 0 0 0 2px #ff9900;
}

.gallery-item.no-image {
    pointer-events: none;
    cursor: default;
}

/* Gallery Item Inner */
.gallery-item-inner {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #f8f9fa;
}

/* Gallery Image */
.gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery-item:hover .gallery-image {
    transform: scale(1.05);
}

/* Image Fallback */
.image-fallback {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 10px;
    gap: 4px;
}

/* ------------------------------------------------------------------
 * Before / after: "after" underneath, "before" clipped to the inline-start
 * side up to --ba-pos; the viewer adds a range input on top to drag it.
 * ---------------------------------------------------------------- */
.ba-compare {
    --ba-pos: 50%;
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    user-select: none;
}

.ba-compare .ba-after,
.ba-compare .ba-before {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ba-compare .ba-before {
    clip-path: inset(0 calc(100% - var(--ba-pos)) 0 0);
}

[dir="rtl"] .ba-compare .ba-before {
    clip-path: inset(0 0 0 calc(100% - var(--ba-pos)));
}

.ba-divider {
    position: absolute;
    top: 0;
    bottom: 0;
    inset-inline-start: var(--ba-pos);
    width: 2px;
    margin-inline-start: -1px;
    background: #fff;
    box-shadow: 0 0 6px rgba(0, 0, 0, 0.35);
    pointer-events: none;
}

.ba-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #fff;
    color: #333;
    font-size: 0.8rem;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.35);
    transform: translate(-50%, -50%);
}

.ba-label {
    position: absolute;
    bottom: 6px;
    z-index: 2;
    padding: 2px 8px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    border-radius: 3px;
    text-transform: uppercase;
    pointer-events: none;
}

.ba-label-before {
    inset-inline-start: 6px;
}

.ba-label-after {
    inset-inline-end: 6px;
}

/* tile: labels at the top, clear of the hover caption */
.gallery-item .ba-label {
    top: 6px;
    bottom: auto;
}

.gallery-item:hover .ba-compare img {
    transform: none;
}

/* viewer: a big comparison with a full-surface (invisible) range input */
.ba-viewer {
    width: 100%;
    background: #000;
}

.ba-compare-lg {
    /* fits the viewer without scrolling: the caption bar needs the rest of the height */
    width: min(100%, calc(60vh * 4 / 3));
    height: auto;
    aspect-ratio: 4 / 3;
    margin: 0 auto;
}

.ba-compare-lg .ba-after,
.ba-compare-lg .ba-before {
    object-fit: contain;
    background: #000;
}

.ba-compare-lg .ba-handle {
    width: 40px;
    height: 40px;
    font-size: 1rem;
}

.ba-compare-lg .ba-label {
    bottom: 12px;
    font-size: 12px;
    padding: 4px 10px;
}

.ba-range {
    position: absolute;
    inset: 0;
    z-index: 3;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: ew-resize;
    touch-action: pan-y;
    -webkit-appearance: none;
    appearance: none;
}

.ba-compare-lg:focus-within .ba-handle {
    outline: 3px solid var(--primary-color, #0d6efd);
    outline-offset: 2px;
}

/* ------------------------------------------------------------------
 * Photo viewer (GLightbox) caption: readable title, caption, meta, link
 * (the theme painted the title black on the black caption bar)
 * ---------------------------------------------------------------- */
.glightbox-container .gslide-description {
    background: rgba(0, 0, 0, 0.82);
}

.glightbox-container .gslide-title {
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.glightbox-container .gslide-desc {
    color: rgba(255, 255, 255, 0.88);
    font-size: 0.875rem;
    line-height: 1.55;
    max-height: 30vh;
    overflow-y: auto;
}

.glightbox-container .gslide-inline {
    background: #000;
    padding: 0;
    max-height: none;
    overflow: hidden;
}

.glightbox-container .gslide-inline .ginlined-content {
    padding: 0;
}

.gallery-viewer-caption {
    margin: 0 0 8px;
    white-space: pre-line;
}

/* a Latin caption on a Persian card (or the reverse) keeps its own direction and punctuation */
.glightbox-container .gslide-title,
.gallery-viewer-caption,
.gallery-title,
.gallery-description {
    unicode-bidi: plaintext;
}

.gallery-viewer-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 14px;
    margin: 0 0 8px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
}

.gallery-viewer-meta i,
.gallery-viewer-link i {
    margin-inline-end: 4px;
}

/* Badges */
.gallery-badge {
    position: absolute;
    top: 6px;
    padding: 4px 7px;
    border-radius: 4px;
    font-size: 10px;
    color: white;
    z-index: 5;
    line-height: 1;
    backdrop-filter: blur(4px);
}

.gallery-badge-featured {
    inset-inline-start: 6px;
    background: #ff9900;
}

/* a before/after tile already has its "Before" label in that corner */
.gallery-item .ba-compare ~ .gallery-badge-featured {
    top: 30px;
}

/* Gallery Overlay */
.gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, transparent 100%);
    color: white;
    padding: 20px 10px 10px;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.gallery-item:hover .gallery-overlay,
.gallery-item:focus-visible .gallery-overlay {
    transform: translateY(0);
}

/* Gallery Content */
.gallery-content {
    transform: translateY(10px);
    transition: transform 0.3s ease;
}

.gallery-item:hover .gallery-content {
    transform: translateY(0);
}

.gallery-title {
    font-size: 0.85rem;
    font-weight: 600;
    margin: 0 0 2px;
    line-height: 1.2;
}

.gallery-description {
    font-size: 0.7rem;
    opacity: 0.85;
    margin: 0;
    line-height: 1.3;
}

/* Empty State */
.empty-state {
    padding: 40px 20px;
}

/* Mobile */
@media (max-width: 380px) {
    .gallery-grid {
        gap: 6px;
    }

    .gallery-title {
        font-size: 0.75rem;
    }

    .gallery-description {
        font-size: 0.65rem;
    }
}
