/* ============================================================
   Leaf & Spirit — Cart styles
   Drawer, backdrop, header badge, add-to-cart buttons,
   qty steppers, /cart page layout
   ============================================================ */

/* ── Header actions group (langswitcher + cart, kept together) ── */
.header-actions {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

/* ── Cart toggle button in header ── */
.cart-toggle {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  padding: .3rem .5rem;
  border-radius: 10px;
  transition: color .2s, background .2s;
}
.cart-toggle:hover { color: var(--gold); background: rgba(201,169,110,.1); }
.cart-toggle svg { display: block; }

/* compact "count · total" label next to the bag icon */
.cart-mini {
  display: inline-flex;
  align-items: baseline;
  gap: .35rem;
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
  line-height: 1;
}
.cart-mini-count { color: var(--text); }
.cart-mini-dot { color: var(--text-light); }
.cart-mini-total { color: var(--gold); }
@media (max-width: 560px) {
  .header-actions { gap: .75rem; }
}

/* ── Backdrop ── */
.cart-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(44, 36, 22, .45);
  backdrop-filter: blur(2px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
}
.cart-backdrop.is-open {
  opacity: 1;
  pointer-events: all;
}

/* ── Drawer ── */
.cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  max-width: 100%;
  background: var(--cream);
  box-shadow: -8px 0 40px rgba(44, 36, 22, .18);
  z-index: 201;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .35s cubic-bezier(.4,0,.2,1);
}
.cart-drawer.is-open {
  transform: translateX(0);
}
@media (prefers-reduced-motion: reduce) {
  .cart-drawer { transition: none; }
  .cart-backdrop { transition: none; }
}

.cart-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--gold-light);
}
.cart-drawer-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--text);
}
.cart-drawer-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.5rem;
  color: var(--text-light);
  padding: .2rem .4rem;
  border-radius: 6px;
  transition: color .2s;
  line-height: 1;
}
.cart-drawer-close:hover { color: var(--text); }

/* Empty state */
.cart-drawer-empty {
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--text-light);
  font-size: 1rem;
}

/* Item list */
.cart-drawer-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: .75rem 0;
}
.cart-drawer-item {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: .75rem;
  align-items: start;
  padding: .85rem 1.5rem;
  border-bottom: 1px solid rgba(201,169,110,.18);
}
.cart-drawer-item:last-child { border-bottom: none; }

.cdi-thumb {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--warm-white);
  flex-shrink: 0;
}
.cdi-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cdi-thumb-placeholder {
  width: 100%;
  height: 100%;
  background: var(--gold-light);
}
.cdi-info {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  min-width: 0;
}
.cdi-name {
  font-weight: 600;
  font-size: .95rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cdi-name:hover { color: var(--gold); }
.cdi-weight {
  font-size: .78rem;
  color: var(--text-light);
}
.cdi-unit-price {
  font-size: .82rem;
  color: var(--gold);
}
.cdi-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .4rem;
}
.cdi-qty-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--gold-light);
  border-radius: 50px;
  overflow: hidden;
}
.cdi-qty-btn {
  background: none;
  border: none;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.cdi-qty-btn:hover { background: var(--gold-light); }
.cdi-qty-val {
  font-size: .85rem;
  min-width: 22px;
  text-align: center;
  font-weight: 600;
}
.cdi-subtotal {
  font-weight: 600;
  font-size: .88rem;
  color: var(--text);
}
.cdi-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--text-light);
  line-height: 1;
  padding: 0;
  transition: color .15s;
}
.cdi-remove:hover { color: var(--tea-dark); }

/* Drawer footer */
.cart-drawer-footer {
  border-top: 1px solid var(--gold-light);
  padding: 1.25rem 1.5rem calc(1.25rem + env(safe-area-inset-bottom));
  background: var(--warm-white);
}
.cart-drawer-subtotal {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1rem;
  margin-bottom: 1rem;
}
.cart-drawer-subtotal-label {
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: .07em;
  font-size: .82rem;
}
.cart-drawer-subtotal-amount {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--gold);
}
.btn-cart-checkout {
  display: block;
  width: 100%;
  background: var(--gold);
  color: var(--text);
  border: none;
  padding: .95rem 1.5rem;
  border-radius: 50px;
  font-weight: 600;
  font-size: .88rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  text-align: center;
  cursor: pointer;
  transition: box-shadow .2s, transform .2s;
  text-decoration: none;
}
.btn-cart-checkout:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(201,169,110,.35);
  color: var(--text);
}
.btn-cart-continue {
  display: block;
  text-align: center;
  font-size: .82rem;
  color: var(--text-light);
  margin-top: .75rem;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  padding: .3rem;
  text-decoration: underline;
}
.btn-cart-continue:hover { color: var(--gold); }

