/**
 * legal.css: términos y condiciones, política de privacidad y política de cookies.
 * Mismo lenguaje visual que sobre.css (tarjetas sobre --surface, kicker dorado, números de sección,
 * titulares light). Estructura en app/public/pages/_legal.php. Prefijo .lg- dentro de .legal;
 * los breakpoints viven acá (761 y 1101, como el resto del sitio).
 * Contraste (WCAG 2.x): --text 17,6:1 sobre --bg y 16,3:1 sobre --surface; --text-2 9,5:1 / 8,8:1;
 * --gold 8,3:1 / 7,7:1.
 */

.legal {
  --lg-gutter: 1rem;
  --lg-radius: 6px;
  color: var(--text);
}

.lg-wrap {
  width: 100%;
  padding: 0 var(--lg-gutter);
}

:where(.legal) ul,
:where(.legal) ol,
:where(.legal) dl {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ---------- Cabecera ---------- */
.lg-hero {
  padding: 6.5rem 0 2.25rem;
  border-bottom: 1px solid var(--border);
}

.lg-kicker {
  color: var(--gold);
  font-size: .9rem;
  font-weight: 600;
}

.lg-h1 {
  margin-top: 1rem;
  max-width: 18ch;
  font-size: clamp(2.2rem, 7vw, 3.9rem);
  font-weight: 300;
  line-height: 1.05;
  letter-spacing: -.02em;
  text-wrap: balance;
}

.legal .lg-lead {
  margin-top: 1.25rem;
  max-width: 60ch;
  color: var(--text-2);
  font-size: clamp(1.05rem, 2.2vw, 1.2rem);
  line-height: 1.55;
}

.legal .lg-meta {
  display: inline-block;
  margin-top: 1.4rem;
  padding-top: .85rem;
  border-top: 1px solid var(--gold-line);
  color: var(--text-2);
  font-size: .9rem;
}

/* Pestañas entre los tres documentos. */
.lg-tabs {
  margin-top: 2rem;
}

.lg-tabs ul {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.lg-tab {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 1rem;
  border: 1px solid var(--border-md);
  border-radius: 999px;
  color: var(--text-2);
  font-size: .9rem;
  font-weight: 500;
  text-decoration: none;
  transition: color .2s, border-color .2s, background-color .2s;
}

.lg-tab:hover {
  color: var(--text);
  border-color: var(--gold-line);
}

.lg-tab.is-current {
  color: var(--text);
  border-color: var(--gold-line);
  background: var(--gold-dim);
}

.lg-tab:focus-visible,
.lg-toc a:focus-visible,
.lg-link:focus-visible,
.lg-body a:focus-visible,
.lg-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

/* ---------- Resumen en tarjetas ---------- */
.lg-summary {
  display: grid;
  gap: 1rem;
  margin-top: 2rem;
}

.lg-card {
  padding: 1.4rem 1.25rem;
  border: 1px solid var(--border-md);
  border-radius: var(--lg-radius);
  background: var(--surface);
}

.lg-card--action {
  background: var(--bg-raised);
  border-color: var(--gold-line);
}

.legal .lg-card .lg-card-title {
  margin-bottom: .5rem;
  color: var(--gold);
  font-size: .95rem;
  font-weight: 600;
}

.legal .lg-card p:not(.lg-card-title) {
  color: var(--text-2);
  font-size: .95rem;
  line-height: 1.6;
}

.lg-card .lg-btn {
  margin-top: 1rem;
}

/* ---------- Índice + cuerpo ---------- */
.lg-layout {
  display: grid;
  gap: 2rem;
  padding-top: 2rem;
  padding-bottom: 4rem;
}

.lg-toc {
  padding: 1.25rem;
  border: 1px solid var(--border-md);
  border-radius: var(--lg-radius);
  background: var(--bg-raised);
}

.legal .lg-toc-title {
  margin-bottom: .6rem;
  color: var(--text);
  font-size: .95rem;
  font-weight: 600;
}

.lg-toc a {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  min-height: 40px;
  padding: .55rem 0;
  border-top: 1px solid var(--border);
  color: var(--text-2);
  font-size: .92rem;
  line-height: 1.35;
  text-decoration: none;
  transition: color .2s;
}

.lg-toc li:first-child a {
  border-top: 0;
}

.lg-toc a:hover {
  color: var(--text);
}

.lg-toc-num {
  flex: none;
  color: var(--gold);
  font-size: .8rem;
  font-variant-numeric: tabular-nums;
}

.lg-body {
  min-width: 0;
  max-width: 46rem;
}

.lg-sec {
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  scroll-margin-top: 6rem;
}

.lg-sec:first-child {
  padding-top: 0;
  border-top: 0;
}

.lg-h2 {
  display: flex;
  align-items: baseline;
  gap: .9rem;
  margin-bottom: 1.1rem;
  font-size: clamp(1.45rem, 4.4vw, 1.9rem);
  font-weight: 300;
  line-height: 1.15;
  letter-spacing: -.01em;
  scroll-margin-top: 6rem;
}

.lg-num {
  flex: none;
  color: var(--gold);
  font-size: .95rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.lg-h3 {
  margin: 1.5rem 0 .5rem;
  color: var(--text);
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.3;
}

.lg-h2 + .lg-h3 {
  margin-top: 0;
}

.lg-body p,
.lg-body li {
  color: var(--text-2);
  font-size: 1rem;
  line-height: 1.7;
}

.lg-body p + p,
.lg-body p + ul,
.lg-body ul + p,
.lg-body p + .lg-table-wrap,
.lg-body .lg-table-wrap + p,
.lg-body p + .lg-facts {
  margin-top: 1rem;
}

.lg-body strong {
  color: var(--text);
  font-weight: 600;
}

.lg-body a,
.lg-link {
  color: var(--gold);
  text-decoration: underline;
  text-decoration-color: var(--gold-line);
  text-underline-offset: 4px;
  overflow-wrap: anywhere;
}

.lg-body a:hover,
.lg-link:hover {
  text-decoration-color: var(--gold);
}

.lg-body code {
  color: var(--text);
  font-size: .88em;
  overflow-wrap: anywhere;
}

/* Viñetas con guion dorado. */
.lg-body ul:not(.lg-links) li {
  position: relative;
  padding-left: 1.25rem;
}

.lg-body ul:not(.lg-links) li + li {
  margin-top: .55rem;
}

.lg-body ul:not(.lg-links) li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .82em;
  width: .55rem;
  height: 1px;
  background: var(--gold);
}

.lg-links {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
}

.lg-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.legal .lg-note {
  padding: 1rem 1.1rem;
  border-left: 2px solid var(--gold-line);
  background: var(--bg-raised);
  font-size: .95rem;
}

/* Datos del responsable. */
.lg-facts {
  display: grid;
  border: 1px solid var(--border-md);
  border-radius: var(--lg-radius);
  background: var(--surface);
}

.lg-facts div {
  display: grid;
  align-content: start;
  gap: .2rem;
  padding: .85rem 1.1rem;
  border-top: 1px solid var(--border);
}

.lg-facts div:first-child {
  border-top: 0;
}

.lg-facts dt {
  color: var(--gold);
  font-size: .85rem;
  font-weight: 600;
}

.lg-facts dd {
  margin: 0;
  color: var(--text);
  font-size: .98rem;
}

/* Tablas: en móvil cada fila es una tarjeta con etiquetas (data-label). */
.lg-table-wrap {
  border: 1px solid var(--border-md);
  border-radius: var(--lg-radius);
  background: var(--surface);
  overflow: hidden;
}

.lg-table,
.lg-table tbody {
  display: block;
  width: 100%;
  border-collapse: collapse;
}

.lg-table thead {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.lg-table tr {
  display: block;
  padding: .9rem 1.1rem;
  border-top: 1px solid var(--border);
}

.lg-table tbody tr:first-child {
  border-top: 0;
}

.lg-table td {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: .75rem;
  padding: .3rem 0;
  color: var(--text-2);
  font-size: .92rem;
  line-height: 1.55;
  text-align: left;
  vertical-align: top;
}

.lg-table td::before {
  content: attr(data-label);
  color: var(--gold);
  font-size: .8rem;
  font-weight: 600;
}

.lg-table td:first-child {
  color: var(--text);
}

.lg-btn {
  min-height: 44px;
}

/* Cierre de contacto. */
.lg-contact {
  margin-top: 1rem;
  padding: 1.5rem 1.25rem;
  border: 1px solid var(--gold-line);
  border-radius: var(--lg-radius);
  background: var(--bg-raised);
}

.legal .lg-contact-title {
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 500;
}

.legal .lg-contact p:not(.lg-contact-title) {
  margin-top: .4rem;
  color: var(--text-2);
  font-size: .95rem;
  line-height: 1.6;
}

.lg-contact .lg-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-top: .4rem;
  font-weight: 600;
}

/* ---------- 761 px ---------- */
@media (min-width: 761px) {
  .legal {
    --lg-gutter: 2rem;
  }

  .lg-hero {
    padding-top: 8rem;
    padding-bottom: 2.75rem;
  }

  .lg-summary {
    grid-template-columns: repeat(3, 1fr);
  }

  .lg-card {
    padding: 1.6rem 1.5rem;
  }

  .lg-facts {
    grid-template-columns: repeat(3, 1fr);
  }

  .lg-facts div {
    border-top: 0;
    border-left: 1px solid var(--border);
  }

  .lg-facts div:first-child {
    border-left: 0;
  }

  /* Tabla clásica desde tablet. */
  .lg-table {
    display: table;
  }

  .lg-table tbody {
    display: table-row-group;
  }

  .lg-table thead {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
    display: table-header-group;
  }

  .lg-table tr {
    display: table-row;
    padding: 0;
    border-top: 0;
  }

  .lg-table th,
  .lg-table td {
    display: table-cell;
    padding: .85rem 1rem;
    border-top: 1px solid var(--border);
  }

  .lg-table td::before {
    content: none;
  }

  .lg-table th {
    border-top: 0;
    background: var(--bg-raised);
    color: var(--gold);
    font-size: .82rem;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
  }

  .lg-table td:first-child {
    white-space: nowrap;
  }

  .lg-contact {
    padding: 1.75rem 1.75rem;
  }
}

/* ---------- 1101 px: índice fijo a la izquierda ---------- */
@media (min-width: 1101px) {
  .legal {
    --lg-gutter: 3.5rem;
  }

  .lg-hero {
    padding-top: 9.5rem;
  }

  .lg-layout {
    grid-template-columns: 16rem minmax(0, 46rem);
    gap: 4.5rem;
    padding-top: 3rem;
    padding-bottom: 5rem;
  }

  .lg-toc {
    position: sticky;
    top: 7rem;
    align-self: start;
  }

  .lg-sec,
  .lg-h2 {
    scroll-margin-top: 7.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lg-tab,
  .lg-toc a {
    transition: none;
  }
}
