/* Jarvin — tela de carregamento
   Paleta monocromática. Nenhuma dependência. Nenhuma biblioteca de animação. */

:root {
  --jv-bg:      #0A0B0D;  /* fundo, preto de oficina  */
  --jv-surface: #14161A;  /* superfície elevada       */
  --jv-line:    #262A30;  /* grade e bordas, gunmetal */
  --jv-graphite:#6E747C;  /* segundo tom, em processo */
  --jv-steel:   #8E949B;  /* texto de apoio           */
  --jv-white:   #E8EAED;  /* acento, instrumento      */
  --jv-text:    #F4F5F7;  /* texto principal          */
}

/* ---------- raiz ---------- */
#jv-loader {
  position: fixed; inset: 0; z-index: 9999; overflow: hidden;
  pointer-events: none;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
  color: var(--jv-text);
}
#jv-loader[hidden] { display: none; }

/* ---------- cortina: duas metades ---------- */
.jv-panel {
  position: absolute; left: 0; right: 0; height: 50.2%;
  background: var(--jv-bg); overflow: hidden;
  transition: transform 900ms cubic-bezier(.76, 0, .24, 1);
}
.jv-panel--top { top: 0 }
.jv-panel--bottom { bottom: 0 }
#jv-loader.is-exiting .jv-panel--top    { transform: translateY(-101%) }
#jv-loader.is-exiting .jv-panel--bottom { transform: translateY(101%) }

/* o fundo de cada metade é o MESMO desenho em coordenadas de viewport:
   a caixa interna mede 100vh e é ancorada no topo / na base, então as duas
   metades batem pixel a pixel e não existe emenda no meio. */
.jv-bg { position: absolute; left: 0; right: 0; height: 100vh; overflow: hidden }
.jv-panel--top .jv-bg { top: 0 }
.jv-panel--bottom .jv-bg { bottom: 0 }

.jv-halo { position: absolute; border-radius: 50%; }
.jv-halo--a {
  top: -22vh; left: -16vw; width: 66vw; height: 66vw;
  background: var(--jv-white); filter: blur(110px); opacity: .12;
  animation: jvHaloA 11s ease-in-out infinite;
}
.jv-halo--b {
  bottom: -26vh; right: -18vw; width: 62vw; height: 62vw;
  background: var(--jv-steel); filter: blur(130px); opacity: .10;
  animation: jvHaloB 9s ease-in-out infinite;
}
.jv-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--jv-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--jv-line) 1px, transparent 1px);
  background-size: 64px 64px;
  animation: jvGrid 24s linear infinite;
  -webkit-mask-image: radial-gradient(ellipse 68% 62% at 50% 48%, #000 28%, transparent 100%);
          mask-image: radial-gradient(ellipse 68% 62% at 50% 48%, #000 28%, transparent 100%);
}
.jv-scan {
  position: absolute; left: 0; right: 0; top: 0; height: 2px; opacity: .5;
  background: linear-gradient(90deg, transparent, var(--jv-white), transparent);
  animation: jvScan 6s linear infinite;
}

/* ---------- conteúdo ---------- */
.jv-content {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  /* row fica no topo; o middle centraliza no espaço restante (margin auto) */
  justify-content: flex-start;
  padding: clamp(22px, 3.4vw, 48px) clamp(20px, 4vw, 56px);
  transition: opacity 220ms linear;
}
/* o conteúdo sai ANTES da cortina abrir, senão a fenda corta o texto */
#jv-loader.is-fading .jv-content { opacity: 0 }

.jv-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px }
.jv-mark { display: flex; align-items: center; gap: 12px }
.jv-mono { font-family: "JetBrains Mono", ui-monospace, monospace; letter-spacing: .24em; font-size: 11px; color: var(--jv-steel) }
.jv-status { font-family: "JetBrains Mono", ui-monospace, monospace; letter-spacing: .24em; font-size: 11px; color: var(--jv-white); animation: jvPulse 2.6s ease-in-out infinite }

/* o bloco principal centraliza verticalmente (row acima, foot abaixo).
   jv-brain (fase 1) e jv-reveal (fase 2) ocupam a MESMA célula de grid —
   truque de empilhamento que permite o crossfade sem salto de layout, já
   que nenhum dos dois precisa saber a altura do outro. */
