/* Portfolio Page Styles */

.portfolio-intro {
    margin-bottom: 2rem;
    padding: 0 2rem;
    text-align: justify;
    max-width: 1250px;
    margin-left: auto;
    margin-right: auto;
}

.portfolio-intro p {
    font-size: 1.3rem;
    line-height: 1.8;
    color: #1a1a1a;
}

/* Filtros do Portfolio */
.portfolio-filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 3rem;
    padding: 0 2rem;
}

.filter-btn {
    padding: 0.75rem 1.5rem;
    background-color: rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    color: #333;
    font-family: 'Gabarito', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-btn:hover,
.filter-btn:focus {
    background-color: rgba(208, 163, 125, 0.2);
    border-color: rgba(208, 163, 125, 0.5);
}

.filter-btn.active {
    background-color: rgb(208, 163, 125);
    border-color: rgb(208, 163, 125);
    color: #fff;
}

.filter-btn:focus {
    outline: 2px solid rgb(208, 163, 125);
    outline-offset: 2px;
}

/* Grid do Portfolio - Masonry Verdadeiro (estilo Pinterest) */
.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: 2px; /* Mais granular para evitar cortes por sub-pixel */
    column-gap: 2rem; /* Gap horizontal entre colunas */
    row-gap: 0; /* Sem row-gap - usamos margin-bottom nos items */
    padding: 0;
    margin-bottom: 0;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

.portfolio-grid-surface {
    border-radius: 8px;
    margin: 0 1.0rem 2.5rem 1.0rem;
    padding: 2rem;
    background-color: rgba(0, 0, 0, 0.85);
    background-image: none;
}

@media (max-width: 1200px) {
    .portfolio-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 1024px) {
    .mesh-overlay {
        left: 220px;
        width: calc(100% - 220px);
    }
}

.portfolio-item {
    border-radius: 8px;
    overflow: visible;
    transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease;
    opacity: 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.0);
    position: relative;
    margin: 0 0 2rem 0; /* 2rem gap vertical entre items */
    /* grid-row-end será calculado dinamicamente por JavaScript */
}

.portfolio-image-wrapper {
    border-radius: 8px;
    overflow: hidden;
}

.portfolio-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.0);
}

.portfolio-image-wrapper {
    position: relative;
    width: 100%;
    display: block;
    line-height: 0;
    font-size: 0;
    margin: 0;
    padding: 0;
    /* border-radius e overflow aplicados acima */
}

.portfolio-image-wrapper img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
    margin: 0;
    padding: 0;
    /* Aspect ratio preservado nativamente */
}

.portfolio-item:hover .portfolio-image-wrapper img {
    transform: scale(1.00);
    filter: brightness(0.50);
}

.portfolio-item h2 {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem 1rem 1rem 1rem;
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #000;
    text-align: center;
    line-height: 1.4;
    background-color: rgba(0, 0, 0, 0.75);
    opacity: 0;
    transition: opacity 0.3s ease;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    z-index: 10;
}

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

.portfolio-link {
    text-decoration: none;
    color: inherit;
    display: block;
    position: relative;
}

.portfolio-link:hover,
.portfolio-link:focus {
    text-decoration: none;
    color: inherit;
}

/* Overlay com cor preta sólida semitransparente para páginas de projeto */
.mesh-overlay {
    position: fixed;
    top: 0;
    left: 275px;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.85);
    background-image: none;
    background-size: auto;
    background-position: 0 0;
    pointer-events: none;
    z-index: 0;
    width: calc(100% - 275px);
}

/* Galeria de Projeto Individual */
.project-gallery {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5.0rem;
    padding: 0 2rem;
    margin-bottom: 3rem;
}

.gallery-item {
    display: block;
    width: 100%;
    max-width: 1300px;
    background-color: transparent;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    overflow: hidden;
}

/* Container para imagens VERTICAIS - largura auto */
.gallery-item:has(picture.portrait) {
    width: fit-content;
}

/* Imagens HORIZONTAIS (landscape) - expandem até 1300px */
.gallery-item picture.landscape {
    display: block;
    width: 100%;
}

.gallery-item picture.landscape img {
    width: 100%;
    height: auto;
    display: block;
}

/* Imagens VERTICAIS (portrait) - mantêm proporção natural */
.gallery-item picture.portrait {
    display: block;
}

.gallery-item picture.portrait img {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 1300px;
    display: block;
}

/* Imagens VERTICAIS em ecrãs pequenos - respeitar margens */
@media (max-width: 1023px) {
    .gallery-item:has(picture.portrait) {
        width: 100%;
    }
    
    .gallery-item picture.portrait img {
        width: 100%;
        height: auto;
        max-height: none;
    }
}

.project-description {
    position: relative;
    z-index: 2;
    max-width: 900px;
    margin: 0 auto 2rem auto;
    padding: 0 2rem;
    text-align: center;
}

