/* ==========================================================================
   MathX — Landing page
   Reaproveita os mesmos tokens do app (app.css) para manter a identidade.
   ========================================================================== */

/* Tokens base vem de tokens.css. A landing engrossa linhas e sombras de
   proposito: e' uma pagina de apresentacao, nao a interface de trabalho. */
:root {
  --line: rgba(15, 23, 42, 0.09);
  --line-strong: rgba(15, 23, 42, 0.14);
  --shadow-md: 0 4px 16px -4px rgba(15, 23, 42, 0.08), 0 2px 8px -2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 44px -12px rgba(15, 23, 42, 0.14), 0 6px 16px -4px rgba(15, 23, 42, 0.06);
  --grid-line: rgba(15, 23, 42, 0.07);
  --glass: rgba(255, 255, 255, 0.82);
  --maxw: 1140px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

html[data-theme="dark"] {
  --grid-line: rgba(255, 255, 255, 0.06);
  --glass: rgba(11, 12, 16, 0.78);
  --shadow-md: 0 4px 16px -4px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 20px 44px -12px rgba(0, 0, 0, 0.6);
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', 'DM Sans', system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { line-height: 1.2; letter-spacing: -0.02em; }
em { font-style: normal; color: var(--accent); }

.skip-link {
  position: absolute;
  left: -9999px;
}
.skip-link:focus {
  left: 12px;
  top: 12px;
  z-index: 99;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
}

/* ---------------------------------------------------------------- Barra */

.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 24px;
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.nav.scrolled {
  border-bottom-color: var(--line);
  box-shadow: var(--shadow-sm);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  flex: 0 0 auto;
}

.mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.nav-links a {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  transition: color 0.15s ease, background-color 0.15s ease;
}

.nav-links a:hover { color: var(--text); background: var(--hover); }

.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--raised);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.theme-toggle:hover { border-color: var(--line-strong); background: var(--hover); }

/* ---------------------------------------------------------------- Botões */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-lg { padding: 13px 26px; font-size: 15px; border-radius: var(--radius-md); }

.btn-solid {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-solid:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-outline {
  background: var(--raised);
  border-color: var(--line-strong);
  color: var(--text);
}
.btn-outline:hover { background: var(--hover); border-color: var(--accent); transform: translateY(-1px); }

.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { background: var(--hover); border-color: var(--line-strong); }

.btn:focus-visible, .theme-toggle:focus-visible, .nav-links a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------------------------------------------------------------- Hero */

.eyebrow {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 72px 24px 56px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 56px;
}

.hero h1 {
  margin: 14px 0 0;
  font-size: clamp(34px, 4.6vw, 54px);
  font-weight: 800;
}

.lede {
  margin-top: 18px;
  max-width: 46ch;
  font-size: 16.5px;
  color: var(--muted);
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 28px;
}

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

/* Entrar no hero: os campos ficam a' vista na landing, sem um botao no meio
   do caminho. Cabe na coluna de texto sem competir com o titulo, por isso o
   cartao e' estreito e as duas caixas dividem a linha. */
.hero-auth {
  max-width: 460px;
  margin-top: 28px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.hero-auth[hidden] { display: none; }

.hero-auth-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.hero-auth label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.hero-auth input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--card-soft);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.hero-auth input::placeholder { color: var(--muted); opacity: 0.7; }

.hero-auth input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.hero-auth-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.hero-auth-actions .btn { flex: 0 0 auto; }

/* O botao do Google e' um iframe de largura propria; sem Google configurado o
   container fica vazio e nao deve abrir buraco na linha. */
.hero-auth .google-login-container { margin: 0; }
.hero-auth .google-login-container:empty { display: none; }

.hero-auth-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 600;
}

.hero-auth-links a { color: var(--accent); }
.hero-auth-links a:hover { text-decoration: underline; }

.hero-auth .auth-message { margin-top: 12px; font-size: 12.5px; }

/* Ilustração do hero */

.hero-visual { position: relative; display: grid; gap: 14px; }

.visual-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-lg);
}

.visual-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.visual-title { font-size: 13px; font-weight: 700; }

.visual-tag {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-light);
  border-radius: var(--radius-full);
  padding: 4px 9px;
}

.visual-graph {
  display: block;
  width: 100%;
  height: auto;
  background: var(--card-soft);
  border-radius: var(--radius-md);
}

