/* ==========================================================================
   SAAV MOTORS — SHINERAY · galería de modelo y lightbox
   Extraído del sistema de diseño (mismo patrón del sitio hermano Yadea/SAAV).
   ========================================================================== */

.gallery-grid {
    max-width: var(--wrap);
    margin-inline: auto;
    padding-inline: var(--gutter);
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-auto-rows: clamp(180px, 21vw, 300px);
    gap: clamp(8px, 1vw, 16px);
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: var(--r-md);
    background: var(--surface-2);
    cursor: zoom-in;
    grid-column: span 6;
}
.gallery-item:nth-child(1) { grid-column: span 7; grid-row: span 2; }
.gallery-item:nth-child(2) { grid-column: span 5; }
.gallery-item:nth-child(3) { grid-column: span 5; }
.gallery-item:nth-child(4) { grid-column: span 6; }
.gallery-item:nth-child(5) { grid-column: span 6; }

/* Ajustes por quantidade para o mosaico fechar sem buracos. */
:where(.gallery-grid--4) .gallery-item:nth-child(n) { grid-column: span 6; grid-row: span 1; }
:where(.gallery-grid--6) .gallery-item:nth-child(4),
:where(.gallery-grid--6) .gallery-item:nth-child(5),
:where(.gallery-grid--6) .gallery-item:nth-child(6) { grid-column: span 4; grid-row: span 1; }
:where(.gallery-grid--7) .gallery-item:nth-child(4),
:where(.gallery-grid--7) .gallery-item:nth-child(5),
:where(.gallery-grid--7) .gallery-item:nth-child(6) { grid-column: span 4; grid-row: span 1; }
:where(.gallery-grid--7) .gallery-item:nth-child(7) { grid-column: span 12; grid-row: span 1; }

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--dur-4) var(--ease-out);
}
.gallery-item:hover img { transform: scale(1.05); }

.gallery-item::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(180deg, transparent 45%, rgba(8, 9, 10, 0.8) 100%);
    opacity: 0;
    transition: opacity var(--dur-3) var(--ease);
}
.gallery-item:hover::before { opacity: 1; }

.gallery-item-overlay {
    position: absolute;
    z-index: 2;
    left: var(--sp-4);
    bottom: var(--sp-4);
    transform: translateY(12px);
    opacity: 0;
    transition: transform var(--dur-3) var(--ease-out), opacity var(--dur-2) var(--ease);
}
.gallery-item:hover .gallery-item-overlay { transform: none; opacity: 1; }
.gallery-item-title {
    display: inline-block;
    padding: 6px 13px;
    border-radius: var(--r-pill);
    background: rgba(8, 9, 10, 0.6);
    backdrop-filter: blur(10px);
    color: #fff;
    font-size: var(--fs-micro);
    font-weight: 500;
    letter-spacing: 0.02em;
}

@media (max-width: 900px) {
    .gallery-grid { grid-auto-rows: clamp(150px, 32vw, 240px); }
    .gallery-item, .gallery-item:nth-child(n) { grid-column: span 6; grid-row: span 1; }
    .gallery-item:nth-child(1) { grid-column: span 12; }
}
@media (max-width: 560px) {
    .gallery-item, .gallery-item:nth-child(n) { grid-column: span 12; }
}

/* ----------------------------------------------------------- LIGHTBOX */

.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: clamp(16px, 4vw, 56px);
    background: var(--lightbox-bg);
    backdrop-filter: blur(8px);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--dur-3) var(--ease), visibility var(--dur-3);
}
.lightbox.active { opacity: 1; visibility: visible; }

.lightbox-content { position: relative; max-width: min(1200px, 92vw); }
.lightbox-image {
    max-width: 100%;
    max-height: 82vh;
    border-radius: var(--r-md);
    transition: opacity var(--dur-2) var(--ease);
}

.lightbox-close,
.lightbox-nav {
    position: absolute;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: var(--r-pill);
    border: 1px solid var(--line-2);
    background: var(--glass);
    backdrop-filter: blur(14px);
    color: var(--text);
    cursor: pointer;
    transition: background var(--dur-2) var(--ease), color var(--dur-2) var(--ease), transform var(--dur-2) var(--ease-out);
}
.lightbox-close:hover, .lightbox-nav:hover { background: var(--text); color: var(--bg); transform: scale(1.06); }
.lightbox-close svg, .lightbox-nav svg { width: 18px; height: 18px; }

