/* ============================================================
   STACK TECNOLÓGICO | css/habilidades.css
   Layout: 3 colunas — col1: .featured (2 rows) | col2: 2 cards | col3: .ai (2 rows)
   ============================================================ */

#habilidades {
    position: relative;
    padding: 120px 0 140px;
    background-color: #06060e;
    overflow: hidden;
    z-index: 2;
}

/* ─── Fundo SVG decorativo ─── */
.stack-bg-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.85;
}

.stack-bg-svg svg {
    width: 100%;
    height: 100%;
}

/* ─── Header ─── */
.stack-header {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: 700px;
    margin: 0 auto clamp(56px, 7vw, 96px);
}

.stack-label {
    display: inline-block;
    font-family: var(--font-code);
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--primary);
    margin-bottom: 20px;
    padding: 5px 16px;
    border: 1px solid var(--card-border);
    border-radius: 3rem;
    background: var(--primary-glow);
}

.stack-header .section-title {
    font-size: clamp(3.2rem, 5vw, 5rem);
    line-height: 1.15;
    margin-bottom: 20px;
    letter-spacing: -1.5px;
}

.stack-header .accent-title-drama {
    font-family: var(--font-drama);
    font-style: italic;
    font-weight: 400;
    color: var(--accent);
    letter-spacing: 0;
}

.stack-intro {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    color: var(--text-muted);
    line-height: 1.7;
    max-width: 580px;
    margin: 0 auto;
}

/* ─── Grid principal ─── */
/*
   Estrutura:
   | .featured (col1, row 1-2) | card2 (col2, row1) | .ai (col3, row 1-2) |
   |                           | card3 (col2, row2) |                     |
   | card4 (col1-2, row3)      |                    | ← não existe; 5 cards|
   
   Layout real com 6 cards:
   col1(1.4fr) | col2(1fr) | col3(1.2fr)
   [.featured  | card2    | .ai       ]  row1
   [           | card3    |           ]  row2
   [card4      | card5    |           ]  ← .ai ainda ocupa col3 row1-2
*/
.stack-grid {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: 1.4fr 1fr 1.2fr;
    grid-template-rows: 280px 280px;
    gap: 18px;
}

/* ─── Posicionamento explícito dos cards ─── */

/* Card 1: .NET & C# — col1, rows 1-2 */
.stack-card--featured {
    grid-column: 1;
    grid-row: 1 / 3;
}

/* Cards 2-5: col2, rows 1 e 2 (automaticos) */
/* Card 6: IA — col3, rows 1-2 */
.stack-card--ai {
    grid-column: 3;
    grid-row: 1 / 3;
}

/* ─── Card base ─── */
.stack-card {
    position: relative;
    border-radius: 2rem;
    overflow: hidden;
    cursor: pointer;
    /* Borda muito sutil — quase invisível */
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.03);
    transition:
        border-color 0.45s ease,
        box-shadow 0.45s ease,
        transform 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.stack-card:hover {
    /* Hover sutil — sem o roxo saturado */
    border-color: rgba(99, 102, 241, 0.18);
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.5),
        0 0 24px rgba(99, 102, 241, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
    transform: translateY(-3px);
}

/* ─── Imagem de fundo ─── */
.stack-card__bg {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.stack-card__bg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 1.6s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform;
    /* Contraste sutil — deixa a imagem respirar */
    filter: brightness(0.38) saturate(0.5);
}

.stack-card:hover .stack-card__bg img {
    transform: scale(1.06);
    filter: brightness(0.48) saturate(0.65);
}

/* ─── Overlay gradiente suave (sem roxo forte) ─── */
.stack-card__overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    background: linear-gradient(
        160deg,
        rgba(6, 6, 14, 0.15) 0%,
        rgba(6, 6, 14, 0.82) 65%,
        rgba(6, 6, 14, 0.97) 100%
    );
    transition: background 0.5s ease;
}

