/**
 * Mobile-only styles for cart.html
 * ONLY applies to screens <= 768px
 * Does NOT affect desktop version
 */

@media (max-width: 768px) {
  /* Prevent horizontal scroll */
  html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
  }

  * {
    -webkit-tap-highlight-color: transparent;
    max-width: 100%;
  }

  svg, img, [data-cy="cart-badge"], .ui-absolute,
  [data-cy="price-line-item"], [data-cy="price-subscription-lineItem"],
  [data-cy="product-detail-price"], [data-cy="product-detail-discount-price"],
  [data-cy="product-detail-regular-price"],
  [data-cy="cart-reassurance-item"],
  [data-cy="cart-reassurance-item"] * {
    max-width: none;
  }

  /* Grid container */
  .gridContainerV3 {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  /* Header */
  header[data-cy="header"] {
    padding: 0.5rem 1rem !important;
    margin-top: 0.5rem !important;
  }

  header a[aria-label*="Oura"] {
    width: 3.5rem !important;
  }

  [data-cy="nav-cart-button"] {
    width: 2.5rem !important;
    height: 2.5rem !important;
  }

  /* Main content */
  .pt-24 {
    padding-top: 4rem !important;
  }

  /* Title */
  h1[data-cy="cart-title"] {
    font-size: 1.5rem !important;
  }

  /* Back link - fix touch target and ensure clickability on mobile */
  a[data-cy="link-continue-shopping"] {
    font-size: 0.875rem !important;
    display: inline-flex !important;
    align-items: center !important;
    min-height: 44px !important;
    padding: 0.5rem 0 !important;
    pointer-events: auto !important;
    position: relative !important;
    z-index: 10 !important;
    max-width: none !important;
  }

  /* Reassurance - match gift checkbox */
  [data-cy="cart-reassurance"] {
    padding: 1rem !important;
    max-width: 100%;
    width: 100% !important;
    box-sizing: border-box !important;
    height: 3.5rem !important; /* to match the gift checkbox height */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important; /* Center the rotating content to match if needed, but flex-start looks more like the top block. Let's use center since it's an animated reassurance text */
  }

  [data-cy="cart-reassurance-items"] {
    display: flex !important;
    position: relative !important;
    height: 1.5rem !important;
    min-height: 1.5rem !important;
    overflow: hidden !important;
    width: 100%;
    align-items: center !important;
  }

  [data-cy="cart-reassurance-item-wrapper"] {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    opacity: 0 !important;
    transition: opacity 0.4s ease;
    pointer-events: none;
  }

  [data-cy="cart-reassurance-item-wrapper"].reassurance-active {
    opacity: 1 !important;
    pointer-events: auto;
  }

  [data-cy="cart-reassurance-item"] {
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
    flex-shrink: 0 !important;
  }

  /* Cart items */
  [data-cy="cart-line-item-product"] {
    padding: 1rem !important;
    gap: 0.75rem !important;
    align-items: flex-start !important;
  }

  /* Smaller image - more space for text */
  [data-cy="cart-line-item-product"] > div:first-child {
    width: 56px !important;
    height: 56px !important;
    min-width: 56px !important;
    flex-shrink: 0 !important;
    padding: 0.25rem !important;
    box-sizing: content-box !important;
  }

  /* Text column - constrain to prevent overlap with price */
  [data-cy="cart-line-item-product"] > div:nth-child(2) {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    overflow: hidden !important;
  }

  /* Price column - ensure KOSTENLOS fits, no clipping */
  [data-cy="cart-line-item-product"] > div:last-child {
    flex-shrink: 0 !important;
    min-width: 5.5rem !important;
    max-width: 38% !important;
    overflow: visible !important;
  }

  [data-cy="cart-line-item-product"] {
    overflow: visible !important;
  }

  /* Subscription price block - stack vertically, no overflow */
  [data-cy="price-subscription-lineItem"] {
    flex-direction: column !important;
    align-items: flex-end !important;
    gap: 0.125rem !important;
  }

  [data-cy="product-detail-discount-price"],
  [data-cy="product-detail-regular-price"] {
    white-space: nowrap !important;
    hyphens: none !important;
    overflow: visible !important;
  }

  [data-cy="product-detail-discount-price"] {
    font-size: 0.875rem !important;
  }

  [data-cy="price-line-item"] [data-cy="product-detail-price"] {
    font-size: 0.875rem !important;
  }

  [data-cy="price-line-item"] [data-cy="product-detail-price"] {
    white-space: nowrap !important;
    hyphens: none !important;
  }

  [data-cy="product-title"] {
    font-size: 0.9375rem !important;
    line-height: 1.35 !important;
    margin-bottom: 0.25rem !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    max-width: 100% !important;
  }

  /* Caption - long words wrap, no overflow */
  [data-cy="product-caption"] {
    font-size: 0.75rem !important;
    line-height: 1.5 !important;
    hyphens: none !important;
    -webkit-hyphens: none !important;
    word-wrap: break-word !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    max-width: 100% !important;
  }

  [data-cy="product-caption"] ul {
    padding-left: 0 !important;
    list-style: none !important;
    margin: 0 !important;
  }

  [data-cy="product-caption"] li {
    margin-bottom: 0.2rem !important;
    display: block !important;
    white-space: normal !important;
  }

  /* Caption inline items - stack on mobile */
  [data-cy="product-caption"] li.inline-block {
    display: block !important;
  }

  /* Edit link - no awkward break */
  [data-cy="cart-line-item-product"] [data-cy="button-remove-cart-item"],
  [data-cy="cart-line-item-product"] [data-cy="button-edit-membership"] {
    white-space: nowrap !important;
  }

  /* Gift checkbox */
  [data-cy="gift-options-checkbox"] {
    padding: 1rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
    height: 3.5rem !important;
  }

  /* Order summary - hide title, show only subtotal */
  h2[data-cy="cart-title"]:not(h1) {
    display: none !important;
  }

  [data-cy="cart-total-row"] {
    display: flex !important;
  }

  /* Checkout button */
  [data-cy="button-checkout"] {
    width: 100% !important;
    padding: 1rem 1.5rem !important;
  }

  /* Payment icons */
  .flex.justify-between.items-center.gap-3.md\\:gap-2 {
    justify-content: center !important;
    flex-wrap: wrap !important;
    gap: 0.75rem !important;
  }

  .flex.justify-between.items-center.gap-3.md\\:gap-2 svg {
    height: 28px !important;
  }

  /* Legal footer */
  [data-cy="legal-disclaimers"] {
    font-size: 0.75rem !important;
    padding: 1.5rem 1rem !important;
  }
}
