/* ==========================================================================
   Portfólio — Gabriel Amaral
   ========================================================================== */

:root {
    --bg: #1d1d20;
    --surface: #26262b;
    --text: #ffffff;
    --text-muted: #a8a8b3;
    --accent: #667eea;
    --accent-dark: #764ba2;
    --border: rgba(255, 255, 255, 0.08);
    --nav-height: 64px;
    --radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

img,
video {
    display: block;
    max-width: 100%;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    position: relative;
    z-index: 2;
}

/* Alvos de âncora não ficam escondidos atrás da nav fixa */
[id] {
    scroll-margin-top: calc(var(--nav-height) + 16px);
}

/* Foco visível e consistente para navegação por teclado */
a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 4px;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 1100;
    padding: 12px 20px;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    border-radius: 0 0 var(--radius) 0;
}

.skip-link:focus {
    left: 0;
}

/* ==========================================================================
   Navegação
   ========================================================================== */

/* Barra flutuante em formato de pílula, centralizada no topo.
   O wrapper ocupa a largura toda mas não captura cliques — só a pílula em si. */
.nav {
    position: fixed;
    top: 18px;
    left: 0;
    right: 0;
    z-index: 1000;
    display: flex;
    justify-content: center;
    padding: 0 16px;
    pointer-events: none;
}

.nav-inner {
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    padding: 7px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(29, 29, 32, 0.5);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.nav.scrolled .nav-inner {
    background: rgba(29, 29, 32, 0.88);
    border-color: rgba(255, 255, 255, 0.22);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
    list-style: none;
}

.nav-links a {
    display: block;
    padding: 9px 20px;
    color: rgba(255, 255, 255, 0.72);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    white-space: nowrap;
    border-radius: 999px;
    transition: color 0.2s ease, background-color 0.2s ease;
}

.nav-links a:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
}

/* CTA de WhatsApp: fecha a pílula do lado direito */
.nav-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
    padding: 9px 18px;
    border-radius: 999px;
    background: #25d366;
    color: #0b3d20;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    white-space: nowrap;
    transition: background-color 0.2s ease, transform 0.2s ease,
        box-shadow 0.2s ease;
}

.nav-cta:hover {
    background: #1fbe5a;
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(37, 211, 102, 0.35);
}

.nav-cta-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ==========================================================================
   Header / Hero
   ========================================================================== */

.header {
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    align-items: center;
    text-align: center;
    /* Espaçamento enxuto de propósito: com padding maior os botões do hero
       caíam abaixo da dobra em telas de notebook. */
    padding: calc(var(--nav-height) + 16px) 0 32px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: #fff;
    position: relative;
    overflow: hidden;
}

/* Overlay: garante legibilidade do texto branco sobre o vídeo */
.header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg,
            rgba(0, 0, 0, 0.45) 0%,
            rgba(0, 0, 0, 0.6) 60%,
            rgba(29, 29, 32, 0.95) 100%);
    z-index: 1;
}

.header-content {
    position: relative;
    z-index: 2;
    width: 100%;
}

.video-background {
    position: absolute;
    inset: 0;
    overflow: hidden;
    z-index: 0;
}

.video-background video {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    transform: translate(-50%, -50%);
    object-fit: cover;
}

.name {
    font-size: clamp(1.75rem, 4.5vw, 3.25rem);
    font-weight: 700;
    margin-bottom: 10px;
    letter-spacing: -1.5px;
    line-height: 1.15;
    text-wrap: balance;
}

.title-large {
    font-size: clamp(1.1rem, 2.5vw, 1.75rem);
    font-weight: 300;
    letter-spacing: 2px;
    margin-bottom: 20px;
    text-transform: uppercase;
    opacity: 0.9;
}

.bio {
    max-width: 700px;
    margin: 0 auto;
    font-size: clamp(0.95rem, 1.6vw, 1.1rem);
    line-height: 1.7;
    opacity: 0.95;
    font-weight: 300;
    text-wrap: pretty;
}

.header-actions {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 28px;
}

.btn {
    display: inline-block;
    padding: 14px 28px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: transform 0.3s ease, box-shadow 0.3s ease,
        background-color 0.3s ease;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: #7688ee;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.35);
}

.btn-ghost {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.35);
}

.btn-ghost:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: translateY(-2px);
}

/* ==========================================================================
   Projetos
   ========================================================================== */

.works {
    padding: 100px 0;
}

.section-title {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    font-weight: 600;
    text-align: center;
    margin-bottom: 70px;
    position: relative;
}

.section-title::after {
    content: '';
    width: 60px;
    height: 4px;
    border-radius: 2px;
    background: linear-gradient(45deg, var(--accent), var(--accent-dark));
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
}

.project-grid {
    display: grid;
    gap: 40px;
}

