/* ===================================================================
   SEÇÃO "SUA CONQUISTA COMEÇA COM UM PLANO" (experiência 3D da home)
   Tudo aqui é prefixado por .x3d, e sai junto com inc/experiencia-3d.php.

   Três modos, decididos pelo controlador (experiencia.js):
   - sem JS: as seis etapas empilhadas, legíveis, com o botão no fim;
   - .x3d--js: uma etapa por vez, com Voltar/Avançar;
   - .x3d--rolagem (desktop, sem movimento reduzido): o palco fica preso na
     tela enquanto o trilho rola, e a rolagem troca as etapas.
   =================================================================== */

.x3d {
    --x3d-topo: 78px;
    --x3d-linha: rgba(201, 162, 74, 0.22);
    position: relative;
    padding: 3.2rem 0 2.4rem;
    color: var(--on-dark);
    background:
        radial-gradient(900px 480px at 18% 8%, rgba(27, 64, 95, 0.75), transparent 70%),
        linear-gradient(180deg, var(--navy-800), var(--navy-900));
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.x3d :focus-visible {
    outline: 3px solid var(--gold-2);
    outline-offset: 3px;
}

/* "Pular explicação" para aqui: a margem desconta o cabeçalho fixo do site */
#depois-da-conquista {
    scroll-margin-top: 96px;
    outline: none;
}

/* ---- Cabeçalho ---- */
.x3d__cabecalho {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1.6rem;
}

.x3d .eyebrow { color: var(--gold-2); margin-bottom: 0.6rem; }

.x3d h2 {
    margin: 0 0 0.5rem;
    color: #fff;
    font-size: clamp(1.9rem, 3.6vw, 2.8rem);
    line-height: 1.1;
}

.x3d__intro {
    margin: 0;
    max-width: 56ch;
    color: var(--on-dark-muted);
}

.x3d__pular {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 44px;
    padding: 0.5rem 1rem;
    border: 1px solid rgba(233, 240, 248, 0.24);
    border-radius: 999px;
    color: var(--on-dark);
    font-size: 0.92rem;
    font-weight: 600;
    transition: border-color 0.2s ease, color 0.2s ease;
}

.x3d__pular:hover { border-color: var(--accent); color: var(--gold-2); }

/* ---- Palco: a cena ocupa a largura toda, e o painel flutua sobre ela ---- */
.x3d__palco {
    position: relative;
    width: min(calc(100% - 2rem), 1320px);
    margin: 0 auto;
}

.x3d__cena {
    position: relative;
    height: 680px;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--x3d-linha);
    background:
        radial-gradient(70% 60% at 50% 42%, rgba(46, 86, 122, 0.55), transparent 72%),
        linear-gradient(180deg, #0d2741, #081a2e);
    box-shadow: 0 30px 60px rgba(2, 8, 18, 0.45);
}

.x3d__cena canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    opacity: 0;
    transition: opacity 0.6s ease;
}

.x3d--3d .x3d__cena canvas { opacity: 1; }
.x3d--3d .x3d__estatica { opacity: 0; visibility: hidden; }

/* Balão de fala do Júlio: a cena o posiciona sobre a cabeça do avatar */
.x3d__fala {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 2;
    width: max-content;
    max-width: min(380px, 48%);
    padding: 0.8rem 1.05rem 0.9rem;
    border-radius: 18px;
    background: #fdfbf6;
    color: var(--navy-900);
    box-shadow: 0 14px 30px rgba(2, 8, 18, 0.35);
    pointer-events: none;
    will-change: transform;
}

.x3d__fala[hidden] { display: none; }

.x3d__fala::after {
    content: "";
    position: absolute;
    left: var(--x3d-fala-seta, 50%);
    bottom: -9px;
    width: 18px;
    height: 18px;
    background: #fdfbf6;
    transform: translateX(-50%) rotate(45deg);
    border-radius: 3px;
}

