/* ============================================================
   CENA 4

   Este arquivo contém apenas os estilos específicos da cena 4
   e seus ajustes responsivos.
   ============================================================ */


/* ============================================================
   CENA 4 — MÃO 3D + LUVA
   ============================================================ */

#scene-4 {
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#hand-stage {
    position: absolute;
    inset: 0;

    display: none;

    z-index: 1;
    pointer-events: none;

    opacity: 0;

    will-change: opacity;
}

#hand-canvas {
    width: 100%;
    height: 100%;

    display: block;
}


/* ============================================================
   SOMBRA SOFT DA MÃO

   Blob radial preto (ou branco em dark mode) que fica embaixo
   da mão. Escala/opacidade são dirigidas pelo hand-scene.js
   com base na progressão da cena 4.
   ============================================================ */

#hand-shadow {
    position: absolute;

    left: 50%;
    bottom: 12%;

    width: 46%;
    height: 16%;

    max-width: 640px;
    max-height: 220px;

    transform: translate(-50%, 0) scale(0.5);

    transform-origin: center bottom;

    background: radial-gradient(
        ellipse at center,
        rgba(0, 0, 0, 0.55) 0%,
        rgba(0, 0, 0, 0.32) 32%,
        rgba(0, 0, 0, 0.10) 62%,
        rgba(0, 0, 0, 0) 88%
    );

    filter: blur(26px);

    opacity: 0;

    pointer-events: none;

    z-index: 0;

    will-change: transform, opacity;
}


/* ============================================================
   NO DARK MODE, A SOMBRA VIRA LUZ DIFUSA
   ============================================================ */

body.dark-mode #hand-shadow {
    background: radial-gradient(
        ellipse at center,
        rgba(255, 255, 255, 0.35) 0%,
        rgba(255, 255, 255, 0.18) 32%,
        rgba(255, 255, 255, 0.05) 62%,
        rgba(255, 255, 255, 0) 88%
    );
}


#swallow-overlay {
    position: absolute;

    inset: 0;

    background: var(--bg-color);

    opacity: 0;

    pointer-events: none;

    z-index: 2;

    will-change: opacity;
}

#scene-4 .label {
    z-index: 4;

    will-change: opacity;
}

.project-container {
    position: absolute;

    width: 60vw;
    max-width: 900px;

    text-align: center;

    opacity: 0;

    will-change: transform, opacity;

    z-index: 3;
}

.project-meta {
    margin-bottom: 1rem;
}

.project-title {
    font-size: clamp(3rem, 6vw, 6rem);

    font-weight: 600;

    letter-spacing: -0.04em;

    margin-bottom: 2rem;

    overflow-wrap: anywhere;
    word-break: break-word;
}

.project-desc {
    font-size: 1.2rem;

    line-height: 1.65;

    color: var(--text-muted);

    margin-bottom: 2.5rem;

    max-width: 620px;

    margin-left: auto;
    margin-right: auto;

    overflow-wrap: anywhere;
    word-break: break-word;
}

.project-tags {
    display: flex;

    justify-content: center;

    gap: 1.4rem;

    flex-wrap: wrap;
}


/* ============================================================
   MOBILE — LAYOUT CINEMÁTICO
   ============================================================ */

