/* Chorregalos — tono informal/desenfadado (ver docs/decisions/0013) */

:root {
  --color-primary: #ff5a4e;
  --color-primary-dark: #e0402f;
  --color-bg: #fffaf3;
  --color-surface: #ffffff;
  --color-text: #2b2620;
  --color-muted: #79706a;
  --color-border: #f0e4d8;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(43, 38, 32, 0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.5;
}

a {
  color: var(--color-primary-dark);
}

.site-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 1.5rem;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.site-header__logo {
  order: 1;
  flex-shrink: 0;
  font-size: 1.5rem;
  font-weight: 800;
  text-decoration: none;
  color: var(--color-text);
}

.site-header__logo span {
  color: var(--color-primary);
}

.btn {
  padding: 0.5rem 1.1rem;
  border: none;
  border-radius: 999px;
  background: var(--color-primary);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  font-size: 1rem;
}

.btn:hover {
  background: var(--color-primary-dark);
}

/* Editor de búsqueda */

.search-editor {
  order: 2;
  position: relative;
  flex: 1 1 260px;
}

/* En escritorio ocupa todo el hueco entre el logo y los menús; en móvil
   pasa a su propia línea, a todo el ancho, debajo de logo+menús. */
@media (max-width: 720px) {
  .search-editor {
    order: 4;
    flex-basis: 100%;
  }
}

.search-editor__box {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.3rem 0.4rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-bg);
}

.search-editor__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.search-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.2rem 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
}

.search-chip--include {
  background: var(--color-primary);
}

.search-chip--exclude {
  background: var(--color-muted);
}

.search-chip__remove {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0.1rem 0.4rem;
}

.search-editor__input {
  flex: 1 1 120px;
  min-width: 90px;
  border: none;
  background: transparent;
  font-size: 1rem;
  padding: 0.4rem 0.2rem;
  outline: none;
}

.search-editor__icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.05rem;
  padding: 0.2rem 0.35rem;
  border-radius: 999px;
}

.search-editor__icon-btn:hover {
  background: var(--color-border);
}

.search-editor__box .btn {
  padding: 0.4rem 0.9rem;
  font-size: 0.9rem;
}

.search-suggestions {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 60vh;
  overflow-y: auto;
  z-index: 20;
}

.search-suggestions__heading {
  padding: 0.5rem 0.9rem 0.25rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted);
  font-weight: 700;
}

.search-suggestions__item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.9rem;
  cursor: pointer;
  color: var(--color-text);
  text-decoration: none;
  font-size: 0.9rem;
}

.search-suggestions__item:hover,
.search-suggestions__item--active {
  background: var(--color-bg);
}

.search-suggestions__item--product img {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

/* Menús desplegables clásicos (Ocasiones / Tags) */

.filter-menus {
  order: 3;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.filter-menu {
  position: relative;
}

.filter-menu__toggle {
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  color: var(--color-text);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

.filter-menu__toggle:hover {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}

.filter-menu__panel {
  display: none;
  position: absolute;
  /* top:100% pegado al botón, SIN margin-top — un hueco real entre
     botón y panel (por posición o por margin, da igual) rompe :hover al
     bajar el ratón en línea recta, porque esa franja no pertenece a
     ningún elemento. El espacio visual se consigue con padding-top, que
     sí forma parte de la caja del panel (y por tanto sigue "hovereado"). */
  top: 100%;
  left: 0;
  min-width: 220px;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.9rem 0.5rem 0.5rem;
  z-index: 20;
}

.filter-menu:hover .filter-menu__panel,
.filter-menu:focus-within .filter-menu__panel {
  display: block;
}

.filter-menu__option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.4rem 0.6rem;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--color-text);
}

.filter-menu__option:hover {
  background: var(--color-bg);
}

.filter-menu__option--active {
  background: var(--color-primary);
  color: #fff;
}

.filter-menu__option--excluded {
  background: var(--color-muted);
  color: #fff;
}

/* Modal de ayuda de búsqueda avanzada */

.search-help-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(43, 38, 32, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 30;
  padding: 1rem;
}

/* [hidden] tiene la misma especificidad que una clase — sin esto,
   display:flex de arriba gana al display:none del atributo hidden del
   navegador (llega después en la cascada) y el modal se ve siempre. */
.search-help-modal:not([hidden]) {
  display: flex;
}

.search-help-modal__content {
  position: relative;
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
}

.search-help-modal__content code {
  background: var(--color-bg);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
}

.search-help-modal__close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  border: none;
  background: transparent;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--color-muted);
}

main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.hero {
  text-align: center;
  padding: 2rem 1rem 3rem;
}

.hero h1 {
  font-size: 2.4rem;
  margin-bottom: 0.25rem;
}

.hero p {
  color: var(--color-muted);
  font-size: 1.1rem;
  margin-top: 0;
}

