/*
 * Sistema visual H9K: home deslogada e cadastro.
 *
 * Tudo aqui é escopado em `.h9k` porque `stylesheet_link_tag :app` carrega
 * todos os arquivos desta pasta em todas as páginas do app.
 *
 * A paleta sai do próprio logo — o olho do HAL 9000: aro cromado, bezel preto,
 * brilho vermelho e núcleo amarelo. O vermelho é ação/marca; o amarelo é
 * "crédito acumulado"; o cromo são as réguas e divisórias.
 */

.h9k {
  /* Claro */
  --bg: #eceef1;
  --surface: #ffffff;
  --surface-2: #f5f6f8;
  --line: #d5dae0;
  --line-strong: #b1bac3;
  --text: #10151a;
  --text-2: #525c68;
  --text-3: #767f8a;
  --sinal: #c81e12;
  --sinal-hover: #a91710;
  --sinal-on: #ffffff;
  --nucleo: #8a5a00;
  --nucleo-fill: #f2b705;
  --bezel: #14181b;
  --glow: 0.16;
  --ok: #16704a;
  --ok-bg: #e3f4ec;
  --ok-line: #b7e0cd;
  --atencao: #8a5a00;
  --atencao-bg: #fdf3dc;
  --atencao-line: #f0d79a;

  background: var(--bg);
  color: var(--text);
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.dark .h9k {
  /* Escuro */
  --bg: #0a0c0d;
  --surface: #131719;
  --surface-2: #1a1f22;
  --line: #262d31;
  --line-strong: #3b454c;
  --text: #edf1f3;
  --text-2: #98a4ad;
  --text-3: #79858e;
  --sinal: #ff4436;
  --sinal-hover: #ff6558;
  --sinal-on: #14181b;
  --nucleo: #f2b705;
  --nucleo-fill: #f2b705;
  --bezel: #05070800;
  --glow: 0.34;
  --ok: #4ade9f;
  --ok-bg: #10241c;
  --ok-line: #1f4736;
  --atencao: #f2b705;
  --atencao-bg: #241d0c;
  --atencao-line: #47380f;
}

/* ---------- Tipografia ---------- */

.h9k-display {
  font-family: "Anybody", "Archivo", ui-sans-serif, system-ui, sans-serif;
  font-variation-settings: "wdth" 106;
  font-weight: 700;
  letter-spacing: -0.022em;
  line-height: 0.98;
  text-wrap: balance;
}

.h9k-mono {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.6875rem;
  font-feature-settings: "zero" 1;
}

.h9k-num {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "zero" 1;
}

/* ---------- Estrutura ---------- */

.h9k-rule {
  border-top: 1px solid var(--line);
}

.h9k-panel {
  background: var(--surface);
  border: 1px solid var(--line);
}

/* Régua de instrumento: o traço fino que abre cada seção. */
.h9k-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--text-3);
}

.h9k-eyebrow::before {
  content: "";
  width: 1.5rem;
  height: 1px;
  background: var(--line-strong);
}

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

.h9k-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.375rem;
  font-weight: 600;
  font-size: 0.9375rem;
  border: 1px solid transparent;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.h9k-btn-primary {
  background: var(--sinal);
  color: var(--sinal-on);
}

.h9k-btn-primary:hover {
  background: var(--sinal-hover);
}

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

.h9k-btn-ghost:hover {
  background: var(--surface-2);
  border-color: var(--text-3);
}

.h9k :focus-visible {
  outline: 2px solid var(--sinal);
  outline-offset: 2px;
}

/* ---------- O medidor: o olho como instrumento ---------- */

.h9k-dial-seg {
  stroke: var(--line-strong);
  stroke-width: 9;
  fill: none;
  transition: stroke 0.18s ease;
}

.h9k-dial-seg[data-on="true"] {
  stroke: var(--nucleo-fill);
}

.h9k-eye-glow {
  opacity: calc(var(--fill, 0) * 0.85 + var(--glow));
  transition: opacity 0.25s ease;
}

/* Slider de meses */
.h9k-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 2rem;
  background: transparent;
  cursor: pointer;
}

.h9k-range::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--line-strong);
}

.h9k-range::-moz-range-track {
  height: 2px;
  background: var(--line-strong);
}

.h9k-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 1.25rem;
  height: 1.25rem;
  margin-top: -0.594rem;
  border-radius: 50%;
  background: var(--sinal);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--line-strong);
}

.h9k-range::-moz-range-thumb {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: var(--sinal);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--line-strong);
}

