/* =========================================================
   BABYLONE COMMERCE LAYER — Step 1
   Native cart drawer, cart badge, add-to-cart states
========================================================= */

:root {
    --commerce-z: 9999;
    --commerce-shadow: 0 32px 90px rgba(9, 26, 16, .28);
  }
  
  .cart-link {
    position: relative;
  }
  
  .cart-count-badge {
    position: absolute;
    top: -7px;
    right: -8px;
    min-width: 18px;
    height: 18px;
    display: inline-grid;
    place-items: center;
    padding: 0 5px;
    color: #183a27;
    background: #d0d3a1;
    border: 1px solid rgba(255,255,255,.75);
    border-radius: 999px;
    font-size: 10px;
    font-weight: 900;
    line-height: 1;
    transform: scale(.92);
    transform-origin: center;
    transition: transform .2s var(--ease), opacity .2s ease;
  }
  
  .cart-count-badge[data-count="0"] {
    opacity: 0;
    transform: scale(.65);
  }
  
  .commerce-backdrop {
    position: fixed;
    inset: 0;
    z-index: var(--commerce-z);
    background: rgba(9, 26, 16, .45);
    backdrop-filter: blur(5px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .28s ease;
  }
  
  .commerce-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
  }
  
  .commerce-drawer {
    position: fixed;
    top: 0;
    right: 0;
    z-index: calc(var(--commerce-z) + 1);
    width: min(470px, 100%);
    height: 100dvh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    color: var(--ink);
    background: #f7f2e8;
    box-shadow: var(--commerce-shadow);
    transform: translateX(105%);
    transition: transform .34s var(--ease);
  }
  
  .commerce-drawer.is-open {
    transform: translateX(0);
  }
  
  .commerce-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 24px;
    border-bottom: 1px solid var(--line);
    background: #fff;
  }
  
  .commerce-drawer-title span {
    display: block;
    margin-bottom: 5px;
    color: #747c50;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .14em;
    text-transform: uppercase;
  }
  
  .commerce-drawer-title strong {
    display: block;
    font: 700 31px/1 var(--font-display);
    letter-spacing: -.035em;
  }
  
  .commerce-drawer-close {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink);
    background: #fff;
    font-size: 26px;
    line-height: 1;
  }
  
  .commerce-drawer-close:hover {
    background: #f0eadc;
  }
  
  .commerce-drawer-body {
    min-height: 0;
    overflow: auto;
    padding: 18px;
  }
  
  .commerce-empty {
    min-height: 100%;
    display: grid;
    place-content: center;
    gap: 16px;
    text-align: center;
    padding: 35px;
    color: var(--muted);
  }
  
  .commerce-empty i {
    width: 44px;
    height: 44px;
    margin: 0 auto;
    color: #747c50;
    stroke-width: 1.2;
  }
  
  .commerce-empty strong {
    display: block;
    color: var(--ink);
    font: 700 32px/1 var(--font-display);
  }
  
  .commerce-empty p {
    max-width: 300px;
    font-size: 13px;
    line-height: 1.65;
  }
  
  .commerce-items {
    display: grid;
    gap: 10px;
  }
  
  .commerce-item {
    display: grid;
    grid-template-columns: 86px minmax(0,1fr);
    gap: 14px;
    padding: 12px;
    border: 1px solid var(--line);
    background: #fff;
  }
  
  .commerce-item-image {
    width: 86px;
    height: 86px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(24, 58, 39, .1);
    background: #fbfaf6;
  }
  
  .commerce-item-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px;
  }
  
  .commerce-item-placeholder {
    color: #9aa087;
    font-size: 10px;
  }
  
  .commerce-item-main {
    min-width: 0;
  }
  
  .commerce-item-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
  }
  
  .commerce-item-title {
    display: block;
    color: var(--ink);
    font-size: 13px;
    font-weight: 800;
    line-height: 1.35;
  }
  
  .commerce-item-meta {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.4;
  }
  
  .commerce-item-remove {
    flex: 0 0 auto;
    color: var(--muted);
    border: 0;
    background: transparent;
    font-size: 18px;
    line-height: 1;
  }
  
  .commerce-item-remove:hover {
    color: #8e3f2d;
  }
  
  .commerce-item-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 14px;
  }
  
  .commerce-qty {
    display: inline-grid;
    grid-template-columns: 32px 34px 32px;
    align-items: center;
    border: 1px solid var(--line);
    background: #f7f2e8;
  }
  
  .commerce-qty button {
    height: 32px;
    border: 0;
    background: transparent;
    color: var(--ink);
    font-size: 16px;
  }
  
  .commerce-qty button:hover {
    background: rgba(24, 58, 39, .07);
  }
  
  .commerce-qty span {
    text-align: center;
    font-size: 12px;
    font-weight: 800;
  }
  
  .commerce-item-price {
    font-size: 13px;
    font-weight: 900;
    white-space: nowrap;
  }
  
  .commerce-drawer-foot {
    border-top: 1px solid var(--line);
    background: #fff;
  }
  
  .commerce-progress {
    padding: 16px 20px 0;
  }
  
  .commerce-progress-copy {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 9px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
  }
  
  .commerce-progress-track {
    height: 8px;
    overflow: hidden;
    background: #eee7d9;
  }
  
  .commerce-progress-track span {
    display: block;
    height: 100%;
    width: var(--progress, 0%);
    background: #747c50;
    transition: width .3s ease;
  }
  
  .commerce-summary {
    display: grid;
    gap: 10px;
    padding: 18px 20px 20px;
  }
  
  .commerce-summary-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    color: var(--muted);
    font-size: 12px;
  }
  
  .commerce-summary-row strong {
    color: var(--ink);
    font-size: 20px;
  }
  
  .commerce-checkout {
    width: 100%;
    min-height: 52px;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 18px;
    color: white;
    background: var(--ink);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .05em;
    text-transform: uppercase;
  }
  
  .commerce-checkout:hover {
    background: var(--ink-2);
  }
  
  .commerce-continue {
    width: 100%;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ink);
    border: 1px solid var(--line);
    background: #fff;
    font-size: 11px;
    font-weight: 850;
    letter-spacing: .04em;
    text-transform: uppercase;
  }
  
  .commerce-continue:hover {
    background: #f7f2e8;
  }
  
  .commerce-notice {
    color: var(--muted);
    font-size: 10px;
    line-height: 1.5;
  }
  
  .commerce-toast-stack {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: calc(var(--commerce-z) + 3);
    display: grid;
    gap: 8px;
    pointer-events: none;
  }
  
  .commerce-toast {
    min-width: min(340px, calc(100vw - 36px));
    max-width: 380px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 15px;
    color: white;
    background: #173525;
    box-shadow: 0 20px 50px rgba(9, 26, 16, .25);
    opacity: 0;
    transform: translateY(10px);
    animation: commerceToast 3.2s ease forwards;
  }
  
  .commerce-toast i {
    width: 21px;
    height: 21px;
    color: #d0d3a1;
  }
  
  .commerce-toast strong {
    display: block;
    font-size: 12px;
  }
  
  .commerce-toast span {
    display: block;
    margin-top: 2px;
    color: rgba(255,255,255,.62);
    font-size: 10px;
  }
  
  @keyframes commerceToast {
    0% { opacity: 0; transform: translateY(10px); }
    10%, 88% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(8px); }
  }
  
  /* Product card commerce controls */
  .product-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    margin-top: 14px;
    padding-top: 11px;
    border-top: 1px solid #edf0e9;
  }
  
  .product-add,
  .product-quick {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .04em;
    text-transform: uppercase;
  }
  
  .product-add {
    color: #fff;
    border-color: var(--ink);
    background: var(--ink);
  }
  
  .product-add:hover {
    background: var(--ink-2);
  }
  
  .product-add[disabled] {
    opacity: .45;
    cursor: not-allowed;
  }
  
  .product-add.is-added {
    background: #68704a;
    border-color: #68704a;
  }
  
  .product-quick {
    width: 42px;
    font-size: 18px;
  }
  
  .product-detail-actions {
    display: grid;
    grid-template-columns: 1.15fr .85fr;
    gap: 10px;
    margin-top: 23px;
  }
  
  .product-detail-add,
  .product-detail-store {
    min-height: 50px;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 16px;
    border: 1px solid var(--ink);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .04em;
    text-transform: uppercase;
  }
  
  .product-detail-add {
    color: #fff;
    background: var(--ink);
  }
  
  .product-detail-add:hover {
    background: var(--ink-2);
  }
  
  .product-detail-store {
    color: var(--ink);
    background: #fff;
  }
  
  .product-detail-store:hover {
    background: #f7f2e8;
  }
  
  .product-detail-add[disabled] {
    opacity: .45;
    cursor: not-allowed;
  }
  
  @media (max-width: 560px) {
    .commerce-drawer {
      width: 100%;
    }
  
    .commerce-drawer-head {
      padding: 20px 16px;
    }
  
    .commerce-drawer-body {
      padding: 12px;
    }
  
    .commerce-item {
      grid-template-columns: 74px minmax(0,1fr);
    }
  
    .commerce-item-image {
      width: 74px;
      height: 74px;
    }
  
    .product-actions {
      grid-template-columns: 1fr;
    }
  
    .product-quick {
      width: 100%;
      font-size: 10px;
    }
  
    .product-detail-actions {
      grid-template-columns: 1fr;
    }
  }
  
  @media (prefers-reduced-motion: reduce) {
    .commerce-backdrop,
    .commerce-drawer,
    .cart-count-badge,
    .commerce-progress-track span {
      transition: none;
    }
  
    .commerce-toast {
      animation: none;
      opacity: 1;
      transform: none;
    }
  }