/* Componentes compartidos: marca, botones, catálogo, bolsa y diálogos. */

/* Marca y botones */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  white-space: nowrap;
}

.brand img {
  width: 58px;
  height: 58px;
  flex: none;
  object-fit: contain;
  mix-blend-mode: multiply;
}

.brand-word {
  color: var(--color-forest);
  font: 700 clamp(1.3rem, 1.8vw, 1.62rem)/1 var(--font-serif);
  letter-spacing: -.045em;
}

.bag-button, .add-product, .close-dialog, .menu-toggle {
  min-height: 44px;
  border: 1px solid var(--color-forest);
}

.bag-button {
  display: inline-flex;
  min-width: 150px;
  min-height: 54px;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 0 20px;
  color: var(--color-cream);
  background: var(--color-forest);
  font-size: .92rem;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  transition: transform .18s ease, background .18s ease;
}

.bag-button:hover {
  background: var(--color-pine);
  transform: translateY(-1px);
}

.bag-button span {
  display: inline-grid;
  width: 27px;
  height: 27px;
  margin-left: 0;
  place-items: center;
  color: var(--color-forest);
  background: var(--color-sun);
  border-radius: 50%;
  font-size: .76rem;
  font-weight: 900;
}

.menu-toggle {
  display: none;
  min-width: 48px;
  width: 48px;
  min-height: 48px;
  padding: 0;
  background: transparent;
  font-size: 1.1rem;
}

.intro-label {
  font-size: .67rem;
  font-weight: 900;
  letter-spacing: .19em;
  text-transform: uppercase;
}

.main-action {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  min-height: 60px;
  padding: 16px 25px;
  color: var(--color-forest);
  background: var(--color-sun);
  font-size: .91rem;
  font-weight: 800;
  text-decoration: none;
  transition: transform .2s ease;
}

.main-action:hover {
  transform: translateY(-2px);
}

.main-action span {
  font-size: 1.2rem;
}

.text-link {
  display: inline-block;
  color: #faf5e8;
  font-size: .83rem;
  font-weight: 800;
  text-underline-offset: 6px;
}

/* Filtros y cambio de vista */
.filters button {
  min-height: 44px;
  padding: 9px 17px;
  color: var(--color-forest);
  background: var(--color-paper);
  border: 1px solid var(--color-border);
  border-radius: 1px;
  font-size: .87rem;
  font-weight: 800;
}

.filters button:hover {
  border-color: var(--color-forest);
}

.filters button[aria-pressed="true"] {
  color: var(--color-cream);
  background: var(--color-forest);
  border-color: var(--color-forest);
}

.view-switcher {
  display: flex;
  align-items: center;
  gap: 7px;
}

.view-switcher button {
  display: grid;
  width: 42px;
  min-height: 42px;
  padding: 0;
  color: var(--color-muted);
  background: transparent;
  border: 1px solid var(--color-border);
  place-items: center;
}

.view-switcher button[aria-pressed="true"] {
  color: var(--color-cream);
  background: var(--color-forest);
  border-color: var(--color-forest);
}

.view-switcher button span {
  font-size: 1.05rem;
  line-height: 1;
}

/* Tarjetas del catálogo */
.product {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.product-photo {
  position: relative;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  background: #dfded2;
}

.product-photo > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .5s ease;
}

.product[data-category="yerbas"] .product-photo > img {
  object-fit: cover;
  object-position: center;
}

.product:hover .product-photo > img {
  transform: scale(1.035);
}

.product[data-category="yerbas"]:hover .product-photo > img {
  transform: none;
}

.photo-index {
  position: absolute;
  top: 13px;
  left: 13px;
  padding: 7px 8px;
  color: var(--color-forest);
  background: var(--color-cream);
  font-size: .61rem;
  letter-spacing: .08em;
}

