/* ============================================================
   b2nus — hoja de estilo compartida de las páginas legales
   (/legal/, /legal/terminos/, /legal/privacidad/,
    /legal/esign-consent/, /legal/card-terms/)

   Los tokens son los mismos de /sitio/index.html: si allí cambian,
   cámbialos también aquí. Se comparte un archivo —en vez de un
   bloque <style> inline por página— porque las páginas legales son
   visualmente idénticas y así no se desincronizan.
   ============================================================ */
:root {
  --bg: #FBFAFC;
  --surface: #FFFFFF;
  --ink: #17121F;
  --ink-muted: #5C5566;
  --ink-inverse: #F7F4FA;
  --brand-tint: #EDE8F0;
  --brand-tint-strong: #E3DBEA;
  --accent: #6B3FA0;
  --accent-deep: #211642;
  --border: #E7E2EC;
  --border-strong: #D8D0E0;

  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --text-h1: clamp(1.9rem, 4.4vw, 3rem);
  --text-caption: 0.8rem;

  --sp-sm: 1rem;
  --sp-md: 1.5rem;
  --sp-lg: 2.5rem;

  --r-sm: 10px;
  --r-md: 16px;
  --r-pill: 999px;

  --shadow-sm: 0 2px 8px rgba(23, 18, 31, 0.06);
  --shadow-md: 0 10px 30px rgba(23, 18, 31, 0.09);

  --dur-fast: 150ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-padding-top: 6.5rem; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
.wrap { width: min(92vw, 1120px); margin: 0 auto; }
img { max-width: 100%; }

a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px;
}
@media (prefers-reduced-motion: reduce) {
  *, ::before, ::after { transition: none !important; animation: none !important; }
}

.skip {
  position: absolute; left: 1rem; top: -100%; z-index: 60;
  background: var(--accent-deep); color: var(--ink-inverse);
  padding: 0.7rem 1.2rem; border-radius: var(--r-pill);
  text-decoration: none; font-size: var(--text-caption); font-weight: 600;
}
.skip:focus { top: 1rem; }

/* ---------- Encabezado ---------- */
header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(251, 250, 252, 0.88); /* fallback = --bg al 88% */
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
header nav { display: flex; align-items: center; gap: var(--sp-sm); padding: 0.75rem 0; }
header .logo { display: block; flex: none; }
header .logo img { width: 104px; height: auto; display: block; }
.doc-switch { display: flex; gap: 0.25rem; list-style: none; margin-left: auto; }
.doc-switch a {
  display: block; padding: 0.55rem 0.8rem; border-radius: var(--r-sm);
  font-size: 0.85rem; font-weight: 500; color: var(--ink-muted); text-decoration: none;
  transition: color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.doc-switch a:hover { color: var(--accent); background: var(--brand-tint); }
.doc-switch a[aria-current="page"] { color: var(--accent); background: var(--brand-tint); font-weight: 600; }
.pill {
  flex: none;
  font-size: 0.82rem; font-weight: 600; color: var(--ink-inverse);
  background: var(--ink); border-radius: var(--r-pill);
  padding: 0.6rem 1.05rem; text-decoration: none; white-space: nowrap;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.pill:hover { background: var(--accent-deep); }
@media (max-width: 700px) {
  header nav { flex-wrap: wrap; row-gap: 0.4rem; }
  .doc-switch { order: 3; width: 100%; margin-left: 0; overflow-x: auto; }
  .doc-switch a { white-space: nowrap; }
  .pill { margin-left: auto; }
}

/* ---------- Cabecera del documento ---------- */
.doc-head {
  background: linear-gradient(180deg, var(--brand-tint) 0%, var(--bg) 100%);
  padding: clamp(2.5rem, 6vw, 4.5rem) 0 clamp(2rem, 4vw, 3rem);
  border-bottom: 1px solid var(--border);
}
.kicker {
  font-size: var(--text-caption); font-weight: 600; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--accent);
}
.doc-head h1 {
  margin-top: 0.6rem;
  font-family: var(--font-display); font-weight: 600;
  font-size: var(--text-h1); line-height: 1.1; letter-spacing: -0.015em;
  text-wrap: balance; max-width: 20ch;
}
.doc-head .entity { margin-top: var(--sp-sm); color: var(--ink-muted); max-width: 46ch; }
.doc-head .updated {
  display: inline-block; margin-top: var(--sp-md);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-pill); padding: 0.35rem 0.9rem;
  font-size: var(--text-caption); color: var(--ink-muted);
}
/* Nota de cabecera (p. ej. el aviso de idioma del E-Sign Notice). */
.doc-head .note {
  margin-top: var(--sp-md); max-width: 62ch;
  font-size: 0.88rem; line-height: 1.6; color: var(--ink-muted);
}

