/* ============================================================
   Aliados · buscador, filtros por categoría, tarjetas y ficha de beneficios
   Mobile first: la base es el celular; los min-width suman columnas y espacio.
   Usa los tokens de MANUAL-DE-ESTILOS.md (definidos en :root de index.html).
   ============================================================ */

.partners-section { overflow: clip; } /* clip (no hidden) para no romper el sticky del riel */

/* ---------- Riel de filtros (sticky) ---------- */
.rail {
  --top-h: calc(env(safe-area-inset-top, 0px) + 63px); /* alto del header */
  position: sticky; top: var(--top-h); z-index: 4;
  margin: 28px calc(var(--gutter-l) * -1) 0 calc(var(--gutter-r) * -1);
  padding: 12px 0 14px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  -webkit-backdrop-filter: blur(14px) saturate(1.2); backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--line);
}

/* Buscador */
.search { position: relative; margin: 0 var(--gutter-l) 12px var(--gutter-r); }
.search svg { position: absolute; left: 16px; top: 50%; translate: 0 -50%; width: 20px; height: 20px; color: var(--sky-ink); pointer-events: none; }
.search input {
  width: 100%; min-height: 48px; padding: 0 48px 0 46px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--bg); color: var(--fg);
  font: 600 16px/1 var(--font-body); /* 16px evita el zoom automático en iOS */
  transition: border-color .15s ease, box-shadow .15s ease;
}
.search input::placeholder { color: var(--muted); font-weight: 500; }
.search input:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 4px color-mix(in srgb, var(--sky) 22%, transparent); }
.search input::-webkit-search-cancel-button { display: none; }
.search .clear {
  position: absolute; right: 6px; top: 50%; translate: 0 -50%; width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: var(--chip); color: var(--fg); cursor: pointer; display: grid; place-items: center;
}
.search .clear[hidden] { display: none; }
.search .clear svg { position: static; translate: none; width: 16px; height: 16px; color: inherit; }