.card-back-thumb {
  position: absolute;
  top: 52px;
  left: 13px;
  z-index: 1;
  width: 82px;
  height: 48px;
  padding: 3px;
  overflow: hidden;
  background: #fefbf2;
  border: 1px solid var(--color-forest);
  border-radius: 3px;
  box-shadow: 0 3px 8px #1426191a;
}

.card-back-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.card-back-thumb:hover, .card-back-thumb:focus-visible {
  border-width: 2px;
}

.product-desc {
  display: flex;
  flex: 1;
  align-items: stretch;
  flex-direction: column;
  gap: 14px;
  padding-top: 14px;
  margin-top: 2px;
  border-top: 2px solid var(--color-forest);
}

.product-desc > div:first-child {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
}

.product-type {
  color: var(--color-muted);
  font-size: .64rem;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.product-type span {
  padding-inline: 4px;
}

.product-desc h3 {
  margin: 9px 0 12px;
  font: bold clamp(1.38rem, 1.95vw, 1.78rem)/1.1 var(--font-serif);
  letter-spacing: -.045em;
}

.product-price {
  margin-top: auto;
  font-size: .96rem;
  font-weight: 800;
}

.product-price--pending {
  color: var(--color-muted);
  font-size: .72rem;
}

.product-actions {
  display: flex;
  align-items: stretch;
  flex: 0 0 auto;
  gap: 8px;
  margin-top: auto;
}

.product-detail {
  display: flex;
  min-width: 0;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  flex: 1 1 0;
  padding: 9px 11px;
  color: var(--color-forest);
  background: transparent;
  border: 1px solid var(--color-forest);
  font-size: .7rem;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.add-product {
  display: flex;
  min-width: 0;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  flex: 1 1 0;
  gap: 9px;
  padding: 11px 14px;
  color: var(--color-cream);
  background: var(--color-forest);
  font-size: .78rem;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.add-product span {
  font-size: 1.2rem;
  font-weight: 400;
}

/* Evitar el hover persistente tras tocar; el foco de teclado se define en base.css. */
@media (hover: hover) and (pointer: fine) {
  .product-detail:hover {
    color: var(--color-cream);
    background: var(--color-forest);
  }

  .add-product:hover {
    background: #526a48;
  }
}

.catalogue-error {
  grid-column: 1 / -1;
  padding: 2rem;
  border: 1px solid var(--color-border);
}

/* Bolsa de compra */
dialog {
  color: var(--color-ink);
  font-family: var(--font-sans);
}

.drawer {
  inset: 0 0 0 auto;
  width: min(465px, 100%);
  height: 100dvh;
  max-height: 100dvh;
  padding: 0;
  margin: 0 0 0 auto;
  background: var(--color-paper);
  border: 0;
  box-shadow: -18px 0 60px #0003;
}

.drawer::backdrop {
  background: rgba(9, 26, 17, .56);
}

.drawer-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 27px 22px;
  border-bottom: 1px solid var(--color-border);
}

.drawer-head h2 {
  margin-top: 8px;
  font: 400 2.5rem/1 var(--font-serif);
  letter-spacing: -.045em;
}

.close-dialog {
  min-width: 40px;
  min-height: 40px;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
}

.drawer-content {
  flex: 1;
  padding: 24px 27px;
  overflow-y: auto;
}

.cart-empty {
  color: var(--color-muted);
  font: italic 1.22rem/1.4 var(--font-serif);
}

.cart-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 15px;
  padding: 17px 0;
  border-bottom: 1px solid var(--color-border);
}

.cart-row:first-child {
  padding-top: 0;
}

.cart-row h3 {
  margin-bottom: 7px;
  font: 400 1.33rem var(--font-serif);
}

.cart-row small {
  color: var(--color-muted);
  font-size: .71rem;
}

.cart-row > strong {
  font-size: .83rem;
}

.qty {
  display: inline-flex;
  align-items: center;
  margin-top: 13px;
  border: 1px solid var(--color-border);
}

.qty button {
  min-width: 34px;
  min-height: 33px;
  background: transparent;
  border: 0;
  font-size: 1.16rem;
}

.quantity-input {
  width: 60px;
  min-width: 0;
  min-height: 40px;
  padding: 6px 4px;
  border: 1px solid var(--color-border);
  border-radius: 0;
  color: var(--color-ink);
  background: var(--color-paper);
  font: inherit;
  text-align: center;
}

.quantity-input:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

.product-quantity {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .78rem;
}

.qty .quantity-input {
  width: 60px;
  min-height: 33px;
  border-width: 0 1px;
  font-size: .85rem;
}

.remove-line {
  margin-left: 10px;
  padding: 6px 3px;
  color: var(--color-muted);
  background: none;
  border: 0;
  font-size: .7rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.drawer-foot {
  padding: 21px 27px 26px;
  background: var(--color-cream);
  border-top: 1px solid var(--color-border);
}

.totals {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: .83rem;
}

.totals strong {
  font: 400 2rem var(--font-serif);
}

.pricing-note {
  min-height: 0;
  margin-top: 7px;
  color: var(--color-muted);
  font-size: .7rem;
  line-height: 1.45;
}

.disclaimer {
  margin: 12px 0 17px;
  color: var(--color-muted);
  font-size: .7rem;
  line-height: 1.5;
}

.checkout {
  display: block;
  width: 100%;
  min-height: 51px;
  padding: 15px;
  color: #fff;
  background: var(--color-forest);
  border: 1px solid var(--color-forest);
  font-size: .82rem;
  font-weight: 800;
}

/* Detalle de producto */
.product-dialog {
  width: min(1020px, calc(100% - 40px));
  max-height: min(90dvh, 820px);
  padding: 0;
  overflow: auto;
  color: var(--color-ink);
  background: var(--color-paper);
  border: 0;
  box-shadow: 0 24px 80px #0005;
}

.product-dialog::backdrop, .image-lightbox::backdrop {
  background: rgba(9, 26, 17, .78);
}

.product-dialog-inner {
  position: relative;
  padding: 34px;
}

.dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  display: grid;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--color-forest);
  background: var(--color-cream);
  border: 1px solid var(--color-forest);
  font-size: 1.6rem;
  place-items: center;
}

