/* --- VARIÁVEIS GLOBAIS --- */
:root {
    --primary-bg: #e5d7c4;
    --header-bg: #ede8e1;
    --accent-color: #d8a879b6;
    --accent-dark: #927749;
    --text-dark: #333;
    --text-light: #777;
    --white: #ffffff;
    --overlay-dark: rgba(0, 0, 0, 0.55);
}

/* --- RESET E ESTILOS BASE --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Helvetica', sans-serif;
}

html, body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100% !important;
}

body {
    padding-top: 110px !important;
    background-color: var(--primary-bg);
    color: var(--text-dark);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: clip;
}

img, video {
    max-width: 100%;
    height: auto;
}

/* --- HEADER PRINCIPAL --- */
.main-header {
    background-color: var(--header-bg);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    padding: 5px 0;
    position: fixed; /* Mudado de sticky para fixed */
    top: 0;
    width: 100%; /* Garantir que ocupa a largura toda */
    z-index: 1000;
    transition: all 0.3s ease-in-out;
}

/* 2. Classe que será adicionada via JavaScript ao fazer scroll */
    .main-header.scrolled {
    /* Diminuímos a opacidade para 0.7 para ser mais visível o efeito */
    background-color: rgba(237, 232, 225, 0.7) !important; 
    backdrop-filter: blur(10px); /* Aumentamos o desfoque */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    padding: 2px 0; /* O header encolhe um pouco no scroll (efeito elegante) */
}

body {
    padding-top: 90px; /* Ajuste este valor conforme a altura do seu logo */
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
}

/* --- LOGO --- */
.logo a {
    text-decoration: none;
    color: var(--text-dark);
    font-weight: bold;
    font-size: 1.5rem;
    letter-spacing: 2px;
}

.logo-img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    transform: scale(1.9);
    transform-origin: left top;
    z-index: 9999;
    position: relative;
    display: block;
    left: -50px;
}

/* --- MENU DE NAVEGAÇÃO (DESKTOP) --- */
.nav-links {
    list-style: none;
    display: flex;
    gap: 30px;
    align-items: center;
    margin-left: auto;
    margin-right: auto;
}

.nav-links li a {
    text-decoration: none;
    color: var(--text-dark);
    font-weight: 500;
    font-size: 0.95rem;
    padding: 8px 16px;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 20px;
    background-color: transparent;
    transition: all 0.3s ease;
    display: inline-block;
}

.nav-links li a:hover {
    border-color: var(--text-dark);
    background-color: rgba(0, 0, 0, 0.05);
    color: #000;
}

/* --- ÍCONES SOCIAIS NO HEADER (DESKTOP) --- */
.social-icons-header {
    display: flex;
    gap: 10px;
    align-items: center;
}

.social-icons-header a img {
    width: 28px;
    height: auto;
    transition: transform 0.2s ease;
}

.social-icons-header a:hover img {
    transform: scale(1.1);
}

/* --- BOTÃO HAMBÚRGUER (escondido no desktop) --- */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-dark);
}

/* --- ELEMENTOS MOBILE (escondidos no desktop) --- */
.mobile-header-left,
.mobile-social-icons,
.mobile-header-center {
    display: none;
}

/* ========== HERO SECTION ========== */
.portfolio-header {
    position: relative;
    overflow: hidden;
    color: var(--white);
    margin-top: 0;
    padding: 60px 40px;  /* VALOR ORIGINAL - não mexe */
    text-align: center;
}

/* Hero da página inicial (com slideshow) */
#hero-home {
    min-height: 600px !important; /* Aumenta a altura (era 500px) */
    margin-top: -110px; /* Anula o padding do body para colar no topo */
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-slideshow {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
}

.hero-slide {
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: #1a1a1a; /* Cor de fundo enquanto a foto não vem */
    background-size: cover;
    background-position: center;
    opacity: 0;
    animation: fadeAnim 15s infinite;
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #00000082;
    z-index: -1;
}

.hero-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 100%;
    text-align: center;
    z-index: 10;
}

.frase-destaque {
    font-size: 3.5rem; 
    color: rgb(220, 214, 207);
    font-weight: bold; 
    letter-spacing: 2px;
    display: block;
    text-align: center;
}

