/* Paleta do app Android (app/.../ui/theme/Color.kt): tema escuro "painel à noite" como padrão,
   com laranja da marca de destaque; tema claro segue o LightColorScheme do app. */
:root {
  --orange: #FF9800;
  --orange-dark: #C66900;
  --orange-light: #FFE0B2;
  --red: #E53935;
  --green: #4CAF50;
  --yellow: #FDD835;

  --bg: #121212;
  --surface: #1E1E1E;
  --surface-2: #2A2A2A;
  --text: #F2F2F2;
  --text-muted: #B0B0B0;
  --border: #333333;
  --accent: var(--orange);
  --on-accent: #1C1B1F;
  --good: var(--green);
  --bad: #EF5350;

  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #FFFBF5;
    --surface: #FFFFFF;
    --surface-2: #F0E9DE;
    --text: #1C1B1F;
    --text-muted: #5F5A52;
    --border: #E4DACB;
    --accent: var(--orange-dark);
    --on-accent: #FFFFFF;
    --good: #357A38;
    --bad: #C62828;
    --shadow: 0 10px 30px rgba(80, 50, 0, .12);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h2 { font-size: clamp(1.6rem, 3vw, 2.2rem); }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 20px; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 999px; border: 1px solid transparent;
  font: inherit; font-weight: 700; text-decoration: none; cursor: pointer;
  transition: transform .15s ease, background-color .15s ease, border-color .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:focus-visible, .tab:focus-visible { outline: 3px solid var(--orange-light); outline-offset: 2px; }
.btn-primary { background: var(--orange); color: #1C1B1F; }
.btn-primary:hover { background: #FFA726; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-small { padding: 8px 16px; font-size: .9rem; }
.btn-large { padding: 16px 28px; font-size: 1.05rem; }
.btn[disabled] { opacity: .6; cursor: progress; transform: none; }

/* ---------- Topo ---------- */
.topbar {
  position: sticky; top: 0; z-index: 1000;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; gap: 24px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 800; font-size: 1.15rem; }
.topnav { display: flex; gap: 20px; margin-left: auto; }
.topnav a { color: var(--text-muted); text-decoration: none; font-weight: 600; }
.topnav a:hover { color: var(--text); }
@media (max-width: 720px) {
  .topnav { display: none; }
  .topbar-inner .btn { margin-left: auto; }
}

/* ---------- Hero ---------- */
.hero { padding: 72px 0 56px; overflow: hidden; }
.hero-inner { display: grid; grid-template-columns: 1.25fr 1fr; gap: 48px; align-items: center; }
.eyebrow { color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: .85rem; }
.hero h1 { font-size: clamp(2rem, 4.6vw, 3.3rem); letter-spacing: -.02em; }
.accent { color: var(--accent); }
.lead { font-size: 1.15rem; color: var(--text-muted); max-width: 40em; }
.cta-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 28px 0; }
.hero-facts { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 10px 24px; color: var(--text-muted); font-size: .95rem; }
.hero-facts strong { color: var(--text); margin-right: 4px; }

.hero-art { display: flex; flex-direction: column; align-items: center; gap: 28px; }
.hero-icon { position: relative; }
.hero-icon img { width: min(220px, 50vw); height: auto; border-radius: 48px; box-shadow: var(--shadow); position: relative; z-index: 1; }
.pulse {
  position: absolute; inset: -18px; border-radius: 64px; border: 2px solid var(--orange);
  animation: pulse 2.4s ease-out infinite; opacity: 0;
}
@keyframes pulse {
  0% { transform: scale(.9); opacity: .7; }
  100% { transform: scale(1.15); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; } .btn:hover { transform: none; } }

.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 100%; max-width: 420px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 10px; text-align: center; }
.stat-value { display: block; font-size: 1.6rem; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.stat-value.good { color: var(--good); }
.stat-label { font-size: .8rem; color: var(--text-muted); }

@media (max-width: 860px) {
  .hero { padding-top: 40px; }
  .hero-inner { grid-template-columns: 1fr; }
  .hero-art { order: -1; }
  .hero-icon img { width: 140px; border-radius: 32px; }
  .pulse { border-radius: 44px; }
}

/* ---------- Seções ---------- */
.section { padding: 72px 0; }
.section-alt { background: var(--surface); border-block: 1px solid var(--border); }
.section-lead { color: var(--text-muted); font-size: 1.05rem; max-width: 42em; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.section-head p { margin: 0; }

.steps { list-style: none; padding: 0; margin: 32px 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.step { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.step p { color: var(--text-muted); margin: 0; }
.step-num {
  display: inline-grid; place-items: center; width: 36px; height: 36px; margin-bottom: 14px;
  border-radius: 50%; background: var(--orange); color: #1C1B1F; font-weight: 800;
}
@media (max-width: 860px) { .steps { grid-template-columns: 1fr; } }

.privacy {
  display: flex; gap: 16px; align-items: center;
  background: color-mix(in srgb, var(--orange) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--orange) 40%, transparent);
  border-radius: var(--radius); padding: 18px 22px; color: var(--text);
}
.privacy svg { color: var(--accent); flex: none; }
.privacy p { margin: 0; }

/* ---------- Tecnologia e comunidade ---------- */
.tech-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin: 32px 0 56px; }
@media (max-width: 860px) { .tech-grid { grid-template-columns: 1fr; } }
.tech-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; }
.tech-card p { color: var(--text-muted); margin: 0; }
.tech-icon {
  display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 16px; border-radius: 14px;
  background: color-mix(in srgb, var(--orange) 16%, transparent); color: var(--accent);
}
.community { display: grid; grid-template-columns: 1.1fr 1fr; gap: 40px; align-items: center; }
@media (max-width: 860px) { .community { grid-template-columns: 1fr; gap: 24px; } }
.community-copy p:last-child { color: var(--text-muted); margin: 0; }
.community-flow { list-style: none; padding: 0; margin: 0; position: relative; display: flex; flex-direction: column; gap: 18px; }
.community-flow::before { content: ""; position: absolute; left: 8px; top: 10px; bottom: 10px; width: 2px; background: var(--border); }
.community-flow li { display: flex; gap: 16px; align-items: flex-start; position: relative; }
.community-flow div { display: flex; flex-direction: column; }
.community-flow span:not(.flow-dot) { color: var(--text-muted); font-size: .95rem; }
.flow-dot { width: 18px; height: 18px; border-radius: 50%; flex: none; margin-top: 3px; border: 3px solid var(--surface); box-sizing: content-box; margin-left: -3px; }
.flow-dot.good { background: var(--good); }
.flow-dot.bad { background: var(--bad); }

/* ---------- Mapa ---------- */
.map-card { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); box-shadow: var(--shadow); }
#map { height: min(560px, 70vh); min-height: 360px; background: var(--surface-2); }
.map-status {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 500;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  padding: 6px 14px; border-radius: 999px; font-size: .9rem; box-shadow: var(--shadow);
  white-space: nowrap; max-width: calc(100% - 28px); overflow: hidden; text-overflow: ellipsis;
}
.legend { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-wrap: wrap; gap: 8px 22px; color: var(--text-muted); font-size: .9rem; }
.legend li { display: flex; align-items: center; gap: 8px; }
.dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
.sev-high { background: var(--red); }
.sev-medium { background: var(--orange); }
.sev-low { background: var(--yellow); }
.dot.ring { background: var(--orange); box-shadow: 0 0 0 2px #fff inset, 0 0 0 1px rgba(0,0,0,.4); }

/* Clusters no tom da marca em vez do verde/amarelo padrão do plugin. */
.cluster {
  display: grid; place-items: center; border-radius: 50%;
  background: color-mix(in srgb, var(--orange) 85%, transparent);
  color: #1C1B1F; font-weight: 800; font-size: .85rem;
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--orange) 30%, transparent);
}
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--surface); color: var(--text); }
.leaflet-popup-content { margin: 12px 16px; font: inherit; font-size: .92rem; }
.leaflet-popup-content strong { display: block; font-size: 1rem; margin-bottom: 4px; }
.popup-meta { color: var(--text-muted); }
.leaflet-container a.leaflet-popup-close-button { color: var(--text-muted); }
.leaflet-control-attribution { font-size: 11px; }