.product-dialog-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(280px, .88fr);
  gap: 38px;
  align-items: start;
}

.detail-gallery {
  min-width: 0;
}

.detail-main-button {
  display: block;
  width: 100%;
  padding: 0;
  background: #fefbf2;
  border: 1px solid var(--color-border);
  cursor: zoom-in;
}

.detail-main-image {
  display: block;
  width: 100%;
  height: min(62vh, 590px);
  object-fit: contain;
}

.detail-thumbnails {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.detail-thumbnails button {
  position: relative;
  width: 88px;
  min-height: 72px;
  padding: 4px;
  background: #fefbf2;
  border: 1px solid var(--color-border);
}

.detail-thumbnails button[aria-pressed="true"] {
  border: 3px solid var(--color-forest);
}

.detail-thumbnails button[aria-pressed="true"]::after {
  position: absolute;
  right: 3px;
  bottom: 3px;
  display: grid;
  width: 20px;
  height: 20px;
  color: var(--color-cream);
  background: var(--color-forest);
  border-radius: 50%;
  content: "✓";
  font-size: .7rem;
  place-items: center;
}

.detail-thumbnails img {
  display: block;
  width: 100%;
  height: 62px;
  object-fit: contain;
}

.detail-copy {
  padding-top: 55px;
}

.detail-copy h2 {
  margin: 10px 0 20px;
  font: 700 clamp(2.2rem, 4vw, 4.2rem)/.96 var(--font-serif);
  letter-spacing: -.055em;
}

.detail-section {
  padding: 18px 0;
  border-top: 1px solid var(--color-border);
}

.detail-section h3 {
  margin-bottom: 8px;
  font-size: .72rem;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.detail-section p {
  color: var(--color-muted);
  font-size: .88rem;
  line-height: 1.65;
}

.detail-properties {
  margin-top: 18px;
}

.detail-properties ul {
  display: grid;
  gap: 7px;
  padding-left: 1.15rem;
  color: var(--color-muted);
  font-size: .88rem;
  line-height: 1.5;
}

.detail-price {
  margin-top: 24px;
}

.detail-add {
  margin-top: 18px;
}

/* Variantes del detalle de Yuyos */
.product-dialog--yuyos [data-detail-meta] {
  display: inline-block;
  padding: 7px 14px;
  background: var(--color-cream);
  border-radius: 999px;
}

.product-dialog--yuyos .detail-main-button {
  overflow: hidden;
}

/* Ampliar solo el fondo libre de las fotos originales; conservar el envase completo. */
.product-dialog--yuyos .detail-main-image {
  height: min(68vh, 620px);
  transform: scale(1.4);
}

.product-dialog--yuyos .detail-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 12px;
  margin-top: 24px;
}

.product-dialog--yuyos .detail-quantity:not([hidden]) {
  display: flex;
  align-items: center;
  border: 1px solid var(--color-border);
}

.product-dialog--yuyos .detail-quantity button {
  width: 44px;
  min-height: 48px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-forest);
  font-size: 1.2rem;
}