.project {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    align-items: center;
    padding: 40px 0;
    border-bottom: 1px solid var(--border);
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.project.is-visible {
    opacity: 1;
    transform: none;
}

.project:last-child {
    border-bottom: none;
}

/* Layout alternado: imagem à direita nos projetos pares.
   `order` no grid é mais previsível que o antigo hack com `direction: rtl`. */
.project:nth-child(even) .project-image {
    order: 2;
}

.project-image {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
    transition: transform 0.4s ease, box-shadow 0.4s ease;
}

.project-image:hover {
    transform: translateY(-10px);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45);
}

/* aspect-ratio no lugar de altura fixa: nada estoura o container no mobile.
   2/1 acompanha a proporção real dos screenshots (~1.97 a 2.11), então o corte
   é mínimo; object-position mantém o topo da tela sempre visível. */
.project-image img {
    width: 100%;
    aspect-ratio: 2 / 1;
    object-fit: cover;
    object-position: top center;
    transition: transform 0.4s ease;
}

.project-image:hover img {
    transform: scale(1.05);
}

.project-content {
    padding: 20px 0;
}

.project-category {
    color: #9aabf5;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.project-title {
    font-size: clamp(1.35rem, 3vw, 2rem);
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
}

.project-description {
    color: #d6d6de;
    font-size: 1rem;
    line-height: 1.7;
    margin-bottom: 25px;
    text-wrap: pretty;
}

.project-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.detail-item h4 {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.detail-item p {
    font-size: 0.95rem;
    color: var(--text);
}

.project-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.project-link {
    display: inline-block;
    padding: 12px 24px;
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 500;
    transition: transform 0.3s ease, box-shadow 0.3s ease,
        background-color 0.3s ease;
}

.project-link:hover {
    background: #7688ee;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

/* ==========================================================================
   Stack
   ========================================================================== */

.stack {
    padding: 20px 0 100px;
}

.stack-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
}

.stack-group {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
}

.stack-group h3 {
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #9aabf5;
    margin-bottom: 18px;
}

.stack-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    list-style: none;
}

.stack-list li {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 0.9rem;
    color: var(--text);
}

/* ==========================================================================
   Footer
   ========================================================================== */

.footer {
    background: #17171a;
    border-top: 1px solid var(--border);
    color: #fff;
    padding: 80px 0 40px;
    text-align: center;
}

.footer h2 {
    font-size: clamp(1.4rem, 3vw, 2rem);
    margin-bottom: 30px;
    font-weight: 300;
}

.contact-links {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.contact-link {
    color: #fff;
    text-decoration: none;
    padding: 10px 20px;
    border: 2px solid var(--border);
    border-radius: 6px;
    transition: border-color 0.3s ease, background-color 0.3s ease,
        transform 0.3s ease;
}

.contact-link:hover {
    border-color: var(--accent);
    background: rgba(102, 126, 234, 0.12);
    transform: translateY(-2px);
}

.copyright {
    border-top: 1px solid #2e2e34;
    padding-top: 24px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ==========================================================================
   Back to top
   ========================================================================== */

.back-to-top {
    position: fixed;
    right: 30px;
    bottom: 30px;
    width: 50px;
    height: 50px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease,
        transform 0.3s ease, background-color 0.3s ease;
    z-index: 900;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover {
    background: var(--accent-dark);
    transform: translateY(-3px);
}

/* ==========================================================================
   Responsivo
   ========================================================================== */

@media (max-width: 900px) {
    .project {
        grid-template-columns: 1fr;
        gap: 28px;
    }

    /* No empilhamento a imagem sempre vem primeiro */
    .project:nth-child(even) .project-image {
        order: 0;
    }
}

@media (max-width: 768px) {
    .nav {
        top: 12px;
        padding: 0 12px;
    }

    .nav-inner {
        padding: 5px 6px;
    }

    .nav-links {
        gap: 2px;
    }

    .nav-links a {
        padding: 8px 12px;
        font-size: 0.7rem;
        letter-spacing: 0.8px;
    }

    /* Espaço apertado: o CTA fica só com o ícone */
    .nav-cta {
        margin-left: 4px;
        padding: 9px 11px;
    }

    .nav-cta-label {
        display: none;
    }

    .header {
        padding: calc(var(--nav-height) + 12px) 0 40px;
    }

    .header-content {
        padding: 0 4px;
    }

    .works {
        padding: 70px 0;
    }

    .section-title {
        margin-bottom: 50px;
    }

    .project-content {
        padding: 0;
    }

    .project-details {
        grid-template-columns: repeat(2, 1fr);
    }

    .footer {
        padding: 60px 0 30px;
    }

    .contact-links {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .back-to-top {
        right: 15px;
        bottom: 15px;
        width: 44px;
        height: 44px;
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .nav-links a {
        padding: 8px 8px;
        font-size: 0.62rem;
        letter-spacing: 0.3px;
    }

    .nav-cta {
        padding: 8px 9px;
    }

    .header-actions .btn {
        width: 100%;
    }

    .project-details {
        grid-template-columns: 1fr;
    }

    .stack-group {
        padding: 22px;
    }
}

/* ==========================================================================
   Acessibilidade — respeita quem pediu menos movimento no sistema
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .project {
        opacity: 1;
        transform: none;
    }

    .video-background {
        display: none;
    }
}