/* ---------- Ranking ---------- */
.tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); }
.tab {
  border: 0; background: transparent; color: var(--text-muted); font: inherit; font-weight: 700;
  padding: 8px 18px; border-radius: 999px; cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--orange); color: #1C1B1F; }
@media (max-width: 520px) {
  .tabs { display: flex; width: 100%; }
  .tab { flex: 1; padding: 8px 6px; font-size: .9rem; }
}
.metric-hint { color: var(--text-muted); margin: 12px 0 20px; font-size: .95rem; }

.my-city {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--orange);
  border-radius: var(--radius); padding: 16px 20px; margin-bottom: 24px;
}
.my-city-text { display: flex; flex-direction: column; }
.my-city-text span { color: var(--text-muted); }
.my-city-text .rank-big { color: var(--text); font-size: 1.1rem; }

.ranking-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.ranking-grid.single { grid-template-columns: 1fr; }
@media (max-width: 860px) { .ranking-grid { grid-template-columns: 1fr; } }
.ranking-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
.ranking-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.ranking-row { display: grid; grid-template-columns: 2.4em 1fr auto; gap: 4px 10px; align-items: center; padding: 6px 8px; border-radius: 10px; }
.ranking-row.mine { background: color-mix(in srgb, var(--orange) 16%, transparent); }
.ranking-pos { color: var(--text-muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.ranking-name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ranking-name small { color: var(--text-muted); font-weight: 500; }
.ranking-value { font-weight: 800; font-variant-numeric: tabular-nums; }
.ranking-bar { grid-column: 2 / 4; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.ranking-bar span { display: block; height: 100%; border-radius: 3px; }
.tone-bad .ranking-value { color: var(--bad); }
.tone-bad .ranking-bar span { background: var(--bad); }
.tone-good .ranking-value { color: var(--good); }
.tone-good .ranking-bar span { background: var(--good); }

.empty { text-align: center; color: var(--text-muted); padding: 40px 20px; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty .btn { margin-top: 12px; }
.skeleton { height: 38px; border-radius: 10px; background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Download ---------- */
.download { background: linear-gradient(135deg, var(--orange-dark), var(--orange)); color: #1C1B1F; }
.download-inner { display: flex; align-items: center; gap: 28px; }
.download-inner img { border-radius: 24px; box-shadow: 0 8px 24px rgba(0,0,0,.25); flex: none; }
.download h2 { color: #1C1B1F; }
.download p { margin: 0; font-size: 1.05rem; }
.download .btn-primary { background: #1C1B1F; color: var(--orange); margin-left: auto; flex: none; }
.download .btn-primary:hover { background: #000; }
@media (max-width: 860px) {
  .download-inner { flex-direction: column; text-align: center; }
  .download .btn-primary { margin-left: 0; }
}

/* ---------- Rodapé ---------- */
.footer { padding: 28px 0; color: var(--text-muted); font-size: .9rem; }
.footer-inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
