/**
 * ESCALA-2026-FNL02 - Consulta Cromática: Estação Ferroviária de Raposos/MG
 * Escala Nacional
 *
 * CSS Puro (Vanilla CSS) - Mobile First - Sem dependências externas
 */

/* ==========================================================================
   1. Variáveis de Design & Tokens
   ========================================================================== */
:root {
  /* Cores Neutras e Estruturais */
  --color-bg-page: #f8fafc;
  --color-bg-card: #ffffff;
  --color-bg-card-hover: #f1f5f9;
  --color-bg-input: #ffffff;
  --color-border: #cbd5e1;
  --color-border-subtle: #e2e8f0;
  --color-border-focus: #1e3a8a;

  /* Cores de Texto */
  --color-text-primary: #0f172a;
  --color-text-secondary: #334155;
  --color-text-muted: #64748b;
  --color-text-inverse: #ffffff;

  /* Cores Institucionais & Ações */
  --color-brand-primary: #1e3a8a;
  --color-brand-primary-hover: #172554;
  --color-brand-accent: #0284c7;
  --color-brand-selected: #2563eb;
  --color-brand-selected-bg: #eff6ff;

  /* Cores de Feedback & Estados */
  --color-success-bg: #ecfdf5;
  --color-success-text: #065f46;
  --color-success-border: #a7f3d0;
  --color-notice-bg: #fffbeb;
  --color-notice-text: #92400e;
  --color-notice-border: #fde68a;
  --color-error-text: #b91c1c;
  --color-error-border: #ef4444;

  /* Tipografia do Sistema (Sem fontes externas) */
  --font-family-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-size-xs: 0.75rem;
  /* 12px */
  --font-size-sm: 0.875rem;
  /* 14px */
  --font-size-base: 1rem;
  /* 16px */
  --font-size-lg: 1.125rem;
  /* 18px */
  --font-size-xl: 1.25rem;
  /* 20px */
  --font-size-2xl: 1.5rem;
  /* 24px */
  --line-height-tight: 1.25;
  --line-height-normal: 1.5;

  /* Espaçamentos e Raios */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);

  /* Dimensões */
  --container-max-width: 680px;
  --min-touch-target: 44px;
}

/* ==========================================================================
   2. Reset & Acessibilidade Básica
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg-page);
  padding: 0;
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Foco visível com alto contraste para acessibilidade */
:focus-visible {
  outline: 3px solid var(--color-brand-selected);
  outline-offset: 3px;
}

/* Utilitário para leitores de tela */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   3. Container Principal e Estrutura Geral
   ========================================================================== */
.page-container {
  width: 100%;
  max-width: var(--container-max-width);
  margin-left: auto;
  margin-right: auto;
  padding: 1.5rem 1rem 3rem 1rem;
}

/* ==========================================================================
   4. Cabeçalho (Header)
   ========================================================================== */
.site-header {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border-subtle);
}

.site-header h1 {
  font-size: clamp(1.35rem, 4.5vw, 1.85rem);
  font-weight: 800;
  line-height: var(--line-height-tight);
  color: var(--color-text-primary);
  margin-bottom: 0.875rem;
}

.header-subtitle {
  font-size: clamp(0.95rem, 2.5vw, 1.05rem);
  color: var(--color-text-secondary);
  line-height: 1.45;
  margin-bottom: 1rem;
}

.header-deadline {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  background-color: #f1f5f9;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-weight: 500;
}

/* ==========================================================================
   5. Banners de Estado Temporal (Avisos Dinâmicos)
   ========================================================================== */
.status-banner {
  margin-bottom: 1.75rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  line-height: 1.45;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  box-shadow: var(--shadow-sm);
}

.status-banner.notice {
  background-color: var(--color-notice-bg);
  color: var(--color-notice-text);
  border: 1px solid var(--color-notice-border);
}

.status-banner.closed {
  background-color: #f8fafc;
  color: #334155;
  border: 1px solid #cbd5e1;
}

.status-banner.qa-ready {
  background-color: var(--color-success-bg);
  color: var(--color-success-text);
  border: 1px solid var(--color-success-border);
}

.status-banner-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
}

/* ==========================================================================
   6. Seções de Conteúdo (Cards & Grids)
   ========================================================================== */