.visual-graph .grid path { stroke: var(--grid-line); stroke-width: 1; fill: none; }
.visual-graph .axis { stroke: var(--muted); stroke-width: 1.2; fill: none; opacity: 0.7; }
.visual-graph .curve { stroke: url(#curve); stroke-width: 3; fill: none; stroke-linecap: round; }
.visual-graph .pt { fill: var(--accent); }
.visual-graph .vertex { fill: none; stroke: var(--warning); stroke-width: 2.5; }

.visual-formula {
  margin-top: 12px;
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 13.5px;
  font-weight: 500;
  text-align: center;
}

.visual-hint { margin-top: 4px; text-align: center; font-size: 10.5px; color: var(--muted); }

.visual-chat { display: grid; gap: 8px; justify-items: end; }

.bubble {
  max-width: 90%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
  background: var(--accent-light);
  font-size: 13px;
  box-shadow: var(--shadow-sm);
}

.bubble.bot {
  justify-self: start;
  background: var(--surface);
  color: var(--muted);
  line-height: 1.8;
}

.bubble.bot strong { color: var(--text); }

/* ---------------------------------------------------------------- Números */

.stats {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 24px 64px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat {
  display: grid;
  gap: 2px;
  justify-items: center;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 22px 14px;
}

.stat strong {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--accent);
}

.stat span { font-size: 12.5px; color: var(--muted); }

/* ---------------------------------------------------------------- Seções */

.section { padding: 72px 24px; }
.section-alt { background: var(--surface); border-block: 1px solid var(--line); }

.section-head {
  max-width: 660px;
  margin: 0 auto 44px;
  text-align: center;
}

.section-head h2 {
  margin-top: 12px;
  font-size: clamp(26px, 3.2vw, 36px);
  font-weight: 800;
}

.section-head p { margin-top: 14px; color: var(--muted); font-size: 15.5px; }

.cards {
  max-width: var(--maxw);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.cards-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); max-width: 900px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  transition: border-color 0.18s var(--ease), transform 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.section-alt .card { background: var(--bg); }

.card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.card-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--accent-light);
  color: var(--accent);
  font-size: 19px;
  margin-bottom: 14px;
}

.card h3 { font-size: 16px; font-weight: 700; }
.card p { margin-top: 8px; font-size: 13.5px; color: var(--muted); }

/* ---------------------------------------------------------------- Passos */

.steps {
  max-width: var(--maxw);
  margin: 0 auto;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  counter-reset: step;
}

.steps li {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 26px 22px;
}

.step-n {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 14px;
}

.steps h3 { font-size: 16.5px; font-weight: 700; }
.steps p { margin-top: 8px; font-size: 13.5px; color: var(--muted); }

/* ---------------------------------------------------------------- Teoria */

