/* ==================== */
/* CINEVIDEO - STYLES   */
/* ==================== */

:root {
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --bg-tertiary: #141414;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --accent-cyan: #4ecdc4;
    --accent-gold: #c9a227;
    --border-color: #2a2a2a;
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ==================== */
/* HEADER               */
/* ==================== */

.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0) 100%);
    padding: 16px 24px;
}

.nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 32px;
}

.nav-item {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 1px;
    transition: color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-item:hover {
    color: var(--text-primary);
}

.nav-item.active {
    color: var(--text-primary);
}

.nav-item.highlight {
    color: var(--accent-cyan);
}

/* ==================== */
/* GALLERY GRID         */
/* ==================== */

.gallery {
    /* Sem recuo lateral: cada fileira ocupa a largura inteira da pagina. */
    padding: 80px 0 24px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Uma fileira justificada. A altura dela e calculada no JS para que a soma das
   larguras preencha exatamente o vao -- e o que elimina a sobra nas laterais. */
.gallery-row {
    display: flex;
    gap: 4px;
}

.shot-card {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    flex: 0 0 auto;
}

.shot-card:hover {
    transform: scale(1.02);
    z-index: 10;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
}

.shot-card img {
    display: block;
    /* O tamanho vem do card, que o JS dimensiona por fileira. */
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.shot-card .overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
    padding: 24px 8px 8px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.shot-card:hover .overlay {
    opacity: 1;
}

.overlay-title {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.overlay-meta {
    font-size: 9px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ==================== */
/* MODAL                */
/* ==================== */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 10, 10, 0.75);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    z-index: 200;
    display: none;
    overflow-y: auto;
}

.modal.active {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 0;
}

/* Side Previews */
.side-previews {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 201;
}

.side-previews-left {
    /* Position next to modal-content (1000px width centered) */
    right: calc(50% + 500px + 16px);
}

.side-previews-right {
    /* Position next to modal-content (1000px width centered) */
    left: calc(50% + 500px + 16px);
}

.side-preview {
    width: 180px;
    height: 105px;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.5;
    transition: opacity 0.2s ease, transform 0.2s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.side-preview:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.side-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.side-preview-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
    padding: 24px 8px 6px;
    opacity: 0;
    transition: opacity 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.side-preview:hover .side-preview-overlay {
    opacity: 1;
}

.preview-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-gold);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-year {
    font-size: 10px;
    color: var(--text-secondary);
}

.modal-content {
    max-width: 1000px;
    margin: 24px auto;
    padding: 20px 28px 40px;
    background: #0a0a0a;
    border-radius: 8px;
    border: 1px solid #1a1a1a;
    /* Cabe na janela por construcao: 48px = as duas margens verticais.
       A imagem absorve a sobra, entao o modal nunca passa da tela. */
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
}

/* Texto e paleta mantem a altura natural; so a imagem cede espaco. */
.modal-header,
.color-palette,
.tags-section,
.metadata-grid {
    flex-shrink: 0;
}

/* Modal Header */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.modal-title {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: nowrap;
}

.modal-title h1 {
    font-size: 18px;
    font-weight: 600;
    color: var(--accent-gold);
    text-decoration: underline;
    text-underline-offset: 4px;
    white-space: nowrap;
}

.modal-title span {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 400;
    white-space: nowrap;
}

.modal-actions {
    display: flex;
    gap: 12px;
}

.action-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    transition: color 0.2s ease;
}

.action-btn:hover {
    color: var(--text-primary);
}

/* Modal Image */
.modal-image-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    /* Altura desejada igual a de antes (50vh, no maximo 500px), mas agora a
       imagem e o UNICO bloco que pode encolher: quando o texto nao cabe na
       janela, ela cede o espaco em vez de empurrar tudo para fora da tela.
       O piso evita esmagar a imagem -- abaixo dele o modal volta a rolar. */
    flex: 0 1 auto;
    height: 50vh;
    min-height: 240px;
    max-height: 500px;
    background: #0a0a0a;
    border-radius: 4px;
}

.modal-image-container img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 2px;
}

