/* public/legal/legal.css
   VB Lina — Hoja de estilos compartida para páginas legales / informativas.
   v1 — producción.
   · Dark aesthetic idéntica a landing.css
   · Layout de dos columnas (TOC sticky + contenido) en desktop
   · Print-friendly (Ley de Consumidores exige legibilidad en PDF)
   · Core Web Vitals: content-visibility en secciones largas, contain en cards
*/

:root {
    --bg-0: #05060d;
    --bg-1: #070912;
    --bg-2: #0a0d1a;

    --text: #d5dbf0;
    --text-soft: #a8b3d3;
    --text-dim: #8b97b8;
    --muted: #5a6588;

    --line: rgba(120, 160, 255, 0.08);
    --line-strong: rgba(120, 160, 255, 0.18);

    --violet: #a17bff;
    --violet-soft: rgba(161, 123, 255, 0.35);
    --cyan: #5ee8b8;
    --blue: #5468c9;
    --blue-2: #7a58b5;

    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 999px;

    --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);

    --content-max: 780px;
    --toc-width: 240px;
    --gap: 48px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
    scroll-behavior: smooth;
    scroll-padding-top: 96px;
    -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

body {
    min-height: 100vh;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    font-size: 16px;
    line-height: 1.7;
    color: var(--text);
    background: var(--bg-0);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
    position: relative;
}

/* Fondo: orbe suave + viñeta */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(60vmin 60vmin at 15% 0%, rgba(122, 88, 181, 0.22), transparent 70%),
        radial-gradient(50vmin 50vmin at 90% 20%, rgba(84, 104, 201, 0.18), transparent 70%),
        radial-gradient(ellipse at 50% 100%, rgba(5, 6, 13, 0.8) 30%, transparent 80%);
}

/* ============================================================
   HEADER
   ============================================================ */
.legal-nav {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px clamp(20px, 5vw, 48px);
    background: rgba(5, 6, 13, 0.72);
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    border-bottom: 1px solid var(--line);
}

.legal-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: 'Instrument Serif', serif;
    font-size: 18px;
    letter-spacing: 0.4px;
    color: var(--text);
    text-decoration: none;
    transition: color 0.25s var(--ease);
}
.legal-brand:hover { color: #fff; }

.legal-brand-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #c9b8ff, var(--violet));
    box-shadow: 0 0 14px var(--violet-soft), 0 0 30px rgba(161, 123, 255, 0.35);
}

.legal-nav-links {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.legal-nav-links a {
    font-size: 13px;
    color: var(--text-dim);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: var(--radius-full);
    border: 1px solid transparent;
    transition: all 0.25s var(--ease);
}
.legal-nav-links a:hover {
    color: #eaf0ff;
    border-color: var(--line-strong);
    background: rgba(16, 22, 44, 0.6);
}

/* Language picker (reusa i18n.js) */
.legal-lang-picker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 10px;
    border-radius: var(--radius-full);
    border: 1px solid var(--line-strong);
    background: rgba(16, 22, 44, 0.5);
    transition: border-color 0.25s var(--ease), background 0.25s var(--ease);
}
.legal-lang-picker:hover,
.legal-lang-picker:focus-within {
    border-color: rgba(161, 123, 255, 0.5);
    background: rgba(30, 26, 60, 0.7);
}
.legal-lang-picker .lang-icon {
    color: var(--text-dim);
    flex-shrink: 0;
}
.legal-lang-select {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: 0;
    outline: none;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 16px 4px 2px;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b97b8' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M6 9l6 6 6-6'/></svg>");
    background-repeat: no-repeat;
    background-position: right 0 center;
    background-size: 11px;
}
.legal-lang-select option {
    background: #0a0f22;
    color: #d5dbf0;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.legal-main {
    position: relative;
    z-index: 1;
    max-width: 1160px;
    margin: 0 auto;
    padding: 40px clamp(20px, 5vw, 48px) 80px;
    display: grid;
    grid-template-columns: var(--toc-width) minmax(0, 1fr);
    gap: var(--gap);
    align-items: start;
}

.legal-main--no-toc {
    display: block;
    max-width: 900px;
}

/* ============================================================
   HERO
   ============================================================ */