.product-dialog--yuyos .detail-quantity button:disabled {
  opacity: .45;
  cursor: default;
}

.product-dialog--yuyos .detail-quantity .quantity-input {
  width: 60px;
  min-height: 48px;
  border-width: 0 1px;
  font-weight: 700;
}

.product-dialog--yuyos .detail-add {
  flex: 1;
  min-width: min(210px, 100%);
  margin-top: 0;
  padding: 14px 18px;
  justify-content: center;
}

/* Imagen ampliada */
.image-lightbox {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  padding: 24px;
  overflow: hidden;
  background: #111a14;
  border: 0;
}

.image-lightbox[open] {
  display: grid;
  place-items: center;
}

.image-lightbox img {
  display: block;
  width: auto;
  max-width: 90vw;
  height: auto;
  max-height: 85vh;
  object-fit: contain;
}

.image-lightbox .dialog-close {
  color: var(--color-cream);
  background: var(--color-forest);
  border-color: var(--color-cream);
}

.image-lightbox--compact {
  width: min(510px, 90vw);
  max-width: none;
  height: max-content;
  min-height: 0;
  max-height: 78vh;
  padding: 0;
  overflow: visible;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.image-lightbox--compact[open] {
  display: block;
}

.image-lightbox--compact::backdrop {
  background: rgba(9, 26, 17, .36);
}

.image-lightbox--compact .dialog-close {
  top: -17px;
  right: -17px;
  width: 42px;
  height: 42px;
  color: var(--color-forest);
  background: var(--color-cream);
  border: 1px solid rgba(36, 61, 44, .42);
  border-radius: 50%;
  box-shadow: 0 4px 14px rgba(9, 26, 17, .16);
  font-size: 1.35rem;
}

.image-lightbox--compact .dialog-close:focus-visible {
  outline: 3px solid var(--color-sun);
  outline-offset: 3px;
}

.image-lightbox--compact img {
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: 75vh;
  object-fit: contain;
  filter: drop-shadow(0 16px 28px rgba(9, 26, 17, .2));
}

.floating-bag {
  display: none;
}

/* Acceso flotante a WhatsApp */
.whatsapp-contact {
  position: fixed;
  right: 24px;
  bottom: calc(24px + env(safe-area-inset-bottom));
  z-index: 91;
  width: 56px;
  height: 56px;
  place-items: center;
  color: var(--color-cream);
  background: var(--color-green);
  border-radius: 50%;
  box-shadow: 0 4px 14px #0002;
}

.whatsapp-contact:not([hidden]) {
  display: grid;
}

.whatsapp-contact:hover {
  background: var(--color-pine);
}

.whatsapp-contact:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 4px;
}

