/* =========================================================================
   Panorama Econômico — tema "terminal financeiro"
   Inspiração: Google Finanças. Fundo em degradê grafite -> cinza metálico,
   acentos verde/vermelho de alta/baixa, cards estilo índice.
   ========================================================================= */

:root {
  --ink:        #f5f7fa;   /* texto principal */
  --ink-2:      #b6bcc4;   /* texto secundário */
  --muted:      #868d96;   /* rótulos/eixos */
  --line:       rgba(255,255,255,.09);   /* linhas finas */
  --line-2:     rgba(255,255,255,.14);
  --up:         #0ecb81;   /* verde de alta */
  --down:       #f6465d;   /* vermelho de baixa */
  --c1:         #4a97ee;   /* série 1 (azul) */
  --c2:         #ef7f4c;   /* série 2 (laranja) */
  --c3:         #2bbf8c;   /* série 3 (verde-água) */
  --radius:     16px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  /* Degradê grafite escuro -> cinza metálico mais claro (pedido do usuário) */
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(120,130,145,.16), transparent 60%),
    linear-gradient(160deg, #16181c 0%, #24272d 42%, #3a3f47 100%);
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.5;
}

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 22px; }

/* ---------- Splash de abertura (fade in -> hold -> fade out) ---------- */
.intro-splash {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #16181c 0%, #24272d 42%, #3a3f47 100%);
  opacity: 0; pointer-events: none;
  /* Reduced duration so the splash fades faster */
  animation: introFade 3s ease-in-out forwards;
}
.intro-logo {
  width: min(88vw, 900px); height: auto;
  max-height: 82vh; object-fit: contain;
  border-radius: 14px;
  filter: drop-shadow(0 24px 70px rgba(0,0,0,.55));
}
@keyframes introFade {
  0%   { opacity: 0; }
  15%  { opacity: 1; }   /* fade-in */
  55%  { opacity: 1; }   /* shorter hold time */
  100% { opacity: 0; visibility: hidden; }   /* faster fade-out */
}
@media (prefers-reduced-motion: reduce) {
  .intro-splash { display: none; }
}