.jv-middle {
  display: grid; grid-template-columns: minmax(0, 1fr);
  margin: auto 0; width: 100%; max-width: 76rem; margin-left: auto; margin-right: auto;
}
.jv-brain, .jv-reveal {
  grid-column: 1; grid-row: 1;
  display: flex; flex-direction: column; gap: clamp(16px, 2.4vw, 32px);
  transition: opacity 700ms cubic-bezier(.22,1,.36,1), filter 700ms cubic-bezier(.22,1,.36,1), transform 700ms cubic-bezier(.22,1,.36,1);
}

/* ---------- fase 1: cérebro ligando + terminal de boot ---------- */
.jv-brain { opacity: 1; filter: blur(0); transform: scale(1); }

/* empilhado em telas estreitas; lado a lado a partir de 880px, cérebro
   e terminal com o mesmo peso visual — nenhum dos dois é acessório */
.jv-brain-stage {
  display: flex; flex-direction: column; align-items: stretch;
  gap: clamp(18px, 2.6vw, 32px);
}
@media (min-width: 880px) {
  .jv-brain-stage { flex-direction: row; align-items: center; }
}

.jv-brain-visual { flex: 1 1 340px; min-width: 0 }
.jv-brain-svg { display: block; width: 100%; height: clamp(200px, 34vw, 380px); overflow: visible }

/* terminal: log de boot que "digita" as etapas do cérebro ligando */
.jv-term {
  flex: 1 1 360px; min-width: 0; max-width: 100%;
  background: #0D0F12; border: 1px solid var(--jv-line); border-radius: 10px;
  overflow: hidden; box-shadow: 0 24px 64px -28px rgba(0, 0, 0, .7);
}
.jv-term-head {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 14px; background: #101317; border-bottom: 1px solid var(--jv-line);
}
.jv-term-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--jv-line) }
.jv-term-title {
  margin-left: 8px; font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 10px; letter-spacing: .18em; text-transform: uppercase; color: var(--jv-steel);
}
.jv-term-body {
  display: flex; flex-direction: column; gap: 7px;
  padding: 14px 16px; min-height: clamp(180px, 21vw, 232px); max-height: clamp(180px, 21vw, 232px);
  overflow-y: auto; font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: clamp(10.5px, 1.05vw, 12.5px); line-height: 1.75;
}
.jv-term-line {
  display: flex; gap: 9px; opacity: 0; transform: translateY(5px);
  transition: opacity 380ms ease, transform 380ms ease;
}
.jv-term-line.is-shown { opacity: 1; transform: none }
.jv-term-tag { flex: none; color: var(--jv-graphite) }
.jv-term-line.is-shown:not(.is-ok) .jv-term-tag { color: var(--jv-steel); animation: jvPulse 1.6s ease-in-out infinite }
.jv-term-line.is-ok .jv-term-tag { color: var(--jv-white) }
.jv-term-text { color: var(--jv-steel) }
.jv-term-line.is-ok .jv-term-text { color: var(--jv-text) }
.jv-term-cursor-row { display: flex; align-items: center; gap: 9px; color: var(--jv-steel); margin-top: 1px }
.jv-term-prompt { opacity: .8 }
.jv-term-cursor {
  display: inline-block; width: 6px; height: 13px; background: var(--jv-white);
  animation: jvBlink 1s steps(1, jump-none) infinite;
}

.jv-node { fill: var(--jv-line); opacity: .55; transition: fill 480ms ease, opacity 480ms ease }
.jv-node.is-lit { fill: var(--jv-white); opacity: 1 }
.jv-node--core {
  fill: var(--jv-white); opacity: 1;
  transform-box: fill-box; transform-origin: center;
  animation: jvCorePulse 2.4s ease-in-out infinite;
}
.jv-brain-halo { opacity: .35; transform-box: fill-box; transform-origin: center; animation: jvHaloPulse 3.2s ease-in-out infinite }

.jv-edge { stroke: var(--jv-line); stroke-width: 1; opacity: .3; transition: stroke 480ms ease, opacity 480ms ease }
.jv-edge.is-lit { stroke: var(--jv-steel); opacity: .8; stroke-dasharray: 5 7; animation: jvSinapse 3.2s linear infinite }

