/* ==========================================================================
   Shiroz — hoja de estilo compartida de las páginas legales
   (privacidad.html y terminos.html)

   Vive en /assets/ a propósito: el rewrite de vercel.json manda todo a
   index.html salvo lo que cuelgue de assets/, así que aquí no hay que tocar
   ese regex para que el CSS se sirva.

   Tokens: los mismos nombres que usa el resto del producto. El tema y el
   acento se leen de localStorage con el mismo IIFE que login.html, así que
   quien entre con tema claro y acento rosa ve estas páginas igual de suyas.
   ========================================================================== */

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

:root {
    --bg: #06060b;
    --card: #0e0e18;
    --card-border: rgba(255, 255, 255, 0.07);
    --primary: #00ff88;
    --primary-dim: rgba(0, 255, 136, 0.12);
    --primary-glow: rgba(0, 255, 136, 0.22);
    --primary-rgb: 0, 255, 136;
    --text: #e4e4e7;
    --text-dim: #a1a1aa;
    --text-muted: #52525b;
    --rule: rgba(255, 255, 255, 0.08);
    --warning: #fbbf24;
    --warning-text: #fcd97a;
    --warning-dim: rgba(251, 191, 36, 0.10);
    --warning-border: rgba(251, 191, 36, 0.32);

    /* Escala tipográfica: un solo paso de 1.25 para que los títulos se
       ordenen solos y el cuerpo no compita con ellos. */
    --step-0: 1rem;
    --step-1: 1.15rem;
    --step-2: 1.45rem;
    --step-3: clamp(2.1rem, 1.4rem + 3vw, 3.4rem);

    --measure: 68ch;   /* ancho de lectura: lo que aguanta un ojo sin perderse */
    --gap: 1.6rem;
}

:root[data-theme="light"] {
    --bg: #eef1f7;
    --card: #ffffff;
    --card-border: rgba(0, 0, 0, 0.09);
    --text: #0d1117;
    --text-dim: #4b5563;
    --text-muted: #6b7280;
    --rule: rgba(0, 0, 0, 0.10);
    --warning: #b45309;
    --warning-text: #7c3f06;
    --warning-dim: rgba(180, 83, 9, 0.08);
    --warning-border: rgba(180, 83, 9, 0.28);
}

html {
    scroll-behavior: smooth;
    /* El índice es sticky y mide ~5rem: sin esto, saltar a una sección la
       deja escondida debajo de la barra. */
    scroll-padding-top: 6.5rem;
}

@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 {
    font-family: 'Barlow', sans-serif;
    font-weight: 400;
    background: var(--bg);
    color: var(--text);
    font-size: var(--step-0);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Textura de fondo: dos manchas del color de acento, muy bajas de opacidad.
   Da profundidad sin robarle contraste al texto, que aquí es lo único que
   importa. */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(ellipse 70% 50% at 12% -5%,
            rgba(var(--primary-rgb), 0.07) 0%, transparent 70%),
        radial-gradient(ellipse 60% 45% at 92% 8%,
            rgba(var(--primary-rgb), 0.045) 0%, transparent 72%);
}

:root[data-theme="light"] body::before { opacity: 0.55; }

/* ── Barra superior ─────────────────────────────────────────────────────── */

.legal-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem clamp(1.1rem, 4vw, 3rem);
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--rule);
}

.legal-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: var(--text);
}

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

.legal-brand span {
    font-weight: 900;
    font-size: 1.32rem;
    letter-spacing: 0.045em;
    text-transform: uppercase;
    line-height: 1;
}

.legal-back {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: color 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.legal-back:hover {
    color: var(--primary);
    border-color: rgba(var(--primary-rgb), 0.42);
    background: var(--primary-dim);
}

/* ── Cabecera ───────────────────────────────────────────────────────────── */

.legal-shell {
    position: relative;
    z-index: 1;
    flex: 1;
    width: 100%;
    max-width: 1140px;
    margin: 0 auto;
    padding: clamp(2.5rem, 6vw, 4.5rem) clamp(1.1rem, 4vw, 3rem) 4rem;
}

.legal-eyebrow {
    display: inline-block;
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--primary);
    padding-bottom: 0.7rem;
}

