/* ==========================================================================
   Tokens de diseño — para cambiar el aspecto (color de marca, radios, fuente)
   basta con tocar este bloque.
   ========================================================================== */
:root {
  --accent: #2457f5;
  --accent-contrast: #ffffff;
  --accent-soft: #e8eeff;

  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #15181e;
  --muted: #5b6370;
  --border: #e1e4ea;

  --hero-from: #101a3a;
  --hero-to: #24357a;
  --hero-text: #ffffff;
  --hero-muted: #c3cbea;

  --letter-bg: hsl(var(--hue, 220) 75% 93%);
  --letter-fg: hsl(var(--hue, 220) 60% 32%);

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgb(16 24 40 / 0.05);
  --shadow-hover: 0 10px 24px -8px rgb(16 24 40 / 0.18);
  --container: 1200px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
}

:root[data-theme="dark"] {
  --accent: #86a6ff;
  --accent-contrast: #0b1020;
  --accent-soft: #1c2748;

  --bg: #0e1117;
  --surface: #171b23;
  --surface-2: #212734;
  --text: #e8ebf1;
  --muted: #98a1b0;
  --border: #283040;

  --hero-from: #0b1020;
  --hero-to: #1a2552;
  --hero-muted: #a9b3d6;

  --letter-bg: hsl(var(--hue, 220) 35% 22%);
  --letter-fg: hsl(var(--hue, 220) 85% 82%);

  --shadow: none;
  --shadow-hover: 0 10px 24px -8px rgb(0 0 0 / 0.6);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: 20px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

/* ---------- Cabecera ---------- */
.hero {
  background: linear-gradient(135deg, var(--hero-from), var(--hero-to));
  color: var(--hero-text);
  padding-bottom: 56px;
}

.hero__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand__logo {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid rgb(255 255 255 / 0.18);
  border-radius: 50%;
  background: rgb(255 255 255 / 0.08);
  color: inherit;
  cursor: pointer;
  transition: background-color 0.15s;
}

.icon-btn:hover { background: rgb(255 255 255 / 0.18); }
.hero :focus-visible { outline-color: #ffffff; }

.icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:root[data-theme="dark"] .icon--moon,
:root:not([data-theme="dark"]) .icon--sun { display: none; }

.hero__title {
  margin: 28px 0 0;
  font-size: clamp(1.9rem, 4.5vw, 2.8rem);
  line-height: 1.1;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.hero__subtitle {
  margin: 10px 0 0;
  max-width: 60ch;
  color: var(--hero-muted);
  font-size: 1.05rem;
}

.hero__subtitle:empty { display: none; }

/* ---------- Buscador ---------- */
.search {
  position: relative;
  max-width: 640px;
  margin-top: 28px;
}

.search__icon {
  position: absolute;
  top: 50%;
  left: 16px;
  width: 20px;
  height: 20px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--muted);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}

.search__input {
  width: 100%;
  height: 52px;
  padding: 0 52px 0 46px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  box-shadow: 0 8px 24px -8px rgb(0 0 0 / 0.35);
}

.search__input::placeholder { color: var(--muted); }
.search__input:focus-visible { outline: 3px solid rgb(255 255 255 / 0.55); outline-offset: 2px; }

.search__kbd {
  position: absolute;
  top: 50%;
  right: 14px;
  transform: translateY(-50%);
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  pointer-events: none;
}

.search__input:focus ~ .search__kbd,
.search__input:not(:placeholder-shown) ~ .search__kbd { display: none; }

/* ---------- Filtros ---------- */
.main {
  flex: 1;
  padding-block: 0 48px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: -20px; /* monta los filtros sobre el borde de la cabecera */
}

.chips:empty { display: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 550;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}

.chip:hover { border-color: var(--accent); }

.chip__count {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-contrast);
}

.chip[aria-pressed="true"] .chip__count {
  background: rgb(255 255 255 / 0.22);
  color: inherit;
}

/* ---------- Secciones y rejilla ---------- */
.section { margin-top: 36px; }

.section__title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
}

.section__count {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
}

/* ---------- Tarjeta ---------- */
.card {
  position: relative;
  display: flex;
  gap: 14px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-hover);
}

.card__icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
}

.card__icon img {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.card__icon--emoji { font-size: 1.5rem; line-height: 1; }

.card__icon--letter {
  background: var(--letter-bg);
  color: var(--letter-fg);
  font-size: 1.2rem;
  font-weight: 700;
}

.card__body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.card__title {
  padding-right: 20px; /* hueco para la flecha */
  font-weight: 650;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.card__desc {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.card__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  min-width: 0;
}

.card__host {
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.76rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
}

.card__arrow {
  position: absolute;
  top: 12px;
  right: 14px;
  color: var(--accent);
  font-size: 1rem;
  opacity: 0;
  transform: translate(-3px, 3px);
  transition: opacity 0.15s, transform 0.15s;
}

.card:hover .card__arrow,
.card:focus-visible .card__arrow {
  opacity: 1;
  transform: none;
}

/* ---------- Mensajes y pie ---------- */
.message {
  margin-top: 48px;
  padding: 40px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.footer {
  padding-block: 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---------- Ajustes ---------- */
@media (max-width: 560px) {
  .hero { padding-bottom: 44px; }
  .grid { grid-template-columns: 1fr; }
  .search__kbd { display: none; }
  .search__input { padding-right: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
