/* ==================================================================
 * DescClamp — clamp de descripciones en tablas (variante B: chevron +
 * bottom difuminado). Componente `DescClamp.astro`.
 *
 * Mejora progresiva: sin JS no hay `.is-clamped` y el texto se ve
 * completo. Con JS, el toggle solo se activa cuando la descripción
 * desborda 3 líneas (`scrollHeight > clientHeight`).
 *
 * La descripción es el PRIMER hijo de `.desc-clamp` (slot `description`);
 * las líneas secundarias (`.param-default`, `.param-example`,
 * `.schema-shared-note`) van en el slot `secondary` y se ocultan cuando
 * está plegado (P2).
 * ================================================================== */

.desc-clamp {
  position: relative;
}

/* --- Clamp a 3 líneas (el «…» es nativo, nunca literal). El índice de
 * esquemas pide 2 con `data-lines="2"` (prop `lines`). --- */
.desc-clamp.is-clamped > :first-child {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  position: relative;
}

.desc-clamp[data-lines='2'].is-clamped > :first-child {
  -webkit-line-clamp: 2;
}

.desc-clamp.is-clamped.is-expanded > :first-child {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
}

/* --- Variante B: bottom difuminado sobre el texto truncado --- */
.desc-clamp.is-clamped > :first-child::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1.6em;
  pointer-events: none;
  background: linear-gradient(to bottom, transparent, var(--color-surface) 85%);
}

.desc-clamp.is-clamped.is-expanded > :first-child::after {
  display: none;
}

/* El fade sigue al fondo de cada sitio: --color-bg en las fichas del
 * índice de esquemas, --color-bg-hover en hover de fila. */
.schemas-item .desc-clamp.is-clamped > :first-child::after {
  background: linear-gradient(to bottom, transparent, var(--color-bg) 85%);
}

.schemas-item.is-target .desc-clamp.is-clamped > :first-child::after {
  background: linear-gradient(to bottom, transparent, var(--color-primary-light) 85%);
}

tbody tr:hover .desc-clamp.is-clamped > :first-child::after {
  background: linear-gradient(to bottom, transparent, var(--color-bg-hover) 85%);
}

/* --- P2: líneas secundarias dentro del área expandible --- */
.desc-clamp.is-clamped:not(.is-expanded) .param-default,
.desc-clamp.is-clamped:not(.is-expanded) .param-example,
.desc-clamp.is-clamped:not(.is-expanded) .schema-shared-note {
  display: none;
}

/* --- Toggle chevron (solo indicador visual; el click es en la celda) --- */
.desc-clamp-toggle {
  display: none;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  user-select: none;
}

.desc-clamp.is-clamped .desc-clamp-toggle {
  display: inline-flex;
}

.desc-clamp-toggle svg {
  width: 16px;
  height: 16px;
  flex: none;
  transition: transform 200ms ease;
}

.desc-clamp.is-clamped.is-expanded .desc-clamp-toggle svg {
  transform: rotate(180deg);
}

.desc-clamp-toggle .desc-clamp-lbl-expanded {
  display: none;
}

.desc-clamp.is-clamped.is-expanded .desc-clamp-toggle .desc-clamp-lbl-collapsed {
  display: none;
}

.desc-clamp.is-clamped.is-expanded .desc-clamp-toggle .desc-clamp-lbl-expanded {
  display: inline;
}

/* --- Objetivo clicable (celda, o el envoltorio fuera de tablas; la clase
 * la pone el JS al activar el clamp) --- */
.desc-cell {
  cursor: pointer;
}

.desc-cell:focus-visible {
  outline: 2px solid var(--color-link);
  outline-offset: -2px;
}
