/*
 * El match de PetFi (lib/nueva/pages/match): «la Dupla» de la app, con su
 * familia de color (`--v5-dupla-*`, la misma de V5Tokens).
 * Solo variables: los valores viven en tokens.css.
 *
 * El HTML trae todos los pasos (sin sesión, organización, filtros, mazo y
 * top 3) y match.js alterna `hidden` entre ellos.
 */

.nw-match {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: var(--nw-page-max);
  margin: 0 auto;
  padding: 18px 16px 28px;
}
/* `hidden` pierde contra el `display` de cualquier clase: aquí manda. */
.nw-match [hidden] {
  display: none !important;
}

/* ── Presentación ────────────────────────────────────────────────────── */
.nw-match__eyebrow {
  margin: 0;
  color: var(--v5-dupla-ink);
  font-size: var(--v5-text-overline);
  font-weight: 700;
  letter-spacing: 0.08em;
}
.nw-match__title {
  margin: 6px 0 0;
}
.nw-match__lead {
  margin: 10px 0 0;
  max-width: var(--nw-text-max);
  color: var(--v5-text-muted);
  font-size: var(--v5-text-body-large);
  line-height: 1.5;
}
.nw-match__steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}
.nw-match__step {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px;
  border-radius: var(--v5-r4);
  background: var(--v5-dupla-soft);
  color: var(--v5-text-muted);
  font-size: var(--v5-text-label);
  line-height: 1.35;
}
.nw-match__step strong {
  color: var(--v5-dupla-ink);
  font-size: var(--v5-text-body);
}
.nw-match__step-icon {
  color: var(--v5-dupla-deep);
  font-size: 22px;
  line-height: 1;
  margin-bottom: 4px;
}

.nw-match__loading {
  margin: 0;
  color: var(--v5-text-muted);
}

/* ── Tarjetas de paso ────────────────────────────────────────────────── */
.nw-match__card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 16px;
  border: 1px solid var(--v5-border);
  border-radius: var(--v5-r4);
  background: var(--v5-surface);
  box-shadow: var(--v5-shadow-card);
}
.nw-match__card p {
  margin: 0;
}
.nw-match__h2 {
  margin: 0;
  color: var(--v5-ink);
  font-size: var(--v5-text-title);
  font-weight: 900;
  line-height: 1.15;
}
.nw-match__sub,
.nw-match__note {
  color: var(--v5-text-muted);
  font-size: var(--v5-text-body);
  line-height: 1.45;
}
.nw-match__note {
  font-style: italic;
  text-align: center;
}
.nw-match__cta {
  justify-content: center;
  gap: 8px;
}

/* ── Filtros ─────────────────────────────────────────────────────────── */
.nw-match__group {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}
.nw-match__legend {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
  padding: 0;
  color: var(--v5-ink);
  font-size: var(--v5-text-body);
  font-weight: 700;
}
.nw-match__optional {
  color: var(--v5-text-light);
  font-size: var(--v5-text-label);
  font-weight: 500;
}
.nw-match__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.nw-match__chip {
  min-height: var(--nw-touch);
  cursor: pointer;
}
.nw-match__chip[aria-pressed='true'] {
  border-color: var(--v5-dupla-deep);
  background: var(--v5-dupla-soft);
  color: var(--v5-dupla-ink);
}
.nw-match__count {
  padding: 10px 12px;
  border-radius: var(--v5-r3);
  background: var(--v5-surface-muted);
  color: var(--v5-text);
  font-size: var(--v5-text-body);
}
.nw-match__error {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--v5-error);
}
.nw-match__empty {
  color: var(--v5-text-muted);
}
.nw-match__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.nw-match__clear,
.nw-match__finish {
  min-height: var(--nw-touch);
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--v5-primary);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.nw-match__clear:disabled {
  color: var(--v5-text-light);
  cursor: default;
}

