/* Guía Pequeños Inventores — área de miembros (PWA)
   Identidade das fichas: violeta -> azul, amarelo nos números, Baloo 2 + Nunito. */

@font-face { font-family: "Baloo 2"; src: url(/fonts/baloo2.woff2) format("woff2"); font-weight: 400 800; font-display: swap; }
@font-face { font-family: "Nunito"; src: url(/fonts/nunito.woff2) format("woff2"); font-weight: 200 1000; font-display: swap; }

:root {
  --violeta: #6c3cf0;
  --violeta-2: #5a25c9;
  --violeta-3: #efe9ff;
  --azul: #4f7cff;
  --amarelo: #ffc928;
  --tinta: #1d1640;
  --suave: #6b6785;
  --fundo: #f5f3fc;
  --card: #fff;
  --linha: #e7e2f5;
  --erro: #c62d42;
  --erro-fundo: #fdecef;
  --raio: 18px;
  --sombra: 0 1px 2px rgba(40, 20, 110, .06), 0 6px 18px rgba(40, 20, 110, .08);
  --cabeca: "Baloo 2", "Nunito", system-ui, sans-serif;
  --corpo: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --topo-h: 60px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--corpo);
  color: var(--tinta);
  background: var(--fundo);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.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; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 3px solid var(--amarelo); outline-offset: 2px; }

