/* ============================================================
   Collection page · Regalos personalizados
   Hereda header/menú/carrito/footer/tarjetas de styles.css.
   Eje de contenido: min(100% - 144px, 1340px) como la PDP.
   ============================================================ */

.collection-main {
  padding-top: 104px;
}

.collection-head,
.collection-cats,
.collection-toolbar,
.collection-active-filters,
.collection-catalog,
.collection-seo {
  width: min(100% - 144px, 1340px);
  margin-left: auto;
  margin-right: auto;
}

/* ── Cabecera ── */
.collection-head {
  margin-top: 26px;
}

.collection-head h1 {
  margin: 0;
  color: var(--ink);
  font-family: var(--display);
  font-size: clamp(34px, 3.4vw, 48px);
  font-weight: 400;
  letter-spacing: var(--ls-serif-lg);
  line-height: 1.02;
}

.collection-head [data-intro-body] {
  position: relative;
  margin: 12px 0 0;
  max-width: none;
  color: rgba(64, 28, 28, 0.66);
  font-family: var(--brand-sans);
  font-size: 15px;
  line-height: 1.55;
}

/* Promesa de entrega: beneficio primero y en corto. Un punto verde "en
   vivo" con onda de radar señala que la promesa está activa ahora mismo. */
.collection-delivery-promise {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  width: fit-content;
  max-width: 100%;
  margin-top: 14px;
  color: rgba(64, 28, 28, 0.6);
  font-family: var(--brand-sans);
  font-size: 14px;
  line-height: 1.35;
}

.collection-delivery-dot {
  position: relative;
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  margin-inline: 2px;
  border-radius: 50%;
  background: var(--success);
}

.collection-delivery-dot::before {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--success);
  content: "";
  animation: collectionDeliveryPing 2s cubic-bezier(0.2, 0, 0, 1) infinite;
}

@keyframes collectionDeliveryPing {
  0% { transform: scale(1); opacity: 0.4; }
  70%, 100% { transform: scale(2.7); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .collection-delivery-dot::before { animation: none; opacity: 0; }
}

.collection-delivery-promise p {
  margin: 0;
}

.collection-delivery-promise strong {
  color: var(--ink);
  font-weight: 600;
}

.collection-delivery-promise time {
  color: var(--success);
  font-weight: 700;
  white-space: nowrap;
}

.collection-intro-toggle {
  display: inline;
  margin: 0 0 0 0.35em;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--rojo-oscuro);
  font: inherit;
  font-weight: 600;
  line-height: inherit;
  text-decoration: none;
  vertical-align: baseline;
  cursor: pointer;
}

.collection-intro-toggle:hover {
  color: var(--rojo-oscuro);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.collection-intro-word[hidden],
.collection-intro-ellipsis[hidden],
.collection-intro-toggle[hidden] {
  display: none !important;
}

/* ── Categorías por miniatura ── */
.collection-cats {
  display: flex;
  gap: 14px;
  margin-top: 30px;
  padding-bottom: 6px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-width: none;
  cursor: grab;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
  user-select: none;
}

.collection-cats.is-dragging {
  cursor: grabbing;
  scroll-snap-type: none;
}

.collection-cats::-webkit-scrollbar {
  display: none;
}

.collection-cat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
  /* Base desktop: 9 tarjetas completas + media tarjeta. */
  width: calc(10.5263% - 13.2632px);
  text-align: center;
  line-height: 1.25;
  padding: 0;
  border: 0;
  background: transparent;
  color: rgba(64, 28, 28, 0.66);
  font-family: var(--brand-sans);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}