.jv-brain-foot { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: -8px }
.jv-brain-pct { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: clamp(13px, 1.6vw, 18px); letter-spacing: .08em; color: var(--jv-steel) }
.jv-brain-pct b { color: var(--jv-white); font-weight: 700 }
.jv-brain-caption {
  margin: 0; font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: clamp(11px, 1.3vw, 14px); letter-spacing: .3em; text-transform: uppercase;
  color: var(--jv-text); animation: jvPulse 2.6s ease-in-out infinite;
}

/* ---------- fase 2: revelação — só o nome, digitado como código ---------- */
.jv-reveal { opacity: 0; filter: blur(14px); transform: scale(.94); transition-delay: 0ms }
#jv-loader.is-phase2 .jv-brain { opacity: 0; filter: blur(16px); transform: scale(1.06); transition-delay: 0ms }
#jv-loader.is-phase2 .jv-reveal { opacity: 1; filter: blur(0); transform: scale(1); transition-delay: 180ms; align-items: center }

/* fase 2 é só o wordmark: o resto (tagline, barras, leitura, estágios,
   rodapé, trilha) nunca chega a aparecer — pedido explícito do usuário. */
#jv-loader.is-phase2 .jv-tagline,
#jv-loader.is-phase2 .jv-bars,
#jv-loader.is-phase2 .jv-readout,
#jv-loader.is-phase2 .jv-stages,
#jv-loader.is-phase2 .jv-foot,
#jv-loader.is-phase2 .jv-track {
  display: none;
}

.jv-title-row { display: flex; align-items: baseline; gap: 2vw; flex-wrap: wrap }
#jv-loader.is-phase2 .jv-title-row { justify-content: center; width: 100% }
.jv-word {
  display: flex; align-items: baseline; margin: 0;
  /* Chakra Petch: display técnica com cortes chanfrados — cara de máquina/
     circuito/automação. Casa com o terminal de boot e a identidade industrial
     do Jarvin (linha de produção). */
  font-family: "Chakra Petch", system-ui, sans-serif; font-weight: 700;
  font-size: clamp(72px, 15vw, 240px); line-height: .84; letter-spacing: -.02em;
}
/* cada letra "chega" como se fosse digitada: nasce apagada e desfocada,
   o typewriter em loading.js liga .is-typed letra a letra */
.jv-word b {
  display: inline-block; width: .66em; flex: none; text-align: center; font-weight: 900;
  color: var(--jv-text); opacity: 0; transform: translateY(.06em); filter: blur(6px);
  transition: opacity 140ms ease, transform 140ms ease, filter 140ms ease;
}
.jv-word b.is-typed { opacity: 1; transform: none; filter: none }
/* cursor de bloco, estilo terminal — anda para depois da última letra digitada */
.jv-type-cursor {
  display: inline-block; flex: none; width: .34em; height: .74em;
  background: var(--jv-white); margin-right: .04em; transform: translateY(.03em);
  animation: jvBlink .85s steps(1, jump-none) infinite;
}
.jv-type-cursor.is-settled { opacity: .5 }
.jv-tagline { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: clamp(11px, 1.2vw, 17px); letter-spacing: .22em; color: var(--jv-steel) }

/* barras: ruído que se alinha conforme o progresso */
.jv-bars { display: flex; align-items: flex-end; gap: clamp(12px, 1.6vw, 22px); height: clamp(56px, 9vw, 120px) }
.jv-bars i {
  flex: 1; height: 100%; background: var(--jv-white); opacity: 1;
  transition: height 240ms linear, opacity 240ms linear, background 240ms linear;
}
.jv-bars i.is-idle { background: var(--jv-steel); opacity: .28 }

/* número + retículo */
.jv-readout { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap }
.jv-gauge { display: flex; align-items: center; gap: clamp(16px, 2vw, 30px) }
.jv-ring { position: relative; width: clamp(58px, 7vw, 104px); height: clamp(58px, 7vw, 104px); flex: none }
.jv-ring svg { position: absolute; inset: 0; width: 100%; height: 100% }
.jv-ring .jv-arc-spin { animation: jvSpin 9s linear infinite }
.jv-ring .jv-arc-spin-rev { animation: jvSpinRev 14s linear infinite }
#jv-progress-arc { transition: stroke-dashoffset 240ms linear }
.jv-pct { font-family: "JetBrains Mono", ui-monospace, monospace; font-weight: 700; font-size: clamp(40px, 6vw, 96px); line-height: 1; font-variant-numeric: tabular-nums }
.jv-pct-sign { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: clamp(14px, 1.4vw, 22px); color: var(--jv-white) }
.jv-detail { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: clamp(10px, 1vw, 13px); letter-spacing: .2em; color: var(--jv-steel); max-width: 38ch; line-height: 1.7 }

