/*
 * QSTI Projects page styles
 * Uses shared variables and header/footer styles from qsti-home.css.
 * Existing animations and gallery interactions remain in style.css/custom.css and JS libraries.
 */
.project-header {
    position: relative;
    isolation: isolate;
    min-height: 190px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1rem !important;
    background-image:
        linear-gradient(rgba(169, 13, 13, .66), rgba(132, 0, 0, .66)),
        url("../img/project-header.jpg");
    background-size: cover;
    background-position: center;
    border-top: 4px dotted #ff0000;
}
.project-header h1 {
    color: #fff;
    font-weight: 800;
    letter-spacing: -.025em;
}
.project-header h1 .text-primary { color: #FDBE33 !important; }
.project-header h4 {
    color: #fff !important;
    line-height: 1.55;
    font-weight: 600;
}
#qsti-project-gallery { scroll-margin-top: 90px; }
#portfolio-flters {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    justify-content: center;
    gap: .55rem;
    padding: 0;
}
#portfolio-flters li {
    width: auto;
    min-width: 145px;
    max-width: 100%;
    min-height: 52px;
    margin: 0 !important;
    padding: .7rem 1rem !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 8px;
    transition: transform .22s ease, box-shadow .22s ease, background-color .22s ease;
}
#portfolio-flters li:hover,
#portfolio-flters li:focus-visible {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(4, 15, 40, .16);
}
#portfolio-flters li.active {
    background: #930707 !important;
    border-color: #930707 !important;
    color: #fff !important;
}
#portfolio-flters li h6 {
    margin: 0 !important;
    line-height: 1.35;
    white-space: normal !important;
    font-size: .84rem;
}
.portfolio-container { align-items: stretch; }
.portfolio-item { margin-bottom: 1.25rem; }
.portfolio-box {
    height: 100%;
    overflow: hidden;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 5px 18px rgba(4, 15, 40, .08);
}
.portfolio-box > img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    transition: transform .45s ease;
}
.portfolio-box:hover > img { transform: scale(1.035); }
.portfolio-title { max-width: 100%; }
@media (max-width: 767.98px) {
    .project-header { min-height: 165px; padding: 2rem 1rem !important; }
    .project-header h1 { font-size: clamp(1.8rem, 7vw, 2.5rem); }
    .project-header h4 { font-size: .95rem; }
    #portfolio-flters { padding: 0 .25rem; }
    #portfolio-flters li { flex: 1 1 calc(50% - .55rem); min-width: 0; }
}
@media (prefers-reduced-motion: reduce) {
    #portfolio-flters li,
    .portfolio-box > img { transition: none !important; }
}

/* Header parity: shared header markup and qsti-home.css are used on every page. */
.project-header { margin: 0; }
.project-gallery-section {
    padding: clamp(2rem, 4vw, 3.5rem) clamp(1rem, 3vw, 2.5rem) 3rem;
}
.project-filter-row { margin-bottom: clamp(2rem, 4vw, 3rem); }
.project-filter-panel {
    display: block;
    width: min(100%, 1180px);
    margin: 0 auto;
    padding: 1.35rem clamp(.8rem, 2.5vw, 2rem) !important;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(4, 15, 40, .10);
}
#portfolio-flters { margin-bottom: 0 !important; }
.portfolio-container { transition: min-height .25s ease; }
.portfolio-item {
    margin-bottom: 1.5rem;
    transform-origin: center center;
    will-change: transform, opacity;
}
.portfolio-item .portfolio-box { transition: box-shadow .3s ease, transform .3s ease; }
.portfolio-item:hover .portfolio-box { transform: translateY(-3px); box-shadow: 0 12px 28px rgba(4, 15, 40, .16); }
/* Isotope handles filter-in/out scaling and opacity; this class reinforces the transition. */
.portfolio-container.is-filtering .portfolio-item { transition: opacity .42s ease, transform .42s ease; }
#qsti-project-gallery { scroll-margin-top: 90px; }
@media (max-width: 767.98px) {
    .project-gallery-section { padding: 1.5rem .85rem 2rem; }
    .project-filter-row { margin-bottom: 1.5rem; }
    .project-filter-panel { padding: 1rem .65rem !important; }
    .portfolio-item { margin-bottom: 1rem; }
}
@media (prefers-reduced-motion: reduce) {
    .portfolio-container, .portfolio-item, .portfolio-item .portfolio-box { transition: none !important; }
}


