/* =====================================================================
   Painel com motor animado (topo da home) + celular animado (Sistemas)
   Adaptado do protótipo de Lucas Lima (github.com/lucaaslimadev/Site-RPC)
   ===================================================================== */

/* ---------------- TOPO: painel + motor ---------------- */
.hero.hero-painel .wrap { grid-template-columns: minmax(0, 1fr) minmax(0, .9fr); }

/* overlay só no lado do texto, para o painel aparecer inteiro à direita */
.hero.hero-painel::before {
  background:
    linear-gradient(90deg, rgba(8,11,15,.96) 0%, rgba(8,11,15,.88) 30%, rgba(8,11,15,.35) 52%, rgba(8,11,15,0) 66%),
    linear-gradient(0deg, var(--bg) 0%, transparent 22%),
    linear-gradient(180deg, rgba(8,11,15,.7) 0%, transparent 18%);
}
.hero.hero-painel::after { display: none; }

.signature-art { position: absolute; inset: 0; z-index: -2; overflow: hidden; }
.signature-scene {
  position: relative; width: 100%; height: 100%;
  object-fit: cover; object-position: 40% center;
  transform: translateY(var(--hero-shift, 0px)) scale(1.045);
  animation: signature-image-in 1.6s cubic-bezier(.16,1,.3,1) both;
  will-change: transform;
}
.signature-scene > img {
  display: block; width: 100%; height: 100%; max-width: none;
  object-fit: inherit; object-position: inherit;
}