.collection-cat-media {
  display: grid;
  place-items: center;
  width: min(104px, 100%);
  height: auto;
  aspect-ratio: 1;
  border: 1px solid rgba(64, 28, 28, 0.14);
  border-radius: var(--r-sm);
  background: linear-gradient(145deg, #ffffff 0%, #f7f1e8 100%);
  overflow: hidden;
  transition: border-color 160ms cubic-bezier(0.2, 0, 0, 1), box-shadow 160ms cubic-bezier(0.2, 0, 0, 1);
}

.collection-cat-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.collection-cat-all {
  position: relative;
  background: linear-gradient(145deg, #fff 0%, var(--papel-crema) 100%);
}

.collection-cat-all::before {
  width: min(36%, 38px);
  height: min(36%, 38px);
  background: var(--red);
  content: "";
  -webkit-mask: url("/assets/brand-mark.svg") center / contain no-repeat;
  mask: url("/assets/brand-mark.svg") center / contain no-repeat;
}

@media (hover: hover) {
  .collection-cat:hover .collection-cat-media {
    border-color: rgba(226, 51, 51, 0.4);
  }

}

.collection-cat.is-active {
  color: var(--ink);
  font-weight: 600;
}

.collection-cat.is-active .collection-cat-media {
  border: 1.5px solid var(--red);
  box-shadow: none;
}

.collection-cat:focus-visible {
  outline: 0;
}

.collection-cat:focus-visible .collection-cat-media {
  border-color: var(--focus-ring);
  box-shadow: 0 0 0 3px var(--focus-halo);
}

/* ── Toolbar ── */
.collection-toolbar {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-top: 18px;
  padding: 6px 0;
  border-top: 1px solid rgba(64, 28, 28, 0.08);
  border-bottom: 1px solid rgba(64, 28, 28, 0.08);
}

.collection-filters-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 4px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--brand-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-underline-offset: 4px;
}

.collection-filters-btn:focus-visible,
.collection-active-filters button:focus-visible,
.collection-more:focus-visible,
.collection-seo-toggle:focus-visible,
.collection-clear:focus-visible,
.collection-apply:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 3px;
}

@media (hover: hover) {
  .collection-filters-btn:hover {
    text-decoration: underline;
  }
}

.collection-filters-count[hidden] {
  display: none;
}

.collection-filters-count {
  display: grid;
  place-items: center;
  min-width: 20px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
}

.collection-counter {
  margin: 0;
  color: rgba(64, 28, 28, 0.5);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.collection-filters-btn {
  margin-left: auto;
}

/* ── Chips de filtros activos ── */
.collection-active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.collection-active-filters button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid rgba(64, 28, 28, 0.13);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  font-family: var(--brand-sans);
  font-size: 11.25px;
  cursor: pointer;
}

.collection-active-filters button::after {
  content: "✕";
  color: rgba(64, 28, 28, 0.45);
  font-size: 8.5px;
}

/* ── Grid de catálogo ── */
.collection-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 28px 20px;
  margin-top: 22px;
}

.collection-grid .product-card {
  width: auto;
}

.collection-grid .prices {
  gap: 5px;
}

.collection-empty {
  margin: 46px 0;
  color: rgba(64, 28, 28, 0.66);
  font-family: var(--brand-sans);
  font-size: 15px;
  text-align: center;
}

.collection-empty .collection-clear {
  margin-left: 10px;
}

/* ── Ver más ── */
.collection-more-wrap {
  display: grid;
  justify-items: center;
  gap: 13px;
  margin-top: 52px;
  margin-bottom: 18px;
}

.collection-more-note {
  margin: 0;
  color: rgba(64, 28, 28, 0.5);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.collection-more {
  min-height: 46px;
  padding: 0 30px;
  border: 1px solid rgba(64, 28, 28, 0.2);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font-family: var(--brand-sans);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

@media (hover: hover) {
  .collection-more:hover {
    border-color: rgba(226, 51, 51, 0.45);
  }
}

/* ── Bloque SEO ── */
.collection-seo {
  margin-top: 64px;
  margin-bottom: 26px;
  padding-top: 42px;
  border-top: 1px solid rgba(64, 28, 28, 0.08);
}

.collection-seo h2 {
  margin: 0;
  color: var(--ink);
  font-family: var(--display);
  font-size: clamp(26px, 2.6vw, 34px);
  font-weight: 400;
  line-height: 1.05;
}

.collection-seo-body {
  margin-top: 18px;
}

.collection-seo-body p {
  margin: 0 0 14px;
  color: rgba(64, 28, 28, 0.72);
  font-family: var(--brand-sans);
  font-size: 13.5px;
  line-height: 1.68;
}

.collection-seo-body.is-clamped {
  position: relative;
  max-height: 116px;
  overflow: hidden;
}

.collection-seo-body.is-clamped::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 48px;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), #fff 92%);
}

.collection-seo-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  margin-top: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--rojo-oscuro);
  font-family: var(--brand-sans);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}

.collection-seo-toggle::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
  transition: transform 160ms cubic-bezier(0.2, 0, 0, 1);
}

.collection-seo-toggle[aria-expanded="true"]::after {
  transform: translateY(1px) rotate(-135deg);
}

/* ── Drawer de filtros ── */
.collection-filters {
  position: fixed;
  inset: 0;
  z-index: 1200;
  visibility: hidden;
}

.collection-filters.is-open {
  visibility: visible;
}

.collection-filters-scrim {
  position: absolute;
  inset: 0;
  border: 0;
  background: var(--overlay-scrim);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 220ms cubic-bezier(0.2, 0, 0, 1);
  cursor: pointer;
}