/* ---------- Layout documento + índice ---------- */
.doc-layout {
  display: grid; grid-template-columns: 260px minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
  padding: clamp(2rem, 5vw, 3.5rem) 0 clamp(3rem, 7vw, 5rem);
}
@media (max-width: 900px) { .doc-layout { grid-template-columns: 1fr; gap: 1.5rem; } }

/* Documento sin índice (páginas cortas: /legal/card-terms/). Misma respiración
   vertical que .doc-layout, sin la columna del índice. */
.doc-solo { padding: clamp(2rem, 5vw, 3.5rem) 0 clamp(3rem, 7vw, 5rem); }

/* Índice */
.toc { position: sticky; top: 5.5rem; max-height: calc(100vh - 7rem); display: flex; flex-direction: column; }
/* The <nav> sits between .toc and the scrollable <ol>. Without min-height:0 it
   keeps its automatic min-content height, refuses to shrink to .toc's
   max-height, and the <ol>'s overflow-y never engages — which silently hid
   two thirds of the index below the fold. */
.toc nav { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.toc-title {
  font-size: var(--text-caption); font-weight: 600; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-muted); margin-bottom: 0.6rem;
}
.toc-toggle { display: none; }
.toc ol { list-style: none; overflow-y: auto; min-height: 0; padding-right: 0.4rem; }
.toc li { margin: 0; }
.toc a {
  display: block; padding: 0.32rem 0.7rem;
  font-size: 0.83rem; line-height: 1.45; color: var(--ink-muted);
  text-decoration: none; border-left: 2px solid var(--border);
  transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.toc a:hover { color: var(--accent); border-left-color: var(--border-strong); }
.toc a[aria-current="true"] { color: var(--accent); border-left-color: var(--accent); font-weight: 600; }
.toc .lvl-3 a { padding-left: 1.5rem; font-size: 0.79rem; }
.toc .group a { font-weight: 600; color: var(--ink); letter-spacing: 0.02em; }
.toc .group + li a { margin-top: 0; }

@media (max-width: 900px) {
  .toc {
    position: static; max-height: none;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-md); padding: 0.9rem 1rem;
  }
  .toc-title { margin-bottom: 0; }
  /* Con JS el índice se pliega; sin JS queda visible y usable. */
  .js .toc-toggle {
    display: flex; align-items: center; justify-content: space-between; gap: 0.8rem;
    width: 100%; background: none; border: 0; cursor: pointer;
    font: 600 var(--text-caption)/1.4 var(--font-body); letter-spacing: 0.14em;
    text-transform: uppercase; color: var(--ink-muted); padding: 0;
  }
  .js .toc-toggle::after {
    content: "+"; content: "+" / ""; font-size: 1.2rem; color: var(--accent);
    font-weight: 400; transition: transform var(--dur-fast) var(--ease-out);
  }
  .js .toc-toggle[aria-expanded="true"]::after { transform: rotate(45deg); }
  .js .toc-title { display: none; }
  .js .toc ol { max-height: min(55vh, 420px); margin-top: 0.7rem; }
  .js .toc ol[hidden] { display: none; }
}

/* ---------- Cuerpo del documento ---------- */
.doc { max-width: 68ch; }
.doc > p:first-child { font-size: 1.06rem; }
.doc p { margin: 0 0 1rem; }
.doc a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.doc strong { font-weight: 600; color: var(--ink); }

/* Banda de TÍTULO (sólo en Términos y Condiciones) */
.doc h2.titulo {
  display: flex; flex-direction: column; gap: 0.2rem;
  margin: 3.2rem 0 1.6rem; padding: 1.1rem 1.3rem;
  background: var(--brand-tint); border-radius: var(--r-md);
  border: 1px solid var(--brand-tint-strong);
}
.doc h2.titulo .titulo-n {
  font: 600 var(--text-caption)/1.4 var(--font-body);
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent);
}
.doc h2.titulo .titulo-t {
  font-family: var(--font-display); font-weight: 600; font-size: 1.32rem;
  line-height: 1.25; letter-spacing: -0.01em; color: var(--ink);
}

/* Encabezados numerados */
.doc h2, .doc h3 { scroll-margin-top: 6.5rem; }
.doc h2:not(.titulo) {
  font-family: var(--font-display); font-weight: 600;
  font-size: 1.45rem; line-height: 1.25; letter-spacing: -0.01em;
  margin: 2.6rem 0 0.9rem; text-wrap: balance;
}
.doc h3 {
  font-family: var(--font-display); font-weight: 600;
  font-size: 1.16rem; line-height: 1.3;
  margin: 2rem 0 0.7rem; text-wrap: balance;
}
.doc h2:not(.titulo) + p, .doc h3 + p { margin-top: 0; }
.doc h2:first-child, .doc h3:first-child { margin-top: 0; }

/* Listas: los marcadores se regeneran con contadores CSS y reproducen
   exactamente los del documento original —"I." romano, "a)" alfabético—. */