/* Hover: toque muito sutil de índigo sem saturar */
.stack-card:hover .stack-card__overlay {
    background: linear-gradient(
        160deg,
        rgba(6, 6, 18, 0.12) 0%,
        rgba(8, 8, 22, 0.80) 60%,
        rgba(10, 10, 28, 0.97) 100%
    );
}

/* Linha índigo animada no base (hover) */
.stack-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(99, 102, 241, 0.6) 30%,
        rgba(129, 140, 248, 0.8) 60%,
        transparent
    );
    z-index: 5;
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 0.55s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.stack-card:hover::after {
    transform: scaleX(1);
}

/* ─── Conteúdo ─── */
.stack-card__content {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: clamp(18px, 3vw, 36px);
}

/* ─── Ícone SVG — tamanho fixo e correto ─── */
.stack-card__icon {
    width: 44px;
    height: 44px;
    /* Garante que o SVG preencherá o container */
    flex-shrink: 0;
    margin-bottom: 14px;
    color: rgba(129, 140, 248, 0.85); /* índigo mais suave */
    /* Sombra muito sutil */
    filter: drop-shadow(0 0 6px rgba(99, 102, 241, 0.25));
    transition: transform 0.35s ease, filter 0.35s ease, color 0.35s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stack-card--featured .stack-card__icon,
.stack-card--ai .stack-card__icon {
    width: 52px;
    height: 52px;
}

.stack-card__icon svg {
    width: 100%;
    height: 100%;
    overflow: visible; /* evita corte de paths nas bordas */
}

.stack-card:hover .stack-card__icon {
    transform: scale(1.1) translateY(-2px);
    color: rgba(165, 180, 252, 0.95);
    filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.45));
}

/* ─── Label ─── */
.stack-card__label {
    display: inline-block;
    font-family: var(--font-code);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    /* Cor mais sutil — não roxo saturado */
    color: rgba(129, 140, 248, 0.7);
    margin-bottom: 8px;
}

/* ─── Título ─── */
.stack-card__title {
    font-family: var(--font-heading);
    font-size: clamp(1.9rem, 2.2vw, 2.6rem);
    font-weight: 700;
    color: #fff;
    line-height: 1.15;
    margin-bottom: 10px;
    letter-spacing: -0.5px;
}

.stack-card--featured .stack-card__title,
.stack-card--ai .stack-card__title {
    font-size: clamp(2.2rem, 2.8vw, 3.2rem);
    margin-bottom: 14px;
}

/* ─── Descrição ─── */
.stack-card__desc {
    font-family: var(--font-heading);
    font-size: clamp(1.25rem, 1.3vw, 1.45rem);
    color: rgba(255, 255, 255, 0.72);
    line-height: 1.65;
    margin: 0;
}

/* ─── Animações SVG refinadas ─── */

/* Card .NET: borda do retângulo se desenha */
@keyframes drawRect {
    0%   { stroke-dashoffset: 120; opacity: 0.4; }
    50%  { opacity: 1; }
    100% { stroke-dashoffset: 0;   opacity: 0.4; }
}
.stack-card--featured .stack-card__icon svg rect {
    stroke-dasharray: 120;
    animation: drawRect 3.5s ease-in-out infinite;
}

/* Angular: escudo pulsa */
@keyframes shieldPulse {
    0%, 100% { transform: scale(1);    opacity: 1;    }
    50%       { transform: scale(1.06); opacity: 0.75; }
}
.stack-card:nth-child(2) .stack-card__icon svg {
    transform-origin: 20px 20px;
    animation: shieldPulse 3s ease-in-out infinite;
}

/* Azure Cloud: nuvem flutua */
@keyframes cloudFloat {
    0%, 100% { transform: translateY(0px); }
    50%       { transform: translateY(-3px); }
}
.stack-card:nth-child(3) .stack-card__icon svg {
    animation: cloudFloat 4s ease-in-out infinite;
}