/* ---------- Escada de níveis ---------- */

.h9k-step {
  background: var(--surface);
  border: 1px solid var(--line);
  transition: border-color 0.15s ease;
}

.h9k-step:hover {
  border-color: var(--line-strong);
}

.h9k-step-mark {
  color: var(--sinal);
}

/*
 * Cartão de nível/produto: altura igual dentro da mesma linha do grid e botão
 * sempre colado no rodapé, para os CTAs alinharem entre cartões de texto
 * desigual.
 */
.h9k-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 1.75rem;
}

@media (min-width: 640px) {
  .h9k-card {
    padding: 2rem;
  }
}

.h9k-card-fill {
  flex: 1 1 auto;
}

.h9k-card-foot {
  margin-top: 2rem;
}

/* ---------- Formulários ---------- */

.h9k .h9k-field {
  display: block;
  width: 100%;
  padding: 0.8125rem 0.875rem;
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.h9k .h9k-field::placeholder {
  color: var(--text-3);
}

.h9k .h9k-field:focus {
  border-color: var(--sinal);
  background: var(--surface);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--sinal) 22%, transparent);
}

.h9k-label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.h9k .h9k-check {
  width: 1.0625rem;
  height: 1.0625rem;
  accent-color: var(--sinal);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  cursor: pointer;
}

.h9k-link {
  color: var(--sinal);
  font-weight: 600;
  text-underline-offset: 0.2em;
}

.h9k-link:hover {
  text-decoration: underline;
}

/*
 * ---------- Documentos longos (termos, política de privacidade) ----------
 *
 * O texto jurídico continua com as classes Tailwind que já tinha. Estes
 * seletores são `.h9k-prose <tag>`, especificidade (0,1,1), então ganham das
 * utilitárias de cor e tamanho, que são (0,1,0). Assim o documento passa a
 * responder aos tokens de tema sem que ninguém precise reescrever a redação.
 */

.h9k-prose {
  max-width: 68ch;
  color: var(--text-2);
  font-size: 1rem;
  line-height: 1.75;
}

.h9k-prose h2 {
  font-family: "Anybody", "Archivo", ui-sans-serif, system-ui, sans-serif;
  font-variation-settings: "wdth" 106;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text);
  font-size: 1.375rem;
  line-height: 1.25;
}

/* Os títulos de cláusula vêm em caixa alta do documento jurídico original. */
.h9k-prose h3 {
  font-family: "Anybody", "Archivo", ui-sans-serif, system-ui, sans-serif;
  font-variation-settings: "wdth" 100;
  font-weight: 700;
  letter-spacing: 0.005em;
  color: var(--text);
  font-size: 0.9375rem;
  line-height: 1.35;
}

.h9k-prose p,
.h9k-prose li,
.h9k-prose div {
  color: var(--text-2);
}