.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-arrow:hover {
    background: rgba(0, 0, 0, 0.9);
    border-color: var(--text-muted);
}

.nav-prev {
    left: 16px;
}

.nav-next {
    right: 16px;
}

/* Color Palette */
.color-palette {
    display: flex;
    gap: 0;
    margin-bottom: 6px;
    margin-top: 6px;
    height: 40px;
    border-radius: 2px;
    overflow: visible;
}

.color-swatch {
    flex: 1;
    min-width: 30px;
    position: relative;
    cursor: pointer;
    transition: transform 0.15s ease, z-index 0s;
    /* Divisoria entre as cores, como no ShotDeck: a borda esquerda de cada
       swatch faz a linha vertical, e a de cima e a de baixo emolduram a faixa.
       So o ultimo ganha borda direita, para fechar a moldura sem duplicar
       linha nenhuma no meio. */
    border: 1px solid #fff;
    border-right: 0;
}

.color-swatch:last-child {
    border-right: 1px solid #fff;
}

.color-swatch:hover {
    transform: scaleY(1.3);
    z-index: 10;
}

.color-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-family: monospace;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    margin-bottom: 6px;
}

.color-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

.color-swatch:hover .color-tooltip {
    opacity: 1;
}

/* Tags */
.tags-section {
    margin-bottom: 6px;
    font-size: 12px;
}

.tags-label {
    color: var(--text-primary);
    font-weight: 600;
    margin-right: 8px;
}

.tags-list {
    color: var(--text-secondary);
}

/* Metadata Grid */
.metadata-grid {
    display: grid;
    /* minmax(0, 1fr) e nao 1fr: o minimo "auto" de 1fr e o min-content, e com
       texto sem quebra isso e a frase inteira -- as colunas estouravam o modal
       em vez de cortar o texto. */
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 32px;
}

.metadata-column {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.metadata-item {
    display: flex;
    align-items: baseline;
    gap: 4px;
    font-size: 12px;
    line-height: 1.4;
}

/* Rotulo e valor correm no mesmo fluxo de texto: o corte cai no meio do valor,
   e nao empurra o valor inteiro para a linha de baixo. */
.meta-conteudo {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
}

/* Aberto, o texto so deixa de ser cortado: ele continua comecando ao lado do
   rotulo e quebra dali para baixo. */
.metadata-item.aberto .meta-conteudo {
    white-space: normal;
}

/* O "..." fica antes do valor e passa despercebido ate o hover -- e o mesmo
   comportamento do ShotDeck, onde o link so ganha cor quando o mouse chega.
   letter-spacing negativo junta os pontos, que por padrao saem espalhados. */
.meta-toggle {
    cursor: pointer;
    color: var(--text-secondary);
    letter-spacing: -1.5px;
    padding-right: 3px;
}

.meta-toggle:hover {
    color: var(--accent-cyan);
}

.meta-label {
    color: var(--text-primary);
    font-weight: 600;
    white-space: nowrap;
}

.meta-value {
    color: var(--text-secondary);
}

/* Separador de secao: 1px, o mesmo peso discreto do .gray_line do ShotDeck */
.gray-line {
    flex-shrink: 0;
    height: 1px;
    background: #444;
    margin: 10px 0;
}

/* ==================== */
/* RESPONSIVE           */
/* ==================== */

@media (max-width: 768px) {
    .gallery {
        padding: 70px 4px 16px;
    }

    .shot-card img {
        height: 80px;
    }

    .metadata-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .modal-content {
        padding: 12px 16px 32px;
    }

    .nav-arrow {
        width: 36px;
        height: 36px;
    }

    .nav-prev {
        left: 8px;
    }

    .nav-next {
        right: 8px;
    }
}