/* ── Mazo ────────────────────────────────────────────────────────────── */
.nw-match__deck-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.nw-match__deck-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 420px;
}
.nw-match__progress {
  margin: 0;
  color: var(--v5-text-muted);
  font-size: var(--v5-text-body);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.nw-match__relaxed {
  margin: 0;
  max-width: 420px;
  color: var(--v5-text-muted);
  font-size: var(--v5-text-label);
  text-align: center;
}
.nw-match__deck {
  width: 100%;
  max-width: 420px;
}
/* La tarjeta se achica con la pantalla: los botones siguen a la vista,
   sobre la barra inferior del teléfono. */
.nw-match__deck {
  max-width: min(420px, calc((100vh - 510px) * 0.8));
  min-width: 240px;
}
@media (min-width: 768px) {
  .nw-match__deck {
    max-width: min(420px, calc((100vh - 360px) * 0.72));
    min-width: 260px;
  }
}
.nw-match__card-pet {
  --nw-drag: 0;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--v5-border);
  border-radius: var(--v5-r5);
  background: var(--v5-surface);
  box-shadow: var(--v5-shadow-raised);
  touch-action: pan-y;
  user-select: none;
  transform: translateX(calc(var(--nw-drag) * 1px))
    rotate(calc(var(--nw-drag) * 0.03deg));
}
.nw-match__card-pet:focus {
  outline: none;
}
.nw-match__card-pet.is-settling {
  transition: transform 0.2s ease;
}
.nw-match__photo {
  position: relative;
  aspect-ratio: 4 / 5;
  background: var(--v5-surface-muted);
}
.nw-match__photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}
.nw-match__stamp {
  position: absolute;
  top: 18px;
  padding: 6px 12px;
  border: 3px solid currentColor;
  border-radius: var(--v5-r3);
  background: var(--nw-glass-light);
  font-size: var(--v5-text-body-large);
  font-weight: 900;
  letter-spacing: 0.06em;
  opacity: 0;
}
.nw-match__stamp--yes {
  left: 16px;
  color: var(--v5-dupla-deep);
  transform: rotate(-12deg);
}
.nw-match__stamp--no {
  right: 16px;
  color: var(--v5-text-muted);
  transform: rotate(12deg);
}
.nw-match__card-pet.is-yes .nw-match__stamp--yes,
.nw-match__card-pet.is-no .nw-match__stamp--no {
  opacity: 1;
}
.nw-match__pet-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 16px 16px;
}
.nw-match__pet-name {
  margin: 0;
  color: var(--v5-ink);
  font-size: var(--v5-text-title);
  font-weight: 900;
}
.nw-match__pet-line,
.nw-match__pet-org {
  margin: 0;
  color: var(--v5-text-muted);
  font-size: var(--v5-text-body);
}
.nw-match__pet-org {
  font-size: var(--v5-text-label);
}
.nw-match__actions {
  display: flex;
  gap: 24px;
}
.nw-match__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: var(--v5-r-pill);
  font-size: 28px;
  cursor: pointer;
  box-shadow: var(--v5-shadow-card);
}
.nw-match__action--no {
  border: 1px solid var(--v5-border-strong);
  background: var(--v5-surface);
  color: var(--v5-text-muted);
}
.nw-match__action--yes {
  border: 1px solid var(--v5-dupla-deep);
  background: var(--v5-dupla-deep);
  color: var(--v5-surface);
}
.nw-match__action:disabled {
  opacity: 0.5;
  cursor: default;
}
.nw-match__disclaimer {
  margin: 0;
  max-width: 420px;
  color: var(--v5-text-light);
  font-size: var(--v5-text-label);
  text-align: center;
}

/* ── Top 3 ───────────────────────────────────────────────────────────── */
.nw-match__top {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.nw-match__top-item {
  display: grid;
  grid-template-columns: auto 56px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--v5-border);
  border-radius: var(--v5-r4);
}
.nw-match__rank {
  color: var(--v5-dupla-ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.nw-match__top-photo {
  width: 56px;
  height: 56px;
  border-radius: var(--v5-r3);
  object-fit: cover;
  background: var(--v5-surface-muted);
}
.nw-match__top-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.nw-match__top-text strong {
  color: var(--v5-ink);
}
.nw-match__reason {
  color: var(--v5-text-muted);
  font-size: var(--v5-text-label);
}
.nw-match__percent {
  padding: 4px 10px;
  border-radius: var(--v5-r-pill);
  background: var(--v5-dupla-soft);
  color: var(--v5-dupla-ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.nw-match__top-actions {
  display: flex;
  gap: 8px;
  grid-column: 1 / -1;
}
.nw-match__top-actions .nw-btn {
  flex: 1 1 0;
  justify-content: center;
}
.nw-match__followed {
  color: var(--v5-text);
}

/* Al bajar al mazo o al top 3, el paso queda bajo el encabezado fijo. */
.nw-match__deck-step,
.nw-match__results {
  scroll-margin-top: calc(var(--nw-header-h) + 8px);
}

/* Hasta tableta, jugando, la presentación se reduce al título. */
@media (max-width: 1023.98px) {
  .nw-match[data-nw-step='mazo'] .nw-match__lead,
  .nw-match[data-nw-step='mazo'] .nw-match__steps,
  .nw-match[data-nw-step='top'] .nw-match__lead,
  .nw-match[data-nw-step='top'] .nw-match__steps {
    display: none;
  }
}

/* ── Escritorio: la presentación a la izquierda, el paso a la derecha ── */
@media (min-width: 1024px) {
  .nw-match {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 520px);
    align-items: start;
    column-gap: 48px;
    padding: 40px 32px 56px;
  }
  .nw-match__intro {
    grid-column: 1;
    grid-row: 1 / span 6;
    position: sticky;
    top: calc(var(--nw-header-h) + 24px);
  }
  .nw-match > :not(.nw-match__intro) {
    grid-column: 2;
  }
  .nw-match__card {
    padding: 24px;
  }
}
