/* ============================================
   EstudaMath — topico.css
   Estilos compartilhados das páginas de conteúdo
   ============================================ */

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

:root {
  --ink: #1a1a2e;
  --ink2: #3d3d5c;
  --muted: #8888aa;
  --bg: #f7f6f0;
  --surface: #ffffff;
  --accent: #4f46e5;
  --accent2: #06b6d4;
  --green: #10b981;
  --warm: #f59e0b;
  --red: #ef4444;
  --border: rgba(0,0,0,0.08);
  --shadow: 0 2px 16px rgba(79,70,229,0.08);
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--accent2);
  outline-offset: 3px;
}

.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;
}

.btn-primary {
  background: var(--ink);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.875rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: background 0.2s, transform 0.15s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.btn-primary:hover {
  background: var(--topic-color, var(--accent));
  transform: translateY(-2px);
}

/* ---- NAV ---- */
nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(247,246,240,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  display: flex; align-items: center; justify-content: space-between;
  height: 64px;
}
.nav-logo {
  font-family: 'DM Serif Display', serif;
  font-size: 1.5rem; color: var(--accent); letter-spacing: -0.5px;
  text-decoration: none;
}
.nav-logo span { color: var(--ink); }
.nav-back {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.875rem; font-weight: 500; color: var(--ink2);
  text-decoration: none; transition: color 0.2s;
}
.nav-back:hover { color: var(--accent); }

/* ---- HERO DO TÓPICO ---- */
.topic-hero {
  padding: 4rem 4rem 3rem;
  border-bottom: 1px solid var(--border);
  position: relative; overflow: hidden;
}
.topic-hero::before {
  content: '';
  position: absolute; right: -100px; top: -100px;
  width: 500px; height: 500px;
  background: radial-gradient(circle, var(--topic-color-light, rgba(79,70,229,0.08)) 0%, transparent 70%);
  border-radius: 50%;
}
.topic-breadcrumb {
  font-size: 0.8rem; color: var(--muted); margin-bottom: 1rem;
}
.topic-breadcrumb a { color: var(--accent); text-decoration: none; }
.topic-breadcrumb a:hover { text-decoration: underline; }

.topic-tag {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--topic-color-light, rgba(79,70,229,0.08));
  color: var(--topic-color, var(--accent));
  padding: 0.3rem 0.9rem; border-radius: 100px;
  font-size: 0.75rem; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  margin-bottom: 1.25rem;
}
.topic-hero h1 {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.15; letter-spacing: -1px; margin-bottom: 1rem;
}
.topic-hero p {
  font-size: 1.1rem; color: var(--ink2);
  line-height: 1.7; max-width: 640px;
}

/* ---- LAYOUT PRINCIPAL ---- */
.content-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 0;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* ---- SIDEBAR ---- */
.sidebar {
  padding: 2.5rem 1.5rem 2.5rem 0;
  position: sticky; top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
  border-right: 1px solid var(--border);
}
.sidebar-title {
  font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 1rem;
}
.sidebar-links { list-style: none; }
.sidebar-links li { margin-bottom: 0.25rem; }
.sidebar-links a {
  display: block; padding: 0.45rem 0.75rem;
  border-radius: 8px; font-size: 0.875rem;
  color: var(--ink2); text-decoration: none;
  transition: all 0.2s;
}
.sidebar-links a:hover { background: rgba(79,70,229,0.06); color: var(--accent); }
.sidebar-links a.active { background: rgba(79,70,229,0.1); color: var(--accent); font-weight: 600; }

/* ---- CONTEÚDO ---- */
.content-body {
  padding: 3rem 0 3rem 3rem;
  width: 100%;
  max-width: 1040px;
}

/* Seção */
.content-section { margin-bottom: 4rem; scroll-margin-top: 80px; }
.content-section h2 {
  font-family: 'DM Serif Display', serif;
  font-size: 1.8rem; margin-bottom: 1rem; line-height: 1.2;
}
.content-section h3 {
  font-size: 1.1rem; font-weight: 600; margin: 2rem 0 0.75rem;
}
.content-section p {
  color: var(--ink2); line-height: 1.8; margin-bottom: 1rem; font-size: 1rem;
}

