/* Flashcards BNCC - estilo do site de estudos
   Paleta escura por padrao, com tema claro alternavel. */

/* ---------- Integracao com o site ----------
   O app e embutido no site, que ja aplica o proprio reset e um padding no
   body para a navbar global. Estes overrides mantem o app isolado: escopo
   proprio de corpo, fundo e tipografia, sem afetar as demais paginas. */
body.fc-app {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  background-image: none;
  color: var(--text);
  line-height: 1.55;
  padding-top: 0;
}

[data-tema="claro"] body.fc-app { background: #eef2f9; }

body.fc-app main#main-content { padding: 0; }
body.fc-app h1, body.fc-app h2, body.fc-app h3 { color: var(--text); }
body.fc-app p { color: inherit; }
body.fc-app a { color: var(--brand); }

/* Envoltorio do app: largura maxima e respiro, independente do .container do site. */
.container-app { max-width: 1200px; margin: 0 auto; padding: 26px 20px 70px; }

/* O rodape e o breadcrumb ficam com o visual do site. */
body.fc-app .rodape { text-align: center; }
body.fc-app .rodape p { max-width: 78ch; margin: 0 auto; }
body.fc-app .rodape-links { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin-bottom: 10px; }
body.fc-app .rodape a { color: var(--brand); text-decoration: none; font-weight: 600; }
body.fc-app .rodape a:hover { text-decoration: underline; }

/* O breadcrumb do site ja tem estilo; so garantimos o espaçamento. */
body.fc-app .breadcrumbs { margin: 0 auto 4px; }

/* Banner de anuncios injetado pelos scripts do site: nao herda o tema do app. */
body.fc-app .ad-banner-wrap { margin: 16px auto 4px; }
body.fc-app .ad-banner-wrap .ad-banner-inner {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
}

/* O botao de CSV virou link: precisa de box-sizing proprio. */
a.icone-btn { display: grid; place-items: center; text-decoration: none; }

:root {
  --bg: #0b1120;
  --bg-2: #0f172a;
  --surface: #131c31;
  --surface-2: #1a2540;
  --line: #24314f;
  --text: #e8eefc;
  --muted: #93a3c0;
  --brand: #6366f1;
  --brand-2: #8b5cf6;
  --ok: #10b981;
  --warn: #f59e0b;
  --bad: #ef4444;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(2, 6, 23, .45);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

[data-tema="claro"] {
  --bg: #eef2f9;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f7fc;
  --line: #dde5f2;
  --text: #14203a;
  --muted: #5a6a86;
  --shadow: 0 8px 24px rgba(20, 32, 58, .10);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: inherit; }

/* ---------- Estrutura ---------- */
.topo {
  position: sticky; top: 0; z-index: 60;
  background: color-mix(in srgb, var(--bg-2) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}.topo-inner {
  max-width: 1200px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.marca { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; letter-spacing: -.02em; }
.marca .logo {
  width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  font-size: 19px; box-shadow: 0 4px 14px rgba(99, 102, 241, .4);
}
.marca small { display: block; font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: 0; }

.busca-topo { flex: 1; min-width: 220px; position: relative; }
.busca-topo input {
  width: 100%; padding: 10px 14px 10px 38px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--text);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.busca-topo input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(99, 102, 241, .16); }
.busca-topo::before {
  content: "⌕"; position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 19px; line-height: 1; pointer-events: none;
}

.acoes-topo { display: flex; gap: 8px; align-items: center; }
.icone-btn {
  width: 38px; height: 38px; border-radius: 11px; border: 1.5px solid var(--line);
  background: var(--surface); display: grid; place-items: center; font-size: 16px;
  transition: border-color .15s, transform .12s;
}
.icone-btn:hover { border-color: var(--brand); transform: translateY(-1px); }

/* O <main> nao leva layout: quem centraliza e o .container-app, para o app
   poder ser embutido numa pagina que ja tenha container proprio. */
body.fc-app main { max-width: none; margin: 0; padding: 0; }

/* ---------- Hero ---------- */
.fc-hero {
  border-radius: 22px; padding: 30px 32px; margin-bottom: 26px;
  background:
    radial-gradient(900px 380px at 12% -10%, rgba(99, 102, 241, .30), transparent 60%),
    radial-gradient(700px 340px at 92% 10%, rgba(14, 165, 233, .24), transparent 62%),
    var(--surface);
  border: 1px solid var(--line);
}
.fc-hero h1 { font-size: clamp(1.6rem, 3.4vw, 2.3rem); line-height: 1.15; letter-spacing: -.03em; }
.fc-hero p { color: var(--muted); margin-top: 9px; max-width: 66ch; }
.stats { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.stat {
  background: color-mix(in srgb, var(--bg-2) 70%, transparent);
  border: 1px solid var(--line); border-radius: 13px; padding: 10px 15px; min-width: 108px;
}
.stat b { display: block; font-size: 1.35rem; letter-spacing: -.02em; }
.stat span { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat.destaque b { color: var(--brand); }

/* ---------- Barra de progresso global ---------- */
.progresso-globalo {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 18px; margin-bottom: 26px;
}
.progresso-globalo .rot { font-weight: 600; font-size: 14px; }
.trilha {
  flex: 1 1 240px; min-width: 200px; height: 9px; border-radius: 999px;
  background: var(--surface-2); overflow: hidden; border: 1px solid var(--line);
}
.trilha > i {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--ok));
  transition: width .35s ease;
}
.pct { font-weight: 800; font-size: 14px; min-width: 42px; text-align: right; }

/* ---------- Secoes ---------- */
.rodape-secao {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 32px 0 16px;
}
.rodape-secao h2 { font-size: 1.2rem; letter-spacing: -.02em; }
.rodape-secao p { color: var(--muted); font-size: 13.5px; }

/* ---------- Cartoes de serie ---------- */
.grade-series {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
}
.cartao-serie {
  position: relative; overflow: hidden; text-align: left;
  background: var(--surface); border: 1.5px solid var(--line);
  border-radius: var(--radius); padding: 18px; width: 100%;
  display: flex; flex-direction: column; gap: 11px;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.cartao-serie:hover, .cartao-serie:focus-visible {
  transform: translateY(-3px); border-color: var(--cor, var(--brand));
  box-shadow: var(--shadow); outline: none;
}
.cartao-serie[aria-pressed="true"] { border-color: var(--cor, var(--brand)); background: var(--surface-2); }
.cartao-serie::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--cor, var(--brand));
}
.serie-topo { display: flex; align-items: center; gap: 12px; }
.serie-num {
  width: 46px; height: 46px; flex-shrink: 0; border-radius: 13px;
  display: grid; place-items: center; font-size: 1.25rem; font-weight: 800;
  background: color-mix(in srgb, var(--cor, var(--brand)) 20%, transparent);
  color: var(--cor, var(--brand)); border: 1.5px solid color-mix(in srgb, var(--cor, var(--brand)) 45%, transparent);
}
.serie-titulo { font-weight: 700; font-size: 1.02rem; letter-spacing: -.01em; }
.serie-sub { font-size: 12px; color: var(--muted); }
.serie-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.pill {
  font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted);
}
.pill.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); }
.pill.bom { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }

/* ---------- Materias de uma serie ---------- */
.painel-series {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin-bottom: 18px;
}
.painel-series > header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.painel-series h3 { font-size: 1.05rem; }
.painel-series .contagem { color: var(--muted); font-size: 13px; }
.grade-materias {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.cartao-materia {
  text-align: left; width: 100%; background: var(--surface-2);
  border: 1.5px solid var(--line); border-radius: 14px; padding: 14px;
  display: flex; flex-direction: column; gap: 9px;
  transition: transform .14s, border-color .14s;
}
.cartao-materia:hover { transform: translateY(-2px); border-color: var(--cor, var(--brand)); }
.materia-topo { display: flex; align-items: center; gap: 9px; }
.materia-emoji { font-size: 19px; }
.materia-nome { font-weight: 700; font-size: 14.5px; }
.materia-area { font-size: 11.5px; color: var(--muted); }
.materia-pe { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.mini-trilha { height: 6px; border-radius: 999px; background: var(--bg-2); overflow: hidden; }
.mini-trilha > i { display: block; height: 100%; background: var(--cor, var(--brand)); transition: width .3s; }

/* ---------- Resultados de busca ---------- */
.resultados { display: flex; flex-direction: column; gap: 9px; }
.resultado {
  width: 100%; text-align: left; background: var(--surface); border: 1.5px solid var(--line);
  border-radius: 13px; padding: 13px 15px; transition: border-color .14s, transform .14s;
}
.resultado:hover { border-color: var(--brand); transform: translateX(3px); }
.resultado .rq { font-weight: 600; font-size: 14.5px; }
.resultado .ra { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.resultado .rm { font-size: 11px; color: var(--muted); margin-top: 7px; display: flex; gap: 7px; align-items: center; }
mark { background: color-mix(in srgb, var(--warn) 40%, transparent); color: inherit; border-radius: 3px; padding: 0 2px; }

/* ---------- Jogador ---------- */
.jogador { max-width: 860px; margin: 0 auto; }
.jogador-topo { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.btn {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border-radius: 11px;
  font-size: 13.5px; font-weight: 600; border: 1.5px solid transparent; transition: all .15s;
}
.btn-primario { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; box-shadow: 0 4px 14px rgba(99, 102, 241, .3); }
.btn-primario:hover { transform: translateY(-1px); box-shadow: 0 7px 20px rgba(99, 102, 241, .4); }
.btn-neutro { background: var(--surface); border-color: var(--line); color: var(--text); }
.btn-neutro:hover { border-color: var(--brand); }
.btn-ok { background: color-mix(in srgb, var(--ok) 18%, transparent); border-color: color-mix(in srgb, var(--ok) 45%, transparent); color: var(--ok); }
.btn-ok:hover { background: color-mix(in srgb, var(--ok) 28%, transparent); }
.btn-bad { background: color-mix(in srgb, var(--bad) 15%, transparent); border-color: color-mix(in srgb, var(--bad) 45%, transparent); color: var(--bad); }
.btn-bad:hover { background: color-mix(in srgb, var(--bad) 25%, transparent); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none !important; box-shadow: none; }

.barra-jogo { margin-bottom: 18px; }
.barra-jogo .trilha { height: 7px; }
.jogo-info { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); font-weight: 600; margin-bottom: 6px; }

.cartao3d { perspective: 1600px; margin-bottom: 18px; }
.cartao3d-inner {
  position: relative; transform-style: preserve-3d;
  transition: transform .5s cubic-bezier(.2, .7, .3, 1);
  min-height: 320px; cursor: pointer;
}
.cartao3d.virada .cartao3d-inner { transform: rotateY(180deg); }
.cara {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 20px; border: 1.5px solid var(--line); padding: 30px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; text-align: center; overflow: auto;
  background: var(--surface);
}
.cara-frente { background: linear-gradient(160deg, color-mix(in srgb, var(--cor, var(--brand)) 14%, var(--surface)), var(--surface)); }
.cara-verso { transform: rotateY(180deg); background: linear-gradient(160deg, color-mix(in srgb, var(--ok) 15%, var(--surface)), var(--surface)); }
.cara-tag {
  position: absolute; top: 14px; left: 16px; font-size: 10.5px; font-weight: 800;
  letter-spacing: .09em; text-transform: uppercase; color: var(--muted);
}
.cara-texto { font-size: clamp(1.05rem, 2.4vw, 1.45rem); font-weight: 600; line-height: 1.42; overflow-wrap: break-word; max-width: 34ch; }
.cara-verso .cara-texto { color: var(--ok); }
.cara-dica { position: absolute; bottom: 14px; font-size: 11.5px; color: var(--muted); }
.nivel-badge {
  position: absolute; top: 14px; right: 16px; font-size: 10.5px; font-weight: 800;
  padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted);
}

.controles { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.controles .btn { padding: 12px 22px; }
.atalhos { text-align: center; font-size: 12px; color: var(--muted); margin-top: 14px; }
.atalhos kbd {
  font-family: ui-monospace, Consolas, monospace; font-size: 11px; padding: 2px 6px;
  border-radius: 5px; background: var(--surface-2); border: 1px solid var(--line); margin: 0 2px;
}

.filtros-jogo { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.chip {
  padding: 6px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--muted);
}
.chip[aria-pressed="true"] { border-color: var(--brand); color: var(--brand); background: color-mix(in srgb, var(--brand) 12%, transparent); }

/* ---------- Modal ---------- */
.modal-fundo {
  position: fixed; inset: 0; z-index: 200; background: rgba(2, 6, 23, .68);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-fundo.aberto { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  max-width: 520px; width: 100%; padding: 26px; box-shadow: var(--shadow);
}
.modal h3 { font-size: 1.15rem; margin-bottom: 10px; }
.modal p { color: var(--muted); font-size: 14px; }
.modal-acoes { display: flex; gap: 9px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }

/* ---------- Estado vazio ---------- */
.vazio {
  text-align: center; padding: 44px 20px; color: var(--muted);
  border: 1.5px dashed var(--line); border-radius: var(--radius);
}
.vazio .big { font-size: 2.4rem; display: block; margin-bottom: 10px; opacity: .55; }

/* ---------- Rodape ---------- */
.rodape {
  border-top: 1px solid var(--line); background: var(--bg-2);
  padding: 28px 20px; text-align: center; color: var(--muted); font-size: 13px;
}
.rodape a { color: var(--brand); text-decoration: none; font-weight: 600; }
.rodape a:hover { text-decoration: underline; }
.rodape-links { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; margin-bottom: 10px; }

.pular {
  position: absolute; left: -9999px; top: 0; z-index: 999;
  background: var(--brand); color: #fff; padding: 10px 18px; border-radius: 0 0 10px 0; font-weight: 600;
}
.pular:focus { left: 0; }

.carregando { text-align: center; padding: 30px; color: var(--muted); font-size: 14px; }
.erro-carga {
  background: color-mix(in srgb, var(--bad) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent);
  color: var(--bad); padding: 14px 16px; border-radius: 12px; font-size: 13.5px;
}
.erro-carga code { background: rgba(0, 0, 0, .18); padding: 2px 6px; border-radius: 5px; font-size: 12px; }

.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Impressao ---------- */
@media print {
  .topo, .rodape, .controles, .atalhos, .filtros-jogo, .btn, .fc-hero, .acoes-topo { display: none !important; }
  body { background: #fff; color: #000; }
  main { max-width: none; padding: 0; }
  .cara { border: 1px solid #000; position: static; transform: none !important; page-break-inside: avoid; }
  .cartao3d-inner { transform: none !important; }
}
