:root {
  --green: #059669;
  --green-dark: #047857;
  --green-light: #ecfdf5;
  /* Verde de FUNDO com texto branco. O --green (#059669) da 3.77:1 com branco,
     abaixo do minimo 4.5:1 do WCAG AA para texto normal; #047857 da 5.48:1.
     Use --green-bg em botoes/chips/badges com texto branco. */
  --green-bg: #047857;
  --green-bg-hover: #036e4f;
  --amber: #f59e0b;
  --ink: #0f172a;
  /* Texto secundario. #64748b dava 4.34:1 sobre o fundo cinza dos botoes
     desabilitados (#f1f5f9), abaixo do minimo 4.5:1; #5b6b7f da 4.97:1 e
     continua legivel como texto de apoio. */
  --muted: #5b6b7f;
  --line: #e2e8f0;
  --bg: #f8fafc;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 16px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--green-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.site-header .container {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 18px;
  color: var(--ink);
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }

.brand .logo,
.brand img.logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: block;
  flex: none;
  object-fit: contain;
  background: #fff;
}

.header-search {
  flex: 1;
  max-width: 460px;
  margin-left: auto;
  position: relative;
}

.header-search input {
  width: 100%;
  height: 42px;
  padding: 0 40px 0 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.header-search input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.15);
}
.header-search .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