.content-section {
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.25rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

.section-title {
  font-size: clamp(1.15rem, 3.5vw, 1.35rem);
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: var(--line-height-tight);
  margin-bottom: 0.5rem;
}

.section-description {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-bottom: 1.25rem;
}

/* ==========================================================================
   7. Seção 1: Referências Históricas
   ========================================================================== */
.history-cards-container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 1rem;
}

.history-card {
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.history-card-media {
  width: 100%;
  background-color: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.history-card-img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

.history-card-body {
  padding: 0.875rem 1rem;
}

.history-card-title {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1.35;
}

.history-card-note {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: 0.35rem;
  line-height: 1.3;
}

/* ==========================================================================
   8. Seção 2: Votação das Alternativas Cromáticas
   ========================================================================== */
.voting-options-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Cartão de votação completo clicável */
.voting-option-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background-color: var(--color-bg-card);
  border: 2px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
  min-height: var(--min-touch-target);
  user-select: none;
}

/* Input radio invisível por cima ou escondido com preservação de foco */
.voting-option-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.voting-option-input:focus-visible+.voting-option-content {
  outline: 3px solid var(--color-brand-selected);
  outline-offset: -3px;
}

/* Estado Selecionado */
.voting-option-card.selected,
.voting-option-card:has(.voting-option-input:checked) {
  border-color: var(--color-brand-selected);
  background-color: var(--color-brand-selected-bg);
  box-shadow: var(--shadow-md);
}

.voting-option-content {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.voting-option-preview {
  width: 100%;
  background-color: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-bottom: 1px solid var(--color-border-subtle);
}

.voting-option-img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: contain;
}

.voting-option-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  gap: 0.75rem;
}

.voting-option-details {
  display: flex;
  flex-direction: column;
}

.voting-option-title {
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--color-text-primary);
}

.voting-option-card.selected .voting-option-title,
.voting-option-card:has(.voting-option-input:checked) .voting-option-title {
  color: var(--color-brand-selected);
}

/* Indicador visual de seleção (Radio falso estilizado) */
.custom-radio-circle {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 50%;
  border: 2px solid var(--color-border);
  background-color: var(--color-bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s ease;
}

.voting-option-card.selected .custom-radio-circle,
.voting-option-card:has(.voting-option-input:checked) .custom-radio-circle {
  border-color: var(--color-brand-selected);
  background-color: var(--color-brand-selected);
}

.custom-radio-circle::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: #ffffff;
  transform: scale(0);
  transition: transform 0.18s ease;
}

.voting-option-card.selected .custom-radio-circle::after,
.voting-option-card:has(.voting-option-input:checked) .custom-radio-circle::after {
  transform: scale(1);
}

/* ==========================================================================
   9. Seção 3: Identificação & Validação
   ========================================================================== */
.form-grid {
  display: flex;
  flex-direction: column;
  gap: 1.125rem;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.form-label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-primary);
}

.form-label .required-indicator {
  color: var(--color-error-text);
  font-weight: 700;
}