@media (max-width: 768px) {

    /* --------------------------------------------------------
       CENA 4
       -------------------------------------------------------- */

    #scene-4 {
        position: absolute;

        inset: 0;

        width: 100%;
        height: 100%;

        padding: 0;

        align-items: center;
        justify-content: center;

        overflow: hidden;
    }

    #scene-4 .label {
        left: 20px;

        top: max(
            16px,
            env(safe-area-inset-top)
        );

        z-index: 8;
    }


    /* --------------------------------------------------------
       HAND STAGE
       -------------------------------------------------------- */

    #hand-stage {
        position: absolute;

        inset: 0;

        width: 100%;
        height: 100%;
    }

    #hand-canvas {
        width: 100% !important;
        height: 100% !important;

        display: block;
    }


    /* --------------------------------------------------------
       SOMBRA
       -------------------------------------------------------- */

    #hand-shadow {
        bottom: 8%;

        width: 60%;
        height: 12%;

        filter: blur(20px);
    }


    /* --------------------------------------------------------
       CONTAINER DO PROJETO

       IMPORTANTE:
       "translate" é usado separadamente do "transform".
       Assim, o JS pode continuar manipulando transform
       sem destruir o posicionamento central do mobile.
       -------------------------------------------------------- */

    .project-container {
        position: absolute;

        top: 50%;
        left: 50%;

        width: min(88vw, 560px);
        max-width: calc(100vw - 28px);

        padding:
            16px
            20px;

        box-sizing: border-box;

        /*
         * Centralização independente da animação JS.
         */
        translate: -50% -50%;

        /*
         * Evita que o conteúdo fique maior que a viewport.
         */
        max-height: calc(
            100dvh -
            max(32px, env(safe-area-inset-top)) -
            max(32px, env(safe-area-inset-bottom))
        );

        overflow: visible;

        z-index: 7;

        text-align: center;

        /*
         * Evita artefatos de composição do texto durante
         * transform/opacity do JS.
         */
        backface-visibility: hidden;
        -webkit-backface-visibility: hidden;

        transform-origin: center center;
    }


    /* --------------------------------------------------------
       META
       -------------------------------------------------------- */

    .project-meta {
        max-width: 100%;

        font-size: 0.52rem;

        line-height: 1.45;

        margin-bottom: 0.75rem;

        overflow-wrap: anywhere;
        word-break: break-word;
    }


    /* --------------------------------------------------------
       TÍTULO

       A altura da viewport também participa do cálculo.
       Isso evita o título ocupar espaço demais em celulares
       muito baixos.
       -------------------------------------------------------- */

    .project-title {
        width: 100%;
        max-width: 100%;

        font-size: clamp(
            2rem,
            min(11vw, 10vh),
            4.6rem
        );

        line-height: 0.91;

        letter-spacing: -0.045em;

        margin: 0 0 1rem;

        overflow-wrap: break-word;
        word-break: normal;

        /*
         * Evita quebra estranha de palavras inteiras.
         */
        text-wrap: balance;

        /*
         * Impede o texto de criar uma camada visual
         * deslocada durante a animação.
         */
        backface-visibility: hidden;
        -webkit-backface-visibility: hidden;
    }


    /* --------------------------------------------------------
       DESCRIÇÃO
       -------------------------------------------------------- */

    .project-desc {
        width: 100%;
        max-width: 470px;

        margin-left: auto;
        margin-right: auto;

        margin-bottom: 1.15rem;

        font-size: clamp(
            0.72rem,
            min(3.15vw, 2.8vh),
            0.98rem
        );

        line-height: 1.48;

        overflow-wrap: break-word;
        word-break: normal;
    }


    /* --------------------------------------------------------
       TAGS
       -------------------------------------------------------- */

    .project-tags {
        width: 100%;
        max-width: 430px;

        margin: 0 auto;

        display: flex;

        justify-content: center;

        gap: 0.35rem 0.55rem;

        flex-wrap: wrap;
    }

    .project-tags span {
        max-width: 100%;

        font-size: 0.52rem;

        line-height: 1.2;

        overflow-wrap: anywhere;
        word-break: break-word;
    }
}


/* ============================================================
   TELAS MUITO PEQUENAS — PORTRAIT
   ============================================================ */

@media (max-width: 380px) {

    .project-container {
        width: calc(100vw - 20px);

        max-width: calc(100vw - 20px);

        padding:
            12px
            12px;

        max-height: calc(
            100dvh -
            max(24px, env(safe-area-inset-top)) -
            max(24px, env(safe-area-inset-bottom))
        );
    }

    .project-meta {
        font-size: 0.46rem;

        line-height: 1.35;

        margin-bottom: 0.55rem;
    }

    .project-title {
        font-size: clamp(
            1.8rem,
            min(11vw, 9.5vh),
            3.2rem
        );

        line-height: 0.9;

        margin-bottom: 0.75rem;
    }

    .project-desc {
        font-size: clamp(
            0.62rem,
            min(2.8vw, 2.5vh),
            0.78rem
        );

        line-height: 1.38;

        margin-bottom: 0.85rem;
    }

    .project-tags {
        gap: 0.25rem 0.45rem;
    }

    .project-tags span {
        font-size: 0.46rem;
    }
}


/* ============================================================
   CELULAR DEITADO — LANDSCAPE
   ============================================================ */

