/* Catálogo de Descargas — Fase 2
   Dirección visual "Ink Dark + saffron": fondo tinta, superficies glass,
   acento azafrán. El acento es saffron y NO dorado (corrección de 2.1 del
   spec, que pedía violeta: se unificó con la paleta por defecto del vault). */

:root {
  /* fondo */
  --bg: #0d0d11;
  --bg-deep: #08080b;

  /* superficies glass */
  --surface: rgba(24, 24, 31, 0.62);
  --surface-solid: #18181f;
  --surface-hi: rgba(32, 32, 41, 0.78);

  /* bordes */
  --border: #26262f;
  --border-glass: rgba(245, 158, 11, 0.14);
  --border-glass-hi: rgba(245, 158, 11, 0.42);

  /* texto */
  --text: #e8e8f0;
  --text-dim: #9a9aab;

  /* acento saffron */
  --accent: #f59e0b;
  --accent-hi: #fbbf24;
  --accent-dim: rgba(245, 158, 11, 0.16);
  --accent-text: #14100a;

  --danger: #ff8a8a;

  --radius: 12px;
  --radius-lg: 16px;
  --maxw: 1100px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 220ms;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* Gradiente mesh de fondo: manchas saffron muy tenues que se desplazan lento.
   Va en un pseudo-elemento fijo para que no participe del layout ni dispare
   reflows al animarse. */
body::before {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(38% 34% at 18% 22%, rgba(245, 158, 11, 0.13), transparent 70%),
    radial-gradient(34% 30% at 82% 72%, rgba(251, 191, 36, 0.09), transparent 70%),
    radial-gradient(60% 50% at 50% 0%, rgba(120, 90, 30, 0.10), transparent 75%);
  animation: mesh-drift 48s ease-in-out infinite alternate;
  will-change: transform;
}

@keyframes mesh-drift {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  50%  { transform: translate3d(2.5%, -2%, 0) scale(1.06); }
  100% { transform: translate3d(-2%, 2.5%, 0) scale(1.02); }
}

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1rem;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* --- header --- */

.site-header {
  border-bottom: 1px solid var(--border);
  padding: 3rem 0 1.75rem;
  margin-bottom: 1.75rem;
}

.site-header h1 {
  margin: 0;
  font-size: clamp(1.9rem, 5vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.site-header h1 .accent { color: var(--accent); }

.tagline {
  margin: 0.5rem 0 0;
  color: var(--text-dim);
  font-size: 1rem;
  font-weight: 300;
}

/* --- controles --- */

.controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.search input {
  width: 100%;
  padding: 0.75rem 0.95rem;
  background: var(--surface);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

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

.search input:hover { border-color: var(--border-glass-hi); }

.search input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  outline: none;
}

.search input:focus-visible,
.filter:focus-visible,
.btn-download:focus-visible,
.btn-hash:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filter {
  padding: 0.45rem 0.95rem;
  background: var(--surface);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease),
              background-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}

.filter:hover {
  color: var(--text);
  border-color: var(--border-glass-hi);
  transform: scale(1.03);
}

.filter:active { transform: scale(0.98); }

.filter[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  box-shadow: 0 4px 18px rgba(245, 158, 11, 0.28);
}

.result-count {
  margin: 0 0 1rem;
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* --- grilla --- */

.catalog {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding-bottom: 2rem;
}

@media (min-width: 640px) {
  .catalog { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 960px) {
  .catalog { grid-template-columns: repeat(3, 1fr); }
}

/* --- card glass --- */

.card {
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--surface);
  -webkit-backdrop-filter: blur(14px) saturate(120%);
  backdrop-filter: blur(14px) saturate(120%);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.15rem;
  transition: transform var(--dur) var(--ease), border-color var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease), background-color var(--dur) var(--ease);
}

.card:hover {
  transform: scale(1.02);
  background: var(--surface-hi);
  border-color: var(--border-glass-hi);
  box-shadow:
    0 0 0 1px rgba(245, 158, 11, 0.10),
    0 10px 40px rgba(245, 158, 11, 0.14),
    0 4px 14px rgba(0, 0, 0, 0.45);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
}

/* Badges: una sola familia de acento, distinta intensidad por categoría.
   Tres colores distintos harían arcoíris; el spec pide cohesión. */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.18rem 0.65rem;
  border: 1px solid var(--border-glass);
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.07);
  color: var(--accent-hi);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.badge-icon { font-size: 0.85em; line-height: 1; }

.badge-programs {
  background: rgba(245, 158, 11, 0.04);
  color: var(--accent);
}

.badge-tools {
  background: rgba(154, 154, 171, 0.08);
  border-color: var(--border);
  color: var(--text-dim);
}

.size {
  color: var(--text-dim);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.card-title {
  margin: 0 0 0.4rem;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.card-desc {
  margin: 0 0 0.8rem;
  color: var(--text-dim);
  font-size: 0.9rem;
  font-weight: 300;
}

.tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 0.9rem;
  padding: 0;
}

.tags li {
  color: var(--text-dim);
  font-size: 0.75rem;
}

.tags li::before { content: "#"; opacity: 0.6; }

.card-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* --- botón de descarga con shimmer --- */

.btn-download {
  position: relative;
  display: block;
  padding: 0.65rem 1rem;
  background: var(--accent);
  border-radius: var(--radius);
  color: var(--accent-text);
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  overflow: hidden;
  isolation: isolate;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              background-color var(--dur) var(--ease);
}

.btn-download::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(
    100deg,
    transparent 20%,
    rgba(255, 255, 255, 0.55) 50%,
    transparent 80%
  );
  transform: translateX(-120%);
}

.btn-download:hover {
  background: var(--accent-hi);
  transform: scale(1.02);
  box-shadow: 0 6px 24px rgba(245, 158, 11, 0.35);
}

.btn-download:hover::after {
  animation: shimmer 900ms var(--ease);
}

.btn-download:active { transform: scale(0.99); }

@keyframes shimmer {
  from { transform: translateX(-120%); }
  to   { transform: translateX(120%); }
}

/* --- botón de copiar sha256 --- */

.btn-hash {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.4rem 0.7rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, monospace;
  font-size: 0.72rem;
  cursor: pointer;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease),
              background-color var(--dur) var(--ease);
}

