/* QRave · páginas legales. Se carga después de home.css y comparte sus tokens, menú, botones y pie. */
.legal-page { background: var(--paper); }

/* Barra de lectura */
.read-bar { position: fixed; inset: 0 0 auto; z-index: 50; height: 3px; pointer-events: none; }
.read-bar i { display: block; height: 100%; background: var(--spectrum); transform: scaleX(0); transform-origin: left; }

/* Portada */
.legal-hero { position: relative; overflow: hidden; padding-block: clamp(48px, 7vw, 96px) clamp(36px, 5vw, 64px); background: var(--ink); color: var(--on-ink); --mx: 72%; --my: 30%; }
.legal-hero__grid { position: absolute; inset: 0; background-image: linear-gradient(rgba(255,255,255,.075) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.075) 1px, transparent 1px); background-size: 38px 38px; mask-image: radial-gradient(440px circle at var(--mx) var(--my), #000, transparent 72%); -webkit-mask-image: radial-gradient(440px circle at var(--mx) var(--my), #000, transparent 72%); pointer-events: none; }
.legal-hero::before { content: ""; position: absolute; width: 720px; height: 720px; left: calc(var(--mx) - 360px); top: calc(var(--my) - 360px); background: radial-gradient(circle, rgba(119,48,239,.2), rgba(125,211,244,.05) 46%, transparent 68%); pointer-events: none; }
.legal-hero::after { content: ""; position: absolute; right: clamp(-90px, -4vw, -30px); bottom: -70px; width: clamp(180px, 26vw, 340px); aspect-ratio: 1; border: clamp(26px, 3.6vw, 46px) solid rgba(255,255,255,.055); border-radius: 22%; animation: legal-drift 15s ease-in-out infinite alternate; pointer-events: none; }
@keyframes legal-drift { to { transform: translate(-22px, -30px) rotate(8deg); } }
.legal-hero__in { position: relative; z-index: 1; width: min(100%, 1180px); margin-inline: auto; padding-inline: var(--gutter); }
.legal-hero__in--split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 410px); gap: clamp(32px, 5vw, 64px); align-items: end; }
.legal-hero h1 { max-width: 15ch; font-size: clamp(2.5rem, 5.4vw, 4.6rem); line-height: 1; letter-spacing: -.04em; animation: rise .9s var(--ease) both; }
.legal-hero p { max-width: 62ch; margin-top: 18px; font-size: clamp(1.02rem, 1.35vw, 1.14rem); color: var(--on-ink-2); animation: rise .9s var(--ease) .12s both; }
.legal-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; animation: rise .9s var(--ease) .2s both; }
.legal-chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px; border-radius: 20px; border: 1px solid var(--ink-line); background: rgba(255,255,255,.04); font-size: .84rem; color: var(--on-ink-2); }
.legal-chip svg { width: 15px; height: 15px; color: var(--aqua); }
.legal-chip b { color: var(--on-ink); font-weight: 600; }
.legal-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; animation: rise .9s var(--ease) .26s both; }
.legal-brief { padding: 24px; border-radius: 22px; background: var(--ink-2); border: 1px solid var(--ink-line); box-shadow: 0 30px 80px rgba(0,0,0,.5), 0 0 70px rgba(119,48,239,.18); animation: rise .9s var(--ease) .18s both; }
.legal-brief__k { font: 600 1.05rem var(--display); color: var(--on-ink); }
.legal-brief ul { display: grid; gap: 12px; margin-top: 14px; }
.legal-brief li { display: flex; gap: 11px; align-items: flex-start; font-size: .92rem; line-height: 1.5; color: var(--on-ink-2); }
.legal-brief li b { color: var(--on-ink); font-weight: 600; }
.legal-brief li svg { width: 22px; height: 22px; flex: none; padding: 4px; border-radius: 7px; background: rgba(125,211,244,.14); color: var(--aqua); margin-top: 1px; }
.legal-hero .legal-brief__note { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--ink-line); font-size: .8rem; line-height: 1.45; color: var(--on-ink-2); animation: none; }