@media (max-width: 900px) and (orientation: landscape) {

    #scene-4 {
        position: fixed !important;

        inset: 0 !important;

        width: 100vw !important;
        height: 100dvh !important;

        min-height: 0 !important;

        padding: 0 !important;

        display: flex;

        align-items: center;
        justify-content: center;

        overflow: hidden;
    }


    /* --------------------------------------------------------
       LABEL
       -------------------------------------------------------- */

    #scene-4 .label {
        top: max(
            12px,
            env(safe-area-inset-top)
        );

        left: 20px;

        z-index: 8;
    }


    /* --------------------------------------------------------
       HAND STAGE
       -------------------------------------------------------- */

    #hand-stage {
        position: fixed !important;

        inset: 0 !important;

        width: 100vw !important;
        height: 100dvh !important;

        min-height: 0 !important;

        margin: 0 !important;
        padding: 0 !important;

        display: block;

        z-index: 1;

        pointer-events: none;
    }

    #hand-canvas {
        position: absolute !important;

        inset: 0 !important;

        width: 100vw !important;
        height: 100dvh !important;

        min-width: 100% !important;
        min-height: 100% !important;

        display: block;
    }


    /* --------------------------------------------------------
       SOMBRA
       -------------------------------------------------------- */

    #hand-shadow {
        bottom: 6%;

        width: 42%;
        height: 18%;

        filter: blur(22px);
    }


    /* --------------------------------------------------------
       OVERLAY
       -------------------------------------------------------- */

    #swallow-overlay {
        position: fixed !important;

        inset: 0 !important;

        width: 100vw !important;
        height: 100dvh !important;

        z-index: 2;
    }


    /* --------------------------------------------------------
       PROJECT CONTAINER
       -------------------------------------------------------- */

    .project-container {
        position: absolute;

        top: 50%;
        left: 50%;

        width: min(82vw, 700px);
        max-width: calc(100vw - 24px);

        padding: 8px 20px;

        box-sizing: border-box;

        /*
         * Não usa transform para centralização.
         * O JS continua livre para animar "transform".
         */
        translate: -50% -50%;

        max-height: calc(
            100dvh -
            max(20px, env(safe-area-inset-top)) -
            max(20px, env(safe-area-inset-bottom))
        );

        z-index: 7;

        text-align: center;

        backface-visibility: hidden;
        -webkit-backface-visibility: hidden;
    }

    .project-meta {
        font-size: 0.48rem;

        line-height: 1.35;

        margin-bottom: 0.5rem;
    }

    .project-title {
        width: 100%;
        max-width: 100%;

        font-size: clamp(
            1.8rem,
            min(6.8vw, 15vh),
            4.2rem
        );

        line-height: 0.88;

        letter-spacing: -0.045em;

        margin-bottom: 0.7rem;

        text-wrap: balance;
    }

    .project-desc {
        max-width: 620px;

        margin-left: auto;
        margin-right: auto;

        margin-bottom: 0.8rem;

        font-size: clamp(
            0.58rem,
            min(1.65vw, 2.8vh),
            0.82rem
        );

        line-height: 1.4;
    }

    .project-tags {
        gap: 0.3rem 0.55rem;

        max-width: 620px;

        margin: 0 auto;
    }

    .project-tags span {
        font-size: 0.46rem;
    }
}


/* ============================================================
   CELULAR DEITADO — ALTURA MUITO BAIXA
   ============================================================ */

@media (max-width: 900px)
and (orientation: landscape)
and (max-height: 430px) {

    .project-container {
        width: min(88vw, 650px);

        max-width: calc(100vw - 20px);

        padding:
            4px
            15px;
    }

    .project-meta {
        font-size: 0.4rem;

        margin-bottom: 0.35rem;
    }

    .project-title {
        font-size: clamp(
            1.45rem,
            min(6vw, 14vh),
            3rem
        );

        line-height: 0.86;

        margin-bottom: 0.45rem;
    }

    .project-desc {
        font-size: clamp(
            0.5rem,
            min(1.2vw, 2.4vh),
            0.6rem
        );

        line-height: 1.26;

        margin-bottom: 0.5rem;
    }

    .project-tags span {
        font-size: 0.4rem;
    }
}


/* ============================================================
   CELULARES MUITO PEQUENOS — LANDSCAPE
   ============================================================ */

@media (max-width: 700px)
and (orientation: landscape)
and (max-height: 360px) {

    #scene-4 {
        position: fixed !important;

        inset: 0 !important;

        width: 100vw !important;
        height: 100dvh !important;

        padding: 0 !important;

        overflow: hidden;
    }

    #hand-stage,
    #hand-canvas,
    #swallow-overlay {
        position: fixed !important;

        inset: 0 !important;

        width: 100vw !important;
        height: 100dvh !important;

        min-width: 100vw !important;
        min-height: 100dvh !important;
    }

    .project-container {
        width: calc(100vw - 20px);

        max-width: 560px;

        padding:
            3px
            10px;
    }

    .project-meta {
        font-size: clamp(
            0.42rem,
            0.9vw,
            0.54rem
        );

        margin-bottom: 0.22rem;
    }

    .project-title {
        font-size: clamp(
            1.2rem,
            min(5.8vw, 13vh),
            2.5rem
        );

        line-height: 0.84;

        margin-bottom: 0.3rem;
    }

    .project-desc {
        max-width: 500px;

        margin-bottom: 0.35rem;

        font-size: clamp(
            0.46rem,
            1vw,
            0.62rem
        );

        line-height: 1.25;
    }

    .project-tags {
        gap: 0.2rem 0.4rem;
    }

    .project-tags span {
        font-size: clamp(
            0.42rem,
            0.9vw,
            0.56rem
        );
    }
}