.jv-track { height: 3px; background: var(--jv-line); position: relative; overflow: hidden }
.jv-track span {
  position: absolute; inset: 0 auto 0 0; width: 100%;
  background: linear-gradient(90deg, var(--jv-graphite), var(--jv-white));
  transition: width 240ms linear;
}

/* fases */
.jv-stages { display: flex; gap: clamp(14px, 2.4vw, 40px); flex-wrap: wrap }
.jv-stage { display: flex; align-items: center; gap: 9px }
/* o marcador é o <i class="jv-dot">, o texto é o <em> — as regras abaixo
   estavam trocadas (dot mirando `em`, texto mirando um `span` que não
   existe no marcado), o que deixava o texto branco sobre fundo branco:
   invisível. */
.jv-stage i.jv-dot { display: block; width: 7px; height: 7px; border-radius: 50%; background: var(--jv-white); transition: background 300ms linear }
.jv-stage em { font-style: normal; font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 10.5px; letter-spacing: .2em; color: var(--jv-text); transition: color 300ms linear }
.jv-stage.is-pending i.jv-dot { background: var(--jv-line) }
.jv-stage.is-pending em { color: #4C5158 }
.jv-stage.is-active i.jv-dot { background: var(--jv-graphite) }

/* ---------- keyframes ---------- */
@keyframes jvHaloA { 0%, 100% { transform: translate3d(0,0,0) scale(1); opacity: .12 } 50% { transform: translate3d(4%, -3%, 0) scale(1.15); opacity: .2 } }
@keyframes jvHaloB { 0%, 100% { transform: translate3d(0,0,0) scale(1.08); opacity: .1 } 50% { transform: translate3d(-5%, 4%, 0) scale(.92); opacity: .18 } }
@keyframes jvGrid { from { background-position: 0 0, 0 0 } to { background-position: 64px 64px, 64px 64px } }
@keyframes jvScan { from { transform: translateY(-30vh) } to { transform: translateY(115vh) } }
@keyframes jvPulse { 0%, 100% { opacity: .45 } 50% { opacity: 1 } }
@keyframes jvSpin { to { transform: rotate(360deg) } }
@keyframes jvSpinRev { to { transform: rotate(-360deg) } }
@keyframes jvCorePulse { 0%, 100% { transform: scale(1); opacity: 1 } 50% { transform: scale(1.2); opacity: .78 } }
@keyframes jvHaloPulse { 0%, 100% { transform: scale(1); opacity: .3 } 50% { transform: scale(1.3); opacity: .55 } }
@keyframes jvSinapse { to { stroke-dashoffset: -24 } }
@keyframes jvBlink { 0%, 100% { opacity: 1 } 50% { opacity: 0 } }

/* ---------- acessibilidade: o estado final é o visível ---------- */
@media (prefers-reduced-motion: reduce) {
  #jv-loader, #jv-loader * { animation: none !important; transition: none !important }
}

/* ============================================================ LOGIN (Jarvis)
   Mesma identidade da tela de carregamento, mas para a portaria: fundo
   #0A0B0D, grade de 64px com máscara radial, scanline descendo. O login vem
   ANTES do loader — quem vê esta tela ainda não autenticou. */
.jv-login-grid {
  background-image:
    radial-gradient(ellipse 80% 55% at 50% 42%, rgba(232,234,237,0.05), transparent 70%),
    linear-gradient(rgba(38,42,48,0.35) 1px, transparent 1px),
    linear-gradient(90deg, rgba(38,42,48,0.35) 1px, transparent 1px);
  background-size: 100% 100%, 64px 64px, 64px 64px;
  animation: jvGrid 24s linear infinite;
  mask-image: radial-gradient(ellipse 90% 75% at 50% 45%, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 90% 75% at 50% 45%, #000 30%, transparent 75%);
}
.jv-login-scan {
  background: linear-gradient(to bottom, transparent 0%, rgba(232,234,237,0.03) 48%, rgba(232,234,237,0.07) 50%, rgba(232,234,237,0.03) 52%, transparent 100%);
  height: 30vh;
  animation: jvScan 14s linear infinite;
}