/* Keep the gallery centered within the same page grid as the other QSTI sections. */
.project-gallery-section {
    width: 100%;
    padding-left: clamp(1rem, 3vw, 2.5rem);
    padding-right: clamp(1rem, 3vw, 2.5rem);
}
.project-filter-row {
    max-width: 1480px;
    margin-left: auto !important;
    margin-right: auto !important;
}
.portfolio-container {
    width: 100%;
    max-width: 1480px;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: 0;
    padding-right: 0;
}
.portfolio-item {
    box-sizing: border-box;
}


/* Keep the lightbox counter hidden, matching the original gallery presentation. */
.lb-data .lb-number { display: none; }


/* Final page-header alignment: same centered container width as QSTI's shared layout. */
.project-header {
    width: 100%;
    min-height: 190px;
    margin: 0;
    padding: 2.5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: linear-gradient(rgba(169, 13, 13, .66), rgba(132, 0, 0, .66)), url('../img/project-header.jpg') center / cover no-repeat;
    border-top: 4px dotted #ff0000;
}
.project-header .container-xl { width: 100%; }
.project-header h1 { margin: 0 0 .45rem; color: #fff; font-size: clamp(2rem, 4vw, 3rem); font-weight: 800; line-height: 1.15; }
.project-header h1 span { color: #FDBE33; }
.project-header p { margin: 0; color: #fff; font-size: clamp(.95rem, 1.6vw, 1.15rem); font-weight: 600; line-height: 1.55; text-transform: uppercase; }
.project-header p strong { color: #fff; font-weight: 800; }

/* Isotope positions cards; horizontalAlign centers incomplete rows as well. */
.project-gallery-section { width: 100%; margin: 0 auto; background: #f4f6f8; }
.portfolio-container { width: 100%; max-width: 1480px; margin-left: auto !important; margin-right: auto !important; }
#portfolio-flters li.active h6 { color: #fff !important; }
@media (max-width: 767.98px) {
    .project-header { min-height: 165px; padding: 2rem 1rem; }
    .project-header h1 { font-size: clamp(1.8rem, 7vw, 2.5rem); }
}


/* Final fixes: keep Back-to-Top in the lower-right corner and show complete card titles. */
body .back-to-top {
    left: auto !important;
    right: 28px !important;
    bottom: 28px !important;
    margin-left: 0 !important;
    z-index: 1050;
    display: none;
}
body .back-to-top.show {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.portfolio-box {
    position: relative;
    overflow: hidden;
}
.portfolio-title.shadow-sm {
    position: absolute;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    height: auto;
    min-height: 0;
    max-height: none;
    padding: .8rem 1rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: rgba(255, 255, 255, .94);
    z-index: 4;
    text-decoration: none;
    overflow: visible;
}
.portfolio-title.shadow-sm p {
    margin: 0 0 .3rem;
    font-size: clamp(.95rem, 1.3vw, 1.15rem);
    line-height: 1.3;
    overflow-wrap: anywhere;
}
.portfolio-title.shadow-sm span {
    display: block;
    font-size: .88rem;
    line-height: 1.35;
    overflow-wrap: anywhere;
}
.portfolio-box > img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}
@media (max-width: 767.98px) {
    body .back-to-top {
        right: 16px !important;
        bottom: 16px !important;
    }
    .portfolio-title.shadow-sm {
        padding: .65rem .75rem;
    }
}


/* Responsive gallery sizing: three spacious cards per desktop row, centered filtered rows. */
.portfolio-container {
    display: block;
    width: 100%;
    max-width: 1480px;
    margin-inline: auto !important;
}
.portfolio-item {
    box-sizing: border-box;
}
@media (min-width: 1200px) {
    .portfolio-item { width: 33.333333%; }
}
@media (min-width: 768px) and (max-width: 1199.98px) {
    .portfolio-item { width: 50%; }
}
@media (max-width: 767.98px) {
    .portfolio-item { width: 100%; }
}


/* Prevent stale gallery sizing from preserving blank space after filtering. */
.portfolio-container {
    height: auto;
    min-height: 0;
}
.portfolio-container::after {
    content: "";
    display: table;
    clear: both;
}
.portfolio-item img {
    display: block;
}


/* Fix filtered cards extending the page below the visible Isotope results.
   The gallery has many absolute-positioned cards; make filtered-out cards leave
   the rendered page flow immediately instead of retaining stale off-screen bounds. */
.portfolio-container .portfolio-item.isotope-hidden {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}
.portfolio-container {
    position: relative;
    overflow: clip;
}
@supports not (overflow: clip) {
    .portfolio-container { overflow: hidden; }
}
