/* Páginas legales (términos y condiciones). Lectura larga: columna de texto
   de ~70 caracteres, índice fijo a la izquierda y los tokens de design-system. */

html {
  scroll-behavior: smooth;
  scroll-padding-top: 88px;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ds-text);
  font-family: var(--ds-font-body);
  background:
    radial-gradient(circle at 12% -10%, rgba(124, 92, 255, 0.22), transparent 42%),
    radial-gradient(circle at 88% 8%, rgba(34, 211, 238, 0.13), transparent 40%),
    linear-gradient(180deg, var(--ds-bg) 0%, #05070d 100%);
  background-attachment: fixed;
}

.legal-top {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px max(20px, calc((100vw - 1100px) / 2));
  background: rgba(9, 12, 20, 0.88);
  border-bottom: 1px solid var(--ds-border);
  backdrop-filter: blur(10px);
}

.legal-brand img {
  display: block;
  height: 34px;
  width: auto;
}

.legal-back {
  padding: 8px 16px;
  border: 1px solid var(--ds-border-strong);
  border-radius: var(--ds-radius-pill);
  color: var(--ds-text);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.legal-back:hover {
  background: var(--ds-surface-hover);
  border-color: var(--ds-primary);
}

.legal-shell {
  width: min(1100px, 100% - 40px);
  margin: 0 auto;
  padding: 40px 0 80px;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 48px;
  align-items: start;
}

/* Índice */
.legal-toc {
  position: sticky;
  top: 96px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  scrollbar-width: thin;
}

.legal-toc-title {
  margin: 0 0 12px;
  color: var(--ds-text-muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.legal-toc ol {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 2px;
  counter-reset: toc;
}

.legal-toc li {
  counter-increment: toc;
}

.legal-toc a {
  display: flex;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  color: var(--ds-text-muted);
  font-size: 0.88rem;
  line-height: 1.35;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.legal-toc a::before {
  content: counter(toc) '.';
  flex: none;
  min-width: 1.4em;
  color: var(--ds-text-faint);
  font-variant-numeric: tabular-nums;
}

.legal-toc a:hover {
  background: rgba(124, 92, 255, 0.12);
  color: var(--ds-text);
}

/* Documento */
.legal-doc {
  min-width: 0;
  padding: 40px 48px 32px;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-xl);
  background: var(--ds-surface-solid);
  box-shadow: var(--ds-shadow-md);
}

.legal-head {
  padding-bottom: 28px;
  border-bottom: 1px solid var(--ds-border);
}

.legal-head h1 {
  margin: 0;
  font-family: var(--ds-font-display);
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  line-height: 1.15;
  text-wrap: balance;
}

.legal-meta {
  margin: 12px 0 0;
  color: var(--ds-text-muted);
  font-size: 0.88rem;
}

.legal-lead {
  margin: 18px 0 0;
  max-width: 68ch;
  color: var(--ds-text);
  font-size: 1.05rem;
  line-height: 1.65;
}

.legal-doc section {
  padding-top: 32px;
}

.legal-doc h2 {
  margin: 0 0 12px;
  font-family: var(--ds-font-display);
  font-size: 1.2rem;
  line-height: 1.3;
}

.legal-doc p,
.legal-doc li {
  max-width: 70ch;
  color: #cbd5e1;
  font-size: 0.98rem;
  line-height: 1.7;
}

.legal-doc p {
  margin: 0 0 12px;
}

.legal-doc ul {
  margin: 0 0 12px;
  padding-left: 22px;
  display: grid;
  gap: 8px;
}

.legal-doc li::marker {
  color: var(--ds-primary);
}

.legal-doc strong {
  color: var(--ds-text);
  font-weight: 700;
}

.legal-doc a {
  color: #67e8f9;
  text-underline-offset: 3px;
}

.legal-doc a:hover {
  color: #a5f3fc;
}

.legal-doc ::selection {
  background: rgba(124, 92, 255, 0.45);
}

.legal-foot {
  margin-top: 40px;
  padding-top: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  border-top: 1px solid var(--ds-border);
}

.legal-foot p {
  margin: 0;
  color: var(--ds-text-muted);
  font-size: 0.86rem;
}

.legal-doc a.legal-cta {
  padding: 10px 20px;
  border-radius: var(--ds-radius-md);
  background: var(--ds-gradient-brand);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.legal-doc a.legal-cta:hover {
  filter: brightness(1.1);
  color: #fff;
}

.legal-back:focus-visible,
.legal-toc a:focus-visible,
.legal-doc a:focus-visible,
.legal-brand:focus-visible {
  outline: 2px solid var(--ds-primary);
  outline-offset: 2px;
}

@media (max-width: 900px) {
  .legal-shell {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    padding-top: 24px;
  }

  .legal-toc {
    position: static;
    max-height: none;
    padding: 16px;
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-surface-solid);
  }

  .legal-toc ol {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .legal-doc {
    padding: 28px 22px 24px;
  }
}

@media (max-width: 520px) {
  .legal-toc ol {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
