/*
 * Albero Group V886.2 — compact touch cart and checkout.
 * Restaurant tokens, server MiniShop3 data, existing DOM, forms, and JS stay authoritative.
 * Mobile/tablet only; desktop >= 992px remains unchanged.
 */
@media (max-width: 991.98px) {
  body.page-cart-full,
  body.page-checkout {
    --ag-v886-dock-height: 79px;
    scroll-padding-bottom: calc(var(--ag-v886-dock-height) + env(safe-area-inset-bottom, 0px));
  }

  body.page-cart-full .cart-page-hero,
  body.page-checkout .checkout-page-hero {
    min-height: 0 !important;
    padding-top: 22px !important;
    padding-bottom: 20px !important;
  }
  body.page-cart-full .cart-page-hero h1,
  body.page-checkout .checkout-page-hero h1 {
    font-size: clamp(26px, 4.8vw, 32px) !important;
    line-height: 1.16 !important;
    margin: 0 0 7px !important;
  }
  body.page-cart-full .cart-delivery-conditions {
    flex-direction: row !important;
    justify-content: center;
    align-items: center;
    gap: 4px 12px !important;
    margin-top: 0 !important;
    font-size: 12px !important;
    line-height: 1.4;
  }
  body.page-cart-full .cart-delivery-conditions a {
    font-weight: 700;
    text-underline-offset: 2px;
  }
  body.page-cart-full .section-space,
  body.page-checkout .section-space {
    padding-top: 20px !important;
    padding-bottom: calc(115px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Reference 2: image | name + weight + server price | quantity on the right. */
  body.page-cart-full .cart-items-card {
    padding: 8px 13px !important;
    border-radius: 19px !important;
  }
  body.page-cart-full .cart-items-card .am-cart-product,
  body.page-cart-full .cart-items-card .am-cart-product.am-cart-product--gift {
    display: grid !important;
    position: relative;
    grid-template-columns: 76px minmax(0, 1fr) 108px !important;
    grid-template-rows: minmax(76px, auto) !important;
    align-items: center;
    column-gap: 11px !important;
    row-gap: 0 !important;
    min-height: 105px !important;
    padding: 13px 0 !important;
    margin: 0 !important;
    border-bottom: 1px solid var(--color-border, #e9ecef);
  }
  body.page-cart-full .cart-items-card .am-cart-product:last-child {
    border-bottom: 0 !important;
  }
  body.page-cart-full .cart-items-card .am-cart-product .am-cart-product__media.ag-media--cart-line {
    grid-column: 1 !important;
    grid-row: 1 !important;
    align-self: center;
    justify-self: start;
    width: 76px !important;
    height: 76px !important;
    min-width: 76px !important;
    min-height: 76px !important;
    max-width: 76px !important;
    max-height: 76px !important;
    aspect-ratio: 1 !important;
    border-radius: 12px !important;
    overflow: hidden;
  }
  body.page-cart-full .cart-items-card .am-cart-product .am-cart-product__media.ag-media--cart-line img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
  }
  body.page-cart-full .cart-items-card .am-cart-product .am-cart-product__content {
    grid-column: 2 !important;
    grid-row: 1 !important;
    align-self: center;
    justify-self: stretch;
    min-width: 0;
    width: auto !important;
    padding: 0 0 20px !important;
  }
  body.page-cart-full .cart-items-card .am-cart-product .am-cart-product__content h3 {
    margin: 0 0 5px !important;
    font-size: 13px !important;
    font-weight: 750;
    line-height: 1.29 !important;
    letter-spacing: 0;
    overflow-wrap: anywhere;
  }
  body.page-cart-full .cart-items-card .am-cart-product .am-cart-product__content p {
    margin: 0 0 2px !important;
    font-size: 11.5px !important;
    line-height: 1.3;
    color: var(--color-muted, #79838b);
    overflow-wrap: anywhere;
  }
  body.page-cart-full .cart-items-card .am-cart-product .am-cart-product__price {
    grid-column: 2 !important;
    grid-row: 1 !important;
    justify-self: start !important;
    align-self: end !important;
    margin: 0 !important;
    padding: 0 !important;
    color: var(--color-accent, #31999c);
    font-size: 13px !important;
    line-height: 1.25 !important;
    font-weight: 800;
    white-space: nowrap;
    z-index: 1;
  }
  body.page-cart-full .cart-items-card .am-cart-product .am-qty {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-34%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 104px;
    height: 36px;
    margin: 0;
    padding: 0 3px;
    border: 0;
    border-radius: 11px;
    background: #f2f4f4;
    box-shadow: none;
    z-index: 1;
  }
  body.page-cart-full .cart-items-card .am-cart-product .am-qty button {
    flex: 0 0 31px;
    width: 31px;
    height: 36px;
    border: 0;
    border-radius: 9px;
    color: var(--color-text, #202936);
    background: transparent;
    font-size: 20px;
    font-weight: 600;
    line-height: 1;
  }
  body.page-cart-full .cart-items-card .am-cart-product .am-qty button:disabled {
    opacity: .3;
  }
  body.page-cart-full .cart-items-card .am-cart-product .am-qty span {
    min-width: 22px;
    text-align: center;
    font-size: 13px;
    font-weight: 750;
    color: var(--color-text, #202936);
  }
  body.page-cart-full .cart-items-card .am-cart-product .am-cart-product__remove-form {
    position: absolute;
    top: 5px;
    right: 0;
    margin: 0;
    z-index: 2;
  }
  body.page-cart-full .cart-items-card .am-cart-product .am-remove {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 30px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #819098;
    font-size: 17px;
    line-height: 1;
  }
  body.page-cart-full .cart-items-card .am-cart-product .am-remove:focus-visible {
    outline: 2px solid var(--color-accent, #31999c);
    outline-offset: 2px;
  }
  body.page-cart-full .cart-items-card .am-cart-product.am-cart-product--gift .am-cart-product__content {
    padding-bottom: 0 !important;
  }
  body.page-cart-full .cart-items-card .am-cart-product.am-cart-product--gift .am-cart-product__price {
    grid-column: 3 !important;
    grid-row: 1 !important;
    align-self: center !important;
    justify-self: end !important;
    color: #357b5a;
    font-size: 12px !important;
  }
  body.page-cart-full .cart-items-card .am-cart-product--gift .albero-gift-quantity {
    margin-top: 3px !important;
    padding: 4px 7px !important;
    font-size: 11px !important;
  }

  /* Compact recommended dishes, original Swiper and native add forms unchanged. */
  body.page-cart-full .cart-upsell {
    min-width: 0;
    margin-top: 20px !important;
    margin-bottom: 16px !important;
  }
  body.page-cart-full .cart-upsell__heading {
    align-items: center;
    flex-wrap: nowrap;
    gap: 10px;
    margin-bottom: 10px !important;
  }
  body.page-cart-full #cart-upsell-title {
    margin: 0 !important;
    font-size: 19px !important;
    line-height: 1.25 !important;
    white-space: nowrap;
  }
  body.page-cart-full .cart-upsell__heading a {
    font-size: 12px;
    white-space: nowrap;
  }
  body.page-cart-full .cart-upsell--swiper .cart-upsell-card {
    display: flex !important;
    flex-direction: row !important;
    min-width: 0;
    height: auto !important;
    min-height: 105px;
    border-radius: 17px;
    overflow: hidden;
  }
  body.page-cart-full .cart-upsell--swiper .cart-upsell-card .cart-upsell-card__media {
    position: relative;
    flex: 0 0 94px !important;
    width: 94px !important;
    height: auto !important;
    min-height: 105px !important;
    aspect-ratio: auto !important;
    border-radius: 12px 0 0 12px !important;
    overflow: hidden;
  }
  body.page-cart-full .cart-upsell--swiper .cart-upsell-card .cart-upsell-card__media img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
  }
  body.page-cart-full .cart-upsell--swiper .cart-upsell-card .cart-upsell-card__body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
    padding: 11px 12px !important;
  }
  body.page-cart-full .cart-upsell--swiper .cart-upsell-card h3 {
    min-height: 0 !important;
    margin: 0 0 7px !important;
    font-size: 13px !important;
    line-height: 1.28;
    font-weight: 700;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  body.page-cart-full .cart-upsell--swiper .cart-upsell-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
  }
  body.page-cart-full .cart-upsell--swiper .cart-upsell-card__footer strong {
    font-size: 13px !important;
    white-space: nowrap;
  }
  body.page-cart-full .cart-upsell--swiper .cart-upsell-card__add {
    justify-content: center;
    width: 35px !important;
    min-width: 35px !important;
    height: 35px !important;
    padding: 2px !important;
    border: 1px solid var(--color-accent, #31999c);
    border-radius: 11px;
    background: var(--color-accent-soft, #eaf6f5);
  }
  body.page-cart-full .cart-upsell--swiper .cart-upsell-card__add-label {
    display: none !important;
  }
  body.page-cart-full .cart-upsell--swiper .cart-upsell-card__add-icon {
    display: inline-grid;
    place-items: center;
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    border-radius: 9px;
    font-size: 20px;
  }
  body.page-cart-full .cart-upsell__arrow {
    width: 37px;
    height: 37px;
  }

  /* Make the existing checkout controls and fields easier to scan on touch. */
  body.page-checkout .am-checkout-card {
    border-radius: 19px !important;
    padding: 17px !important;
  }
  body.page-checkout .checkout-delivery-methods {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 8px;
  }
  body.page-checkout .am-checkout-card > h2 {
    margin-bottom: 13px !important;
    font-size: 20px !important;
  }
  body.page-checkout .am-checkout-card .form-control {
    min-height: 45px;
    border-radius: 12px;
    font-size: 16px;
  }
  body.page-checkout .checkout-review-item-v302 {
    grid-template-columns: 72px minmax(0, 1fr) auto !important;
    gap: 10px;
    padding: 11px 0;
  }
  body.page-checkout .checkout-review-item-v302__media {
    width: 72px !important;
    min-width: 72px !important;
    height: 54px !important;
  }
  body.page-checkout .checkout-review-item-v302__title {
    font-size: 13px;
  }

  /*
   * Sticky bottom bar reuses existing server-rendered total and the original
   * MiniShop3 checkout link / order submit button. No cloned submit or totals.
   */
  body.page-cart-full .cart-summary-card::before,
  body.page-checkout .checkout-summary-card::before {
    content: "";
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(var(--ag-v886-dock-height) + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--color-border, #e9ecef);
    background: rgba(255,255,255,.975);
    box-shadow: 0 -8px 22px rgba(27,36,45,.07);
    z-index: 1010;
    pointer-events: none;
  }
  body.page-cart-full .cart-summary-card > .am-summary-total,
  body.page-checkout .checkout-summary-card > .am-summary-total {
    position: fixed;
    left: max(14px, calc((100vw - 760px) / 2));
    bottom: calc(17px + env(safe-area-inset-bottom, 0px));
    z-index: 1012;
    display: flex !important;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    width: 36vw;
    max-width: 220px;
    min-width: 100px;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent;
    box-shadow: none !important;
  }
  body.page-cart-full .cart-summary-card > .am-summary-total > span,
  body.page-checkout .checkout-summary-card > .am-summary-total > span {
    font-size: 11px;
    font-weight: 500;
    line-height: 1.15;
    color: var(--color-muted, #79838b);
  }
  body.page-cart-full .cart-summary-card > .am-summary-total > strong,
  body.page-checkout .checkout-summary-card > .am-summary-total > strong {
    font-size: 20px;
    font-weight: 800;
    line-height: 1.18;
    white-space: nowrap;
    color: var(--color-text, #202936);
  }
  body.page-cart-full .cart-summary-card > a.am-btn-primary,
  body.page-checkout .checkout-summary-card > button[type="submit"] {
    position: fixed;
    right: max(14px, calc((100vw - 760px) / 2));
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 1013;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: clamp(163px, 50vw, 330px) !important;
    min-height: 49px;
    height: 49px;
    margin: 0 !important;
    padding: 9px 12px !important;
    border-radius: 13px !important;
    font-size: 13px !important;
    font-weight: 800;
    line-height: 1.2;
    white-space: nowrap;
    box-shadow: none !important;
  }
  body.page-checkout .checkout-summary-card > button[type="submit"]:disabled {
    cursor: not-allowed;
    opacity: .55;
  }

  /* iOS keyboard: fixed controls must not cover an active text input. */
  body.page-checkout:has(input:not([type="radio"]):not([type="checkbox"]):focus) .checkout-summary-card::before,
  body.page-checkout:has(input:not([type="radio"]):not([type="checkbox"]):focus) .checkout-summary-card > .am-summary-total,
  body.page-checkout:has(input:not([type="radio"]):not([type="checkbox"]):focus) .checkout-summary-card > button[type="submit"],
  body.page-checkout:has(textarea:focus) .checkout-summary-card::before,
  body.page-checkout:has(textarea:focus) .checkout-summary-card > .am-summary-total,
  body.page-checkout:has(textarea:focus) .checkout-summary-card > button[type="submit"],
  body.page-cart-full:has(.cart-promo-v302__input:focus) .cart-summary-card::before,
  body.page-cart-full:has(.cart-promo-v302__input:focus) .cart-summary-card > .am-summary-total,
  body.page-cart-full:has(.cart-promo-v302__input:focus) .cart-summary-card > a.am-btn-primary {
    visibility: hidden;
    pointer-events: none;
  }
}

@media (max-width: 379.98px) {
  body.page-cart-full .cart-items-card {
    padding-inline: 10px !important;
  }
  body.page-cart-full .cart-items-card .am-cart-product,
  body.page-cart-full .cart-items-card .am-cart-product.am-cart-product--gift {
    grid-template-columns: 64px minmax(0, 1fr) 99px !important;
    column-gap: 8px !important;
    min-height: 96px !important;
  }
  body.page-cart-full .cart-items-card .am-cart-product .am-cart-product__media.ag-media--cart-line {
    width: 64px !important;
    height: 64px !important;
    min-width: 64px !important;
    min-height: 64px !important;
    max-width: 64px !important;
    max-height: 64px !important;
  }
  body.page-cart-full .cart-items-card .am-cart-product .am-qty {
    min-width: 96px;
  }
  body.page-cart-full .cart-items-card .am-cart-product .am-qty button {
    flex-basis: 29px;
    width: 29px;
  }
}

@media (min-width: 600px) and (max-width: 991.98px) {
  body.page-cart-full .cart-items-card .am-cart-product,
  body.page-cart-full .cart-items-card .am-cart-product.am-cart-product--gift {
    grid-template-columns: 80px minmax(0, 1fr) 122px !important;
  }
  body.page-cart-full .cart-items-card .am-cart-product .am-cart-product__media.ag-media--cart-line {
    width: 80px !important;
    height: 80px !important;
    min-width: 80px !important;
    min-height: 80px !important;
    max-width: 80px !important;
    max-height: 80px !important;
  }
  body.page-cart-full .cart-items-card .am-cart-product .am-cart-product__content h3 {
    font-size: 15px !important;
  }
  body.page-cart-full .cart-items-card .am-cart-product .am-cart-product__price {
    font-size: 15px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.page-cart-full .am-cart-product,
  body.page-checkout .am-checkout-card {
    scroll-behavior: auto;
    transition-duration: 0s;
  }
}
