/* 04-projeto-personalizado · H04 · merge.
   Composição e texto: .custom-scenario da V1 (texto à esquerda, palco à direita).
   Palco: moldura de .method-preview da V1; dentro, o gráfico pedido na revisão (REV-09), adaptado do
   site antigo da cliente: Diagnósticos, Propostas e Vendas, a parte "antes" em cinza e o ganho em
   laranja crescendo dentro da meta tracejada, a linha de tendência e o medidor circular.
   Sem números (decisão do dono): traços no lugar dos valores.
   O estado de repouso das regras é o estado final; as animações (loop de 8 s) partem dele e só rodam
   em cena ([data-loop]); com movimento reduzido fica o gráfico completo, parado.
   Título: cada linha numa linha só, com o corpo medido pela largura da coluna (cqi). */

#h04.custom-scenario {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(20rem, 0.92fr);
  align-items: center;
  gap: clamp(3rem, 5.5vw, 7rem);
  min-height: 100svh;
  padding: clamp(6rem, 11vw, 10rem) max(1.5rem, calc((100vw - 75.5rem) / 2));
  background: var(--black);
  color: var(--white);
}

#h04 .custom-scenario__copy {
  max-width: 45rem;
  container-type: inline-size;
  transform: translateX(clamp(1.5rem, 3vw, 3rem));
}

#h04 .custom-scenario__eyebrow {
  margin: 0 0 clamp(1.5rem, 2.25vw, 2.25rem);
  color: var(--orange-editorial);
  font-family: var(--font-serif);
  font-size: max(0.875rem, min(1rem, 1.03vw));
  font-variation-settings: "wght" 400;
  font-weight: 400;
  letter-spacing: 0.08em;
  line-height: 1.2;
}

#h04 h2 {
  margin: 0;
  color: rgb(248 248 246 / 72%);
  /* "Personalizamos o projeto" mede ~11.3 em: o corpo acompanha a coluna e a linha nunca quebra */
  font-size: min(3.75rem, 8.6cqi);
  font-weight: 350;
  letter-spacing: -0.045em;
  line-height: 1.02;
}

#h04 h2 span { display: block; white-space: nowrap; }

#h04 h2 span:first-child {
  color: var(--white);
  font-family: var(--font-serif);
  font-variation-settings: "wght" 400;
  font-weight: 400;
}

/* texto: a frase de abertura como lide (branca, maior, medida curta) e o complemento em cinza,
   com medida de leitura; text-wrap: pretty evita palavra sozinha na última linha */
#h04 .custom-scenario__description {
  max-width: 34rem;
  margin: clamp(2rem, 3vw, 2.75rem) 0 0;
  color: rgb(248 248 246 / 62%);
  font-size: clamp(1rem, 1.05vw, 1.0625rem);
  letter-spacing: 0;
  line-height: 1.6;
}

#h04 .custom-scenario__description span { display: block; text-wrap: pretty; }
#h04 .custom-scenario__description-lead {
  max-width: 30rem;
  margin-bottom: 1.1rem;
  padding-left: 1rem;
  border-left: 2px solid var(--orange);
  color: var(--white);
  font-size: clamp(1.15rem, 1.35vw, 1.3rem);
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1.4;
}

/* ——— Palco (moldura de .method-preview da V1) ——— */
#h04 {
  --h04-fio: var(--line-dark);
  --h04-tinta: color-mix(in srgb, var(--white) 44%, transparent);
  --h04-tinta-fraca: color-mix(in srgb, var(--white) 16%, transparent);
  --h04-fundo: #0f0f0f;
}

#h04 .h04-palco {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 5 / 4;
  padding: clamp(1.75rem, 3.6vw, 3.25rem);
  overflow: hidden;
  border: 0.5rem solid var(--surface-dark);
  border-radius: clamp(1.1rem, 1.4vw, 1.45rem);
  background:
    radial-gradient(circle at 1px 1px, rgb(248 248 246 / 8%) 1px, transparent 1.5px) 0 0 / 18px 18px,
    radial-gradient(60% 55% at 50% 50%, rgb(255 255 255 / 4%), transparent 72%),
    var(--h04-fundo);
  box-shadow: 0 0 0 1px rgb(255 255 255 / 23%), 0 2rem 4rem -1.5rem rgb(0 0 0 / 70%);
  isolation: isolate;
}

/* o gráfico ocupa o palco: plot em cima, eixo com os rótulos embaixo */
#h04 .h04-grafico {
  --h04-ciclo: 8s;
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  align-self: stretch;
  justify-self: stretch;
  min-width: 0;
}

