/* ============================================================
   NicoChat — páginas legais (Termos, Privacidade, Ética, Afiliados)
   Depende de css/styles.css: tokens, navbar, botões e footer do site.
   Aqui só entra o layout do documento: hero, sumário fixo e artigo.
   ============================================================ */

:root {
  --legal-grad: linear-gradient(90deg, #0099ff 0%, #5cc0ff 100%);
  --legal-bg: #fbfcfe;
}

/* ---------- Barra de progresso de leitura ---------- */
.read-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: var(--legal-grad);
  z-index: 200;
  transition: width 0.1s linear;
}

/* ---------- Hero ---------- */
.legal-hero {
  position: relative;
  padding: 72px 0 44px;
  overflow: hidden;
  background: var(--legal-bg);
  border-bottom: 1px solid var(--border);
}
.legal-hero-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.legal-hero-bg::before,
.legal-hero-bg::after {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(60px);
}
.legal-hero-bg::before {
  top: -180px;
  left: 2%;
  background: radial-gradient(circle, rgba(0, 153, 255, 0.20), transparent 70%);
}
.legal-hero-bg::after {
  top: -140px;
  right: 4%;
  background: radial-gradient(circle, rgba(46, 60, 112, 0.16), transparent 70%);
}
.legal-hero-inner {
  position: relative;
  z-index: 1;
  max-width: 920px;
}

.legal-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 6px 14px 6px 7px;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--navy);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-card);
}
.legal-eyebrow-dot {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--legal-grad);
  display: inline-grid;
  place-items: center;
  color: var(--white);
}
.legal-eyebrow-dot svg { width: 11px; height: 11px; }

.legal-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.25rem, 5.4vw, 3.75rem);
  line-height: 1.04;
  letter-spacing: -0.025em;
  color: var(--navy);
  margin: 20px 0 16px;
  text-wrap: balance;
}
.legal-title .grad {
  background: var(--legal-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.legal-lead {
  font-size: 1.125rem;
  line-height: 1.55;
  color: var(--muted);
  max-width: 720px;
  text-wrap: pretty;
}

.legal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin-top: 26px;
  font-size: 0.8125rem;
  color: var(--muted);
}
.legal-meta span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.legal-meta svg { width: 14px; height: 14px; color: var(--gray-light); }
.legal-meta-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #12b76a;
  box-shadow: 0 0 0 3px rgba(18, 183, 106, 0.16);
}

/* ---------- Layout: sumário + artigo ---------- */
.legal-body {
  display: grid;
  grid-template-columns: 264px 1fr;
  gap: 60px;
  align-items: start;
  padding: 52px 24px 104px;
  max-width: var(--container);
  margin: 0 auto;
}

.toc {
  position: sticky;
  top: 96px;
  align-self: start;
  max-height: calc(100vh - 130px);
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-width: thin;
}
.toc-title {
  font-family: var(--font-display);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--gray-light);
  margin-bottom: 14px;
}
.toc ol {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
  counter-reset: toc;
}
.toc li { counter-increment: toc; }
.toc a {
  position: relative;
  display: block;
  padding: 7px 10px 7px 36px;
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--text);
  border-radius: 8px;
  border-left: 2px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.toc a::before {
  content: counter(toc, decimal-leading-zero);
  position: absolute;
  left: 11px;
  top: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.625rem;
  color: var(--gray-light);
}
.toc a:hover { background: var(--bg-soft); color: var(--navy); }
.toc a.is-active {
  color: var(--navy);
  font-weight: 700;
  background: rgba(0, 153, 255, 0.07);
  border-left-color: var(--blue);
}
.toc a.is-active::before { color: var(--blue); }

/* ---------- Artigo ---------- */
.legal-article {
  max-width: 760px;
  counter-reset: section;
}

.legal-intro {
  padding: 24px 26px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 44px;
  font-size: 0.9688rem;
  color: var(--text);
}
.legal-intro p:last-child { margin-bottom: 0; }

.legal-article h2 {
  position: relative;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.375rem, 2.6vw, 1.75rem);
  line-height: 1.18;
  letter-spacing: -0.015em;
  color: var(--navy);
  margin: 56px 0 18px;
  padding-left: 60px;
  scroll-margin-top: 104px;
  text-wrap: balance;
}
.legal-article h2::before {
  counter-increment: section;
  content: counter(section, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--blue);
  background: var(--white);
  padding: 6px 10px;
  border: 1px solid var(--border-2);
  border-radius: 8px;
  line-height: 1;
}
.legal-article h2:first-of-type { margin-top: 0; }

.legal-article h3 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.0625rem;
  letter-spacing: -0.01em;
  color: var(--navy);
  margin: 32px 0 10px;
}

.legal-article p {
  margin-bottom: 16px;
  font-size: 1rem;
  line-height: 1.72;
  color: var(--text);
  text-wrap: pretty;
}
.legal-article strong { color: var(--navy); font-weight: 600; }
.legal-article a {
  color: var(--blue);
  text-decoration: underline;
  text-decoration-color: rgba(0, 153, 255, 0.35);
  text-underline-offset: 2px;
}
.legal-article a:hover { text-decoration-color: var(--blue); }