.legal-title {
    font-size: var(--step-3);
    font-weight: 900;
    line-height: 1.02;
    letter-spacing: -0.02em;
    text-transform: uppercase;
}

/* Regla de acento bajo el título: el único adorno de la página. */
.legal-title::after {
    content: '';
    display: block;
    width: 82px;
    height: 3px;
    margin-top: 1.15rem;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--primary), transparent);
}

.legal-meta {
    padding-top: 1.15rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.legal-lede {
    max-width: var(--measure);
    padding-top: 1.6rem;
    font-size: var(--step-1);
    color: var(--text-dim);
}

/* ── Cuerpo a dos columnas ──────────────────────────────────────────────── */

.legal-body {
    display: grid;
    grid-template-columns: 232px minmax(0, 1fr);
    gap: clamp(2rem, 5vw, 4.5rem);
    padding-top: clamp(2.5rem, 5vw, 3.75rem);
    align-items: start;
}

.legal-toc {
    position: sticky;
    top: 5.6rem;
    font-size: 0.875rem;
}

.legal-toc h2 {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding-bottom: 0.85rem;
}

.legal-toc ol {
    list-style: none;
    counter-reset: toc;
    border-left: 1px solid var(--rule);
}

.legal-toc a {
    counter-increment: toc;
    display: block;
    position: relative;
    /* Sangría francesa: el número va absoluto y el texto arranca siempre en
       el mismo punto, así una entrada de dos líneas no vuelve al margen y se
       mete debajo de su propio número. */
    padding: 0.34rem 0 0.34rem 2.4rem;
    margin-left: -1px;
    border-left: 2px solid transparent;
    color: var(--text-dim);
    text-decoration: none;
    line-height: 1.4;
    transition: color 0.16s ease, border-color 0.16s ease;
}

.legal-toc a::before {
    content: counter(toc) ".";
    position: absolute;
    left: 1rem;
    top: 0.34rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.legal-toc a:hover {
    color: var(--primary);
    border-left-color: var(--primary);
}

.legal-content {
    max-width: var(--measure);
}

.legal-content section + section { padding-top: 2.9rem; }

.legal-content h2 {
    font-size: var(--step-2);
    font-weight: 900;
    line-height: 1.2;
    letter-spacing: -0.01em;
    padding-bottom: 0.9rem;
}

.legal-content h3 {
    font-size: var(--step-1);
    font-weight: 700;
    padding: 1.5rem 0 0.5rem;
}

.legal-content p { padding-bottom: 0.95rem; }

.legal-content p:last-child,
.legal-content ul:last-child { padding-bottom: 0; }

.legal-content ul {
    list-style: none;
    padding-bottom: 0.95rem;
}

.legal-content li {
    position: relative;
    padding: 0 0 0.55rem 1.35rem;
}

.legal-content li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.72em;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--primary);
    opacity: 0.75;
}

.legal-content strong { font-weight: 700; }

.legal-content a {
    color: var(--primary);
    text-decoration: none;
    border-bottom: 1px solid rgba(var(--primary-rgb), 0.35);
    transition: border-color 0.16s ease;
}

.legal-content a:hover { border-bottom-color: var(--primary); }

/* ── Bloques destacados ─────────────────────────────────────────────────── */

.legal-note {
    padding: 1.15rem 1.3rem;
    margin: 0 0 1.15rem;
    border: 1px solid var(--card-border);
    border-left: 3px solid var(--primary);
    border-radius: 10px;
    background: var(--card);
}

.legal-note p:last-child { padding-bottom: 0; }