/* SQL: linha do banco pulsa */
@keyframes dbPulse {
    0%, 100% { stroke-dashoffset: 0;  opacity: 0.5; }
    50%       { stroke-dashoffset: 8;  opacity: 1;   }
}
.stack-card:nth-child(4) .stack-card__icon svg line {
    stroke-dasharray: 4 4;
    animation: dbPulse 2.5s ease-in-out infinite;
}

/* CI/CD: check se desenha */
@keyframes checkDraw {
    0%   { stroke-dashoffset: 30; }
    60%  { stroke-dashoffset: 0;  }
    100% { stroke-dashoffset: 0;  }
}
.stack-card:nth-child(5) .stack-card__icon svg path:last-child {
    stroke-dasharray: 30;
    animation: checkDraw 2.2s ease-in-out infinite;
}

/* IA/Gemini: anéis giram em direções opostas, nós pulsam */
@keyframes aiRotateOuter {
    from { transform: rotate(0deg);   }
    to   { transform: rotate(360deg); }
}
@keyframes aiRotateInner {
    from { transform: rotate(0deg);    }
    to   { transform: rotate(-360deg); }
}
@keyframes nodePulse {
    0%, 100% { opacity: 0.35; r: 2; }
    50%       { opacity: 0.85; r: 2.8; }
}

.stack-icon-ai .ai-ring-1 {
    transform-origin: 20px 20px;
    animation: aiRotateOuter 10s linear infinite;
}
.stack-icon-ai .ai-ring-2 {
    transform-origin: 20px 20px;
    animation: aiRotateInner 16s linear infinite;
}
/* Os 4 nós pulsam em cascata */
.stack-icon-ai circle:nth-child(4) { animation: nodePulse 2s ease-in-out infinite 0s;    }
.stack-icon-ai circle:nth-child(5) { animation: nodePulse 2s ease-in-out infinite 0.5s;  }
.stack-icon-ai circle:nth-child(6) { animation: nodePulse 2s ease-in-out infinite 1s;    }
.stack-icon-ai circle:nth-child(7) { animation: nodePulse 2s ease-in-out infinite 1.5s;  }

/* ─── Rodapé da seção ─── */
.stack-footer-bar {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 40px;
    padding-top: 28px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    flex-wrap: wrap;
}

.stack-footer-label {
    font-family: var(--font-code);
    font-size: 1.1rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    white-space: nowrap;
    flex-shrink: 0;
}

.stack-tags {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.stack-tags span {
    font-family: var(--font-code);
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.52);
    padding: 5px 14px;
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 3rem;
    background: rgba(255, 255, 255, 0.02);
    transition: color 0.3s ease, border-color 0.3s ease;
    cursor: default;
}

.stack-tags span:hover {
    color: rgba(165, 180, 252, 0.75);
    border-color: rgba(129, 140, 248, 0.2);
}

/* ─── Responsividade ─── */
@media (max-width: 1100px) {
    .stack-grid {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 300px 260px 260px;
    }

    /* .featured ocupa as 2 colunas na linha 1 */
    .stack-card--featured {
        grid-column: 1 / 3;
        grid-row: 1;
    }

    /* .ai ocupa as 2 colunas na linha 3 */
    .stack-card--ai {
        grid-column: 1 / 3;
        grid-row: 3;
    }

    /* cards 2-5 ficam no grid automático entre linhas 2 */
}

@media (max-width: 768px) {
    #habilidades {
        padding: 80px 0 100px;
    }

    .stack-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }

    .stack-card--featured,
    .stack-card--ai {
        grid-column: 1;
        grid-row: auto;
        min-height: 320px;
    }

    .stack-card {
        min-height: 220px;
    }

    .stack-footer-bar {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .stack-card {
        border-radius: 1.5rem;
        min-height: 200px;
    }

    .stack-card__content {
        padding: 20px;
    }
}