/* plot: três faixas iguais (centros em 1/6, 3/6 e 5/6, os mesmos da tendência), linhas de grade discretas */
#h04 .h04-plot {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  border-bottom: 1px solid rgb(248 248 246 / 22%);
  background: repeating-linear-gradient(to top, transparent 0 calc(25% - 1px), rgb(248 248 246 / 6%) calc(25% - 1px) 25%);
}

#h04 .h04-coluna { position: relative; height: 100%; }
#h04 .h04-coluna > span {
  position: absolute;
  left: 50%;
  width: 54%;
  transform: translateX(-50%);
}

/* a meta: o contorno tracejado até onde a coluna chega */
#h04 .h04-meta {
  bottom: 0;
  height: calc((var(--antes) + var(--ganho)) * 1%);
  border: 1px dashed rgb(248 248 246 / 26%);
  border-bottom: 0;
  border-radius: clamp(0.4rem, 0.9vw, 0.6rem) clamp(0.4rem, 0.9vw, 0.6rem) 0 0;
  background: rgb(248 248 246 / 3%);
}
/* no lugar do valor, um traço */
#h04 .h04-valor {
  position: absolute;
  top: clamp(0.65rem, 1.6vw, 1rem);
  left: 50%;
  width: 38%;
  height: 4px;
  border-radius: var(--radius-pill);
  background: rgb(248 248 246 / 55%);
  transform: translateX(-50%);
  animation: h04-valor var(--h04-ciclo) var(--ease-out) calc(var(--o) * 0.22s) infinite both;
}

/* antes: cinza que esmaece para a base */
#h04 .h04-antes {
  bottom: 0;
  height: calc(var(--antes) * 1%);
  border-radius: 2px 2px 0 0;
  background: linear-gradient(180deg, rgb(248 248 246 / 30%), rgb(248 248 246 / 7%));
}

/* o ganho: laranja que cresce a partir do topo do "antes" */
#h04 .h04-ganho {
  bottom: calc(var(--antes) * 1%);
  height: calc(var(--ganho) * 1%);
  border-radius: clamp(0.4rem, 0.9vw, 0.6rem) clamp(0.4rem, 0.9vw, 0.6rem) 2px 2px;
  background: linear-gradient(180deg, var(--orange), rgb(255 108 17 / 45%));
  box-shadow: 0 -0.5rem 1.6rem -0.4rem rgb(255 108 17 / 45%);
  transform-origin: 50% 100%;
  animation: h04-cresce var(--h04-ciclo) cubic-bezier(0.45, 0, 0.2, 1) calc(var(--o) * 0.22s) infinite both;
}

@keyframes h04-cresce {
  0%, 8% { transform: translateX(-50%) scaleY(0); }
  40%, 84% { transform: translateX(-50%) scaleY(1); }
  95%, 100% { transform: translateX(-50%) scaleY(0); }
}
@keyframes h04-valor {
  0%, 22% { opacity: 0; }
  34%, 84% { opacity: 1; }
  92%, 100% { opacity: 0; }
}

/* tendência: tracejado claro que se desenha da esquerda para a direita depois das barras */
#h04 .h04-tendencia {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  animation: h04-traca var(--h04-ciclo) ease-in-out infinite both;
}
#h04 .h04-tendencia polyline {
  fill: none;
  stroke: rgb(248 248 246 / 62%);
  stroke-width: 1.25;
  stroke-dasharray: 5 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
@keyframes h04-traca {
  0%, 30% { clip-path: inset(-10% 100% -10% 0); opacity: 1; }
  56%, 84% { clip-path: inset(-10% 0 -10% 0); opacity: 1; }
  94%, 100% { clip-path: inset(-10% 0 -10% 0); opacity: 0; }
}

/* marcos da tendência no topo de cada meta; o último pulsa */
#h04 .h04-marco {
  position: absolute;
  left: calc(var(--x) / 6 * 100%);
  bottom: calc(var(--y) * 1%);
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 0 0 3px var(--h04-fundo);
  transform: translate(-50%, 50%);
  animation: h04-marco var(--h04-ciclo) var(--ease-out) calc(1.6s + var(--o) * 0.55s) infinite both;
}
#h04 .h04-marco--fim { background: var(--orange); box-shadow: 0 0 0 3px var(--h04-fundo), 0 0 0.8rem rgb(255 108 17 / 80%); }
@keyframes h04-marco {
  0%, 4% { transform: translate(-50%, 50%) scale(0); }
  12%, 58% { transform: translate(-50%, 50%) scale(1); }
  64%, 100% { transform: translate(-50%, 50%) scale(0); }
}