.theory-grid {
  max-width: var(--maxw);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.theory {
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 18px 20px;
}

.theory h4 { font-size: 14.5px; font-weight: 700; }
.theory p { margin-top: 6px; font-size: 13px; color: var(--muted); }

/* ---------------------------------------------------------------- Split */

.split {
  max-width: var(--maxw);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  gap: 52px;
}

.split-copy h2 { margin-top: 12px; font-size: clamp(26px, 3vw, 34px); font-weight: 800; }
.split-copy > p { margin-top: 14px; color: var(--muted); font-size: 15.5px; }

.checks { margin-top: 22px; list-style: none; display: grid; gap: 11px; }

.checks li {
  position: relative;
  padding-left: 28px;
  font-size: 14px;
  color: var(--muted);
}

.checks li::before {
  content: "✓";
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.mini-panel {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: grid;
  gap: 15px;
  box-shadow: var(--shadow-lg);
}

.mini-row {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 12px;
  font-size: 12.5px;
  color: var(--muted);
}

.mini-row b { text-align: right; font-size: 12px; color: var(--text); }

.bar { height: 7px; border-radius: var(--radius-full); background: var(--hover); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.bar.warn i { background: var(--warning); }

/* ---------------------------------------------------------------- CTA final */

.final-cta {
  max-width: 760px;
  margin: 0 auto;
  padding: 84px 24px 96px;
  text-align: center;
}

.final-cta h2 { font-size: clamp(28px, 3.6vw, 40px); font-weight: 800; }
.final-cta p { margin-top: 14px; color: var(--muted); font-size: 16px; }
.final-cta .hero-cta { justify-content: center; }

/* ---------------------------------------------------------------- Rodapé */

.footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 26px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.footer-brand { display: flex; align-items: center; gap: 11px; }
.footer-brand strong { display: block; font-size: 14.5px; }
.footer-brand small { font-size: 11.5px; color: var(--muted); }

.footer-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
  font-size: 12.5px;
  color: var(--muted);
}

.footer-meta a { font-weight: 600; color: var(--accent); }
.footer-meta a:hover { text-decoration: underline; }

/* ------------------------------------------- Tela de entrar / criar conta */

/* Quando a tela de conta esta' aberta, a landing sai de cena por inteiro. Era
   esse o incomodo do modal antigo no app: um painel pequeno com a aplicacao
   inteira viva atras. Aqui o login e' a unica coisa na tela. */
body.auth-open { overflow: hidden; }
body.auth-open > .nav,
body.auth-open > main,
body.auth-open > .footer,
body.auth-open > .skip-link { display: none; }

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  overflow-y: auto;
  background:
    radial-gradient(900px 520px at 50% -8%, var(--accent-light), transparent 68%),
    var(--bg);
}

/* Especificidade maior que .auth-screen para o [hidden] valer sobre o grid. */
.auth-screen[hidden] { display: none; }

.auth-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 34px 32px 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.auth-back {
  position: absolute;
  top: 14px;
  left: 14px;
  border: 0;
  background: none;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.auth-back:hover { color: var(--text); background: var(--hover); }

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 22px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.auth-view h1 { font-size: 22px; font-weight: 800; }

.auth-lede { margin-top: 8px; font-size: 13.5px; color: var(--muted); }

.google-login-container {
  display: flex;
  justify-content: center;
  margin-top: 20px;
  min-height: 0;
}

.google-login-container:empty { display: none; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 4px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* Sem Google configurado o container fica vazio: a linha "ou entre com
   e-mail" nao teria o que separar. */
.google-login-container:empty + .auth-divider { display: none; }

.auth-form { display: grid; gap: 12px; margin-top: 18px; text-align: left; }

.auth-form label {
  display: grid;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.auth-form input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--card-soft);
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.auth-form input::placeholder { color: var(--muted); opacity: 0.7; }

.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.auth-submit { width: 100%; margin-top: 4px; }

.auth-link {
  margin-top: 14px;
  border: 0;
  background: none;
  padding: 0;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.auth-link:hover { color: var(--accent); text-decoration: underline; }

.auth-switch {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}

.auth-switch button {
  border: 0;
  background: none;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  font-weight: 700;
  color: var(--accent);
  cursor: pointer;
}

.auth-switch button:hover { text-decoration: underline; }

.auth-message { margin-top: 14px; font-size: 13px; color: var(--muted); }
.auth-message:empty { display: none; }
.auth-message.error { color: var(--danger); }
.auth-message.success { color: var(--accent); }

.auth-back:focus-visible,
.auth-link:focus-visible,
.auth-switch button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------------------------------------------------------------- Responsivo */

@media (max-width: 940px) {
  .hero { grid-template-columns: minmax(0, 1fr); gap: 40px; padding-top: 52px; }
  .split { grid-template-columns: minmax(0, 1fr); gap: 36px; }
  .cards, .cards-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .theory-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-links { display: none; }
}

@media (max-width: 560px) {
  .nav { padding: 10px 14px; gap: 10px; }
  .nav-actions { gap: 6px; }
  .btn { padding: 8px 13px; font-size: 12.5px; }
  .btn-lg { padding: 12px 20px; font-size: 14px; }
  .section { padding: 52px 18px; }
  .hero { padding: 40px 18px 44px; }
  .hero-auth { padding: 16px; }
  .hero-auth-fields { grid-template-columns: minmax(0, 1fr); }
  .hero-auth-actions .btn { width: 100%; }
  .stats { padding: 0 18px 48px; }
  .cards, .cards-3, .theory-grid { grid-template-columns: minmax(0, 1fr); }
  .mini-row { grid-template-columns: 96px minmax(0, 1fr) 36px; gap: 9px; }
  .footer { flex-direction: column; align-items: flex-start; }
  .auth-screen { padding: 0; place-items: stretch; }
  .auth-card {
    max-width: none;
    min-height: 100%;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 56px 20px 32px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