/* Hero */
.hero {
  padding: 40px 0 24px;
  text-align: center;
}
.hero h1 {
  font-size: clamp(26px, 4vw, 38px);
  margin: 0 0 10px;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.hero p {
  margin: 0 auto;
  max-width: 640px;
  color: var(--muted);
  font-size: 16px;
}

.badge-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge.age { color: #b91c1c; border-color: #fecaca; background: #fef2f2; }
.badge.safe { color: var(--green-dark); border-color: #a7f3d0; background: var(--green-light); }

.data-note {
  max-width: 760px;
  margin: 16px auto 0;
  font-size: 13px;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  border-radius: 8px;
  padding: 10px 14px;
  text-align: left;
}

/* Filters */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 18px;
  flex-wrap: wrap;
}
.toolbar .result-count {
  color: var(--muted);
  font-size: 14px;
  margin-right: auto;
}
.chips { display: flex; gap: 8px; flex-wrap: wrap; }

/* titulo de secao (h2) que agrupa os cards - mantem a hierarquia h1 > h2 > h3 */
.section-title {
  font-size: 20px;
  margin: 4px 0 14px;
  letter-spacing: -0.01em;
}
.chip {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.chip:hover { border-color: var(--green); color: var(--green-dark); }
.chip.active { background: var(--green-bg); border-color: var(--green-bg); color: #fff; }

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform .15s, box-shadow .15s;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 8px 28px rgba(15, 23, 42, 0.12); }

.card-top { display: flex; gap: 12px; align-items: flex-start; }

.app-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  flex: none;
  display: block;
  object-fit: contain;
  background: #f1f5f9;
  border: 1px solid var(--line);
  padding: 2px;
}

.card-meta { flex: 1; min-width: 0; }
.card-meta h3 { margin: 0; font-size: 17px; line-height: 1.2; }
.card-meta .category { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card-meta .site-line {
  font-size: 12px;
  font-weight: 600;
  color: var(--green-dark);
  margin-top: 6px;
  word-break: break-all;
}

.rating { display: flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; color: var(--ink); margin-top: 6px; }
.rating .stars { color: var(--amber); letter-spacing: 1px; }
.rating .count { color: var(--muted); font-weight: 500; }

.bonus {
  background: var(--green-light);
  border: 1px solid #a7f3d0;
  color: var(--green-dark);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 700;
}

.features { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: #f1f5f9;
  padding: 3px 8px;
  border-radius: 6px;
}

.card-actions { display: flex; gap: 10px; margin-top: auto; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--green-bg); color: #fff; }
.btn-primary:hover { background: var(--green-bg-hover); }
.btn-ghost { background: #fff; color: var(--ink); border-color: var(--line); flex: none; }
.btn-ghost:hover { border-color: var(--green); color: var(--green-dark); }
.btn-muted {
  background: #f1f5f9;
  color: var(--muted);
  border-color: var(--line);
  cursor: default;
  font-weight: 600;
}
.btn-block { width: 100%; }

.site-badge {
  background: var(--green-light);
  border: 1px solid #a7f3d0;
  color: var(--green-dark);
  border-radius: 9px;
  padding: 10px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  word-break: break-all;
}

.icon-preview {
  display: block;
  width: 96px;
  height: 96px;
  margin: 0 auto;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #f8fafc;
  padding: 4px;
}

.muted-note { margin: 0; font-size: 14px; color: var(--muted); }

/* Lista de apps relacionados (sidebar do detalhe) */
.app-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.app-list li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.app-list img { width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--line); background: #f8fafc; flex: none; }
.app-list a { font-weight: 600; color: var(--ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-list .val { margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; }

/* Ranking na home: os dois paineis ficam lado a lado no desktop.
   O margin-top/bottom em forma longa e proposital: a forma curta
   (margin: 8px 0 40px) zeraria o "auto" horizontal herdado de .container e o
   bloco ficaria colado na esquerda. */
.ranking { margin-top: 8px; margin-bottom: 40px; margin-left: auto; margin-right: auto; }
.ranking h2 { font-size: 20px; margin: 0 0 6px; }
.rank-panels { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin-top: 14px; }
.rank-panels > .panel { flex: 1 1 340px; margin: 0; min-width: 0; }
.rank-panels > .panel .rank-list { max-height: 520px; overflow-y: auto; }
.ranking h3 { margin: 0 0 10px; font-size: 15px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rank-list li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.rank-list img { width: 24px; height: 24px; border-radius: 6px; border: 1px solid var(--line); background: #f8fafc; flex: none; }
.rank-list .pos { flex: none; width: 26px; color: var(--muted); font-variant-numeric: tabular-nums; font-weight: 700; font-size: 12px; }
.rank-list a { font-weight: 600; color: var(--ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-list .val { margin-left: auto; color: var(--muted); font-size: 11px; white-space: nowrap; }

/* FAQ (details/summary, sem JS).
   Mesmo cuidado do .ranking: margem vertical em forma longa, senao a forma
   curta zeraria o "auto" horizontal de .container e o bloco ficaria a esquerda. */
.faq { margin-top: 32px; margin-bottom: 8px; margin-left: auto; margin-right: auto; }
.faq h2 { font-size: 20px; margin: 0 0 12px; }
.faq-list { display: flex; flex-direction: column; gap: 8px; }
.faq-item {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.faq-item summary {
  cursor: pointer;
  padding: 14px 16px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: "+";
  margin-left: auto;
  font-size: 20px;
  line-height: 1;
  color: var(--green);
  font-weight: 700;
}
/* hífen en-dash: usar a entidade CSS evita depender de encoding no arquivo */
.faq-item[open] summary::after { content: "\2013"; }
.faq-item summary:hover { color: var(--green-dark); }
.faq-item summary:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; }
.faq-answer { padding: 0 16px 14px; }
.faq-answer p { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.6; }

/* Botao "voltar ao topo" - aparece no mobile depois de rolar a pagina */
.back-to-top {
  position: fixed;
  right: 16px;
  bottom: 20px;
  z-index: 55;
  width: 44px;
  height: 44px;
  display: none;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: var(--green-bg);
  color: #fff;
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.35);
  cursor: pointer;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .18s ease, transform .18s ease, background .15s ease;
}
.back-to-top:hover { background: var(--green-bg-hover); }
.back-to-top:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.back-to-top.is-visible { opacity: 1; transform: translateY(0); }

@media (max-width: 720px) {
  .back-to-top { display: flex; }
}

/* na pagina de app a barra de download ocupa o rodape: o botao sobe para nao
   ficar por cima dela */
@media (max-width: 720px) {
  body.has-sticky-download .back-to-top { bottom: 84px; }
}

@media (prefers-reduced-motion: reduce) {
  .back-to-top { transition: none; }
}

.no-results {
  display: none;
  text-align: center;
  padding: 48px 16px;
  color: var(--muted);
  font-size: 15px;
}

/* Detail page */
.detail-head { background: #fff; border-bottom: 1px solid var(--line); padding: 28px 0; }
.detail-head .container { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.detail-head .app-icon { width: 84px; height: 84px; border-radius: 18px; padding: 4px; }
.detail-title h1 { margin: 0; font-size: clamp(24px, 3vw, 32px); }
.detail-title .category { color: var(--muted); font-size: 14px; margin-top: 4px; }

.detail-body { padding: 24px 0 48px; display: grid; grid-template-columns: 2fr 1fr; gap: 24px; align-items: start; }

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.panel h2 { margin: 0 0 12px; font-size: 18px; }

.sidebar { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 80px; }

.fact-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.fact-list li { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.fact-list .k { color: var(--muted); }
.fact-list .v { font-weight: 700; text-align: right; }

.disclaimer {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
}

.breadcrumb { font-size: 13px; color: var(--muted); margin: 16px 0 0; }
.breadcrumb a { color: var(--muted); }

/* Footer */
.site-footer {
  border-top: 1px solid var(--line);
  background: #fff;
  padding: 32px 0;
  margin-top: 24px;
}
.site-footer .container { text-align: center; color: var(--muted); font-size: 13px; }
.site-footer .foot-links { display: flex; justify-content: center; gap: 18px; margin-bottom: 12px; flex-wrap: wrap; }
.site-footer a { color: var(--muted); }

/* Responsive */
@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .detail-body { grid-template-columns: 1fr; }
  .sidebar { position: static; }
}

@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
  .site-header .container { flex-wrap: wrap; height: auto; padding: 10px 16px; }
  .header-search { order: 3; flex-basis: 100%; max-width: none; }
  .detail-head .container { justify-content: center; text-align: center; }
}

/* Barra de download fixa no rodape - somente mobile.
   Fica visivel o tempo todo para o CTA principal estar sempre a um toque. */
.sticky-download { display: none; }
body.has-sticky-download { padding-bottom: 0; }

@media (max-width: 720px) {
  .sticky-download {
    display: flex;
    align-items: center;
    gap: 10px;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60; /* acima do header sticky (50) e do sidebar */
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.08);
  }

  .sticky-info { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
  .sticky-info img {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #f8fafc;
    flex: none;
  }
  .sticky-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
  .sticky-text strong {
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .sticky-text small {
    font-size: 11px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sticky-btn { flex: none; height: 44px; padding: 0 18px; white-space: nowrap; }

  /* nada de conteudo pode ficar escondido atras da barra */
  body.has-sticky-download { padding-bottom: 76px; }
  .site-footer { margin-bottom: 0; }
}

@media (max-width: 380px) {
  /* telas estreitas: o CTA ocupa a linha inteira e o nome do app sai */
  .sticky-text { display: none; }
  .sticky-btn { width: 100%; }
}
