/*
 * commerce.css — ConservasDeNavarra.org
 * Estilos del sistema de comercio:
 * catálogo, product cards, filtros de categoría,
 * cart drawer y order modal.
 * Reutilizable en cualquier página con carrito.
 * Requiere base.css cargado antes.
 */

/* ══ CATÁLOGO — cabecera y filtros ════════════════════════════ */
.catalogo {
  padding: 6rem 2.5rem;
  background: var(--cw);
}

.cat-hd {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  margin-bottom: 2rem;
  gap: 2rem;
}

.cat-hd-text .sec-ey {
  margin-bottom: 0.5rem;
}

.cat-h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 38px;
  font-weight: 300;
  color: var(--o);
  line-height: 1.1;
}

.cat-h2 em {
  font-style: italic;
  color: var(--t);
}

.cat-view-all {
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--t);
  border-bottom: 0.5px solid rgba(122, 92, 58, 0.25);
  padding-bottom: 1px;
  white-space: nowrap;
  transition: color 0.2s;
}

.cat-view-all:hover {
  color: var(--o);
}

/* Filtros de categoría */
.cat-tabs {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-bottom: 2.5rem;
}

.cat-tab {
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 7px 16px;
  border: 0.5px solid rgba(122, 92, 58, 0.22);
  background: transparent;
  color: var(--t);
  cursor: pointer;
  transition: all 0.2s;
}

.cat-tab:hover {
  border-color: var(--t);
  color: var(--o);
}

.cat-tab.active {
  background: var(--o);
  color: var(--c);
  border-color: var(--o);
}

/* ══ PRODUCT GRID ══════════════════════════════════════════════ */
.product-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
}

/* ══ PRODUCT CARD ══════════════════════════════════════════════ */
.pc {
  background: var(--w);
  display: flex;
  flex-direction: column;
  border: 0.5px solid rgba(122, 92, 58, 0.06);
  overflow: hidden;
  position: relative;
  transition: transform 0.3s, box-shadow 0.3s;
}

.pc:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 44px rgba(26, 22, 16, 0.08);
}

.pc.hidden {
  display: none;
}

/* Imagen */
.pc-img {
  width: 100%;
  height: 280px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  cursor: zoom-in;
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Padding reducido para que el producto ocupe más espacio del contenedor. */
  padding: 14px 18px;
}

/* ── NORMALIZACIÓN DE PESO VISUAL ─────────────────────────────────
   Las latas horizontales y los tarros verticales tienen aspect-ratios
   muy distintos. Sin forzar dimensión, las latas quedan pequeñas y
   los tarros llenan la card.
   Solución: dar a la imagen una altura objetivo (no max). Cada imagen
   escala su lado más restrictivo a ese tamaño y mantiene proporción.
   - Tarros (altos): alcanzan la altura, el ancho queda contenido por el padding.
   - Latas (anchas): alcanzan la altura proporcional al ancho disponible.
   El resultado: todas las imágenes tienen el mismo "peso visual" en card,
   independientemente del formato del envase. */
.pc-img img {
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: transform 0.4s ease;
}

.pc:hover .pc-img img {
  transform: scale(1.04);
}


/* ── OVERLAY "AÑADIR AL CARRITO" (visible en hover, desktop) ──────
   Hover refinado: sin oscurecer la imagen, botón más pequeño y
   sutil. Transición discreta. La interacción sigue clara pero
   no compite con el producto. */
.pc-img-overlay {
  position: absolute;
  inset: auto 0 0 0;          /* alineado abajo, no centrado */
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 0 12px;
  background: transparent;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  z-index: 3;
}
.pc:hover .pc-img-overlay {
  opacity: 1;
  pointer-events: auto;
}
.pc-img-overlay .pc-img-overlay-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  height: auto;
  padding: 7px 13px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--o);
  border: 0.5px solid rgba(122, 92, 58, 0.18);
  font-family: 'Jost', sans-serif;
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 500;
  cursor: pointer;
  transform: translateY(4px);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              background 0.18s,
              color 0.18s;
  white-space: nowrap;
  border-radius: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}
.pc:hover .pc-img-overlay .pc-img-overlay-btn {
  transform: translateY(0);
}
.pc-img-overlay .pc-img-overlay-btn:hover {
  background: var(--o);
  color: #FFFFFF;
  border-color: var(--o);
}
.pc-img-overlay .pc-img-overlay-btn svg {
  width: 10px;
  height: 10px;
  stroke-width: 1.6;
  flex-shrink: 0;
}

/* En móvil/táctil ocultar el overlay (no hay hover) — queda el botón + del footer */
@media (hover: none), (max-width: 720px) {
  .pc-img-overlay {
    display: none;
  }
}