.doc ol.lst { list-style: none; display: grid; gap: 0.55rem; margin: 0 0 1.1rem; padding: 0; }
.doc ol.lst > li { position: relative; padding-left: 2.7rem; }
.doc ol.lst > li::before {
  position: absolute; left: 0; top: 0; width: 2.1rem;
  text-align: right; font-weight: 600; color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.doc ol.lst-roman { counter-reset: lst-r; }
.doc ol.lst-roman > li { counter-increment: lst-r; }
.doc ol.lst-roman > li::before { content: counter(lst-r, upper-roman) "."; }
.doc ol.lst-alpha { counter-reset: lst-a; }
.doc ol.lst-alpha > li { counter-increment: lst-a; }
.doc ol.lst-alpha > li::before { content: counter(lst-a, lower-alpha) ")"; }
.doc ol.lst ol.lst { margin: 0.6rem 0 0.2rem; }

/* Marcadores decimales y viñetas: los usan las páginas que no vienen del
   convertidor .docx (/legal/esign-consent/, /legal/card-terms/), donde el
   documento original numera "1., 2., …" o usa una lista sin numerar. */
.doc ol.lst-decimal { counter-reset: lst-d; }
.doc ol.lst-decimal > li { counter-increment: lst-d; }
.doc ol.lst-decimal > li::before { content: counter(lst-d) "."; }
.doc ul.lst { list-style: none; display: grid; gap: 0.55rem; margin: 0 0 1.1rem; padding: 0; }
.doc ul.lst > li { position: relative; padding-left: 2.7rem; }
.doc ul.lst.lst-bullet > li::before {
  content: "•"; position: absolute; left: 0; top: 0; width: 2.1rem;
  text-align: right; font-weight: 600; color: var(--accent);
}

/* Anexo */
.doc .annex-rule { border: 0; border-top: 1px solid var(--border); margin: 3.5rem 0 2.5rem; }
.doc .annex-note { font-size: 0.88rem; color: var(--ink-muted); font-style: italic; }
.doc .annex-label { display: none; } /* el número de anexo ya va en el encabezado */

.doc-foot {
  margin-top: 3rem; padding-top: 1.4rem; border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; gap: 0.8rem 1.5rem; align-items: center;
  font-size: var(--text-caption); color: var(--ink-muted);
}
.doc-foot a { color: var(--accent); text-decoration: none; font-weight: 600; }
.doc-foot a:hover { text-decoration: underline; }

/* ---------- Índice de /legal/ ---------- */
.legal-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--sp-sm); padding: clamp(2rem, 5vw, 3.5rem) 0; }
@media (max-width: 700px) { .legal-cards { grid-template-columns: 1fr; } }
.legal-card {
  display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: var(--sp-md); text-decoration: none; color: inherit;
  transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.legal-card:hover { border-color: var(--brand-tint-strong); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.legal-card h2 { font-family: var(--font-display); font-weight: 600; font-size: 1.25rem; line-height: 1.25; }
.legal-card p { margin-top: 0.5rem; font-size: 0.9rem; color: var(--ink-muted); }
.legal-card .go { margin-top: var(--sp-sm); display: inline-block; font-size: var(--text-caption); font-weight: 600; color: var(--accent); }

/* ---------- Pie ---------- */
footer { border-top: 1px solid var(--border); padding: var(--sp-lg) 0; }
footer .wrap { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-sm); flex-wrap: wrap; }
footer img { width: 88px; height: auto; opacity: 0.9; }
footer p { font-size: var(--text-caption); color: var(--ink-muted); }
footer nav { display: flex; gap: 1rem; flex-wrap: wrap; }
footer nav a { font-size: var(--text-caption); color: var(--ink-muted); text-decoration: none; }
footer nav a:hover { color: var(--accent); text-decoration: underline; }

/* ---------- Impresión ---------- */
@media print {
  header, .toc, .skip, .doc-foot, footer nav, .pill { display: none !important; }
  body { background: #fff; color: #000; font-size: 10.5pt; line-height: 1.45; }
  .doc-head { background: none; border-bottom: 1px solid #000; padding: 0 0 1rem; }
  .doc-layout { display: block; padding: 1rem 0 0; }
  .doc { max-width: none; }
  .doc h2, .doc h3 { break-after: avoid; }
  .doc ol.lst > li, .doc ul.lst > li, .doc p { break-inside: avoid; }
  .doc h2.titulo { background: none; border: 0; border-top: 2px solid #000; border-radius: 0; padding: 0.6rem 0 0; }
  .doc ol.lst > li::before, .doc ul.lst > li::before, .kicker, .doc a { color: #000; }
  /* Only internal links need their destination spelled out on paper: every
     external/mailto link in these documents already shows the address as its
     own text, so appending the href would just print it twice. */
  .doc a[href^="/"]::after { content: " (https://b2nus.com" attr(href) ")"; font-size: 0.85em; word-break: break-all; }
  .wrap { width: auto; }
}