.hero-energy { position: absolute; pointer-events: none; visibility: hidden; max-width: none; overflow: visible; }
.hero-energy.is-aligned { visibility: visible; }
.energy-circuit { stroke-linecap: round; stroke-linejoin: round; mix-blend-mode: screen; }
.energy-pulse {
  --pulse-opacity: 1; opacity: 0;
  stroke-dasharray: 150 850; stroke-dashoffset: 160;
  animation: energy-impulse var(--energy-cycle, 6s) linear var(--energy-phase, 0s) infinite both;
}
.energy-lime { --energy-color: #d1ff70; --energy-core: #f5ffdc; }
.energy-copper { --energy-color: #ffbb61; --energy-core: #fff1c7; }
.energy-bloom { --pulse-opacity: .65; stroke: var(--energy-color); stroke-width: 13; filter: url(#hero-energy-bloom); }
.energy-filament { stroke: var(--energy-core); stroke-width: 3; }
.energy-tip { stroke: #fffef3; stroke-width: 4.5; stroke-dasharray: 3 997; }
.energy-copper .energy-bloom { --pulse-opacity: .7; stroke-width: 12; }
.energy-copper .energy-filament { stroke-width: 3.2; }
.energy-copper .energy-tip { stroke-width: 4.2; }
.energy-route-feed .energy-pulse { animation-name: energy-rise; }
.energy-lime .energy-pulse { animation-name: energy-outgoing; }
.energy-emission { opacity: 0; transform-box: fill-box; transform-origin: center; animation: energy-source 6s linear infinite; }

.hmi-screen text { fill: #e2e4e2; font-family: "JetBrains Mono", Consolas, Arial, sans-serif; font-weight: 400; letter-spacing: 0; }
.hmi-screen .hmi-value { font-size: 20px; fill: #e3f6b5; font-weight: 500; }
.hmi-page { opacity: 0; animation: hmi-cycle 18s linear infinite; }
.hmi-page-electric { animation-delay: -12s; }
.hmi-page-production { animation-delay: -6s; }
.hmi-trend { stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 100; animation: hmi-draw 6s ease-in-out infinite; }

/* pausa quando o topo sai da tela ou a aba fica oculta (economiza CPU) */
.outside-viewport .hero-loop, .tab-inactive .hero-loop,
.outside-viewport .energy-pulse, .tab-inactive .energy-pulse,
.outside-viewport .energy-emission, .tab-inactive .energy-emission,
.outside-viewport .signature-scene { animation-play-state: paused; }

@keyframes signature-image-in { from { opacity: .45; scale: 1.04; } to { opacity: 1; scale: 1; } }
@keyframes energy-impulse { 0% { stroke-dashoffset: 160; opacity: 0; } 2% { opacity: var(--pulse-opacity); } 20% { stroke-dashoffset: -1020; opacity: var(--pulse-opacity); } 22%, 100% { stroke-dashoffset: -1020; opacity: 0; } }
@keyframes energy-rise { 0% { stroke-dashoffset: 160; opacity: 0; } 2% { opacity: var(--pulse-opacity); } 44% { stroke-dashoffset: -1020; opacity: var(--pulse-opacity); } 46%, 100% { stroke-dashoffset: -1020; opacity: 0; } }
@keyframes energy-outgoing { 0% { stroke-dashoffset: 160; opacity: 0; } 2% { opacity: var(--pulse-opacity); } 30% { stroke-dashoffset: -1020; opacity: var(--pulse-opacity); } 32%, 100% { stroke-dashoffset: -1020; opacity: 0; } }
@keyframes energy-source { 0% { opacity: 0; transform: scale(.6); } 3% { opacity: .85; } 15% { opacity: 0; transform: scale(2.5); } 100% { opacity: 0; transform: scale(2.5); } }
@keyframes hmi-cycle { 0%, 30% { opacity: 1; } 33.333%, 97% { opacity: 0; } 100% { opacity: 1; } }
@keyframes hmi-draw { 0% { stroke-dashoffset: 100; } 45%, 92% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: 100; } }

.hero.hero-painel .lead { max-width: 44ch; }

/* tablet/celular: texto em cima, na largura toda, e logo abaixo o painel com o motor (sem texto por cima da foto) */
@media (max-width: 980px) {
  .hero.hero-painel .wrap { grid-template-columns: minmax(0, 1fr); }
  .hero.hero-painel { flex-direction: column; align-items: stretch; justify-content: flex-start; min-height: 0; padding: 104px 0 8px; }
  .hero.hero-painel::before { background: linear-gradient(0deg, var(--bg) 0%, transparent 14%); }
  .hero.hero-painel .hero-chips { margin-top: 26px; }
  .hero.hero-painel .signature-art {
    position: relative; inset: auto; order: 2; z-index: 0;
    width: 100%; height: auto; aspect-ratio: 1.45; max-height: 520px; margin-top: 10px;
    -webkit-mask-image: linear-gradient(to bottom, transparent, #000 9%, #000 88%, transparent);
            mask-image: linear-gradient(to bottom, transparent, #000 9%, #000 88%, transparent);
  }
  .hero.hero-painel .signature-scene { object-position: 88% center; transform: none; }
}
@media (max-width: 560px) {
  .hero.hero-painel { padding-top: 96px; }
  .hero.hero-painel h1 { margin: 16px 0 16px; }
  .hero.hero-painel .lead { margin-bottom: 22px; font-size: 1rem; line-height: 1.55; }
  .hero.hero-painel .hero-chips { margin-top: 18px; gap: 8px; }
  .hero.hero-painel .chip { padding: 6px 10px; font-size: .7rem; }
  .hero.hero-painel .signature-art { aspect-ratio: 1.15; margin-top: 0; }
  .hero.hero-painel .signature-scene { object-position: 92% center; }
  /* botões ocupam a largura toda, sem cortar o texto */
  .hero.hero-painel .btns { display: grid; grid-template-columns: 1fr; gap: 10px; width: 100%; }
  .hero.hero-painel .btns .btn { width: 100%; justify-content: center; white-space: normal; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .signature-scene { transform: none !important; animation: none; will-change: auto; }
  .energy-circuit, .energy-emission { display: none; }
  .hmi-page, .hmi-trend { animation: none !important; }
  .hmi-page { opacity: 0; } .hmi-page-operation { opacity: 1; } .hmi-trend { stroke-dashoffset: 0; }
}

/* ---------------- SISTEMAS: celular animado ---------------- */
/* A aba do celular tem exatamente a altura das outras abas:
   moldura = 8px + 8px de respiro + 2px de borda + 34px da barra + imagem 16:10 da largura interna. */
.screen-pane { container-type: inline-size; }
.phone-demo {
  --ink: #202420; --muted: #606760; --carbon: #080b09; --accent: #b7ff00;
  position: relative; isolation: isolate; box-sizing: border-box;
  height: calc((100cqw - 18px) * .625 + 52px);
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .95fr); grid-template-rows: minmax(0, 1fr); align-items: center; gap: 12px;
  border-radius: 16px; border: 1px solid #394738;
  background: radial-gradient(ellipse at 72% 55%, rgba(183,255,0,.07) 0, transparent 55%), #0b0f13;
  box-shadow: 0 40px 90px -40px rgba(0,0,0,.9);
  overflow: hidden; padding: 28px 24px 28px 40px;
}

.phone-copy { display: flex; flex-direction: column; align-items: flex-start; gap: 16px; min-width: 0; }
.phone-eyebrow { font: 600 .72rem var(--body); letter-spacing: .14em; text-transform: uppercase; color: var(--lime); }
.phone-copy h3 { font-family: var(--display); font-size: clamp(1.6rem, 3.4cqw, 2.3rem); line-height: 1.1; color: var(--text); margin: 0; }
.phone-copy > p { color: var(--text2); font-size: .95rem; line-height: 1.6; margin: 0; max-width: 34ch; }
.phone-copy .phone-tabs { margin-top: 8px; }

/* a área do celular tem a altura da moldura; o aparelho fica solto no centro e é reduzido para caber */
.phone-view { position: relative; height: 100%; min-width: 0; min-height: 0; z-index: 0; }
.phone-view::before, .phone-view::after {
  content: ''; position: absolute; left: 50%; top: 50%; z-index: -1;
  border: 1px solid rgba(164,166,164,.16); border-radius: 50%;
  width: 92%; aspect-ratio: 1; transform: translate(-50%, -50%) rotate(-25deg); pointer-events: none;
}
.phone-view::after { width: 118%; border-style: dashed; border-color: rgba(164,166,164,.10); }

/* tela estreita: a moldura das outras fica baixa demais para o celular; empilha com altura própria */
@container (max-width: 600px) {
  .phone-demo { height: auto; grid-template-columns: 1fr; padding: 24px 18px 8px; gap: 4px; }
  .phone-copy { align-items: center; text-align: center; gap: 12px; }
  .phone-copy > p { display: none; }
  .phone-view { height: 500px; }
}

.phone-tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 12px; background: rgba(255,255,255,.04); border: 1px solid var(--line2); }
.phone-tabs button {
  border: 0; background: none; cursor: pointer; font: 600 .82rem var(--body);
  color: var(--text2); padding: 9px 16px; border-radius: 9px; position: relative; overflow: hidden;
}
.phone-tabs button:hover { color: var(--text); }
.phone-tabs button[aria-selected=true] { color: #0b1400; background: var(--lime); }
/* barrinha de progresso da troca automática */
.phone-tabs button[aria-selected=true]::after {
  content: ''; position: absolute; left: 0; bottom: 0; height: 2px; width: 100%;
  background: rgba(11,20,0,.45); transform-origin: left; transform: scaleX(0);
  animation: phone-progress var(--phone-cycle, 5s) linear forwards;
}
.phone-demo.is-paused .phone-tabs button::after { animation: none; transform: scaleX(0); }
@keyframes phone-progress { to { transform: scaleX(1); } }

/* --s = escala calculada pelo JS para o celular caber na altura da moldura */
.phone-stage { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(var(--s, .8)) rotate(-4deg); transition: transform .5s; z-index: 1; }
.phone-stage:hover { transform: translate(-50%, -50%) scale(var(--s, .8)) rotate(-2deg); }
.phone {
  width: 284px; min-height: 596px; background: #f8faf8; border: 7px solid #222422; border-radius: 42px;
  box-shadow: 25px 30px 65px rgba(0,0,0,.6), 0 0 0 1px #929492; position: relative; overflow: hidden;
  color: var(--ink); font-size: 12px; font-family: var(--body); line-height: 1.4;
}
.phone h3 { color: var(--ink); font-family: var(--body); font-weight: 400; letter-spacing: -.04em; }
.phone p { color: var(--muted); margin: 0; }
.phone-shadow { position: absolute; bottom: -25px; left: -35px; right: -35px; height: 25px; border-radius: 50%; background: rgba(0,0,0,.45); filter: blur(18px); }
.phone-status { display: flex; justify-content: space-between; padding: 12px 19px 8px; font-size: 9px; font-weight: 600; }
.phone-camera { position: absolute; left: 35%; top: 8px; width: 30%; height: 17px; border-radius: 15px; background: #222422; }
.phone-app { padding: 17px 16px 12px; transition: opacity .25s ease, transform .25s ease; }
.phone-app.is-switching { opacity: 0; transform: translateY(6px); }
.phone-app-header { display: flex; align-items: center; justify-content: space-between; padding-bottom: 22px; font-size: 13px; letter-spacing: -.03em; }
.phone-app-header b { font-weight: 600; }
.phone-avatar { background: #e5ebdf; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; font-size: 9px; }
.phone-greeting { font-size: 10px; }
.phone-app h3 { font-size: 21px; margin-top: 5px; }
.phone-period { margin: 17px 0 10px; display: flex; justify-content: space-between; font-size: 9px; }
.phone-period > span { color: #757775; font-size: 8px; }
.phone-stat { background: var(--carbon); color: #fff; padding: 16px; border-radius: 12px; min-height: 137px; }
.phone-stat > span { font-size: 9px; color: #dadcda; display: block; }
.phone-stat strong { font-size: 31px; font-weight: 400; letter-spacing: -.04em; display: block; line-height: 1.2; margin-top: 6px; color: #fff; }
.phone-stat small { font-size: 12px; color: #d2d4d2; letter-spacing: 0; }
.mini-chart { height: 36px; display: flex; align-items: end; gap: 5px; margin-top: 10px; }
.mini-chart i { height: 65%; width: 9px; background: var(--accent); border-radius: 2px 2px 0 0; transform-origin: bottom; animation: bar-grow .6s ease both; }
.mini-chart i:nth-child(2n) { height: 45%; }
.mini-chart i:nth-child(3n) { height: 85%; }
.mini-chart i:nth-child(5n) { height: 100%; }
.mini-chart i:nth-child(n) { animation-delay: calc(var(--i, 0) * 40ms); }
@keyframes bar-grow { from { transform: scaleY(.15); } to { transform: scaleY(1); } }
.phone-metrics { display: flex; gap: 10px; margin-top: 11px; }
.phone-metrics > div { flex: 1; border: 1px solid #dfe1df; border-radius: 9px; padding: 10px; }
.phone-metrics span { display: block; font-size: 8px; color: var(--muted); }
.phone-metrics strong { font-weight: 500; display: block; font-size: 17px; margin-top: 3px; color: var(--ink); }
.phone-section-title { font-size: 10px; font-weight: 500; margin: 20px 0 7px; }
.phone-event { display: flex; align-items: center; width: 100%; gap: 8px; padding: 10px 0; border: 0; border-bottom: 1px solid #e4e6e4; background: none; text-align: left; color: var(--ink); font: inherit; cursor: pointer; }
.phone-event > span { font-size: 10px; flex: 1; line-height: 1.4; }
.phone-event small { display: block; color: var(--muted); font-size: 8px; margin-top: 3px; }
.phone-event > b { font-size: 11px; font-weight: 400; transition: transform .2s; }
.phone-event[aria-expanded=true] > b { transform: rotate(180deg); }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: #7cbf2a; flex: 0 0 auto; }
.status-dot.amber { background: #c69539; }
.event-detail { font-size: 9px; padding: 8px 0; }
.phone-bottom-nav { display: flex; justify-content: space-between; border-top: 1px solid #dfe1df; margin-top: 12px; padding-top: 12px; font-size: 8px; color: #868886; }
.phone-bottom-nav .selected { color: var(--ink); font-weight: 600; }
.phone-home { height: 3px; width: 30%; background: #2c2e2c; border-radius: 5px; margin: 7px auto 9px; }
.phone-note { font: 500 .72rem var(--mono); letter-spacing: .06em; color: #6b7782; margin: 0; }

@media (prefers-reduced-motion: reduce) {
  .phone-stage, .phone-stage:hover { transform: translate(-50%, -50%) scale(var(--s, .8)); }
  .phone-app, .mini-chart i { transition: none; animation: none; }
  .phone-tabs button::after { animation: none !important; }
}