.btn-hash:hover {
  color: var(--text);
  border-color: var(--border-glass-hi);
  background: rgba(245, 158, 11, 0.06);
}

.btn-hash .hash-label { letter-spacing: 0.02em; }

.btn-hash.copied {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-dim);
}

/* --- skeleton de carga (glass, no spinner) --- */

.skeleton-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding-bottom: 2rem;
}

@media (min-width: 640px) { .skeleton-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .skeleton-grid { grid-template-columns: repeat(3, 1fr); } }

.skeleton {
  background: var(--surface);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.15rem;
}

.sk-line {
  height: 0.7rem;
  border-radius: 6px;
  margin-bottom: 0.7rem;
  background: linear-gradient(
    90deg,
    rgba(154, 154, 171, 0.08) 25%,
    rgba(245, 158, 11, 0.16) 50%,
    rgba(154, 154, 171, 0.08) 75%
  );
  background-size: 200% 100%;
  animation: sk-pulse 1.6s ease-in-out infinite;
}

.sk-line.sk-badge { width: 35%; height: 1.1rem; border-radius: 999px; }
.sk-line.sk-title { width: 75%; height: 1rem; }
.sk-line.sk-text  { width: 100%; }
.sk-line.sk-text2 { width: 60%; }
.sk-line.sk-btn   { width: 100%; height: 2.3rem; border-radius: var(--radius); margin-top: 1.1rem; margin-bottom: 0; }

@keyframes sk-pulse {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* --- estados --- */

.state {
  padding: 3.5rem 1rem;
  color: var(--text-dim);
  text-align: center;
  font-weight: 300;
}

.state-error { color: var(--danger); }

/* --- footer --- */

.site-footer {
  margin-top: auto;
  padding: 1.5rem 0;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.8rem;
}

.site-footer p { margin: 0; }

/* --- reduced motion ---------------------------------------------------
   Regla de performance del spec: quien pidió menos movimiento no recibe
   ninguno. Se apagan el mesh de fondo, el shimmer, el pulso del skeleton y
   los scale de hover. Las animaciones de GSAP se desactivan aparte, en JS:
   el CSS no puede alcanzarlas. */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  body::before { animation: none; transform: none; }

  .card:hover,
  .filter:hover,
  .filter:active,
  .btn-download:hover,
  .btn-download:active { transform: none; }

  .btn-download:hover::after { animation: none; }

  .sk-line { animation: none; background-position: 0 0; }
}