.collection-filters.is-open .collection-filters-scrim {
  opacity: 1;
}

.collection-filters-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(420px, calc(100vw - 18px));
  background: #fff;
  border-left: 1px solid rgba(64, 28, 28, 0.08);
  border-radius: 15px 0 0 15px;
  box-shadow: -12px 0 34px rgba(64, 28, 28, 0.12);
  transform: translateX(101%);
  transition: transform 260ms cubic-bezier(0.2, 0, 0, 1);
}

.collection-filters.is-open .collection-filters-drawer {
  transform: none;
}

.collection-filters-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 14px;
  border-bottom: 1px solid rgba(64, 28, 28, 0.08);
}

.collection-filters-head h2 {
  margin: 0;
  color: var(--ink);
  font-family: var(--display);
  font-size: 24px;
  font-weight: 400;
}

.collection-filters-x {
  position: relative;
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.collection-filters-x::before,
.collection-filters-x::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 1.6px;
  background: var(--ink);
}

.collection-filters-x::before { transform: translate(-50%, -50%) rotate(45deg); }
.collection-filters-x::after { transform: translate(-50%, -50%) rotate(-45deg); }

.collection-filters-x {
  border-radius: 50%;
  outline: 0;
}

@media (hover: hover) and (pointer: fine) {
  .collection-filters-x:hover {
    background: rgba(64, 28, 28, 0.045);
  }
}

.collection-filters-x:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.collection-filters-body {
  overflow-y: auto;
  padding: 10px 24px 18px;
}

.collection-filters-body fieldset {
  margin: 0;
  padding: 22px 0;
  border: 0;
  border-bottom: 1px solid rgba(64, 28, 28, 0.08);
}

.collection-filters-body fieldset:last-child {
  border-bottom: 0;
}