/* Responsive: estos ajustes se aplican hasta 820 px, incluidos. */
@media (max-width: 820px) {
  .menu-toggle {
    display: inline-grid;
    place-items: center;
  }

  .bag-button {
    min-width: 122px;
    min-height: 44px;
    padding-inline: 13px;
    font-size: .82rem;
  }

}

/* Responsive: estos ajustes se aplican hasta 720 px, incluidos. */
@media (max-width: 720px) {
  .product-dialog--yuyos .detail-main-image {
    height: min(43vh, 420px);
  }

  .product-dialog--yuyos .detail-actions {
    gap: 10px;
  }

  .filters button {
    min-height: 40px;
    padding: 8px 11px;
    font-size: .76rem;
  }

  .product-desc {
    padding-top: 13px;
  }

  .product-actions {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }

  .product-detail, .add-product {
    width: auto;
    padding-inline: 7px;
  }

  /* El texto más largo puede ocupar dos líneas; apilar solo si ambos no caben. */
  .product-detail {
    min-width: min-content;
    white-space: normal;
  }

  .product-actions > .add-product {
    min-width: max-content;
  }

  .add-product {
    gap: 5px;
  }

  .card-back-thumb {
    width: 58px;
    height: 38px;
    padding: 2px;
  }

  .drawer-head {
    padding: 22px 18px;
  }

  .drawer-content {
    padding: 20px 18px;
  }

  .drawer-foot {
    padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  }

  .product-dialog {
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
  }

  .product-dialog-inner {
    min-height: 100%;
    padding: 68px 18px 28px;
  }

  .product-dialog-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
  }

  .detail-main-image {
    height: min(43vh, 420px);
  }

  .detail-copy {
    padding-top: 0;
  }

  .detail-copy h2 {
    font-size: clamp(2.35rem, 11vw, 3.4rem);
  }

  .detail-thumbnails button {
    width: 82px;
    min-height: 70px;
  }

  .image-lightbox {
    padding: 68px 12px 18px;
  }

  .image-lightbox--compact {
    width: 88vw;
    height: max-content;
    max-height: 72vh;
    padding: 0;
  }

  .image-lightbox--compact .dialog-close {
    top: -14px;
    right: -10px;
  }

  .image-lightbox--compact img {
    max-height: 70vh;
  }

  .floating-bag.is-visible {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 90;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 15px 18px calc(15px + env(safe-area-inset-bottom));
    color: var(--color-cream);
    background: var(--color-forest);
    border: 0;
    box-shadow: 0 -9px 25px #0002;
    font-size: .85rem;
    font-weight: 800;
  }

  .whatsapp-contact {
    right: 18px;
    bottom: calc(18px + env(safe-area-inset-bottom));
  }

  .floating-bag.is-visible ~ .whatsapp-contact {
    bottom: calc(88px + env(safe-area-inset-bottom));
  }

}

/* Responsive: estos ajustes se aplican hasta 520 px, incluidos. */
@media (max-width: 520px) {
  .brand {
    gap: 8px;
  }

  .brand img {
    width: 48px;
    height: 48px;
  }

  .brand-word {
    font-size: 1.02rem;
  }

  .bag-button {
    min-width: auto;
    min-height: 46px;
    gap: 8px;
    padding: 0 11px;
    font-size: .78rem;
  }

  .bag-button span {
    width: 24px;
    height: 24px;
    font-size: .7rem;
  }

  .menu-toggle {
    min-width: 46px;
    width: 46px;
    min-height: 46px;
  }

}

/* Responsive: estos ajustes se aplican hasta 370 px, incluidos. */
@media (max-width: 370px) {
  .site-header .shell {
    gap: 5px;
  }

  .brand {
    gap: 5px;
  }

  .brand-word {
    font-size: .92rem;
  }

  .nav-right {
    gap: 6px;
  }

  .bag-button {
    gap: 6px;
    padding-inline: 8px;
    font-size: .72rem;
  }

}
