/* ==========================================================================
   Búsqueda de Constancias — RAUGM 2026
   Chrome neutro en OKLCH, acento --primary en verde RAUGM (raugm.org.mx).
   Los tokens --danger/--warning/--success/--info se reutilizan como color
   semántico por tipo de constancia (participación=info, asistencia=success,
   curso=warning), así el color vive solo en el ícono/insignia.
   ========================================================================== */

:root {
  /* Chrome neutro con un toque verde muy sutil (hue 140), a juego con
     --primary, en vez del azul original. */
  --bg-dark: oklch(0.92 0.02 140);
  --bg: oklch(0.96 0.02 140);
  --bg-light: oklch(1 0.02 140);

  --text: oklch(0.15 0.02 140);
  --text-muted: oklch(0.4 0.02 140);

  --highlight: oklch(1 0.02 140);
  --border: oklch(0.6 0.02 140);
  --border-muted: oklch(0.7 0.02 140 / 0.35);

  /* Verde RAUGM (raugm.org.mx: --raugm-primary-color / gradiente de calls) */
  --primary: #93c01f;
  --primary-dark: #399413;
  --primary-bg: color-mix(in oklch, #93c01f 14%, white);
  --primary-bg-hover: color-mix(in oklch, #93c01f 22%, white);
  --secondary: oklch(0.4 0.1 82);

  --danger: oklch(0.5 0.08 30);
  --warning: oklch(0.5 0.08 100);
  --success: oklch(0.5 0.08 160);
  --info: oklch(0.5 0.08 260);

  /* Fondos claros por tono: misma fórmula que --bg-dark (L 0.92 / C 0.04)
     aplicada al hue de cada estado, para insignias/paneles tintados. */
  --danger-bg: oklch(0.92 0.04 30);
  --warning-bg: oklch(0.92 0.04 100);
  --success-bg: oklch(0.92 0.04 160);
  --info-bg: var(--bg-light);

  --tipo-participacion: var(--info);
  --tipo-participacion-bg: var(--info-bg);
  --tipo-asistencia: var(--success);
  --tipo-asistencia-bg: var(--success-bg);
  --tipo-curso: var(--warning);
  --tipo-curso-bg: var(--warning-bg);

  --shadow-card: 0px 1px 2px -1px oklch(0.15 0.02 140 / 0.08);
  --shadow-hero: 0px 10px 28px -16px oklch(0.15 0.02 140 / 0.18);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 32px 20px 64px;
}

.page {
  max-width: 720px;
  margin: 0 auto;
}

/* ---------- Hero (header + búsqueda fusionados) ---------- */

.hero {
  background: var(--bg-light);
  border: 1px solid var(--border-muted);
  border-radius: 28px;
  padding: 40px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-hero);
  text-align: center;
}

.hero-kicker {
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.hero-title {
  color: var(--text);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-wrap: balance;
  margin-bottom: 10px;
}

.hero-subtitle {
  color: var(--text-muted);
  font-size: 1rem;
  text-wrap: pretty;
  margin-bottom: 28px;
}

.search-wrap {
  position: relative;
  margin-bottom: 14px;
}

.search-wrap .search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  pointer-events: none;
  transition-property: color;
  transition-duration: 150ms;
}

.search-input {
  width: 100%;
  min-height: 56px;
  padding: 15px 20px 15px 50px;
  font-size: 1.05rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-dark);
  border: 1.5px solid transparent;
  border-radius: 16px;
  outline: none;
  transition-property: border-color, box-shadow, background-color;
  transition-duration: 180ms;
  transition-timing-function: ease-out;
}

.search-input::placeholder {
  color: var(--text-muted);
}

.search-input:focus {
  background: var(--bg-light);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px color-mix(in oklch, var(--primary) 20%, transparent);
}

.search-wrap:has(.search-input:focus) .search-icon {
  color: var(--primary);
}

.search-help {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-wrap: pretty;
}

.search-help strong {
  color: var(--text);
}

/* ---------- Estados: loading / error / vacío ---------- */

.state {
  display: none;
  background: var(--bg-light);
  border: 1px solid var(--border-muted);
  border-radius: 20px;
  padding: 36px 32px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-card);
  text-align: center;
}