/* Animações do carrossel */
.hero-slide:nth-child(1) { animation-delay: 0s; }
.hero-slide:nth-child(2) { animation-delay: 3s; }
.hero-slide:nth-child(3) { animation-delay: 6s; }
.hero-slide:nth-child(4) { animation-delay: 9s; }
.hero-slide:nth-child(5) { animation-delay: 12s; }
.hero-slide:nth-child(6) { animation-delay: 15s; }
.hero-slide:nth-child(7) { animation-delay: 18s; }
.hero-slide:nth-child(8) { animation-delay: 21s; }
.hero-slide:nth-child(9) { animation-delay: 24s; }
.hero-slide:nth-child(10) { animation-delay: 27s; }
.hero-slide:nth-child(11) { animation-delay: 30s; }
.hero-slide:nth-child(12) { animation-delay: 33s; }
.hero-slide:nth-child(13) { animation-delay: 36s; }
.hero-slide:nth-child(14) { animation-delay: 39s; }
.hero-slide:nth-child(15) { animation-delay: 42s; }
.hero-slide:nth-child(16) { animation-delay: 45s; }
.hero-slide:nth-child(17) { animation-delay: 48s; }
.hero-slide:nth-child(18) { animation-delay: 51s; }
.hero-slide:nth-child(19) { animation-delay: 54s; }
.hero-slide:nth-child(20) { animation-delay: 57s; }
.hero-slide:nth-child(21) { animation-delay: 60s; }
.hero-slide:nth-child(22) { animation-delay: 63s; }
.hero-slide:nth-child(23) { animation-delay: 66s; }
.hero-slide:nth-child(24) { animation-delay: 69s; }
.hero-slide:nth-child(25) { animation-delay: 72s; }
.hero-slide:nth-child(26) { animation-delay: 75s; }
.hero-slide:nth-child(27) { animation-delay: 78s; }
.hero-slide:nth-child(28) { animation-delay: 81s; }
.hero-slide:nth-child(29) { animation-delay: 84s; }
.hero-slide:nth-child(30) { animation-delay: 87s; }

@keyframes fadeAnim {
    0% { opacity: 0; }
    10% { opacity: 1; }
    33% { opacity: 1; }
    43% { opacity: 0; }
    100% { opacity: 0; }
}

/* --- HEADER2 (títulos) --- */
.header2 {
    text-align: center;
    margin: 0;  /* ZERA a margem aqui */
    position: relative;  /* ADICIONA isto */
    top: -60px;  /* AJUSTA este valor (negativo sobe, positivo desce) */
}

.header2 h2 {
    font-size: 2.8rem;
    color: #dfd7d7;
    font-weight: 300;
    text-transform: uppercase;
    letter-spacing: 3px;
    position: relative;
    display: inline-block;
    padding-bottom: 10px;
}

.header2 h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 2px;
    background-color: var(--accent-dark);
}

.header2 h3 {
    color: var(--text-dark);
    font-size: 1.3rem;
    font-weight: bold;
    text-align: center;
    margin: 5px 0;
}

.header2.e-mais {
    margin: 40px 0 20px 0;
    font-weight: 300;
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

/* --- GRID DE PORTFÓLIO --- */
.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    background-color: transparent;
    padding: 10px 40px 40px 40px;
    max-width: 1800px;
    margin: 0 auto;
    width: 100%;
}

.portfolio-item {
    position: relative;
    overflow: hidden;
    background-color: var(--primary-bg);
    display: flex;
    justify-content: center;
    align-items: center;
}

.portfolio-item img {
    width: 100%;
    height: auto;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}

.portfolio-item:hover img, 
.portfolio-item:hover .video-content {
    transform: scale(1.05);
}

.item-overlay h3 {
    color: #c6bbad !important; /* Garante que é branco puro */
    font-size: 1.4rem;        /* Aumenta um pouco o tamanho */
    font-weight: 700;        /* Torna a letra mais grossa (Negrito) */
    text-align: center;
    text-transform: uppercase; /* Opcional: letras maiúsculas ajudam na leitura */
    letter-spacing: 1px;      /* Espaçamento entre letras para dar ar profissional */
    
    /* O SEGREDO: Sombra no texto para ele "saltar" da imagem/vídeo */
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7); 
    
    padding: 0 15px;
    margin: 0;
}