/* ---------- Cabeçalho ---------- */
.topbar { padding: 26px 0 6px; }
.brand { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; row-gap: 8px; }
.logo-mark {
  height: 30px; width: auto; display: block;
  border-radius: 7px;
  box-shadow: 0 2px 10px rgba(0,0,0,.4);
}
.brand .mark { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.brand .mark .b { color: var(--ink); }
.brand .mark .t { color: var(--ink-2); font-weight: 500; }
.brand .tag {
  margin-left: auto; font-size: 11px; color: var(--muted); line-height: 1.5;
  border: 1px solid var(--line); padding: 5px 12px; border-radius: 10px;
  max-width: 340px; text-align: right;
}
.brand .tag a { color: var(--c1); text-decoration: none; }
.brand .tag a:hover { text-decoration: underline; }
.subtitle { margin: 4px 0 0; font-size: 13px; color: var(--muted); }

/* ---------- Pills de atalho (grupos) ---------- */
.presets {
  display: flex; gap: 8px; margin: 20px 0 6px; flex-wrap: wrap;
}
.pill {
  background: rgba(255,255,255,.05); color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 15px; font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all .15s ease;
}
.pill:hover { background: rgba(255,255,255,.10); color: var(--ink); }
.pill.active {
  background: linear-gradient(180deg, #e9edf2, #c7ced6);
  color: #1a1d21; border-color: transparent; font-weight: 600;
}

/* ---------- Seletores de país ---------- */
.selectors { display: flex; gap: 12px; margin: 12px 0 22px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.field select {
  appearance: none;
  background: linear-gradient(180deg, #2f343b, #262a30) no-repeat;
  color: var(--ink);
  border: 1px solid var(--line-2); border-radius: 10px;
  padding: 9px 32px 9px 12px; font-size: 14px; font-weight: 600; cursor: pointer;
  min-width: 180px;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%23b6bcc4' d='M6 8 0 0h12z'/%3E%3C/svg%3E"),
    linear-gradient(180deg, #2f343b, #262a30);
  background-repeat: no-repeat; background-position: right 12px center, center;
}
.field select:focus { outline: 2px solid var(--c1); outline-offset: 1px; }

/* ---------- Faixa de status ---------- */
.status { margin: 4px 0 14px; padding: 10px 14px; border-radius: 10px; font-size: 14px; font-weight: 500; }
.status.loading { background: rgba(74,151,238,.14); color: #9cc4f5; }
.status.error   { background: rgba(246,70,93,.14); color: #ff8a99; }

/* ---------- Cards de país (estilo índice) ---------- */
.cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px;
}
.card {
  background: linear-gradient(150deg, #2b3037 0%, #23272d 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px 14px;
  box-shadow: 0 1px 0 rgba(255,255,255,.05) inset, 0 10px 24px rgba(0,0,0,.28);
  display: flex; flex-direction: column; gap: 10px;
}
.card-top { display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.card-name { font-size: 16px; font-weight: 600; }
.card-gdp { font-size: 27px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.card-change { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.card-change .arrow { font-size: 12px; }
.card-change.up { color: var(--up); }
.card-change.down { color: var(--down); }
.card-change .base { color: var(--muted); font-weight: 400; }
.spark { width: 100%; height: 46px; display: block; }
.card-foot { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-2); border-top: 1px solid var(--line); padding-top: 9px; }
.card-foot span b { color: var(--ink); font-weight: 600; }

/* ---------- Gráfico comparativo ---------- */
.chart-card {
  margin-top: 20px;
  background: linear-gradient(150deg, #2b3037 0%, #23272d 100%);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px 22px; box-shadow: 0 10px 24px rgba(0,0,0,.28);
}
.chart-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 6px; }
.chart-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.chart-note { font-size: 12px; color: var(--muted); }
.chart-box { position: relative; height: 360px; }

/* ---------- Rodapé ---------- */
.rodape { margin: 24px 0 40px; font-size: 12px; color: var(--muted); text-align: center; }
.rodape a { color: var(--c1); text-decoration: none; }

@media (max-width: 640px) {
  .selectors { flex-direction: column; }
  .field select { width: 100%; }
  .chart-box { height: 300px; }

  /* iOS Safari renderiza mal background-attachment: fixed */
  body { background-attachment: scroll; }

  /* cabecalho: nome + logo em cima, assinatura de fontes embaixo, sem estourar */
  .brand { gap: 8px; }
  .brand .mark { font-size: 19px; }
  .brand .tag {
    margin-left: 0; max-width: 100%; width: 100%;
    text-align: left; order: 3;
  }
  .card { padding: 14px 15px 12px; }
  .card-gdp { font-size: 24px; }
  .field-action { width: 100%; }
  .field-action .btn-generate { width: 100%; }
}


/* ---------- Rotulos de fonte + KPIs Factbook nos cards ---------- */
.card-src {
  font-size: 10px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); margin-top: -4px;
}
.card-src.fb-src { color: #c9a15a; }            /* dourado discreto p/ a 2a fonte */
.card-src.oecd-src { color: #8bd3c7; }          /* verde-agua p/ a 3a fonte (OECD) */
.card-foot.oecd { color: var(--ink-2); }
.card-foot.fb { color: var(--ink-2); }
.rankbadge {
  font-style: normal; font-size: 10px; color: var(--ink-2);
  background: rgba(255,255,255,.06); border: 1px solid var(--line);
  border-radius: 6px; padding: 1px 5px; margin-left: 5px;
  font-variant-numeric: tabular-nums;
}

.gini-missing {
  display: inline-block; padding: 4px 8px; border-radius: 8px; background: rgba(255,255,255,0.03);
  color: #f0f0f0; font-size: 12px; font-weight: 700; border: 1px solid rgba(255,255,255,0.04);
}

/* Small version badge shown on the site linking to the registro-final.md */
.version-badge {
  position: fixed; top: 12px; right: 12px; z-index: 14000;
  /* Dark blue tone for the version badge */
  background: #0b2a5e; color: #ffffff;
  border: 1px solid rgba(255,255,255,0.06); padding: 6px 12px; border-radius: 10px;
  font-size: 13px; text-decoration: none; font-weight: 800;
  box-shadow: 0 8px 30px rgba(11,42,94,0.24), 0 2px 6px rgba(0,0,0,0.6);
  text-shadow: none;
}
.version-badge:hover { opacity: 0.95; }
.version-badge:focus { outline: 2px solid rgba(255,255,255,0.35); outline-offset: 2px; }

/* Developer link next to the Sources tag */
.dev-link {
  margin-left: 10px; display: inline-block; font-size: 12px; color: var(--c1);
  text-decoration: none; font-weight: 600; padding: 6px 8px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.04); background: rgba(255,255,255,0.02);
}
.dev-link:hover { background: rgba(74,151,238,0.06); color: #fff; border-color: rgba(74,151,238,0.14); }



/* ---------- Botao verde "Generate", selo de PIB, aviso vermelho, cobertura ---------- */
.field-action { justify-content: flex-end; }
.btn-generate {
  background: linear-gradient(180deg, #12b981, #0ea371);
  color: #04140d; border: 1px solid rgba(255,255,255,.16);
  border-radius: 10px; padding: 0 20px; height: 40px;
  font-size: 14px; font-weight: 700; cursor: pointer; white-space: nowrap;
  box-shadow: 0 6px 16px rgba(14,163,113,.28);
  transition: filter .15s ease, transform .05s ease;
}
.btn-generate:hover { filter: brightness(1.08); }
.btn-generate:active { transform: translateY(1px); }

.gdp-rank { font-size: 12px; color: var(--ink-2); font-weight: 600; margin-top: -2px; }
.gdp-rank b { color: var(--ink); }
.gdp-rank .of { color: var(--muted); font-weight: 400; }

.missing-note {
  margin-top: 4px; font-size: 11px; line-height: 1.45; color: #ff8a99;
  background: rgba(246,70,93,.10); border: 1px solid rgba(246,70,93,.32);
  border-radius: 8px; padding: 6px 9px;
}

.coverage { margin: 4px 0 0; font-size: 11px; color: var(--muted); }
.coverage b { color: var(--ink-2); }