.state.active {
  display: block;
}

.state-loading .spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 16px;
  border: 3px solid var(--bg-dark);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.state-loading p {
  color: var(--text-muted);
  font-weight: 600;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.state-error {
  text-align: left;
  display: none;
}

.state-error.active {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.state-error .state-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--danger-bg);
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
}

.state-error .state-icon svg {
  width: 20px;
  height: 20px;
}

.state-error-title {
  color: var(--danger);
  font-weight: 700;
  margin-bottom: 4px;
}

.state-error-text {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.state-empty .state-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  border-radius: 14px;
  background: var(--bg-dark);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.state-empty .state-icon svg {
  width: 24px;
  height: 24px;
}

.state-empty p {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.5;
  text-wrap: pretty;
}

/* ---------- Resultados ---------- */

.results {
  display: none;
}

.results.active {
  display: block;
}

.results-summary {
  padding: 4px 4px 20px;
  color: var(--text-muted);
  font-size: 1rem;
}

.results-summary strong {
  color: var(--text);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.results-list {
  display: grid;
  gap: 18px;
}

.participant-card {
  background: var(--primary-bg);
  border: 1px solid var(--border-muted);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow-card);
  transition-property: box-shadow, border-color, transform;
  transition-duration: 200ms;
  transition-timing-function: ease-out;

  opacity: 0;
  transform: translateY(14px);
  filter: blur(3px);
  animation: card-enter 420ms cubic-bezier(0.2, 0, 0, 1) forwards;
  animation-delay: var(--stagger-delay, 0ms);
}

@keyframes card-enter {
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

.participant-card:hover {
  border-color: var(--border);
  transform: translateY(-2px);
}

.participant-header {
  border-bottom: 1px solid var(--border-muted);
  padding-bottom: 14px;
  margin-bottom: 16px;
}

.participant-name {
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.constancias-list {
  display: grid;
  gap: 12px;
}

.constancia-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  background: var(--bg-light);
  border-radius: 14px;
  transition-property: background-color;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}

.constancia-item:hover {
  background: var(--primary-bg-hover);
}

.constancia-icon {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--tipo-bg, var(--bg-dark));
  color: var(--tipo-color, var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
}

.constancia-icon svg {
  width: 20px;
  height: 20px;
}

.constancia-content {
  flex: 1;
  min-width: 0;
}

.constancia-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

.constancia-title {
  color: var(--text);
  font-size: 1rem;
  font-weight: 700;
}

.constancia-tag {
  flex-shrink: 0;
  padding: 2px 9px;
  background: var(--bg-light);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  border-radius: 9999px;
}

.constancia-tag-outline {
  background: transparent;
  color: var(--text-muted);
  box-shadow: inset 0 0 0 1px var(--border-muted);
  cursor: help;
}

.constancia-description {
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.45;
  text-wrap: pretty;
  margin-bottom: 6px;
}

.constancia-autores {
  color: var(--text-muted);
  font-size: 0.8rem;
  line-height: 1.4;
  margin-bottom: 6px;
}

.constancia-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.constancia-link {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 10px 18px 10px 16px;
  background: var(--primary);
  color: var(--bg-light);
  text-decoration: none;
  border-radius: 9999px;
  font-size: 0.88rem;
  font-weight: 700;
  transition-property: background-color, scale;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}

.constancia-link:hover {
  background: var(--primary-dark);
}

.constancia-link:active {
  scale: 0.96;
}

.constancia-link svg {
  width: 16px;
  height: 16px;
}

.no-constancias {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  background: var(--warning-bg);
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.5;
}

.no-constancias small {
  color: var(--text-muted);
}

/* ---------- Responsive ---------- */

@media (max-width: 640px) {
  body {
    padding: 20px 14px 48px;
  }

  .hero {
    padding: 28px 22px;
    border-radius: 22px;
  }

  .hero-title {
    font-size: 1.5rem;
  }

  .participant-card {
    padding: 18px;
  }

  .participant-name {
    font-size: 1.1rem;
  }

  .constancia-actions {
    justify-content: stretch;
  }

  .constancia-link {
    flex: 1;
    justify-content: center;
  }
}