/* ============ LOGIN ============ */
.login {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(24px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
  background:
    radial-gradient(90% 60% at 10% 0%, #e4dcff 0%, transparent 60%),
    radial-gradient(80% 60% at 100% 100%, #dbe6ff 0%, transparent 60%),
    #f3f1fc;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border-radius: 24px;
  padding: 28px 22px 26px;
  box-shadow: 0 2px 4px rgba(40, 20, 110, .05), 0 18px 48px rgba(40, 20, 110, .12);
  text-align: center;
}
.btn-instalar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 18px;
  margin-bottom: 22px;
  border: 0;
  border-radius: 12px;
  background: var(--violeta);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
}
.btn-instalar:active { background: var(--violeta-2); }
.btn-instalar svg { width: 20px; height: 20px; }
.login-logo {
  width: 88px;
  height: 88px;
  margin: 0 auto 14px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  background: radial-gradient(120% 120% at 20% 10%, #7d8bff 0%, #7b4dff 52%, #5a25c9 100%);
  box-shadow: 0 8px 20px rgba(108, 60, 240, .3);
}
.login-titulo {
  margin: 0;
  font-family: var(--cabeca);
  font-weight: 800;
  font-size: 27px;
  line-height: 1.1;
  letter-spacing: -.01em;
}
.login-sub { margin: 8px 0 22px; color: var(--suave); font-size: 16px; }

.campo {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 54px;
  padding: 0 14px;
  border: 1.5px solid var(--linha);
  border-radius: 14px;
  background: #f7f6fb;
  color: var(--suave);
  transition: border-color .15s, background .15s;
}
.campo:focus-within { border-color: var(--violeta); background: #fff; color: var(--violeta); }
.campo input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 17px; /* >= 16px: o iOS não dá zoom ao focar */
  color: var(--tinta);
  outline: none;
  padding: 14px 0;
}
.campo input::placeholder { color: #8f8ba6; }
.login-dica { margin: 8px 2px 0; font-size: 13.5px; color: var(--suave); text-align: left; }

.aviso {
  margin: 14px 0 0;
  padding: 11px 13px;
  border-radius: 12px;
  background: var(--erro-fundo);
  color: var(--erro);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.4;
  text-align: left;
}
.btn-entrar {
  width: 100%;
  min-height: 54px;
  margin-top: 18px;
  border: 0;
  border-radius: 14px;
  background: var(--violeta);
  color: #fff;
  font-family: var(--cabeca);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: .01em;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(108, 60, 240, .32);
  transition: background .15s, transform .1s;
}
.btn-entrar:active { background: var(--violeta-2); transform: translateY(1px); }
.btn-entrar[disabled] { opacity: .7; cursor: progress; }

/* ============ TOPO ============ */
.app { min-height: 100vh; min-height: 100dvh; }
.topo {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  height: calc(var(--topo-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0 14px;
  background: linear-gradient(100deg, var(--violeta-2) 0%, var(--violeta) 55%, #7b5cff 100%);
  color: #fff;
  box-shadow: 0 2px 12px rgba(60, 20, 160, .18);
}
.topo-marca {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}
.topo-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .95);
  flex: none;
}
.topo-nome, .topo-titulo {
  font-family: var(--cabeca);
  font-weight: 800;
  font-size: 19px;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}
.topo-titulo { flex: 1; min-width: 0; }
.topo-voltar {
  width: 40px;
  height: 40px;
  margin-left: -6px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.topo-voltar svg { width: 26px; height: 26px; stroke-width: 2.4; }
.topo-acoes { margin-left: auto; display: flex; gap: 8px; }
.topo-btn {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 12px;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.topo-btn:active, .topo-voltar:active { background: rgba(255, 255, 255, .26); }

/* ============ CONTEÚDO ============ */
.conteudo {
  max-width: 980px;
  margin: 0 auto;
  padding: 20px 16px calc(32px + env(safe-area-inset-bottom));
  outline: none;
}
.titulo-sec {
  margin: 0 0 14px;
  font-family: var(--cabeca);
  font-weight: 800;
  font-size: 23px;
  line-height: 1.15;
}

/* --- home: cards de módulo (grade de 2, como no app de referência) --- */
.modulos {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.modulo {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: var(--raio);
  overflow: hidden;
  box-shadow: var(--sombra);
  color: inherit;
  text-decoration: none;
  transition: transform .12s;
}
.modulo:active { transform: scale(.985); }
/* arte do card: a capa do módulo, ou as capas dos itens em leque enquanto ela não existe */
.modulo-arte { position: relative; aspect-ratio: 4 / 5; overflow: hidden; background: var(--violeta-3); }
.modulo-arte img { width: 100%; height: 100%; object-fit: cover; }
.modulo-rodape {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 13px 14px;
  margin-top: auto;
}
.modulo-nome {
  flex: 1;
  font-weight: 800;
  font-size: 15.5px;
  line-height: 1.25;
  color: var(--violeta-2);
}
.seta {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--violeta-3);
  color: var(--violeta);
  flex: none;
}
.seta svg { width: 17px; height: 17px; stroke-width: 2.6; }

/* leque: --d é a distância ao centro (-1, -0.5, 0, 0.5, 1…), --s a escala; vêm do app.js */
.modulo-arte.leque {
  --passo: 27%;
  --largura: 50%;
  background:
    radial-gradient(80% 60% at 50% 105%, rgba(255, 201, 40, .38) 0%, transparent 65%),
    linear-gradient(140deg, #4f7cff 0%, #6c3cf0 55%, #8a4fff 100%);
}
.modulo-arte.leque[data-n="3"] { --passo: 25%; --largura: 46%; }
.modulo-arte.leque img {
  position: absolute;
  top: 50%;
  left: calc(50% + var(--d) * var(--passo));
  width: var(--largura);
  height: auto; /* sem isso o atributo height="509" do <img> vence o aspect-ratio */
  aspect-ratio: 360 / 509;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(20, 5, 70, .38);
  transform: translate(-50%, -50%) rotate(calc(var(--d) * 9deg)) scale(var(--s));
}

/* --- módulo: grade de itens --- */
.itens {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px 12px;
}
.item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: inherit;
  text-decoration: none;
}
.item-capa {
  aspect-ratio: 360 / 509;
  border-radius: 12px;
  overflow: hidden;
  background: var(--violeta-3);
  box-shadow: var(--sombra);
  transition: transform .12s;
}
.item:active .item-capa { transform: scale(.97); }
.item-capa img { width: 100%; height: 100%; object-fit: cover; }
.item-nome {
  font-weight: 800;
  font-size: 13.5px;
  line-height: 1.25;
  text-align: center;
  color: var(--violeta-2);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* módulo com poucos itens (Kit de Inicio): 2 por linha, sem esticar no desktop */
.itens.poucos { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 460px; }
.itens.poucos .item-nome { font-size: 15px; }

@media (min-width: 560px) {
  .modulos { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
  .itens { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px 16px; }
  .item-nome { font-size: 14.5px; }
}
@media (min-width: 820px) {
  .itens { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

/* ============ FOLHA iOS ============ */
.folha { position: fixed; inset: 0; z-index: 50; display: grid; align-items: end; }
.folha-fundo { position: absolute; inset: 0; background: rgba(20, 10, 50, .45); }
.folha-caixa {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 22px calc(22px + env(safe-area-inset-bottom));
  border-radius: 24px 24px 0 0;
  background: #fff;
  animation: sobe .22s ease-out;
}
.folha-caixa h2 { margin: 0 0 12px; font-family: var(--cabeca); font-weight: 800; font-size: 22px; }
.folha-caixa ol { margin: 0; padding-left: 22px; font-size: 16.5px; line-height: 1.6; }
.folha-caixa li { margin-bottom: 6px; }
.ico-inline { width: 20px; height: 20px; vertical-align: -4px; color: #0a84ff; }
@keyframes sobe { from { transform: translateY(40px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