.legal-note--warn {
    border-color: var(--warning-border);
    border-left-color: var(--warning);
    background: var(--warning-dim);
    color: var(--warning-text);
}

:root[data-theme="light"] .legal-note--warn { color: var(--warning-text); }

/* ── Tabla de proveedores ───────────────────────────────────────────────── */

.legal-table-wrap {
    /* Sin esto la tabla desborda el body entero en móvil. */
    overflow-x: auto;
    margin-bottom: 1.15rem;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    background: var(--card);
}

/* El ancho de lectura está pensado para prosa; a una tabla de cinco columnas
   lo único que le hace es partir cada celda en tres líneas. En pantallas
   anchas la dejamos salirse hacia la derecha, hasta donde da el contenedor
   sin tocar el borde de la página. */
@media (min-width: 1024px) {
    .legal-table-wrap { width: calc(100% + 5.5rem); }
}

.legal-table {
    width: 100%;
    min-width: 520px;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.legal-table th,
.legal-table td {
    padding: 0.72rem 0.95rem;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--rule);
}

.legal-table th {
    font-weight: 700;
    font-size: 0.74rem;
    letter-spacing: 0.11em;
    text-transform: uppercase;
    color: var(--text-muted);
    white-space: nowrap;
}

.legal-table tbody tr:last-child td { border-bottom: none; }
.legal-table td:first-child { font-weight: 600; white-space: nowrap; }

/* ── Pie ────────────────────────────────────────────────────────────────── */

.legal-foot {
    position: relative;
    z-index: 1;
    padding: 2rem clamp(1.1rem, 4vw, 3rem) 2.5rem;
    border-top: 1px solid var(--rule);
    color: var(--text-muted);
    font-size: 0.875rem;
    text-align: center;
}

.legal-foot nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem 1.4rem;
    padding-bottom: 0.85rem;
}

.legal-foot a {
    color: var(--text-dim);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.16s ease;
}

.legal-foot a:hover { color: var(--primary); }

/* ── Responsive ─────────────────────────────────────────────────────────── */

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

    /* En móvil el índice deja de ser sticky y pasa a ser una tarjeta
       plegable arriba del texto: ocupar una pantalla entera con enlaces
       antes de empezar a leer es peor que no tener índice. */
    .legal-toc {
        position: static;
        border: 1px solid var(--card-border);
        border-radius: 10px;
        background: var(--card);
    }

    .legal-toc-details > summary {
        cursor: pointer;
        list-style: none;
        padding: 0.9rem 1.1rem;
        font-size: 0.74rem;
        font-weight: 700;
        letter-spacing: 0.16em;
        text-transform: uppercase;
        color: var(--text-dim);
    }

    .legal-toc-details > summary::-webkit-details-marker { display: none; }

    /* En móvil el rótulo lo pone el <summary>; el <h2> diría "Índice" una
       segunda vez en cuanto se despliegue. */
    .legal-toc-details > h2 { display: none; }

    .legal-toc-details > summary::after {
        content: '+';
        float: right;
        font-size: 1.05rem;
        line-height: 1;
        color: var(--primary);
    }

    .legal-toc-details[open] > summary::after { content: '–'; }

    .legal-toc ol {
        border-left: none;
        padding: 0 1.1rem 1rem;
    }
}

/* El índice solo se pliega en móvil: en escritorio el resumen sobra, porque
   ya hay un <h2> encima. El <details> nace con `open` en el HTML y un script
   de dos líneas se lo quita solo si la pantalla es chica; la segunda regla
   cubre el caso de cerrarlo en móvil y ensanchar después la ventana, para
   que el índice no se quede escondido sin nada que lo despliegue. */
@media (min-width: 861px) {
    .legal-toc-details > summary { display: none; }
    .legal-toc-details:not([open]) > ol { display: block; }
}

/* ── Accesibilidad ──────────────────────────────────────────────────────── */

a:focus-visible,
summary:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
    border-radius: 4px;
}