.lightbox-close { top: -58px; right: 0; }
.lightbox-nav { top: 50%; margin-top: -22px; }
.lightbox-prev { left: -62px; }
.lightbox-next { right: -62px; }

@media (max-width: 900px) {
    .lightbox-prev { left: 8px; }
    .lightbox-next { right: 8px; }
    .lightbox-close { top: -54px; right: 0; }
}

/* Imagens de estúdio (fundo transparente) posam sobre um palco claro. */
.gallery-item--stage { background: var(--surface-2); }
.gallery-item--stage img {
    object-fit: contain;
    padding: 7%;
    filter: drop-shadow(0 14px 12px rgba(10, 11, 13, 0.22));
}
:root[data-theme="light"] .gallery-item--stage img {
    filter: drop-shadow(0 14px 12px rgba(15, 16, 18, 0.12));
}

/* ------------------------------------------------------------- VÍDEOS */
.video-grid {
    max-width: var(--wrap);
    margin-inline: auto;
    padding-inline: var(--gutter);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: clamp(12px, 1.5vw, 20px);
}
.video-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 300px;
    min-width: 0;
    margin-inline: auto;
}
.video-card video {
    width: 100%;
    aspect-ratio: 9 / 16;
    object-fit: contain;
    display: block;
    border-radius: var(--r-md);
    background: #000;
    box-shadow: var(--card-shadow);
}
.video-card-body { display: flex; flex-direction: column; gap: 3px; padding-inline: 2px; }
.video-card-title { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; letter-spacing: -0.01em; }
.video-card-tag { font-size: var(--fs-micro); color: var(--text-3); letter-spacing: 0.02em; }
.video-card figcaption { margin: 0; }
@media (max-width: 560px) {
    .video-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 380px) {
    .video-grid { grid-template-columns: 1fr; }
}

.video-frame { position: relative; }
.video-expand {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 50%;
    background: rgba(8, 9, 10, 0.62);
    color: #fff;
    cursor: pointer;
    backdrop-filter: blur(8px);
    transition: background var(--dur-2) var(--ease), transform var(--dur-2) var(--ease-out);
}
.video-expand:hover { background: var(--accent); transform: scale(1.06); }
.video-expand svg { width: 17px; height: 17px; }
.video-card video::-webkit-media-controls-fullscreen-button,
.video-modal__box video::-webkit-media-controls-fullscreen-button { display: none; }

.video-modal {
    position: fixed;
    inset: 0;
    z-index: 1300;
    display: grid;
    place-items: center;
    padding: clamp(14px, 3vw, 32px);
    background: rgba(5, 6, 8, 0.8);
    backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--dur-3) var(--ease), visibility var(--dur-3);
}
.video-modal.active { opacity: 1; visibility: visible; }
.video-modal__box {
    position: relative;
    width: min(92vw, 46vh, 420px);
    max-height: 88vh;
    padding: 6px;
    border-radius: 18px;
    background: #000;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
}
.video-modal__box video {
    display: block;
    width: 100%;
    max-height: 82vh;
    aspect-ratio: 9 / 16;
    object-fit: contain;
    border-radius: 12px;
    background: #000;
}
.video-modal__close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.34);
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.62);
    color: #fff;
    cursor: pointer;
    backdrop-filter: blur(8px);
}
.video-modal__close:hover { background: var(--accent); }
.video-modal__close svg { width: 18px; height: 18px; }
.video-modal__status {
    position: absolute;
    inset: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.42);
    color: #fff;
    font-size: 0.82rem;
    letter-spacing: 0.01em;
    text-align: center;
    pointer-events: none;
}
.video-modal__status[hidden] { display: none; }
.video-spinner {
    width: 20px;
    height: 20px;
    flex: none;
    border: 2px solid rgba(255, 255, 255, 0.32);
    border-top-color: #fff;
    border-radius: 50%;
    animation: video-spin 0.8s linear infinite;
}
@keyframes video-spin {
    to { transform: rotate(360deg); }
}
