/* ==========================================================================
   Estilos Gerais
   ========================================================================== */
body {
    background: #1A1A2E; /* Fundo entre preto e violeta escuro */
    color: #F5F5F5;
    font-family: 'Montserrat', sans-serif;
    font-weight: 300;
    margin: 0;
    padding: 0;
    overflow: auto;
    box-sizing: border-box;
}

/* ==========================================================================
   Imagem de Fundo
   ========================================================================== */
.bg-img {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: -1;
    transform: scale(1.15);
    animation: driftZoom 60s infinite ease-in-out, pulseOpacity 30s infinite ease-in-out;
    opacity: 0; /* Inicia invisível */
    transition: opacity 1s ease-in-out; /* Transição suave */
    display: none; /* Oculta no início */
}

@keyframes driftZoom {
    0% { transform: scale(1.15) translate(0, 0); }
    50% { transform: scale(1.35) translate(-4%, 4%); }
    100% { transform: scale(1.15) translate(0, 0); }
}

@keyframes pulseOpacity {
    0% { opacity: 0.5; }
    50% { opacity: 0.8; }
    100% { opacity: 0.5; }
}

/* ==========================================================================
   Transição de Página
   ========================================================================== */
.page-transition {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #1A1A2E; /* Mesmo tom do body */
    z-index: 10; /* Atrás dos botões, acima da imagem */
    opacity: 1;
    transition: opacity 1s ease-in-out;
}

.page-transition.fade-out {
    opacity: 0;
    display: none;
}

/* ==========================================================================
   Imagem de Substituição do Vídeo
   ========================================================================== */
#background-video {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 5; /* Acima do bg-img, abaixo do word-sea */
    opacity: 0; /* Inicia invisível */
    display: none; /* Oculta no início */
    animation: syncFadeZoom 50s infinite ease-in-out; /* Sincroniza fade e zoom */
}

@keyframes syncFadeZoom {
    0% { opacity: 0; transform: scale(1.2) translate(0, 0); } /* Início: invisível, zoom mínimo */
    50% { opacity: 1; transform: scale(1.4) translate(2%, -2%); } /* Pico: opacidade máxima, zoom máximo */
    100% { opacity: 0; transform: scale(1.2) translate(0, 0); } /* Fim: volta a invisível, zoom mínimo */
}

/* ==========================================================================
   Word-Sea
   ========================================================================== */
.word-sea {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 20; /* Acima da imagem */
    overflow: hidden;
    background: transparent;
}

.word-sea:empty {
    display: none;
}

/* Palavras Individuais no Word-Sea */
.word {
    position: absolute;
    font-family: 'Raleway', sans-serif;
    font-weight: 300;
    text-transform: lowercase;
    color: #F5F5F5;
    white-space: nowrap;
    user-select: none;
    transition: opacity 2s ease-in-out, transform 2s ease-in-out;
    opacity: 0.7;
    will-change: transform, opacity;
    transform-origin: center;
}

.word.color1 {
    color: rgba(109, 155, 216, 0.6);
    text-shadow: 0 0 4px rgba(173, 216, 230, 0.3);
}

.word.color2 {
    color: rgba(70, 130, 180, 0.6);
    text-shadow: 0 0 4px rgba(173, 216, 230, 0.3);
}

.word.color3 {
    color: rgba(245, 245, 220, 0.6);
    text-shadow: 0 0 4px rgba(173, 216, 230, 0.3);
}

.word.entering {
    opacity: 0;
    transform: translateY(20px);
}

.word.entering:not(.exiting) {
    opacity: 0.7;
}

.word.exiting {
    opacity: 0;
    transform: translateY(-20px);
}

@keyframes wave {
    0% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(10px, -10px) rotate(50deg); }
    50% { transform: translate(-10px, 10px) rotate(-50deg); }
    75% { transform: translate(10px, 10px) rotate(30deg); }
    100% { transform: translate(0, 0) rotate(0deg); }
}

/* ==========================================================================
   Narrative Popup
   ========================================================================== */
