/* ============================================================
   GERTH — Base: reset, tipografia, componentes compartilhados
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

* { margin: 0; }

/* Restaura o contrato semântico do atributo [hidden]: sem isto, qualquer regra
   de componente com "display" (grid, flex...) some com display:none do UA
   stylesheet por especificidade, e o elemento continua visível mesmo marcado
   como oculto via JS (ex.: form.hidden = true). Achado ao testar o fluxo de
   convite expirado em portal/aceitar-convite.html — o mesmo padrão existe em
   password-reset.js para o link de recuperação de senha. */
[hidden] { display: none !important; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

html { overflow-x: clip; }

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--text);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
}

img, svg, video { display: block; max-width: 100%; }

input, button, textarea, select { font: inherit; color: inherit; }

a { color: inherit; }

h1, h2, h3, h4 {
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.022em;
  text-wrap: balance;
}

p { text-wrap: pretty; }

:focus-visible {
  outline: 2px solid var(--green-600);
  outline-offset: 2px;
  border-radius: 2px;
}

::selection { background: var(--green-100); color: var(--ink-900); }

/* ---------- Utilitários ---------- */

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: clamp(1.25rem, 4vw, 2.5rem);
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute;
  top: -48px; left: 16px;
  z-index: 200;
  background: var(--ink-900);
  color: var(--text-invert);
  padding: 10px 18px;
  border-radius: 0 0 var(--r-sm) var(--r-sm);
  text-decoration: none;
  font-weight: 600;
  font-size: var(--fs-sm);
  transition: top var(--t-base) var(--ease-out);
}
.skip-link:focus-visible { top: 0; }

.mono { font-family: var(--font-mono); }

/* ---------- Botões ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 28px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-weight: 700;
  font-size: var(--fs-base);
  letter-spacing: -0.01em;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: transform var(--t-fast) var(--ease-out),
              background-color var(--t-fast) ease,
              border-color var(--t-fast) ease,
              color var(--t-fast) ease,
              box-shadow var(--t-fast) ease;
}
.btn:active { transform: scale(0.97); }
.btn .btn-ic { flex: none; }

.btn-primary {
  background: var(--green-600);
  color: #FFFFFF;
  box-shadow: var(--sh-btn);
}
.btn-primary:active { background: var(--green-800); }

.btn-dark {
  background: var(--ink-900);
  color: var(--text-invert);
  box-shadow: var(--sh-btn);
}

.btn-ghost {
  background: transparent;
  color: var(--ink-800);
  border-color: var(--line-strong);
}

.btn-ghost-invert {
  background: transparent;
  color: var(--text-invert);
  border-color: rgba(244, 247, 245, 0.28);
}

.btn-sm { padding: 9px 18px; font-size: var(--fs-sm); border-radius: 10px; }
.btn-lg { padding: 17px 34px; font-size: var(--fs-md); }

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { background: var(--green-700); }
  .btn-dark:hover { background: var(--ink-800); }
  .btn-ghost:hover { background: var(--ink-050); border-color: var(--ink-300); }
  .btn-ghost-invert:hover { background: rgba(244, 247, 245, 0.08); border-color: rgba(244, 247, 245, 0.5); }
}

/* ---------- Chips / tags ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.chip-line { border: 1px solid var(--line-strong); color: var(--text-2); background: var(--card); }
.chip-green { background: var(--green-050); color: var(--green-800); border: 1px solid var(--green-100); }
.chip-dark { background: rgba(111, 191, 103, 0.12); color: var(--dk-green); border: 1px solid rgba(111, 191, 103, 0.25); }

.chip-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

/* ---------- Deltas (variação de indicadores) ---------- */

.delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 700;
  padding: 3px 9px;
  border-radius: var(--r-full);
}
.delta svg { width: 12px; height: 12px; }
.delta-pos { color: var(--green-800); background: var(--pos-bg); }
.delta-neg { color: var(--neg); background: var(--neg-bg); }
.delta-warn { color: #8A6416; background: var(--warn-bg); }

/* ---------- Placeholder de imagem pendente ----------
   Bloco visível com borda tracejada + rótulo do arquivo a fornecer.
   Se a imagem real existir em ../imagens/, ela cobre o placeholder. */

.ph {
  position: relative;
  overflow: hidden;
  border-radius: var(--r-lg);
  border: 2px dashed var(--line-strong);
  background:
    repeating-linear-gradient(-45deg, transparent 0 14px, rgba(7, 43, 55, 0.025) 14px 28px),
    var(--paper-2);
  display: grid;
  place-items: center;
}
.ph-dark {
  border-color: rgba(244, 247, 245, 0.2);
  background:
    repeating-linear-gradient(-45deg, transparent 0 14px, rgba(244, 247, 245, 0.03) 14px 28px),
    rgba(244, 247, 245, 0.04);
}
.ph-body {
  padding: var(--sp-6);
  text-align: center;
  max-width: 36ch;
}
.ph-body svg { margin-inline: auto; margin-bottom: 10px; color: var(--text-3); }
.ph-dark .ph-body svg { color: var(--text-invert-2); }
.ph-kicker {
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}
.ph-dark .ph-kicker { color: var(--text-invert-2); }
.ph-file {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--green-700);
  word-break: break-all;
  margin-top: 6px;
}
.ph-dark .ph-file { color: var(--dk-green); }
.ph-desc { font-size: var(--fs-xs); color: var(--text-3); margin-top: 6px; }
.ph-dark .ph-desc { color: var(--text-invert-2); }

.ph > img.ph-real {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: 1;
}

/* ---------- Barras de meta ---------- */

.meter {
  width: 100%;
  height: 8px;
  border-radius: var(--r-full);
  background: var(--ink-050);
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  border-radius: var(--r-full);
  background: var(--green-500);
  transform-origin: left center;
  transform: scaleX(var(--fill, 1));
  transition: transform 700ms var(--ease-out);
}
.meter-fill.is-warn { background: var(--warn); }
.meter-fill.is-neg { background: var(--neg); }
/* com JS: barra começa vazia e preenche ao entrar na tela */
.js .meter-fill { transform: scaleX(0); }
.js .in-view .meter-fill { transform: scaleX(var(--fill, 1)); }

/* ---------- Reveal on scroll ---------- */

.rv {
  transition: opacity 560ms var(--ease-out), transform 560ms var(--ease-out);
  transition-delay: var(--rv-d, 0ms);
}
/* estado oculto só existe com JS ativo — sem JS o conteúdo permanece visível */
.js .rv { opacity: 0; transform: translateY(18px); }
.js .rv.in-view { opacity: 1; transform: none; }

/* ---------- Acessibilidade: menos movimento ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .rv, .js .rv { transition: opacity 240ms ease; transform: none; }
  .meter-fill, .js .meter-fill, .js .in-view .meter-fill {
    transition: none;
    transform: scaleX(var(--fill, 1));
  }
  *, *::before, *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
  }
}
