/*
 * legal.css — páginas de documentos legales (Términos y Condiciones, Política de Privacidad).
 * Mismo sistema visual que el landing: fondo hueso, bordes piedra de 1px, Inter + Instrument Serif.
 *
 * Estructura esperada:
 *   body.legal
 *     header.legal-top            barra superior (logo + volver)
 *     header.legal-hero           eyebrow + h1 + fecha de actualización
 *     div.legal-layout
 *       nav.legal-toc             índice fijo (enlaces a #seccion-N); se marca .is-active con JS
 *       article.legal-doc         el texto: <section id="seccion-N"><h2>…</h2><p>…</p></section>
 *     footer.legal-footer
 */

:root {
  --lg-bg: #fbfaf7;
  --lg-bg-2: #f5f1ea;
  --lg-card: #ffffff;
  --lg-border: #ebe5da;
  --lg-border-strong: #ddd4c4;
  --lg-text: #1c1917;
  --lg-muted: #6b6259;
  --lg-primary: #136dec;
  --lg-radius: 20px;
  --lg-shadow: 0 1px 2px rgba(28, 25, 23, 0.04), 0 12px 32px -14px rgba(28, 25, 23, 0.16);
  --lg-serif: "Instrument Serif", ui-serif, Georgia, serif;
  --lg-sans: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --fx-gradient: linear-gradient(90deg, #136dec, #7c3aed, #c2410c, #136dec);
}

html { scroll-behavior: smooth; overflow-x: clip; }
body.legal {
  margin: 0;
  background: var(--lg-bg);
  color: var(--lg-text);
  font-family: var(--lg-sans);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.011em;
}
body.legal ::selection { background: var(--lg-primary); color: #fff; }
.legal a { color: var(--lg-primary); }
.legal :where(a, button):focus-visible { outline: 2px solid var(--lg-primary); outline-offset: 3px; border-radius: 6px; }

.legal-container { max-width: 1120px; margin: 0 auto; padding: 0 20px; box-sizing: border-box; }
@media (min-width: 768px) { .legal-container { padding: 0 32px; } }

/* ---------- Barra superior ---------- */
.legal-top {
  position: sticky; top: 0; z-index: 20;
  background: rgba(251, 250, 247, 0.82);
  -webkit-backdrop-filter: saturate(180%) blur(14px); backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--lg-border);
}
.legal-top .legal-container { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.legal-logo { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; letter-spacing: -0.03em; color: var(--lg-text) !important; text-decoration: none; }
.legal-logo img { width: 26px; height: 26px; }
.legal-back {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--lg-border-strong); background: var(--lg-card); color: var(--lg-text) !important;
  font-size: 14px; font-weight: 500; text-decoration: none; transition: background 0.2s;
}
.legal-back:hover { background: var(--lg-bg-2); }
.legal-back .material-icons { font-size: 18px; }

/* ---------- Encabezado ---------- */
.legal-hero { position: relative; padding: 72px 0 40px; overflow: hidden; }
.legal-hero::before {
  content: ""; position: absolute; inset: -40% -10% auto; height: 420px; pointer-events: none;
  background:
    radial-gradient(40% 60% at 30% 40%, rgba(251, 146, 60, 0.16), transparent 70%),
    radial-gradient(40% 60% at 70% 40%, rgba(19, 109, 236, 0.12), transparent 70%);
}
.legal-hero .legal-container { position: relative; display: grid; gap: 14px; }
.legal-eyebrow { font-size: 13px; font-weight: 600; color: var(--lg-primary); }
.legal-hero h1 {
  margin: 0; font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1.05; font-weight: 600; letter-spacing: -0.045em;
  text-wrap: balance;
}
.legal-accent { font-family: var(--lg-serif); font-style: italic; font-weight: 400; letter-spacing: -0.02em; padding-right: 0.06em; }
.legal-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.legal-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px;
  background: var(--lg-card); border: 1px solid var(--lg-border); font-size: 13px; color: var(--lg-muted);
}
.legal-chip .material-icons { font-size: 15px; }

