/* ==========================================================================
   Centro legal (Términos y Privacidad): lectura larga con el índice al lado.
   Lo único con el degradado de la marca es la línea del índice, que se llena
   mientras se lee (--lg-p, de 0 a 1, lo pone legal.js).
   ========================================================================== */

.lg {
  --lg-surface: #0c0f19;
  --lg-line: rgba(255, 255, 255, 0.08);
  --lg-line-strong: rgba(255, 255, 255, 0.16);
  --lg-text: #eef1f8;
  --lg-body: #c6cddb;
  --lg-muted: #9aa4b8;
  --lg-num: #7c879c;
  --lg-link: #8ab4ff;
  --lg-key: #fcd34d;
  --lg-head: var(--v-header-h, 68px);
  --lg-grad: linear-gradient(180deg, #3b82f6 0%, #8b5cf6 55%, #22d3ee 100%);
  --lg-p: 0;
  width: min(1200px, calc(100% - 32px));
  margin-inline: auto;
  padding: 64px 0 96px;
  color: var(--lg-text);
}
body:not(.v2-dark) .lg { background: #06070c; border-radius: 24px; padding-inline: 24px; }

@media (prefers-reduced-motion: no-preference) {
  html:has([data-lg]) { scroll-behavior: smooth; }
}

.lg-sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------- Encabezado ---------- */
.lg-hero { padding-bottom: 40px; margin-bottom: 40px; border-bottom: 1px solid var(--lg-line); }
.lg-kicker { margin: 0 0 14px; color: var(--lg-muted); font-size: 0.95rem; }
.lg-title {
  margin: 0 0 20px;
  font-family: var(--v-display, 'Space Grotesk', sans-serif); font-weight: 700;
  font-size: clamp(2.5rem, 6vw, 4.25rem); line-height: 1; letter-spacing: -0.04em; color: #fff;
}
.lg-lead { margin: 0 0 28px; max-width: 60ch; color: var(--lg-body); font-size: clamp(1.05rem, 1.6vw, 1.2rem); line-height: 1.6; }

.lg-hero-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 32px; }
.lg-switch { display: inline-flex; gap: 4px; padding: 4px; border: 1px solid var(--lg-line-strong); border-radius: 999px; }
.lg-switch a {
  display: inline-flex; align-items: center; min-height: 40px; padding: 8px 16px; border-radius: 999px;
  color: var(--lg-muted); font-size: 0.92rem; font-weight: 600; text-decoration: none;
}
.lg-switch a:hover { color: #fff; }
.lg-switch a[aria-current="page"] { background: #fff; color: #0b0e17; }
.lg-print {
  display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 10px 18px;
  border: 1px solid var(--lg-line-strong); border-radius: 999px; background: transparent;
  color: var(--lg-text); font: inherit; font-size: 0.92rem; font-weight: 600; cursor: pointer;
}
.lg-print:hover { border-color: rgba(255, 255, 255, 0.34); }

.lg-facts { display: flex; flex-wrap: wrap; gap: 12px 44px; margin: 0; }
.lg-facts div { display: grid; gap: 2px; }
.lg-facts dt { color: var(--lg-muted); font-size: 0.8rem; }
.lg-facts dd { margin: 0; color: #fff; font-family: var(--v-display, 'Space Grotesk', sans-serif); font-size: 1.05rem; font-weight: 600; }

/* ---------- En pocas palabras ---------- */
.lg-brief {
  display: grid; grid-template-columns: minmax(0, 280px) minmax(0, 1fr); gap: 24px 56px;
  margin-bottom: 72px; padding: 32px; border: 1px solid var(--lg-line); border-radius: 20px; background: var(--lg-surface);
}
.lg-brief-head h2 { margin: 0 0 8px; color: #fff; font-family: var(--v-display, 'Space Grotesk', sans-serif); font-size: 1.5rem; letter-spacing: -0.02em; }
.lg-brief-head p { margin: 0; color: var(--lg-muted); font-size: 0.95rem; line-height: 1.55; }
.lg-brief-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 40px; margin: 0; padding: 0; list-style: none; }
.lg-brief-list li { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 14px; padding: 18px 0; border-top: 1px solid var(--lg-line); }
.lg-brief-list li:nth-child(-n + 2) { border-top: 0; padding-top: 0; }
.lg-brief-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: rgba(138, 180, 255, 0.1); color: var(--lg-link); }
.lg-brief-list strong { display: block; margin-bottom: 4px; color: #fff; font-size: 1rem; font-weight: 600; }
.lg-brief-list p { margin: 0 0 6px; color: var(--lg-body); font-size: 0.92rem; line-height: 1.5; }
.lg-brief-list a { color: var(--lg-link); font-size: 0.85rem; font-weight: 600; text-decoration: none; }
.lg-brief-list a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Índice + documento ---------- */
.lg-body { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 72px; align-items: start; }

.lg-toc {
  position: sticky; top: calc(var(--lg-head) + 24px);
  max-height: calc(100vh - var(--lg-head) - 48px); overflow-y: auto; scrollbar-width: thin;
  padding-left: 18px;
}
.lg-toc-title { margin: 0 0 12px; color: #fff; font-family: var(--v-display, 'Space Grotesk', sans-serif); font-size: 0.95rem; font-weight: 600; }
.lg-rail { position: absolute; top: 38px; bottom: 46px; left: 0; width: 2px; border-radius: 2px; background: var(--lg-line); }
/* --lg-r: hasta la sección que se está leyendo (legal.js). */
.lg-rail span { position: absolute; inset: 0; border-radius: 2px; background: var(--lg-grad); transform: scaleY(var(--lg-r, 0)); transform-origin: top; }
@media (prefers-reduced-motion: no-preference) {
  .lg-rail span { transition: transform 0.35s var(--v-ease, ease-out); }
}
.lg-toc-list { display: grid; gap: 2px; margin: 0; padding: 0; list-style: none; }
.lg-toc-list a {
  display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 6px; padding: 7px 10px; border-radius: 8px;
  color: var(--lg-muted); font-size: 0.88rem; line-height: 1.35; text-decoration: none;
}
.lg-toc-list a span { color: var(--lg-num); font-variant-numeric: tabular-nums; }
.lg-toc-list a:hover { background: rgba(255, 255, 255, 0.04); color: #fff; }
.lg-toc-list a[aria-current="location"] { background: rgba(138, 180, 255, 0.1); color: #fff; }
.lg-toc-list a[aria-current="location"] span { color: var(--lg-link); }
.lg-top { display: inline-block; margin: 16px 0 4px 10px; color: var(--lg-muted); font-size: 0.85rem; }
.lg-top:hover { color: #fff; }

.lg-doc { max-width: 760px; }
.lg-sec {
  display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 8px;
  padding: 36px 0; border-top: 1px solid var(--lg-line);
  scroll-margin-top: calc(var(--lg-head) + 20px);
}
.lg-sec:first-child { padding-top: 0; border-top: 0; }
.lg-num {
  margin: 0; padding-top: 2px; color: var(--lg-num);
  font-family: var(--v-display, 'Space Grotesk', sans-serif); font-size: 2rem; font-weight: 500;
  line-height: 1.1; letter-spacing: -0.03em; font-variant-numeric: tabular-nums;
}
.lg-sec.is-current .lg-num { color: var(--lg-link); }
.lg-sec-head { display: flex; align-items: flex-start; gap: 8px; }
.lg-sec h2 {
  margin: 4px 0 14px; color: #fff;
  font-family: var(--v-display, 'Space Grotesk', sans-serif); font-size: clamp(1.3rem, 2.2vw, 1.6rem);
  font-weight: 600; line-height: 1.2; letter-spacing: -0.02em;
}
.lg-copy {
  flex: none; display: grid; place-items: center; width: 36px; height: 36px; margin-top: 2px;
  border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--lg-muted); cursor: pointer;
}
.lg-copy:hover, .lg-copy:focus-visible { border-color: var(--lg-line-strong); color: #fff; }
@media (hover: hover) {
  .lg-copy { opacity: 0; }
  .lg-sec:hover .lg-copy, .lg-copy:focus-visible { opacity: 1; }
}

.lg-sec-body p { max-width: 68ch; margin: 0 0 16px; color: var(--lg-body); font-size: 1.0625rem; line-height: 1.75; }
.lg-sec-body ul { display: grid; gap: 10px; max-width: 68ch; margin: 0 0 16px; padding-left: 1.2em; list-style: disc; }
.lg-sec-body li { padding-left: 0.3em; color: var(--lg-body); font-size: 1.0625rem; line-height: 1.7; }
.lg-sec-body li::marker { color: var(--lg-link); }
.lg-sec-body strong { color: #fff; font-weight: 600; }
.lg-sec-body a { color: var(--lg-link); text-decoration: underline; text-underline-offset: 3px; }
.lg-sec-body > :last-child { margin-bottom: 0; }

/* Cláusulas clave: las que más reclamos evitan si se leen. */
.lg-sec.is-key .lg-sec-body { padding: 22px 24px; border: 1px solid rgba(251, 191, 36, 0.24); border-radius: 16px; background: rgba(251, 191, 36, 0.045); }
.lg-sec-body .lg-flag {
  display: inline-block; margin: -4px 0 14px; padding: 4px 10px; border-radius: 999px;
  background: rgba(251, 191, 36, 0.14); color: var(--lg-key); font-size: 0.8rem; font-weight: 600; line-height: 1.4;
}

.lg-help { margin-top: 56px; padding: 32px; border: 1px solid var(--lg-line); border-radius: 20px; background: var(--lg-surface); }
.lg-help h2 { margin: 0 0 8px; color: #fff; font-family: var(--v-display, 'Space Grotesk', sans-serif); font-size: 1.4rem; letter-spacing: -0.02em; }
.lg-help p { max-width: 60ch; margin: 0 0 20px; color: var(--lg-body); line-height: 1.6; }
.lg-help a { color: var(--lg-link); }
.lg-help-btn {
  min-height: 48px; padding: 12px 22px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--v-grad-btn, linear-gradient(135deg, #2563eb 0%, #7c3aed 100%)); color: #fff; font: inherit; font-weight: 700;
}

.lg-toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 90; margin: 0; padding: 10px 16px; border-radius: 999px;
  background: #fff; color: #0b0e17; font-size: 0.9rem; font-weight: 600; pointer-events: none;
  opacity: 0; transform: translate(-50%, 12px); transition: opacity 0.2s, transform 0.2s;
}
.lg-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { .lg-toast { transition: none; } }

.lg-progress, .lg-toc-m { display: none; }

/* ---------- Tableta y celular: el índice pasa a un menú fijo bajo la barra superior ---------- */
@media (max-width: 1000px) {
  .lg-body { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .lg-toc { display: none; }
  .lg-brief { grid-template-columns: minmax(0, 1fr); padding: 24px; margin-bottom: 40px; }

  .lg-toc-m {
    display: block; position: sticky; top: var(--lg-head); z-index: 60;
    margin: 0 -16px 24px; border-bottom: 1px solid var(--lg-line);
    background: rgba(6, 7, 12, 0.94); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  }
  .lg-toc-m::after {
    content: ''; position: absolute; left: 0; bottom: -1px; width: 100%; height: 2px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6, #22d3ee); transform: scaleX(var(--lg-p)); transform-origin: left;
  }
  .lg-toc-m summary {
    display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 0 16px;
    color: #fff; font-weight: 600; list-style: none; cursor: pointer;
  }
  .lg-toc-m summary::-webkit-details-marker { display: none; }
  .lg-toc-m summary::after {
    content: ''; flex: none; width: 8px; height: 8px; margin-left: 4px;
    border-right: 2px solid var(--lg-muted); border-bottom: 2px solid var(--lg-muted); transform: rotate(45deg) translateY(-2px);
  }
  .lg-toc-m[open] summary::after { transform: rotate(-135deg) translateY(-2px); }
  .lg-toc-m-now { flex: 1; min-width: 0; overflow: hidden; color: var(--lg-muted); font-size: 0.88rem; font-weight: 500; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
  .lg-toc-m .lg-toc-list { position: relative; max-height: 60vh; overflow-y: auto; padding: 4px 8px 12px; }
  .lg-sec { scroll-margin-top: calc(var(--lg-head) + 64px); }
}

@media (max-width: 640px) {
  .lg { padding-top: 36px; }
  .lg-hero { padding-bottom: 28px; margin-bottom: 28px; }
  .lg-switch { width: 100%; }
  .lg-switch a { flex: 1; justify-content: center; padding: 8px; font-size: 0.85rem; text-align: center; }
  .lg-print { width: 100%; justify-content: center; }
  .lg-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 20px; }
  .lg-facts div:first-child { grid-column: 1 / -1; }
  .lg-brief-list { grid-template-columns: minmax(0, 1fr); }
  .lg-brief-list li:nth-child(2) { padding-top: 18px; border-top: 1px solid var(--lg-line); }
  .lg-sec { grid-template-columns: minmax(0, 1fr); gap: 0; padding: 28px 0; }
  .lg-num { padding: 0; margin-bottom: 4px; color: var(--lg-link); font-size: 1rem; }
  .lg-sec.is-key .lg-sec-body { padding: 18px 16px; }
  .lg-sec-body p, .lg-sec-body li { font-size: 1rem; }
  .lg-help { padding: 24px; }
}

/* ---------- Impresión y PDF: solo el texto, en negro sobre blanco ---------- */
@media print {
  @page { margin: 18mm 16mm; }
  html, body { background: #fff !important; color: #000 !important; }
  .v2-header, .site-header, .v2-footer, .site-footer, .co-footer, .mobile-tabbar, .mobile-category-sheet, .mobile-sheet-backdrop, #asistente,
  .lg-hero-row, .lg-brief, .lg-toc, .lg-toc-m, .lg-copy, .lg-help, .lg-toast, .lg-top { display: none !important; }
  .lg { width: auto; padding: 0; background: none !important; color: #000; }
  .lg-hero { margin-bottom: 14pt; padding-bottom: 10pt; border-color: #999; }
  .lg-kicker, .lg-lead, .lg-facts dt, .lg-facts dd { color: #000; }
  .lg-title { max-width: none; color: #000; font-size: 26pt; }
  .lg-body { display: block; }
  .lg-sec { display: block; padding: 10pt 0; border-color: #bbb; }
  .lg-num { display: none; }
  .lg-sr { position: static; width: auto; height: auto; overflow: visible; clip: auto; clip-path: none; white-space: normal; }
  .lg-sec h2 { margin: 0 0 6pt; color: #000; font-size: 13pt; break-after: avoid; }
  .lg-sec-body p, .lg-sec-body li { color: #000; font-size: 10.5pt; line-height: 1.5; }
  .lg-sec-body strong, .lg-sec-body a { color: #000; }
  .lg-sec-body li::marker { color: #000; }
  .lg-sec.is-key .lg-sec-body { padding: 8pt 10pt; border: 1px solid #999; background: none; }
  .lg-sec-body .lg-flag { padding: 1pt 6pt; border: 1px solid #000; background: none; color: #000; }
}
