/**
 * Café Ganoderma — responsive móvil (iOS / Android / tablets)
 * Se carga al final del <head> para sobreescribir landing, tienda y admin.
 */

/* ——— Base: sin scroll horizontal, notch safe-area ——— */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  max-width: 100%;
  overflow-x: clip;
}

body {
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}

img,
video,
iframe,
svg,
embed,
object {
  max-width: 100%;
  height: auto;
}

iframe {
  max-width: 100%;
}

/* Evita zoom automático en iOS al enfocar inputs */
@media (max-width: 900px) {
  input,
  select,
  textarea {
    font-size: 16px !important;
  }

  button,
  .btn,
  .admin-btn,
  .shop-cat,
  .nav-toggle,
  a.btn {
    min-height: 44px;
    touch-action: manipulation;
  }
}

/* ——— Header / nav ——— */
@media (max-width: 900px) {
  .topbar {
    font-size: 0.62rem;
    letter-spacing: 0.1em;
    padding: 0.5rem 0.75rem;
    line-height: 1.35;
    word-break: break-word;
  }

  .nav {
    padding: 0.7rem 0.85rem;
    gap: 0.5rem;
  }

  .logo {
    font-size: 1.05rem;
    min-width: 0;
    flex: 1;
  }

  .logo img,
  .logo-img,
  .brand-logo-img {
    height: 32px;
    max-width: 120px;
  }

  .logo-text {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: min(42vw, 11rem);
  }

  .nav-toggle {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    font-size: 1.5rem;
  }

  .nav-links {
    max-height: min(70vh, 520px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 60;
  }
}

@media (max-width: 380px) {
  .logo-text {
    display: none;
  }
}

/* ——— Landing hero ——— */
@media (max-width: 900px) {
  .landing-hero {
    min-height: min(72vh, 560px);
    min-height: min(72dvh, 560px);
  }

  .landing-hero__brand {
    font-size: clamp(1.85rem, 9.5vw, 3.2rem);
    letter-spacing: 0.08em;
    word-break: break-word;
    padding: 0 0.25rem;
  }

  .landing-hero__title {
    font-size: clamp(0.92rem, 3.8vw, 1.1rem);
    max-width: 22rem;
    margin-bottom: 1.15rem;
    padding: 0 0.35rem;
  }

  .landing-hero__copy {
    padding: 1.25rem 1rem calc(1.5rem + env(safe-area-inset-bottom, 0));
    width: 100%;
    max-width: 100%;
  }

  
  .landing-hero__logo {
    margin-bottom: 0.85rem;
  }

  .landing-hero__logo img {
    width: clamp(112px, 34vw, 168px);
    height: clamp(112px, 34vw, 168px);
  }
.landing-hero__ctas {
    width: 100%;
    max-width: 22rem;
    margin: 0 auto;
    flex-direction: column;
    align-items: stretch;
  }

  .landing-hero__ctas .btn {
    width: 100%;
    padding: 0.95rem 1.1rem;
  }
}

@media (max-width: 480px) {
  .landing-hero {
    min-height: min(68vh, 520px);
    min-height: min(68dvh, 520px);
  }
}

/* ——— Secciones landing ——— */
@media (max-width: 900px) {
  .landing-section {
    padding: 2.75rem 1rem;
  }

  .landing-section-title {
    font-size: clamp(1.55rem, 6.5vw, 2.35rem);
    letter-spacing: 0.06em;
  }

  .landing-section-lead {
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    padding: 0 0.15rem;
  }

  .landing-facts__grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .landing-products__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
  }

  .landing-product__visual {
    padding: 0.45rem;
  }

  .landing-product h3 {
    font-size: 1.05rem;
    min-height: 2.4em;
  }

  .landing-product__body {
    padding: 0.75rem 0.7rem 0.85rem;
  }

  .landing-product__add .btn,
  .product-card__view {
    font-size: 0.65rem;
    letter-spacing: 0.08em;
    padding: 0.7rem 0.5rem;
  }

  .packages {
    grid-template-columns: 1fr;
    gap: 0.9rem;
  }

  .package {
    padding: 1.35rem 1.1rem;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
  }

  .map-wrap {
    aspect-ratio: 4 / 3;
    min-height: 240px;
    border-radius: 0;
  }

  .map-wrap iframe {
    min-height: 240px;
  }

  .site-footer__inner {
    grid-template-columns: 1fr;
    padding: 2.25rem 1rem 1.5rem;
    gap: 1.5rem;
  }
}

@media (max-width: 560px) {
  .landing-products__grid,
  .shop-page .landing-products__grid,
  .shop-main .landing-products__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.5rem;
  }

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

  .landing-facts__grid article {
    padding: 1.15rem 1rem;
  }
}

/* Visores / modales */
@media (max-width: 800px) {
  .product-viewer,
  .cg-gallery-viewer {
    padding: 0.5rem;
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  }

  .product-viewer__dialog {
    max-height: min(94dvh, 94vh);
    width: 100%;
  }

  .product-viewer__media img {
    height: min(36vh, 240px);
  }

  .modal-card,
  .membership-modal,
  [class*="modal__"] {
    max-width: 100%;
  }

  .cg-gallery-viewer__stage {
    width: min(96vw, 100%);
    height: min(52vh, 52dvh);
  }
}