/* ── Add-to-cart button (catalog card) ── */
.btn-add-to-cart {
  display: block;
  width: calc(100% - 2rem);
  margin: 0 1rem 1rem;
  background: var(--gold);
  color: var(--text);
  border: none;
  padding: .65rem 1rem;
  border-radius: 50px;
  font-weight: 600;
  font-size: .78rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition: letter-spacing .5s var(--ease-silk),
              transform .5s var(--ease-silk),
              box-shadow .5s var(--ease-silk),
              background-color .4s ease;
}
.btn-add-to-cart:hover {
  background-color: var(--gold-deep);
  color: var(--text);
  letter-spacing: .12em;
  transform: translateY(-2px);
  box-shadow: 0 10px 24px -8px rgba(201,169,110,.5);
}
.btn-add-to-cart:active { transform: translateY(-1px); }
.btn-add-to-cart:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ── Add-to-cart button (product detail) — PRIMARY ── */
.btn-add-to-cart-primary {
  background: var(--gold);
  color: var(--text);
  border: none;
  padding: .95rem 2.3rem;
  border-radius: 50px;
  font-weight: 600;
  letter-spacing: .1em;
  font-size: .82rem;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(61,74,53,.05);
  transition: letter-spacing .55s var(--ease-silk),
              transform .55s var(--ease-silk),
              box-shadow .55s var(--ease-silk),
              background-color .4s ease;
}
.btn-add-to-cart-primary:hover {
  background-color: var(--gold-deep);
  letter-spacing: .15em;
  transform: translateY(-2px);
  box-shadow: 0 14px 34px -10px rgba(201,169,110,.5);
}
.btn-add-to-cart-primary:active { transform: translateY(-1px); }
.btn-add-to-cart-primary:focus-visible { outline: 2px solid var(--tea-dark); outline-offset: 3px; }

/* ── Product card restructure ── */
.product-card-wrapper {
  display: flex;
  flex-direction: column;
  background: var(--warm-white);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--gold-light);
  transition: transform .3s ease, box-shadow .3s ease;
}
.product-card-wrapper:hover {
  box-shadow: 0 8px 26px rgba(61,74,53,.09);
  border-color: var(--gold);
}
.product-card-wrapper.sold-out { opacity: .7; }
.product-card-link {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  text-decoration: none;
  color: inherit;
}
.product-card-link:hover { color: inherit; }
.product-card-link:hover h3 { color: var(--gold); }

/* ── /cart page ── */
.cart-page {
  padding: 3rem 1.5rem 5rem;
}
.cart-page h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  margin-bottom: 2rem;
}
.cart-page-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 3rem;
  align-items: start;
}
@media (max-width: 860px) {
  .cart-page-layout { grid-template-columns: 1fr; }
}
.cart-page-list {
  list-style: none;
  margin-bottom: 1.5rem;
}
.cart-page-item {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 1rem 0;
  border-bottom: 1px solid var(--gold-light);
}
.cart-page-item:last-child { border-bottom: 2px solid var(--gold-light); }
.cpi-thumb {
  width: 80px;
  height: 80px;
  border-radius: 10px;
  overflow: hidden;
  background: var(--warm-white);
}
.cpi-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cpi-thumb-placeholder { width: 100%; height: 100%; background: var(--gold-light); }
.cpi-info { display: flex; flex-direction: column; gap: .2rem; }
.cpi-name { font-weight: 600; font-size: 1rem; color: var(--text); }
.cpi-name:hover { color: var(--gold); }
.cpi-weight { font-size: .8rem; color: var(--text-light); }
.cpi-controls {
  display: flex;
  align-items: center;
  gap: .75rem;
}
/* stepper with the qty × price formula hanging beneath it; the formula is
   absolutely positioned so the stepper itself stays on the total's line */
.cpi-qty-block { position: relative; }
.cpi-unit { position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
  margin-top: .3rem; font-size: .78rem; color: var(--text-light); white-space: nowrap; }