/* medidor: anel que se carrega em laranja, sem número; ao lado, traços no lugar do texto */
#h04 .h04-medidor {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem 0.6rem 0.6rem;
  border: 1px solid rgb(255 255 255 / 12%);
  border-radius: clamp(0.6rem, 1vw, 0.8rem);
  background: linear-gradient(160deg, rgb(255 255 255 / 6%), rgb(255 255 255 / 1%)), var(--surface-dark);
  box-shadow: 0 16px 32px -20px rgb(0 0 0 / 90%), inset 0 1px 0 rgb(255 255 255 / 6%);
}
#h04 .h04-anel { position: relative; display: grid; place-items: center; width: clamp(2.4rem, 3.6vw, 3rem); aspect-ratio: 1; }
#h04 .h04-anel svg { width: 100%; height: 100%; transform: rotate(-90deg); }
#h04 .h04-anel circle { fill: none; stroke-width: 3.5; }
#h04 .h04-anel__trilho { stroke: rgb(248 248 246 / 12%); }
#h04 .h04-anel__carga {
  stroke: var(--orange);
  stroke-linecap: round;
  stroke-dasharray: 100;
  stroke-dashoffset: 24;
  animation: h04-carga var(--h04-ciclo) var(--ease-out) infinite both;
}
#h04 .h04-anel .h04-anel__seta {
  position: absolute;
  width: 38%;
  height: 38%;
  transform: none;
  fill: none;
  stroke: var(--white);
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
@keyframes h04-carga {
  0%, 26% { stroke-dashoffset: 100; opacity: 0; }
  30% { opacity: 1; }
  62%, 84% { stroke-dashoffset: 24; opacity: 1; }
  86% { opacity: 1; }
  92%, 100% { stroke-dashoffset: 100; opacity: 0; }
}
#h04 .h04-medidor__linhas { display: grid; gap: 0.4rem; width: clamp(3.5rem, 6vw, 5rem); }
#h04 .h04-medidor__linhas b { display: block; width: 100%; height: 5px; border-radius: var(--radius-pill); background: var(--h04-tinta); }
#h04 .h04-medidor__linhas b.fraco { width: 64%; height: 4px; background: var(--h04-tinta-fraca); }

/* eixo: os três rótulos, centrados sob as colunas */
#h04 .h04-eixo {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  padding-top: clamp(0.7rem, 1.2vw, 0.95rem);
}
#h04 .h04-eixo span {
  overflow: hidden;
  color: rgb(248 248 246 / 58%);
  font-size: clamp(0.6rem, 0.78vw, 0.72rem);
  font-weight: 500;
  letter-spacing: 0.1em;
  line-height: 1.2;
  text-align: center;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}
#h04 .h04-eixo span:last-child { color: var(--orange-editorial); }

@media (prefers-reduced-motion: reduce) {
  #h04 .h04-palco * { animation: none !important; }
}

@media (max-width: 900px) {
  #h04.custom-scenario {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    min-height: 0;
    padding-block: clamp(5rem, 11vw, 7.5rem);
  }

  #h04 .custom-scenario__copy {
    max-width: 42rem;
    transform: none;
  }

  #h04 .custom-scenario__showcase { width: min(100%, 36rem); margin-top: 1.5rem; }
}

@media (max-width: 560px) {
  #h04.custom-scenario {
    padding-right: 1.25rem;
    padding-left: 1.25rem;
  }

  #h04 .custom-scenario__eyebrow { font-size: 0.93rem; }
  #h04 .custom-scenario__description { margin-top: 1.75rem; font-size: 0.975rem; }
  #h04 .custom-scenario__description-lead { padding-left: 0.85rem; font-size: 1.0625rem; letter-spacing: 0; }
  #h04 .h04-palco { padding: 1.25rem; border-width: 0.4rem; aspect-ratio: 1 / 1; }
  #h04 .h04-medidor { gap: 0.55rem; padding: 0.45rem 0.65rem 0.45rem 0.45rem; }
  #h04 .h04-medidor__linhas { width: 2.75rem; gap: 0.3rem; }
  #h04 .h04-medidor__linhas b { height: 4px; }
  #h04 .h04-medidor__linhas b.fraco { height: 3px; }
  #h04 .h04-coluna > span { width: 58%; }
  #h04 .h04-eixo span { letter-spacing: 0.06em; }
}