/* ——— Tienda / carrito / checkout ——— */
@media (max-width: 900px) {
  .shop {
    padding: 0.85rem 0.85rem 2rem;
  }

  .shop-header {
    grid-template-columns: 1fr;
    justify-items: stretch;
    gap: 0.65rem;
  }

  .shop-utils {
    justify-self: stretch;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .shop-utils__cta,
  .shop-utils__link,
  .shop-utils__cart {
    flex: 1 1 auto;
    justify-content: center;
    text-align: center;
  }

  .shop-search,
  .shop-search--wide {
    max-width: 100%;
  }

  .shop-cats {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0.4rem;
    padding-bottom: 0.35rem;
    margin-left: -0.15rem;
    margin-right: -0.15rem;
    padding-left: 0.15rem;
    padding-right: 0.15rem;
    scrollbar-width: thin;
  }

  .shop-cat {
    flex: 0 0 auto;
    white-space: nowrap;
  }

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

  .checkout-form fieldset {
    padding: 0.85rem;
  }

  .checkout-submit,
  .cart-actions .btn {
    width: 100%;
  }

  .cart-total {
    margin-left: 0;
    width: 100%;
    justify-content: space-between;
  }

  .cart-table-wrap,
  .admin-table-wrap {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .cart-table {
    min-width: 520px;
  }

  .order-track__lookup {
    max-width: 100%;
  }

  .order-track__actions .btn {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .shop-page .landing-products__grid,
  .shop-main .landing-products__grid,
  .shop-page .landing-products__grid,
  .shop-main .landing-products__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.5rem;
  }
}

/* Carrito drawer */
@media (max-width: 900px) {
  .cart-drawer__panel {
    width: 100%;
    max-width: 100%;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .cart-drawer__line {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .cart-drawer__checkout {
    width: 100%;
    min-height: 48px;
  }
}

/* WhatsApp: no tapa CTAs inferiores; leyenda visible */
@media (max-width: 900px) {
  .wa-float {
    right: max(0.75rem, env(safe-area-inset-right));
    bottom: max(0.85rem, calc(0.65rem + env(safe-area-inset-bottom)));
    min-width: 0;
    height: auto;
    padding-right: 0;
    gap: 0.4rem;
  }

  .wa-float__icon {
    width: 52px;
    height: 52px;
  }

  .wa-float__chip {
    display: inline-block !important;
    max-width: min(160px, 46vw);
    font-size: 0.7rem;
    padding: 0.45rem 0.7rem;
  }

  .cg-cart-toast {
    bottom: max(4.5rem, calc(4rem + env(safe-area-inset-bottom)));
    left: 50%;
    width: calc(100% - 1.5rem);
    max-width: 360px;
  }
}

/* ——— Admin (móvil usable) ——— */
@media (max-width: 900px) {
  .admin-shell,
  .admin-layout {
    overflow-x: clip;
  }

  .admin-panel {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }

  .admin-table {
    min-width: 640px;
  }

  .inv-form--row,
  .cat-filters {
    grid-template-columns: 1fr !important;
  }

  .inv-branch-form select {
    min-width: 0;
    width: 100%;
  }
}

/* Landscape phones */
@media (max-height: 430px) and (orientation: landscape) {
  .landing-hero {
    min-height: auto;
    padding: 2.5rem 0;
  }

  .landing-hero__brand {
    font-size: clamp(1.5rem, 6vw, 2.2rem);
  }
}

/* === Productos móvil: 4 a la vista (2 columnas) === */
@media (max-width: 900px) {
  .landing-products__grid,
  .shop-page .landing-products__grid,
  .shop-main .landing-products__grid,
  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.55rem !important;
  }

  .landing-product h3 {
    font-size: 0.92rem !important;
    line-height: 1.2 !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.3em !important;
  }

  .landing-product__visual {
    padding: 0.4rem !important;
    aspect-ratio: 1 !important;
  }

  .landing-product__visual img {
    object-fit: contain !important;
    object-position: center !important;
  }

  .landing-product__body {
    padding: 0.55rem 0.5rem 0.65rem !important;
    gap: 0.2rem !important;
  }

  .landing-product p {
    font-size: 0.58rem !important;
    letter-spacing: 0.06em !important;
  }

  .landing-product strong {
    font-size: 0.88rem !important;
  }

  .landing-product__add .btn,
  .product-card__view {
    font-size: 0.58rem !important;
    letter-spacing: 0.06em !important;
    padding: 0.55rem 0.35rem !important;
  }

  .landing-product__desc,
  .landing-product__unit {
    display: none !important;
  }
}

@media (max-width: 560px) {
  .landing-products__grid,
  .shop-page .landing-products__grid,
  .shop-main .landing-products__grid,
  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.5rem !important;
  }
}