/* Listas com marcador e listas alfabéticas */
.legal-article ul,
.legal-article ol.lettered,
.legal-article ol.numbered {
  list-style: none;
  margin-bottom: 20px;
}
.legal-article li {
  position: relative;
  padding: 5px 0 5px 30px;
  font-size: 1rem;
  line-height: 1.72;
  color: var(--text);
}
.legal-article ul > li::before {
  content: "";
  position: absolute;
  left: 9px;
  top: 15px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--legal-grad);
}
.legal-article ol.lettered { counter-reset: letter; }
.legal-article ol.lettered > li { counter-increment: letter; padding-left: 38px; }
.legal-article ol.lettered > li::before {
  content: counter(letter, upper-alpha);
  position: absolute;
  left: 0;
  top: 7px;
  min-width: 22px;
  padding: 3px 0;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--blue);
  background: rgba(0, 153, 255, 0.10);
  border-radius: 6px;
  line-height: 1.2;
}
.legal-article ol.numbered { counter-reset: num; }
.legal-article ol.numbered > li { counter-increment: num; padding-left: 38px; }
.legal-article ol.numbered > li::before {
  content: counter(num);
  position: absolute;
  left: 0;
  top: 7px;
  min-width: 22px;
  padding: 3px 0;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.75rem;
  color: var(--blue);
  background: rgba(0, 153, 255, 0.10);
  border-radius: 6px;
  line-height: 1.2;
}
.legal-article li strong { color: var(--navy); }

/* Blocos de destaque */
.callout {
  margin: 22px 0;
  padding: 18px 22px;
  background: rgba(0, 153, 255, 0.05);
  border: 1px solid rgba(0, 153, 255, 0.20);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  color: var(--text);
}
.callout p:last-child, .warn p:last-child { margin-bottom: 0; }
.callout strong { color: var(--navy); }

.warn {
  margin: 22px 0;
  padding: 18px 22px;
  background: rgba(255, 61, 0, 0.045);
  border: 1px solid rgba(255, 61, 0, 0.22);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  color: #8a3200;
}
.warn strong { color: #6b2700; }

.verse {
  margin: 26px 0;
  padding: 20px 24px;
  border-left: 3px solid var(--blue);
  background: linear-gradient(90deg, rgba(0, 153, 255, 0.05), transparent);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 500;
  font-style: italic;
  line-height: 1.5;
  color: var(--navy);
}
.verse cite {
  display: block;
  margin-top: 8px;
  font-family: var(--font-body);
  font-style: normal;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}

/* Cartão de contato */
.legal-contact {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 22px 0;
  padding: 20px 24px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.legal-contact-icon {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(0, 153, 255, 0.10);
  color: var(--blue);
}
.legal-contact-icon svg { width: 21px; height: 21px; }
.legal-contact strong {
  display: block;
  font-family: var(--font-display);
  color: var(--navy);
  font-size: 0.9375rem;
}
.legal-contact a { font-size: 1.0625rem; font-weight: 600; }

/* Rodapé do documento + navegação entre políticas */
.legal-endnote {
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--gray-light);
}

.legal-related {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 24px;
}
.legal-related a {
  display: block;
  padding: 16px 18px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--navy);
  text-decoration: none;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.legal-related a:hover {
  border-color: rgba(0, 153, 255, 0.4);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}
.legal-related span {
  display: block;
  margin-top: 3px;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--muted);
}

/* Voltar ao topo */
.to-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 90;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--white);
  border: 1px solid var(--border-2);
  border-radius: 50%;
  color: var(--navy);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s, visibility 0.2s;
}
.to-top.is-visible { opacity: 1; visibility: visible; transform: translateY(0); }
.to-top:hover { border-color: var(--blue); color: var(--blue); }
.to-top svg { width: 18px; height: 18px; }

/* ---------- Responsivo ---------- */
@media (max-width: 1024px) {
  .legal-body { grid-template-columns: 1fr; gap: 32px; padding-top: 32px; }
  .toc {
    position: static;
    max-height: none;
    padding: 18px 20px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
  }
  .toc ol { max-height: 260px; overflow-y: auto; }
  .legal-related { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .legal-hero { padding: 44px 0 32px; }
  .legal-body { padding: 24px 20px 72px; }
  .legal-article h2 { padding-left: 0; }
  .legal-article h2::before {
    position: static;
    display: inline-block;
    transform: none;
    margin-bottom: 10px;
  }
  .to-top { right: 14px; bottom: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .read-progress, .to-top, .legal-related a { transition: none; }
}

/* ---------- Impressão ---------- */
@media print {
  .navbar, .toc, .footer, .legal-hero-bg, .to-top,
  .read-progress, .legal-related { display: none !important; }
  .legal-body { grid-template-columns: 1fr; padding: 0; max-width: none; }
  .legal-hero { padding: 0 0 16px; border-bottom: 1px solid #ddd; }
  .legal-article { max-width: none; }
  body { background: #fff; }
  .legal-article h2 { page-break-after: avoid; }
  .legal-article p, .legal-article li { page-break-inside: avoid; }
  a { text-decoration: none !important; color: inherit !important; }
}
