/**
 * css/wiclee-legal.css — Documentos legales públicos (aviso legal, privacidad, cookies).
 *
 * Contexto: lo cargan templates/home/legal/_legal_layout.twig y, por herencia, los tres
 * documentos. Sustituye a css/wiclee-landing-legal.css. Pensado también para los futuros
 * textos contractuales (condiciones, contrato marco) y la pantalla de aceptación.
 * Reglas: solo tokens de css/tokens.css, sin hex, sin estilos en línea, mobile-first.
 * Variables heredadas de wiclee-landing.css: --wiclee-landing-header-h, --wiclee-landing-gutter.
 * Notas de mantenimiento: la numeración de secciones es automática (contadores CSS);
 * no escribir números a mano en los títulos.
 */

.wiclee-legal {
  --wiclee-legal-toc-w: 15rem;
  --wiclee-legal-doc-w: 50rem;
  --wiclee-legal-wrap-w: 74rem;
  --wiclee-legal-sticky-top: calc(var(--wiclee-landing-header-h) + var(--wiclee-space-lg));
  background: var(--wiclee-bg-card);
  color: var(--wiclee-text);
}

.wiclee-legal__wrap {
  width: 100%;
  max-width: var(--wiclee-legal-wrap-w);
  margin: 0 auto;
  padding: 0 var(--wiclee-landing-gutter);
}

/* ---------- Cabecera del documento ---------- */

.wiclee-legal__hero {
  padding-top: var(--wiclee-space-2xl);
  border-bottom: 0.0625rem solid var(--wiclee-border);
  background: var(--wiclee-primary-50);
}

.wiclee-legal__kicker {
  margin: 0 0 var(--wiclee-space-sm);
  color: var(--wiclee-primary-800);
  font-size: var(--wiclee-font-size-xs);
  font-weight: var(--wiclee-font-weight-extrabold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.wiclee-legal__title {
  max-width: 40rem;
  margin: 0 0 var(--wiclee-space-md);
  color: var(--wiclee-text);
  font-size: clamp(1.875rem, 4vw, 2.75rem);
  font-weight: var(--wiclee-font-weight-extrabold);
  letter-spacing: -0.03em;
  line-height: 1.12;
}

.wiclee-legal__lead {
  max-width: 44rem;
  margin: 0 0 var(--wiclee-space-lg);
  color: var(--wiclee-text-secondary);
  font-size: 1.125rem;
  line-height: 1.6;
}

.wiclee-legal__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--wiclee-space-xs) var(--wiclee-space-lg);
  margin: 0 0 var(--wiclee-space-xl);
  padding: 0;
  list-style: none;
  color: var(--wiclee-text-muted);
  font-size: var(--wiclee-font-size-sm);
}

.wiclee-legal__meta strong {
  color: var(--wiclee-text-secondary);
  font-weight: var(--wiclee-font-weight-bold);
}

/* ---------- Selector de documento (pestañas rectas, sin píldoras) ---------- */

.wiclee-legal__tabs {
  display: flex;
  gap: 0;
  margin: 0;
  padding: 0;
  overflow-x: auto;
  list-style: none;
  -webkit-overflow-scrolling: touch;
}

.wiclee-legal__tab {
  display: block;
  min-height: 3rem;
  padding: var(--wiclee-space-md) var(--wiclee-space-lg);
  border-bottom: 0.1875rem solid transparent;
  color: var(--wiclee-text-secondary);
  font-size: var(--wiclee-font-size-md);
  font-weight: var(--wiclee-font-weight-bold);
  line-height: 1.4;
  text-decoration: none;
  white-space: nowrap;
}

.wiclee-legal__tabs li:first-child .wiclee-legal__tab {
  padding-left: 0;
}

.wiclee-legal__tab:hover {
  color: var(--wiclee-text);
  border-bottom-color: var(--wiclee-primary-300);
}

.wiclee-legal__tab[aria-current="page"] {
  color: var(--wiclee-primary-900);
  border-bottom-color: var(--wiclee-primary-700);
}

.wiclee-legal__tab:focus-visible,
.wiclee-legal__toc-link:focus-visible,
.wiclee-legal__toc-summary:focus-visible,
.wiclee-legal__doc a:focus-visible {
  outline: 0.125rem solid var(--wiclee-primary-700);
  outline-offset: 0.125rem;
}