/* Cuerpo */
.legal-body { width: min(100%, 1180px); margin-inline: auto; padding: clamp(28px, 4vw, 56px) var(--gutter) clamp(48px, 7vw, 88px); display: grid; grid-template-columns: 268px minmax(0, 1fr); gap: clamp(32px, 5vw, 72px); align-items: start; }
.legal-content { min-width: 0; }

/* Índice */
.toc { position: sticky; top: 92px; min-width: 0; }
.toc__label { display: flex; align-items: center; gap: 8px; width: 100%; padding: 0 0 12px 12px; border: 0; background: none; color: var(--text); font: 600 1rem var(--display); text-align: left; cursor: default; }
.toc__label em, .toc__label svg { display: none; }
.toc nav { position: relative; display: flex; flex-direction: column; gap: 1px; max-height: calc(100vh - 150px); overflow-y: auto; scrollbar-width: none; overscroll-behavior: contain; }
.toc__group { margin: 14px 0 3px; padding-left: 12px; font-size: .78rem; font-weight: 600; color: var(--muted); }
.toc__group:first-child { margin-top: 0; }
.toc a { position: relative; display: flex; align-items: baseline; gap: 10px; padding: 7px 12px; border-radius: 10px; font-size: .86rem; line-height: 1.35; font-weight: 500; color: var(--muted); text-decoration: none; transition: background .18s, color .18s, transform .22s var(--ease); }
.toc a .n { flex: none; font: 600 .74rem var(--display); font-variant-numeric: tabular-nums; color: var(--muted); }
.toc a:hover { color: var(--text); background: rgba(119,48,239,.08); transform: translateX(3px); }
.toc a.done .n { color: var(--ok-deep); }
.toc a.active { background: var(--violet); color: #fff; font-weight: 600; }
.toc a.active .n { color: #fff; }

/* Partes */
.legal-group { display: flex; align-items: center; gap: 14px; margin: 44px 0 6px; scroll-margin-top: 96px; }
.legal-group:first-child { margin-top: 0; }
.legal-group__k { display: grid; place-items: center; width: 46px; height: 46px; flex: none; border-radius: 14px; background: var(--violet); color: #fff; font: 700 1.15rem var(--display); }
.legal-group b { display: block; font: 600 clamp(1.45rem, 2.4vw, 1.9rem)/1.1 var(--display); letter-spacing: -.02em; }
.legal-group small { display: block; margin-top: 3px; font-size: .9rem; color: var(--muted); }

/* Secciones */
.legal-section { padding-block: clamp(22px, 2.8vw, 32px); border-bottom: 1px solid var(--paper-line); scroll-margin-top: 84px; }
.legal-section__head { display: flex; align-items: center; gap: 13px; margin-bottom: 14px; }
.legal-section__n { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--white); border: 1px solid var(--paper-line); color: var(--violet-deep); font: 600 .9rem var(--display); font-variant-numeric: tabular-nums; transition: background .3s, color .3s, border-color .3s, transform .35s var(--ease); }
.legal-section:hover .legal-section__n, .legal-section:target .legal-section__n { background: var(--violet); border-color: var(--violet); color: #fff; transform: scale(1.08); }
.legal-section:target { animation: legal-mark 1.8s var(--ease); }
@keyframes legal-mark { 0%, 35% { background: rgba(119,48,239,.09); } 100% { background: transparent; } }
.legal-section h2 { font-size: clamp(1.25rem, 2vw, 1.45rem); line-height: 1.2; letter-spacing: -.015em; }
.legal-section h3 { margin: 20px 0 8px; font-size: 1.05rem; }
.legal-section p { margin: 0 0 12px; max-width: 72ch; color: var(--muted); font-size: .98rem; line-height: 1.7; text-wrap: pretty; }
.legal-section p:last-child { margin-bottom: 0; }
.legal-section p strong, .legal-section li strong { color: var(--text); font-weight: 600; }
.legal-section ul, .legal-section ol { margin: 4px 0 14px; padding-left: 22px; max-width: 72ch; color: var(--muted); font-size: .98rem; line-height: 1.7; list-style: revert; }
.legal-section li { margin: 6px 0; }
.legal-section li::marker { color: var(--violet); font-weight: 600; }
.legal-section a { color: var(--violet-deep); font-weight: 600; text-underline-offset: 3px; }
.legal-section a.btn--outline { border-color: var(--violet); text-decoration: none; }

/* Bloques */
.legal-defs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 16px 0; }
.legal-def { display: grid; gap: 2px; padding: 12px 14px; border-radius: 14px; background: var(--white); border: 1px solid var(--paper-line); }
.legal-def dt { font-size: .78rem; font-weight: 600; color: var(--muted); }
.legal-def dd { margin: 0; font-size: .92rem; font-weight: 600; overflow-wrap: anywhere; }
.legal-callout { display: flex; gap: 12px; align-items: flex-start; margin: 16px 0; padding: 14px 16px; border-radius: 14px; background: rgba(119,48,239,.08); }
.legal-callout svg { width: 20px; height: 20px; flex: none; margin-top: 2px; color: var(--violet); }
.legal-callout p { margin: 0; max-width: none; font-size: .93rem; color: var(--text); }
.legal-callout.warn { background: #FFF3DC; }
.legal-callout.warn svg { color: #8F5B00; }
.legal-contact { display: flex; gap: 14px; align-items: flex-start; margin-top: 16px; padding: 18px; border-radius: 16px; background: var(--ink); color: var(--on-ink); }
.legal-contact__ic { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 13px; background: var(--violet); color: #fff; }
.legal-contact__ic svg { width: 21px; height: 21px; }
.legal-contact__tx { min-width: 0; }
.legal-contact h3 { margin: 0 0 4px; font-size: 1rem; color: var(--on-ink); }
.legal-section .legal-contact p { margin: 0; font-size: .92rem; color: var(--on-ink-2); }
.legal-section .legal-contact p strong { color: var(--on-ink); }
.legal-section .legal-contact a { color: var(--aqua); overflow-wrap: anywhere; }
.legal-terms { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 16px 0; }
.legal-term { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: baseline; padding: 14px 16px; border-radius: 14px; background: var(--white); border: 1px solid var(--paper-line); }
.legal-term b { font: 600 clamp(1.5rem, 2.3vw, 1.95rem)/1 var(--display); letter-spacing: -.03em; color: var(--violet); }
.legal-term span { font-size: .8rem; font-weight: 600; }
.legal-term small { grid-column: 1 / -1; margin-top: 6px; font-size: .8rem; line-height: 1.4; color: var(--muted); }

/* PQR */
.pqr-steps, .pqr-channels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 16px 0; }
.pqr-step { display: flex; gap: 12px; padding: 14px; border-radius: 14px; background: var(--white); border: 1px solid var(--paper-line); }
.pqr-step__n { display: grid; place-items: center; width: 32px; height: 32px; flex: none; border-radius: 50%; background: var(--violet); color: #fff; font: 600 .88rem var(--display); }
.pqr-step__b { min-width: 0; }
.pqr-step__b b { display: block; margin-bottom: 3px; font: 600 .95rem var(--display); }
.legal-section .pqr-step__b p { margin: 0; font-size: .88rem; line-height: 1.5; }
.pqr-ch { display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: 14px; background: var(--white); border: 1px solid var(--paper-line); }
.legal-section a.pqr-ch { text-decoration: none; transition: border-color .2s, transform .22s var(--ease); }
.legal-section a.pqr-ch:hover { border-color: var(--violet); transform: translateY(-3px); }
.pqr-ch__ic { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px; background: rgba(119,48,239,.1); color: var(--violet); }
.pqr-ch__ic svg { width: 19px; height: 19px; }
.pqr-ch__b, .pqr-ch > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.pqr-ch .l { font-size: .76rem; font-weight: 600; color: var(--muted); }
.pqr-ch .v { font-size: .92rem; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }

/* Cierre */
.legal-end { margin-top: 40px; }
.legal-end__k { margin-bottom: 12px; font: 600 1.05rem var(--display); }
.legal-docs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.legal-doc { display: flex; align-items: center; gap: 13px; padding: 16px; border-radius: 16px; background: var(--white); border: 1px solid var(--paper-line); color: var(--text); text-decoration: none; transition: border-color .2s, transform .25s var(--ease), box-shadow .25s; }
.legal-doc:hover { border-color: var(--violet); transform: translateY(-3px); box-shadow: 0 14px 34px rgba(119,48,239,.16); }
.legal-doc__ic { display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 13px; background: rgba(119,48,239,.1); color: var(--violet); }
.legal-doc__ic svg { width: 20px; height: 20px; }
.legal-doc > span:nth-child(2) { flex: 1; min-width: 0; }
.legal-doc b { display: block; font: 600 .98rem var(--display); }
.legal-doc small { display: block; margin-top: 2px; font-size: .84rem; line-height: 1.4; color: var(--muted); }
.legal-doc > svg { width: 18px; height: 18px; flex: none; color: var(--muted); transition: transform .22s var(--ease), color .2s; }
.legal-doc:hover > svg { transform: translateX(4px); color: var(--violet); }
.legal-end__note { margin-top: 16px; font-size: .84rem; color: var(--muted); }

/* Volver arriba y aparición */
.totop { position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); z-index: 40; display: grid; place-items: center; width: 46px; height: 46px; padding: 0; border: 0; border-radius: 14px; background: var(--violet); color: #fff; cursor: pointer; opacity: 0; transform: translateY(10px); pointer-events: none; transition: opacity .25s, transform .25s var(--ease); }
.totop svg { width: 20px; height: 20px; }
.totop.show { opacity: 1; transform: none; pointer-events: auto; }
.totop.show:hover { transform: translateY(-3px); }
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .55s var(--ease), transform .55s var(--ease); }
.reveal.is-in { opacity: 1; transform: none; }

@media (max-width: 1020px) {
  .legal-hero__in--split { grid-template-columns: minmax(0, 1fr); align-items: start; }
  .legal-body { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .toc--fold { position: sticky; top: 76px; z-index: 20; padding: 5px; border-radius: 16px; background: rgba(255,255,255,.95); border: 1px solid var(--paper-line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
  .toc--fold .toc__label { min-height: 44px; padding: 8px 10px; cursor: pointer; }
  .toc--fold .toc__label span { flex: none; }
  .toc--fold .toc__label em { display: block; flex: 1; min-width: 0; overflow: hidden; font: 500 .84rem var(--body); color: var(--violet-deep); text-overflow: ellipsis; white-space: nowrap; }
  .toc--fold .toc__label svg { display: block; width: 18px; height: 18px; flex: none; color: var(--muted); transition: transform .25s var(--ease); }
  .toc--fold.is-open .toc__label svg { transform: rotate(180deg); }
  .toc--fold nav { display: none; max-height: 56vh; padding: 2px 3px 5px; }
  .toc--fold.is-open nav { display: flex; }
}
@media (max-width: 680px) {
  .legal-defs, .pqr-steps, .pqr-channels, .legal-docs { grid-template-columns: minmax(0, 1fr); }
  .legal-actions .btn { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; }
}

/* Imprimir o guardar PDF: solo el documento */
@media print {
  .nav, .sheet, .toc, .totop, .read-bar, .foot, .dissolve, .legal-actions, .legal-hero__grid, .legal-docs, .legal-end__k { display: none !important; }
  .legal-page, .legal-hero { background: #fff !important; color: #000 !important; }
  .legal-hero::before, .legal-hero::after { display: none !important; }
  .legal-hero { padding: 0 0 14px; }
  .legal-hero h1, .legal-hero p, .legal-chip, .legal-chip b { color: #000 !important; animation: none; }
  .legal-hero__in--split, .legal-body { display: block; width: 100%; padding: 0; }
  .legal-brief { margin-top: 14px; background: #fff; box-shadow: none; border: 1px solid #bbb; }
  .legal-brief__k, .legal-brief li, .legal-brief li b, .legal-hero .legal-brief__note { color: #000; }
  .legal-section { padding: 10px 0; border: 0; break-inside: avoid; }
  .legal-section p, .legal-section li { max-width: none; color: #000; font-size: 11.5pt; }
  .legal-section .legal-contact { background: #fff; color: #000; border: 1px solid #bbb; }
  .legal-section .legal-contact h3, .legal-section .legal-contact p, .legal-section .legal-contact a { color: #000; }
  .legal-group { margin: 20px 0 6px; break-after: avoid; }
  .reveal { opacity: 1 !important; transform: none !important; }
}