.legal-hero {
    margin-bottom: 32px;
}

.legal-eyebrow {
    display: inline-block;
    font-size: 11.5px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: rgba(161, 123, 255, 0.78);
    font-weight: 500;
    padding: 5px 12px;
    border: 1px solid rgba(161, 123, 255, 0.25);
    border-radius: var(--radius-full);
    background: rgba(161, 123, 255, 0.06);
    margin-bottom: 16px;
}

.legal-hero h1 {
    font-family: 'Instrument Serif', serif;
    font-weight: 400;
    font-size: clamp(32px, 5vw, 52px);
    line-height: 1.08;
    letter-spacing: -0.015em;
    color: #f2f5ff;
    margin-bottom: 12px;
    text-shadow: 0 0 40px rgba(161, 123, 255, 0.15);
}

.legal-hero .legal-lede {
    font-size: clamp(15px, 1.6vw, 17px);
    line-height: 1.65;
    color: var(--text-dim);
    max-width: 64ch;
}

.legal-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 16px;
    font-size: 12.5px;
    color: var(--muted);
}
.legal-meta span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.legal-meta strong {
    font-weight: 500;
    color: var(--text-soft);
}

/* ============================================================
   TOC
   ============================================================ */
.legal-toc {
    position: sticky;
    top: 88px;
    padding: 20px 18px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    background: rgba(10, 13, 28, 0.55);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(140, 180, 255, 0.15) transparent;
}
.legal-toc::-webkit-scrollbar { width: 4px; }
.legal-toc::-webkit-scrollbar-thumb {
    background: rgba(140, 180, 255, 0.2);
    border-radius: 2px;
}

.legal-toc-title {
    font-size: 11px;
    letter-spacing: 2.5px;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 500;
    margin-bottom: 12px;
}

.legal-toc ol {
    list-style: none;
    counter-reset: toc-counter;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

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

.legal-toc a {
    display: grid;
    grid-template-columns: 20px 1fr;
    gap: 8px;
    padding: 6px 8px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--text-dim);
    text-decoration: none;
    border-radius: 6px;
    transition: color 0.2s var(--ease), background 0.2s var(--ease);
}
.legal-toc a::before {
    content: counter(toc-counter, decimal-leading-zero);
    font-family: 'Instrument Serif', serif;
    font-style: italic;
    font-size: 11px;
    color: rgba(161, 123, 255, 0.45);
    letter-spacing: 0.02em;
    align-self: center;
}
.legal-toc a:hover {
    color: #eaf0ff;
    background: rgba(255, 255, 255, 0.04);
}
.legal-toc a.is-active {
    color: #c9b8ff;
    background: rgba(161, 123, 255, 0.08);
}
.legal-toc a.is-active::before {
    color: var(--violet);
}

/* ============================================================
   CONTENIDO
   ============================================================ */
.legal-content {
    max-width: var(--content-max);
    font-size: 15.5px;
    line-height: 1.75;
    color: var(--text);
}

.legal-content section {
    content-visibility: auto;
    contain-intrinsic-size: 1px 800px;
    margin-bottom: 44px;
    scroll-margin-top: 96px;
}

.legal-content section:last-child {
    margin-bottom: 0;
}

.legal-content h2 {
    font-family: 'Instrument Serif', serif;
    font-weight: 400;
    font-size: clamp(24px, 2.6vw, 30px);
    line-height: 1.2;
    letter-spacing: -0.01em;
    color: #f0f3ff;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
    counter-increment: section-counter;
    display: flex;
    align-items: baseline;
    gap: 14px;
}