.hero .search-form {
  justify-content: center;
  margin: 1.5rem 0 1rem;
}

.page-title {
  font-size: 1.7rem;
  margin-bottom: 1.5rem;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.product-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease;
}

.product-card:hover {
  transform: translateY(-3px);
}

.product-card__image {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.product-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-card__image .placeholder {
  font-size: 2.5rem;
}

.product-card__image-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  transform: translateY(-50%);
  border: none;
  background: rgba(43, 38, 32, 0.55);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.product-card__image:hover .product-card__image-nav {
  opacity: 1;
}

.product-card__image-nav--prev {
  left: 0.4rem;
}

.product-card__image-nav--next {
  right: 0.4rem;
}

/* El efecto "empuje" al cambiar de foto (tarjetas y ficha de producto)
   ya no usa clases CSS: window.ChorreGallery.animateImageSwap en
   product-cards.js crea una imagen temporal y anima ambas por estilo
   inline, así no hay ninguna transición que cortar a medias (ver
   comentario en ese fichero sobre por qué la versión anterior rebotaba). */

/* En la ficha de producto no hay hover que revele las flechas (no son
   parte de una tarjeta) — siempre visibles. */
.product-detail__image-nav {
  opacity: 1;
}

.product-card__body {
  padding: 0.9rem 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  flex-grow: 1;
}

.product-card__title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text);
  text-decoration: none;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-card__cta-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: auto;
}

.product-card__price {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--color-primary-dark);
}

.product-card__cta {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

/* Icono de marketplace: iniciales sobre un círculo de color, no el logo
   real de terceros (evita líos de marca/licencia) — mismo criterio que
   el nombre en texto que sustituye. */
.marketplace-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  flex-shrink: 0;
}

.marketplace-icon--aliexpress {
  color: #e62e04;
}

.marketplace-icon--amazon {
  color: #232f3e;
}

.product-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.product-card__tags a {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-primary-dark);
  text-decoration: none;
  background: var(--color-bg);
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
}

.product-card__tags a:hover {
  background: var(--color-primary);
  color: #fff;
}

.empty-state {
  color: var(--color-muted);
  padding: 2rem 0;
}

.draft-banner {
  background: #ffef99;
  color: #4a3f00;
  padding: 0.6rem 1rem;
  border-radius: var(--radius);
  font-weight: 600;
  margin-bottom: 1.5rem;
}

.article {
  max-width: 720px;
}

.article h1 {
  font-size: 2rem;
}

.article-body {
  font-size: 1.05rem;
}

.article-body img {
  max-width: 100%;
  border-radius: var(--radius);
}

.site-footer {
  border-top: 1px solid var(--color-border);
  padding: 1.5rem;
  text-align: center;
  color: var(--color-muted);
  font-size: 0.85rem;
}

.site-footer p {
  max-width: 640px;
  margin: 0.3rem auto;
}

.product-detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 2rem;
}

@media (max-width: 700px) {
  .product-detail {
    grid-template-columns: 1fr;
  }
}

.product-detail__main-image {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-detail__main-image img {
  cursor: zoom-in;
}

.product-detail__main-image--placeholder .placeholder {
  font-size: 4rem;
}

.product-detail__main-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-detail__thumbnails {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.product-detail__thumbnail {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  opacity: 0.7;
}

.product-detail__thumbnail:hover,
.product-detail__thumbnail.active {
  border-color: var(--color-primary);
  opacity: 1;
}

.product-detail__info h1 {
  font-size: 1.6rem;
  margin-top: 0;
}

.product-detail__price {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--color-primary-dark);
  margin: 0.25rem 0 1rem;
}

.product-detail__description {
  color: var(--color-text);
  line-height: 1.6;
  margin: 1rem 0;
}

.product-detail__cta {
  margin-top: 1rem;
  font-size: 1.05rem;
  padding: 0.75rem 1.5rem;
}

/* Lightbox de la ficha de producto: foto a pantalla completa con
   flechas y miniaturas. Mismo patrón que .search-help-modal para el
   bug de especificidad de [hidden] (ver comentario más arriba). */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 17, 14, 0.92);
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 2rem 1rem 6rem;
}

.lightbox:not([hidden]) {
  display: flex;
}

.lightbox__image {
  max-width: min(90vw, 900px);
  max-height: 75vh;
  object-fit: contain;
  border-radius: 8px;
}

.lightbox__close {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox__nav:hover {
  background: rgba(255, 255, 255, 0.3);
}

.lightbox__nav--prev {
  left: 1rem;
}

.lightbox__nav--next {
  right: 1rem;
}

.lightbox__thumbnails {
  position: absolute;
  bottom: 1.5rem;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0 1rem;
}

.lightbox__thumbnail {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  opacity: 0.6;
}

.lightbox__thumbnail:hover,
.lightbox__thumbnail.active {
  border-color: var(--color-primary);
  opacity: 1;
}