.item-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--overlay-dark); /* O teu preto translúcido */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1; /* Mudado de 0 para 1 */
    transition: background-color 0.3s ease;
    pointer-events: none;
}

/* 2. Faz o texto ficar sempre visível e no centro */
.item-overlay span {
    color: #c6bbad;
    font-size: 1.2rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1px;
    transform: translateY(0); /* Mudado de 20px para 0 para o texto não subir */
    transition: transform 0.3s ease;
    text-align: center;
}

/* Quando o contentor tiver a classe 'is-playing', escondemos o overlay */
.portfolio-item.is-playing .item-overlay {
    opacity: 0;
    pointer-events: none; /* Garante que não bloqueia o clique enquanto toca */
    transition: opacity 0.4s ease; /* Efeito suave ao desaparecer */
}

.portfolio-item:hover .item-overlay {
    opacity: 1;
}

/* --- VÍDEOS --- */
.video-content {
    width: 100%;
    height: auto;
    object-fit: contain;
    display: block;
}

/* --- PÁGINAS SECUNDÁRIAS (com h1) --- */
.portfolio-header:has(h1) {
    padding: 20px 20px 10px 20px;
    color: #44423f;
}

.portfolio-header h1 {
    font-size: 2.5rem;
    margin: 0;
}

.portfolio-header h3 {
    font-size: 3.4rem;
    color: rgb(0, 0, 0);
    margin: 10px 0;
    font-weight: bold;
}

/* Espaço extra da home */
.espaco {
    margin-bottom: 0; /* Removido espaço extra */
}

/* --- PÁGINAS: SOBRE E CONTACTOS --- */
.page-container {
    max-width: 1000px;
    margin: 40px auto;
    padding: 0 20px;
    text-align: center;
}

.page-title {
    font-size: 2.5rem;
    color: var(--text-dark);
    font-weight: 300;
    margin-bottom: 20px;
}

.sobre-texto {
    font-size: 1.1rem;
    line-height: 1.8;
    color: #444;
    margin-bottom: 40px;
}

.equipa-grid {
    display: flex;
    justify-content: center;
    gap: 80px;
    flex-wrap: wrap;
}

.membro {
    max-width: 300px;
    text-align: center;
}

.membro-foto {
    width: 220px;
    height: 220px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--accent-color);
    margin-bottom: 20px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.membro h3 {
    margin-bottom: 10px;
    color: var(--text-dark);
    font-size: 1.5rem;
}

.membro p {
    font-size: 1rem;
    color: #555;
    line-height: 1.6;
}

/* --- CONTACTOS --- */
.contacto-info {
    font-size: 1.2rem;
    line-height: 2.2;
    color: #444;
    margin-top: 40px;
}

.contacto-info strong {
    color: var(--text-dark);
}

.contacto-info a {
    color: var(--accent-dark);
    text-decoration: none;
    font-weight: bold;
    transition: color 0.3s;
}

.contacto-info a:hover {
    color: var(--text-dark);
}