.project-description p {
    font-size: 1.3rem;
    line-height: 1.8;
    color: rgba(208, 163, 125, 0.75);
}

.about-text-project-summary {
    position: relative;
    z-index: 2;
    max-width: 1200px;
    padding: 0 2rem 0 2rem;
    margin: 0 auto 2rem auto;
    column-count: 2;
    column-gap: 3rem;
    column-rule: 1px solid rgb(208, 163, 125);
}

.about-text-project-summary p {
    text-indent: 3em;
    font-size: 1.3rem;
    line-height: 1.8;
    color: rgba(208, 163, 125, 0.75);
    margin-bottom: 1.5rem;
    text-align: justify;
    hyphens: auto;
}

.about-text-project-summary p:last-child {
    margin-bottom: 0;
}

/* Responsividade para textos dos projectos do portfolio */
@media (max-width: 1100px) {
    .about-text-project-summary {
        column-count: 1;
        column-rule: none;
    }
}

/* Textos nas páginas de projeto individual - acima do mesh-overlay */
.project-gallery ~ .share-section {
    position: relative;
    z-index: 2;
}

.share-section p {
    color: rgba(255, 255, 255, 0.65);
}

.project-gallery ~ .share-section p {
    color: rgba(255, 255, 255, 0.65);
}

.portfolio-grid-surface ~ .share-section p {
    color: #333;
}

.portfolio-grid-surface ~ .copyrights p {
    color: #333;
}

.about-card ~ .copyrights {
    position: relative;
    z-index: 2;
}

.about-card ~ .copyrights p {
    color: rgba(255, 255, 255, 0.65);
}

/* Copyrights na página de projeto individual */
.project-gallery ~ .copyrights {
    position: relative;
    z-index: 2;
}

.copyrights p {
    color: rgba(255, 255, 255, 0.65);
}

.project-gallery ~ .copyrights p {
    color: rgba(255, 255, 255, 0.65);
}

/* Títulos nas páginas de projeto individual */
.content-wrapper h1,
.content-wrapper h2 {
    color: rgb(208, 163, 125);
}

/* Exceção: título da página do portfolio grid */
.content-wrapper .portfolio-grid-title {
    color: #1a1a1a;
}

/* Responsividade */
@media (max-width: 1000px) and (min-width: 769px) {
    .portfolio-grid {
        grid-template-columns: 1fr;
    }

    .project-gallery {
        gap: 3.0rem;
        padding: 0 1rem;
    }
}

@media (max-width: 768px) {
    .portfolio-grid-surface {
        border-radius: 8px;
        margin: 0 1.0rem 4rem;
        padding: 2rem;
        background-color: rgba(0, 0, 0, 0.85);
        background-image: none;
    }

    .portfolio-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
        padding: 0.5rem 0 0 0;
        grid-auto-rows: auto; /* Mobile usa auto, sem masonry JavaScript */
    }

    .portfolio-grid-title {
        padding: 1.5rem 0 0 0;
        font-size: clamp(1.4rem, 4vw, 2.8rem);
        word-break: break-word;
        font-weight: 800;
    }

    .portfolio-filters {
        gap: 0.75rem;
        padding: 0 1rem;
        margin-bottom: 2rem;
    }

    .filter-btn {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
    }

    .portfolio-intro {
        padding: 0 1rem;
    }

    .portfolio-intro p {
        font-size: 1.3rem;
        line-height: 1.8;
        color: #1a1a1a;
        padding: 0 1.5rem 0 1.5rem;
    }

    .project-gallery {
        gap: 3.0rem;
        padding: 0 1rem;
    }

    .page-header h1 {
        font-size: clamp(2.8rem, 4vw, 4rem);
        word-break: break-word;
        font-weight: 800;
        padding: 1rem 0;
    }

    .portfolio-item { margin: 0; }

    .portfolio-item h2 {
        font-size: 1rem;
        padding: 1rem;
    }

    .mesh-overlay {
        left: 0;
        width: 100%;
        top: 64px;
    }
}

@media (max-width: 480px) {
    .portfolio-grid-surface {
        border-radius: 8px;
        margin: 0 0 4rem;
        padding: 2rem;
        background-color: rgba(0, 0, 0, 0.85);
        background-image: none;
    }

    .portfolio-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
        padding: 0.5rem 0 0 0;
    }

    .portfolio-grid-title {
        padding: 1rem 0 0 0;
        font-size: clamp(1.2rem, 5vw, 2.4rem);
        word-break: break-word;
        font-weight: 800;
    }

    .portfolio-intro p {
        padding: 1rem 0 1rem 0;
        color: #1a1a1a;
    }

    .portfolio-filters {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
    }

    .filter-btn {
        width: auto;
        padding: 0.75rem 1.5rem;
    }
}

/* Acessibilidade - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .portfolio-item,
    .portfolio-item:hover,
    .portfolio-image-wrapper img,
    .filter-btn {
        transition: none;
        transform: none;
    }
}
