/* Homepage gallery — staggered photo wall (<x-uowa.index.gallery>).

   Masonry with a flat bottom edge (see Wall), a quiet
   hover (scrim, category, two-line title, corner mark), and the filters in a
   bar under the wall. Everything is .ul-hg-*, so style.css's old mosaic and
   overlay rules for .ul-gallery-* never reach it. */

.ul-hg {
    --hg-gap: 16px;
    --hg-radius: 12px;
    --hg-ink: var(--ul-primary, #041c33);
    --hg-gold: var(--ul-c3, #febe35);
}

.ul-hg .ul-section-heading {
    margin-bottom: clamp(28px, 3vw, 44px);
}

/* --------------------------------------------------------------------------
   Wall

   gallery.js deals the tiles into .ul-hg-col columns (each tile to the
   shortest column so far) and gives each its shape in --hg-ratio. The columns
   stretch to the tallest one and their tiles grow to fill it, so the wall
   ends on one straight line with no gap under a short column. Without the
   script the tiles fall back to a plain 4-up grid.
   -------------------------------------------------------------------------- */
.ul-hg-grid {
    --hg-cols: 4;

    display: grid;
    grid-template-columns: repeat(var(--hg-cols), minmax(0, 1fr));
    align-items: stretch;
    gap: var(--hg-gap);
}

.ul-hg-col {
    display: flex;
    flex-direction: column;
    gap: var(--hg-gap);
    min-width: 0;
}

.ul-hg-item {
    position: relative;
    /* Grows past its shape when its column is shorter than the tallest. */
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    border-radius: var(--hg-radius);
    overflow: hidden;
    background: #e9edf2;
    aspect-ratio: var(--hg-ratio, 4 / 3);
}

/* Entrance, only once gallery.js has run (it adds .is-js). */
.ul-hg-grid.is-js .ul-hg-item {
    opacity: 0;
    transform: translateY(14px);
    transition:
        opacity 0.5s ease var(--hg-delay, 0ms),
        transform 0.6s cubic-bezier(0.22, 1, 0.36, 1) var(--hg-delay, 0ms);
}

.ul-hg-grid.is-js .ul-hg-item.is-in {
    opacity: 1;
    transform: none;
}

.ul-hg-link {
    position: absolute;
    inset: 0;
    display: block;
    color: #fff;
    text-decoration: none;
}

.ul-hg-link img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

/* --------------------------------------------------------------------------
   Hover
   -------------------------------------------------------------------------- */

/* Scrim: only the bottom third darkens, and only on hover. */
.ul-hg-link::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(4, 28, 51, 0.82) 0%, rgba(4, 28, 51, 0.35) 38%, rgba(4, 28, 51, 0) 62%);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.ul-hg-caption {
    position: absolute;
    z-index: 1;
    inset-inline: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 16px 14px;
    text-align: start;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.35s ease, transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.ul-hg-cat {
    /* meta role */
    font-size: var(--t-meta);
    font-weight: 700;
    line-height: var(--lh-ui);
    color: var(--hg-gold);
}

.ul-hg-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    /* card role */
    font-size: var(--t-card);
    font-weight: 700;
    line-height: var(--lh-heading);
    color: #fff;
}

.ul-hg-mark {
    position: absolute;
    z-index: 1;
    top: 12px;
    inset-inline-end: 12px;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    font-size: 13px;
    color: var(--hg-ink);
    background: rgba(255, 255, 255, 0.92);
    border-radius: 50%;
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

/* A video says so at rest, not only on hover. */
.ul-hg-item.is-video .ul-hg-mark {
    opacity: 1;
    transform: none;
    color: #fff;
    background: rgba(4, 28, 51, 0.7);
}

.ul-hg-item:hover .ul-hg-link img,
.ul-hg-link:focus-visible img {
    transform: scale(1.05);
}

.ul-hg-item:hover .ul-hg-link::after,
.ul-hg-link:focus-visible::after,
.ul-hg-item:hover .ul-hg-caption,
.ul-hg-link:focus-visible .ul-hg-caption,
.ul-hg-item:hover .ul-hg-mark,
.ul-hg-link:focus-visible .ul-hg-mark {
    opacity: 1;
    transform: none;
}

.ul-hg-item.is-video:hover .ul-hg-mark {
    color: var(--hg-ink);
    background: var(--hg-gold);
}

.ul-hg-link:focus-visible {
    outline: 3px solid var(--hg-gold);
    outline-offset: -3px;
}

/* No hover on touch: show the caption at rest, so a phone still sees it. */
@media (hover: none) {
    .ul-hg-link::after,
    .ul-hg-caption {
        opacity: 1;
        transform: none;
    }

    .ul-hg-title {
        -webkit-line-clamp: 1;
    }
}

/* --------------------------------------------------------------------------
   Filter bar — above the wall, centred
   -------------------------------------------------------------------------- */
.ul-hg-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px 16px;
    margin-bottom: clamp(20px, 2.4vw, 32px);
}

.ul-hg-filters {
    display: flex;
    gap: 4px;
    max-width: 100%;
    padding: 5px;
    overflow-x: auto;
    scrollbar-width: none;
    background: var(--hg-ink);
    border-radius: 999px;
}

.ul-hg-filters::-webkit-scrollbar {
    display: none;
}

.ul-hg-filter-btn {
    flex: 0 0 auto;
    padding: 9px 18px;
    /* label role */
    font-size: var(--t-label);
    font-weight: 700;
    line-height: var(--lh-ui);
    white-space: nowrap;
    color: rgba(255, 255, 255, 0.78);
    background: transparent;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 0.25s ease, color 0.25s ease;
}

.ul-hg-filter-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.ul-hg-filter-btn.active {
    color: var(--hg-ink);
    background: #fff;
}

.ul-hg-all {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    font-size: 13.5px;
    font-weight: 700;
    color: var(--hg-ink);
    background: #fff;
    border: 1px solid rgba(4, 28, 51, 0.16);
    border-radius: 999px;
    text-decoration: none;
    transition: background-color 0.25s ease, border-color 0.25s ease;
}

.ul-hg-all i {
    font-size: 12px;
    color: var(--hg-gold);
    transition: transform 0.3s ease;
}

.ul-hg-all:hover {
    color: var(--hg-ink);
    background: var(--hg-gold);
    border-color: var(--hg-gold);
}

.ul-hg-all:hover i {
    color: var(--hg-ink);
}

/* «عرض الكل» is a filter now, not a link: when it is the active filter the
   pill goes gold, the way the category pills go white. */
.ul-hg-all.active,
.ul-hg-all.active:hover {
    color: var(--hg-ink);
    background: var(--hg-gold);
    border-color: var(--hg-gold);
}

.ul-hg-all.active i {
    color: var(--hg-ink);
}

/* The way through to the full gallery page, under the wall. */
.ul-hg-foot {
    display: flex;
    justify-content: center;
    margin-top: clamp(22px, 2.4vw, 32px);
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media screen and (max-width: 1199px) {
    .ul-hg-grid:not(.is-js) {
        --hg-cols: 3;
    }
}

@media screen and (max-width: 767px) {
    .ul-hg {
        --hg-gap: 10px;
        --hg-radius: 10px;
    }

    .ul-hg-grid:not(.is-js) {
        --hg-cols: 2;
    }

    .ul-hg-caption {
        padding: 10px 10px 9px;
    }


    .ul-hg-mark {
        top: 8px;
        inset-inline-end: 8px;
        width: 30px;
        height: 30px;
        font-size: 11px;
    }

    .ul-hg-filter-btn {
        padding: 8px 14px;
    }
}