.legal-content h2::before {
    content: counter(section-counter, decimal-leading-zero);
    font-family: 'Instrument Serif', serif;
    font-style: italic;
    font-size: 0.65em;
    color: rgba(161, 123, 255, 0.55);
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.legal-content { counter-reset: section-counter; }

.legal-content h3 {
    font-family: 'Instrument Serif', serif;
    font-weight: 400;
    font-size: 20px;
    color: #eaf0ff;
    margin-top: 28px;
    margin-bottom: 10px;
    letter-spacing: 0.1px;
}

.legal-content h4 {
    font-size: 15px;
    font-weight: 500;
    color: #eaf0ff;
    margin-top: 20px;
    margin-bottom: 8px;
}

.legal-content p {
    margin-bottom: 14px;
    color: var(--text);
}

.legal-content p:last-child { margin-bottom: 0; }

.legal-content strong {
    font-weight: 500;
    color: #f2f5ff;
}

.legal-content em { color: #c9b8ff; font-style: italic; }

.legal-content a {
    color: #c9b8ff;
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    text-decoration-color: rgba(161, 123, 255, 0.4);
    transition: color 0.2s var(--ease), text-decoration-color 0.2s var(--ease);
}
.legal-content a:hover {
    color: #e0d4ff;
    text-decoration-color: rgba(161, 123, 255, 0.8);
}

.legal-content ul,
.legal-content ol {
    margin: 12px 0 16px 0;
    padding-left: 24px;
}

.legal-content li {
    margin-bottom: 8px;
    line-height: 1.65;
}

.legal-content ul li::marker {
    color: rgba(161, 123, 255, 0.6);
    font-size: 0.9em;
}

.legal-content ol li::marker {
    color: rgba(161, 123, 255, 0.6);
    font-family: 'Instrument Serif', serif;
    font-style: italic;
}

/* Callout / note */
.legal-note {
    margin: 18px 0;
    padding: 14px 18px;
    border-left: 3px solid rgba(161, 123, 255, 0.55);
    background: rgba(161, 123, 255, 0.06);
    border-radius: 0 12px 12px 0;
    font-size: 14.5px;
    color: var(--text-soft);
    line-height: 1.65;
}
.legal-note strong {
    color: #eaf0ff;
}

.legal-note--warning {
    border-left-color: rgba(255, 170, 80, 0.7);
    background: rgba(255, 170, 80, 0.06);
}

.legal-note--info {
    border-left-color: rgba(94, 232, 184, 0.6);
    background: rgba(94, 232, 184, 0.05);
}

/* Tabla */
.legal-content table {
    width: 100%;
    margin: 16px 0 20px;
    border-collapse: collapse;
    font-size: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    overflow: hidden;
    display: block;
    overflow-x: auto;
    white-space: nowrap;
}
.legal-content table thead {
    background: rgba(16, 22, 44, 0.6);
}
.legal-content table th,
.legal-content table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    white-space: normal;
}
.legal-content table th {
    font-weight: 500;
    color: #eaf0ff;
    font-size: 13px;
    letter-spacing: 0.02em;
}
.legal-content table tr:last-child td { border-bottom: 0; }
.legal-content table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Anchor link para h2 */
.legal-content h2 .anchor {
    margin-left: auto;
    opacity: 0;
    font-size: 0.6em;
    color: var(--muted);
    text-decoration: none;
    transition: opacity 0.2s var(--ease), color 0.2s var(--ease);
    flex-shrink: 0;
}
.legal-content h2:hover .anchor { opacity: 1; }
.legal-content h2 .anchor:hover { color: var(--violet); }

/* ============================================================
   FOOTER
   ============================================================ */
.legal-footer {
    position: relative;
    z-index: 1;
    padding: 32px clamp(20px, 5vw, 48px) 48px;
    border-top: 1px solid var(--line);
    background: rgba(5, 6, 13, 0.6);
}

.legal-footer-inner {
    max-width: 1160px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 20px 32px;
    justify-content: space-between;
    align-items: flex-start;
    font-size: 13px;
    color: var(--muted);
}

.legal-footer-brand {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 340px;
}
.legal-footer-brand strong {
    font-family: 'Instrument Serif', serif;
    font-size: 17px;
    color: var(--text);
    letter-spacing: 0.3px;
}
.legal-footer-brand span {
    color: var(--muted);
    line-height: 1.5;
    font-size: 12.5px;
}

.legal-footer-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    max-width: 520px;
}
.legal-footer-nav a {
    color: var(--text-dim);
    text-decoration: none;
    transition: color 0.2s var(--ease);
    font-size: 12.5px;
}
.legal-footer-nav a:hover {
    color: #eaf0ff;
}

.legal-footer-meta {
    width: 100%;
    padding-top: 20px;
    margin-top: 4px;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 12px;
    color: var(--muted);
}