/* Fórmula em destaque */
.formula-box {
  background: var(--ink);
  color: white;
  border-radius: 14px;
  padding: 1.5rem 2rem;
  margin: 1.5rem 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.15rem;
  line-height: 1.8;
  position: relative;
}
.formula-box .formula-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: rgba(255,255,255,0.4); margin-bottom: 0.5rem;
}
.formula-box .formula-main { color: var(--accent2); font-size: 1.3rem; }
.formula-box .formula-vars { color: rgba(255,255,255,0.6); font-size: 0.85rem; margin-top: 0.5rem; }

/* Exemplo resolvido */
.example-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  margin: 1.5rem 0;
}
.example-box .ex-label {
  font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--topic-color, var(--accent)); margin-bottom: 0.75rem;
}
.example-box .ex-problem {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem; color: var(--ink); margin-bottom: 1rem;
  padding-bottom: 1rem; border-bottom: 1px solid var(--border);
}
.example-box .ex-step {
  display: flex; gap: 1rem; margin-bottom: 0.6rem; align-items: flex-start;
}
.ex-step-num {
  width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
  background: var(--topic-color, var(--accent));
  color: white; font-size: 0.7rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin-top: 2px;
}
.ex-step-text {
  font-size: 0.9rem; color: var(--ink2); line-height: 1.6;
}
.ex-step-text code {
  font-family: 'JetBrains Mono', monospace;
  background: rgba(0,0,0,0.04); padding: 0.1rem 0.4rem;
  border-radius: 4px; font-size: 0.85rem;
}
.ex-result {
  margin-top: 1rem; padding: 0.75rem 1rem;
  background: var(--topic-color-light, rgba(79,70,229,0.06));
  border-radius: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem; color: var(--topic-color, var(--accent));
}

/* Tabela */
.content-table {
  width: 100%; border-collapse: collapse; margin: 1.5rem 0;
  font-size: 0.9rem;
}
.content-table th {
  background: var(--ink); color: white;
  padding: 0.75rem 1rem; text-align: left;
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.05em;
}
.content-table th:first-child { border-radius: 10px 0 0 0; }
.content-table th:last-child  { border-radius: 0 10px 0 0; }
.content-table td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--ink2);
}
.content-table tr:hover td { background: rgba(0,0,0,0.02); }
.content-table code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
}

/* Dica */
.tip-box {
  display: flex; gap: 1rem;
  background: rgba(245,158,11,0.08);
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: 12px; padding: 1.25rem;
  margin: 1.5rem 0;
}
.tip-icon { font-size: 1.25rem; flex-shrink: 0; margin-top: 2px; }
.tip-text { font-size: 0.9rem; color: var(--ink2); line-height: 1.6; }
.tip-text strong { color: var(--ink); font-weight: 600; }

