@layer pages {
    /* ==========================================================================
       PORTFOLIO.CSS - Estilos Exclusivos da Página de Portfólio
       ========================================================================== */

    .hero-portfolio {
        min-height: 100vh;
        position: relative;
    }

    /* Transição suave/degradê do fundo do Hero (Paridade com index.html) */
    #main-content::after {
        content: '';
        position: absolute;
        bottom: -2px; /* Resolve subpixel rendering issues */
        left: 0;
        width: 100%;
        height: 200px; /* Gradient generoso e orgânico */
        z-index: 5;
        background: linear-gradient(to bottom, rgba(244, 247, 249, 0) 0%, var(--bg-color) 100%);
        pointer-events: none;
    }

    html.dark-theme #main-content::after {
        background: linear-gradient(to bottom, rgba(26, 30, 38, 0) 0%, var(--bg-color) 100%);
    }

    .hero-portfolio h1 {
        font-size: 1.2rem;
        color: var(--highlight-color);
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 2px;
        margin-bottom: 15px;
    }

    .hero-portfolio h2 i {
        margin: 0 10px;
        opacity: 0.9;
        font-size: 0.85em;
        vertical-align: middle;
    }

    .hero-description {
        font-size: 1rem !important;
        opacity: 0.8;
        max-width: 700px;
        margin: 0 auto 40px;
        line-height: 1.6;
    }

    /* GRID & FILTROS */
    .portfolio-grid-section {
        padding: 60px 20px 100px;
    }

    .portfolio-container {
        max-width: 1200px;
        margin: 0 auto;
    }

    .filter-controls {
        display: flex;
        justify-content: center;
        gap: 15px;
        margin-bottom: 50px;
        flex-wrap: wrap;
    }

    .filter-btn {
        background: transparent;
        border: 1px solid var(--border-color);
        color: var(--secondary-text-color);
        padding: 10px 24px;
        border-radius: 99px;
        font-size: 0.95rem;
        cursor: pointer;
        transition: all 0.3s ease;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .filter-btn:hover {
        border-color: var(--highlight-color);
        color: var(--highlight-color);
    }

    .filter-btn.active {
        background: var(--highlight-color);
        border-color: var(--highlight-color);
        color: #fff;
        box-shadow: 0 4px 15px rgba(var(--highlight-color-rgb), 0.3);
    }

    html.dark-theme .filter-btn.active {
        box-shadow: 0 4px 15px rgba(var(--highlight-color-rgb), 0.3);
    }

    /* BENTO GRID HÍBRIDO */
    .hybrid-bento-grid {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        grid-auto-rows: 320px;
        gap: 16px;
    }

    .bento-card {
        position: relative;
        border-radius: 20px;
        overflow: hidden;
        border: 1px solid var(--border-color);
        background: var(--container-bg-color);
        transition: transform 0.4s cubic-bezier(.16, 1, .3, 1), box-shadow 0.4s ease, opacity 0.4s ease, scale 0.4s ease;
        box-shadow: var(--card-shadow);
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        align-items: stretch;
        isolation: isolate; /* Garante que os z-index internos não conflitem com o exterior */
    }

    .bento-card.hidden {
        opacity: 0;
        scale: 0.95;
        pointer-events: none;
        position: absolute;
        /* Remove do fluxo layout visual no grid estrito */
        visibility: hidden;
    }

    .bento-card:hover {
        transform: translateY(-6px);
        box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
        z-index: 10;
    }

    .span-2-col {
        grid-column: span 2;
    }

    .span-3-col {
        grid-column: span 3;
    }

    .span-4-col {
        grid-column: span 4;
    }

    .span-2-row {
        grid-row: span 2;
    }

    /* Assets dentro dos cards */
    .bento-image,
    .bento-video,
    .bento-canvas,
    .bento-iframe-container {
        position: absolute;
        inset: 0;
        width: 100% !important;
        height: 100% !important;
        object-fit: cover;
        z-index: 0;
        transition: transform 0.6s cubic-bezier(.16, 1, .3, 1);
    }

    .bento-iframe-container iframe {
        width: 100%;
        height: 100%;
        border: none;
        pointer-events: none;
    }

    .bento-image,
    .bento-video,
    .bento-canvas {
        object-position: center;
    }

    /* Utilitário para focar no topo (útil para prints de sites) */
    .pos-top {
        object-position: top center !important;
    }

    .bento-card:hover .bento-image,
    .bento-card:hover .bento-video,
    .bento-card:hover .bento-canvas {
        transform: scale(1.05);
    }

    /* Trocador Light / Dark para imagens (Transversal ao site) */
    .dark-img {
        display: none;
    }

    html.dark-theme .dark-img {
        display: block;
    }

    html.dark-theme .light-img {
        display: none;
    }

    /* Utilidade de Ocultação Real */
    .hidden {
        display: none !important;
    }

    /* Overlay Estilos */
    .bento-overlay {
        position: relative;
        z-index: 2;
        padding: 24px 24px 74px 24px;
        /* Gradiente Suavizado (Easing) para evitar bordas duras */
        background: linear-gradient(
            to top,
            rgba(0, 0, 0, 0.8) 0%,
            rgba(0, 0, 0, 0.4) 30%,
            rgba(0, 0, 0, 0.1) 60%,
            rgba(0, 0, 0, 0) 100%
        );
        color: #fff;
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        height: 100%;
        width: 100%;
        box-sizing: border-box;
        pointer-events: none;
    }

    .bento-overlay h3 {
        font-size: 1.4rem;
        font-weight: 700;
        margin: 0; /* Removida margem inferior para o título encostar na base */
        color: #fff;
        text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6); /* Sombra sutil mas eficaz */
        transition: transform 0.4s cubic-bezier(.16, 1, .3, 1);
    }

    .bento-overlay p {
        font-size: 0.95rem;
        margin: 0;
        opacity: 0; /* Oculto por padrão */
        max-height: 0; /* Não ocupa espaço físico */
        overflow: hidden; /* Garante que o texto não "vaze" */
        transform: translateY(10px); /* Prepara o efeito de subida no hover */
        line-height: 1.4;
        text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
        transition: opacity 0.4s ease, transform 0.4s cubic-bezier(.16, 1, .3, 1), max-height 0.4s ease, margin-top 0.4s ease;
    }

    .bento-card:hover .bento-overlay p {
        opacity: 0.9;
        max-height: 100px; /* Suficiente para a descrição */
        margin-top: 8px; /* Espaço entre título e descrição apenas no hover */
        transform: translateY(0);
    }

    /* Rodapé Glassbar Dedicado (Agora como Link Direto) */
    .bento-footer {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        height: 64px;
        background: rgba(0, 0, 0, 0.25);
        -webkit-backdrop-filter: blur(12px);
        backdrop-filter: blur(12px);
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        padding: 0 24px;
        display: flex;
        align-items: center;
        justify-content: space-between; /* Separa o texto da seta */
        z-index: 3;
        transition: all 0.3s ease;
        text-decoration: none;
        color: #fff;
        font-size: 0.85rem;
        font-weight: 700;
    }

    .bento-card:hover .bento-footer {
        background: rgba(0, 0, 0, 0.5);
    }

    .bento-footer i {
        transition: transform 0.3s ease;
        opacity: 0.7;
    }

    .bento-footer:hover i {
        transform: translateX(6px);
        opacity: 1;
    }

    .bento-badge {
        position: absolute;
        top: 20px;
        left: 20px;
        background: rgba(0, 0, 0, 0.5);
        -webkit-backdrop-filter: blur(8px);
        backdrop-filter: blur(8px);
        border: 1px solid rgba(255, 255, 255, 0.2);
        padding: 6px 12px;
        border-radius: 99px;
        font-size: 0.75rem;
        font-weight: 700;
        color: #fff;
        display: flex;
        align-items: center;
        gap: 6px;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    /* ==========================================================================
       DETALHES DO PROJETO (EXPANSÍVEL)
       ========================================================================== */
    .project-detail-panel {
        background: var(--container-bg-color);
        border: 1px solid var(--border-color);
        border-radius: 20px;
        margin-bottom: 40px;
        position: relative;
        overflow: hidden;
        transition: all 0.5s cubic-bezier(0.16, 1, 0.3, 1);
        max-height: 900px;
        opacity: 1;
        box-shadow: var(--card-shadow);
        will-change: max-height, opacity, margin-bottom;
    }

    .project-detail-panel.hidden {
        max-height: 0;
        opacity: 0;
        margin-bottom: 0;
        border-width: 0;
        padding-top: 0;
        padding-bottom: 0;
        pointer-events: none;
    }

    .detail-layout {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 40px;
        padding: 40px;
        min-height: 400px;
        transition: opacity 0.3s ease-in-out;
    }

    .detail-layout.content-fade-out {
        opacity: 0;
    }

    .detail-content {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: flex-start;
        padding-right: 20px;
    }

    .detail-visual {
        position: relative;
        border-radius: 12px;
        overflow: hidden;
        background: rgba(0, 0, 0, 0.2);
        width: 100%;
        height: 450px;
        /* Tamanho definido para evitar cortes bruscos */
        border: 1px solid var(--border-color);
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    }

    .detail-media-item {
        position: absolute;
        inset: 0;
        width: 100%;
        height: 100%;
        object-fit: cover;
        object-position: top center;
        border: none;
    }

    .detail-media-item.hidden {
        display: none !important;
    }

    /* Visual em Camadas (Ícone + Fundo) no Detalhe */
    .detail-layered-container {
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--container-bg-color);
        overflow: hidden;
    }

    .detail-layered-container .pcard-bg-layer {
        opacity: 0.5;
        transition: transform 1.2s cubic-bezier(.16, 1, .3, 1);
    }

    .detail-layered-container:hover .pcard-bg-layer {
        transform: scale(1.15);
    }

    /* Painel de detalhes com hero de fundo (Luxe Salão, Gym Brasil) */
    .detail-layered-container.has-hero-bg .pcard-bg-layer {
        background-image:
            linear-gradient(rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.5)),
            var(--detail-hero-bg);
        opacity: 1;
        filter: blur(3px);
        transform: scale(1.08);
    }

    html.dark-theme .detail-layered-container.has-hero-bg .pcard-bg-layer {
        background-image:
            linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)),
            var(--detail-hero-bg);
    }

    .detail-layered-container.has-hero-bg:hover .pcard-bg-layer {
        transform: scale(1.13);
    }

    /* Overlay definido por tema no CSS; o JS injeta apenas a URL do hero */
    .detail-layered-container.has-hero-bg .pcard-icon-layer {
        z-index: 2;
    }

    /* Classes de Fix para o background do detalhe */
    .detail-layered-container.bg-academia-fix .pcard-bg-layer {
        transform: rotate(90deg) scale(1.8);
    }
    .detail-layered-container.bg-academia-fix:hover .pcard-bg-layer {
        transform: rotate(90deg) scale(2);
    }

    .detail-layered-container .pcard-icon-layer img {
        width: 180px !important; /* Maior que no card original */
        max-width: 80% !important;
        transform: translateY(0) !important; /* Sem offset forçado para alinhar ao centro do painel */
        filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.3));
        transition: transform 0.8s cubic-bezier(.16, 1, .3, 1), filter 0.8s ease;
    }

    .detail-layered-container:hover .pcard-icon-layer img {
        transform: scale(1.1) rotate(2deg) !important;
    }

    .detail-title {
        font-size: 2.2rem;
        margin: 20px 0 15px;
        color: var(--text-color);
        font-weight: 700;
        letter-spacing: -0.5px;
    }

    .detail-description {
        font-size: 1.05rem;
        line-height: 1.7;
        color: var(--secondary-text-color);
        margin-bottom: 30px;
    }

    .btn-close-detail {
        position: absolute;
        top: 20px;
        right: 20px;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.1);
        color: var(--text-color);
        width: 44px;
        height: 44px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 10;
        transition: all 0.3s ease;
        -webkit-backdrop-filter: blur(8px);
        backdrop-filter: blur(8px);
    }

    .btn-close-detail:hover {
        background: var(--highlight-color);
        border-color: var(--highlight-color);
        color: #fff;
        transform: rotate(90deg);
    }

    .detail-content .bento-badge {
        position: static;
        display: inline-flex;
    }

    /* CTA Section (Card Style) */
    .cta-section {
        padding: 100px 20px;
        text-align: center;
    }

    .interactive-wrapper .cta-section {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        position: relative;
        z-index: 5;
    }

    .portfolio-cta-box {
        background-color: var(--container-bg-color);
        padding: 40px;
        border-radius: 12px;
        border: 1px solid var(--highlight-color);
        max-width: 800px;
        margin: 0 auto;
        position: relative;
        box-shadow: 0 0 30px rgba(var(--highlight-rgb), 0.1);
    }

    .portfolio-cta-box h3 {
        font-size: 1.8rem;
        margin-bottom: 15px;
        color: var(--text-color);
    }

    .portfolio-cta-box p {
        color: var(--secondary-text-color);
        margin-bottom: 30px;
        font-size: 1.1rem;
    }

    /* RESPONSIVE */
    @media (max-width: 1024px) {
        .detail-layout {
            gap: 20px;
            padding: 30px;
        }

        .hybrid-bento-grid {

            grid-template-columns: repeat(2, 1fr);
        }

        /* Ajuste de reflow no masonry/bento para evitar buracos quando filtrar */
        .span-2-col {
            grid-column: span 1;
        }
    }

    @media (max-width: 600px) {
        .hybrid-bento-grid {
            grid-template-columns: 1fr;
            grid-auto-rows: 280px;
        }

        .bento-overlay {
            /* Gradiente mobile ultra-suavizado e mais terminal para não subir no ícone */
            background: linear-gradient(
                to top,
                rgba(0, 0, 0, 0.75) 0%,
                rgba(0, 0, 0, 0.3) 25%,
                rgba(0, 0, 0, 0) 50%
            ) !important;
            padding-bottom: 65px;
        }

        .span-2-row {
            grid-row: span 1;
        }

        .filter-controls {
            flex-direction: column;
            align-items: stretch;
            gap: 10px;
        }

        .filter-btn {
            justify-content: center;
        }

        /* Ajustes no Painel de Detalhes */
        .detail-layout {
            grid-template-columns: 1fr;
            padding: 30px 20px;
            gap: 25px;
            min-height: 0;
        }

        .detail-visual {
            order: -1;
            /* Move a imagem para o topo */
            height: 250px;
            border-radius: 12px;
        }

        .detail-content {
            padding-right: 0;
            align-items: center;
            text-align: center;
        }

        .detail-title {
            font-size: 1.6rem;
            margin: 10px 0;
        }

        .detail-description {
            font-size: 0.95rem;
            margin-bottom: 25px;
        }

        .detail-content .cta-button {
            width: 100%;
            justify-content: center;
        }

        .btn-close-detail {
            top: 10px;
            right: 10px;
            width: 36px;
            height: 36px;
        }
    }
}