/* fixed-width, right-aligned total: longer prices don't push the stepper */
.cpi-line-total { font-weight: 700; font-size: 1rem; color: var(--gold); white-space: nowrap;
  width: 6.5em; text-align: right; }
.cpi-info { min-width: 0; }
/* Narrow screens: the controls row won't fit beside thumb + info, so drop it
   to a full-width second row (thumb + name on top, controls below). */
@media (max-width: 560px) {
  .cart-page-item {
    grid-template-columns: 64px 1fr;
    grid-template-areas:
      "thumb info"
      "controls controls";
    column-gap: .85rem;
    row-gap: .75rem;
  }
  .cpi-thumb { grid-area: thumb; width: 64px; height: 64px; }
  .cpi-info { grid-area: info; }
  .cpi-controls {
    grid-area: controls;
    flex-wrap: wrap;
    gap: .6rem .9rem;
  }
  .cpi-line-total { margin-left: auto; }
}
.cart-page-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0 2rem;
}
.cart-page-total-label {
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .85rem;
  color: var(--text-light);
}
.cart-page-total-amount {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  color: var(--gold);
}
.cart-page-empty {
  padding: 3rem 0;
  color: var(--text-light);
  font-size: 1.1rem;
}
.cart-page-empty a:not(.btn-cart-browse) { color: var(--gold); }

/* Cart page checkout form panel */
.cart-checkout-panel {
  background: var(--warm-white);
  border: 1px solid var(--gold-light);
  border-radius: 16px;
  padding: 2rem;
  position: sticky;
  top: 120px;
}
.cart-checkout-panel h2 {
  font-size: 1.6rem;
  margin-bottom: 1.5rem;
}
.cart-checkout-panel .form-field { margin-bottom: 1rem; }
.cart-checkout-panel label {
  display: block;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-light);
  margin-bottom: .3rem;
}
.cart-checkout-panel input,
.cart-checkout-panel textarea {
  width: 100%;
  padding: .7rem .9rem;
  border: 1px solid var(--gold-light);
  border-radius: 8px;
  background: var(--cream);
  font: inherit;
  font-size: 1rem; /* keep ≥16px so iOS Safari doesn't auto-zoom on focus */
  color: var(--text);
  transition: border-color .2s;
}
.cart-checkout-panel input:focus,
.cart-checkout-panel textarea:focus {
  outline: none;
  border-color: var(--gold);
}
.cart-checkout-panel textarea { min-height: 90px; resize: vertical; }
.btn-send-order {
  display: block;
  width: 100%;
  background: var(--tea-dark);
  color: var(--cream);
  border: none;
  padding: 1rem 1.5rem;
  border-radius: 50px;
  font-weight: 600;
  font-size: .88rem;
  letter-spacing: .07em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background .2s, transform .2s, box-shadow .2s;
  margin-top: .5rem;
}
.btn-send-order:hover {
  background: var(--gold);
  color: var(--text);
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(201,169,110,.3);
}
.btn-send-order:disabled {
  opacity: .5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ── Toast ── */
.ls-cart-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(1rem);
  background: var(--tea-dark);
  color: var(--cream);
  padding: .7rem 1.5rem;
  border-radius: 50px;
  font-size: .9rem;
  font-weight: 500;
  z-index: 300;
  pointer-events: none;
  opacity: 0;
  transition: opacity .25s, transform .25s;
  white-space: nowrap;
}
.ls-cart-toast--visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
@media (prefers-reduced-motion: reduce) {
  .ls-cart-toast { transition: none; }
}

/* Responsive: drawer full-width on mobile */
@media (max-width: 480px) {
  .cart-drawer { width: 100%; }
}
/* Two-up card grid kicks in at 560px — tighten the card button so its label
   (e.g. the longer "В КОРЗИНУ") fits on one line without overflowing. */
@media (max-width: 560px) {
  .btn-add-to-cart {
    font-size: .72rem;
    letter-spacing: .03em;
    padding: .55rem .5rem;
  }
  .btn-add-to-cart::before { width: .95em; height: .95em; }
  .btn-add-to-cart, .btn-add-to-cart-primary { gap: .35rem; }
}

/* ── Drawer empty state ── */
.cart-drawer-empty-state {
  padding: 3rem 1.5rem 2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  flex: 1;
}
.cart-drawer-browse-link {
  display: inline-block;
  padding: .6rem 1.4rem;
  border: 1px solid var(--gold);
  border-radius: 50px;
  color: var(--gold);
  font-size: .82rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  transition: background .2s, color .2s;
}
.cart-drawer-browse-link:hover {
  background: var(--gold);
  color: var(--text);
}