/* ============================================================
   BACK TO TOP
   ============================================================ */
.back-to-top {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 30;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--line-strong);
    background: rgba(16, 22, 44, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: var(--text-soft);
    cursor: pointer;
    display: grid;
    place-items: center;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
    transition: opacity 0.25s var(--ease), transform 0.25s var(--ease), border-color 0.25s var(--ease), color 0.25s var(--ease);
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
}
.back-to-top.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}
.back-to-top:hover {
    border-color: rgba(161, 123, 255, 0.55);
    color: #eaf0ff;
    transform: translateY(-2px);
}
.back-to-top svg { width: 18px; height: 18px; }

/* ============================================================
   BANNER "Esta página está en ES/EN"
   ============================================================ */
.lang-notice {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    margin: 0 0 24px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(161, 123, 255, 0.25);
    background: rgba(161, 123, 255, 0.06);
    font-size: 13px;
    color: var(--text-soft);
    line-height: 1.5;
}
.lang-notice svg {
    color: var(--violet);
    flex-shrink: 0;
}
.lang-notice[hidden] { display: none; }

/* ============================================================
   UTILIDADES
   ============================================================ */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-to-content {
    position: absolute;
    top: -100px;
    left: 16px;
    padding: 10px 16px;
    background: var(--violet);
    color: #fff;
    border-radius: 8px;
    font-size: 14px;
    text-decoration: none;
    z-index: 100;
    transition: top 0.2s var(--ease);
}
.skip-to-content:focus {
    top: 16px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 960px) {
    .legal-main {
        grid-template-columns: 1fr;
        gap: 24px;
        padding-top: 24px;
    }
    .legal-toc {
        position: relative;
        top: 0;
        max-height: 280px;
    }
}

@media (max-width: 620px) {
    .legal-nav {
        padding: 12px 16px;
        flex-wrap: wrap;
    }
    .legal-nav-links a {
        padding: 6px 10px;
        font-size: 12px;
    }
    .legal-lang-select {
        font-size: 12px;
    }
    .legal-content {
        font-size: 15px;
    }
    .legal-content h2 {
        font-size: 24px;
    }
    .legal-content h3 {
        font-size: 18px;
    }
    .legal-footer {
        padding: 24px 16px 32px;
    }
    .back-to-top {
        right: 14px;
        bottom: 14px;
        width: 40px;
        height: 40px;
    }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
    html, body {
        background: #fff !important;
        color: #000 !important;
    }
    body::before { display: none; }

    .legal-nav,
    .legal-toc,
    .back-to-top,
    .legal-footer-nav,
    .skip-to-content,
    .lang-notice {
        display: none !important;
    }

    .legal-main {
        display: block !important;
        max-width: none !important;
        padding: 0 !important;
    }
    .legal-content {
        max-width: none;
        font-size: 11pt;
        line-height: 1.5;
        color: #000;
    }
    .legal-content h2 {
        color: #000;
        border-bottom: 1px solid #ccc;
        page-break-after: avoid;
    }
    .legal-content h3 {
        color: #000;
        page-break-after: avoid;
    }
    .legal-content a {
        color: #000;
        text-decoration: underline;
    }
    .legal-content a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 0.85em;
        color: #555;
    }
    .legal-content section {
        page-break-inside: avoid;
    }
    .legal-hero h1 {
        color: #000;
        text-shadow: none;
    }
    .legal-footer {
        background: #fff;
        color: #333;
        border-top: 1px solid #ccc;
    }
    .legal-footer-brand strong { color: #000; }
}

/* Tipografía para chino */
html[lang="zh"] body,
html[lang="zh"] .legal-content,
html[lang="zh"] .legal-hero h1,
html[lang="zh"] .legal-content h2,
html[lang="zh"] .legal-content h3 {
    font-family: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont,
                 system-ui, 'PingFang SC', 'Hiragino Sans GB',
                 'Microsoft YaHei', sans-serif;
    letter-spacing: 0.02em;
}
html[lang="zh"] .legal-hero h1,
html[lang="zh"] .legal-content h2,
html[lang="zh"] .legal-content h3 {
    font-weight: 500;
}
html[lang="zh"] .legal-content em { font-style: normal; font-weight: 600; }