/* Chips con ícono */
.chips {
  display: flex; gap: 10px; overflow-x: auto; padding: 4px var(--gutter-r) 6px var(--gutter-l);
  scroll-snap-type: x proximity; scroll-padding-inline: var(--gutter-l);
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 var(--gutter-l), #000 calc(100% - 28px), transparent);
          mask-image: linear-gradient(90deg, transparent 0, #000 var(--gutter-l), #000 calc(100% - 28px), transparent);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; scroll-snap-align: start; position: relative;
  display: inline-flex; align-items: center; gap: 10px; min-height: 48px;
  padding: 6px 16px 6px 6px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--bg); color: var(--fg);
  font: 700 15px/1 var(--font-body); cursor: pointer; white-space: nowrap;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease, color .18s ease, border-color .18s ease;
}
.chip .ico {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: color-mix(in srgb, var(--sky) 16%, transparent); color: var(--sky-ink);
  transition: background .18s ease, color .18s ease, transform .25s ease;
}
.chip .ico svg { width: 20px; height: 20px; }
.chip .n {
  font: 700 12px/1 var(--font-display); font-variant-numeric: tabular-nums;
  padding: 4px 7px; border-radius: 999px; background: var(--chip); color: var(--muted);
}
.chip:hover { transform: translateY(-2px); border-color: var(--sky); }
.chip[aria-pressed="true"] {
  color: var(--on-brand); border-color: transparent;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-light) 100%);
  box-shadow: 0 10px 22px -10px rgba(29, 72, 151, .75);
}
.chip[aria-pressed="true"] .ico { background: var(--sun); color: #14213d; transform: rotate(-8deg) scale(1.05); }
.chip[aria-pressed="true"] .n { background: rgba(255, 255, 255, .22); color: #fff; }

/* ---------- Estado y resultado ---------- */
.count-line { margin-top: 18px; font-size: 14px; color: var(--muted); }
.empty { margin-top: 24px; padding: 28px 20px; text-align: center; border: 1.5px dashed var(--line); border-radius: 20px; color: var(--muted); }
.empty b { display: block; font: 700 18px/1.3 var(--font-display); color: var(--fg); margin-bottom: 4px; }

/* ---------- Tarjetas (2 columnas en celular) ---------- */
.aliados { list-style: none; padding: 0; margin: 14px 0 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.aliado {
  width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px;
  padding: 18px 10px 14px; border-radius: 20px; border: 1px solid var(--line); background: var(--bg);
  color: inherit; font: inherit; cursor: pointer; min-width: 0;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.aliado:hover { transform: translateY(-4px); box-shadow: 0 14px 28px -16px rgba(29, 72, 151, .45); border-color: var(--sky); }
.aliado:active { transform: scale(.98); }

.logo-c {
  width: 92px; height: 92px; border-radius: 50%; flex: none; background: #fff;
  box-shadow: 0 0 0 4px var(--sky); display: grid; place-items: center; overflow: hidden;
}
.logo-c img { width: 100%; height: 100%; object-fit: contain; display: block; } /* el margen ya viene en la imagen (logo centrado, ~78 % del círculo) */
.logo-c.sm { width: 64px; height: 64px; box-shadow: 0 0 0 3px var(--sky); }
.logo-c.lg { width: 72px; height: 72px; }
/* Monograma cuando aún no hay logo */
.mono { font: 900 24px/1 var(--font-display); letter-spacing: -.02em; color: #fff; width: 100%; height: 100%; display: grid; place-items: center; }
.mono.s1 { background: linear-gradient(135deg, var(--brand-deep), var(--brand)); }
.mono.s2 { background: linear-gradient(135deg, var(--brand), var(--brand-light)); }
.mono.s3 { background: linear-gradient(135deg, var(--sky-strong), var(--brand-light)); }
.mono.long { font-size: 19px; }

.aliado .name { font-weight: 700; font-size: 14px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.5em; }
.aliado .cat { font-size: 12px; color: var(--muted); margin-top: -4px; }

/* Insignia del beneficio principal */
.deal {
  margin-top: auto; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 8px 8px 7px; border-radius: 14px; background: var(--sun); color: #14213d;
}
.deal small { font: 700 11px/1 var(--font-display); letter-spacing: .1em; text-transform: uppercase; opacity: .8; }
.deal b { font: 900 28px/1 var(--font-display); letter-spacing: -.01em; }
.deal em { font-style: normal; font-weight: 700; font-size: 11px; line-height: 1.2; }
.more { font-size: 12px; font-weight: 600; color: var(--sky-ink); display: inline-flex; align-items: center; gap: 4px; }
.more svg { width: 12px; height: 12px; }

/* ---------- Ficha de beneficios (bottom sheet en celular) ---------- */
.sheet {
  padding: 0; border: 0; background: var(--surface); color: var(--fg);
  width: 100%; max-width: 100%; max-height: 88dvh; margin: auto 0 0; /* abajo */
  border-radius: 28px 28px 0 0; box-shadow: 0 -20px 60px -20px rgba(5, 15, 45, .55);
  overflow: hidden; overscroll-behavior: contain;
}
.sheet::backdrop { background: rgba(8, 20, 55, .55); backdrop-filter: blur(3px); }
.sheet[open] { display: flex; flex-direction: column; animation: sheet-up .28s cubic-bezier(.2, .8, .2, 1); }
.sheet[open]::backdrop { animation: fade .25s ease; }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet-head {
  position: relative; display: flex; align-items: center; gap: 14px; flex: none;
  padding: 26px var(--gutter-r) 18px var(--gutter-l); color: var(--on-brand);
  background: linear-gradient(165deg, var(--brand-deep) 0%, var(--brand) 55%, var(--brand-light) 100%);
}
.sheet-head::before { /* asa de arrastre */
  content: ""; position: absolute; top: 9px; left: 50%; translate: -50% 0; width: 44px; height: 5px; border-radius: 99px; background: rgba(255, 255, 255, .4);
}
.sheet-head .logo-c { box-shadow: 0 0 0 4px var(--sun); }
.sheet-head h3 { font-weight: 900; font-size: 22px; line-height: 1.1; }
.sheet-head .kicker { color: var(--on-brand-soft); font-size: 12px; margin-bottom: 6px; display: block; }
.sheet-close {
  position: absolute; top: 14px; right: 12px; width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .16); color: #fff; cursor: pointer; display: grid; place-items: center;
}
.sheet-close svg { width: 20px; height: 20px; }
.sheet-head > div:not(.logo-c) { min-width: 0; padding-right: 40px; } /* deja espacio al botón ✕; no aplica al círculo del logo */
.sheet-head .logo-c { width: 76px; height: 76px; padding: 0; } /* gana al .logo-c de escritorio (104 px), que es para las tarjetas */

.sheet-body { overflow-y: auto; padding: 18px var(--gutter-r) calc(24px + env(safe-area-inset-bottom, 0px)) var(--gutter-l); display: grid; gap: 12px; align-content: start; }
.perk { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 14px; align-items: center; padding: 12px; border-radius: 18px; background: var(--bg); border: 1px solid var(--line); }
.perk .val {
  min-height: 64px; border-radius: 14px; background: var(--sun); color: #14213d; display: grid; place-content: center; text-align: center; padding: 4px;
}
.perk .val b { font: 900 28px/1 var(--font-display); letter-spacing: -.01em; }
.perk .val b.w { font-size: 20px; }
.perk .val small { font: 700 10px/1.1 var(--font-display); letter-spacing: .08em; text-transform: uppercase; margin-top: 2px; }
.perk p { font-size: 15px; line-height: 1.4; font-weight: 600; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag-c { font: 700 12px/1 var(--font-body); padding: 6px 10px; border-radius: 999px; background: var(--chip); color: var(--sky-ink); }

.fine { margin-top: 4px; padding: 14px 16px; border-radius: 16px; background: var(--chip); }
.fine h4 { margin: 0 0 6px; font: 700 12px/1.2 var(--font-display); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.fine ul { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.show-card { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; padding: 12px 16px; border-radius: 16px; border: 1.5px dashed var(--sky); color: var(--sky-ink); }
.show-card svg { width: 22px; height: 22px; flex: none; }

/* ---------- Pantallas más grandes ---------- */
@media (min-width: 560px) {
  .aliados { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
}
@media (min-width: 760px) {
  .rail { position: sticky; display: grid; grid-template-columns: minmax(240px, 320px) minmax(0, 1fr); align-items: center; gap: 16px; padding: 12px var(--gutter-r) 14px var(--gutter-l); border-radius: 0; }
  .search { margin: 0; }
  .chips { padding: 4px 0 6px; -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 40px), transparent); }
  .aliados { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .logo-c { width: 104px; height: 104px; }
  .aliado .name { font-size: 15px; }
  .sheet { width: min(560px, calc(100% - 32px)); margin: auto; border-radius: 28px; max-height: 84dvh; }
  .sheet-head::before { display: none; }
}
@media (min-width: 1000px) {
  .aliados { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .chip, .chip .ico, .aliado, .search input { transition: none; }
  .sheet[open], .sheet[open]::backdrop { animation: none; }
}

/* ============================================================
   Preguntas frecuentes (<details> nativo: funciona sin JS)
   ============================================================ */
.faq-split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 32px; }
.faq-list { display: grid; gap: 12px; align-content: start; }
.faq-item { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; transition: border-color .2s ease, box-shadow .2s ease; }
.faq-item[open] { border-color: var(--sky); box-shadow: 0 14px 28px -20px rgba(29, 72, 151, .5); }
.faq-item summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: 60px; padding: 14px 16px 14px 20px; border-radius: 16px;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary h3 { font: 700 17px/1.3 var(--font-display); text-wrap: balance; }
.faq-ico { flex: none; position: relative; width: 36px; height: 36px; border-radius: 50%; background: color-mix(in srgb, var(--sky) 16%, transparent); transition: background .2s ease, transform .25s ease; }
.faq-ico::before, .faq-ico::after { content: ""; position: absolute; left: 50%; top: 50%; width: 14px; height: 2.5px; border-radius: 2px; background: var(--sky-ink); translate: -50% -50%; transition: transform .25s ease, background .2s ease; }
.faq-ico::after { transform: rotate(90deg); }
.faq-item[open] .faq-ico { background: var(--sun); transform: rotate(180deg); }
.faq-item[open] .faq-ico::before, .faq-item[open] .faq-ico::after { background: #14213d; }
.faq-item[open] .faq-ico::after { transform: rotate(0deg); } /* el "+" se vuelve "−" */
.faq-a { padding: 0 20px 18px; }
.faq-a p { color: var(--muted); font-size: 16px; line-height: 1.6; max-width: 62ch; }
.faq-a a { color: var(--sky-ink); font-weight: 700; text-underline-offset: 3px; }
@media (min-width: 960px) {
  .faq-split { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 56px; align-items: start; }
  .faq-split .section-head { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 96px); }
  .faq-item summary h3 { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  .faq-item, .faq-ico, .faq-ico::before, .faq-ico::after { transition: none; }
}