/* ---------- Rejilla índice + documento ---------- */

.wiclee-legal__layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--wiclee-space-lg);
  padding-top: var(--wiclee-space-xl);
  padding-bottom: calc(var(--wiclee-space-2xl) * 2);
}

.wiclee-legal__toc {
  min-width: 0;
}

/* Móvil: el índice es un <details> plegado; en escritorio se muestra abierto y fijo. */
.wiclee-legal__toc-details {
  border: 0.0625rem solid var(--wiclee-border);
  background: var(--wiclee-bg-page);
}

.wiclee-legal__toc-summary {
  display: block;
  padding: var(--wiclee-space-md);
  color: var(--wiclee-text);
  font-size: var(--wiclee-font-size-sm);
  font-weight: var(--wiclee-font-weight-extrabold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.wiclee-legal__toc-list {
  margin: 0;
  padding: 0 var(--wiclee-space-md) var(--wiclee-space-md);
  list-style: none;
  counter-reset: toc;
}

.wiclee-legal__toc-item {
  counter-increment: toc;
}

.wiclee-legal__toc-link {
  display: block;
  padding: var(--wiclee-space-sm) var(--wiclee-space-md);
  border-left: 0.125rem solid var(--wiclee-border);
  color: var(--wiclee-text-secondary);
  font-size: var(--wiclee-font-size-sm);
  line-height: 1.4;
  text-decoration: none;
}

.wiclee-legal__toc-link::before {
  content: counter(toc) ". ";
  color: var(--wiclee-text-muted);
}

.wiclee-legal__toc-link:hover {
  color: var(--wiclee-text);
  border-left-color: var(--wiclee-primary-300);
}

.wiclee-legal__toc-link.is-active {
  border-left-color: var(--wiclee-primary-700);
  color: var(--wiclee-primary-900);
  font-weight: var(--wiclee-font-weight-bold);
}

/* ---------- Documento ---------- */

.wiclee-legal__doc {
  min-width: 0;
  max-width: var(--wiclee-legal-doc-w);
  counter-reset: seccion;
}

.wiclee-legal__seccion {
  padding-top: var(--wiclee-space-xl);
  margin-top: var(--wiclee-space-xl);
  border-top: 0.0625rem solid var(--wiclee-border);
  scroll-margin-top: var(--wiclee-legal-sticky-top);
  counter-increment: seccion;
}

.wiclee-legal__seccion:first-of-type {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.wiclee-legal__h2 {
  display: flex;
  gap: var(--wiclee-space-sm);
  align-items: baseline;
  margin: 0 0 var(--wiclee-space-md);
  color: var(--wiclee-text);
  font-size: 1.375rem;
  font-weight: var(--wiclee-font-weight-extrabold);
  line-height: 1.3;
}

.wiclee-legal__h2::before {
  content: counter(seccion) ".";
  color: var(--wiclee-primary-800);
}

.wiclee-legal__h3 {
  margin: var(--wiclee-space-lg) 0 var(--wiclee-space-sm);
  color: var(--wiclee-primary-900);
  font-size: 1.0625rem;
  font-weight: var(--wiclee-font-weight-extrabold);
  line-height: 1.35;
}

.wiclee-legal__doc p,
.wiclee-legal__doc li {
  color: var(--wiclee-text);
  font-size: var(--wiclee-font-size-md);
  line-height: 1.7;
}

.wiclee-legal__doc p {
  margin: 0 0 var(--wiclee-space-md);
}

.wiclee-legal__doc ul,
.wiclee-legal__doc ol {
  margin: 0 0 var(--wiclee-space-md);
  padding-left: 1.25rem;
}

.wiclee-legal__doc li + li {
  margin-top: var(--wiclee-space-xs);
}

.wiclee-legal__doc a {
  color: var(--wiclee-primary-800);
  font-weight: var(--wiclee-font-weight-bold);
  text-underline-offset: 0.2em;
}

.wiclee-legal__doc a:hover {
  color: var(--wiclee-primary-900);
}

.wiclee-legal__doc code {
  padding: 0.1em 0.35em;
  border-radius: var(--wiclee-radius-sm);
  background: var(--wiclee-bg-muted);
  color: var(--wiclee-primary-900);
  font-size: 0.92em;
}

/* ---------- Resumen de primera capa ---------- */

.wiclee-legal__resumen {
  margin: 0 0 var(--wiclee-space-xl);
  padding: var(--wiclee-space-lg);
  border-left: 0.25rem solid var(--wiclee-primary-700);
  background: var(--wiclee-bg-page);
}

.wiclee-legal__resumen-title {
  margin: 0 0 var(--wiclee-space-md);
  font-size: var(--wiclee-font-size-sm);
  font-weight: var(--wiclee-font-weight-extrabold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.wiclee-legal__facts {
  display: grid;
  gap: var(--wiclee-space-md);
  margin: 0;
}

.wiclee-legal__facts dt {
  color: var(--wiclee-text-muted);
  font-size: var(--wiclee-font-size-sm);
  font-weight: var(--wiclee-font-weight-bold);
}

.wiclee-legal__facts dd {
  margin: 0;
  font-size: var(--wiclee-font-size-md);
  line-height: 1.55;
}

/* ---------- Avisos dentro del texto ---------- */

.wiclee-legal__nota {
  margin: 0 0 var(--wiclee-space-md);
  padding: var(--wiclee-space-md);
  border-left: 0.25rem solid var(--wiclee-accent-500);
  background: var(--wiclee-accent-50);
}

.wiclee-legal__nota p:last-child {
  margin-bottom: 0;
}

/* ---------- Tablas ---------- */

.wiclee-legal__table-wrap {
  margin: 0 0 var(--wiclee-space-md);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 0.0625rem solid var(--wiclee-border);
}

.wiclee-legal__table {
  width: 100%;
  min-width: 38rem;
  border-collapse: collapse;
  font-size: var(--wiclee-font-size-sm);
}

.wiclee-legal__table th,
.wiclee-legal__table td {
  padding: var(--wiclee-space-sm) var(--wiclee-space-md);
  border-bottom: 0.0625rem solid var(--wiclee-border);
  text-align: left;
  vertical-align: top;
  line-height: 1.5;
}

.wiclee-legal__table th {
  background: var(--wiclee-bg-muted);
  color: var(--wiclee-text-secondary);
  font-weight: var(--wiclee-font-weight-bold);
}

.wiclee-legal__table tbody tr:last-child td {
  border-bottom: 0;
}

/* ---------- Documentos relacionados ---------- */

.wiclee-legal__related {
  margin: var(--wiclee-space-2xl) 0 0;
  padding: 0;
  list-style: none;
  border-top: 0.0625rem solid var(--wiclee-border);
}

.wiclee-legal__related a {
  display: flex;
  justify-content: space-between;
  gap: var(--wiclee-space-md);
  min-height: 3rem;
  padding: var(--wiclee-space-md) 0;
  border-bottom: 0.0625rem solid var(--wiclee-border);
  align-items: center;
  text-decoration: none;
}

.wiclee-legal__related a::after {
  content: "\2192";
}

/* ---------- Escritorio ---------- */

@media (min-width: 992px) {
  .wiclee-legal__layout {
    grid-template-columns: var(--wiclee-legal-toc-w) minmax(0, 1fr);
    gap: calc(var(--wiclee-space-2xl) + var(--wiclee-space-md));
    padding-top: var(--wiclee-space-2xl);
  }

  .wiclee-legal__toc-details {
    position: sticky;
    top: var(--wiclee-legal-sticky-top);
    max-height: calc(100vh - var(--wiclee-legal-sticky-top) - var(--wiclee-space-lg));
    overflow-y: auto;
    border: 0;
    background: transparent;
  }

  .wiclee-legal__toc-summary {
    padding-left: 0;
    cursor: default;
    pointer-events: none;
  }

  .wiclee-legal__toc-list {
    padding-right: 0;
    padding-left: 0;
  }

  .wiclee-legal__facts {
    grid-template-columns: 11rem minmax(0, 1fr);
  }
}

@media (max-width: 575px) {
  .wiclee-legal__hero {
    padding-top: var(--wiclee-space-xl);
  }

  .wiclee-legal__tab {
    padding-right: var(--wiclee-space-md);
    padding-left: var(--wiclee-space-md);
  }
}

@media print {
  .wiclee-legal__toc,
  .wiclee-legal__tabs {
    display: none;
  }
}
