/* ============================================================
   Shared layout styles — loaded after each variant CSS so these
   rules win on the projects index when a layout class is set.
   ============================================================ */

/* --- Mosaic: Pinterest-style asymmetric columns --- */
.projects-layout-mosaic {
    display: block !important;
    columns: 3;
    column-gap: 24px;
    grid-template-columns: none !important;
}
.projects-layout-mosaic > * {
    break-inside: avoid;
    margin-bottom: 24px;
    display: block !important;
    width: 100%;
}
/* The grid layout pins every card to a fixed height (380px), which makes the
   masonry columns line up into a uniform grid. In mosaic each card's height
   must follow its image's natural aspect ratio so the columns stagger. */
.projects-layout-mosaic .project-card-link {
    height: auto !important;
}
.projects-layout-mosaic .project-card-image {
    height: auto !important;
    width: 100% !important;
}
/* Placeholder cards have no intrinsic image — give them varied ratios so the
   stagger still reads even without photos. */
.projects-layout-mosaic .project-placeholder.project-card-image { aspect-ratio: 3 / 4; }
.projects-layout-mosaic .project-card-link:nth-child(3n+2) .project-placeholder.project-card-image { aspect-ratio: 1 / 1; }
.projects-layout-mosaic .project-card-link:nth-child(3n+3) .project-placeholder.project-card-image { aspect-ratio: 4 / 5; }
@media (max-width: 900px) { .projects-layout-mosaic { columns: 2; } }
@media (max-width: 600px) { .projects-layout-mosaic { columns: 1; } }

/* --- List: image left, content right --- */
.projects-layout-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
    grid-template-columns: none !important;
}
.projects-layout-list > * {
    display: flex !important;
    flex-direction: row !important;
    gap: 20px;
    align-items: stretch;
    width: 100%;
    height: auto !important;
}
.projects-layout-list .project-card-image {
    width: 220px !important;
    max-width: 220px;
    height: 160px !important;
    flex-shrink: 0;
    object-fit: cover;
}
@media (max-width: 600px) {
    .projects-layout-list > * { flex-direction: column !important; }
    .projects-layout-list .project-card-image { width: 100% !important; max-width: none; height: 220px !important; }
}

/* --- Pagination --- */
.pagination-wrap {
    margin: 32px 0;
    display: flex;
    justify-content: center;
}
.site-pagination {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
}
.site-pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    padding: 8px 12px;
    border: 1px solid currentColor;
    border-radius: 6px;
    color: inherit;
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.15s ease;
    opacity: 0.7;
}
.site-pagination-link:hover { opacity: 1; }
.site-pagination-link.active {
    opacity: 1;
    font-weight: 700;
    background: rgba(127, 127, 127, 0.18);
}
.site-pagination-link.disabled { opacity: 0.3; pointer-events: none; }

/* --- News gallery grid --- */
.news-gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-top: 0;
}
.news-gallery-item {
    display: block;
    overflow: hidden;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.1);
    aspect-ratio: 4 / 3;
    position: relative;
}
.news-gallery-item img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    transition: transform 0.4s ease;
}
.news-gallery-item:hover img { transform: scale(1.05); }

@media (max-width: 1100px) { .news-gallery-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px)  { .news-gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; } }
@media (max-width: 420px)  { .news-gallery-grid { grid-template-columns: 1fr; } }

/* --- News slideshow (per-article alternative to the grid) --- */
.news-slideshow {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: rgba(0, 0, 0, 0.15);
}
.news-slideshow-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
}
.news-slide {
    position: absolute;
    inset: 0;
    margin: 0;
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
}
.news-slide.is-active {
    opacity: 1;
    pointer-events: auto;
}
.news-slide img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.news-ss-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    font: 600 26px/1 system-ui, sans-serif;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.18s;
    z-index: 2;
}
.news-ss-btn:hover { background: rgba(0, 0, 0, 0.7); }
.news-ss-btn[data-dir="prev"] { left: 14px; }
.news-ss-btn[data-dir="next"] { right: 14px; }
.news-ss-dots {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 2;
}
.news-ss-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.45);
    cursor: pointer;
    padding: 0;
    transition: background 0.18s, transform 0.18s;
}
.news-ss-dot.is-active { background: #fff; transform: scale(1.25); }
@media (max-width: 600px) {
    .news-ss-btn { width: 38px; height: 38px; font-size: 22px; }
}

/* --- Lightbox for gallery --- */
.news-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(8, 12, 18, 0.92);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.news-lightbox.is-open {
    display: flex;
    opacity: 1;
}
.news-lightbox-stage {
    position: relative;
    max-width: 92vw;
    max-height: 88vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.news-lightbox-img {
    max-width: 92vw;
    max-height: 88vh;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    border-radius: 6px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    user-select: none;
    -webkit-user-drag: none;
}
.news-lightbox-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    font: 600 22px/1 system-ui, sans-serif;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.18s, transform 0.18s;
    padding: 0;
}
.news-lightbox-btn:hover { background: rgba(255, 255, 255, 0.2); }
.news-lightbox-btn:active { transform: translateY(-50%) scale(0.96); }
.news-lightbox-btn[data-dir="prev"] { left: -64px; }
.news-lightbox-btn[data-dir="next"] { right: -64px; }
.news-lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    font: 400 22px/1 system-ui, sans-serif;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: background 0.18s;
}
.news-lightbox-close:hover { background: rgba(0, 0, 0, 0.7); }
.news-lightbox-counter {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    letter-spacing: 0.04em;
}
body.lightbox-open { overflow: hidden; }

@media (max-width: 720px) {
    .news-lightbox-btn[data-dir="prev"] { left: 8px; }
    .news-lightbox-btn[data-dir="next"] { right: 8px; }
    .news-lightbox-btn {
        background: rgba(0, 0, 0, 0.55);
    }
}