.pc-img-ph {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 1.25rem;
  text-align: center;
}

.pc-img-ph span {
  font-size: 8px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.pc-img-ph em {
  font-family: 'Cormorant Garamond', serif;
  font-size: 12px;
  font-style: italic;
  font-weight: 300;
  line-height: 1.4;
}

/* Badge denominación */
.pc-badge {
  position: absolute;
  top: 0.85rem;
  left: 0.85rem;
  z-index: 2;
  font-size: 12px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  padding: 4px 10px;
  border: 0.5px solid rgba(196, 176, 124, 0.5);
  color: rgba(196, 176, 124, 0.95);
  background: rgba(26, 22, 16, 0.52);
  backdrop-filter: blur(4px);
}

/* Cuerpo de card */
.pc-body {
  padding: 1.25rem 1.25rem 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.pc-cat {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--t);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.pc-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 17px;
  font-weight: 400;
  color: var(--o);
  line-height: 1.22;
  margin-bottom: 0.4rem;
  /* Reparto tipográfico equilibrado: navegadores compatibles
     distribuyen mejor los caracteres entre líneas, evitando
     una línea muy llena seguida de otra casi vacía.
     Fallback silencioso en navegadores antiguos. */
  text-wrap: balance;
  /* Empuja el pie hacia abajo para que el precio se alinee
     entre cards de distinta altura de nombre */
  flex: 1;
}

/* Pie de card */
.pc-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 0.5px solid rgba(122, 92, 58, 0.08);
  padding-top: 1rem;
  margin-top: 1rem;
}

.pc-price {
  font-family: 'Cormorant Garamond', serif;
  font-size: 21px;
  font-weight: 300;
  color: var(--o);
  line-height: 1;
}

/* Botón añadir */
.add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: var(--o);
  color: var(--c);
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  font-size: 12px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  font-weight: 500;
  transition: background 0.2s;
}

.add-btn:hover {
  background: var(--os);
}

.add-btn.added {
  background: var(--v);
}

.add-btn svg {
  flex-shrink: 0;
}

/* Nota comercial */
.cat-nota {
  margin-top: 2.5rem;
  padding: 1.25rem 1.5rem;
  background: var(--w);
  border: 0.5px solid rgba(122, 92, 58, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.cat-nota-txt {
  font-size: 15px;
  color: var(--g);
  font-weight: 300;
}

.cat-nota-txt strong {
  color: var(--o);
  font-weight: 400;
}

.cat-nota-wa {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--v);
  color: var(--w);
  padding: 10px 18px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 500;
  flex-shrink: 0;
  transition: background 0.2s;
}

.cat-nota-wa:hover {
  background: var(--vm);
}

/* ══ CART DRAWER ═══════════════════════════════════════════════ */
.cart-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(26, 22, 16, 0);
  pointer-events: none;
  transition: background 0.35s ease;
}

.cart-overlay.open {
  background: rgba(26, 22, 16, 0.5);
  pointer-events: auto;
}

.cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: 380px;
  max-width: 95vw;
  background: var(--w);
  z-index: 401;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.38s cubic-bezier(0, 0, 0.2, 1);
  border-left: 0.5px solid rgba(122, 92, 58, 0.2);
}

.cart-drawer.open {
  transform: translateX(0);
}

.cart-hd {
  padding: 2rem;
  border-bottom: 0.5px solid rgba(122, 92, 58, 0.1);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.cart-ht {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  font-weight: 400;
  color: var(--o);
}

.cart-cls {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--g);
  transition: color 0.2s;
}

.cart-cls:hover {
  color: var(--o);
}

.cart-items-el {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1px;
  scrollbar-width: thin;
  scrollbar-color: rgba(122, 92, 58, 0.12) transparent;
}

/* Estado vacío */
.cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 1rem;
  text-align: center;
  padding: 3rem 2rem;
}

.cart-empty-icon {
  font-family: 'Cormorant Garamond', serif;
  font-size: 48px;
  font-weight: 300;
  color: rgba(122, 92, 58, 0.18);
  line-height: 1;
}

.cart-empty-txt {
  font-size: 16px;
  color: var(--g);
  font-weight: 400;
  line-height: 1.68;
}

/* Filas de item */
.cart-item-row {
  padding: 1.25rem 0;
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 0.85rem;
  align-items: start;
  border-bottom: 0.5px solid rgba(122, 92, 58, 0.07);
}

.cart-item-row:last-child {
  border-bottom: none;
}

.ci-thumb {
  width: 56px;
  height: 56px;
  object-fit: contain;
  background: var(--cw);
  padding: 3px;
}