/* ── Form success message ── */
.notices.success,
.notices.green {
  background: rgba(122,139,110,.15);
  border: 1px solid var(--tea-green);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  color: var(--tea-dark);
  margin-bottom: 1.5rem;
}

/* ── Sticky bar body padding ── */
@media (max-width: 768px) {
  body.has-pdp-sticky { padding-bottom: 80px; }
}

/* ── Cart page empty state improvements ── */
.cart-page-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.25rem;
}
.btn-cart-browse {
  display: inline-block;
  padding: .75rem 1.75rem;
  background: var(--gold);
  color: var(--text);
  border-radius: 50px;
  font-weight: 600;
  font-size: .85rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  transition: transform .2s, box-shadow .2s;
  text-decoration: none;
}
.btn-cart-browse:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(201,169,110,.3);
  color: var(--text);
}

/* ── Order confirmation (shown after a successful checkout) ── */
/* The [hidden] attribute's display:none is otherwise overridden by the explicit
   display on these elements, so re-assert it with a class+attribute selector. */
.cart-page-layout[hidden],
.order-confirmation[hidden] { display: none; }
.order-confirmation {
  max-width: 30rem;
  margin: 2rem auto 4rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  animation: order-confirm-in .6s var(--ease-silk, ease) both;
}
.order-confirmation-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 4.25rem;
  height: 4.25rem;
  border-radius: 50%;
  background: rgba(201,169,110,.14);
  color: var(--gold-deep, var(--gold));
  border: 1px solid rgba(201,169,110,.4);
}
.order-confirmation h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.9rem;
  color: var(--tea-dark);
}
.order-confirmation p {
  margin: 0;
  color: var(--text-light);
  line-height: 1.6;
  max-width: 26rem;
}
.order-confirmation .btn-cart-browse { margin-top: .5rem; }
@keyframes order-confirm-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .order-confirmation { animation: none; }
}

/* ── Bag icon on Add-to-cart buttons ── */
.btn-add-to-cart, .btn-add-to-cart-primary { gap: .5rem; }
.btn-add-to-cart { display: flex; align-items: center; justify-content: center; }
.btn-add-to-cart-primary { display: inline-flex; align-items: center; justify-content: center; }
.btn-add-to-cart::before, .btn-add-to-cart-primary::before {
  content: "";
  width: 1.05em; height: 1.05em; flex-shrink: 0;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4z'/%3E%3Cpath d='M3 6h18'/%3E%3Cpath d='M16 10a4 4 0 0 1-8 0'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 2 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6l-3-4z'/%3E%3Cpath d='M3 6h18'/%3E%3Cpath d='M16 10a4 4 0 0 1-8 0'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* ── Touch devices: enlarge small tap targets (header bag, drawer & cart rows) ── */
@media (any-pointer: coarse), (max-width: 768px) {
  .cart-toggle { min-height: 44px; }
  .cart-drawer-close { min-width: 44px; min-height: 44px; padding: 0; }
  .cdi-qty-btn { width: 40px; height: 40px; }
  .cdi-remove { min-width: 44px; min-height: 44px; }
  .btn-cart-continue { min-height: 44px; }
  .btn-add-to-cart { min-height: 42px; }
}

/* ── Drawer minimizes into the header bag on close (see cart.js closeDrawer) ── */
.cart-drawer.is-minimizing {
  transform: scale(.02);
  opacity: 0;
  pointer-events: none;
  /* opacity holds until the panel is almost at the bag, then snuffs out —
     the whole flight stays visible and it "lands" right on the icon */
  transition: transform .5s cubic-bezier(.45, 0, .6, .25), opacity .05s ease-out .45s;
}
@keyframes cartCatch { 0% { transform: scale(1); } 35% { transform: scale(1.22); } 100% { transform: scale(1); } }
.cart-toggle.cart-caught { animation: cartCatch .4s var(--ease-silk); }

/* P.S. line under the empty-cart joke */
.cart-drawer-empty-ps {
  font-size: .78rem;
  color: var(--text-light);
  padding: 0 1.5rem;
  margin: -2.1rem 0 1.5rem;
  text-align: center;
}