.narrative-popup {
    position: fixed;
    top: 0;
    left: 0; /* Centralizado */
    width: 100%; /* Ocupa toda a largura */
    height: 100%;
    background: rgba(28, 37, 38, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 40; /* Acima dos botões e word-sea */
    opacity: 0;
    transition: opacity 0.8s ease;
}

.narrative-popup.active {
    display: flex;
    opacity: 1;
}

.narrative-container {
    max-width: 600px;
    width: 90%;
    padding: 16px;
    background: rgba(10, 20, 40, 0.2);
    text-align: center;
    backdrop-filter: blur(4px);
    overflow: auto;
    border: 1px solid rgba(255, 215, 150, 0.3);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}

.narrative-text-line {
    display: block;
    font-family: 'Montserrat', sans-serif;
    font-weight: 300;
    font-size: 1.4em;
    color: rgba(255, 215, 150, 0.9);
    margin: 20px 0;
    line-height: 2.0;
    letter-spacing: 0.05em;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.narrative-text-line.active {
    opacity: 1;
    transform: translateY(0);
}

.narrative-text:empty::before {
    content: "Carregando texto...";
    color: rgba(255, 215, 150, 0.9);
    font-family: 'Montserrat', sans-serif;
    font-size: 1.4em;
}

/* ==========================================================================
   Links Flutuantes (Botões)
   ========================================================================== */
.floating-text {
    position: fixed;
    color: #F5F5F5;
    font-family: 'Montserrat', sans-serif;
    font-size: 1.5em;
    font-weight: 300;
    text-decoration: none;
    z-index: 30;
    transition: color 0.5s ease;
}

.floating-text:hover {
    color: #FFD700;
}

.floating-text.square-button {
    /* Apenas ícone, sem fundo ou bordas */
}

/* Ajuste de posições dos botões */
.floating-text.chaos8 { /* Return ◯ */
    top: 5%;
    left: 5%;
    animation: subtleChaos8 90s infinite ease-in-out;
}

.floating-text.chaos9 { /* Poetica ⋮ */
    bottom: 10%;
    right: 10%;
    animation: subtleChaos9 94s infinite ease-in-out;
}

.floating-text.chaos10 { /* Reset ⊙ */
    bottom: 10%;
    left: 10%;
    animation: subtleChaos10 90s infinite ease-in-out;
}

.floating-text.chaos11 { /* Start ▶ */
    top: 5%;
    right: 5%;
    animation: subtleChaos11 94s infinite ease-in-out;
}

@keyframes subtleChaos8 {
    0% { top: 5%; left: 5%; transform: rotate(0deg); }
    20% { top: 7%; left: 7%; transform: rotate(4deg); }
    40% { top: 6%; left: 6%; transform: rotate(-4deg); }
    60% { top: 8%; left: 8%; transform: rotate(3deg); }
    80% { top: 6%; left: 7%; transform: rotate(-3deg); }
    100% { top: 5%; left: 5%; transform: rotate(0deg); }
}

@keyframes subtleChaos9 {
    0% { bottom: 10%; right: 10%; transform: rotate(0deg); }
    20% { bottom: 12%; right: 12%; transform: rotate(-4deg); }
    40% { bottom: 11%; right: 11%; transform: rotate(3deg); }
    60% { bottom: 13%; right: 13%; transform: rotate(-3deg); }
    80% { bottom: 11%; right: 12%; transform: rotate(2deg); }
    100% { bottom: 10%; right: 10%; transform: rotate(0deg); }
}

@keyframes subtleChaos10 {
    0% { bottom: 10%; left: 10%; transform: rotate(0deg); }
    20% { bottom: 12%; left: 12%; transform: rotate(4deg); }
    40% { bottom: 11%; left: 11%; transform: rotate(-4deg); }
    60% { bottom: 13%; left: 13%; transform: rotate(3deg); }
    80% { bottom: 11%; left: 12%; transform: rotate(-3deg); }
    100% { bottom: 10%; left: 10%; transform: rotate(0deg); }
}

@keyframes subtleChaos11 {
    0% { top: 5%; right: 5%; transform: rotate(0deg); }
    20% { top: 7%; right: 7%; transform: rotate(-4deg); }
    40% { top: 6%; right: 6%; transform: rotate(3deg); }
    60% { top: 8%; right: 8%; transform: rotate(-3deg); }
    80% { top: 6%; right: 7%; transform: rotate(2deg); }
    100% { top: 5%; right: 5%; transform: rotate(0deg); }
}

/* ==========================================================================
   Responsividade
   ========================================================================== */
@media (max-width: 768px) {
    .floating-text {
        font-size: 1.2em;
    }

    .word {
        font-size: 0.6em;
    }

    .narrative-container {
        max-width: 90%;
        padding: 12px;
    }

    .narrative-text-line {
        font-size: 1.2em;
        margin: 16px 0;
        line-height: 1.8;
    }
}