/* =======================================================================
   QM Gallery — stylesheet
   ======================================================================= */

/* -----------------------------------------------------------------------
   Grid
----------------------------------------------------------------------- */
.qm-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    padding: 0;
    margin: 0;
}

/* -----------------------------------------------------------------------
   Thumbnail
----------------------------------------------------------------------- */
.qm-item {
    position: relative;
}

.qm-thumb {
    position: relative;
    width: 100%;
    padding-top: 100%; /* square by default; override per-item if needed */
    background-size: cover;
    background-position: center;
    background-color: #e8e4df;
    cursor: pointer;
    overflow: hidden;
    border-radius: 2px;
}

.qm-thumb-overlay {
    position: absolute;
    inset: 0;
    background: rgba(20, 15, 10, 0);
    display: flex;
    align-items: flex-end;
    padding: 12px;
    transition: background 0.25s ease;
}

.qm-thumb:hover .qm-thumb-overlay,
.qm-thumb:focus .qm-thumb-overlay {
    background: rgba(20, 15, 10, 0.55);
}

.qm-thumb-title {
    color: #fff;
    font-family: DMSans, 'DMSans', sans-serif;
	font-size: 0.82rem;
    font-style: normal;
    letter-spacing: 0.02em;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    line-height: 1.35;
}

.qm-thumb:hover .qm-thumb-title,
.qm-thumb:focus .qm-thumb-title {
    opacity: 1;
    transform: translateY(0);
}

.qm-thumb:focus {
    outline: 2px solid #8b6f4e;
    outline-offset: 2px;
}

/* -----------------------------------------------------------------------
   Lightbox backdrop
----------------------------------------------------------------------- */
.qm-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qm-lightbox[hidden] {
    display: none;
}

.qm-lb-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(12, 9, 6, 0.92);
    cursor: pointer;
}

/* -----------------------------------------------------------------------
   Lightbox stage
----------------------------------------------------------------------- */
.qm-lb-stage {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: row;
    align-items: stretch;
    max-width: 900px;
    width: calc(100vw - 120px);
    max-height: calc(100vh - 80px);
    background: #1a1410;
    border-radius: 3px;
    overflow: hidden;
    box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}

.qm-lb-img-wrap {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    background: #100d0a;
    padding: 24px;
}

.qm-lb-img {
    max-width: 100%;
    max-height: calc(100vh - 128px);
    object-fit: contain;
    display: block;
    border-radius: 1px;
}

/* -----------------------------------------------------------------------
   Lightbox info panel
----------------------------------------------------------------------- */
.qm-lb-info {
    flex: 0 0 230px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 32px 28px;
    border-left: 1px solid #2e2720;
    gap: 12px;
}

.qm-lb-title {
    font-family: DMSans, 'DMSans', sans-serif;
    font-size: 1.15rem;
    font-weight: normal;
    font-style: normal;
    color: #e8e0d4;
    margin: 0;
    line-height: 1.4;
}

.qm-lb-desc {
    font-family: DMSans, 'DMSans', sans-serif;
    font-size: 0.82rem;
    color: #9e9389;
    margin: 0;
    line-height: 1.65;
}

.qm-lb-link {
    display: inline-block;
    margin-top: 8px;
    font-family: DMSans, 'DMSans', sans-serif;
    font-size: 0.72rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #c9a96e;
    text-decoration: none;
    border-bottom: 1px solid rgba(201, 169, 110, 0.35);
    padding-bottom: 2px;
    transition: color 0.2s, border-color 0.2s;
    align-self: flex-start;
}

.qm-lb-link:hover {
    color: #e8c98a;
    border-color: #e8c98a;
}

.qm-lb-link[data-hidden="true"] {
    display: none;
}

/* -----------------------------------------------------------------------
   Lightbox controls
----------------------------------------------------------------------- */
.qm-lb-close,
.qm-lb-prev,
.qm-lb-next {
    position: fixed;
    z-index: 2;
    background: none;
    border: none;
    color: #b5a99c;
    cursor: pointer;
    font-size: 1.6rem;
    line-height: 1;
    padding: 10px;
    transition: color 0.2s, transform 0.15s;
}

.qm-lb-close:hover,
.qm-lb-prev:hover,
.qm-lb-next:hover {
    color: #fff;
}

.qm-lb-close {
    top: 20px;
    right: 24px;
    font-size: 2rem;
}

.qm-lb-prev {
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2rem;
}

.qm-lb-next {
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2rem;
}

.qm-lb-prev:hover {
    transform: translateY(-50%) translateX(-3px);
}

.qm-lb-next:hover {
    transform: translateY(-50%) translateX(3px);
}

.qm-lb-prev[disabled],
.qm-lb-next[disabled] {
    opacity: 0.2;
    cursor: default;
}

/* -----------------------------------------------------------------------
   Responsive
----------------------------------------------------------------------- */
@media (max-width: 640px) {
    .qm-lb-stage {
        flex-direction: column;
        width: calc(100vw - 32px);
        max-height: calc(100vh - 48px);
    }

    .qm-lb-info {
        flex: 0 0 auto;
        border-left: none;
        border-top: 1px solid #2e2720;
        padding: 20px;
    }

    .qm-lb-prev { left: 8px; }
    .qm-lb-next { right: 8px; }

    .qm-gallery {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 8px;
    }
}