/* Mini quiz inline */
.inline-quiz {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 16px; padding: 2rem; margin: 2rem 0;
}
.inline-quiz .iq-label {
  font-size: 0.7rem; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 1rem;
}
.inline-quiz .iq-question {
  font-family: 'DM Serif Display', serif;
  font-size: 1.2rem; margin-bottom: 1.25rem; line-height: 1.4;
}
.iq-options { display: grid; gap: 0.6rem; }
.iq-option {
  padding: 0.75rem 1rem;
  border: 1.5px solid var(--border); border-radius: 10px;
  cursor: pointer; font-size: 0.9rem;
  font-family: 'DM Sans', sans-serif;
  background: transparent; text-align: left; color: var(--ink);
  transition: all 0.2s;
}
.iq-option:hover { border-color: var(--accent); background: rgba(79,70,229,0.04); }
.iq-option.correct { border-color: var(--green); background: rgba(16,185,129,0.08); color: #065f46; }
.iq-option.wrong   { border-color: var(--red);   background: rgba(239,68,68,0.08);  color: #991b1b; }
.iq-feedback {
  margin-top: 1rem; padding: 0.75rem 1rem;
  border-radius: 8px; font-size: 0.875rem;
  display: none;
}
.iq-feedback.show    { display: block; }
.iq-feedback.correct { background: rgba(16,185,129,0.1); color: #065f46; }
.iq-feedback.wrong   { background: rgba(239,68,68,0.1);  color: #991b1b; }

.graph-accessible-note {
  color: rgba(255,255,255,0.55);
  font-size: 0.8rem;
  line-height: 1.5;
  margin-top: 0.75rem;
  text-align: center;
}

/* Canvas gráfico */
.graph-container {
  background: var(--ink);
  border-radius: 16px; padding: 1.5rem;
  margin: 1.5rem 0;
  display: flex; flex-direction: column; align-items: center;
}
.graph-container canvas { width: 100%; max-width: 560px; }
.graph-caption {
  font-size: 0.8rem; color: rgba(255,255,255,0.4);
  margin-top: 0.75rem; text-align: center;
}

/* ============================================
   FRAÇÕES TIPOGRÁFICAS — uso: <span class="F"><b>num</b><b>den</b></span>
   ============================================ */
.F {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  margin: 0 5px;
  font-family: 'JetBrains Mono', monospace;
  line-height: 1.15;
}
.F b:first-child {
  border-bottom: 2px solid currentColor;
  padding: 1px 7px 3px;
  font-weight: 400;
  font-size: 0.95em;
  text-align: center;
}
.F b:last-child {
  padding: 3px 7px 1px;
  font-weight: 400;
  font-size: 0.95em;
  text-align: center;
}

/* Dentro de .formula-box as frações ficam na cor accent2 */
.formula-box .F { color: var(--accent2); }
.formula-box .F b:first-child { border-color: var(--accent2); }

/* Dentro de .ex-result as frações ficam na cor do tópico */
.ex-result .F { color: var(--topic-color, #4f46e5); }
.ex-result .F b:first-child { border-color: var(--topic-color, #4f46e5); }

/* ============================================
   LISTA DE FÓRMULAS — cada linha é um item
   ============================================ */
.formula-list {
  list-style: none;
  padding: 0; margin: 0.5rem 0 0;
  display: flex; flex-direction: column; gap: 0;
}
.formula-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.6rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  color: rgba(255,255,255,0.88);
  flex-wrap: wrap;
}
.formula-list li:last-child { border-bottom: none; }
.formula-list li .fl-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.7rem; font-weight: 700;
  color: rgba(255,255,255,0.3);
  text-transform: uppercase; letter-spacing: 0.08em;
  min-width: 100px; flex-shrink: 0;
}
.formula-list .hl { color: var(--accent2); }

/* ============================================
   PAGINAÇÃO ENTRE TÓPICOS
   ============================================ */
.topic-nav {
  display: flex; justify-content: space-between;
  margin-top: 4rem; padding-top: 2.75rem;
  position: relative;
}
.topic-nav::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}
.topic-nav a {
  display: flex; flex-direction: column; gap: 0.25rem;
  text-decoration: none; padding: 1rem 1.25rem;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg);
  position: relative;
  z-index: 1;
  width: min(340px, 45%);
  max-width: 340px;
  transition: all 0.2s;
}
.topic-nav a:hover { border-color: var(--accent); }
.topic-nav-label { font-size: 0.75rem; color: var(--muted); font-weight: 500; }
.topic-nav-title { font-size: 0.95rem; font-weight: 600; color: var(--ink); }
.topic-nav .next { text-align: right; margin-left: auto; }

.site-footer {
  background: var(--ink);
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
  padding: 2.5rem 2rem;
  font-size: 0.875rem;
  line-height: 1.7;
  margin-top: 3rem;
}

.site-footer strong { color: white; }

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-top: 0.85rem;
}

.footer-links a {
  color: rgba(255, 255, 255, 0.82);
  text-decoration: none;
  transition: color 0.2s;
}

.footer-links a:hover { color: white; }

/* Responsivo */
@media (max-width: 860px) {
  .content-layout { grid-template-columns: 1fr; padding: 0 1.5rem; }
  .sidebar { display: none; }
  .content-body { padding: 2rem 0; }
  .topic-hero { padding: 2.5rem 1.5rem; }
}

@media (max-width: 560px) {
  .topic-nav { flex-direction: column; gap: 0.75rem; }
  .topic-nav a { width: 100%; max-width: none; }
  .topic-nav .next { margin-left: 0; text-align: left; }
}