/* --- FOOTER --- */
.main-footer {
    background-color: var(--primary-bg);
    padding: 20px;
    text-align: center;
    width: 100%;
    margin-top: auto;
    font-size: 0.8rem;
    color: var(--text-light);
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Estado inicial: Overlay visível e "atravessável" pelo clique */
.portfolio-item .item-overlay {
    opacity: 1;
    pointer-events: none; /* IMPORTANTE: permite clicar no play através do texto */
    transition: opacity 0.4s ease-in-out;
    z-index: 2;
}

/* Quando o vídeo está a tocar, a classe 'is-playing' esconde o overlay */
.portfolio-item.is-playing .item-overlay {
    opacity: 0;
}

/* Garante que o texto h3 seja branco e nítido */
.item-overlay h3 {
    color: #ffffff !important;
    text-shadow: 0px 2px 10px rgba(0, 0, 0, 0.8);
    pointer-events: none;
}

/* COMPORTAMENTO EXCLUSIVO PARA GALERIAS DE FOTOS NAS CATEGORIAS */

/* 1. Esconde o overlay por padrão */
.gallery-photos .portfolio-item .item-overlay {
    opacity: 0;
    pointer-events: auto; /* Permite detetar o rato */
    transition: opacity 0.3s ease;
}

/* 2. Mostra o overlay apenas ao passar o rato (Hover) */
.gallery-photos .portfolio-item:hover .item-overlay {
    opacity: 1;
}

/* 3. Garante que o texto se move ligeiramente (efeito elegante) */
.gallery-photos .item-overlay h3 {
    transform: translateY(10px);
    transition: transform 0.3s ease;
}

.gallery-photos .portfolio-item:hover .item-overlay h3 {
    transform: translateY(0);
}

/* --- BOTÃO VOLTAR (DISCRETO) --- */
.back-btn {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    color: var(--text-light); /* Cor cinza discreta */
    font-size: 0.85rem;
    font-weight: 400;
    margin-bottom: 10px;
    transition: color 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.back-btn:hover {
    color: var(--accent-dark); /* Ganha cor ao passar o rato */
}

/* Ajuste específico para garantir que o botão não fica "esmagado" no mobile */
@media screen and (max-width: 768px) {
    .back-btn {
        font-size: 0.75rem;
        margin-bottom: 5px;
    }
}





/* ========== MEDIA QUERIES - TELEMÓVEL ========== */
@media screen and (max-width: 768px) {
    /* Header mobile */
    .social-icons-header {
        display: none;
    }
    
    .mobile-header-left,
    .mobile-header-center,
    .mobile-social-icons {
        display: flex;
    }

    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    body {
        overflow-x: hidden !important;
        position: relative !important;
    }
    
     .nav-container {
        width: 100% !important;
        max-width: 100% !important;
        padding: 5px 10px !important;  /* Reduzir padding lateral */
        box-sizing: border-box !important;
    }

     .membro {
        width: 100% !important;
        max-width: 280px !important;
    }
    
    .mobile-header-left {
        display: flex !important;
        align-items: center;
        justify-content: flex-start;
        width: 80px;
        flex: 0 0 80px !important;
        order: 1;
    }
    
    .mobile-social-icons {
        display: flex !important;
        flex-direction: column;
        gap: 8px;
        margin-left: 15px;
    }
    
    .mobile-social-icons a img {
        width: 28px;
        height: auto;
        display: block;
    }
    
    .mobile-header-center {
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        order: 2;
        flex: 1;
    }
    
    .mobile-header-center .logo {
        display: flex !important;
        justify-content: center;
        align-items: center;
    }
    
    .mobile-header-center .logo-img {
        left: 0 !important; /* Isto anula o 'left: -50px' que tinhas no desktop */
        margin: 0 auto !important;
        transform: none !important;
        width: 100px !important;
        height: 100px !important;
        display: block !important;
    }
    
    .nav-container > .logo:not(.mobile-header-center .logo) {
        display: none;
    }
    
    .menu-toggle {
        display: block !important;
        order: 3;
        width: 80px !important;
        flex: 0 0 80px !important;
        text-align: right;
        background: none;
        border: none;
        font-size: 32px;
        color: var(--text-dark);
        padding: 0;
        margin-right: 15px;
    }
    
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background-color: var(--header-bg);
        flex-direction: column;
        padding: 20px;
        z-index: 1000;
        box-shadow: 0 5px 10px rgba(0,0,0,0.1);
    }
    
    .nav-links.active {
        display: flex !important;
    }
    
    .nav-links li {
        width: 100%;
        text-align: center;
        margin: 5px 0;
    }
    
    .nav-links li a {
        display: block;
        padding: 12px;
        font-size: 1.1rem;
        border: none;
        border-bottom: 1px solid rgba(0,0,0,0.1);
        border-radius: 0;
    }
    
    /* Hero mobile */
    .portfolio-header {
        padding: 40px 20px;
    }
    
    #hero-home {
        min-height: 400px !important; /* Altura maior no telemóvel (era 300px) */
        margin-top: -90px !important; /* Cola o hero no topo do ecrã */
        padding: 0 !important;
    }

    /* Ajuste para a frase não ficar tapada pelo logo se o hero subir */
    #hero-home .hero-content {
        padding-top: 80px; 
        font-size: bold;
    }
    
    .frase-destaque {
        font-size: 1.4rem !important;
        padding: 0 10px !important;  /* Adicionar padding nas laterais */
        word-wrap: break-word !important;
    }
    
    /* Grid mobile */
    .portfolio-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 15px;
        padding: 10px 40px 40px 40px;
        width: 100% !important;
        max-width: 1600px;
        box-sizing: border-box !important;
        gap: 8px !important;  /* Espaço pequeno entre as fotos */
        margin: 0 auto 20px auto;
    }
    
    .portfolio-item {
        aspect-ratio: 1 / 1 !important;  /* FORÇA QUADRADO PERFEITO */
        width: 100% !important;
        overflow: hidden !important;
        margin: 0 !important;
        border-radius: 8px !important;  /* Cantos ligeiramente arredondados (opcional) */
    }

    .portfolio-item img {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        object-fit: cover !important;  /* A imagem preenche todo o quadrado */
    }

    /* Texto "E mais..." */
    .header2.e-mais {
        margin-top: -15px !important;
        margin-bottom: 20px !important;
    }
    
    /* Vídeos mobile */
    .portfolio-item:has(video) {
        background-color: #1a1a1a;
        border-radius: 12px;
        overflow: hidden;
        box-shadow: 0 4px 12px rgba(0,0,0,0.2);
        margin-bottom: 15px;
    }
    
    .portfolio-item:has(video) .item-overlay {
        display: flex !important; /* Mudamos para flex para que o texto apareça */
    }
    
    /* Garante que o H1 não fica colado ou tapado pelo Header */
    .portfolio-header:has(h1) {
        padding-top: 20px !important;
        padding-bottom: 10px !important;
    }

    /* Vídeos */
    .video-content {
        width: 100% !important;
        height: auto !important;
        max-height: 70vh !important;
    }


    
    
    /* Títulos mobile */
    .header2 {
        top: 0 !important; 
        margin-top: 30px !important;
        margin-bottom: 10px !important;
    }

    .header2 h2 {
        font-size: 1.8rem !important;
        color: #000;
        white-space: normal !important;  /* Permitir quebra de linha */
        word-wrap: break-word !important;
        margin: 0 !important;  /* Remove margens internas */
        padding: 0 !important;
    }
    
    .header2 h3 {
        font-size: 1.2rem;
    }
    
    .portfolio-header h1 {
        font-size: 1.8rem;
    }
    
    .portfolio-header h3 {
        font-size: 2.2rem;
    }
    
    /* Páginas secundárias mobile */
    .page-container {
        margin: 30px auto;
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 15px !important;
        box-sizing: border-box !important;
    }
    
    .page-title {
        font-size: 2rem;
    }
    
    .equipa-grid {
        width: 100% !important;
        gap: 30px !important;
    }
    
    .membro-foto {
        width: 180px !important;
        height: 180px !important;
    }

    .contacto-info {
        width: 100% !important;
        word-wrap: break-word !important;
    }
    
    .contacto-info p {
        width: 100% !important;
        word-wrap: break-word !important;
    }

    /* Garantir que links e textos não ultrapassam */
    a {
        word-wrap: break-word !important;
    }

    /* Ajuste de alinhamento para textos longos no overlay mobile */
    .item-overlay {
        display: flex !important;
        flex-direction: column !important; /* Garante o empilhamento */
        justify-content: center !important;
        align-items: center !important;
        text-align: center !important; /* Alinha o contentor */
        padding: 15px !important;      /* Evita que o texto bata nas bordas */
        box-sizing: border-box !important;
    }

    .item-overlay span, 
    .item-overlay h3 {
        display: block !important;    /* Força o span a comportar-se como bloco */
        width: 100% !important;       /* Garante que ocupa a largura toda para centrar */
        text-align: center !important; /* Centra as linhas de texto entre si */
        margin: 0 !important;
        padding: 0 !important;
        white-space: normal !important; /* Garante que o texto quebra se for longo */
    }

    /* Footer mobile */
    .main-footer {
        width: 100% !important;
        padding: 15px 10px !important;
        font-size: 0.5rem;
        box-sizing: border-box !important;
        margin-top: 50px !important;
    }
}