.ci-thumb-ph {
  width: 56px;
  height: 56px;
  background: var(--cw);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0.5px solid rgba(122, 92, 58, 0.1);
  font-family: 'Cormorant Garamond', serif;
  font-size: 20px;
  font-weight: 300;
  color: rgba(122, 92, 58, 0.2);
}

.ci-producer {
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--t);
  margin-bottom: 0.2rem;
  font-weight: 500;
}

.ci-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 16px;
  font-weight: 400;
  color: var(--o);
  line-height: 1.25;
  margin-bottom: 0.3rem;
}

.ci-price {
  font-size: 13px;
  color: var(--g);
  font-weight: 300;
  white-space: nowrap;
}

.ci-qty {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.qbtn {
  width: 22px;
  height: 22px;
  border: 0.5px solid rgba(122, 92, 58, 0.2);
  background: transparent;
  color: var(--g);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s;
}

.qbtn:hover {
  border-color: var(--t);
  color: var(--o);
  background: var(--c);
}

.qnum {
  font-size: 13px;
  min-width: 20px;
  text-align: center;
  color: var(--o);
}

.ci-rm {
  color: var(--gl);
  font-size: 16px;
  padding: 2px;
  transition: color 0.18s;
  align-self: center;
}

.ci-rm:hover {
  color: var(--t);
}

/* Footer del drawer */
.cart-ft {
  padding: 1.5rem 2rem 2rem;
  border-top: 0.5px solid rgba(122, 92, 58, 0.1);
  background: var(--c);
}

.cart-tot-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 1.25rem;
}

.cart-tot-lbl {
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--t);
}

.cart-tot-amt {
  font-family: 'Cormorant Garamond', serif;
  font-size: 26px;
  font-weight: 300;
  color: var(--o);
}

.cart-wa-btn {
  width: 100%;
  background: var(--v);
  color: var(--w);
  padding: 14px;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s;
}

.cart-wa-btn:hover {
  background: var(--vm);
}

.cart-bottom-note {
  font-size: 13px;
  color: var(--gl);
  text-align: center;
  margin-top: 0.85rem;
  letter-spacing: 0.04em;
}

/* ══ ORDER MODAL ═══════════════════════════════════════════════ */
.order-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(26, 22, 16, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  padding: 1.5rem;
}

.order-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.order-modal {
  background: var(--w);
  width: 100%;
  max-width: 500px;
  padding: 3rem;
  position: relative;
  border: 0.5px solid rgba(122, 92, 58, 0.12);
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(16px);
  transition: transform 0.3s ease;
}

.order-overlay.open .order-modal {
  transform: translateY(0);
}

.order-cls {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--g);
  transition: color 0.2s;
}

.order-cls:hover {
  color: var(--o);
}

.order-ey {
  font-size: 13px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--t);
  margin-bottom: 0.75rem;
  display: block;
  font-weight: 500;
}

.order-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 28px;
  font-weight: 300;
  color: var(--o);
  margin-bottom: 0.4rem;
}

.order-sub {
  font-size: 17px;
  color: var(--t);
  font-weight: 400;
  margin-bottom: 2rem;
}

.order-summary-el {
  background: var(--c);
  border: 0.5px solid rgba(122, 92, 58, 0.1);
  padding: 1.25rem;
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
}

.os-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 0.5px solid rgba(122, 92, 58, 0.07);
  font-size: 15px;
  color: var(--g);
  font-weight: 300;
}

.os-row > span {
  /* el nombre del producto puede romper */
  min-width: 0;
}

.os-row:last-child {
  border-bottom: none;
  color: var(--o);
  font-weight: 400;
}

.os-row strong {
  font-family: 'Cormorant Garamond', serif;
  font-size: 16px;
  font-weight: 400;
  color: var(--o);
  /* el precio nunca se rompe en dos líneas */
  white-space: nowrap;
  flex-shrink: 0;
}

/* Formulario del modal */
.order-form-el {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.of-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin-bottom: 1px;
}

.of {
  display: flex;
  flex-direction: column;
  background: var(--c);
}

.of label {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--t);
  padding: 0.75rem 1rem 0.2rem;
}

.of input,
.of textarea {
  background: transparent;
  border: none;
  outline: none;
  font-family: 'Jost', sans-serif;
  font-size: 15px;
  color: var(--o);
  padding: 0.35rem 1rem 0.85rem;
  font-weight: 300;
  border-bottom: 0.5px solid rgba(122, 92, 58, 0.1);
  transition: border-color 0.2s;
  width: 100%;
  resize: none;
}

.of input:focus,
.of textarea:focus {
  border-bottom-color: var(--t);
}

.of input::placeholder,
.of textarea::placeholder {
  color: var(--gl);
}

.of textarea {
  min-height: 72px;
}