.collection-filters-body legend {
  float: left;
  width: 100%;
  padding: 0 0 14px;
  color: var(--red);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.collection-filters-body fieldset > div {
  clear: both;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}

.collection-filters-body label {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  color: var(--ink);
  font-family: var(--brand-sans);
  font-size: 14px;
  cursor: pointer;
}

/* Precio: chips en fila, mejor aprovechamiento */
.collection-filters-body fieldset[data-filter-style="chips"] > div {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

fieldset[data-filter-style="chips"] label {
  min-height: 44px;
  padding: 0 14px;
  gap: 0;
  border: 1px solid var(--control-border);
  border-radius: 7px;
  font-size: 13px;
  transition: border-color 140ms cubic-bezier(0.2, 0, 0, 1), background 140ms cubic-bezier(0.2, 0, 0, 1);
}

fieldset[data-filter-style="chips"] .collection-check {
  display: none;
}

fieldset[data-filter-style="chips"] label:has(input:checked) {
  border-color: var(--control-border-active);
  background: var(--control-active-bg);
  color: var(--ink);
  font-weight: 600;
}

fieldset[data-filter-style="chips"] label:has(input:focus-visible) {
  border-color: var(--focus-ring);
  box-shadow: 0 0 0 3px var(--focus-halo);
}

.collection-filters-body input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.collection-filters-body .collection-sort-options {
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.collection-sort-options label {
  min-height: 44px;
  padding: 0 11px;
  border: 1px solid var(--control-border);
  border-radius: var(--r-sm);
  background: #fff;
  font-size: 12.5px;
}

.collection-sort-options input[type="radio"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.collection-radio {
  display: grid;
  place-items: center;
  flex: 0 0 17px;
  width: 17px;
  height: 17px;
  border: 1px solid rgba(64, 28, 28, 0.28);
  border-radius: 50%;
  background: #fff;
}

.collection-radio::after {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--control-selected-indicator);
  content: "";
  opacity: 0;
}

.collection-sort-options label:has(input:checked) {
  border-color: var(--control-border-active);
  background: var(--control-active-bg);
  font-weight: 600;
}

.collection-sort-options input:checked + .collection-radio {
  border-color: var(--control-border-active);
}

.collection-sort-options input:checked + .collection-radio::after {
  opacity: 1;
}

.collection-sort-options label:has(input:focus-visible) {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.collection-check {
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border: 1px solid rgba(64, 28, 28, 0.28);
  border-radius: 5px;
  background: #fff;
  transition: background 140ms cubic-bezier(0.2, 0, 0, 1), border-color 140ms cubic-bezier(0.2, 0, 0, 1);
}

.collection-check::after {
  content: "";
  width: 9px;
  height: 5px;
  border-left: 2px solid #fff;
  border-bottom: 2px solid #fff;
  transform: rotate(-45deg) translate(0, -1px);
  opacity: 0;
}

input:checked + .collection-check {
  border-color: var(--control-border-active);
  background: var(--control-selected-indicator);
}

input:checked + .collection-check::after {
  opacity: 1;
}

input:focus-visible + .collection-check {
  border-color: var(--focus-ring);
  box-shadow: 0 0 0 3px var(--focus-halo);
}

@media (hover: hover) {
  .collection-filters-body label:hover .collection-check {
    border-color: var(--control-border-hover);
  }
}

.collection-filters-foot {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  padding: 14px 24px calc(16px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(64, 28, 28, 0.08);
}

.collection-clear {
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: rgba(64, 28, 28, 0.62);
  font-family: var(--brand-sans);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.collection-apply {
  min-height: 48px;
  border: 0;
  border-radius: 7px;
  background: var(--red);
  color: #fff;
  font-family: var(--brand-sans);
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
}

.collection-apply:active {
  background: var(--red-dark);
}

/* ── Responsive ── */
@media (min-width: 761px) and (max-width: 1180px) {
  .collection-head,
  .collection-cats,
  .collection-toolbar,
  .collection-active-filters,
  .collection-catalog,
  .collection-seo {
    width: min(100% - 56px, 960px);
  }

  .collection-cat-media {
    width: min(108px, 100%);
  }
}

/* En desktop ancho caben más categorías sin aumentar el espacio invisible
   alrededor de cada miniatura; el último elemento conserva el peek del 50 %. */
@media (min-width: 1280px) and (max-width: 1399px) {
  .collection-cat { width: calc(9.5238% - 13.3333px); }
}

@media (min-width: 1400px) {
  .collection-cat { width: calc(8.6957% - 13.3913px); }
}

@media (min-width: 761px) and (max-width: 899px) {
  /* 6,5 categorías visibles. */
  .collection-cat { width: calc(15.3846% - 12.9231px); }
  .collection-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 900px) and (max-width: 1180px) {
  /* 7,5 categorías visibles. */
  .collection-cat { width: calc(13.3333% - 13.0667px); }
  .collection-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .collection-main {
    padding-top: 86px;
  }

  .collection-head,
  .collection-cats,
  .collection-toolbar,
  .collection-active-filters,
  .collection-catalog,
  .collection-seo {
    width: calc(100% - 36px);
  }

  .collection-head {
    margin-top: 14px;
  }

  .collection-head [data-intro-body] {
    margin-top: 8px;
    font-size: 14px;
  }

  .collection-delivery-promise {
    margin-top: 11px;
    font-size: 13.5px;
  }

  /* La tira de categorías sangra hasta el borde para invitar al swipe */
  .collection-cats {
    width: 100%;
    gap: 10px;
    padding-left: 18px;
    padding-right: 18px;
    margin-top: 16px;
    scroll-padding-inline: 18px;
    scroll-snap-type: x proximity;
  }

  .collection-cat {
    gap: 7px;
    font-size: 11.5px;
    scroll-snap-align: start;
  }

  .collection-cat-media {
    width: min(calc(100% - 4px), 104px);
    height: auto;
    aspect-ratio: 1;
  }

  .collection-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 4px 0;
  }

  .collection-counter {
    margin: 0;
  }

  .collection-filters-btn {
    width: auto;
    min-height: 44px;
    margin-left: auto;
    padding: 0 4px;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  .collection-active-filters button {
    min-height: 30px;
    padding-inline: 9px;
  }

  .collection-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px 14px;
    margin-top: 20px;
  }

  .collection-seo {
    margin-top: 42px;
    padding-top: 32px;
  }
}

/* Half-item peek móvil. La propia geometría deja media categoría visible;
   no necesita degradados, indicadores ni lógica JavaScript. */
@media (max-width: 430px) {
  .collection-cat { width: calc(28.5714% - 3.4286px); }
}

@media (min-width: 431px) and (max-width: 600px) {
  .collection-cat { width: calc(22.2222% - 4.8889px); }
}

@media (min-width: 601px) and (max-width: 760px) {
  .collection-cat { width: calc(18.1818% - 5.8182px); }
  .collection-cat-media { width: min(calc(100% - 4px), 112px); }
}

@media (max-width: 360px) {
  .collection-head h1 {
    font-size: 30px;
    line-height: 1.02;
  }
}

@media (min-width: 561px) and (max-width: 760px) {
  .collection-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .collection-filters-scrim,
  .collection-filters-drawer,
  .collection-cat-media,
  .collection-seo-toggle::after {
    transition: none;
  }
}