/* ---------- Layout con índice ---------- */
.legal-layout { display: grid; gap: 32px; padding-bottom: 96px; }
@media (min-width: 960px) {
  .legal-layout { grid-template-columns: 240px minmax(0, 1fr); gap: 56px; align-items: start; }
}
.legal-toc { display: none; }
@media (min-width: 960px) {
  .legal-toc { display: block; position: sticky; top: 92px; }
}
.legal-toc p { margin: 0 0 10px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--lg-muted); }
.legal-toc ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; border-left: 1px solid var(--lg-border); }
.legal-toc a {
  display: block; padding: 6px 12px; margin-left: -1px; border-left: 2px solid transparent;
  font-size: 13.5px; line-height: 1.4; color: var(--lg-muted) !important; text-decoration: none;
  transition: color 0.2s, border-color 0.2s;
}
.legal-toc a:hover { color: var(--lg-text) !important; }
.legal-toc a.is-active { color: var(--lg-text) !important; border-left-color: var(--lg-primary); font-weight: 500; }

/* ---------- Documento ---------- */
.legal-doc {
  background: var(--lg-card); border: 1px solid var(--lg-border); border-radius: var(--lg-radius);
  box-shadow: var(--lg-shadow); padding: clamp(24px, 5vw, 56px);
  max-width: 760px;
}
.legal-doc section { scroll-margin-top: 88px; }
.legal-doc section + section { margin-top: 36px; padding-top: 36px; border-top: 1px solid var(--lg-border); }
.legal-doc h2 {
  margin: 0 0 12px; font-size: 1.25rem; font-weight: 600; letter-spacing: -0.025em; line-height: 1.3;
  display: flex; gap: 12px; align-items: baseline;
}
.legal-num {
  flex: none; display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 6px; border-radius: 8px;
  background: var(--lg-bg-2); border: 1px solid var(--lg-border); font-size: 13px; font-weight: 600; color: var(--lg-muted);
  font-variant-numeric: tabular-nums; transform: translateY(-2px);
}
.legal-doc h3 { margin: 20px 0 8px; font-size: 1rem; font-weight: 600; letter-spacing: -0.015em; }
.legal-doc p, .legal-doc li { font-size: 15.5px; line-height: 1.75; color: #3f3a35; }
.legal-doc p { margin: 0 0 12px; }
.legal-doc ul, .legal-doc ol { margin: 8px 0 12px; padding-left: 1.3rem; }
.legal-doc li { margin: 4px 0; }
.legal-doc li::marker { color: var(--lg-primary); }
.legal-doc strong { color: var(--lg-text); font-weight: 600; }
.legal-lead { font-size: 17px !important; color: var(--lg-text) !important; }
.legal-note {
  margin: 16px 0; padding: 14px 16px; border-radius: 14px;
  background: linear-gradient(120deg, #fff7ef, #eef4ff); border: 1px solid var(--lg-border);
  font-size: 14.5px; line-height: 1.6;
}

/* ---------- Footer ---------- */
.legal-footer { border-top: 1px solid var(--lg-border); padding: 28px 0 40px; }
.legal-footer .legal-container { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; font-size: 13px; color: var(--lg-muted); }
.legal-footer nav { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.legal-footer a { color: var(--lg-muted) !important; text-decoration: none; display: inline-block; padding: 6px 0; }
.legal-footer a:hover { color: var(--lg-text) !important; }

/* Aparición suave */
.legal-reveal { animation: legal-in 0.8s cubic-bezier(0.16, 1, 0.3, 1) both; animation-delay: var(--d, 0ms); }
@keyframes legal-in { from { opacity: 0; transform: translateY(14px); filter: blur(6px); } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .legal-reveal { animation: none; }
}

@media print {
  .legal-top, .legal-toc, .legal-footer, .legal-hero::before { display: none !important; }
  .legal-doc { box-shadow: none; border: 0; padding: 0; max-width: none; }
  body.legal { background: #fff; }
}