.x3d__fala::before {
    content: "Júlio · consultor Embracon";
    display: block;
    margin-bottom: 0.3rem;
    color: var(--accent-dark);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* balão ao lado do rosto: a seta aponta para ele */
.x3d__fala--esq::after,
.x3d__fala--dir::after {
    top: var(--x3d-fala-seta-y, 50%);
    bottom: auto;
    transform: translateY(-50%) rotate(45deg);
}

.x3d__fala--esq::after { left: auto; right: -9px; }
.x3d__fala--dir::after { left: -9px; }

.x3d__fala p {
    position: relative;
    margin: 0;
    font-size: clamp(0.95rem, 0.86rem + 0.25vw, 1.1rem);
    line-height: 1.45;
    font-weight: 500;
}

.x3d__fala--digitando p::after {
    content: "";
    display: inline-block;
    width: 2px;
    height: 1em;
    margin-left: 2px;
    vertical-align: -0.15em;
    background: var(--accent-dark);
    animation: x3d-cursor 0.8s steps(1) infinite;
}

@keyframes x3d-cursor { 50% { opacity: 0; } }

/* Legenda da contemplação: o número da Loteria Federal, ou a regra do lance */
.x3d__legenda {
    position: absolute;
    left: 1rem;
    top: 1rem;
    z-index: 2;
    display: grid;
    gap: 0.35rem;
    max-width: min(460px, 62%);
    padding: 1rem 1.3rem 1.1rem;
    border-radius: 14px;
    border: 1px solid var(--line-gold);
    background: rgba(7, 20, 37, 0.84);
    pointer-events: none;
    animation: x3d-entra 0.35s ease both;
}

.x3d__legenda[hidden] { display: none; }

.x3d__legenda-rotulo {
    color: var(--gold-2);
    font-size: clamp(0.85rem, 0.75rem + 0.3vw, 1.02rem);
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.x3d__legenda-numero {
    color: #fff;
    font-size: clamp(2rem, 1.6rem + 1vw, 2.7rem);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: 0.12em;
    font-variant-numeric: tabular-nums;
}

.x3d__legenda-numero:empty { display: none; }
.x3d__legenda-numero b { color: var(--gold-2); }

.x3d__legenda-detalhe {
    color: #fff;
    font-size: clamp(1.05rem, 0.9rem + 0.45vw, 1.3rem);
    font-weight: 500;
    line-height: 1.4;
}

/* Ilustração estática: a cena enquanto o 3D não chega, e no lugar dele sem WebGL */
.x3d__estatica {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    transition: opacity 0.4s ease;
}

.x3d__estatica-figura {
    display: none;
    width: min(62%, 300px);
    aspect-ratio: 1;
    place-items: center;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(201, 162, 74, 0.14), transparent 68%);
    color: var(--gold-2);
}

.x3d:not(.x3d--js) .x3d__estatica-figura[data-figura="0"],
.x3d[data-etapa-atual="0"] .x3d__estatica-figura[data-figura="0"],
.x3d[data-etapa-atual="1"] .x3d__estatica-figura[data-figura="1"],
.x3d[data-etapa-atual="2"] .x3d__estatica-figura[data-figura="2"],
.x3d[data-etapa-atual="3"] .x3d__estatica-figura[data-figura="3"],
.x3d[data-etapa-atual="4"] .x3d__estatica-figura[data-figura="4"],
.x3d[data-etapa-atual="5"] .x3d__estatica-figura[data-figura="5"] {
    display: grid;
}

.x3d__estatica-bem { width: 62%; }
.x3d__estatica-figura--julio { background: none; border-radius: 0; }
.x3d__estatica-figura--julio img { height: 100%; width: auto; }
.x3d__estatica-bem[hidden] { display: none; }
.x3d__estatica-figura svg { width: 100%; height: auto; }

.x3d-svg__cota { fill: #2b5277; stroke: rgba(230, 200, 120, 0.5); stroke-width: 1.5; }
.x3d-svg__cota--destaque { fill: var(--gold-2); }
.x3d-svg__fundo { fill: rgba(201, 162, 74, 0.25); stroke: var(--accent); stroke-width: 2; }
.x3d-svg__fluxo { stroke: rgba(230, 200, 120, 0.35); stroke-width: 1.5; stroke-dasharray: 3 5; }
.x3d-svg__carta { fill: #11304f; stroke: var(--accent); stroke-width: 2; }
.x3d-svg__chip { fill: var(--gold-2); }
.x3d-svg__linha { stroke: rgba(233, 240, 248, 0.45); stroke-width: 4; stroke-linecap: round; }

/* ---- Painel, sobre a cena, à direita ---- */
.x3d__painel {
    position: absolute;
    top: 1rem;
    right: 1rem;
    bottom: 1rem;
    width: min(440px, 36%);
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    min-width: 0;
    padding: 1rem;
    border-radius: 20px;
    border: 1px solid var(--x3d-linha);
    background: rgba(7, 20, 37, 0.78);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    box-shadow: 0 20px 40px rgba(2, 8, 18, 0.35);
}

/* No painel flutuante, a etapa é lida pelo título: os passos ficam só com o número */
.x3d__painel .x3d__passo-nome { display: none; }
.x3d__painel .x3d__passo { align-items: center; }

.x3d__progresso {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.35rem;
}

.x3d__passo {
    width: 100%;
    min-height: 44px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    padding: 0.45rem 0.4rem;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--on-dark-muted);
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.x3d__passo:hover { background: rgba(255, 255, 255, 0.05); color: var(--on-dark); }

.x3d__passo-num {
    display: inline-grid;
    place-items: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    border: 1px solid rgba(233, 240, 248, 0.28);
    font-size: 0.8rem;
    font-weight: 700;
}

.x3d__passo-nome {
    font-size: 0.72rem;
    line-height: 1.25;
}

.x3d__passo.is-feito .x3d__passo-num { border-color: var(--accent); color: var(--gold-2); }

.x3d__passo[aria-current="step"] { color: #fff; }
.x3d__passo[aria-current="step"] .x3d__passo-num {
    background: var(--accent);
    border-color: var(--accent);
    color: #241a04;
}

.x3d__barra {
    height: 3px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.x3d__barra span {
    display: block;
    height: 100%;
    width: 20%;
    background: linear-gradient(90deg, var(--accent), var(--gold-2));
    transform-origin: left;
    transition: width 0.35s ease;
}

.x3d:not(.x3d--js) .x3d__progresso,
.x3d:not(.x3d--js) .x3d__barra,
.x3d:not(.x3d--js) .x3d__nav,
.x3d:not(.x3d--js) .x3d__reiniciar {
    display: none;
}

.x3d__etapas {
    flex: 1;
    min-height: 0;
    overflow: auto;
    display: grid;
    gap: 1rem;
    align-content: start;
}

.x3d__etapa {
    padding: 0.2rem 0.3rem 0.4rem;
}

.x3d__comecar { width: 100%; margin-top: 0.4rem; }

.x3d--js .x3d__etapa { animation: x3d-entra 0.45s ease both; }
.x3d__etapa[hidden] { display: none; }

@keyframes x3d-entra {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

.x3d__etapa-num {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--gold-2);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.x3d h3 {
    margin: 0 0 0.6rem;
    color: #fff;
    font-size: clamp(1.45rem, 1.1rem + 0.8vw, 1.85rem);
    line-height: 1.2;
}

.x3d__etapa p {
    margin: 0 0 0.8rem;
    color: #e3ebf4;
    font-size: clamp(1.02rem, 0.92rem + 0.3vw, 1.18rem);
    line-height: 1.55;
}

.x3d__etapa p:last-child { margin-bottom: 0; }
.x3d__etapa strong { color: #fff; }

.x3d .x3d__nota {
    color: var(--on-dark-muted);
    font-size: 0.95rem;
}

.x3d .x3d__nota--separada { margin-top: 0.9rem; }

/* frase de reforço no painel: borda dourada à esquerda */
.x3d .x3d__destaque {
    margin-top: 0.4rem;
    padding: 0.75rem 0.9rem;
    border-left: 3px solid var(--accent);
    border-radius: 0 12px 12px 0;
    background: rgba(201, 162, 74, 0.1);
}

.x3d .x3d__destaque strong { color: var(--gold-2); }

.x3d__fala strong { font-weight: 700; color: var(--navy-700); }

.x3d__nota[hidden],
.x3d__caminho[hidden] { display: none; }

.x3d__opcoes {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.55rem;
    margin: 0.9rem 0;
}

.x3d__opcoes--dois { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.x3d__opcao {
    min-height: 48px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.7rem 0.5rem;
    border: 1px solid rgba(233, 240, 248, 0.2);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--on-dark);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.x3d__opcao svg { width: 1.9rem; height: 1.9rem; }

.x3d__opcao:hover { border-color: rgba(230, 200, 120, 0.6); transform: translateY(-1px); }

.x3d__opcao[aria-pressed="true"] {
    border-color: var(--accent);
    background: rgba(201, 162, 74, 0.16);
    color: var(--gold-2);
}

.x3d__caminho { margin-top: 0.2rem; }

/* As quatro formas de contemplação: 2 x 2, e a barra que corre no botão ativo
   enquanto a troca automática estiver ligada */
.x3d__opcoes--quatro { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.x3d__forma {
    position: relative;
    overflow: hidden;
    font-size: 1rem;
    min-height: 52px;
}

.x3d--auto .x3d__forma[aria-pressed="true"]::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 3px;
    background: var(--gold-2);
    transform-origin: left;
    animation: x3d-auto var(--x3d-auto, 7s) linear forwards;
}

@keyframes x3d-auto {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

.x3d--js .x3d__caminho:not([hidden]) { animation: x3d-entra 0.35s ease both; }

.x3d__objetivo-final {
    font-size: 1.05rem;
}

.x3d__objetivo-final strong { color: var(--gold-2); }

.x3d__cta {
    width: 100%;
    margin-top: 0.4rem;
}

.x3d__reiniciar {
    display: block;
    min-height: 44px;
    margin: 0.4rem auto 0;
    padding: 0.4rem 0.8rem;
    border: 0;
    background: transparent;
    color: var(--on-dark-muted);
    font: inherit;
    font-size: 0.9rem;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
}

.x3d__reiniciar:hover { color: var(--gold-2); }

.x3d__nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}

.x3d__nav-botao {
    min-height: 46px;
    min-width: 7.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.1rem;
    border: 1px solid rgba(233, 240, 248, 0.26);
    border-radius: 999px;
    background: transparent;
    color: var(--on-dark);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}

.x3d__nav-botao:hover:not(:disabled) { border-color: var(--accent); color: var(--gold-2); }

.x3d__nav-botao--avancar {
    border-color: transparent;
    background: linear-gradient(135deg, var(--gold-2), var(--accent));
    color: #241a04;
}

.x3d__nav-botao--avancar:hover:not(:disabled) { color: #241a04; background: linear-gradient(135deg, var(--accent), var(--accent-dark)); }

.x3d__nav-botao:disabled { opacity: 0.35; cursor: default; }

.x3d__nav-status {
    color: var(--on-dark-muted);
    font-size: 0.85rem;
    text-align: center;
}

/* Crédito dos modelos 3D, que a licença CC BY exige */
.x3d__creditos {
    margin-top: 0.6rem;
    color: rgba(159, 178, 198, 0.75);
    font-size: 0.72rem;
    line-height: 1.5;
}

/* recolhido: só a palavra "Créditos", e o texto abre ao clicar */
.x3d__creditos summary {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    cursor: pointer;
    list-style: none;
}

.x3d__creditos summary::-webkit-details-marker { display: none; }

.x3d__creditos summary:hover { color: var(--gold-2); }

.x3d__creditos p { margin: 0; }

.x3d__creditos a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.x3d__creditos a:hover { color: var(--gold-2); }

/* ---- Modo rolagem (desktop) ---- */
.x3d--rolagem .x3d__trilho {
    /* uma tela por etapa, sem prender ninguém: a rolagem segue normal */
    height: calc(6 * 72vh + 100vh - var(--x3d-topo));
}

.x3d--rolagem .x3d__palco {
    position: sticky;
    top: calc(var(--x3d-topo) + 1rem);
    height: calc(100vh - var(--x3d-topo) - 2rem);
    min-height: 560px;
}

.x3d--rolagem .x3d__cena { height: 100%; }

/* ---- Celular e tablet: cena em cima, painel embaixo, tudo por botão ---- */
@media (max-width: 1024px) {
    .x3d__cabecalho {
        flex-direction: column;
        align-items: flex-start;
    }

    .x3d__cena {
        height: clamp(340px, 62vh, 620px);
    }

    /* o painel deixa de flutuar e vem para baixo da cena */
    .x3d__painel {
        position: static;
        width: auto;
        margin-top: 1rem;
        padding: 1rem 0.9rem;
        background: rgba(7, 20, 37, 0.6);
    }

    .x3d__etapas { overflow: visible; }
}

@media (max-width: 480px) {
    .x3d { padding-top: 2.4rem; }

    .x3d__passo-nome { display: none; }

    .x3d__passo { align-items: center; }


    .x3d h3 { font-size: 1.28rem; }

    .x3d__nav-botao { min-width: 6.4rem; padding: 0.6rem 0.9rem; }

    /* largo, o balão cabe acima da cabeça e não cobre o bem ao lado */
    .x3d__fala { max-width: calc(100% - 20px); }
}

@media (prefers-reduced-motion: reduce) {
    .x3d--js .x3d__etapa { animation: none; }
    .x3d--js .x3d__caminho:not([hidden]),
    .x3d__legenda,
    .x3d--auto .x3d__forma[aria-pressed="true"]::after,
    .x3d__fala--digitando p::after { animation: none; }
    .x3d__barra span,
    .x3d__cena canvas,
    .x3d__estatica { transition: none; }
}