.of-submit {
  width: 100%;
  background: var(--v);
  color: var(--w);
  padding: 15px;
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.2s;
}

.of-submit:hover {
  background: var(--vm);
}

.of-privacy {
  font-size: 12px;
  color: var(--g);
  text-align: center;
  margin-top: 1rem;
  letter-spacing: 0.04em;
}

.of-privacy a {
  color: var(--t);
  border-bottom: 0.5px solid rgba(122, 92, 58, 0.2);
}

/* ══ RESPONSIVE — commerce ═════════════════════════════════════ */
@media (max-width: 1100px) {
  .product-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .catalogo {
    padding: 4rem 1.25rem;
  }

  .product-grid {
    grid-template-columns: 1fr 1fr;
  }

  .cart-drawer {
    width: 100%;
    max-width: 100%;
  }

  .order-modal {
    padding: 2rem 1.5rem;
  }

  .of-row {
    grid-template-columns: 1fr;
  }
}

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

/* ══ LIGHTBOX ══════════════════════════════════════════════════
   Activado al hacer clic en .pc-img con imagen real.
   Sin dependencias externas.
══════════════════════════════════════════════════════════════ */
.cdn-lightbox {
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgba(26, 22, 16, 0);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, background 0.25s ease;
}

.cdn-lightbox.open {
  opacity: 1;
  pointer-events: auto;
  background: rgba(26, 22, 16, 0.88);
}

.cdn-lightbox-inner {
  position: relative;
  max-width: 860px;
  max-height: 90vh;
  width: 100%;
  transform: scale(0.96);
  transition: transform 0.25s ease;
}

.cdn-lightbox.open .cdn-lightbox-inner {
  transform: scale(1);
}

.cdn-lightbox-img {
  display: block;
  width: 100%;
  max-height: 82vh;
  object-fit: contain;
  border: 0.5px solid rgba(196, 176, 124, 0.12);
}

.cdn-lightbox-caption {
  font-size: 12px;
  letter-spacing: 0.1em;
  color: rgba(245, 237, 224, 0.72);
  margin-top: 0.75rem;
  text-align: center;
}

.cdn-lightbox-close {
  position: absolute;
  top: -2.5rem;
  right: 0;
  font-family: 'Jost', sans-serif;
  font-size: 12px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(245, 237, 224, 0.72);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: color 0.18s;
}

.cdn-lightbox-close:hover {
  color: var(--c);
}

/* ═══════════════════════════════════════════════════════════════
   CONSENTIMIENTO RGPD — checkbox del formulario de pedido
   ─────────────────────────────────────────────────────────────
   Sobreescribe las reglas heredadas de .of label y .of input
   para que el checkbox se vea con su texto en línea normal.
═══════════════════════════════════════════════════════════════ */
.of-consent {
  margin-top: 0.5rem;
  padding: 1rem;
  background: rgba(122, 92, 58, 0.04);
  border-left: 2px solid rgba(122, 92, 58, 0.22);
  border-radius: 2px;
  display: block;  /* anula display:flex de .of para este caso */
}
.of-consent .of-consent-label {
  /* Sobreescribir 'font-size 11px, uppercase, letter-spacing 0.18em' de .of label */
  display: flex !important;
  align-items: flex-start;
  gap: 0.7rem;
  cursor: pointer;
  padding: 0 !important;
  font-size: 12.5px !important;
  font-weight: 400;
  letter-spacing: 0 !important;
  text-transform: none !important;
  line-height: 1.5;
  color: rgba(28, 24, 18, 0.78);
  width: 100%;
}
.of-consent .of-consent-label span {
  flex: 1;
  text-align: left;
}
.of-consent .of-consent-label input[type="checkbox"] {
  /* Sobreescribir width:100% y padding de .of input */
  width: 16px !important;
  height: 16px !important;
  padding: 0 !important;
  margin: 3px 0 0 0 !important;
  flex-shrink: 0;
  border: 1px solid rgba(122, 92, 58, 0.4) !important;
  border-bottom: 1px solid rgba(122, 92, 58, 0.4) !important;
  accent-color: var(--tierra, #7A5C3A);
  cursor: pointer;
  background: white;
}


/* ═══════════════════════════════════════════════════════════════
   ENLACE DEL NOMBRE DE PRODUCTO A SU FICHA INDIVIDUAL
   El enlace dentro de .pc-name aparece cuando el producto tiene
   campo fichaUrl. Hereda color del h3 para no romper la estética.
═══════════════════════════════════════════════════════════════ */
.pc-name-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 0.5px solid transparent;
  transition: border-color 0.2s ease;
}
.pc-name-link:hover {
  border-bottom-color: rgba(122, 92, 58, 0.5);
}