.h9k-prose ul {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.h9k-prose li,
.h9k-prose ul > div {
  margin-bottom: 0.5rem;
}

.h9k-prose .font-semibold,
.h9k-prose .font-bold,
.h9k-prose strong {
  color: var(--text);
}

.h9k-prose hr {
  margin: 2rem 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.h9k-prose a {
  color: var(--sinal);
  font-weight: 600;
}

.h9k-prose a:hover {
  text-decoration: underline;
}

/* Numeração da seção, à esquerda no desktop. */
.h9k-doc-section {
  scroll-margin-top: 6rem;
  padding-top: 2rem;
  border-top: 1px solid var(--line);
  margin-top: 2rem;
}

.h9k-doc-section:first-of-type {
  border-top: 0;
  margin-top: 0;
}

/* Índice lateral. */
.h9k-toc a {
  display: block;
  padding: 0.4375rem 0;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--text-3);
  border-left: 2px solid transparent;
  padding-left: 0.875rem;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.h9k-toc a:hover {
  color: var(--text);
  border-left-color: var(--sinal);
}

/* Barra de progresso do formulário: o eco linear do mostrador da home. */
.h9k-progress {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 3px;
}

.h9k-progress-seg {
  height: 3px;
  background: var(--line-strong);
  transition: background-color 0.2s ease;
}

.h9k-progress-seg[data-on="true"] {
  background: var(--nucleo-fill);
}

/* ---------- FAQ nativo ---------- */

.h9k-faq summary {
  cursor: pointer;
  list-style: none;
}

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

.h9k-faq summary .h9k-faq-icon {
  transition: transform 0.2s ease;
}

.h9k-faq details[open] summary .h9k-faq-icon {
  transform: rotate(45deg);
}

/* ---------- Entrada ---------- */

@media (prefers-reduced-motion: no-preference) {
  .h9k-rise {
    animation: h9k-rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
  }
}

@keyframes h9k-rise {
  from {
    opacity: 0;
    transform: translateY(0.75rem);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Selos de estado (telas de compra) ---------- */

.h9k-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4375rem 0.75rem;
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-2);
}

.h9k-badge-ok {
  background: var(--ok-bg);
  border-color: var(--ok-line);
  color: var(--ok);
}

.h9k-badge-atencao {
  background: var(--atencao-bg);
  border-color: var(--atencao-line);
  color: var(--atencao);
}

/* Cabeçalho vermelho do cartão de compra. */
.h9k-card-header {
  background: var(--sinal);
  color: var(--sinal-on);
  padding: 1.375rem 1.5rem;
  text-align: center;
}

.h9k-card-header p {
  opacity: 0.85;
}

/* Bloco de preço. */
.h9k-price {
  background: var(--surface-2);
  border: 1px solid var(--line);
  padding: 1.25rem 1.5rem;
}

.h9k-btn-ok {
  background: var(--ok);
  color: var(--surface);
}

.dark .h9k-btn-ok {
  color: #10241c;
}

/*
 * ---------- Central de robôs: leitura de licença ----------
 *
 * O mesmo mostrador segmentado da home, reduzido a duas casas: o que já roda em
 * conta demo e o que precisa de licença para conta real. Amarelo é o núcleo, a
 * cor de crédito parcial; verde é acesso completo.
 */

.h9k-meter {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 3px;
}

.h9k-meter-seg {
  height: 4px;
  background: var(--line);
}

.h9k-meter-seg[data-on="atencao"] {
  background: var(--nucleo-fill);
}

.h9k-meter-seg[data-on="ok"] {
  background: var(--ok);
}

/*
 * Alinhamento entre cartões da mesma linha.
 *
 * Sem altura reservada, um robô de descrição curta empurra o medidor para cima
 * e o vizinho de descrição longa o empurra para baixo, então a leitura de
 * acesso aparecia em alturas diferentes lado a lado. Nome e descrição passam a
 * ocupar sempre as mesmas linhas, e o bloco de estado, a mesma faixa.
 */

.h9k-card-name {
  min-height: 1.96em; /* duas linhas em line-height 0.98 */
}

.h9k-card-desc {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 4.8em; /* três linhas em line-height 1.6 */
}

/*
 * Faixa de aquisição do cartão: mesma altura em todos, vazia quando a conta já
 * tem tudo o que aquele robô oferece. Sem a altura reservada, o cartão com
 * oferta empurra os próprios botões para cima e desalinha da fileira.
 */
.h9k-card-cta {
  min-height: 3rem;
}

.h9k-card-state {
  display: flex;
  align-items: flex-start;
  min-height: 2.25rem;
}

/* Aba de plataforma: régua embaixo, sem pílula nem sombra. */
.h9k-tab {
  padding: 0.625rem 0.125rem;
  border-bottom: 2px solid transparent;
  color: var(--text-3);
  transition: color 0.15s ease, border-color 0.15s ease;
}

.h9k-tab:hover {
  color: var(--text);
}

.h9k-tab[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--sinal);
}

/*
 * ---------- Mensagens de flash dentro do sistema ----------
 *
 * O partial compartilhado pinta tudo de amarelo, inclusive sucesso. Aqui dentro
 * a mensagem recebe a cor do próprio tipo, usando os tokens de tema. Os
 * seletores são (0,2,0) e por isso ganham das utilitárias do partial.
 */

.h9k [data-flash-type] {
  border-radius: 0;
  border: 1px solid var(--line);
  border-left-width: 3px;
  background: var(--surface-2);
  color: var(--text);
  line-height: 1.5;
}

.h9k [data-flash-type="notice"],
.h9k [data-flash-type="success"] {
  border-left-color: var(--ok);
  background: var(--ok-bg);
  color: var(--ok);
}

.h9k [data-flash-type="alert"],
.h9k [data-flash-type="error"] {
  border-left-color: var(--sinal);
  color: var(--sinal);
}

.h9k [data-flash-type="warning"] {
  border-left-color: var(--atencao);
  background: var(--atencao-bg);
  color: var(--atencao);
}

.h9k [data-flash-type="info"] {
  border-left-color: var(--line-strong);
}