.form-input {
  width: 100%;
  min-height: var(--min-touch-target);
  padding: 0.625rem 0.875rem;
  font-family: var(--font-family-base);
  font-size: 1rem;
  color: var(--color-text-primary);
  background-color: var(--color-bg-input);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus {
  outline: none;
  border-color: var(--color-brand-selected);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-input.is-invalid {
  border-color: var(--color-error-border);
  background-color: #fef2f2;
}

.field-error-message {
  font-size: var(--font-size-xs);
  color: var(--color-error-text);
  font-weight: 500;
  display: none;
}

.form-input.is-invalid+.field-error-message,
.form-field.has-error .field-error-message {
  display: block;
}

/* Checkbox dos Termos */
.checkbox-field {
  margin-top: 0.5rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
}

.checkbox-input {
  width: 20px;
  height: 20px;
  min-width: 20px;
  margin-top: 2px;
  accent-color: var(--color-brand-selected);
  cursor: pointer;
}

.checkbox-label-text {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  line-height: 1.45;
}

.checkbox-link {
  color: var(--color-brand-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 600;
}

.checkbox-link:hover,
.checkbox-link:focus-visible {
  color: var(--color-brand-selected);
}

/* Botão Principal */
.btn-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  padding: 0.875rem 1.5rem;
  margin-top: 1.5rem;
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--color-text-inverse);
  background-color: var(--color-brand-primary);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.btn-submit:hover {
  background-color: var(--color-brand-primary-hover);
}

.btn-submit:active {
  transform: translateY(1px);
}

.btn-submit:disabled {
  background-color: #94a3b8;
  cursor: not-allowed;
  box-shadow: none;
}

/* Mensagem de Feedback Técnico (QA) */
.qa-feedback-box {
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  background-color: var(--color-success-bg);
  border: 1.5px solid var(--color-success-border);
  border-radius: var(--radius-md);
  color: var(--color-success-text);
  font-size: var(--font-size-sm);
  font-weight: 600;
  text-align: center;
  display: none;
}

.qa-feedback-box.visible {
  display: block;
}

/* ==========================================================================
   10. Seção de Resultados Provisórios (A partir de 16/09/2026)
   ========================================================================== */
.results-container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.results-summary-card {
  background-color: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  text-align: center;
}

.results-summary-value {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  color: var(--color-brand-primary);
  margin-top: 0.25rem;
}

.results-breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.result-row {
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: 0.875rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.result-row.is-winner {
  border-color: #10b981;
  background-color: #f0fdf4;
}

.result-row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.result-row-title {
  font-weight: 700;
  font-size: var(--font-size-sm);
}

.result-row-badge {
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: #065f46;
  background-color: #d1fae5;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
}

.result-row-metrics {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
}

.result-progress-bar {
  width: 100%;
  height: 8px;
  background-color: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.result-progress-fill {
  height: 100%;
  background-color: var(--color-brand-primary);
  width: 0%;
  border-radius: 999px;
}

.result-row.is-winner .result-progress-fill {
  background-color: #10b981;
}

/* ==========================================================================
   11. Bloco Institucional de Marcas
   ========================================================================== */
.institutional-block {
  background-color: var(--color-bg-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  padding: 2rem 1.25rem;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2rem;
  overflow: hidden;
}

/* Cada nível institucional */
.institutional-group {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.75rem;
}

/* Lei Rouanet abre o bloco sem título textual acima */
.institutional-group--rouanet {
  padding-bottom: 0.25rem;
}

/* Rótulos APOIO / PATROCÍNIO / REALIZAÇÃO */
.institutional-label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  line-height: 1.2;
}

/* Linha genérica de marcas */
.institutional-logos-row {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

/* Linhas com apenas uma marca */
.institutional-logos-row--single {
  justify-content: center;
}

/* Apoio: no mobile, Prefeitura e Escala ficam empilhadas */
.institutional-logos-row--support {
  flex-direction: column;
  gap: 1.25rem;
}

/* Regras gerais das imagens */
.institutional-logo {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  object-fit: contain;
  flex: 0 0 auto;
}

/*
 * Dimensionamento individual.
 * Mantém a proporção original de cada arquivo e permite equilíbrio
 * visual sem forçar todas as marcas à mesma largura.
 */
.institutional-logo--leirouanet {
  width: min(100%, 220px);
  max-height: 100px;
}

.institutional-logo--raposos {
  width: min(100%, 170px);
  max-height: 95px;
}

.institutional-logo--escala {
  width: min(100%, 175px);
  max-height: 95px;
}

.institutional-logo--anglogold {
  width: min(100%, 220px);
  max-height: 100px;
}

.institutional-logo--governo {
  width: min(100%, 280px);
  max-height: 125px;
}

/* ==========================================================================
   12. Responsividade para Telas Maiores (Desktop / Tablet)
   ========================================================================== */
@media (min-width: 640px) {

  /* Referências históricas lado a lado e com bases alinhadas */
  .history-cards-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    align-items: stretch;
  }

  .history-card {
    height: 100%;
  }

  .history-card-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
  }

  /* Bloco institucional com maior respiro no desktop */
  .institutional-block {
    padding: 2.25rem 2rem;
    gap: 2.25rem;
  }

  /* Prefeitura e Escala passam a ficar lado a lado */
  .institutional-logos-row--support {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: center;
    gap: 2.5rem;
  }

  /* Ajustes discretos de escala para telas maiores */
  .institutional-logo--leirouanet {
    width: min(100%, 250px);
    max-height: 110px;
  }

  .institutional-logo--raposos {
    width: min(42%, 190px);
    max-height: 105px;
  }

  .institutional-logo--escala {
    width: min(42%, 195px);
    max-height: 105px;
  }

  .institutional-logo--anglogold {
    width: min(100%, 250px);
    max-height: 110px;
  }

  .institutional-logo--governo {
    width: min(100%, 330px);
    max-height: 140px;
  }
}